From 902ed74c2adaf2dadcd38f1fb96963f7ec46df07 Mon Sep 17 00:00:00 2001 From: Giacomo Pozzoni Date: Tue, 25 Aug 2020 14:14:06 +0200 Subject: Core/SAI: Implement SMART_TARGET_ACTION_INVOKER in SMART_EVENT_FRIENDLY_HEALTH_PCT (#25318) * Core/SAI: Implement SMART_TARGET_ACTION_INVOKER in SMART_EVENT_FRIENDLY_HEALTH_PCT * Require radius (5th parameter) to be set (cherry picked from commit cbed1039c47f0e3487cea555bb8552a4e6445f5a) --- src/server/game/Grids/Notifiers/GridNotifiers.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/server/game/Grids') diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 08165b08934..2f75b5d7447 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -887,6 +887,27 @@ namespace Trinity uint64 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 FriendlyBelowHpPctEntryInRange { public: -- cgit v1.2.3