refactor(Core/Combat): Port TrinityCore heap-based threat system (#24715)

Co-authored-by: blinkysc <blinkysc@users.noreply.github.com>
Co-authored-by: Treeston <treeston.mmoc@gmail.com>
Co-authored-by: killerwife <killerwife@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
blinkysc
2026-03-18 13:36:59 -05:00
committed by GitHub
parent c80a0f1fad
commit 984baa92dd
101 changed files with 7045 additions and 2659 deletions

View File

@@ -673,6 +673,20 @@ class spell_dk_dancing_rune_weapon : public AuraScript
{
PrepareAuraScript(spell_dk_dancing_rune_weapon);
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* caster = GetCaster();
if (!caster)
return;
// Redirect 100% of the DRW's threat to the DK player
uint32 npcEntry = GetSpellInfo()->Effects[EFFECT_0].MiscValue;
std::list<Creature*> runeWeapons;
caster->GetAllMinionsByEntry(runeWeapons, npcEntry);
for (Creature* temp : runeWeapons)
temp->GetThreatMgr().RegisterRedirectThreat(GetId(), caster->GetGUID(), 100);
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (!eventInfo.GetActor() || !eventInfo.GetActionTarget() || !eventInfo.GetActionTarget()->IsAlive() || !eventInfo.GetActor()->IsPlayer())
@@ -749,6 +763,7 @@ class spell_dk_dancing_rune_weapon : public AuraScript
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_dk_dancing_rune_weapon::HandleApply, EFFECT_2, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
DoCheckProc += AuraCheckProcFn(spell_dk_dancing_rune_weapon::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_dk_dancing_rune_weapon::HandleProc, EFFECT_1, SPELL_AURA_DUMMY);
}

View File

@@ -52,6 +52,7 @@ enum HunterSpells
SPELL_HUNTER_IMPROVED_MEND_PET = 24406,
SPELL_HUNTER_INVIGORATION_TRIGGERED = 53398,
SPELL_HUNTER_MASTERS_CALL_TRIGGERED = 62305,
SPELL_HUNTER_MISDIRECTION = 34477,
SPELL_HUNTER_MISDIRECTION_PROC = 35079,
SPELL_HUNTER_PET_LAST_STAND_TRIGGERED = 53479,
SPELL_HUNTER_PET_HEART_OF_THE_PHOENIX = 55709,
@@ -893,7 +894,7 @@ class spell_hun_misdirection : public AuraScript
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT || !GetTarget()->HasAura(SPELL_HUNTER_MISDIRECTION_PROC))
GetTarget()->ResetRedirectThreat();
GetTarget()->GetThreatMgr().UnregisterRedirectThreat(SPELL_HUNTER_MISDIRECTION);
}
bool CheckProc(ProcEventInfo& eventInfo)
@@ -902,7 +903,7 @@ class spell_hun_misdirection : public AuraScript
if ((eventInfo.GetProcSpell() && (eventInfo.GetProcSpell()->GetSpellInfo()->SpellFamilyFlags[0] & 0x800000)) || (eventInfo.GetHealInfo() && (eventInfo.GetHealInfo()->GetSpellInfo()->SpellFamilyFlags[0] & 0x800000)))
return false;
return GetTarget()->GetRedirectThreatTarget();
return GetTarget()->GetThreatMgr().HasRedirects();
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
@@ -926,7 +927,7 @@ class spell_hun_misdirection_proc : public AuraScript
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->ResetRedirectThreat();
GetTarget()->GetThreatMgr().UnregisterRedirectThreat(SPELL_HUNTER_MISDIRECTION);
}
void Register() override

View File

@@ -915,9 +915,8 @@ class spell_pri_mind_control : public AuraScript
{
if (Unit* target = GetTarget())
{
uint32 duration = static_cast<uint32>(GetDuration());
caster->SetInCombatWith(target, duration);
target->SetInCombatWith(caster, duration);
caster->SetInCombatWith(target);
target->SetInCombatWith(caster);
}
}
}

View File

@@ -42,6 +42,7 @@ enum RogueSpells
SPELL_ROGUE_KILLING_SPREE_DMG_BUFF = 61851,
SPELL_ROGUE_PREY_ON_THE_WEAK = 58670,
SPELL_ROGUE_SHIV_TRIGGERED = 5940,
SPELL_ROGUE_TRICKS_OF_THE_TRADE = 57934,
SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST = 57933,
SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC = 59628,
// Proc system spells
@@ -616,53 +617,68 @@ class spell_rog_shiv : public SpellScript
}
};
// 57934 - Tricks of the Trade
class spell_rog_tricks_of_the_trade : public AuraScript
// 57934 - Tricks of the Trade (AuraScript)
class spell_rog_tricks_of_the_trade_aura : public AuraScript
{
PrepareAuraScript(spell_rog_tricks_of_the_trade);
PrepareAuraScript(spell_rog_tricks_of_the_trade_aura);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC });
}
bool Load() override
{
_redirectTarget = nullptr;
return true;
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT)
GetTarget()->ResetRedirectThreat();
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT || !GetTarget()->HasAura(SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC))
GetTarget()->GetThreatMgr().UnregisterRedirectThreat(SPELL_ROGUE_TRICKS_OF_THE_TRADE);
}
bool CheckProc(ProcEventInfo& /*eventInfo*/)
{
_redirectTarget = GetTarget()->GetRedirectThreatTarget();
return _redirectTarget;
}
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
Unit* target = GetTarget();
target->CastSpell(_redirectTarget, SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST, true);
target->CastSpell(target, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC, true);
Remove(AURA_REMOVE_BY_DEFAULT); // maybe handle by proc charges
Unit* rogue = GetTarget();
Unit* target = ObjectAccessor::GetUnit(*rogue, _redirectTarget);
if (target)
{
rogue->CastSpell(target, SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST, true, nullptr, aurEff);
rogue->CastSpell(rogue, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC, true, nullptr, aurEff);
}
Remove(AURA_REMOVE_BY_DEFAULT);
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_rog_tricks_of_the_trade::OnRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
DoCheckProc += AuraCheckProcFn(spell_rog_tricks_of_the_trade::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_rog_tricks_of_the_trade::HandleProc, EFFECT_1, SPELL_AURA_DUMMY);
AfterEffectRemove += AuraEffectRemoveFn(spell_rog_tricks_of_the_trade_aura::OnRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectProc += AuraEffectProcFn(spell_rog_tricks_of_the_trade_aura::HandleProc, EFFECT_1, SPELL_AURA_DUMMY);
}
private:
Unit* _redirectTarget;
ObjectGuid _redirectTarget;
public:
void SetRedirectTarget(ObjectGuid const& guid) { _redirectTarget = guid; }
};
// 57934 - Tricks of the Trade (SpellScript)
class spell_rog_tricks_of_the_trade : public SpellScript
{
PrepareSpellScript(spell_rog_tricks_of_the_trade);
void DoAfterHit()
{
if (Aura* aura = GetHitAura())
if (auto* script = aura->GetScript<spell_rog_tricks_of_the_trade_aura>("spell_rog_tricks_of_the_trade"))
{
if (Unit* explTarget = GetExplTargetUnit())
script->SetRedirectTarget(explTarget->GetGUID());
else
script->SetRedirectTarget(ObjectGuid::Empty);
}
}
void Register() override
{
AfterHit += SpellHitFn(spell_rog_tricks_of_the_trade::DoAfterHit);
}
};
// 59628 - Tricks of the Trade (Proc)
@@ -672,7 +688,7 @@ class spell_rog_tricks_of_the_trade_proc : public AuraScript
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->ResetRedirectThreat();
GetTarget()->GetThreatMgr().UnregisterRedirectThreat(SPELL_ROGUE_TRICKS_OF_THE_TRADE);
}
void Register() override
@@ -1162,7 +1178,7 @@ void AddSC_rogue_spell_scripts()
RegisterSpellScript(spell_rog_prey_on_the_weak);
RegisterSpellScript(spell_rog_rupture);
RegisterSpellScript(spell_rog_shiv);
RegisterSpellScript(spell_rog_tricks_of_the_trade);
RegisterSpellAndAuraScriptPair(spell_rog_tricks_of_the_trade, spell_rog_tricks_of_the_trade_aura);
RegisterSpellScript(spell_rog_tricks_of_the_trade_proc);
RegisterSpellScript(spell_rog_pickpocket);
RegisterSpellScript(spell_rog_vanish_purge);

View File

@@ -748,7 +748,7 @@ class spell_warr_vigilance : public AuraScript
target->RemoveAurasDueToSpell(SPELL_GEN_DAMAGE_REDUCTION_AURA);
}
target->ResetRedirectThreat();
target->GetThreatMgr().UnregisterRedirectThreat(SPELL_WARRIOR_VIGILANCE_REDIRECT_THREAT, GetCasterGUID());
}
bool CheckProc(ProcEventInfo& /*eventInfo*/)