public bool CheckSurroundingEntities() { this.NearbyEntities.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; } if (leader == null) { DisplayLog(" No leader detected."); 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())); 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) { 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(); 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); }