fix(Spell/Core): Prayer of Mending Heal not smart Healing [TC Cherry Pick] (#8753)

Co-authored by @Keader
This commit is contained in:
acidmanifesto
2021-11-04 13:24:24 -04:00
committed by GitHub
parent 98f28456bb
commit 8ac01da463
3 changed files with 93 additions and 5 deletions

View File

@@ -22,6 +22,7 @@
#include "CreatureAI.h"
#include "DynamicObject.h"
#include "GameObject.h"
#include "Group.h"
#include "Object.h"
#include "ObjectGridLoader.h"
#include "Optional.h"
@@ -1351,6 +1352,55 @@ namespace Acore
float m_fRange;
};
class MostHPMissingGroupInRange
{
public:
MostHPMissingGroupInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) {}
bool operator()(Unit* u)
{
if (i_obj == u)
{
return false;
}
Player* player = nullptr;
if (u->GetTypeId() == TYPEID_PLAYER)
{
player = u->ToPlayer();
}
else if (u->IsPet() && u->GetOwner())
{
player = u->GetOwner()->ToPlayer();
}
if (!player)
{
return false;
}
Group* group = player->GetGroup();
if (!group || !group->IsMember(i_obj->IsPet() ? i_obj->GetOwnerGUID() : i_obj->GetGUID()))
{
return false;
}
if (u->IsAlive() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
{
i_hp = u->GetMaxHealth() - u->GetHealth();
return true;
}
return false;
}
private:
Unit const* i_obj;
float i_range;
uint32 i_hp;
};
class AllDeadCreaturesInRange
{
public: