AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::MostHPMissingGroupInRange Class Reference

#include "GridNotifiers.h"

Public Member Functions

 MostHPMissingGroupInRange (Unit const *obj, float range, uint32 hp)
 
bool operator() (Unit *u)
 

Private Attributes

Unit const * i_obj
 
float i_range
 
uint32 i_hp
 

Detailed Description

Constructor & Destructor Documentation

◆ MostHPMissingGroupInRange()

Acore::MostHPMissingGroupInRange::MostHPMissingGroupInRange ( Unit const *  obj,
float  range,
uint32  hp 
)
inline
1481: i_obj(obj), i_range(range), i_hp(hp) {}
float i_range
Definition: GridNotifiers.h:1523
Unit const * i_obj
Definition: GridNotifiers.h:1522
uint32 i_hp
Definition: GridNotifiers.h:1524

Member Function Documentation

◆ operator()()

bool Acore::MostHPMissingGroupInRange::operator() ( Unit u)
inline
1484 {
1485 if (i_obj == u)
1486 {
1487 return false;
1488 }
1489
1490 Player* player = nullptr;
1491 if (u->IsPlayer())
1492 {
1493 player = u->ToPlayer();
1494 }
1495
1496 else if (u->IsPet() && u->GetOwner())
1497 {
1498 player = u->GetOwner()->ToPlayer();
1499 }
1500
1501 if (!player)
1502 {
1503 return false;
1504 }
1505
1506 Group* group = player->GetGroup();
1507 if (!group || !group->IsMember(i_obj->IsPet() ? i_obj->GetOwnerGUID() : i_obj->GetGUID()))
1508 {
1509 return false;
1510 }
1511
1512 if (u->IsAlive() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
1513 {
1514 i_hp = u->GetMaxHealth() - u->GetHealth();
1515 return true;
1516 }
1517
1518 return false;
1519 }
bool IsPlayer() const
Definition: Object.h:197
Player * ToPlayer()
Definition: Object.h:198
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1321
Definition: Player.h:1064
Group * GetGroup()
Definition: Player.h:2448
Unit * GetOwner() const
Definition: Unit.cpp:10562
bool IsPet() const
Definition: Unit.h:710
uint32 GetMaxHealth() const
Definition: Unit.h:870
bool IsAlive() const
Definition: Unit.h:1204
uint32 GetHealth() const
Definition: Unit.h:869
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1210
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:10198
Definition: Group.h:169
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2336

References Player::GetGroup(), Object::GetGUID(), Unit::GetHealth(), Unit::GetMaxHealth(), Unit::GetOwner(), Unit::GetOwnerGUID(), i_hp, i_obj, i_range, Unit::IsAlive(), Unit::IsHostileTo(), Group::IsMember(), Unit::IsPet(), Object::IsPlayer(), WorldObject::IsWithinDistInMap(), and Object::ToPlayer().

Member Data Documentation

◆ i_hp

uint32 Acore::MostHPMissingGroupInRange::i_hp
private

Referenced by operator()().

◆ i_obj

Unit const* Acore::MostHPMissingGroupInRange::i_obj
private

Referenced by operator()().

◆ i_range

float Acore::MostHPMissingGroupInRange::i_range
private

Referenced by operator()().