refactor(Scripts/EasternKingdoms): spell scripts use registry macros (#20399)

This commit is contained in:
Jelle Meeus
2024-11-01 20:54:41 +01:00
committed by GitHub
parent bbbcaac77c
commit 7410175a08
9 changed files with 308 additions and 433 deletions

View File

@@ -153,30 +153,19 @@ public:
};
};
class spell_gnomeregan_radiation_bolt : public SpellScriptLoader
class spell_gnomeregan_radiation_bolt : public SpellScript
{
public:
spell_gnomeregan_radiation_bolt() : SpellScriptLoader("spell_gnomeregan_radiation_bolt") { }
PrepareSpellScript(spell_gnomeregan_radiation_bolt);
class spell_gnomeregan_radiation_bolt_SpellScript : public SpellScript
void HandleTriggerSpell(SpellEffIndex effIndex)
{
PrepareSpellScript(spell_gnomeregan_radiation_bolt_SpellScript);
if (roll_chance_i(80))
PreventHitDefaultEffect(effIndex);
}
void HandleTriggerSpell(SpellEffIndex effIndex)
{
if (roll_chance_i(80))
PreventHitDefaultEffect(effIndex);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_gnomeregan_radiation_bolt_SpellScript::HandleTriggerSpell, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL);
}
};
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_gnomeregan_radiation_bolt_SpellScript;
OnEffectHit += SpellEffectFn(spell_gnomeregan_radiation_bolt::HandleTriggerSpell, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL);
}
};
@@ -184,5 +173,5 @@ void AddSC_instance_gnomeregan()
{
new instance_gnomeregan();
new npc_kernobee();
new spell_gnomeregan_radiation_bolt();
RegisterSpellScript(spell_gnomeregan_radiation_bolt);
}

View File

@@ -157,31 +157,30 @@ private:
EventMap _events;
};
class spell_q12641_death_comes_from_on_high_summon_ghouls : public SpellScriptLoader
enum DeathComesFromOnHigh
{
public:
spell_q12641_death_comes_from_on_high_summon_ghouls() : SpellScriptLoader("spell_q12641_death_comes_from_on_high_summon_ghouls") { }
SUMMON_GHOULS_ON_SCARLET_CRUSADE = 54522
};
class spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript : public SpellScript
class spell_q12641_death_comes_from_on_high_summon_ghouls : public SpellScript
{
PrepareSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript);
return ValidateSpellInfo({ SUMMON_GHOULS_ON_SCARLET_CRUSADE });
}
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 54522, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
void HandleScriptEffect(SpellEffIndex effIndex)
{
return new spell_q12641_death_comes_from_on_high_summon_ghouls_SpellScript();
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), SUMMON_GHOULS_ON_SCARLET_CRUSADE, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12641_death_comes_from_on_high_summon_ghouls::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
@@ -406,64 +405,47 @@ enum GiftOfTheHarvester
SAY_GOTHIK_PIT = 0
};
class spell_item_gift_of_the_harvester : public SpellScriptLoader
class spell_item_gift_of_the_harvester : public SpellScript
{
public:
spell_item_gift_of_the_harvester() : SpellScriptLoader("spell_item_gift_of_the_harvester") { }
PrepareSpellScript(spell_item_gift_of_the_harvester);
class spell_item_gift_of_the_harvester_SpellScript : public SpellScript
SpellCastResult CheckRequirement()
{
PrepareSpellScript(spell_item_gift_of_the_harvester_SpellScript);
SpellCastResult CheckRequirement()
std::list<Creature*> ghouls;
GetCaster()->GetAllMinionsByEntry(ghouls, NPC_GHOUL);
if (ghouls.size() >= MAX_GHOULS)
{
std::list<Creature*> ghouls;
GetCaster()->GetAllMinionsByEntry(ghouls, NPC_GHOUL);
if (ghouls.size() >= MAX_GHOULS)
{
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_TOO_MANY_GHOULS);
return SPELL_FAILED_CUSTOM_ERROR;
}
return SPELL_CAST_OK;
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_TOO_MANY_GHOULS);
return SPELL_FAILED_CUSTOM_ERROR;
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_item_gift_of_the_harvester_SpellScript::CheckRequirement);
}
};
return SPELL_CAST_OK;
}
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_item_gift_of_the_harvester_SpellScript();
OnCheckCast += SpellCheckCastFn(spell_item_gift_of_the_harvester::CheckRequirement);
}
};
class spell_q12698_the_gift_that_keeps_on_giving : public SpellScriptLoader
class spell_q12698_the_gift_that_keeps_on_giving : public SpellScript
{
public:
spell_q12698_the_gift_that_keeps_on_giving() : SpellScriptLoader("spell_q12698_the_gift_that_keeps_on_giving") { }
PrepareSpellScript(spell_q12698_the_gift_that_keeps_on_giving);
class spell_q12698_the_gift_that_keeps_on_giving_SpellScript : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareSpellScript(spell_q12698_the_gift_that_keeps_on_giving_SpellScript);
return ValidateSpellInfo({ SPELL_SUMMON_SCARLET_GHOST });
}
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
if (GetOriginalCaster() && GetHitUnit())
GetOriginalCaster()->CastSpell(GetHitUnit(), urand(0, 1) ? GetEffectValue() : SPELL_SUMMON_SCARLET_GHOST, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12698_the_gift_that_keeps_on_giving_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
return new spell_q12698_the_gift_that_keeps_on_giving_SpellScript();
if (GetOriginalCaster() && GetHitUnit())
GetOriginalCaster()->CastSpell(GetHitUnit(), urand(0, 1) ? GetEffectValue() : SPELL_SUMMON_SCARLET_GHOST, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q12698_the_gift_that_keeps_on_giving::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
@@ -1237,10 +1219,10 @@ void AddSC_the_scarlet_enclave_c1()
{
// Ours
RegisterCreatureAI(npc_eye_of_acherus);
new spell_q12641_death_comes_from_on_high_summon_ghouls();
RegisterSpellScript(spell_q12641_death_comes_from_on_high_summon_ghouls);
new npc_death_knight_initiate();
new spell_item_gift_of_the_harvester();
new spell_q12698_the_gift_that_keeps_on_giving();
RegisterSpellScript(spell_item_gift_of_the_harvester);
RegisterSpellScript(spell_q12698_the_gift_that_keeps_on_giving);
new npc_scarlet_ghoul();
new npc_dkc1_gothik();
new npc_scarlet_cannon();

View File

@@ -1177,75 +1177,53 @@ public:
};
};
class spell_chapter5_light_of_dawn_aura : public SpellScriptLoader
class spell_chapter5_light_of_dawn_aura : public AuraScript
{
public:
spell_chapter5_light_of_dawn_aura() : SpellScriptLoader("spell_chapter5_light_of_dawn_aura") { }
PrepareAuraScript(spell_chapter5_light_of_dawn_aura);
class spell_chapter5_light_of_dawn_aura_AuraScript : public AuraScript
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PrepareAuraScript(spell_chapter5_light_of_dawn_aura_AuraScript);
GetUnitOwner()->Dismount();
GetUnitOwner()->SetCanFly(true);
GetUnitOwner()->SetDisableGravity(true);
GetUnitOwner()->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->Dismount();
GetUnitOwner()->SetCanFly(true);
GetUnitOwner()->SetDisableGravity(true);
GetUnitOwner()->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->SetCanFly(false);
GetUnitOwner()->SetDisableGravity(false);
GetUnitOwner()->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
GetUnitOwner()->GetMotionMaster()->MoveFall();
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_chapter5_light_of_dawn_aura_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_chapter5_light_of_dawn_aura_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
return new spell_chapter5_light_of_dawn_aura_AuraScript();
GetUnitOwner()->SetCanFly(false);
GetUnitOwner()->SetDisableGravity(false);
GetUnitOwner()->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
GetUnitOwner()->GetMotionMaster()->MoveFall();
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_chapter5_light_of_dawn_aura::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_chapter5_light_of_dawn_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_chapter5_rebuke : public SpellScriptLoader
class spell_chapter5_rebuke : public SpellScript
{
public:
spell_chapter5_rebuke() : SpellScriptLoader("spell_chapter5_rebuke") { }
PrepareSpellScript(spell_chapter5_rebuke);
class spell_chapter5_rebuke_SpellScript : public SpellScript
void HandleLeapBack(SpellEffIndex effIndex)
{
PrepareSpellScript(spell_chapter5_rebuke_SpellScript);
PreventHitEffect(effIndex);
if (Unit* unitTarget = GetHitUnit())
unitTarget->KnockbackFrom(2282.86f, -5263.45f, 40.0f, 8.0f);
}
void HandleLeapBack(SpellEffIndex effIndex)
{
PreventHitEffect(effIndex);
if (Unit* unitTarget = GetHitUnit())
unitTarget->KnockbackFrom(2282.86f, -5263.45f, 40.0f, 8.0f);
}
void Register() override
{
OnEffectLaunchTarget += SpellEffectFn(spell_chapter5_rebuke_SpellScript::HandleLeapBack, EFFECT_0, SPELL_EFFECT_LEAP_BACK);
}
};
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_chapter5_rebuke_SpellScript();
OnEffectLaunchTarget += SpellEffectFn(spell_chapter5_rebuke::HandleLeapBack, EFFECT_0, SPELL_EFFECT_LEAP_BACK);
}
};
void AddSC_the_scarlet_enclave_c5()
{
new npc_highlord_darion_mograine();
new spell_chapter5_light_of_dawn_aura();
new spell_chapter5_rebuke();
RegisterSpellScript(spell_chapter5_light_of_dawn_aura);
RegisterSpellScript(spell_chapter5_rebuke);
}

View File

@@ -246,86 +246,64 @@ public:
};
};
class spell_scholomance_fixate : public SpellScriptLoader
class spell_scholomance_fixate_aura : public AuraScript
{
public:
spell_scholomance_fixate() : SpellScriptLoader("spell_scholomance_fixate") { }
PrepareAuraScript(spell_scholomance_fixate_aura);
class spell_scholomance_fixate_AuraScript : public AuraScript
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PrepareAuraScript(spell_scholomance_fixate_AuraScript);
Unit* target = GetTarget();
if (Unit* caster = GetCaster())
caster->TauntApply(target);
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
if (Unit* caster = GetCaster())
caster->TauntApply(target);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
if (Unit* caster = GetCaster())
caster->TauntFadeOut(target);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_scholomance_fixate_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_scholomance_fixate_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
return new spell_scholomance_fixate_AuraScript();
Unit* target = GetTarget();
if (Unit* caster = GetCaster())
caster->TauntFadeOut(target);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_scholomance_fixate_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_scholomance_fixate_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_scholomance_boon_of_life : public SpellScriptLoader
class spell_scholomance_boon_of_life_aura : public AuraScript
{
public:
spell_scholomance_boon_of_life() : SpellScriptLoader("spell_scholomance_boon_of_life") { }
PrepareAuraScript(spell_scholomance_boon_of_life_aura);
class spell_scholomance_boon_of_life_AuraScript : public AuraScript
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PrepareAuraScript(spell_scholomance_boon_of_life_AuraScript);
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
if (Unit* target = GetTarget())
if (Creature* creature = target->ToCreature())
{
creature->AI()->AttackStart(caster);
creature->AddThreat(caster, 10000.0f);
}
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
if (Unit* target = GetTarget())
if (Creature* creature = target->ToCreature())
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_CANCEL)
{
creature->AI()->Talk(TALK_RAS_HUMAN);
creature->SetDisplayId(MODEL_RAS_HUMAN);
creature->SetHealth(target->GetMaxHealth());
if (InstanceScript* instance = creature->GetInstanceScript())
instance->SetData(DATA_RAS_HUMAN, 1);
}
}
{
creature->AI()->AttackStart(caster);
creature->AddThreat(caster, 10000.0f);
}
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_scholomance_boon_of_life_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
AfterEffectApply += AuraEffectApplyFn(spell_scholomance_boon_of_life_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
return new spell_scholomance_boon_of_life_AuraScript();
if (Unit* target = GetTarget())
if (Creature* creature = target->ToCreature())
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_CANCEL)
{
creature->AI()->Talk(TALK_RAS_HUMAN);
creature->SetDisplayId(MODEL_RAS_HUMAN);
creature->SetHealth(target->GetMaxHealth());
if (InstanceScript* instance = creature->GetInstanceScript())
instance->SetData(DATA_RAS_HUMAN, 1);
}
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_scholomance_boon_of_life_aura::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
AfterEffectApply += AuraEffectApplyFn(spell_scholomance_boon_of_life_aura::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
@@ -460,7 +438,7 @@ public:
void AddSC_instance_scholomance()
{
new instance_scholomance();
new spell_scholomance_fixate();
new spell_scholomance_boon_of_life();
RegisterSpellScript(spell_scholomance_fixate_aura);
RegisterSpellScript(spell_scholomance_boon_of_life_aura);
new npc_scholomance_occultist();
}

View File

@@ -137,42 +137,31 @@ public:
};
};
class spell_shadowfang_keep_haunting_spirits : public SpellScriptLoader
class spell_shadowfang_keep_haunting_spirits_aura : public AuraScript
{
public:
spell_shadowfang_keep_haunting_spirits() : SpellScriptLoader("spell_shadowfang_keep_haunting_spirits") { }
PrepareAuraScript(spell_shadowfang_keep_haunting_spirits_aura);
class spell_shadowfang_keep_haunting_spirits_AuraScript : public AuraScript
void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
{
PrepareAuraScript(spell_shadowfang_keep_haunting_spirits_AuraScript);
isPeriodic = true;
amplitude = irand(30 * IN_MILLISECONDS, 90 * IN_MILLISECONDS);
}
void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
{
isPeriodic = true;
amplitude = irand(30 * IN_MILLISECONDS, 90 * IN_MILLISECONDS);
}
void HandleDummyTick(AuraEffect const* aurEff)
{
GetTarget()->CastSpell((Unit*)nullptr, aurEff->GetAmount(), true);
}
void HandleUpdatePeriodic(AuraEffect* aurEff)
{
aurEff->CalculatePeriodic(GetCaster());
}
void Register() override
{
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_shadowfang_keep_haunting_spirits_AuraScript::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_shadowfang_keep_haunting_spirits_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_shadowfang_keep_haunting_spirits_AuraScript::HandleUpdatePeriodic, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
void HandleDummyTick(AuraEffect const* aurEff)
{
return new spell_shadowfang_keep_haunting_spirits_AuraScript();
GetTarget()->CastSpell((Unit*)nullptr, aurEff->GetAmount(), true);
}
void HandleUpdatePeriodic(AuraEffect* aurEff)
{
aurEff->CalculatePeriodic(GetCaster());
}
void Register() override
{
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_shadowfang_keep_haunting_spirits_aura::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_shadowfang_keep_haunting_spirits_aura::HandleDummyTick, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_shadowfang_keep_haunting_spirits_aura::HandleUpdatePeriodic, EFFECT_0, SPELL_AURA_DUMMY);
}
};
@@ -182,58 +171,70 @@ enum ForsakenSpells
SPELL_FORSAKEN_SKILL_SHADOW = 7053
};
class spell_shadowfang_keep_forsaken_skills : public SpellScriptLoader
class spell_shadowfang_keep_forsaken_skills_aura : public AuraScript
{
public:
spell_shadowfang_keep_forsaken_skills() : SpellScriptLoader("spell_shadowfang_keep_forsaken_skills") { }
PrepareAuraScript(spell_shadowfang_keep_forsaken_skills_aura);
class spell_shadowfang_keep_forsaken_skills_AuraScript : public AuraScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareAuraScript(spell_shadowfang_keep_forsaken_skills_AuraScript);
bool Load() override
{
_forsakenSpell = 0;
return true;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
_forsakenSpell = urand(SPELL_FORSAKEN_SKILL_SWORD, SPELL_FORSAKEN_SKILL_SHADOW);
if (_forsakenSpell == SPELL_FORSAKEN_SKILL_SHADOW - 1)
++_forsakenSpell;
GetUnitOwner()->CastSpell(GetUnitOwner(), _forsakenSpell, true);
}
void HandleDummyTick(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
GetUnitOwner()->RemoveAurasDueToSpell(_forsakenSpell);
_forsakenSpell = urand(SPELL_FORSAKEN_SKILL_SWORD, SPELL_FORSAKEN_SKILL_SHADOW);
if (_forsakenSpell == SPELL_FORSAKEN_SKILL_SHADOW - 1)
++_forsakenSpell;
GetUnitOwner()->CastSpell(GetUnitOwner(), _forsakenSpell, true);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_shadowfang_keep_forsaken_skills_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_shadowfang_keep_forsaken_skills_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
}
private:
uint32 _forsakenSpell;
};
AuraScript* GetAuraScript() const override
{
return new spell_shadowfang_keep_forsaken_skills_AuraScript();
return ValidateSpellInfo(
{
SPELL_FORSAKEN_SKILL_SWORD,
SPELL_FORSAKEN_SKILL_SWORD+1,
SPELL_FORSAKEN_SKILL_SWORD+2,
SPELL_FORSAKEN_SKILL_SWORD+3,
SPELL_FORSAKEN_SKILL_SWORD+4,
SPELL_FORSAKEN_SKILL_SWORD+5,
SPELL_FORSAKEN_SKILL_SWORD+6,
SPELL_FORSAKEN_SKILL_SWORD+7,
SPELL_FORSAKEN_SKILL_SWORD+8,
SPELL_FORSAKEN_SKILL_SWORD+9,
SPELL_FORSAKEN_SKILL_SWORD+10,
SPELL_FORSAKEN_SKILL_SWORD+11,
SPELL_FORSAKEN_SKILL_SWORD+12,
SPELL_FORSAKEN_SKILL_SWORD+13,
// SPELL_FORSAKEN_SKILL_SHADOW-1, // not used
SPELL_FORSAKEN_SKILL_SHADOW,
});
}
bool Load() override
{
_forsakenSpell = 0;
return true;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
_forsakenSpell = urand(SPELL_FORSAKEN_SKILL_SWORD, SPELL_FORSAKEN_SKILL_SHADOW);
if (_forsakenSpell == SPELL_FORSAKEN_SKILL_SHADOW - 1)
++_forsakenSpell;
GetUnitOwner()->CastSpell(GetUnitOwner(), _forsakenSpell, true);
}
void HandleDummyTick(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
GetUnitOwner()->RemoveAurasDueToSpell(_forsakenSpell);
_forsakenSpell = urand(SPELL_FORSAKEN_SKILL_SWORD, SPELL_FORSAKEN_SKILL_SHADOW);
if (_forsakenSpell == SPELL_FORSAKEN_SKILL_SHADOW - 1)
++_forsakenSpell;
GetUnitOwner()->CastSpell(GetUnitOwner(), _forsakenSpell, true);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_shadowfang_keep_forsaken_skills_aura::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_shadowfang_keep_forsaken_skills_aura::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
}
private:
uint32 _forsakenSpell;
};
void AddSC_instance_shadowfang_keep()
{
new instance_shadowfang_keep();
new spell_shadowfang_keep_haunting_spirits();
new spell_shadowfang_keep_forsaken_skills();
RegisterSpellScript(spell_shadowfang_keep_haunting_spirits_aura);
RegisterSpellScript(spell_shadowfang_keep_forsaken_skills_aura);
}

View File

@@ -227,71 +227,54 @@ public:
}
};
class spell_temple_of_atal_hakkar_hex_of_jammal_an : public SpellScriptLoader
class spell_temple_of_atal_hakkar_hex_of_jammal_an_aura : public AuraScript
{
public:
spell_temple_of_atal_hakkar_hex_of_jammal_an() : SpellScriptLoader("spell_temple_of_atal_hakkar_hex_of_jammal_an") { }
PrepareAuraScript(spell_temple_of_atal_hakkar_hex_of_jammal_an_aura);
class spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript : public AuraScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareAuraScript(spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript);
return ValidateSpellInfo({ HEX_OF_JAMMAL_AN, HEX_OF_JAMMAL_AN_CHARM });
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
if (caster->IsAlive() && caster->IsInCombat())
{
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN, true);
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN_CHARM, true);
}
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
return new spell_temple_of_atal_hakkar_hex_of_jammal_an_AuraScript();
if (Unit* caster = GetCaster())
if (caster->IsAlive() && caster->IsInCombat())
{
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN, true);
caster->CastSpell(GetTarget(), HEX_OF_JAMMAL_AN_CHARM, true);
}
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_temple_of_atal_hakkar_hex_of_jammal_an_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_temple_of_atal_hakkar_awaken_the_soulflayer : public SpellScriptLoader
class spell_temple_of_atal_hakkar_awaken_the_soulflayer : public SpellScript
{
public:
spell_temple_of_atal_hakkar_awaken_the_soulflayer() : SpellScriptLoader("spell_temple_of_atal_hakkar_awaken_the_soulflayer") { }
PrepareSpellScript(spell_temple_of_atal_hakkar_awaken_the_soulflayer);
class spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript : public SpellScript
void HandleSendEvent(SpellEffIndex effIndex)
{
PrepareSpellScript(spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript);
PreventHitDefaultEffect(effIndex);
InstanceScript* instanceScript = GetCaster()->GetInstanceScript();
Map* map = GetCaster()->FindMap();
if (!map || !instanceScript || instanceScript->GetData(TYPE_HAKKAR_EVENT) != NOT_STARTED)
return;
void HandleSendEvent(SpellEffIndex effIndex)
Position pos = {-466.795f, 272.863f, -90.447f, 1.57f};
if (TempSummon* summon = map->SummonCreature(NPC_SHADE_OF_HAKKAR, pos))
{
PreventHitDefaultEffect(effIndex);
InstanceScript* instanceScript = GetCaster()->GetInstanceScript();
Map* map = GetCaster()->FindMap();
if (!map || !instanceScript || instanceScript->GetData(TYPE_HAKKAR_EVENT) != NOT_STARTED)
return;
Position pos = {-466.795f, 272.863f, -90.447f, 1.57f};
if (TempSummon* summon = map->SummonCreature(NPC_SHADE_OF_HAKKAR, pos))
{
summon->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN);
instanceScript->SetData(TYPE_HAKKAR_EVENT, IN_PROGRESS);
}
summon->SetTempSummonType(TEMPSUMMON_MANUAL_DESPAWN);
instanceScript->SetData(TYPE_HAKKAR_EVENT, IN_PROGRESS);
}
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_temple_of_atal_hakkar_awaken_the_soulflayer_SpellScript();
OnEffectHit += SpellEffectFn(spell_temple_of_atal_hakkar_awaken_the_soulflayer::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
@@ -299,6 +282,6 @@ void AddSC_instance_sunken_temple()
{
new instance_sunken_temple();
new at_malfurion_stormrage();
new spell_temple_of_atal_hakkar_hex_of_jammal_an();
new spell_temple_of_atal_hakkar_awaken_the_soulflayer();
RegisterSpellScript(spell_temple_of_atal_hakkar_hex_of_jammal_an_aura);
RegisterSpellScript(spell_temple_of_atal_hakkar_awaken_the_soulflayer);
}

View File

@@ -140,30 +140,19 @@ public:
}
};
class spell_uldaman_sub_boss_agro_keepers : public SpellScriptLoader
class spell_uldaman_sub_boss_agro_keepers : public SpellScript
{
public:
spell_uldaman_sub_boss_agro_keepers() : SpellScriptLoader("spell_uldaman_sub_boss_agro_keepers") { }
PrepareSpellScript(spell_uldaman_sub_boss_agro_keepers);
class spell_uldaman_sub_boss_agro_keepers_SpellScript : public SpellScript
void HandleSendEvent(SpellEffIndex /*effIndex*/)
{
PrepareSpellScript(spell_uldaman_sub_boss_agro_keepers_SpellScript);
if (Creature* keeper = GetCaster()->FindNearestCreature(NPC_STONE_KEEPER, 100.0f, true))
keeper->AI()->SetData(1, 1);
}
void HandleSendEvent(SpellEffIndex /*effIndex*/)
{
if (Creature* keeper = GetCaster()->FindNearestCreature(NPC_STONE_KEEPER, 100.0f, true))
keeper->AI()->SetData(1, 1);
}
void Register() override
{
OnEffectLaunch += SpellEffectFn(spell_uldaman_sub_boss_agro_keepers_SpellScript::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_uldaman_sub_boss_agro_keepers_SpellScript();
OnEffectLaunch += SpellEffectFn(spell_uldaman_sub_boss_agro_keepers::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
@@ -172,84 +161,62 @@ enum UldamanStonedEnum
MAP_ULDAMAN = 70
};
class spell_uldaman_stoned : public SpellScriptLoader
class spell_uldaman_stoned_aura : public AuraScript
{
public:
spell_uldaman_stoned() : SpellScriptLoader("spell_uldaman_stoned") { }
PrepareAuraScript(spell_uldaman_stoned_aura);
class spell_uldaman_stoned_AuraScript : public AuraScript
bool Load() override
{
PrepareAuraScript(spell_uldaman_stoned_AuraScript);
return GetUnitOwner()->IsCreature() && GetUnitOwner()->GetMapId() == MAP_ULDAMAN;
}
bool Load() override
{
return GetUnitOwner()->IsCreature() && GetUnitOwner()->GetMapId() == MAP_ULDAMAN;
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Creature* target = GetUnitOwner()->ToCreature();
target->SetReactState(REACT_PASSIVE);
target->SetImmuneToAll(true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Creature* target = GetUnitOwner()->ToCreature();
target->SetReactState(REACT_AGGRESSIVE);
target->SetImmuneToAll(false);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_uldaman_stoned_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_uldaman_stoned_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
return new spell_uldaman_stoned_AuraScript();
Creature* target = GetUnitOwner()->ToCreature();
target->SetReactState(REACT_PASSIVE);
target->SetImmuneToAll(true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Creature* target = GetUnitOwner()->ToCreature();
target->SetReactState(REACT_AGGRESSIVE);
target->SetImmuneToAll(false);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_uldaman_stoned_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_uldaman_stoned_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_uldaman_boss_agro_archaedas : public SpellScriptLoader
class spell_uldaman_boss_agro_archaedas : public SpellScript
{
public:
spell_uldaman_boss_agro_archaedas() : SpellScriptLoader("spell_uldaman_boss_agro_archaedas") { }
PrepareSpellScript(spell_uldaman_boss_agro_archaedas);
class spell_uldaman_boss_agro_archaedas_SpellScript : public SpellScript
void HandleSendEvent(SpellEffIndex /*effIndex*/)
{
PrepareSpellScript(spell_uldaman_boss_agro_archaedas_SpellScript);
InstanceScript* instance = GetCaster()->GetInstanceScript();
void HandleSendEvent(SpellEffIndex /*effIndex*/)
{
InstanceScript* instance = GetCaster()->GetInstanceScript();
if (!instance || instance->GetData(DATA_ARCHAEDAS) == IN_PROGRESS || instance->GetData(DATA_ARCHAEDAS) == DONE)
return;
if (!instance || instance->GetData(DATA_ARCHAEDAS) == IN_PROGRESS || instance->GetData(DATA_ARCHAEDAS) == DONE)
return;
instance->SetData(DATA_ARCHAEDAS, IN_PROGRESS);
if (Creature* archaedas = GetCaster()->FindNearestCreature(NPC_ARCHAEDAS, 100.0f, true))
archaedas->AI()->SetData(1, 1);
}
instance->SetData(DATA_ARCHAEDAS, IN_PROGRESS);
if (Creature* archaedas = GetCaster()->FindNearestCreature(NPC_ARCHAEDAS, 100.0f, true))
archaedas->AI()->SetData(1, 1);
}
void Register() override
{
OnEffectLaunch += SpellEffectFn(spell_uldaman_boss_agro_archaedas_SpellScript::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_uldaman_boss_agro_archaedas_SpellScript();
OnEffectLaunch += SpellEffectFn(spell_uldaman_boss_agro_archaedas::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
void AddSC_instance_uldaman()
{
new instance_uldaman();
new spell_uldaman_sub_boss_agro_keepers();
new spell_uldaman_stoned();
new spell_uldaman_boss_agro_archaedas();
RegisterSpellScript(spell_uldaman_sub_boss_agro_keepers);
RegisterSpellScript(spell_uldaman_stoned_aura);
RegisterSpellScript(spell_uldaman_boss_agro_archaedas);
}

View File

@@ -710,44 +710,33 @@ private:
InstanceScript* instance;
};
class spell_threatening_gaze : public SpellScriptLoader
class spell_threatening_gaze_aura : public AuraScript
{
public:
spell_threatening_gaze() : SpellScriptLoader("spell_threatening_gaze") { }
PrepareAuraScript(spell_threatening_gaze_aura);
class spell_threatening_gaze_AuraScript : public AuraScript
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PrepareAuraScript(spell_threatening_gaze_AuraScript);
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE)
{
if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE)
if (Unit* target = GetTarget())
{
if (Unit* target = GetTarget())
if (Unit* caster = GetCaster())
{
if (Unit* caster = GetCaster())
if (Creature* cCaster = caster->ToCreature())
{
if (Creature* cCaster = caster->ToCreature())
if (cCaster->IsAIEnabled)
{
if (cCaster->IsAIEnabled)
{
cCaster->AI()->SetGUID(target->GetGUID(), ACTION_CHARGE);
}
cCaster->AI()->SetGUID(target->GetGUID(), ACTION_CHARGE);
}
}
}
}
}
}
void Register() override
{
OnEffectRemove += AuraEffectRemoveFn(spell_threatening_gaze_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
void Register() override
{
return new spell_threatening_gaze_AuraScript();
OnEffectRemove += AuraEffectRemoveFn(spell_threatening_gaze_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
@@ -798,7 +787,7 @@ void AddSC_boss_mandokir()
new npc_ohgan();
RegisterZulGurubCreatureAI(npc_chained_spirit);
RegisterZulGurubCreatureAI(npc_vilebranch_speaker);
new spell_threatening_gaze();
RegisterSpellScript(spell_threatening_gaze_aura);
RegisterSpellScript(spell_mandokir_charge);
RegisterSpellScript(spell_threatening_gaze_charge);
}