mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/Spells: removed pre cast spell hacks from spell class and moved remnants to spell scripts
closes #81
This commit is contained in:
9
sql/updates/world/4.3.4/2020_05_10_02_world.sql
Normal file
9
sql/updates/world/4.3.4/2020_05_10_02_world.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
UPDATE `spell_dbc` SET `DurationIndex`= 3 WHERE `Id`= 61988;
|
||||
|
||||
DELETE FROM `spell_script_names` WHERE `ScriptName` IN
|
||||
('spell_pal_divine_shield',
|
||||
'spell_pal_hand_of_protection');
|
||||
|
||||
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
|
||||
(1022, 'spell_pal_hand_of_protection'),
|
||||
(642, 'spell_pal_divine_shield');
|
||||
@@ -625,7 +625,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;
|
||||
m_spellAura = nullptr;
|
||||
|
||||
@@ -2916,29 +2915,6 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
|
||||
|
||||
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);
|
||||
|
||||
if (sSpellMgr->GetSpellInfo(m_preCastSpell))
|
||||
// Blizz seems to just apply aura without bothering to cast
|
||||
m_caster->AddAura(m_preCastSpell, 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
|
||||
@@ -8098,29 +8074,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;
|
||||
}
|
||||
}
|
||||
|
||||
// handle SPELL_AURA_ADD_TARGET_TRIGGER auras:
|
||||
// save auras which were present on spell caster on cast, to prevent triggered auras from affecting caster
|
||||
// and to correctly calculate proc chance when combopoints are present
|
||||
|
||||
@@ -519,7 +519,6 @@ class TC_GAME_API Spell
|
||||
uint32 m_castItemEntry;
|
||||
uint8 m_cast_count;
|
||||
uint32 m_glyphIndex;
|
||||
uint32 m_preCastSpell;
|
||||
SpellCastTargets m_targets;
|
||||
int8 m_comboPointGain;
|
||||
SpellCustomErrors m_customError;
|
||||
|
||||
@@ -86,7 +86,8 @@ enum MageSpells
|
||||
SPELL_MAGE_MIRROR_IMAGE_TRIGGERED_FIRE = 88092,
|
||||
SPELL_MAGE_MIRROR_IMAGE_TRIGGERED_ARCANE = 88091,
|
||||
SPELL_MAGE_MIRROR_IMAGE_TRIGGERED_FROST = 58832,
|
||||
SPELL_MAGE_PERMAFROST = 91394,
|
||||
SPELL_MAGE_PERMAFROST_REDUCE_HEAL = 68391,
|
||||
SPELL_MAGE_PERMAFROST_HEAL = 91394,
|
||||
SPELL_MAGE_PYROBLAST = 11366,
|
||||
SPELL_MAGE_PYROMANIAC_TRIGGERED = 83582,
|
||||
SPELL_MAGE_SCORCH = 2948,
|
||||
@@ -1068,44 +1069,39 @@ class spell_mage_nether_vortex : public AuraScript
|
||||
};
|
||||
|
||||
// -11175 - Permafrost
|
||||
class spell_mage_permafrost : public SpellScriptLoader
|
||||
class spell_mage_permafrost : public AuraScript
|
||||
{
|
||||
public:
|
||||
spell_mage_permafrost() : SpellScriptLoader("spell_mage_permafrost") { }
|
||||
PrepareAuraScript(spell_mage_permafrost);
|
||||
|
||||
class spell_mage_permafrost_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_mage_permafrost_AuraScript);
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo(
|
||||
{
|
||||
return ValidateSpellInfo({ SPELL_MAGE_PERMAFROST });
|
||||
}
|
||||
SPELL_MAGE_PERMAFROST_HEAL,
|
||||
SPELL_MAGE_PERMAFROST_REDUCE_HEAL
|
||||
});
|
||||
}
|
||||
|
||||
bool DoCheck(ProcEventInfo& eventInfo)
|
||||
{
|
||||
return GetTarget()->GetGuardianPet() && eventInfo.GetDamageInfo()->GetDamage();
|
||||
}
|
||||
bool DoCheck(ProcEventInfo& eventInfo)
|
||||
{
|
||||
return GetTarget()->GetGuardianPet() && eventInfo.GetDamageInfo()->GetDamage() && eventInfo.GetProcTarget();
|
||||
}
|
||||
|
||||
void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
|
||||
{
|
||||
PreventDefaultAction();
|
||||
void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
|
||||
{
|
||||
PreventDefaultAction();
|
||||
|
||||
int32 heal = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()));
|
||||
GetTarget()->CastCustomSpell(SPELL_MAGE_PERMAFROST, SPELLVALUE_BASE_POINT0, heal, (Unit*)nullptr, true, nullptr, aurEff);
|
||||
}
|
||||
Unit* target = GetTarget();
|
||||
int32 heal = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()));
|
||||
target->CastCustomSpell(SPELL_MAGE_PERMAFROST_HEAL, SPELLVALUE_BASE_POINT0, heal, (Unit*)nullptr, true, nullptr, aurEff);
|
||||
target->CastSpell(eventInfo.GetProcTarget(), SPELL_MAGE_PERMAFROST_REDUCE_HEAL, true, nullptr, aurEff);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
DoCheckProc += AuraCheckProcFn(spell_mage_permafrost_AuraScript::DoCheck);
|
||||
OnEffectProc += AuraEffectProcFn(spell_mage_permafrost_AuraScript::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript* GetAuraScript() const override
|
||||
{
|
||||
return new spell_mage_permafrost_AuraScript();
|
||||
}
|
||||
void Register() override
|
||||
{
|
||||
DoCheckProc += AuraCheckProcFn(spell_mage_permafrost::DoCheck);
|
||||
OnEffectProc += AuraEffectProcFn(spell_mage_permafrost::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
// 118 - Polymorph
|
||||
@@ -2330,7 +2326,7 @@ void AddSC_mage_spell_scripts()
|
||||
RegisterSpellAndAuraScriptPair(spell_mage_mirror_image, spell_mage_mirror_image_AurasScript);
|
||||
RegisterAuraScript(spell_mage_nether_vortex);
|
||||
RegisterAuraScript(spell_mage_offensive_state_dnd);
|
||||
new spell_mage_permafrost();
|
||||
RegisterAuraScript(spell_mage_permafrost);
|
||||
new spell_mage_polymorph();
|
||||
new spell_mage_polymorph_cast_visual();
|
||||
RegisterAuraScript(spell_mage_pyromaniac);
|
||||
|
||||
@@ -2012,6 +2012,44 @@ class spell_pal_lights_beacon : public AuraScript
|
||||
}
|
||||
};
|
||||
|
||||
// 1022 - Hand of Protection
|
||||
class spell_pal_hand_of_protection : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_pal_hand_of_protection);
|
||||
|
||||
void HandleForbearance(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
// Serverside spell, so it's not sent in spell cast packets which gives us freedom of choice here
|
||||
GetHitUnit()->AddAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER, GetHitUnit());
|
||||
if (Unit* caster = GetCaster())
|
||||
caster->CastSpell(GetHitUnit(), SPELL_PALADIN_FORBEARANCE, true);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_pal_hand_of_protection::HandleForbearance, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
|
||||
}
|
||||
};
|
||||
|
||||
// 642 - Divine Shield
|
||||
class spell_pal_divine_shield : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_pal_divine_shield);
|
||||
|
||||
void HandleForbearance(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
// Serverside spell, so it's not sent in spell cast packets which gives us freedom of choice here
|
||||
GetHitUnit()->AddAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER, GetHitUnit());
|
||||
if (Unit* caster = GetCaster())
|
||||
caster->CastSpell(GetHitUnit(), SPELL_PALADIN_FORBEARANCE, true);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_pal_divine_shield::HandleForbearance, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_paladin_spell_scripts()
|
||||
{
|
||||
RegisterAuraScript(spell_pal_ardent_defender);
|
||||
@@ -2026,6 +2064,7 @@ void AddSC_paladin_spell_scripts()
|
||||
new spell_pal_consecration();
|
||||
RegisterAuraScript(spell_pal_divine_purpose);
|
||||
new spell_pal_divine_sacrifice();
|
||||
RegisterSpellScript(spell_pal_divine_shield);
|
||||
RegisterSpellScript(spell_pal_divine_storm);
|
||||
RegisterSpellScript(spell_pal_divine_storm_dummy);
|
||||
RegisterSpellAndAuraScriptPair(spell_pal_exorcism, spell_pal_exorcism_AuraScript);
|
||||
@@ -2036,6 +2075,7 @@ void AddSC_paladin_spell_scripts()
|
||||
RegisterSpellScript(spell_pal_guardian_of_ancient_kings);
|
||||
new spell_pal_hand_of_light();
|
||||
RegisterSpellAndAuraScriptPair(spell_pal_holy_radiance, spell_pal_holy_radiance_AuraScript);
|
||||
RegisterSpellScript(spell_pal_hand_of_protection);
|
||||
new spell_pal_hand_of_sacrifice();
|
||||
new spell_pal_holy_shock();
|
||||
RegisterAuraScript(spell_pal_illuminated_healing);
|
||||
|
||||
Reference in New Issue
Block a user