aboutsummaryrefslogtreecommitdiff
path: root/src/game/ThreatManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/ThreatManager.cpp')
-rw-r--r--src/game/ThreatManager.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp
index a0459aa81dc..60c46c2307d 100644
--- a/src/game/ThreatManager.cpp
+++ b/src/game/ThreatManager.cpp
@@ -34,11 +34,9 @@
// The pHatingUnit is not used yet
float ThreatCalcHelper::calcThreat(Unit* pHatedUnit, Unit* pHatingUnit, float pThreat, SpellSchoolMask schoolMask, SpellEntry const *pThreatSpell)
{
- if(pThreatSpell)
- {
- if( Player* modOwner = pHatingUnit->GetSpellModOwner() )
+ if (pThreatSpell)
+ if (Player* modOwner = pHatedUnit->GetSpellModOwner())
modOwner->ApplySpellMod(pThreatSpell->Id, SPELLMOD_THREAT, pThreat);
- }
float threat = pHatedUnit->ApplyTotalThreatModifier(pThreat, schoolMask);
return threat;
@@ -346,7 +344,7 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe
//=================== ThreatManager ==========================
//============================================================
-ThreatManager::ThreatManager(Unit* owner) : iCurrentVictim(NULL), iOwner(owner)
+ThreatManager::ThreatManager(Unit* owner) : iCurrentVictim(NULL), iOwner(owner), iUpdateTimer(THREAT_UPDATE_INTERVAL)
{
}
@@ -357,6 +355,7 @@ void ThreatManager::clearReferences()
iThreatContainer.clearReferences();
iThreatOfflineContainer.clearReferences();
iCurrentVictim = NULL;
+ iUpdateTimer = THREAT_UPDATE_INTERVAL;
}
//============================================================
@@ -470,6 +469,10 @@ void ThreatManager::tauntFadeOut(Unit *pTaunter)
void ThreatManager::setCurrentVictim(HostilReference* pHostilReference)
{
+ if (pHostilReference && pHostilReference != iCurrentVictim)
+ {
+ iOwner->SendChangeCurrentVictimOpcode(pHostilReference);
+ }
iCurrentVictim = pHostilReference;
}
@@ -515,6 +518,7 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat
setCurrentVictim(NULL);
setDirty(true);
}
+ iOwner->SendRemoveFromThreatListOpcode(hostilReference);
if(hostilReference->isOnline())
iThreatContainer.remove(hostilReference);
else
@@ -523,3 +527,16 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat
}
}
+bool ThreatManager::isNeedUpdateToClient(uint32 time)
+{
+ if (isThreatListEmpty())
+ return false;
+ if (time >= iUpdateTimer)
+ {
+ iUpdateTimer = THREAT_UPDATE_INTERVAL;
+ return true;
+ }
+ iUpdateTimer -= time;
+ return false;
+}
+