diff options
author | Treeston <treeston.mmoc@gmail.com> | 2017-07-01 20:18:02 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-08-13 22:46:44 +0200 |
commit | 8be23fcbbdf26e8169defd761e61765f301bebe0 (patch) | |
tree | 6309b79f7dd617a8ddc801624dbbd4ed7ac22174 /src/server/game/Spells/Spell.cpp | |
parent | 2c99678118798279372f17d4bb5f5a88ac95c413 (diff) |
[3.3.5] Combat/Threat rewrite - prep & refactor (#19966)
* Combat/Threat rewrite (PR #19930) prep work. Mostly refactors, and a compatibility layer on ThreatManager/HostileReference that allows scripts to be changed already.
(cherry picked from commit e2a1ccd118d129b96e09ff1a15ed0adb1d4a3897)
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 75b8a94a535..6d279322c55 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2453,7 +2453,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) HealInfo healInfo(caster, unitTarget, addhealth, m_spellInfo, m_spellInfo->GetSchoolMask()); caster->HealBySpell(healInfo, crit); - unitTarget->getHostileRefManager().threatAssist(caster, float(healInfo.GetEffectiveHeal()) * 0.5f, m_spellInfo); + unitTarget->GetThreatManager().ForwardThreatForAssistingMe(caster, float(healInfo.GetEffectiveHeal())*0.5f, m_spellInfo); m_healing = healInfo.GetEffectiveHeal(); // Do triggers for unit @@ -2523,8 +2523,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) if (missInfo == SPELL_MISS_RESIST && m_spellInfo->HasAttribute(SPELL_ATTR0_CU_PICKPOCKET) && unitTarget->GetTypeId() == TYPEID_UNIT) { m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK); - if (unitTarget->ToCreature()->IsAIEnabled) - unitTarget->ToCreature()->AI()->AttackStart(m_caster); + unitTarget->ToCreature()->EngageWithTarget(m_caster); } } @@ -2620,14 +2619,16 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) // assisting case, healing and resurrection if (unit->HasUnitState(UNIT_STATE_ATTACK_PLAYER)) { - m_caster->SetContestedPvP(); - if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->UpdatePvP(true); + if (Player* playerOwner = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself()) + { + playerOwner->SetContestedPvP(); + playerOwner->UpdatePvP(true); + } } if (unit->IsInCombat() && m_spellInfo->HasInitialAggro()) { m_caster->SetInCombatState(unit->GetCombatTimer() > 0, unit); - unit->getHostileRefManager().threatAssist(m_caster, 0.0f); + unit->GetThreatManager().ForwardThreatForAssistingMe(m_caster, 0.0f, nullptr, true); } } } @@ -4838,14 +4839,14 @@ void Spell::HandleThreatSpells() // positive spells distribute threat among all units that are in combat with target, like healing if (m_spellInfo->IsPositive()) - target->getHostileRefManager().threatAssist(m_caster, threatToAdd, m_spellInfo); + target->GetThreatManager().ForwardThreatForAssistingMe(m_caster, threatToAdd, m_spellInfo); // for negative spells threat gets distributed among affected targets else { if (!target->CanHaveThreatList()) continue; - target->AddThreat(m_caster, threatToAdd, m_spellInfo->GetSchoolMask(), m_spellInfo); + target->GetThreatManager().AddThreat(m_caster, threatToAdd, m_spellInfo, true); } } TC_LOG_DEBUG("spells", "Spell %u, added an additional %f threat for %s %u target(s)", m_spellInfo->Id, threat, m_spellInfo->IsPositive() ? "assisting" : "harming", uint32(m_UniqueTargetInfo.size())); @@ -7937,7 +7938,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) return false; break; case TARGET_CHECK_THREAT: - if (_referer->getThreatManager().getThreat(unitTarget, true) <= 0.0f) + if (_referer->GetThreatManager().getThreat(unitTarget, true) <= 0.0f) return false; break; case TARGET_CHECK_TAP: |