aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Combat/ThreatManager.h
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2016-10-06 23:14:51 -0300
committerjoschiwald <joschiwald.trinity@gmail.com>2017-08-21 21:49:36 +0200
commitec3dc0a43101dcbe2e469891acf0b654106eccfc (patch)
tree88f8c416d14b54fc5a71ba7f7cdb039aa66af44c /src/server/game/Combat/ThreatManager.h
parentab916fd1b37ca39071c2253be68e60ac2a735ada (diff)
Core/Misc: fix interaction of spells like Shadowmeld with Threat reducing effects
- SPELL_AURA_MOD_TOTAL_THREAT should be temporary and not added/subtracted from total, only computed - Cleanup of reference related code - Kill getLast() and reverse iterator obsevers, LinkedList iterator can't be used as a standard reverse_iterator (ie with operator++). They weren't used anyways (cherry picked from commit 3b6fd226bedb689847dadaeeba36a588ee9bc928) # Conflicts: # src/server/game/Combat/ThreatManager.cpp # src/server/game/Loot/LootMgr.h
Diffstat (limited to 'src/server/game/Combat/ThreatManager.h')
-rw-r--r--src/server/game/Combat/ThreatManager.h37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h
index 493192248ca..4b739d192c1 100644
--- a/src/server/game/Combat/ThreatManager.h
+++ b/src/server/game/Combat/ThreatManager.h
@@ -41,8 +41,8 @@ class SpellInfo;
struct TC_GAME_API ThreatCalcHelper
{
- static float calcThreat(Unit* hatedUnit, Unit* hatingUnit, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* threatSpell = NULL);
- static bool isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell = NULL);
+ static float calcThreat(Unit* hatedUnit, Unit* hatingUnit, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* threatSpell = nullptr);
+ static bool isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell = nullptr);
};
//==============================================================
@@ -54,11 +54,11 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
//=================================================
void addThreat(float modThreat);
- void setThreat(float threat) { addThreat(threat - getThreat()); }
+ void setThreat(float threat) { addThreat(threat - iThreat); }
void addThreatPercent(int32 percent);
- float getThreat() const { return iThreat; }
+ float getThreat() const { return iThreat + iTempThreatModifier; }
bool isOnline() const { return iOnline; }
@@ -66,27 +66,27 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
// in this case online = true, but accessible = false
bool isAccessible() const { return iAccessible; }
- // used for temporary setting a threat and reducting it later again.
+ // used for temporary setting a threat and reducing it later again.
// the threat modification is stored
void setTempThreat(float threat)
{
- addTempThreat(threat - getThreat());
+ addTempThreat(threat - iTempThreatModifier);
}
void addTempThreat(float threat)
{
- iTempThreatModifier = threat;
- if (iTempThreatModifier != 0.0f)
- addThreat(iTempThreatModifier);
+ if (!threat)
+ return;
+
+ iTempThreatModifier += threat;
+
+ ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, threat);
+ fireStatusChanged(event);
}
void resetTempThreat()
{
- if (iTempThreatModifier != 0.0f)
- {
- addThreat(-iTempThreatModifier);
- iTempThreatModifier = 0.0f;
- }
+ addTempThreat(-iTempThreatModifier);
}
float getTempThreatModifier() { return iTempThreatModifier; }
@@ -100,7 +100,7 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
void setAccessibleState(bool isAccessible);
//=================================================
- bool operator == (const HostileReference& hostileRef) const { return hostileRef.getUnitGuid() == getUnitGuid(); }
+ bool operator==(HostileReference const& hostileRef) const { return hostileRef.getUnitGuid() == getUnitGuid(); }
//=================================================
@@ -113,7 +113,7 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
//=================================================
- HostileReference* next() { return ((HostileReference*) Reference<Unit, ThreatManager>::next()); }
+ HostileReference* next() { return static_cast<HostileReference*>(Reference<Unit, ThreatManager>::next()); }
//=================================================
@@ -125,14 +125,17 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
// Tell our refFrom (source) object, that the link is cut (Target destroyed)
void sourceObjectDestroyLink() override;
+
private:
// Inform the source, that the status of that reference was changed
void fireStatusChanged(ThreatRefStatusChangeEvent& threatRefStatusChangeEvent);
Unit* GetSourceUnit();
+
private:
float iThreat;
- float iTempThreatModifier; // used for taunt
+ float iTempThreatModifier; // used for SPELL_AURA_MOD_TOTAL_THREAT
+
ObjectGuid iUnitGuid;
bool iOnline;
bool iAccessible;