public new void SetRevengeTarget(EntityAlive _other) { if (_other) { // Forgive friendly fire, even from explosions. EntityAlive myLeader = EntityUtilities.GetLeaderOrOwner(entityId) as EntityAlive; if (myLeader) { if (myLeader.entityId == _other.entityId) { return; } } if (EntityUtilities.IsAnAlly(entityId, _other.entityId)) { return; } if (_other.IsDead()) { return; } } base.SetRevengeTarget(_other); // Debug.Log("Adding Buff for RevengeTarget() "); Buffs.AddBuff("buffNotifyTeamAttack", -1, true); }
public override void SetAttackTarget(EntityAlive _attackTarget, int _attackTargetTime) { if (_attackTarget != null) { if (_attackTarget.IsDead()) { return; } } if (_attackTarget == null) { // Some of the AI tasks resets the attack target when it falls down stunned; this will prevent the NPC from ignoring its stunned opponent. if (attackTarget != null && attackTarget.IsAlive()) { return; } // Reset the hand held back to their preferred item 0 // EntityUtilities.ChangeHandholdItem(this.entityId, EntityUtilities.Need.Ranged, 0); } base.SetAttackTarget(_attackTarget, _attackTargetTime); // Debug.Log("Adding Buff for Attack Target() "); Buffs.AddBuff("buffNotifyTeamAttack", -1, true); }
public override void SetRevengeTarget(EntityAlive _other) { if (_other) { // Forgive friendly fire, even from explosions. EntityAlive myLeader = EntityUtilities.GetLeaderOrOwner(entityId) as EntityAlive; if (myLeader) { if (myLeader.entityId == _other.entityId) { return; } } if (EntityUtilities.IsAnAlly(entityId, _other.entityId)) { return; } if (_other.IsDead()) { return; } } //if (_other == null) //{ // // Reset the hand held back to their preferred item 0 // EntityUtilities.ChangeHandholdItem(this.entityId, EntityUtilities.Need.Ranged, 0); //} base.SetRevengeTarget(_other); // Debug.Log("Adding Buff for RevengeTarget() "); Buffs.AddBuff("buffNotifyTeamAttack", -1, true); }
public bool CheckSurroundingEntities() { this.NearbyEntities.Clear(); EntityAlive leader = EntityUtilities.GetLeaderOrOwner(this.theEntity.entityId) as EntityAlive; if (!leader) { return(false); } // Search in the bounds are to try to find the most appealing entity to follow. Bounds bb = new Bounds(this.theEntity.position, new Vector3(this.theEntity.GetSeeDistance(), 20f, this.theEntity.GetSeeDistance())); //Bounds bb = new Bounds(this.theEntity.position, new Vector3(20f, 20f,20f)); this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities); DisplayLog(" Nearby Entities: " + this.NearbyEntities.Count); for (int i = this.NearbyEntities.Count - 1; i >= 0; i--) { EntityAlive x = (EntityAlive)this.NearbyEntities[i]; if (x != this.theEntity) { if (x.IsDead()) { continue; } DisplayLog("Nearby Entity: " + x.EntityName); if (x.GetAttackTarget() == leader) { DisplayLog(" My leader is being attacked by " + x.ToString()); targetEntity = x; this.theEntity.SetRevengeTarget(targetEntity); return(true); } if (x.GetRevengeTarget() == leader) { DisplayLog(" My leader is being avenged by " + x.ToString()); targetEntity = x; this.theEntity.SetRevengeTarget(targetEntity); return(true); } if (x.GetDamagedTarget() == leader) { DisplayLog(" My leader is being attacked by something that damaged it " + x.ToString()); targetEntity = x; this.theEntity.SetRevengeTarget(targetEntity); return(true); } } } return(false); }
public bool CheckSurroundingEntities() { this.NearbyEntities.Clear(); NearbyEnemies.Clear(); EntityAlive leader = EntityUtilities.GetLeaderOrOwner(this.theEntity.entityId) as EntityAlive; float originalView = this.theEntity.GetMaxViewAngle(); this.theEntity.SetMaxViewAngle(360f); // Search in the bounds are to try to find the most appealing entity to follow. Bounds bb = new Bounds(this.theEntity.position, new Vector3(20f, 20f, 20f)); this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities); DisplayLog(" Nearby Entities: " + this.NearbyEntities.Count); for (int i = this.NearbyEntities.Count - 1; i >= 0; i--) { EntityAlive x = (EntityAlive)this.NearbyEntities[i]; if (x is EntityVehicle) { continue; } if (x.IsDead()) { continue; } if (x != this.theEntity && x.IsAlive()) { if (leader != null && x == leader) { continue; } if (x.CanSee(this.theEntity.position)) { DisplayLog(" I can be seen by an enemy."); if (!this.theEntity.CanSee(x.position)) { DisplayLog(" I know an entity is there, but I can't see it: " + x.EntityName); continue; } } DisplayLog("Nearby Entity: " + x.EntityName); if (CheckFactionForEnemy(x)) { NearbyEnemies.Add(x); } } } this.theEntity.SetMaxViewAngle(originalView); return(NearestEnemy()); }
public static void PlayerCheck() { try { if (!IsRunning) { IsRunning = true; List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null && _cInfoList.Count > 0) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0) { EntityAlive _player = PersistentOperations.GetPlayerAlive(_cInfo.playerId); if (_player != null) { if (!_player.IsDead()) { if (_player.IsSpawned() && _player.IsAlive()) { if (Zones.IsEnabled) { Zones.ZoneCheck(_cInfo, _player); } if (Lobby.IsEnabled) { Lobby.LobbyCheck(_cInfo, _player); } if (Market.IsEnabled) { Market.MarketCheck(_cInfo, _player); } } } else if (BloodmoonWarrior.IsEnabled && BloodmoonWarrior.WarriorList.Contains(_cInfo.playerId)) { BloodmoonWarrior.WarriorList.Remove(_cInfo.playerId); BloodmoonWarrior.KilledZombies.Remove(_cInfo.playerId); } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in PersistentOperations.PlayerCheck: {0}", e.Message)); } IsRunning = false; }
// Enables the entity, and checks if we have root motion enabled or not. public void SwitchModelAndView(string _modelName, bool _bFPV, bool _bMale) { Log("Running Switch and Model View"); // If Root MOtion is enabled on this entity, initialize it. if (entityAlive.RootMotion) { Log("Enabling Root Motion..."); var avatarRootMotion = bipedTransform.GetComponent <AvatarRootMotion>(); if (avatarRootMotion == null) { avatarRootMotion = bipedTransform.gameObject.AddComponent <AvatarRootMotion>(); } avatarRootMotion.Init(this, anim); Log("Enabled Root Motion"); } anim.SetBool("IsDead", entityAlive.IsDead()); anim.SetBool("IsAlive", entityAlive.IsAlive()); assignBodyParts(); //// Add in support for animations that can fire weapons if (rightHandItemTransform != null) { Log("Reading Right hand Items to equipment weapons"); Debug.Log("Setting Right hand position"); //Debug.Log("RIGHTHAND ITEM TRANSFORM"); rightHandItemTransform.parent = rightHandItemTransform; var position = AnimationGunjointOffsetData.AnimationGunjointOffset[entityAlive.inventory.holdingItem.HoldType.Value].position; var rotation = AnimationGunjointOffsetData.AnimationGunjointOffset[entityAlive.inventory.holdingItem.HoldType.Value].rotation; rightHandItemTransform.localPosition = position; rightHandItemTransform.localEulerAngles = rotation; SetInRightHand(this.rightHandItemTransform); } }
public IEnumerator DestroyAround(EntityAlive ctrl) { running = true; // Actions are static, is this fine ? FIXME: There should be one per giant ! Printer.Log(35, "MinEventActionGiantDestroy", ctrl, ctrl.GetPosition()); Bounds Bounds = ctrl.boundingBox; // check: not affected by rescale ! Vector3 dir = SdtdUtils.EffectsEntity.MoveDir(ctrl); Vector3 pos = ctrl.GetPosition(); int ymax = (int)Math.Floor(ctrl.boundingBox.size.y * ctrl.gameObject.transform.localScale.y); // how to enumerate x,z wrt direction ?? h is ok foreach (int p in SdtdUtils.EffectsGround.LR(4)) { foreach (int q in SdtdUtils.EffectsGround.LR(4)) { Vector3 where = new Vector3(pos.x + p, pos.y, pos.z + q); if (!aigu(dir.x, dir.z, where.x - pos.x, where.z - pos.z)) { continue; // test not depending on y } for (int y = 0; y < ymax; y++) // TODO adjust by current giant ratio { Printer.Log(30, "MinEventActionGiantDestroy at", p, q, y); where.y = pos.y + y; Vector3i iwhere = Vectors.ToInt(where); BlockValue block = World.GetBlock(iwhere); if (block.type != 0) { DamageBlock(ctrl, iwhere); } // todo: passer block et bv a DamageBlock } DamageEnts(ctrl); yield return(new WaitForSeconds(0.2f)); if (ctrl == null || ctrl.IsDead()) { yield break; } } } running = false; }
public static bool Prefix(ref bool __result, ManagedZombie mz) { EntityAlive zombie = mz.zombie; if (!zombie || zombie.IsDead() || zombie.IsDespawned || !zombie.gameObject) { return(true); } // Check if the zombie has an attack or revenge target, and if not, allow them to target a player. EntityAlive entity = EntityUtilities.GetAttackOrReventTarget(zombie.entityId) as EntityAlive; if (entity == null) { return(true); } __result = true; return(false); }
public override void SetAttackTarget(EntityAlive _attackTarget, int _attackTargetTime) { if (_attackTarget != null) { if (_attackTarget.IsDead()) { return; } } if (_attackTarget == null) { // Reset the hand held back to their preferred item 0 EntityUtilities.ChangeHandholdItem(this.entityId, EntityUtilities.Need.Ranged, 0); } base.SetAttackTarget(_attackTarget, _attackTargetTime); // Debug.Log("Adding Buff for Attack Target() "); Buffs.AddBuff("buffNotifyTeamAttack", -1, true); }
public override IEnumerator Regen(EntityPlayer player, Vector3i zchunk, int iniguess) { Vector3 ppos = player.GetPosition(); Vector3 where = new Vector3(this.centerx, ppos.y, this.centerz); if ((ppos - where).magnitude > 50f) { Printer.Log(45, "Giant too far ", this.centerx, this.centerz, "from player ", ppos); yield break; } Bounds area = new Bounds(where, new Vector3(20, 20, 20)); Printer.Log(40, "EntityPool.Update"); EntityPool.Update(area); if (EntityPool.Entities[0] != null) { EntityAlive giant = (EntityAlive)EntityPool.Entities[0]; // could be null if not alive ?! if (giant == null) { Printer.Print("giant is not alive !"); } else { Printer.Log(40, "giant buff", giant); if (giant.IsDead()) { yield break; } if (!giant.Buffs.HasBuff(opt.OptionEntity.buff)) { giant.Buffs.AddBuff(opt.OptionEntity.buff); } } yield return(new WaitForSeconds(2f)); } }
public EntityAlive GetMasterEntity() { if (masterEntity != null) { try { if (masterEntity.IsDespawned) { // master entity despawned if (debug) { Debug.Log("Master entity despawned"); } masterEntity = null; //hasFlock = false; -> never does this, or it would start spawning new children } else if (masterEntity.IsDead()) { if (debug) { Debug.Log("Master entity died"); } masterEntity = null; //hasFlock = false; -> never does this, or it would start spawning new children } } catch (Exception ex) { if (debug) { Debug.Log("WARNING: Master entity doesn't exist? - " + ex.Message); } } } return(masterEntity); }
public new EntityAlive GetMasterEntity() { if (masterEntity != null) { try { if (masterEntity.IsDespawned) { // master entity despawned if (debug) { Debug.Log("Master entity despawned"); } masterEntity = null; hasFlock = false; } else if (masterEntity.IsDead()) { if (debug) { Debug.Log("Master entity died"); } masterEntity = null; hasFlock = false; } } catch (Exception ex) { if (debug) { Debug.Log("WARNING: Master entity doesn't exist? - " + ex.Message); } } } return(masterEntity); }
public new void SetAttackTarget(EntityAlive _attackTarget, int _attackTargetTime) { if (_attackTarget != null) { if (_attackTarget.IsDead()) { return; } } if (_attackTarget == null) { // Some of the AI tasks resets the attack target when it falls down stunned; this will prevent the NPC from ignoring its stunned opponent. if (attackTarget != null && attackTarget.IsAlive()) { return; } } base.SetAttackTarget(_attackTarget, _attackTargetTime); // Debug.Log("Adding Buff for Attack Target() "); Buffs.AddBuff("buffNotifyTeamAttack", -1, true); }
public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt) { Zombiome.Routines.Start(Particles._Next(player), "RandomSize-Particles"); if (target is EntityZombie || target is EntityAnimal) { if (!target.IsDead()) { SdtdUtils.EffectsItem.SpawnParticle(target.GetPosition(), "wire_tool_sparks", biome.groundColor, "electric_fence_impact"); int index = rand.RandomRange(buffs.Length); // target.Buffs.AddBuff(buffs[index]); // rm others, otherwise they would set back scaling=1 when gone but the neew buff still runs for (int k = 0; k < buffs.Length; k++) { if (k != index && target.Buffs.HasBuff(buffs[k])) { target.Buffs.RemoveBuff(buffs[k]); } } target.Buffs.AddBuff(buffs[index]); } } yield break; }
public void FindAndKillSurroundingEntities() { //if (entityDamage == 0 || entityVehicle.lastControllerVelocityMagnitude < 5f || Time.time - entityHitAgainDelay < lastEntityHitTime) if (entityDamage == 0 || lastControllerVelocityMagnitude < entityHitMinSpeed) { //DebugMsg("NOT damaging entity: entityDamage = " + entityDamage.ToString() + " | lastControllerVelocityMagnitude = " + entityVehicle.lastControllerVelocityMagnitude.ToString("0.000")); return; } else { //DebugMsg("lastControllerVelocityMagnitude = " + entityVehicle.lastControllerVelocityMagnitude.ToString("0.000")); } // Try-catch for now because of an error with Bandits and survivors try { Vector3 b = new Vector3(0f, entityVehicle.m_characterController.height / 2f, 0f); RaycastHit raycastHit; //if (Physics.CapsuleCast(entityVehicle.position - b, entityVehicle.position + b, destructionRadius, entityVehicle.motion.normalized, out raycastHit, entityVehicle.motion.magnitude, -1) && raycastHit.collider != null) if (Physics.CapsuleCast(entityVehicle.position - b, entityVehicle.position + b, destructionRadius, entityVehicle.motion.normalized, out raycastHit, destructionRadius + 1, -1) && raycastHit.collider != null) { RootTransformRefEntity component = raycastHit.collider.gameObject.GetComponent <RootTransformRefEntity>(); if (component) { EntityAlive entityAlive = component.RootTransform.GetComponent <Entity>() as EntityAlive; //if (entityAlive != null && entityAlive != entityVehicle.AttachedEntities && entityAlive.Spawned && !entityAlive.IsDead()) if (entityAlive != null && entityAlive != entityVehicle.AttachedEntities && !entityAlive.IsDead() && !(entityAlive.entityId == lastHitEntityId && Time.time - entityHitAgainDelay < lastEntityHitTime)) { int damage = entityDamage; entityHitSpeedRatio = CustomVehiclesUtils.GetRatio(Mathf.Clamp(lastControllerVelocityMagnitude, entityHitMinSpeed, 18f), entityHitMinSpeed, 18f) + 1f; entityHitDamage = Mathf.RoundToInt((float)damage * entityHitSpeedRatio); bool isCritical = lastControllerVelocityMagnitude > entityCriticalHitMinSpeed; // Doing this in order to properly kill entities. Otherwise they die instantly without animation, and animal corpses disappear. if (entityHitDamage > entityAlive.Health) { entityHitDamage = entityAlive.Health; isCritical = true; } DamageSourceEntity damageSourceEntity; if (isCritical) { damageSourceEntity = new DamageSourceEntity(EnumDamageSourceType.Melee, entityVehicle.player.entityId, -raycastHit.normal); } else { damageSourceEntity = new DamageSourceEntity(EnumDamageSourceType.Melee, entityVehicle.player.entityId, -raycastHit.normal, raycastHit.transform.name, raycastHit.point, Vector2.zero); } //DamageSourceEntity damageSourceEntity = new DamageSourceEntity(EnumDamageSourceType.Melee, entityVehicle.player.entityId, -raycastHit.normal, raycastHit.transform.name, raycastHit.point, Vector2.zero); lastHitEntityId = entityAlive.entityId; entityAlive.DamageEntity(damageSourceEntity, entityHitDamage, isCritical, isCritical? 3f : 2f); //DebugMsg("Damage Entity: " + entityAlive.entityId + " | lastControllerVelocityMagnitude = " + lastControllerVelocityMagnitude.ToString("0.000") + " (hit speed ratio = " + entityHitSpeedRatio.ToString("0.000") // + ") | damage = " + entityHitDamage.ToString("0.000") + " (" + entityAlive.Health.ToString() + "/" + entityAlive.GetMaxHealth().ToString() + ") | hit transform name = " + raycastHit.transform.name + " | critical = " + isCritical.ToString()); float vehDmg = (((float)entityAlive.GetMaxHealth()) / 3000.0f) * vehicleDamageFactor_entities * entityHitSpeedRatio; DamageVehicle(vehDmg, 2f); lastEntityHitTime = Time.time; } } } } catch (System.Exception e) { Debug.LogError("An error occurred: " + e); } }
public bool CheckSurroundingEntities() { this.NearbyEntities.Clear(); NearbyEnemies.Clear(); EntityAlive leader = null; if (this.theEntity.Buffs.HasCustomVar("Leader")) { DisplayLog(" leader Detected."); int EntityID = (int)this.theEntity.Buffs.GetCustomVar("Leader"); leader = this.theEntity.world.GetEntity(EntityID) as EntityAlive; } // Search in the bounds are to try to find the most appealing entity to follow. Bounds bb = new Bounds(this.theEntity.position, new Vector3(this.theEntity.GetSeeDistance(), 20f, this.theEntity.GetSeeDistance())); this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities); DisplayLog(" Nearby Entities: " + this.NearbyEntities.Count); for (int i = this.NearbyEntities.Count - 1; i >= 0; i--) { EntityAlive x = (EntityAlive)this.NearbyEntities[i]; if (x != this.theEntity && x.IsAlive()) { if (x == leader) { continue; } DisplayLog("Nearby Entity: " + x.EntityName); if (CheckFactionForEnemy(x)) { NearbyEnemies.Add(x); } } // if one of our faction died, flee from the spot. if (x.factionId == this.theEntity.factionId) { if (x.GetRevengeTarget() != null) { DisplayLog(" My Faction has a Revenge Target. I am sharing it. "); this.fleeDistance = 100; this.theEntity.SetRevengeTarget(x.GetRevengeTarget()); this.avoidEntity = x.GetRevengeTarget(); return(true); } if (x.IsDead()) { //DisplayLog(" One of my factions has died. Fleeing, and abandoning the herd"); //this.fleeDistance = 100; //if (x.entityThatKilledMe != null) //{ // DisplayLog(" I am fleeing: " + x.entityThatKilledMe.EntityName); // this.avoidEntity = x.entityThatKilledMe; //} //else //{ DisplayLog(" I don not know who killed my friend, so i am running from " + x.EntityName); this.avoidEntity = x; // } return(true); } } } return(NearestEnemy()); }
private void GetIsAlive(EntityAlive entityAlive) => Bin.Add("IsAlive", IsAlive = !entityAlive.IsDead());