Skip to content

Commit

Permalink
Core/Spells: Ice Lance
Browse files Browse the repository at this point in the history
* fixed secondary target damage with Splitting Ice talent
* fixed dropping 2 charges of Fingers of Frost with Splitting Ice
  • Loading branch information
Shauren committed Dec 24, 2020
1 parent cafa00b commit 041ceee
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 59 deletions.
13 changes: 13 additions & 0 deletions sql/updates/world/master/2020_12_24_01_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Fingers of Frost
DELETE FROM `spell_proc` WHERE `SpellId`=44544;
INSERT INTO `spell_proc` (`SpellId`,`SchoolMask`,`SpellFamilyName`,`SpellFamilyMask0`,`SpellFamilyMask1`,`SpellFamilyMask2`,`SpellFamilyMask3`,`ProcFlags`,`SpellTypeMask`,`SpellPhaseMask`,`HitMask`,`AttributesMask`,`DisableEffectsMask`,`ProcsPerMinute`,`Chance`,`Cooldown`,`Charges`) VALUES
(44544,0,3,0,0,0,0x100,0x10000,0,0x4,0x3FFF,0,0,0,100,0,0); -- PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG; PROC_SPELL_PHASE_FINISH; PROC_HIT_MASK_ALL

-- mage ice lance
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_mage_fingers_of_frost';
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_mage_ice_lance';
DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_mage_ice_lance_damage';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(44544,'spell_mage_fingers_of_frost'),
(30455,'spell_mage_ice_lance'),
(228598,'spell_mage_ice_lance_damage');
3 changes: 0 additions & 3 deletions sql/updates/world/master/9999_99_99_30455_world.sql

This file was deleted.

162 changes: 106 additions & 56 deletions src/server/scripts/Spells/spell_mage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ enum MageSpells
SPELL_MAGE_TEMPORAL_DISPLACEMENT = 80354,
SPELL_MAGE_WORGEN_FORM = 32819,
SPELL_PET_NETHERWINDS_FATIGUED = 160455,
SPELL_MAGE_ICE_LANCE = 30455,
SPELL_MAGE_ICE_LANCE_TRIGGER = 228598,
SPELL_MAGE_THERMAL_VOID = 155149,
SPELL_MAGE_ICY_VEINS = 12472,
SPELL_MAGE_SPLITTING_ICE = 56377,
SPELL_MAGE_CHAIN_REACTION_DUMMY = 278309,
SPELL_MAGE_CHAIN_REACTION = 278310,
};

Expand Down Expand Up @@ -277,6 +276,28 @@ class spell_mage_conjure_refreshment : public SpellScript
}
};

// 44544 - Fingers of Frost
class spell_mage_fingers_of_frost : public AuraScript
{
PrepareAuraScript(spell_mage_fingers_of_frost);

void SuppressWarning(AuraEffect const* /*aurEff*/, ProcEventInfo& /*procInfo*/)
{
PreventDefaultAction();
}

void DropFingersOfFrost(ProcEventInfo& /*eventInfo*/)
{
GetAura()->ModStackAmount(-1);
}

void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_mage_fingers_of_frost::SuppressWarning, EFFECT_1, SPELL_AURA_DUMMY);
AfterProc += AuraProcFn(spell_mage_fingers_of_frost::DropFingersOfFrost);
}
};

// 11426 - Ice Barrier
class spell_mage_ice_barrier : public AuraScript
{
Expand Down Expand Up @@ -313,6 +334,86 @@ class spell_mage_ice_barrier : public AuraScript
}
};

// Ice Lance - 30455
class spell_mage_ice_lance : public SpellScript
{
PrepareSpellScript(spell_mage_ice_lance);

bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo
({
SPELL_MAGE_ICE_LANCE_TRIGGER,
SPELL_MAGE_THERMAL_VOID,
SPELL_MAGE_ICY_VEINS,
SPELL_MAGE_CHAIN_REACTION_DUMMY,
SPELL_MAGE_CHAIN_REACTION,
SPELL_MAGE_FINGERS_OF_FROST
});
}

void IndexTarget(SpellEffIndex /*effIndex*/)
{
_orderedTargets.push_back(GetHitUnit()->GetGUID());
}

void HandleOnHit(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
Unit* target = GetHitUnit();

std::ptrdiff_t index = std::distance(_orderedTargets.begin(), std::find(_orderedTargets.begin(), _orderedTargets.end(), target->GetGUID()));

if (index == 0 // only primary target triggers these benefits
&& target->HasAuraState(AURA_STATE_FROZEN, GetSpellInfo(), caster))
{
// Thermal Void
if (Aura const* thermalVoid = caster->GetAura(SPELL_MAGE_THERMAL_VOID))
if (SpellEffectInfo const* thermalVoidEffect = thermalVoid->GetSpellInfo()->GetEffect(EFFECT_0))
if (Aura* icyVeins = caster->GetAura(SPELL_MAGE_ICY_VEINS))
icyVeins->SetDuration(icyVeins->GetDuration() + thermalVoidEffect->CalcValue(caster) * IN_MILLISECONDS);

// Chain Reaction
if (caster->HasAura(SPELL_MAGE_CHAIN_REACTION_DUMMY))
caster->CastSpell(caster, SPELL_MAGE_CHAIN_REACTION, true);
}

// put target index for chain value multiplier into EFFECT_1 base points, otherwise triggered spell doesn't know which damage multiplier to apply
caster->CastCustomSpell(SPELL_MAGE_ICE_LANCE_TRIGGER, SPELLVALUE_BASE_POINT1, index, target, true);
}

void Register() override
{
OnEffectLaunchTarget += SpellEffectFn(spell_mage_ice_lance::IndexTarget, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffectHitTarget += SpellEffectFn(spell_mage_ice_lance::HandleOnHit, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}

std::vector<ObjectGuid> _orderedTargets;
};

// 228598 - Ice Lance
class spell_mage_ice_lance_damage : public SpellScript
{
PrepareSpellScript(spell_mage_ice_lance_damage);

void ApplyDamageMultiplier(SpellEffIndex /*effIndex*/)
{
SpellValue const* spellValue = GetSpellValue();
if (spellValue->CustomBasePointsMask & (1 << EFFECT_1))
{
int32 originalDamage = GetHitDamage();
float targetIndex = float(spellValue->EffectBasePoints[EFFECT_1]);
float multiplier = std::pow(GetEffectInfo()->CalcDamageMultiplier(GetCaster(), GetSpell()), targetIndex);
SetHitDamage(int32(originalDamage * multiplier));
}
}

void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_mage_ice_lance_damage::ApplyDamageMultiplier, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};

// 12846 - Ignite
class spell_mage_ignite : public AuraScript
{
Expand Down Expand Up @@ -701,59 +802,6 @@ class spell_mage_water_elemental_freeze : public SpellScript
}
};

// Ice Lance - 30455
class spell_mage_ice_lance : public SpellScript
{
PrepareSpellScript(spell_mage_ice_lance);

bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({
SPELL_MAGE_ICE_LANCE,
SPELL_MAGE_ICE_LANCE_TRIGGER
});
}

void HandleOnHit(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
Unit* target = GetHitUnit();

bool targetFrozen = target->HasAuraState(AURA_STATE_FROZEN, GetSpellInfo(), caster);

// Thermal Void
if (caster->HasAura(SPELL_MAGE_THERMAL_VOID) && targetFrozen)
{
if (Aura* icyVeins = caster->GetAura(SPELL_MAGE_ICY_VEINS))
{
if (SpellInfo const* thermalVoidInfo = sSpellMgr->GetSpellInfo(SPELL_MAGE_THERMAL_VOID, GetCastDifficulty()))
{
if (SpellEffectInfo const* eff0 = thermalVoidInfo->GetEffect(EFFECT_0))
{
int32 increaseDuration = eff0->CalcValue() * IN_MILLISECONDS;
int32 newDuration = (icyVeins->GetDuration() + increaseDuration);
icyVeins->SetDuration(newDuration);
}
}
}
}

caster->CastSpell(target, SPELL_MAGE_ICE_LANCE_TRIGGER, true); // TODO damage x3 on frozen target

// Chain Reaction
if (targetFrozen)
caster->CastSpell(caster, SPELL_MAGE_CHAIN_REACTION, true);

if (Aura* fingersOfFrost = caster->GetAura(SPELL_MAGE_FINGERS_OF_FROST))
fingersOfFrost->ModStackAmount(-1);
}

void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_mage_ice_lance::HandleOnHit, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};

void AddSC_mage_spell_scripts()
{
RegisterAuraScript(spell_mage_blazing_barrier);
Expand All @@ -762,7 +810,10 @@ void AddSC_mage_spell_scripts()
RegisterSpellScript(spell_mage_cold_snap);
RegisterSpellScript(spell_mage_cone_of_cold);
RegisterSpellScript(spell_mage_conjure_refreshment);
RegisterAuraScript(spell_mage_fingers_of_frost);
RegisterAuraScript(spell_mage_ice_barrier);
RegisterSpellScript(spell_mage_ice_lance);
RegisterSpellScript(spell_mage_ice_lance_damage);
RegisterAuraScript(spell_mage_ignite);
RegisterAuraScript(spell_mage_imp_mana_gems);
RegisterSpellScript(spell_mage_living_bomb);
Expand All @@ -775,5 +826,4 @@ void AddSC_mage_spell_scripts()
RegisterSpellScript(spell_mage_time_warp);
RegisterSpellScript(spell_mage_trigger_chilled);
RegisterSpellScript(spell_mage_water_elemental_freeze);
RegisterSpellScript(spell_mage_ice_lance);
}

0 comments on commit 041ceee

Please sign in to comment.