mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-28 16:16:27 +00:00
feat(Core/SmartScripts): Improvements to SMART_EVENT_FRIENDLY_HEALTH_PCT: (#11171)
* Added new parameter: radius. * The event can be used with SMART_TARGET_SELF and SMART_TARGET_ACTION_INVOKER target types. * Closes #5270
This commit is contained in:
@@ -787,6 +787,30 @@ namespace Acore
|
||||
uint32 i_hp;
|
||||
};
|
||||
|
||||
class MostHPPercentMissingInRange
|
||||
{
|
||||
public:
|
||||
MostHPPercentMissingInRange(Unit const* obj, float range, uint32 minHpPct, uint32 maxHpPct) :
|
||||
i_obj(obj), i_range(range), i_minHpPct(minHpPct), i_maxHpPct(maxHpPct), i_hpPct(101.f) { }
|
||||
|
||||
bool operator()(Unit* u)
|
||||
{
|
||||
if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
|
||||
i_minHpPct <= u->GetHealthPct() && u->GetHealthPct() <= i_maxHpPct && u->GetHealthPct() < i_hpPct)
|
||||
{
|
||||
i_hpPct = u->GetHealthPct();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
Unit const* i_obj;
|
||||
float i_range;
|
||||
float i_minHpPct, i_maxHpPct, i_hpPct;
|
||||
};
|
||||
|
||||
class FriendlyCCedInRange
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user