Core/Spells: move m_preCastSpell logic to scripts

- Bad name because it was actaully executed after effects
This commit is contained in:
ariel-
2018-03-10 00:55:24 -03:00
parent 6feee74c5a
commit bd3530dd1f
6 changed files with 148 additions and 53 deletions

View File

@@ -0,0 +1,7 @@
DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_mage_frostfire_bolt','spell_mage_ice_block','spell_pal_immunities');
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(-44614, 'spell_mage_frostfire_bolt'),
( 45438, 'spell_mage_ice_block'),
( 498, 'spell_pal_immunities'),
( 642, 'spell_pal_immunities'),
( -1022, 'spell_pal_immunities');

View File

@@ -588,7 +588,6 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
focusObject = nullptr;
m_cast_count = 0;
m_glyphIndex = 0;
m_preCastSpell = 0;
m_triggeredByAuraSpell = nullptr;
unitCaster = nullptr;
_spellAura = nullptr;
@@ -2805,30 +2804,6 @@ void Spell::DoSpellEffectHit(Unit* unit, uint8 effIndex, TargetInfo& hitInfo)
void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
{
// Apply additional spell effects to target
/// @todo move this code to scripts
if (m_preCastSpell)
{
// Paladin immunity shields
if (m_preCastSpell == 61988)
{
// Cast Forbearance
m_caster->CastSpell(unit, 25771, true);
// Cast Avenging Wrath Marker
unit->CastSpell(unit, 61987, true);
}
// Avenging Wrath
if (m_preCastSpell == 61987)
// Cast the serverside immunity shield marker
m_caster->CastSpell(unit, 61988, true);
// Blizz seems to just apply aura without bothering to cast
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(m_preCastSpell))
if (Unit* unitCaster = m_caster->ToUnit())
unitCaster->AddAura(spellInfo, MAX_EFFECT_MASK, unit);
}
// handle SPELL_AURA_ADD_TARGET_TRIGGER auras
// this is executed after spell proc spells on target hit
// spells are triggered for each hit spell target
@@ -7901,29 +7876,6 @@ bool Spell::CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByA
void Spell::PrepareTriggersExecutedOnHit()
{
/// @todo move this to scripts
if (m_spellInfo->SpellFamilyName)
{
SpellInfo const* excludeCasterSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeCasterAuraSpell);
if (excludeCasterSpellInfo && !excludeCasterSpellInfo->IsPositive())
m_preCastSpell = m_spellInfo->ExcludeCasterAuraSpell;
SpellInfo const* excludeTargetSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeTargetAuraSpell);
if (excludeTargetSpellInfo && !excludeTargetSpellInfo->IsPositive())
m_preCastSpell = m_spellInfo->ExcludeTargetAuraSpell;
}
/// @todo move this to scripts
switch (m_spellInfo->SpellFamilyName)
{
case SPELLFAMILY_MAGE:
{
// Permafrost
if (m_spellInfo->SpellFamilyFlags[1] & 0x00001000 || m_spellInfo->SpellFamilyFlags[0] & 0x00100220)
m_preCastSpell = 68391;
break;
}
}
Unit* unitCaster = m_caster->ToUnit();
if (!unitCaster)
return;

View File

@@ -490,7 +490,6 @@ class TC_GAME_API Spell
uint32 m_castItemEntry;
uint8 m_cast_count;
uint32 m_glyphIndex;
uint32 m_preCastSpell;
SpellCastTargets m_targets;
void AddComboPointGain(Unit* target, int8 amount)

View File

@@ -67,7 +67,8 @@ enum MageSpells
SPELL_MAGE_T10_2P_BONUS_EFFECT = 70753,
SPELL_MAGE_T8_4P_BONUS = 64869,
SPELL_MAGE_MISSILE_BARRAGE = 44401,
SPELL_MAGE_FINGERS_OF_FROST_AURASTATE_AURA = 44544
SPELL_MAGE_FINGERS_OF_FROST_AURASTATE_AURA = 44544,
SPELL_MAGE_PERMAFROST_AURA = 68391
};
enum MageSpellIcons
@@ -656,6 +657,34 @@ class spell_mage_fire_frost_ward : public SpellScriptLoader
}
};
// -44614 - Frostfire Bolt
class spell_mage_frostfire_bolt : public AuraScript
{
PrepareAuraScript(spell_mage_frostfire_bolt);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_MAGE_PERMAFROST_AURA });
}
void ApplyPermafrost(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
caster->CastSpell(GetTarget(), SPELL_MAGE_PERMAFROST_AURA, aurEff);
}
void RemovePermafrost(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(SPELL_MAGE_PERMAFROST_AURA);
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_mage_frostfire_bolt::ApplyPermafrost, EFFECT_0, SPELL_AURA_MOD_DECREASE_SPEED, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
AfterEffectRemove += AuraEffectRemoveFn(spell_mage_frostfire_bolt::ApplyPermafrost, EFFECT_0, SPELL_AURA_MOD_DECREASE_SPEED, AURA_EFFECT_HANDLE_REAL);
}
};
// 54646 - Focus Magic
class spell_mage_focus_magic : public SpellScriptLoader
{
@@ -966,6 +995,27 @@ class spell_mage_ice_barrier : public SpellScriptLoader
}
};
// 45438 - Ice Block
class spell_mage_ice_block : public SpellScript
{
PrepareSpellScript(spell_mage_ice_block);
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->ExcludeTargetAuraSpell });
}
void TriggerHypothermia()
{
GetCaster()->CastSpell(nullptr, GetSpellInfo()->ExcludeTargetAuraSpell, true);
}
void Register() override
{
AfterHit += SpellHitFn(spell_mage_ice_block::TriggerHypothermia);
}
};
// -11119 - Ignite
class spell_mage_ignite : public SpellScriptLoader
{
@@ -1360,6 +1410,7 @@ void AddSC_mage_spell_scripts()
new spell_mage_empowered_fire();
new spell_mage_fingers_of_frost();
new spell_mage_fire_frost_ward();
RegisterAuraScript(spell_mage_frostfire_bolt);
new spell_mage_focus_magic();
new spell_mage_gen_extra_effects();
new spell_mage_glyph_of_polymorph();
@@ -1367,6 +1418,7 @@ void AddSC_mage_spell_scripts()
new spell_mage_glyph_of_ice_block();
new spell_mage_hot_streak();
new spell_mage_ice_barrier();
RegisterSpellScript(spell_mage_ice_block);
new spell_mage_ignite();
new spell_mage_living_bomb();
new spell_mage_magic_absorption();

View File

@@ -301,11 +301,13 @@ class spell_pal_avenging_wrath : public SpellScriptLoader
return ValidateSpellInfo(
{
SPELL_PALADIN_SANCTIFIED_WRATH,
SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1
SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1,
SPELL_PALADIN_AVENGING_WRATH_MARKER,
SPELL_PALADIN_IMMUNE_SHIELD_MARKER
});
}
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
void HandleApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
if (AuraEffect const* aurEff = target->GetAuraEffectOfRankedSpell(SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1, EFFECT_2))
@@ -315,6 +317,11 @@ class spell_pal_avenging_wrath : public SpellScriptLoader
.AddSpellMod(SPELLVALUE_BASE_POINT1, aurEff->GetAmount());
target->CastSpell(target, SPELL_PALADIN_SANCTIFIED_WRATH, args);
}
target->CastSpell(nullptr, SPELL_PALADIN_AVENGING_WRATH_MARKER, aurEff);
// Blizz seems to just apply aura without bothering to cast
target->AddAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER, target);
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -324,7 +331,7 @@ class spell_pal_avenging_wrath : public SpellScriptLoader
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_pal_avenging_wrath_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
AfterEffectApply += AuraEffectApplyFn(spell_pal_avenging_wrath_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
AfterEffectRemove += AuraEffectRemoveFn(spell_pal_avenging_wrath_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
}
};
@@ -1108,6 +1115,57 @@ public:
}
};
// 498 - Divine Protection
// 642 - Divine Shield
// -1022 - Hand of Protection
class spell_pal_immunities : public SpellScript
{
PrepareSpellScript(spell_pal_immunities);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo(
{
SPELL_PALADIN_FORBEARANCE,
SPELL_PALADIN_AVENGING_WRATH_MARKER,
SPELL_PALADIN_IMMUNE_SHIELD_MARKER
});
}
SpellCastResult CheckCast()
{
Unit* caster = GetCaster();
// for HoP
Unit* target = GetExplTargetUnit();
if (!target)
target = caster;
// "Cannot be used within $61987d. of using Avenging Wrath."
if (target->HasAura(SPELL_PALADIN_FORBEARANCE) || target->HasAura(SPELL_PALADIN_AVENGING_WRATH_MARKER))
return SPELL_FAILED_TARGET_AURASTATE;
return SPELL_CAST_OK;
}
void TriggerDebuffs()
{
if (Unit* target = GetHitUnit())
{
// Blizz seems to just apply aura without bothering to cast
GetCaster()->AddAura(SPELL_PALADIN_FORBEARANCE, target);
GetCaster()->AddAura(SPELL_PALADIN_AVENGING_WRATH_MARKER, target);
GetCaster()->AddAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER, target);
}
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_pal_immunities::CheckCast);
AfterHit += SpellHitFn(spell_pal_immunities::TriggerDebuffs);
}
};
// Maybe this is incorrect
// These spells should always be cast on login, regardless of whether the player has the talent or not
@@ -2377,6 +2435,7 @@ void AddSC_paladin_spell_scripts()
new spell_pal_heart_of_the_crusader();
new spell_pal_holy_shock();
new spell_pal_illumination();
RegisterSpellScript(spell_pal_immunities);
new spell_pal_improved_aura("spell_pal_improved_concentraction_aura", SPELL_PALADIN_IMPROVED_CONCENTRACTION_AURA);
new spell_pal_improved_aura("spell_pal_improved_devotion_aura", SPELL_PALADIN_IMPROVED_DEVOTION_AURA);
new spell_pal_improved_aura("spell_pal_sanctified_retribution", SPELL_PALADIN_SANCTIFIED_RETRIBUTION_AURA);

View File

@@ -954,6 +954,32 @@ class spell_pri_power_word_shield : public SpellScriptLoader
public:
spell_pri_power_word_shield() : SpellScriptLoader("spell_pri_power_word_shield") { }
class spell_pri_power_word_shield_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_power_word_shield_SpellScript);
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ spellInfo->ExcludeTargetAuraSpell });
}
void WeakenSoul()
{
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, GetSpellInfo()->ExcludeTargetAuraSpell, true);
}
void Register() override
{
AfterHit += SpellHitFn(spell_pri_power_word_shield_SpellScript::WeakenSoul);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_pri_power_word_shield_SpellScript();
}
class spell_pri_power_word_shield_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_power_word_shield_AuraScript);