aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Combat/ThreatManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Combat/ThreatManager.cpp')
-rw-r--r--src/server/game/Combat/ThreatManager.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp
index f7240308aef..f655f2bfa86 100644
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -131,6 +131,9 @@ void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& threatRefSt
GetSource()->processThreatEvent(&threatRefStatusChangeEvent);
}
+// -- compatibility layer for combat rewrite (PR #19930)
+Unit* HostileReference::GetOwner() const { return GetSource()->GetOwner(); }
+
//============================================================
void HostileReference::addThreat(float modThreat)
@@ -264,7 +267,7 @@ void ThreatContainer::clearReferences()
//============================================================
// Return the HostileReference of NULL, if not found
-HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) const
+HostileReference* ThreatContainer::getReferenceByTarget(Unit const* victim) const
{
if (!victim)
return NULL;
@@ -293,7 +296,7 @@ HostileReference* ThreatContainer::addThreat(Unit* victim, float threat)
//============================================================
-void ThreatContainer::modifyThreatPercent(Unit* victim, int32 percent)
+void ThreatContainer::ModifyThreatByPercent(Unit* victim, int32 percent)
{
if (HostileReference* ref = getReferenceByTarget(victim))
ref->addThreatPercent(percent);
@@ -392,6 +395,30 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
ThreatManager::ThreatManager(Unit* owner) : iCurrentVictim(NULL), iOwner(owner), iUpdateTimer(THREAT_UPDATE_INTERVAL) { }
+// -- compatibility layer for combat rewrite (PR #19930)
+void ThreatManager::ForwardThreatForAssistingMe(Unit* victim, float amount, SpellInfo const* spell, bool ignoreModifiers, bool ignoreRedirection)
+{
+ (void)ignoreModifiers; (void)ignoreRedirection;
+ GetOwner()->getHostileRefManager().threatAssist(victim, amount, spell);
+}
+
+void ThreatManager::AddThreat(Unit* victim, float amount, SpellInfo const* spell, bool ignoreModifiers, bool ignoreRedirection)
+{
+ (void)ignoreModifiers; (void)ignoreRedirection;
+ if (!iOwner->CanHaveThreatList() || iOwner->HasUnitState(UNIT_STATE_EVADE))
+ return;
+ iOwner->SetInCombatWith(victim);
+ victim->SetInCombatWith(iOwner);
+ addThreat(victim, amount, spell ? spell->GetSchoolMask() : victim->GetMeleeDamageSchoolMask(), spell);
+}
+
+void ThreatManager::ClearAllThreat()
+{
+ if (iOwner->CanHaveThreatList(true) && !isThreatListEmpty())
+ iOwner->SendClearThreatListOpcode();
+ clearReferences();
+}
+
//============================================================
void ThreatManager::clearReferences()
@@ -471,9 +498,9 @@ void ThreatManager::_addThreat(Unit* victim, float threat)
//============================================================
-void ThreatManager::modifyThreatPercent(Unit* victim, int32 percent)
+void ThreatManager::ModifyThreatByPercent(Unit* victim, int32 percent)
{
- iThreatContainer.modifyThreatPercent(victim, percent);
+ iThreatContainer.ModifyThreatByPercent(victim, percent);
}
//============================================================