using System; using System.Linq; using ACE.Server.Entity; using ACE.Entity.Enum; using ACE.Entity.Enum.Properties; namespace ACE.Server.WorldObjects { /// /// Handles player->monster visibility checks /// partial class Player { /// /// Wakes up any monsters within the applicable range /// public void CheckMonsters() { if (!Attackable || Teleporting) return; var visibleObjs = PhysicsObj.ObjMaint.GetVisibleObjectsValuesOfTypeCreature(); foreach (var monster in visibleObjs) { if (monster is Player) continue; //if (Location.SquaredDistanceTo(monster.Location) <= monster.VisualAwarenessRangeSq) if (PhysicsObj.get_distance_sq_to_object(monster.PhysicsObj, true) <= monster.VisualAwarenessRangeSq) AlertMonster(monster); } } /// /// Called when this player attacks a monster /// public void OnAttackMonster(Creature monster) { if (monster == null || !Attackable) return; /*Console.WriteLine($"{Name}.OnAttackMonster({monster.Name})"); Console.WriteLine($"Attackable: {monster.Attackable}"); Console.WriteLine($"Tolerance: {monster.Tolerance}");*/ // faction mobs will retaliate against players belonging to the same faction if (SameFaction(monster)) monster.AddRetaliateTarget(this); if (monster.MonsterState != State.Awake && (monster.Tolerance & PlayerCombatPet_RetaliateExclude) == 0) { monster.AttackTarget = this; monster.WakeUp(); } } } }