fix(Scripts/Naxxramas): Patchwerk's Hateful Strike target selection (#25429)

This commit is contained in:
sogladev
2026-05-02 20:41:35 +02:00
committed by GitHub
parent 43aa645660
commit 1c66fdd45b
2 changed files with 52 additions and 38 deletions

View File

@@ -2310,6 +2310,32 @@ namespace Acore
private:
bool const _ascending;
};
// Binary predicate for sorting Units based on current value of health
class HealthOrderPred
{
public:
HealthOrderPred(bool ascending = true) : _ascending(ascending) { }
bool operator()(WorldObject const* objA, WorldObject const* objB) const
{
Unit const* a = objA->ToUnit();
Unit const* b = objB->ToUnit();
uint32 rA = a ? a->GetHealth() : 0;
uint32 rB = b ? b->GetHealth() : 0;
return _ascending ? rA < rB : rA > rB;
}
bool operator() (Unit const* a, Unit const* b) const
{
uint32 rA = a ? a->GetHealth() : 0;
uint32 rB = b ? b->GetHealth() : 0;
return _ascending ? rA < rB : rA > rB;
}
private:
bool const _ascending;
};
}
class RedirectSpellEvent : public BasicEvent