diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2018-01-03 20:04:19 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-05-16 21:56:01 +0200 |
| commit | 34c7810fe507eca1b8b9389630db5d5d26d92e77 (patch) | |
| tree | e05653a0adaf4c4f5c406649f1bfe6573cbb22ff /src/server/scripts/Spells | |
| parent | 5158136ee8a77046e37bafa192481b8b61d4a116 (diff) | |
Core: Combat/threat system rewrite (PR #19930)
- PvE combat is now always mutual. UNIT_FLAG_IN_COMBAT is backed by actual references to the units we're in combat with.
- PvP combat is now also tracked, and almost always mutual; spells like Vanish and Feign Death can break this rule. That means we can easily determine a list of players we're fighting.
- By extension, IsInCombatWith now has sensible behavior when invoked on nonplayers.
- Threat and combat systems are no longer the same.
- They still have an enforced relationship (threat implies combat - clearing combat clears threat)...
- ...but we can have combat without threat. A creature (with threat list) isn't considered to be engaged until it has an entry on its threat list...
- ...which means we can now faithfully replicate retail engage behavior. Combat on projectile launch - engagement start on projectile impact. Yay for progress!
- AI method refactor, as already ported in 6113b9d - `JustEngagedWith`, `JustEnteredCombat` and `JustExitedCombat`.
- Vehicle threat is now properly pooled on the main vehicle body (fixes #16542).
- Various edge case bug fixes for threat redirects (Misdirection "cancelling" Vigilance and similar).
- Target re-selection is now significantly faster.
- Fixed a ton of other smaller edge case bugs, probably.
Closes #7951 and #19998.
(cherry picked from commit 532ab1c7f8653d1a2e48aa1f1f8a9ba1041d4bb7)
Diffstat (limited to 'src/server/scripts/Spells')
| -rw-r--r-- | src/server/scripts/Spells/spell_hunter.cpp | 11 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_rogue.cpp | 119 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_warlock.cpp | 8 |
3 files changed, 65 insertions, 73 deletions
diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 45a8e390b9c..ed8f1eb38d5 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -38,6 +38,7 @@ enum HunterSpells SPELL_HUNTER_EXHILARATION_R2 = 231546, SPELL_HUNTER_LONE_WOLF = 155228, SPELL_HUNTER_MASTERS_CALL_TRIGGERED = 62305, + SPELL_HUNTER_MISDIRECTION = 34477, SPELL_HUNTER_MISDIRECTION_PROC = 35079, SPELL_HUNTER_MULTI_SHOT_FOCUS = 213363, SPELL_HUNTER_PET_LAST_STAND_TRIGGERED = 53479, @@ -297,12 +298,7 @@ class spell_hun_misdirection : public SpellScriptLoader return; if (!GetTarget()->HasAura(SPELL_HUNTER_MISDIRECTION_PROC)) - GetTarget()->ResetRedirectThreat(); - } - - bool CheckProc(ProcEventInfo& /*eventInfo*/) - { - return GetTarget()->GetRedirectThreatTarget() != nullptr; + GetTarget()->GetThreatManager().UnregisterRedirectThreat(SPELL_HUNTER_MISDIRECTION); } void HandleProc(AuraEffect* aurEff, ProcEventInfo& /*eventInfo*/) @@ -314,7 +310,6 @@ class spell_hun_misdirection : public SpellScriptLoader void Register() override { AfterEffectRemove += AuraEffectRemoveFn(spell_hun_misdirection_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - DoCheckProc += AuraCheckProcFn(spell_hun_misdirection_AuraScript::CheckProc); OnEffectProc += AuraEffectProcFn(spell_hun_misdirection_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_DUMMY); } }; @@ -337,7 +332,7 @@ class spell_hun_misdirection_proc : public SpellScriptLoader void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->ResetRedirectThreat(); + GetTarget()->GetThreatManager().UnregisterRedirectThreat(SPELL_HUNTER_MISDIRECTION); } void Register() override diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 003b55c260e..25ba6f0006d 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -51,6 +51,7 @@ enum RogueSpells SPELL_ROGUE_STEALTH_STEALTH_AURA = 158185, SPELL_ROGUE_STEALTH_SHAPESHIFT_AURA = 158188, SPELL_ROGUE_VANISH_AURA = 11327, + SPELL_ROGUE_TRICKS_OF_THE_TRADE = 57934, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC = 59628, SPELL_ROGUE_HONOR_AMONG_THIEVES_ENERGIZE = 51699, SPELL_ROGUE_T5_2P_SET_BONUS = 37169 @@ -507,82 +508,78 @@ class spell_rog_vanish_aura : public SpellScriptLoader }; // 57934 - Tricks of the Trade -class spell_rog_tricks_of_the_trade : public SpellScriptLoader +class spell_rog_tricks_of_the_trade_aura : public AuraScript { - public: - spell_rog_tricks_of_the_trade() : SpellScriptLoader("spell_rog_tricks_of_the_trade") { } + PrepareAuraScript(spell_rog_tricks_of_the_trade_aura); - class spell_rog_tricks_of_the_trade_AuraScript : public AuraScript - { - PrepareAuraScript(spell_rog_tricks_of_the_trade_AuraScript); + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC }); - } + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT || !GetTarget()->HasAura(SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC)) + GetTarget()->GetThreatManager().UnregisterRedirectThreat(SPELL_ROGUE_TRICKS_OF_THE_TRADE); + } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT) - GetTarget()->ResetRedirectThreat(); - } + void HandleProc(AuraEffect* aurEff, ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); - bool CheckProc(ProcEventInfo& /*eventInfo*/) - { - _redirectTarget = GetTarget()->GetRedirectThreatTarget(); - return _redirectTarget != nullptr; - } + Unit* rogue = GetTarget(); + if (ObjectAccessor::GetUnit(*rogue, _redirectTarget)) + rogue->CastSpell(rogue, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC, aurEff); + Remove(AURA_REMOVE_BY_DEFAULT); + } - void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& /*eventInfo*/) - { - PreventDefaultAction(); + void Register() override + { + 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); + } - Unit* target = GetTarget(); - target->CastSpell(target, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC, true); - Remove(AURA_REMOVE_BY_DEFAULT); // maybe handle by proc charges - } + ObjectGuid _redirectTarget; +public: + void SetRedirectTarget(ObjectGuid guid) { _redirectTarget = guid; } +}; - void Register() override +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")) { - AfterEffectRemove += AuraEffectRemoveFn(spell_rog_tricks_of_the_trade_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - DoCheckProc += AuraCheckProcFn(spell_rog_tricks_of_the_trade_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_rog_tricks_of_the_trade_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_DUMMY); + if (Unit* explTarget = GetExplTargetUnit()) + script->SetRedirectTarget(explTarget->GetGUID()); + else + script->SetRedirectTarget(ObjectGuid::Empty); } + } - Unit* _redirectTarget = nullptr; - }; - - AuraScript* GetAuraScript() const override - { - return new spell_rog_tricks_of_the_trade_AuraScript(); - } + void Register() override + { + AfterHit += SpellHitFn(spell_rog_tricks_of_the_trade::DoAfterHit); + } }; // 59628 - Tricks of the Trade (Proc) -class spell_rog_tricks_of_the_trade_proc : public SpellScriptLoader +class spell_rog_tricks_of_the_trade_proc : public AuraScript { - public: - spell_rog_tricks_of_the_trade_proc() : SpellScriptLoader("spell_rog_tricks_of_the_trade_proc") { } + PrepareAuraScript(spell_rog_tricks_of_the_trade_proc); - class spell_rog_tricks_of_the_trade_proc_AuraScript : public AuraScript - { - PrepareAuraScript(spell_rog_tricks_of_the_trade_proc_AuraScript); - - void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetTarget()->ResetRedirectThreat(); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_rog_tricks_of_the_trade_proc_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->GetThreatManager().UnregisterRedirectThreat(SPELL_ROGUE_TRICKS_OF_THE_TRADE); + } - AuraScript* GetAuraScript() const override - { - return new spell_rog_tricks_of_the_trade_proc_AuraScript(); - } + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_rog_tricks_of_the_trade_proc::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } }; // 198031 - Honor Among Thieves @@ -704,8 +701,8 @@ void AddSC_rogue_spell_scripts() new spell_rog_stealth(); new spell_rog_vanish(); new spell_rog_vanish_aura(); - new spell_rog_tricks_of_the_trade(); - new spell_rog_tricks_of_the_trade_proc(); + RegisterSpellAndAuraScriptPair(spell_rog_tricks_of_the_trade, spell_rog_tricks_of_the_trade_aura); + RegisterAuraScript(spell_rog_tricks_of_the_trade_proc); new spell_rog_honor_among_thieves(); new spell_rog_eviscerate(); new spell_rog_envenom(); diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 163c867d71d..1740f3291f9 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -51,7 +51,7 @@ enum WarlockSpells SPELL_WARLOCK_RAIN_OF_FIRE_DAMAGE = 42223, SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE = 27285, SPELL_WARLOCK_SEED_OF_CORRUPTION_GENERIC = 32865, - SPELL_WARLOCK_SOULSHATTER = 32835, + SPELL_WARLOCK_SOULSHATTER_EFFECT = 32835, SPELL_WARLOCK_SOUL_SWAP_CD_MARKER = 94229, SPELL_WARLOCK_SOUL_SWAP_OVERRIDE = 86211, SPELL_WARLOCK_SOUL_SWAP_MOD_COST = 92794, @@ -815,15 +815,15 @@ class spell_warl_soulshatter : public SpellScriptLoader bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_WARLOCK_SOULSHATTER }); + return ValidateSpellInfo({ SPELL_WARLOCK_SOULSHATTER_EFFECT }); } void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); if (Unit* target = GetHitUnit()) - if (target->CanHaveThreatList() && target->GetThreatManager().IsThreatenedBy(caster, true)) - caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER, true); + if (target->GetThreatManager().IsThreatenedBy(caster, true)) + caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER_EFFECT, true); } void Register() override |
