refactor(Core/Scripts): Spell To Scripts (#9718)

This commit is contained in:
IntelligentQuantum
2021-12-21 17:43:45 +03:30
committed by GitHub
parent 838c88f45a
commit 11a734bf2b
6 changed files with 103 additions and 31 deletions

View File

@@ -17,6 +17,7 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "ruins_of_ahnqiraj.h"
enum Yells
@@ -124,7 +125,29 @@ public:
}
};
class spell_rajaxx_thundercrash : public SpellScript
{
PrepareSpellScript(spell_rajaxx_thundercrash);
void HandleDamageCalc(SpellEffIndex /*effIndex*/)
{
int32 damage = GetHitUnit()->GetHealth() / 2;
if (damage < 200)
{
damage = 200;
}
SetHitDamage(damage);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_rajaxx_thundercrash::HandleDamageCalc, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};
void AddSC_boss_rajaxx()
{
new boss_rajaxx();
RegisterSpellScript(spell_rajaxx_thundercrash);
}

View File

@@ -431,8 +431,25 @@ public:
}
};
class spell_four_horsemen_consumption : public SpellScript
{
PrepareSpellScript(spell_four_horsemen_consumption);
void HandleDamageCalc(SpellEffIndex /*effIndex*/)
{
uint32 damage = GetCaster()->GetMap()->ToInstanceMap()->GetDifficulty() == REGULAR_DIFFICULTY ? 2750 : 4250;
SetHitDamage(damage);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_four_horsemen_consumption::HandleDamageCalc, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};
void AddSC_boss_four_horsemen()
{
new boss_four_horsemen();
new spell_four_horsemen_mark();
RegisterSpellScript(spell_four_horsemen_consumption);
}

View File

@@ -28,6 +28,7 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
// TODO: this import is not necessary for compilation and marked as unused by the IDE
// however, for some reasons removing it would cause a damn linking issue
@@ -306,10 +307,35 @@ public:
}
};
class spell_pet_dk_gargoyle_strike : public SpellScript
{
PrepareSpellScript(spell_pet_dk_gargoyle_strike);
void HandleDamageCalc(SpellEffIndex /*effIndex*/)
{
int32 damage = 60;
if (Unit* caster = GetCaster())
{
if (caster->getLevel() >= 60)
{
damage += (caster->getLevel() - 60) * 4;
}
}
SetHitDamage(damage);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_pet_dk_gargoyle_strike::HandleDamageCalc, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
}
};
void AddSC_deathknight_pet_scripts()
{
new npc_pet_dk_ebon_gargoyle();
new npc_pet_dk_ghoul();
new npc_pet_dk_army_of_the_dead();
new npc_pet_dk_dancing_rune_weapon();
RegisterSpellScript(spell_pet_dk_gargoyle_strike);
}

View File

@@ -4363,6 +4363,29 @@ class spell_gen_holiday_buff_food : public AuraScript
}
};
class spell_gen_arcane_charge : public SpellScript
{
PrepareSpellScript(spell_gen_arcane_charge);
SpellCastResult CheckRequirement()
{
if (Unit* target = GetExplTargetUnit())
{
if (target->GetCreatureType() != CREATURE_TYPE_DEMON && target->GetCreatureType() != CREATURE_TYPE_UNDEAD)
{
return SPELL_FAILED_DONT_REPORT;
}
}
return SPELL_CAST_OK;
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_gen_arcane_charge::CheckRequirement);
}
};
void AddSC_generic_spell_scripts()
{
RegisterSpellScript(spell_silithyst);
@@ -4495,4 +4518,5 @@ void AddSC_generic_spell_scripts()
RegisterSpellScript(spell_gen_charmed_unit_spell_cooldown);
RegisterSpellScript(spell_contagion_of_rot);
RegisterSpellScript(spell_gen_holiday_buff_food);
RegisterSpellScript(spell_gen_arcane_charge);
}