Core/Spells: Fixed warlock's Banish cancel if target was already banished (#23697)

* Core/Spells: Add SpellMissInfo argument to BeforeHit hooks and call them also when the spell doesn't hit. (#17613)

(cherry picked from commit 8ff5b35be1)

# Conflicts:
#	src/server/game/Spells/Spell.cpp
#	src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
#	src/server/scripts/Spells/spell_warlock.cpp

* Core/Spells: Fixed warlock's Banish cancel if target was already banished (#17614)

(cherry picked from commit 4587b5d880)

# Conflicts:
#	src/server/scripts/Spells/spell_warlock.cpp
This commit is contained in:
ForesterDev
2019-08-23 21:24:56 +04:00
committed by Giacomo Pozzoni
parent 10f6e38185
commit 448facc5e7
13 changed files with 81 additions and 50 deletions

View File

@@ -270,8 +270,11 @@ class spell_garfrost_permafrost : public SpellScriptLoader
}
private:
void PreventHitByLoS()
void PreventHitByLoS(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
return;
if (Unit* target = GetHitUnit())
{
Unit* caster = GetCaster();
@@ -312,7 +315,7 @@ class spell_garfrost_permafrost : public SpellScriptLoader
void Register() override
{
BeforeHit += SpellHitFn(spell_garfrost_permafrost_SpellScript::PreventHitByLoS);
BeforeHit += BeforeSpellHitFn(spell_garfrost_permafrost_SpellScript::PreventHitByLoS);
AfterHit += SpellHitFn(spell_garfrost_permafrost_SpellScript::RestoreImmunity);
}

View File

@@ -1410,15 +1410,18 @@ class spell_valanar_kinetic_bomb_knockback : public SpellScriptLoader
{
PrepareSpellScript(spell_valanar_kinetic_bomb_knockback_SpellScript);
void KnockIntoAir()
void KnockIntoAir(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
return;
if (Creature* target = GetHitCreature())
target->AI()->DoAction(ACTION_KINETIC_BOMB_JUMP);
}
void Register() override
{
BeforeHit += SpellHitFn(spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir);
BeforeHit += BeforeSpellHitFn(spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir);
}
};

View File

@@ -556,9 +556,9 @@ class spell_blood_queen_vampiric_bite : public SpellScriptLoader
return SPELL_CAST_OK;
}
void OnCast()
void OnCast(SpellMissInfo missInfo)
{
if (GetCaster()->GetTypeId() != TYPEID_PLAYER)
if (GetCaster()->GetTypeId() != TYPEID_PLAYER || missInfo != SPELL_MISS_NONE)
return;
uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_FRENZIED_BLOODTHIRST, GetCaster());
@@ -591,7 +591,7 @@ class spell_blood_queen_vampiric_bite : public SpellScriptLoader
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_blood_queen_vampiric_bite_SpellScript::CheckTarget);
BeforeHit += SpellHitFn(spell_blood_queen_vampiric_bite_SpellScript::OnCast);
BeforeHit += BeforeSpellHitFn(spell_blood_queen_vampiric_bite_SpellScript::OnCast);
OnEffectHitTarget += SpellEffectFn(spell_blood_queen_vampiric_bite_SpellScript::HandlePresence, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL);
}
};

View File

@@ -2128,14 +2128,17 @@ class spell_igb_below_zero : public SpellScriptLoader
{
PrepareSpellScript(spell_igb_below_zero_SpellScript);
void RemovePassengers()
void RemovePassengers(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
return;
GetHitUnit()->CastSpell(GetHitUnit(), SPELL_EJECT_ALL_PASSENGERS_BELOW_ZERO, TRIGGERED_FULL_MASK);
}
void Register() override
{
BeforeHit += SpellHitFn(spell_igb_below_zero_SpellScript::RemovePassengers);
BeforeHit += BeforeSpellHitFn(spell_igb_below_zero_SpellScript::RemovePassengers);
}
};

View File

@@ -2194,8 +2194,11 @@ class spell_the_lich_king_necrotic_plague_jump : public SpellScriptLoader
targets.resize(1);
}
void CheckAura()
void CheckAura(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
return;
if (GetHitUnit()->HasAura(GetSpellInfo()->Id))
_hadAura = true;
}
@@ -2209,7 +2212,7 @@ class spell_the_lich_king_necrotic_plague_jump : public SpellScriptLoader
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_necrotic_plague_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
BeforeHit += SpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::CheckAura);
BeforeHit += BeforeSpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::CheckAura);
OnHit += SpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::AddMissingStack);
}
@@ -3005,8 +3008,11 @@ class spell_the_lich_king_restore_soul : public SpellScriptLoader
}
}
void RemoveAura()
void RemoveAura(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
return;
if (Unit* target = GetHitUnit())
target->RemoveAurasDueToSpell(target->GetMap()->IsHeroic() ? SPELL_HARVEST_SOULS_TELEPORT : SPELL_HARVEST_SOUL_TELEPORT);
}
@@ -3014,7 +3020,7 @@ class spell_the_lich_king_restore_soul : public SpellScriptLoader
void Register() override
{
OnEffectHit += SpellEffectFn(spell_the_lich_king_restore_soul_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
BeforeHit += SpellHitFn(spell_the_lich_king_restore_soul_SpellScript::RemoveAura);
BeforeHit += BeforeSpellHitFn(spell_the_lich_king_restore_soul_SpellScript::RemoveAura);
}
InstanceScript* _instance;

View File

@@ -1598,8 +1598,11 @@ class spell_auto_repair : public SpellScriptLoader
{
PrepareSpellScript(spell_auto_repair_SpellScript);
void CheckCooldownForTarget()
void CheckCooldownForTarget(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
return;
if (GetHitUnit()->HasAuraEffect(SPELL_AUTO_REPAIR, EFFECT_2)) // Check presence of dummy aura indicating cooldown
{
PreventHitEffect(EFFECT_0);
@@ -1640,7 +1643,7 @@ class spell_auto_repair : public SpellScriptLoader
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_auto_repair_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
BeforeHit += SpellHitFn(spell_auto_repair_SpellScript::CheckCooldownForTarget);
BeforeHit += BeforeSpellHitFn(spell_auto_repair_SpellScript::CheckCooldownForTarget);
}
};

View File

@@ -255,8 +255,11 @@ class spell_rog_deadly_poison : public SpellScriptLoader
return GetCaster()->GetTypeId() == TYPEID_PLAYER && GetCastItem();
}
void HandleBeforeHit()
void HandleBeforeHit(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_NONE)
return;
if (Unit* target = GetHitUnit())
// Deadly Poison
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x10000, 0x80000, 0, GetCaster()->GetGUID()))
@@ -319,7 +322,7 @@ class spell_rog_deadly_poison : public SpellScriptLoader
void Register() override
{
BeforeHit += SpellHitFn(spell_rog_deadly_poison_SpellScript::HandleBeforeHit);
BeforeHit += BeforeSpellHitFn(spell_rog_deadly_poison_SpellScript::HandleBeforeHit);
AfterHit += SpellHitFn(spell_rog_deadly_poison_SpellScript::HandleAfterHit);
}

View File

@@ -148,40 +148,26 @@ class spell_warl_banish : public SpellScriptLoader
PrepareSpellScript(spell_warl_banish_SpellScript);
public:
spell_warl_banish_SpellScript()
{
_removed = false;
}
spell_warl_banish_SpellScript() {}
private:
void HandleBanish()
void HandleBanish(SpellMissInfo missInfo)
{
if (missInfo != SPELL_MISS_IMMUNE)
return;
if (Unit* target = GetHitUnit())
{
if (target->GetAuraEffect(SPELL_AURA_SCHOOL_IMMUNITY, SPELLFAMILY_WARLOCK, 0, 0x08000000, 0))
{
// No need to remove old aura since its removed due to not stack by current Banish aura
PreventHitDefaultEffect(EFFECT_0);
PreventHitDefaultEffect(EFFECT_1);
PreventHitDefaultEffect(EFFECT_2);
_removed = true;
}
// Casting Banish on a banished target will remove applied aura
if (Aura * banishAura = target->GetAura(GetSpellInfo()->Id, GetCaster()->GetGUID()))
banishAura->Remove();
}
}
void RemoveAura()
{
if (_removed)
PreventHitAura();
}
void Register() override
{
BeforeHit += SpellHitFn(spell_warl_banish_SpellScript::HandleBanish);
AfterHit += SpellHitFn(spell_warl_banish_SpellScript::RemoveAura);
BeforeHit += BeforeSpellHitFn(spell_warl_banish_SpellScript::HandleBanish);
}
bool _removed;
};
SpellScript* GetSpellScript() const override