public override void Activate() { // Not yet active, so teleport to first target if (!Activated) { Activated = true; var target = EntUtils.FindEntityByTargetName(null, Target); //Added this null check because missing targets would cause crashes - Solokiller if (target != null) { Target = target.Target; CurrentTarget.Set(target);// keep track of this since path corners change our target for us. SetOrigin(target.Origin - ((Mins + Maxs) * 0.5f)); } if (string.IsNullOrEmpty(TargetName)) { // not triggered, so start immediately SetNextThink(GetLastThink() + 0.1f); SetThink(Next); } else { SpawnFlags |= SF.WaitRetrigger; } } }
private static bool InTransitionVolume(BaseEntity pEntity, string volumeName) { if ((pEntity.ObjectCaps() & EntityCapabilities.ForceTransition) != 0) { return(true); } // If you're following another entity, follow it through the transition (weapons follow the player) if (pEntity.MoveType == MoveType.Follow && pEntity.AimEntity != null) { pEntity = pEntity.AimEntity; } var inVolume = true; // Unless we find a trigger_transition, everything is in the volume for (BaseEntity volume = null; (volume = EntUtils.FindEntityByTargetName(volume, volumeName)) != null;) { if (volume.ClassName == "trigger_transition") { if (volume.Intersects(pEntity)) // It touches one, it's in the volume { return(true); } else { inVolume = false; // Found a trigger_transition, but I don't intersect it -- if I don't find another, don't go! } } } return(inVolume); }
public override void Initialize(IServiceProvider serviceProvider) { ServiceProvider = serviceProvider; Engine.Server = ServiceProvider.GetRequiredService <IEngineServer>(); Engine.Globals = ServiceProvider.GetRequiredService <IGlobalVars>(); Engine.FileSystem = ServiceProvider.GetRequiredService <IFileSystem>(); Server.Game.Engine.Trace.EngineTrace = ServiceProvider.GetRequiredService <ITrace>(); Engine.EntityDictionary = ServiceProvider.GetRequiredService <IEntityDictionary>(); Engine.EntityRegistry = ServiceProvider.GetRequiredService <IEntityRegistry>(); Engine.Entities = ServiceProvider.GetRequiredService <IEngineEntities>(); Engine.Sound = ServiceProvider.GetRequiredService <ISoundSystem>(); CVar.EngineCVar = ServiceProvider.GetRequiredService <ICVar>(); NetMessage.EngineNetworking = ServiceProvider.GetRequiredService <IEngineNetworking>(); NetMessage.NetworkMessages = ServiceProvider.GetRequiredService <INetworkMessages>(); EntUtils.Initialize(ServiceProvider.GetRequiredService <IEntityDictionary>()); SetupFileSystem(); Globals.g_psv_gravity = CVar.GetCVar("sv_gravity"); Globals.g_psv_aim = CVar.GetCVar("sv_aim"); Globals.g_footsteps = CVar.GetCVar("mp_footsteps"); //Set up our own entities var entities = EntityRegistryUtils.CollectEntityClasses(Assembly.GetExecutingAssembly()); entities.ForEach(i => Engine.EntityRegistry.AddEntityClass(i)); //Link messages now so it gets done LinkUserMessages(); }
/// <summary> /// Designers were using this to fire targets that may or may not exist -- /// so I changed it to use the standard target fire code, made it a little simpler. /// </summary> private void ManagerThink() { var time = Engine.Globals.Time - StartTime; while (Index < Targets.Count && Targets[Index].Delay <= time) { EntUtils.FireTargets(Targets[Index].Name, Activator, this, UseType.Toggle, 0); ++Index; } if (Index >= Targets.Count)// have we fired all targets? { SetThink(null); if (IsClone) { EntUtils.Remove(this); return; } SetUse(ManagerUse);// allow manager re-use } else { SetNextThink(StartTime + Targets[Index].Delay); } }
public override void Use(BaseEntity pActivator, BaseEntity pCaller, UseType useType, float value) { if (!string.IsNullOrEmpty(Target)) { for (BaseEntity target = null; (target = EntUtils.FindEntityByTargetName(target, Target)) != null;) { if ((SpawnFlags & SF.MaskFX) == 0) { target.RenderEffect = RenderEffect; } if ((SpawnFlags & SF.MaskAmount) == 0) { target.RenderAmount = RenderAmount; } if ((SpawnFlags & SF.MaskMode) == 0) { target.RenderMode = RenderMode; } if ((SpawnFlags & SF.MaskColor) == 0) { target.RenderColor = RenderColor; } } } }
private void PlayTrack() { EntUtils.PlayCDTrack((int)Health); SetTouch(null); EntUtils.Remove(this); }
private void TeleportTouch(BaseEntity pOther) { // Only teleport monsters or clients if ((pOther.Flags & (EntFlags.Client | EntFlags.Monster)) == 0) { return; } if (!EntUtils.IsMasterTriggered(Master, pOther)) { return; } if ((SpawnFlags & SF.AllowMonsters) == 0) {// no monsters allowed! if ((pOther.Flags & EntFlags.Monster) != 0) { return; } } if ((SpawnFlags & SF.NoClients) != 0) {// no clients allowed if (pOther.IsPlayer()) { return; } } var target = EntUtils.FindEntityByTargetName(null, Target); if (target == null) { return; } var tmp = target.Origin; if (pOther.IsPlayer()) { tmp.z -= pOther.Mins.z;// make origin adjustments in case the teleportee is a player. (origin in center, not at feet) } tmp.z++; pOther.Flags &= ~EntFlags.OnGround; pOther.SetOrigin(tmp); pOther.Angles = target.Angles; if (pOther.IsPlayer()) { pOther.ViewAngle = target.ViewAngle; } pOther.FixAngle = FixAngleMode.ForceViewAngles; pOther.Velocity = pOther.BaseVelocity = WorldConstants.g_vecZero; }
public BattleConflict(EntController contA, EntController contB, EntUtils.ColliderType typeA, EntUtils.ColliderType typeB) { _Pair = new BattleConflictPair( new BattleConflictAgitator(contA, typeA), new BattleConflictAgitator(contB, typeB)); }
public override void Use(BaseEntity pActivator, BaseEntity pCaller, UseType useType, float value) { SUB_UseTargets(this, TriggerType); if ((SpawnFlags & SF.FireOnce) != 0) { EntUtils.Remove(this); } }
public static void DeactivateSatchels(BasePlayer pOwner) { for (BaseEntity entity = null; (entity = EntUtils.FindEntityByClassName(entity, "monster_satchel")) != null;) { if (entity is SatchelCharge satchel && satchel.Owner == pOwner) { satchel.Deactivate(); } } }
private void WaitAtNode() { var target = CurrentTarget.Entity; // Fire the pass target if there is one if (!string.IsNullOrEmpty(target.Message)) { EntUtils.FireTargets(target.Message, this, this, UseType.Toggle, 0); if ((target.SpawnFlags & PathCorner.SF.FireOnce) != 0) { target.Message = string.Empty; } } // need pointer to LAST target. if ((target.SpawnFlags & SF.WaitRetrigger) != 0 || (SpawnFlags & SF.WaitRetrigger) != 0) { SpawnFlags |= SF.WaitRetrigger; // clear the sound channel. if (!string.IsNullOrEmpty(NoiseMoving)) { StopSound(SoundChannel.Static, NoiseMoving); } if (!string.IsNullOrEmpty(NoiseArrived)) { EmitSound(SoundChannel.Voice, NoiseArrived, Volume); } SetNextThink(0); return; } // Log.Alert ( AlertType.Console, "%f\n", Wait ); if (Wait != 0) {// -1 wait will wait forever! SetNextThink(GetLastThink() + Wait); if (!string.IsNullOrEmpty(NoiseMoving)) { StopSound(SoundChannel.Static, NoiseMoving); } if (!string.IsNullOrEmpty(NoiseArrived)) { EmitSound(SoundChannel.Voice, NoiseArrived, Volume); } SetThink(Next); } else { Next();// do it RIGHT now! } }
/// <summary> /// Called when a new client connects (unsquelches its entity for everyone) /// </summary> /// <param name="edict"></param> public void ClientConnected(Edict edict) { var index = EntUtils.EntIndex(edict) - 1; var data = Players[index]; // Clear out everything we use for deltas on this guy. data.WantEnable = true; data.SentGameRulesMasks = new BitVector32(); data.SentBanMasks = new BitVector32(); }
public override void Think() { if (GlobalState == null || Globals.GlobalState.EntityGetState(GlobalState) == GlobalEState.On) { SUB_UseTargets(this, TriggerType, 0); if ((SpawnFlags & SF.FireOnce) != 0) { EntUtils.Remove(this); } } }
private void Smoke() { if ((SpawnFlags & SF.NoSmoke) == 0) { TempEntity.Smoke(Origin, (short)Globals.g_sModelIndexSmoke, SpriteScale, 12); } if ((SpawnFlags & SF.Repeatable) == 0) { EntUtils.Remove(this); } }
public override void Use(BaseEntity pActivator, BaseEntity pCaller, UseType useType, float value) { ModelName = null; //invisible Solid = Solid.Not; // intangible var vecSpot = Origin + new Vector(0, 0, 8); // trace starts here! Server.Game.Engine.Trace.Line(vecSpot, vecSpot + new Vector(0, 0, -40), TraceFlags.IgnoreMonsters, Edict(), out var tr); // Pull out of the wall a bit if (tr.Fraction != 1.0) { Origin = tr.EndPos + (tr.PlaneNormal * (Magnitude - 24) * 0.6); } // draw decal if ((SpawnFlags & SF.NoDecal) == 0) { if (EngineRandom.Float(0, 1) < 0.5f) { EntUtils.DecalTrace(tr, Decal.Scorch1); } else { EntUtils.DecalTrace(tr, Decal.Scorch2); } } // draw fireball TempEntity.Explosion(Origin, (short)Globals.g_sModelIndexFireball, (SpawnFlags & SF.NoFireball) == 0 ? SpriteScale : 0, 15); // do damage if ((SpawnFlags & SF.NoDamage) == 0) { RadiusDamage(this, this, Magnitude, EntityClass.None, DamageTypes.Blast); } SetThink(Smoke); SetNextThink(Engine.Globals.Time + 0.3f); // draw sparks if ((SpawnFlags & SF.NoSparks) == 0) { int sparkCount = EngineRandom.Long(0, 3); for (var i = 0; i < sparkCount; ++i) { Create("spark_shower", Origin, tr.PlaneNormal); } } }
private static BaseEntity FindLandmark(string landmarkName) { for (BaseEntity landmark = null; (landmark = EntUtils.FindEntityByTargetName(landmark, landmarkName)) != null;) { // Found the landmark if (landmark.ClassName == "info_landmark") { return(landmark); } } Log.Alert(AlertType.Error, $"Can't find landmark {landmarkName}\n"); return(null); }
public override void Think() { TempEntity.Sparks(Origin); Speed -= 0.1f; if (Speed > 0) { SetNextThink(Engine.Globals.Time + 0.1f); } else { EntUtils.Remove(this); } Flags &= ~EntFlags.OnGround; }
public override void Spawn() { EntUtils.SetMovedir(this); InitTrigger(); SetNextThink(0); Speed = 200; Height = 150; if (!string.IsNullOrEmpty(TargetName)) { // if targeted, spawn turned off Solid = Solid.Not; SetOrigin(Origin); // Unlink from trigger list SetUse(ToggleUse); } }
/// <summary> /// only plays for ONE client, so only use in single play! /// </summary> public override void Think() { // manually find the single player. var client = EntUtils.IndexEnt(1); // Can't play if the client is not connected! if (client == null) { return; } SetNextThink(Engine.Globals.Time + 0.5f); if ((client.Origin - Origin).Length() <= Scale) { Play(); } }
private void Register() { SetThink(SUB_DoNothing); // search for all entities which target this multisource (TargetName) for (BaseEntity entity = null; (entity = EntUtils.FindEntityByString(entity, "target", TargetName)) != null;) { Entities.Add(new MultiEntity(entity)); } for (BaseEntity entity = null; (entity = EntUtils.FindEntityByString(entity, "classname", "multi_manager")) != null;) { if (entity.HasTarget(TargetName)) { Entities.Add(new MultiEntity(entity)); } } SpawnFlags &= ~SF.Init; }
public static void RegisterConflict(EntController contA, EntController contB, EntUtils.ColliderType typeA, EntUtils.ColliderType typeB) { if (Logging) { Debug.LogFormat("[CONFLICT] Attempt to register\n{0}{1}{2} ({3}{4}{5}) - {6}{7}{8} ({9}{10}{11})", LOG_CONTROLLER_PREFIX, contA.name, LOG_CONTROLLER_SUFFIX, LOG_BEHAVIOUR_PREFIX, typeA, LOG_BEHAVIOUR_SUFFIX, LOG_CONTROLLER_PREFIX, contB.name, LOG_CONTROLLER_SUFFIX, LOG_BEHAVIOUR_PREFIX, typeB, LOG_BEHAVIOUR_SUFFIX ); } BattleConflict conflict = new BattleConflict(contA, contB, typeA, typeB); if (!CollectionUtils.Contains(_Conflicts, conflict)) { _Conflicts.Add(new BattleConflict(contA, contB, typeA, typeB)); if (Logging) { Debug.Log("[CONFLICT] accepted count now " + _Conflicts.Count); } } else if (Logging) { Debug.Log("[CONFLICT] rejected"); } }
public override bool KeyValue(string key, string value) { // UNDONE: Maybe this should do something like this: // if (!base.KeyValue(key, value)) // ... etc. if (key == "wait") { float.TryParse(value, out Wait); return(true); } // add this field to the target list // this assumes that additional fields are targetnames and their values are delay values. //Hammer appends #<number> to the end of keys with the same name to differentiate, remove that EntUtils.StripToken(key, out var target); float.TryParse(value, out var delay); Targets.Add(new MultiTarget { Name = key, Delay = delay }); return(true); }
//called by worldspawn public static void W_Precache() { memset(BasePlayerItem::ItemInfoArray, 0, sizeof(BasePlayerItem::ItemInfoArray)); memset(BasePlayerItem::AmmoInfoArray, 0, sizeof(BasePlayerItem::AmmoInfoArray)); Globals.giAmmoIndex = 0; // custom items... // common world objects EntUtils.PrecacheOther("item_suit"); EntUtils.PrecacheOther("item_battery"); EntUtils.PrecacheOther("item_antidote"); EntUtils.PrecacheOther("item_security"); EntUtils.PrecacheOther("item_longjump"); // shotgun UTIL_PrecacheOtherWeapon("weapon_shotgun"); EntUtils.PrecacheOther("ammo_buckshot"); // crowbar UTIL_PrecacheOtherWeapon("weapon_crowbar"); // glock UTIL_PrecacheOtherWeapon("weapon_9mmhandgun"); EntUtils.PrecacheOther("ammo_9mmclip"); // mp5 UTIL_PrecacheOtherWeapon("weapon_9mmAR"); EntUtils.PrecacheOther("ammo_9mmAR"); EntUtils.PrecacheOther("ammo_ARgrenades"); #if !OEM_BUILD && !HLDEMO_BUILD // python UTIL_PrecacheOtherWeapon("weapon_357"); EntUtils.PrecacheOther("ammo_357"); #endif #if !OEM_BUILD && !HLDEMO_BUILD // gauss UTIL_PrecacheOtherWeapon("weapon_gauss"); EntUtils.PrecacheOther("ammo_gaussclip"); #endif #if !OEM_BUILD && !HLDEMO_BUILD // rpg UTIL_PrecacheOtherWeapon("weapon_rpg"); EntUtils.PrecacheOther("ammo_rpgclip"); #endif #if !OEM_BUILD && !HLDEMO_BUILD // crossbow UTIL_PrecacheOtherWeapon("weapon_crossbow"); EntUtils.PrecacheOther("ammo_crossbow"); #endif #if !OEM_BUILD && !HLDEMO_BUILD // egon UTIL_PrecacheOtherWeapon("weapon_egon"); #endif // tripmine UTIL_PrecacheOtherWeapon("weapon_tripmine"); #if !OEM_BUILD && !HLDEMO_BUILD // satchel charge UTIL_PrecacheOtherWeapon("weapon_satchel"); #endif // hand grenade UTIL_PrecacheOtherWeapon("weapon_handgrenade"); #if !OEM_BUILD && !HLDEMO_BUILD // squeak grenade UTIL_PrecacheOtherWeapon("weapon_snark"); #endif #if !OEM_BUILD && !HLDEMO_BUILD // hornetgun UTIL_PrecacheOtherWeapon("weapon_hornetgun"); #endif #if !OEM_BUILD && !HLDEMO_BUILD if (Engine.GameRules.IsDeathmatch()) { EntUtils.PrecacheOther("weaponbox");// container for dropped deathmatch weapons } #endif Globals.g_sModelIndexFireball = Engine.Server.PrecacheModel("sprites/zerogxplode.spr"); // fireball Globals.g_sModelIndexWExplosion = Engine.Server.PrecacheModel("sprites/WXplo1.spr"); // underwater fireball Globals.g_sModelIndexSmoke = Engine.Server.PrecacheModel("sprites/steam1.spr"); // smoke Globals.g_sModelIndexBubbles = Engine.Server.PrecacheModel("sprites/bubble.spr"); //bubbles Globals.g_sModelIndexBloodSpray = Engine.Server.PrecacheModel("sprites/bloodspray.spr"); // initial blood Globals.g_sModelIndexBloodDrop = Engine.Server.PrecacheModel("sprites/blood.spr"); // splattered blood Globals.g_sModelIndexLaser = Engine.Server.PrecacheModel(Globals.g_pModelNameLaser); Globals.g_sModelIndexLaserDot = Engine.Server.PrecacheModel("sprites/laserdot.spr"); // used by explosions Engine.Server.PrecacheModel("models/grenade.mdl"); Engine.Server.PrecacheModel("sprites/explode1.spr"); Engine.Server.PrecacheSound("weapons/debris1.wav"); // explosion aftermaths Engine.Server.PrecacheSound("weapons/debris2.wav"); // explosion aftermaths Engine.Server.PrecacheSound("weapons/debris3.wav"); // explosion aftermaths Engine.Server.PrecacheSound("weapons/grenade_hit1.wav"); //grenade Engine.Server.PrecacheSound("weapons/grenade_hit2.wav"); //grenade Engine.Server.PrecacheSound("weapons/grenade_hit3.wav"); //grenade Engine.Server.PrecacheSound("weapons/bullet_hit1.wav"); // hit by bullet Engine.Server.PrecacheSound("weapons/bullet_hit2.wav"); // hit by bullet Engine.Server.PrecacheSound("items/weapondrop1.wav"); // weapon falls to the ground }
public void SetAbsBox(Edict pent) { var entity = pent.TryGetEntity(); if (entity == null) { throw new InvalidOperationException($"Error: Entity \"{pent.Vars.ClassName}\" (index {EntUtils.EntIndex(pent)}) has no entity instance assigned for SetAbsBox call"); } entity.SetObjectCollisionBox(); }
public override void Think() { SUB_UseTargets(this, UseType.Toggle, 0); EntUtils.Remove(this); }
public override object GetData(int actionType) { //return base.GetData(actionType); ResponseObj = new TransObj(); StringBuilder sql; ExcelLoader exLoader; string path; int cat, i = 0; try { switch ((ActionType)actionType) { case ActionType.GetCatalog: #region GetCatalog GeneralController catController = new CatalogsController(); //cat = int.Parse(RequestObj.TransParms.Where(p => p.Key == "cat").FirstOrDefault().Value); catController.RequestObj = this.RequestObj; return(catController.GetData((int)CatalogsController.ActionType.GetCatalog)); #endregion case ActionType.GetWorksheets: #region GetWorksheets path = JsonConvert.DeserializeObject <string>(RequestObj.TransParms.Where(p => p.Key == "fName").FirstOrDefault().Value); exLoader = new ExcelLoader(); return(exLoader.LoadWorkSheets(path)); #endregion case ActionType.ImportDespachos: #region ImportDespachos path = JsonConvert.DeserializeObject <string>(RequestObj.TransParms.Where(p => p.Key == "fName").FirstOrDefault().Value); string workSheet = JsonConvert.DeserializeObject <string>(RequestObj.TransParms.Where(p => p.Key == "workSheet").FirstOrDefault().Value); exLoader = new ExcelLoader(); DtDespachosIn = exLoader.LoadFile(path, workSheet); return(true); #endregion case ActionType.LoadRemitente: #region LoadRemitente var clts = Entities.Database.SqlQuery <GeneralCat>(SQL_GET_CLIENTES).ToList(); clts.Insert(0, new GeneralCat { catId = -1, catVal = "Seleccione..." }); return(clts); #endregion case ActionType.LoadCitiesFullName: #region LoadCitiesFullName CitiesFullNames = Entities.Database.SqlQuery <GeneralCat>(SQL_CIUDADES).ToList(); #endregion break; case ActionType.LoadProveedores: #region LoadProveedores Proveedores = Entities.Database.SqlQuery <GeneralCat>(string.Format(SQL_PROVEEDORES, ClienteID)).ToList(); #endregion break; case ActionType.IsInDespacho: #region IsInDespacho ConsecCliente = Entities.Database.SqlQuery <string>(SQL_IS_IN_DESPACHO, ClienteID).ToList(); #endregion break; case ActionType.InsertDespachos: #region InsertDespachos //int cId = JsonConvert.DeserializeObject<int>(RequestObj.TransParms.Where(p => p.Key == "cId").FirstOrDefault().Value); DataRow r = null; sql = new StringBuilder(); string s = "", conCliente = ""; try { for (i = 0; i < DtDespachosOut.Rows.Count; i++) { r = DtDespachosOut.Rows[i]; if (r[COL_CONSECUTIVO_CLIENTE].ToString().Trim().Length == 0) { continue; } conCliente = r[COL_CONSECUTIVO_CLIENTE].ToString(); var e = Entities.LGC_DESPACHO. Where(d => d.CONSECUTIVO_CLIENTE == conCliente) .FirstOrDefault(); if (e != null) { sql.Clear(); throw new GeneralControllerException(string.Format("El registro en la fila {0} ya existe.(Consec:{1})", i + 1, conCliente)); } s = string.Format(SQL_IN_DESPACHO, ClienteID, EntUtils.GetStrFromDtRow(r, GV_COL_CONSECUTIVO), EntUtils.GetStrFromDtRow(r, GV_COL_CONSECUTVO_AVMK), EntUtils.GetStrFromDtRow(r, GV_COL_CONSECUTIVO_CLIENTE), EntUtils.GetDTFromDtRow(r, GV_COL_FECHA_ENVIO_ARCHIVO, false).Value.ToString("dd/MM/yyyy"), "", "", EntUtils.GetDTFromDtRow(r, GV_COL_FECHA_DE_REDENCION, false).Value.ToString("dd/MM/yyyy"), EntUtils.GetStrFromDtRow(r, GV_COL_CEDULA), EntUtils.GetStrFromDtRow(r, GV_COL_CLIENTE), EntUtils.GetStrFromDtRow(r, GV_COL_ENTREGAR_A), EntUtils.GetStrFromDtRow(r, GV_COL_DIRECCION), EntUtils.GetStrFromDtRow(r, GV_COL_CIUDAD), EntUtils.GetIntFromDtRow(r, GV_COL_DEPARTAMENTO), EntUtils.GetStrFromDtRow(r, GV_COL_TELEFONO), EntUtils.GetStrFromDtRow(r, GV_COL_CELULAR), EntUtils.GetStrFromDtRow(r, GV_COL_CORREO_ELECTRONICO), EntUtils.GetStrFromDtRow(r, GV_COL_CODIGO_PREMIO), EntUtils.GetStrFromDtRow(r, GV_COL_PREMIO), EntUtils.GetStrFromDtRow(r, GV_COL_ESPECIFICACIONES), EntUtils.GetIntFromDtRow(r, GV_COL_PROVEEDOR), EntUtils.GetIntFromDtRow(r, GV_COL_CANTIDAD), EntUtils.GetIntFromDtRow(r, GV_COL_VALOR), ClienteID); sql.Append(s); } DataBaseUtils dbUtils = new DataBaseUtils(); return(dbUtils.RunScriptFromStngBldr(sql, Entities)); } catch (Exception ex) { string rData = ""; if (r != null) { rData = string.Join("|", r.ItemArray); } throw new Exception(string.Format("Error en fila {0}. [{1}] ", i + 1, rData) + ex.Message); } #endregion default: break; } } catch (Exception ex) { throw ex; } return(ResponseObj); }
public override bool IsTriggered(BaseEntity pActivator) { return(EntUtils.IsMasterTriggered(NetName, pActivator)); }
public BattleConflictAgitator(EntController agitator, EntUtils.ColliderType colliderType) { Controller = agitator; Behaviour = agitator.CurrentBehaviour; ColliderType = colliderType; }
//TODO: could move these to BaseEntity public void RadiusDamage(BaseEntity inflictor, BaseEntity attacker, float damage, EntityClass classIgnore, DamageTypes damageTypes) { EntUtils.RadiusDamage(Origin, inflictor, attacker, damage, damage * 2.5f, classIgnore, damageTypes); }
/// <summary> /// This has grown into a complicated beast /// Can we make this more elegant? /// This builds the list of all transitions on this level and which entities are in their PVS's and can / should /// be moved across. /// </summary> /// <returns></returns> private static IList <Transition> ChangeList() { var transitions = new List <Transition>(); // Find all of the possible level changes on this BSP for (ChangeLevel changeLevel = null; (changeLevel = (ChangeLevel)EntUtils.FindEntityByClassName(changeLevel, "trigger_changelevel")) != null;) { // Find the corresponding landmark var landmark = FindLandmark(changeLevel.LandmarkName); if (landmark != null) { // Build a list of unique transitions if (AddTransitionToList(transitions, changeLevel.MapName, changeLevel.LandmarkName, landmark)) { } } } //TODO: implement when persistence system is implemented #if false if (transitions.Count > 0 && Engine.Globals.SaveData != IntPtr.Zero && ((SAVERESTOREDATA *)gpGlobals->pSaveData)->pTable) { CSave saveHelper((SAVERESTOREDATA *)gpGlobals->pSaveData); for (var i = 0; i < transitions.Count; ++i) { var transition = transitions[i]; // Follow the linked list of entities in the PVS of the transition landmark // Build a list of valid entities in this linked list (we're going to use entity.Chain again) for (var entity = EntUtils.EntitiesInPVS(transition.Landmark); entity != null; entity = entity.Chain) { //Log.Alert(AlertType.Console, $"Trying {entity.ClassName}\n"); var caps = entity.ObjectCaps(); if ((caps & EntityCapabilities.DontSave) == 0) { var flags = EntTableFlags.None; // If this entity can be moved or is global, mark it if ((caps & EntityCapabilities.AcrossTransition) != 0) { flags |= EntTableFlags.Moveable; } if (!string.IsNullOrEmpty(entity.GlobalName) && !entity.IsDormant()) { flags |= EntTableFlags.Global; } if (flags != 0) { // Check to make sure the entity isn't screened out by a trigger_transition if (InTransitionVolume(entity, transition.LandmarkName)) { // Mark entity table with 1<<i var index = saveHelper.EntityIndex(entity); // Flag it with the level number saveHelper.EntityFlagsSet(index, flags | (EntTableFlags)(1 << i)); } //else // Log.Alert(AlertType.Console, $"Screened out {pEntList[j].ClassName}\n"); } //else // Log.Alert(AlertType.Console, $"Failed {pEntity.ClassName}\n"); } //else // Log.Alert(AlertType.Console, $"DON'T SAVE {pEntity.ClassName}\n"); } } } #endif return(transitions); }
private void Play() { EntUtils.PlayCDTrack((int)Health); EntUtils.Remove(this); }
private void ChangeLevelNow(BaseEntity pActivator) { //The original version stored off the arguments for ChangeLevel because it referenced the strings directly //The current engine build queues up a changelevel server command, and no longer requires the strings to stick around //So we don't have to do that anymore Debug.Assert(!string.IsNullOrEmpty(MapName)); // Don't work in deathmatch if (Engine.GameRules.IsDeathmatch()) { return; } // Some people are firing these multiple times in a frame, disable if (Engine.Globals.Time == DamageTime) { return; } DamageTime = Engine.Globals.Time; //TODO: needs revisiting for multiplayer changelevel - Solokiller var pPlayer = EntUtils.IndexEnt(1); if (!InTransitionVolume(pPlayer, LandmarkName)) { Log.Alert(AlertType.AIConsole, $"Player isn't in the transition volume {LandmarkName}, aborting\n"); return; } // Create an entity to fire the changetarget if (!string.IsNullOrEmpty(ChangeTarget)) { var fireAndDie = Engine.EntityRegistry.CreateInstance <FireAndDie>(); if (fireAndDie != null) { // Set target and delay fireAndDie.Target = ChangeTarget; fireAndDie.Delay = ChangeTargetDelay; fireAndDie.Origin = pPlayer.Origin; // Call spawn EntUtils.DispatchSpawn(fireAndDie.Edict()); } } Activator.Set(pActivator); SUB_UseTargets(pActivator, UseType.Toggle, 0); // look for a landmark entity var landmark = FindLandmark(LandmarkName); if (landmark != null) { Engine.Globals.LandmarkOffset = landmark.Origin; } var landmarkName = landmark != null ? LandmarkName : string.Empty; // Log.Alert(AlertType.Console, $"Level touches {ChangeList(levels, 16)} levels\n"); Log.Alert(AlertType.Console, $"CHANGE LEVEL: {MapName} {landmarkName}\n"); Engine.Server.ChangeLevel(MapName, LandmarkName); }