aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Spells
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-01-03 20:04:19 +0100
committerGitHub <noreply@github.com>2018-01-03 20:04:19 +0100
commit532ab1c7f8653d1a2e48aa1f1f8a9ba1041d4bb7 (patch)
tree81e2f7eb89b3144c14dd488ea6304f6d44d19848 /src/server/scripts/Spells
parent425b181544a21d2246fdf0261ba76a37e2510883 (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.
Diffstat (limited to 'src/server/scripts/Spells')
-rw-r--r--src/server/scripts/Spells/spell_hunter.cpp11
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp134
-rw-r--r--src/server/scripts/Spells/spell_warlock.cpp10
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp2
4 files changed, 75 insertions, 82 deletions
diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp
index c9ae8848d40..89b14f71ccb 100644
--- a/src/server/scripts/Spells/spell_hunter.cpp
+++ b/src/server/scripts/Spells/spell_hunter.cpp
@@ -45,6 +45,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,
@@ -911,12 +912,7 @@ class spell_hun_misdirection : public SpellScriptLoader
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT || !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 const* aurEff, ProcEventInfo& /*eventInfo*/)
@@ -928,7 +924,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);
}
};
@@ -951,7 +946,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 fd46173675d..e04c0f76791 100644
--- a/src/server/scripts/Spells/spell_rogue.cpp
+++ b/src/server/scripts/Spells/spell_rogue.cpp
@@ -43,7 +43,8 @@ enum RogueSpells
SPELL_ROGUE_KILLING_SPREE_WEAPON_DMG = 57841,
SPELL_ROGUE_KILLING_SPREE_DMG_BUFF = 61851,
SPELL_ROGUE_PREY_ON_THE_WEAK = 58670,
- SPELL_ROGUE_SHIV_TRIGGERED = 5940,
+ 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,
SPELL_ROGUE_HONOR_AMONG_THIEVES = 51698,
@@ -52,7 +53,7 @@ enum RogueSpells
SPELL_ROGUE_T10_2P_BONUS = 70804,
SPELL_ROGUE_GLYPH_OF_BACKSTAB_TRIGGER = 63975,
SPELL_ROGUE_QUICK_RECOVERY_ENERGY = 31663,
- SPELL_ROGUE_CRIPPLING_POISON = 3409,
+ SPELL_ROGUE_CRIPPLING_POISON = 3409,
SPELL_ROGUE_MASTER_OF_SUBTLETY_BUFF = 31665,
SPELL_ROGUE_OVERKILL_BUFF = 58427
};
@@ -879,87 +880,86 @@ class spell_rog_shiv : 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
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ return ValidateSpellInfo(
{
- PrepareAuraScript(spell_rog_tricks_of_the_trade_AuraScript);
+ SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST,
+ SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC
+ });
+ }
- bool Validate(SpellInfo const* /*spellInfo*/) override
- {
- return ValidateSpellInfo(
- {
- SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST,
- 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 const* aurEff, ProcEventInfo& /*eventInfo*/)
+ {
+ PreventDefaultAction();
- bool CheckProc(ProcEventInfo& /*eventInfo*/)
- {
- _redirectTarget = GetTarget()->GetRedirectThreatTarget();
- return _redirectTarget != nullptr;
- }
+ Unit* rogue = GetTarget();
+ Unit* target = ObjectAccessor::GetUnit(*rogue, _redirectTarget);
+ if (target)
+ {
+ rogue->CastSpell(target, SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST, aurEff);
+ rogue->CastSpell(rogue, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC, aurEff);
+ }
+ Remove(AURA_REMOVE_BY_DEFAULT);
+ }
- void HandleProc(AuraEffect const* /*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(_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
- }
+ ObjectGuid _redirectTarget;
+public:
+ void SetRedirectTarget(ObjectGuid const& 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);
+ }
};
// 51698,51700,51701 - Honor Among Thieves
@@ -1135,8 +1135,8 @@ void AddSC_rogue_spell_scripts()
new spell_rog_glyph_of_backstab_triggered();
new spell_rog_setup();
new spell_rog_shiv();
- 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_honor_among_thieves_proc();
new spell_rog_turn_the_tables();
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp
index 4be4717c9e4..38772874e0e 100644
--- a/src/server/scripts/Spells/spell_warlock.cpp
+++ b/src/server/scripts/Spells/spell_warlock.cpp
@@ -63,7 +63,7 @@ enum WarlockSpells
SPELL_WARLOCK_NETHER_PROTECTION_ARCANE = 54373,
SPELL_WARLOCK_NETHER_PROTECTION_SHADOW = 54374,
SPELL_WARLOCK_NETHER_PROTECTION_NATURE = 54375,
- SPELL_WARLOCK_SOULSHATTER = 32835,
+ SPELL_WARLOCK_SOULSHATTER_EFFECT = 32835,
SPELL_WARLOCK_SIPHON_LIFE_HEAL = 63106,
SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL = 31117,
SPELL_WARLOCK_GLYPH_OF_LIFE_TAP_TRIGGERED = 63321,
@@ -1383,17 +1383,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
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index 3693ccf6eca..929bdb8fac3 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -1091,7 +1091,7 @@ class spell_warr_vigilance : public SpellScriptLoader
target->RemoveAurasDueToSpell(SPELL_GEN_DAMAGE_REDUCTION_AURA);
}
- target->ResetRedirectThreat();
+ target->GetThreatManager().UnregisterRedirectThreat(SPELL_WARRIOR_VIGILANCE_REDIRECT_THREAT, GetCasterGUID());
}
bool CheckProc(ProcEventInfo& /*eventInfo*/)