mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/AI: Added new method for search friendly targets with certain entry and hp pct below a value (#18310)
(cherry picked from commit e7024f8a4c)
This commit is contained in:
@@ -360,6 +360,16 @@ Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff)
|
||||
return unit;
|
||||
}
|
||||
|
||||
Unit* ScriptedAI::DoSelectBelowHpPctFriendlyWithEntry(uint32 entry, float range, uint8 minHPDiff, bool excludeSelf)
|
||||
{
|
||||
Unit* unit = nullptr;
|
||||
Trinity::FriendlyBelowHpPctEntryInRange u_check(me, entry, range, minHPDiff, excludeSelf);
|
||||
Trinity::UnitLastSearcher<Trinity::FriendlyBelowHpPctEntryInRange> searcher(me, unit, u_check);
|
||||
Cell::VisitAllObjects(me, searcher, range);
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range)
|
||||
{
|
||||
std::list<Creature*> list;
|
||||
@@ -422,54 +432,6 @@ enum NPCs
|
||||
NPC_SARTHARION = 28860
|
||||
};
|
||||
|
||||
// Hacklike storage used for misc creatures that are expected to evade of outside of a certain area.
|
||||
// It is assumed the information is found elswehere and can be handled by the core. So far no luck finding such information/way to extract it.
|
||||
/*bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff)
|
||||
{
|
||||
if (_evadeCheckCooldown <= diff)
|
||||
_evadeCheckCooldown = 2500;
|
||||
else
|
||||
{
|
||||
_evadeCheckCooldown -= diff;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (me->IsInEvadeMode() || !me->GetVictim())
|
||||
return false;
|
||||
|
||||
float x = me->GetPositionX();
|
||||
float y = me->GetPositionY();
|
||||
float z = me->GetPositionZ();
|
||||
|
||||
switch (me->GetEntry())
|
||||
{
|
||||
case NPC_BROODLORD: // broodlord (not move down stairs)
|
||||
if (z > 448.60f)
|
||||
return false;
|
||||
break;
|
||||
case NPC_VOID_REAVER: // void reaver (calculate from center of room)
|
||||
if (me->GetDistance2d(432.59f, 371.93f) < 105.0f)
|
||||
return false;
|
||||
break;
|
||||
case NPC_JAN_ALAI: // jan'alai (calculate by Z)
|
||||
if (z > 12.0f)
|
||||
return false;
|
||||
break;
|
||||
case NPC_SARTHARION: // 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.
|
||||
TC_LOG_INFO("misc", "TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition. Using the default one.", me->GetEntry());
|
||||
uint32 homeAreaId = me->GetMap()->GetAreaId(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY(), me->GetHomePosition().GetPositionZ());
|
||||
if (me->GetAreaId() == homeAreaId)
|
||||
return false;
|
||||
}
|
||||
|
||||
EnterEvadeMode();
|
||||
return true;
|
||||
}*/
|
||||
|
||||
// BossAI - for instanced bosses
|
||||
BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature),
|
||||
instance(creature->GetInstanceScript()),
|
||||
|
||||
@@ -223,6 +223,9 @@ struct TC_GAME_API ScriptedAI : public CreatureAI
|
||||
//Returns friendly unit with the most amount of hp missing from max hp
|
||||
Unit* DoSelectLowestHpFriendly(float range, uint32 minHPDiff = 1);
|
||||
|
||||
//Returns friendly unit with hp pct below specified and with specified entry
|
||||
Unit* DoSelectBelowHpPctFriendlyWithEntry(uint32 entry, float range, uint8 hpPct = 1, bool excludeSelf = true);
|
||||
|
||||
//Returns a list of friendly CC'd units within range
|
||||
std::list<Creature*> DoFindFriendlyCC(float range);
|
||||
|
||||
|
||||
@@ -804,6 +804,28 @@ namespace Trinity
|
||||
uint64 i_hp;
|
||||
};
|
||||
|
||||
class FriendlyBelowHpPctEntryInRange
|
||||
{
|
||||
public:
|
||||
FriendlyBelowHpPctEntryInRange(Unit const* obj, uint32 entry, float range, uint8 pct, bool excludeSelf) : i_obj(obj), i_entry(entry), i_range(range), i_pct(pct), i_excludeSelf(excludeSelf) { }
|
||||
|
||||
bool operator()(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;
|
||||
}
|
||||
|
||||
private:
|
||||
Unit const* i_obj;
|
||||
uint32 i_entry;
|
||||
float i_range;
|
||||
uint8 i_pct;
|
||||
bool i_excludeSelf;
|
||||
};
|
||||
|
||||
class FriendlyCCedInRange
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user