Core/AI: Added new method for search friendly targets with certain entry and hp pct below a value
This commit is contained in:
@@ -324,53 +324,6 @@ namespace Game.AI
|
|||||||
_isCombatMovementAllowed = allowMovement;
|
_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)
|
// Called at any Damage from any attacker (before damage apply)
|
||||||
public override void DamageTaken(Unit attacker, ref uint damage) { }
|
public override void DamageTaken(Unit attacker, ref uint damage) { }
|
||||||
|
|
||||||
|
|||||||
@@ -3768,6 +3768,15 @@ namespace Game.AI
|
|||||||
return searcher.GetTarget();
|
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<Creature> _list, float range)
|
void DoFindFriendlyCC(List<Creature> _list, float range)
|
||||||
{
|
{
|
||||||
if (me == null)
|
if (me == null)
|
||||||
|
|||||||
@@ -1392,6 +1392,33 @@ namespace Game.Maps
|
|||||||
ulong i_hp;
|
ulong i_hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FriendlyBelowHpPctEntryInRange : ICheck<Unit>
|
||||||
|
{
|
||||||
|
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<Creature>
|
public class FriendlyCCedInRange : ICheck<Creature>
|
||||||
{
|
{
|
||||||
public FriendlyCCedInRange(Unit obj, float range)
|
public FriendlyCCedInRange(Unit obj, float range)
|
||||||
|
|||||||
Reference in New Issue
Block a user