diff --git a/Source/Game/AI/ScriptedAI/ScriptedAI.cs b/Source/Game/AI/ScriptedAI/ScriptedAI.cs index 933bf2b82..e0015977c 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedAI.cs @@ -324,53 +324,6 @@ namespace Game.AI _isCombatMovementAllowed = allowMovement; } - /*bool EnterEvadeIfOutOfCombatArea(uint diff) - { - if (_evadeCheckCooldown <= diff) - _evadeCheckCooldown = 2500; - else - { - _evadeCheckCooldown -= diff; - return false; - } - - if (me.IsInEvadeMode() || me.GetVictim() == null) - return false; - - float x = me.GetPositionX(); - float y = me.GetPositionY(); - float z = me.GetPositionZ(); - - switch (me.GetEntry()) - { - case 12017: // broodlord (not move down stairs) - if (z > 448.60f) - return false; - break; - case 19516: // void reaver (calculate from center of room) - if (me.GetDistance2d(432.59f, 371.93f) < 105.0f) - return false; - break; - case 23578: // jan'alai (calculate by Z) - if (z > 12.0f) - return false; - break; - case 28860: // sartharion (calculate box) - if (x > 3218.86f && x < 3275.69f && y < 572.40f && y > 484.68f) - return false; - break; - default: // For most of creatures that certain area is their home area. - Log.outInfo(LogFilter.Server, "Scripts: EnterEvadeIfOutOfCombatArea used for creature entry {0}, but does not have any definition. Using the default one.", me.GetEntry()); - uint homeAreaId = me.GetMap().GetAreaId(me.GetHomePosition().posX, me.GetHomePosition().posY, me.GetHomePosition().posZ); - if (me.GetAreaId() == homeAreaId) - return false; - break; - } - - EnterEvadeMode(); - return true; - }*/ - // Called at any Damage from any attacker (before damage apply) public override void DamageTaken(Unit attacker, ref uint damage) { } diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 99d025df5..4fc760287 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -3768,6 +3768,15 @@ namespace Game.AI return searcher.GetTarget(); } + Unit DoSelectBelowHpPctFriendlyWithEntry(uint entry, float range, byte minHPDiff = 1, bool excludeSelf = true) + { + FriendlyBelowHpPctEntryInRange u_check = new FriendlyBelowHpPctEntryInRange(me, entry, range, minHPDiff, excludeSelf); + UnitLastSearcher searcher = new UnitLastSearcher(me, u_check); + Cell.VisitAllObjects(me, searcher, range); + + return searcher.GetTarget(); + } + void DoFindFriendlyCC(List _list, float range) { if (me == null) diff --git a/Source/Game/Maps/GridNotifiers.cs b/Source/Game/Maps/GridNotifiers.cs index 28a015c6a..abb05765e 100644 --- a/Source/Game/Maps/GridNotifiers.cs +++ b/Source/Game/Maps/GridNotifiers.cs @@ -1392,6 +1392,33 @@ namespace Game.Maps ulong i_hp; } + public class FriendlyBelowHpPctEntryInRange : ICheck + { + public FriendlyBelowHpPctEntryInRange(Unit obj, uint entry, float range, byte pct, bool excludeSelf) + { + i_obj = obj; + i_entry = entry; + i_range = range; + i_pct = pct; + i_excludeSelf = excludeSelf; + } + + public bool Invoke(Unit u) + { + if (i_excludeSelf && i_obj.GetGUID() == u.GetGUID()) + return false; + if (u.GetEntry() == i_entry && u.IsAlive() && u.IsInCombat() && !i_obj.IsHostileTo(u) && i_obj.IsWithinDistInMap(u, i_range) && u.HealthBelowPct(i_pct)) + return true; + return false; + } + + Unit i_obj; + uint i_entry; + float i_range; + byte i_pct; + bool i_excludeSelf; + } + public class FriendlyCCedInRange : ICheck { public FriendlyCCedInRange(Unit obj, float range)