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 005e8fad2a8..5a1207b82ca 100644
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -130,6 +130,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)
@@ -263,7 +266,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 nullptr;
@@ -292,7 +295,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);
@@ -391,6 +394,30 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
ThreatManager::ThreatManager(Unit* owner) : iCurrentVictim(nullptr), 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()
@@ -453,9 +480,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);
}
//============================================================