19 #ifndef _THREATMANAGER
20 #define _THREATMANAGER
37 #define THREAT_UPDATE_INTERVAL 1 * IN_MILLISECONDS // Server should send threat update to client periodically each second
55 void addThreat(
float modThreat);
57 void setThreat(
float threat) { addThreat(threat - getThreat()); }
59 void addThreatPercent(
int32 percent);
73 addTempThreat(threat - getThreat());
78 iTempThreatModifier = threat;
79 if (iTempThreatModifier != 0.0f)
80 addThreat(iTempThreatModifier);
85 if (iTempThreatModifier != 0.0f)
87 addThreat(-iTempThreatModifier);
88 iTempThreatModifier = 0.0f;
96 void updateOnlineStatus();
98 void setOnlineOfflineState(
bool isOnline);
100 void setAccessibleState(
bool isAccessible);
112 void removeReference();
132 Unit* GetSourceUnit();
167 return iThreatList.empty();
172 return iThreatList.empty() ?
NULL : iThreatList.front();
182 iThreatList.remove(hostileRef);
187 iThreatList.push_back(hostileRef);
210 void clearReferences();
214 void doAddThreat(
Unit* victim,
float threat);
216 void modifyThreatPercent(
Unit* victim,
int32 percent);
218 float getThreat(
Unit* victim,
bool alsoSearchOfflineList =
false);
224 bool isNeedUpdateToClient(
uint32 time);
230 Unit* getHostilTarget();
232 void tauntApply(
Unit* taunter);
233 void tauntFadeOut(
Unit* taunter);
237 void setDirty(
bool isDirty) { iThreatContainer.setDirty(isDirty); }
240 void resetAllAggro();
243 template<
class PREDICATE>
void resetAggro(PREDICATE predicate)
246 if (threatList.empty())
249 for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
268 void _addThreat(
Unit* victim,
float threat);
bool isOnline() const
Definition: ThreatManager.h:63
HostileReference * getCurrentVictim() const
Definition: ThreatManager.h:226
ThreatContainer & getOnlineContainer()
Definition: ThreatManager.h:265
void modifyThreatPercent(Unit *victim, int32 percent)
Definition: ThreatManager.cpp:452
StorageType iThreatList
Definition: ThreatManager.h:195
void addThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: ThreatManager.cpp:406
void addThreat(float modThreat)
Definition: ThreatManager.cpp:136
SpellSchoolMask
Definition: SharedDefines.h:285
Definition: SpellInfo.h:326
virtual void targetObjectDestroyLink()=0
float getThreat() const
Definition: ThreatManager.h:61
Definition: ThreatManager.h:282
bool empty() const
Definition: ThreatManager.h:165
arena_t NULL
Definition: jemalloc_internal.h:624
ThreatContainer::StorageType const & getThreatList() const
Definition: ThreatManager.h:263
#define false
Definition: CascPort.h:18
bool operator()(HostileReference const *a, HostileReference const *b) const
Definition: ThreatManager.h:286
virtual void sourceObjectDestroyLink()=0
void setDirty(bool isDirty)
Definition: ThreatManager.h:237
void setTempThreat(float threat)
Definition: ThreatManager.h:71
Definition: ThreatManager.h:201
Definition: Creature.h:467
void resetAggro(PREDICATE predicate)
Definition: ThreatManager.h:243
bool isThreatListEmpty() const
Definition: ThreatManager.h:220
void addReference(HostileReference *hostileRef)
Definition: ThreatManager.h:185
uint32 iUpdateTimer
Definition: ThreatManager.h:272
ObjectGuid getUnitGuid() const
Definition: ThreatManager.h:107
Definition: ThreatManager.h:42
float iThreat
Definition: ThreatManager.h:134
void setThreat(float threat)
Definition: ThreatManager.h:57
float iTempThreatModifier
Definition: ThreatManager.h:135
bool iAccessible
Definition: ThreatManager.h:138
float getTempThreatModifier()
Definition: ThreatManager.h:92
~ThreatContainer()
Definition: ThreatManager.h:153
Definition: SharedDefines.h:288
ThreatContainer::StorageType const & getOfflineThreatList() const
Definition: ThreatManager.h:264
ThreatContainer iThreatOfflineContainer
Definition: ThreatManager.h:274
ThreatContainer()
Definition: ThreatManager.h:151
HostileReference * next()
Definition: ThreatManager.h:116
ThreatContainer iThreatContainer
Definition: ThreatManager.h:273
Definition: ThreatManager.h:49
int32_t int32
Definition: Define.h:146
bool operator==(const CoordPair< LIMIT > &p1, const CoordPair< LIMIT > &p2)
Definition: GridDefines.h:160
Definition: Reference.h:27
ObjectGuid iUnitGuid
Definition: ThreatManager.h:136
uint32_t uint32
Definition: Define.h:150
ThreatOrderPred(bool ascending=false)
Definition: ThreatManager.h:285
void clearReferences()
Definition: ThreatManager.cpp:396
HostileReference * iCurrentVictim
Definition: ThreatManager.h:270
const bool m_ascending
Definition: ThreatManager.h:291
Definition: ThreatManager.h:144
std::list< HostileReference * > StorageType
Definition: ThreatManager.h:149
~ThreatManager()
Definition: ThreatManager.h:208
#define TC_GAME_API
Definition: Define.h:134
virtual void targetObjectBuildLink()=0
StorageType const & getThreatList() const
Definition: ThreatManager.h:177
bool iDirty
Definition: ThreatManager.h:196
Unit * GetOwner() const
Definition: ThreatManager.h:228
bool isAccessible() const
Definition: ThreatManager.h:67
HostileReference * getMostHated() const
Definition: ThreatManager.h:170
Definition: ObjectGuid.h:189
void resetTempThreat()
Definition: ThreatManager.h:83
Unit * iOwner
Definition: ThreatManager.h:271
void setDirty(bool isDirty)
Definition: ThreatManager.h:161
bool isDirty() const
Definition: ThreatManager.h:163
Definition: UnitEvents.h:84
ThreatContainer & getOfflineContainer()
Definition: ThreatManager.h:266
void addTempThreat(float threat)
Definition: ThreatManager.h:76
bool iOnline
Definition: ThreatManager.h:137
TO * getTarget() const
Definition: Reference.h:94