Skip to content

Commit

Permalink
Spell/Unit: Port several more spells from unit damage handlers to spe…
Browse files Browse the repository at this point in the history
…ll scripts
  • Loading branch information
killerwife committed Sep 29, 2023
1 parent 5c4aa5f commit 0ce14cc
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 70 deletions.
12 changes: 12 additions & 0 deletions sql/scriptdev2/spell.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,10 @@ INSERT INTO spell_scripts(Id, ScriptName) VALUES
(47578,'spell_twisted_faith'),
(51166,'spell_twisted_faith'),
(51167,'spell_twisted_faith'),
(55682,'spell_glyph_of_shadow_word_death'),
(47558,'spell_test_of_faith'),
(47559,'spell_test_of_faith'),
(47560,'spell_test_of_faith'),
(34861,'spell_circle_of_healing'),
(34863,'spell_circle_of_healing'),
(34864,'spell_circle_of_healing'),
Expand Down Expand Up @@ -1262,6 +1266,12 @@ INSERT INTO spell_scripts(Id, ScriptName) VALUES
(47198,'spell_deaths_embrace'),
(47199,'spell_deaths_embrace'),
(47200,'spell_deaths_embrace'),
(1120,'spell_drain_soul'),
(8288,'spell_drain_soul'),
(8289,'spell_drain_soul'),
(11675,'spell_drain_soul'),
(27217,'spell_drain_soul'),
(47855,'spell_drain_soul'),
(48018,'spell_demonic_circle_summon'),
(48020,'spell_demonic_circle_teleport');

Expand Down Expand Up @@ -1447,6 +1457,7 @@ INSERT INTO spell_scripts(Id, ScriptName) VALUES
(57850,'spell_improved_insect_swarm'),
(57851,'spell_improved_insect_swarm'),
(69366,'spell_moonkin_form_passive'),
(54743,'spell_glyph_of_regrowth'),
(40121,'spell_swift_flight_form_passive');

-- Rogue
Expand Down Expand Up @@ -1530,6 +1541,7 @@ INSERT INTO spell_scripts(Id, ScriptName) VALUES
(51479,'spell_astral_shift_shaman'),
(51505,'spell_lava_burst'),
(60043,'spell_lava_burst'),
(55438,'spell_glyph_of_lesser_healing_wave'),
(2825,'spell_heroism_bloodlust'),
(32182,'spell_heroism_bloodlust');

Expand Down
68 changes: 0 additions & 68 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8046,16 +8046,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel
}
break;
}
case SPELLFAMILY_WARLOCK:
{
// Drain Soul
if (spellInfo->SpellFamilyFlags & uint64(0x0000000000004000))
{
if (victim->GetHealth() * 100 / victim->GetMaxHealth() <= 25)
DoneTotalMod *= 4;
}
break;
}
case SPELLFAMILY_PRIEST:
{
// Smite
Expand All @@ -8067,39 +8057,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel
if (Aura* aur = GetAura(55692, EFFECT_INDEX_0))
DoneTotalMod *= (aur->GetModifier()->m_amount + 100.0f) / 100.0f;
}
// Shadow word: Death
else if (spellInfo->IsFitToFamilyMask(uint64(0x0000000200000000)))
{
// Glyph of Shadow word: Death
if (SpellAuraHolder const* glyph = GetSpellAuraHolder(55682))
{
Aura const* hpPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_0);
Aura const* dmPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_1);
if (hpPct && dmPct && victim->GetHealth() * 100 <= victim->GetMaxHealth() * hpPct->GetModifier()->m_amount)
DoneTotalMod *= (dmPct->GetModifier()->m_amount + 100.0f) / 100.0f;
}
}
break;
}
case SPELLFAMILY_DRUID:
{
// Improved Insect Swarm (Wrath part)
if (spellInfo->SpellFamilyFlags & uint64(0x0000000000000001))
{
// if Insect Swarm on target
if (victim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, uint64(0x000000000200000), 0, GetObjectGuid()))
{
Unit::AuraList const& improvedSwarm = GetAurasByType(SPELL_AURA_DUMMY);
for (auto iter : improvedSwarm)
{
if (iter->GetSpellProto()->SpellIconID == 1771)
{
DoneTotalMod *= (iter->GetModifier()->m_amount + 100.0f) / 100.0f;
break;
}
}
}
}
break;
}
case SPELLFAMILY_DEATHKNIGHT:
Expand Down Expand Up @@ -8132,13 +8089,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel
}
}
}
// Death Coil (bonus from Item - Death Knight T8 DPS Relic)
else if (spellInfo->SpellFamilyFlags & uint64(0x00002000))
{
if (Aura* sigil = GetDummyAura(64962))
DoneTotal += sigil->GetModifier()->m_amount;
}
break;
}
default:
break;
Expand Down Expand Up @@ -8331,18 +8281,6 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellInfo, in
continue;
switch (i->GetModifier()->m_miscvalue)
{
case 21: // Test of Faith
case 6935:
case 6918:
if (victim->GetHealth() < victim->GetMaxHealth() / 2)
DoneTotalMod *= (i->GetModifier()->m_amount + 100.0f) / 100.0f;
break;
case 7798: // Glyph of Regrowth
{
if (victim->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, uint64(0x0000000000000040)))
DoneTotalMod *= (i->GetModifier()->m_amount + 100.0f) / 100.0f;
break;
}
case 8477: // Nourish Heal Boost
{
int32 stepPercent = i->GetModifier()->m_amount;
Expand All @@ -8359,12 +8297,6 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellInfo, in
DoneTotalMod *= (stepPercent * ownHotCount + 100.0f) / 100.0f;
break;
}
case 7871: // Glyph of Lesser Healing Wave
{
if (victim->GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, uint64(0x0000040000000000), 0, GetObjectGuid()))
DoneTotalMod *= (i->GetModifier()->m_amount + 100.0f) / 100.0f;
break;
}
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ struct DeathCoilDK : public SpellScript
}
else
{
if (Aura* sigil = caster->GetDummyAura(64962))
damage += sigil->GetAmount();
int32 bp = damage;
caster->CastCustomSpell(target, 47632, &bp, nullptr, nullptr, TRIGGERED_OLD_TRIGGERED);
}
Expand Down
22 changes: 20 additions & 2 deletions src/game/Spells/Scripts/Scripting/ClassScripts/Druid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ struct ImprovedInsectSwarm : public AuraScript

void OnCritChanceCalculate(Aura* aura, Unit const* target, float& chance, SpellEntry const* /*spellInfo*/) const override
{
if (target->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, uint64(0x000000000000002), 0, aura->GetTarget()->GetObjectGuid())) chance += aura->GetModifier()->m_amount; // Weakened Soul
if (target->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, uint64(0x000000000000002), 0, aura->GetTarget()->GetObjectGuid())) chance += aura->GetModifier()->m_amount; // Starfire
}

void OnDamageCalculate(Aura* aura, Unit* /*attacker*/, Unit* victim, int32& /*advertisedBenefit*/, float& totalMod) const override
{
if (victim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, uint64(0x00200000), 0, aura->GetTarget()->GetObjectGuid())) totalMod *= (aura->GetModifier()->m_amount + 100.0f) / 100.0f;
if (victim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, uint64(0x00200000), 0, aura->GetTarget()->GetObjectGuid())) totalMod *= (aura->GetModifier()->m_amount + 100.0f) / 100.0f; // Wrath
}
};

Expand All @@ -231,6 +231,23 @@ struct StarfireBonus : public AuraScript
}
};

// 54743 - Glyph of Regrowth
struct GlyphOfRegrowth : public AuraScript
{
void OnApply(Aura* aura, bool apply) const override
{
if (aura->GetEffIndex() == EFFECT_INDEX_0)
aura->GetTarget()->RegisterScriptedLocationAura(aura, SCRIPT_LOCATION_SPELL_HEALING_DONE, apply);
}

void OnDamageCalculate(Aura* aura, Unit* /*attacker*/, Unit* victim, int32& /*advertisedBenefit*/, float& totalMod) const override
{
// Regrowth
if (victim->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_SHAMAN, uint64(0x0000000000000040), 0, aura->GetTarget()->GetObjectGuid()))
totalMod *= (aura->GetModifier()->m_amount + 100.0f) / 100.0f;
}
};

void LoadDruidScripts()
{
RegisterSpellScript<Regrowth>("spell_regrowth");
Expand All @@ -245,4 +262,5 @@ void LoadDruidScripts()
RegisterSpellScript<PrimalTenacity>("spell_primal_tenacity");
RegisterSpellScript<MoonkinFormPassive>("spell_moonkin_form_passive");
RegisterSpellScript<ImprovedInsectSwarm>("spell_improved_insect_swarm");
RegisterSpellScript<GlyphOfRegrowth>("spell_glyph_of_regrowth");
}
37 changes: 37 additions & 0 deletions src/game/Spells/Scripts/Scripting/ClassScripts/Priest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,41 @@ struct TwistedFaith : public AuraScript
}
};

// 55682 - Glyph of Shadow Word: Death
struct GlyphOfShadowWordDeath : public AuraScript
{
void OnApply(Aura* aura, bool apply) const override
{
if (aura->GetEffIndex() == EFFECT_INDEX_0)
aura->GetTarget()->RegisterScriptedLocationAura(aura, SCRIPT_LOCATION_SPELL_DAMAGE_DONE, apply);
}

void OnDamageCalculate(Aura* aura, Unit* /*attacker*/, Unit* victim, int32& /*advertisedBenefit*/, float& totalMod) const override
{
SpellAuraHolder* holder = aura->GetHolder();
Aura const* hpPct = holder->GetAuraByEffectIndex(EFFECT_INDEX_0);
Aura const* dmPct = holder->GetAuraByEffectIndex(EFFECT_INDEX_1);
if (hpPct && dmPct && victim->GetHealth() * 100 <= victim->GetMaxHealth() * hpPct->GetModifier()->m_amount)
totalMod *= (dmPct->GetModifier()->m_amount + 100.0f) / 100.0f;
}
};

// 47558 - Test of Faith
struct TestOfFaith : public AuraScript
{
void OnApply(Aura* aura, bool apply) const override
{
if (aura->GetEffIndex() == EFFECT_INDEX_0)
aura->GetTarget()->RegisterScriptedLocationAura(aura, SCRIPT_LOCATION_SPELL_HEALING_DONE, apply);
}

void OnDamageCalculate(Aura* aura, Unit* /*attacker*/, Unit* victim, int32& /*advertisedBenefit*/, float& totalMod) const override
{
if (victim->GetHealth() < victim->GetMaxHealth() / 2)
totalMod *= (aura->GetModifier()->m_amount + 100.0f) / 100.0f;
}
};

void LoadPriestScripts()
{
RegisterSpellScript<PowerInfusion>("spell_power_infusion");
Expand All @@ -446,4 +481,6 @@ void LoadPriestScripts()
RegisterSpellScript<RenewedHopeDamageTaken>("spell_renewed_hope_damage_taken");
RegisterSpellScript<ImprovedFlashHeal>("spell_improved_flash_heal");
RegisterSpellScript<TwistedFaith>("spell_twisted_faith");
RegisterSpellScript<GlyphOfShadowWordDeath>("spell_glyph_of_shadow_word_death");
RegisterSpellScript<TestOfFaith>("spell_test_of_faith");
}
18 changes: 18 additions & 0 deletions src/game/Spells/Scripts/Scripting/ClassScripts/Shaman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,23 @@ struct LavaBurst : public SpellScript
}
};

// 55438 - Glyph of Lesser Healing Wave
struct GlyphOfLesserHealingWave : public AuraScript
{
void OnApply(Aura* aura, bool apply) const override
{
if (aura->GetEffIndex() == EFFECT_INDEX_0)
aura->GetTarget()->RegisterScriptedLocationAura(aura, SCRIPT_LOCATION_SPELL_HEALING_DONE, apply);
}

void OnDamageCalculate(Aura* aura, Unit* /*attacker*/, Unit* victim, int32& /*advertisedBenefit*/, float& totalMod) const override
{
// Earth Shield
if (victim->GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, uint64(0x0000040000000000), 0, aura->GetTarget()->GetObjectGuid()))
totalMod *= (aura->GetModifier()->m_amount + 100.0f) / 100.0f;
}
};

void LoadShamanScripts()
{
Script* pNewScript = new Script;
Expand All @@ -340,4 +357,5 @@ void LoadShamanScripts()
RegisterSpellScript<FireNovaShaman>("spell_fire_nova_shaman");
RegisterSpellScript<AstralShiftShaman>("spell_astral_shift_shaman");
RegisterSpellScript<LavaBurst>("spell_lava_burst");
RegisterSpellScript<GlyphOfLesserHealingWave>("spell_glyph_of_lesser_healing_wave");
}
11 changes: 11 additions & 0 deletions src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,16 @@ struct DeathsEmbrace : public AuraScript
}
};

// 1120 - Drain Soul
struct DrainSoul : public AuraScript
{
void OnPeriodicCalculateAmount(Aura* aura, uint32& amount) const override
{
if (aura->GetTarget()->GetHealthPercent() <= 25.f)
amount *= 4; // can be done here because amount contains all done bonuses already
}
};

void LoadWarlockScripts()
{
RegisterSpellScript<UnstableAffliction>("spell_unstable_affliction");
Expand All @@ -516,4 +526,5 @@ void LoadWarlockScripts()
RegisterSpellScript<DemonicCircleSummon>("spell_demonic_circle_summon");
RegisterSpellScript<GlyphOfShadowburn>("spell_glyph_of_shadowburn");
RegisterSpellScript<DeathsEmbrace>("spell_deaths_embrace");
RegisterSpellScript<DrainSoul>("spell_drain_soul");
}

0 comments on commit 0ce14cc

Please sign in to comment.