diff options
author | ariel- <ariel-@users.noreply.github.com> | 2016-10-06 23:14:51 -0300 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2016-10-06 23:14:51 -0300 |
commit | 3b6fd226bedb689847dadaeeba36a588ee9bc928 (patch) | |
tree | 150c771b9981e66adb69fae74b1a17873b0d7014 /src/server/game/Combat/ThreatManager.cpp | |
parent | f6788b78a6d5237c86ec5ff8c087a0d630f3afeb (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
Diffstat (limited to 'src/server/game/Combat/ThreatManager.cpp')
-rw-r--r-- | src/server/game/Combat/ThreatManager.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index e04e1485d64..fec4ec300cc 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -30,7 +30,7 @@ //============================================================== // The hatingUnit is not used yet -float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float threat, SpellSchoolMask schoolMask, SpellInfo const* threatSpell) +float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float threat, SpellSchoolMask schoolMask, SpellInfo const* threatSpell /*= nullptr*/) { if (threatSpell) { @@ -39,7 +39,7 @@ float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float threat *= threatEntry->pctMod; // Energize is not affected by Mods - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; i++) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (threatSpell->Effects[i].Effect == SPELL_EFFECT_ENERGIZE || threatSpell->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_ENERGIZE) return threat; @@ -50,7 +50,7 @@ float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float return hatedUnit->ApplyTotalThreatModifier(threat, schoolMask); } -bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell) +bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell /*= nullptr*/) { //function deals with adding threat and adding players and pets into ThreatList //mobs, NPCs, guards have ThreatList and HateOfflineList @@ -134,18 +134,20 @@ void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& threatRefSt void HostileReference::addThreat(float modThreat) { + if (!modThreat) + return; + iThreat += modThreat; + // the threat is changed. Source and target unit have to be available // if the link was cut before relink it again if (!isOnline()) updateOnlineStatus(); - if (modThreat != 0.0f) - { - ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, modThreat); - fireStatusChanged(event); - } - if (isValid() && modThreat >= 0.0f) + ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, modThreat); + fireStatusChanged(event); + + if (isValid() && modThreat > 0.0f) { Unit* victimOwner = getTarget()->GetCharmerOrOwner(); if (victimOwner && victimOwner->IsAlive()) @@ -155,9 +157,7 @@ void HostileReference::addThreat(float modThreat) void HostileReference::addThreatPercent(int32 percent) { - float tmpThreat = iThreat; - AddPct(tmpThreat, percent); - addThreat(tmpThreat - iThreat); + addThreat(CalculatePct(iThreat, percent)); } //============================================================ @@ -193,6 +193,7 @@ void HostileReference::updateOnlineStatus() else accessible = true; } + setAccessibleState(accessible); setOnlineOfflineState(online); } @@ -221,7 +222,7 @@ void HostileReference::setAccessibleState(bool isAccessible) { iAccessible = isAccessible; - ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ASSECCIBLE_STATUS, this); + ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ACCESSIBLE_STATUS, this); fireStatusChanged(event); } } |