refactor(Script/Event): convert midsummer into new system (#9607)
This commit is contained in:
@@ -46,14 +46,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class npc_midsummer_bonfire : public CreatureScript
|
struct npc_midsummer_bonfire : public ScriptedAI
|
||||||
{
|
{
|
||||||
public:
|
npc_midsummer_bonfire(Creature* creature) : ScriptedAI(creature)
|
||||||
npc_midsummer_bonfire() : CreatureScript("npc_midsummer_bonfire") { }
|
|
||||||
|
|
||||||
struct npc_midsummer_bonfireAI : public ScriptedAI
|
|
||||||
{
|
|
||||||
npc_midsummer_bonfireAI(Creature* c) : ScriptedAI(c)
|
|
||||||
{
|
{
|
||||||
me->IsAIEnabled = true;
|
me->IsAIEnabled = true;
|
||||||
goGUID.Clear();
|
goGUID.Clear();
|
||||||
@@ -86,22 +81,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
CreatureAI* GetAI(Creature* creature) const override
|
|
||||||
{
|
|
||||||
return new npc_midsummer_bonfireAI(creature);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class npc_midsummer_torch_target : public CreatureScript
|
struct npc_midsummer_torch_target : public ScriptedAI
|
||||||
{
|
{
|
||||||
public:
|
npc_midsummer_torch_target(Creature* creature) : ScriptedAI(creature)
|
||||||
npc_midsummer_torch_target() : CreatureScript("npc_midsummer_torch_target") { }
|
|
||||||
|
|
||||||
struct npc_midsummer_torch_targetAI : public ScriptedAI
|
|
||||||
{
|
|
||||||
npc_midsummer_torch_targetAI(Creature* c) : ScriptedAI(c)
|
|
||||||
{
|
{
|
||||||
teleTimer = 0;
|
teleTimer = 0;
|
||||||
startTimer = 1;
|
startTimer = 1;
|
||||||
@@ -203,12 +187,6 @@ public:
|
|||||||
|
|
||||||
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation());
|
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation());
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
CreatureAI* GetAI(Creature* creature) const override
|
|
||||||
{
|
|
||||||
return new npc_midsummer_torch_targetAI(creature);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
@@ -222,14 +200,9 @@ enum CrabDisguise
|
|||||||
SPELL_FADE_DIGUISE = 47693,
|
SPELL_FADE_DIGUISE = 47693,
|
||||||
};
|
};
|
||||||
|
|
||||||
class spell_gen_crab_disguise : public SpellScriptLoader
|
class spell_gen_crab_disguise : public AuraScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareAuraScript(spell_gen_crab_disguise);
|
||||||
spell_gen_crab_disguise() : SpellScriptLoader("spell_gen_crab_disguise") { }
|
|
||||||
|
|
||||||
class spell_gen_crab_disguise_AuraScript : public AuraScript
|
|
||||||
{
|
|
||||||
PrepareAuraScript(spell_gen_crab_disguise_AuraScript);
|
|
||||||
|
|
||||||
bool Validate(SpellInfo const* /*spell*/) override
|
bool Validate(SpellInfo const* /*spell*/) override
|
||||||
{
|
{
|
||||||
@@ -256,14 +229,8 @@ public:
|
|||||||
|
|
||||||
void Register() override
|
void Register() override
|
||||||
{
|
{
|
||||||
AfterEffectApply += AuraEffectRemoveFn(spell_gen_crab_disguise_AuraScript::OnApply, EFFECT_0, SPELL_AURA_FORCE_REACTION, AURA_EFFECT_HANDLE_REAL);
|
AfterEffectApply += AuraEffectRemoveFn(spell_gen_crab_disguise::OnApply, EFFECT_0, SPELL_AURA_FORCE_REACTION, AURA_EFFECT_HANDLE_REAL);
|
||||||
AfterEffectRemove += AuraEffectRemoveFn(spell_gen_crab_disguise_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_FORCE_REACTION, AURA_EFFECT_HANDLE_REAL);
|
AfterEffectRemove += AuraEffectRemoveFn(spell_gen_crab_disguise::OnRemove, EFFECT_0, SPELL_AURA_FORCE_REACTION, AURA_EFFECT_HANDLE_REAL);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AuraScript* GetAuraScript() const override
|
|
||||||
{
|
|
||||||
return new spell_gen_crab_disguise_AuraScript();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -276,14 +243,9 @@ enum RibbonPole
|
|||||||
NPC_RIBBON_POLE_DEBUG_TARGET = 17066,
|
NPC_RIBBON_POLE_DEBUG_TARGET = 17066,
|
||||||
};
|
};
|
||||||
|
|
||||||
class spell_midsummer_ribbon_pole : public SpellScriptLoader
|
class spell_midsummer_ribbon_pole : public AuraScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareAuraScript(spell_midsummer_ribbon_pole)
|
||||||
spell_midsummer_ribbon_pole() : SpellScriptLoader("spell_midsummer_ribbon_pole") { }
|
|
||||||
|
|
||||||
class spell_midsummer_ribbon_pole_AuraScript : public AuraScript
|
|
||||||
{
|
|
||||||
PrepareAuraScript(spell_midsummer_ribbon_pole_AuraScript)
|
|
||||||
|
|
||||||
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
|
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
|
||||||
{
|
{
|
||||||
@@ -301,19 +263,18 @@ public:
|
|||||||
if (Aura* aur = target->GetAura(SPELL_RIBBON_POLE_XP))
|
if (Aura* aur = target->GetAura(SPELL_RIBBON_POLE_XP))
|
||||||
aur->SetDuration(std::min(aur->GetDuration() + 3 * MINUTE * IN_MILLISECONDS, 60 * MINUTE * IN_MILLISECONDS));
|
aur->SetDuration(std::min(aur->GetDuration() + 3 * MINUTE * IN_MILLISECONDS, 60 * MINUTE * IN_MILLISECONDS));
|
||||||
else
|
else
|
||||||
target->CastSpell(target, SPELL_RIBBON_POLE_XP, true);
|
|
||||||
|
|
||||||
if (roll_chance_i(5))
|
|
||||||
{
|
{
|
||||||
cr->Relocate(cr->GetPositionX(), cr->GetPositionY(), cr->GetPositionZ() - 6.5f);
|
target->CastSpell(target, SPELL_RIBBON_POLE_XP, true);
|
||||||
cr->CastSpell(cr, SPELL_RIBBON_POLE_FIREWORKS, true);
|
|
||||||
cr->Relocate(cr->GetPositionX(), cr->GetPositionY(), cr->GetPositionZ() + 6.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Achievement
|
// Achievement
|
||||||
if ((GameTime::GetGameTime().count() - GetApplyTime()) > 60 && target->GetTypeId() == TYPEID_PLAYER)
|
if ((GameTime::GetGameTime().count() - GetApplyTime()) > 60 && target->GetTypeId() == TYPEID_PLAYER)
|
||||||
target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 58934, 0, target);
|
target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 58934, 0, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Achievement
|
||||||
|
if ((time(nullptr) - GetApplyTime()) > 60 && target->GetTypeId() == TYPEID_PLAYER)
|
||||||
|
target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 58934, 0, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||||
@@ -324,25 +285,14 @@ public:
|
|||||||
|
|
||||||
void Register() override
|
void Register() override
|
||||||
{
|
{
|
||||||
OnEffectApply += AuraEffectApplyFn(spell_midsummer_ribbon_pole_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
OnEffectApply += AuraEffectApplyFn(spell_midsummer_ribbon_pole::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||||
OnEffectPeriodic += AuraEffectPeriodicFn(spell_midsummer_ribbon_pole_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
|
OnEffectPeriodic += AuraEffectPeriodicFn(spell_midsummer_ribbon_pole::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AuraScript* GetAuraScript() const override
|
|
||||||
{
|
|
||||||
return new spell_midsummer_ribbon_pole_AuraScript();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class spell_midsummer_torch_quest : public SpellScriptLoader
|
class spell_midsummer_torch_quest : public AuraScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareAuraScript(spell_midsummer_torch_quest)
|
||||||
spell_midsummer_torch_quest() : SpellScriptLoader("spell_midsummer_torch_quest") { }
|
|
||||||
|
|
||||||
class spell_midsummer_torch_quest_AuraScript : public AuraScript
|
|
||||||
{
|
|
||||||
PrepareAuraScript(spell_midsummer_torch_quest_AuraScript)
|
|
||||||
|
|
||||||
bool Load() override
|
bool Load() override
|
||||||
{
|
{
|
||||||
@@ -358,7 +308,7 @@ public:
|
|||||||
if (Creature* cr = ar->SummonCreature(25535, ar->GetPositionX(), ar->GetPositionY(), ar->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 90000))
|
if (Creature* cr = ar->SummonCreature(25535, ar->GetPositionX(), ar->GetPositionY(), ar->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 90000))
|
||||||
{
|
{
|
||||||
torchGUID = cr->GetGUID();
|
torchGUID = cr->GetGUID();
|
||||||
CAST_AI(npc_midsummer_torch_target::npc_midsummer_torch_targetAI, cr->AI())->SetPlayerGUID(ar->GetGUID(), (GetId() == 45716 ? 8 : 20));
|
CAST_AI(npc_midsummer_torch_target, cr->AI())->SetPlayerGUID(ar->GetGUID(), (GetId() == 45716 ? 8 : 20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,14 +320,8 @@ public:
|
|||||||
|
|
||||||
void Register() override
|
void Register() override
|
||||||
{
|
{
|
||||||
OnEffectApply += AuraEffectApplyFn(spell_midsummer_torch_quest_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DETECT_AMORE, AURA_EFFECT_HANDLE_REAL);
|
OnEffectApply += AuraEffectApplyFn(spell_midsummer_torch_quest::HandleEffectApply, EFFECT_0, SPELL_AURA_DETECT_AMORE, AURA_EFFECT_HANDLE_REAL);
|
||||||
OnEffectRemove += AuraEffectRemoveFn(spell_midsummer_torch_quest_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DETECT_AMORE, AURA_EFFECT_HANDLE_REAL);
|
OnEffectRemove += AuraEffectRemoveFn(spell_midsummer_torch_quest::HandleEffectRemove, EFFECT_0, SPELL_AURA_DETECT_AMORE, AURA_EFFECT_HANDLE_REAL);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AuraScript* GetAuraScript() const override
|
|
||||||
{
|
|
||||||
return new spell_midsummer_torch_quest_AuraScript();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -391,14 +335,9 @@ enum flingTorch
|
|||||||
SPELL_TORCH_COUNTER = 45693,
|
SPELL_TORCH_COUNTER = 45693,
|
||||||
};
|
};
|
||||||
|
|
||||||
class spell_midsummer_fling_torch : public SpellScriptLoader
|
class spell_midsummer_fling_torch : public SpellScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareSpellScript(spell_midsummer_fling_torch);
|
||||||
spell_midsummer_fling_torch() : SpellScriptLoader("spell_midsummer_fling_torch") {}
|
|
||||||
|
|
||||||
class spell_midsummer_fling_torch_SpellScript : public SpellScript
|
|
||||||
{
|
|
||||||
PrepareSpellScript(spell_midsummer_fling_torch_SpellScript);
|
|
||||||
|
|
||||||
bool handled;
|
bool handled;
|
||||||
bool Load() override { handled = false; return true; }
|
bool Load() override { handled = false; return true; }
|
||||||
@@ -493,22 +432,16 @@ public:
|
|||||||
|
|
||||||
void Register() override
|
void Register() override
|
||||||
{
|
{
|
||||||
AfterCast += SpellCastFn(spell_midsummer_fling_torch_SpellScript::HandleFinish);
|
AfterCast += SpellCastFn(spell_midsummer_fling_torch::HandleFinish);
|
||||||
if (m_scriptSpellId == 45671)
|
if (m_scriptSpellId == 45671)
|
||||||
{
|
{
|
||||||
OnCheckCast += SpellCheckCastFn(spell_midsummer_fling_torch_SpellScript::CheckCast);
|
OnCheckCast += SpellCheckCastFn(spell_midsummer_fling_torch::CheckCast);
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_midsummer_fling_torch_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
OnEffectHitTarget += SpellEffectFn(spell_midsummer_fling_torch::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<Creature*> _crList;
|
std::list<Creature*> _crList;
|
||||||
};
|
|
||||||
|
|
||||||
SpellScript* GetSpellScript() const override
|
|
||||||
{
|
|
||||||
return new spell_midsummer_fling_torch_SpellScript();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eJuggle
|
enum eJuggle
|
||||||
@@ -523,14 +456,9 @@ enum eJuggle
|
|||||||
QUEST_CHECK = 11937,
|
QUEST_CHECK = 11937,
|
||||||
};
|
};
|
||||||
|
|
||||||
class spell_midsummer_juggling_torch : public SpellScriptLoader
|
class spell_midsummer_juggling_torch : public SpellScript
|
||||||
{
|
{
|
||||||
public:
|
PrepareSpellScript(spell_midsummer_juggling_torch);
|
||||||
spell_midsummer_juggling_torch() : SpellScriptLoader("spell_midsummer_juggling_torch") {}
|
|
||||||
|
|
||||||
class spell_midsummer_juggling_torch_SpellScript : public SpellScript
|
|
||||||
{
|
|
||||||
PrepareSpellScript(spell_midsummer_juggling_torch_SpellScript);
|
|
||||||
|
|
||||||
bool handled;
|
bool handled;
|
||||||
bool Load() override { handled = false; return true; }
|
bool Load() override { handled = false; return true; }
|
||||||
@@ -573,15 +501,9 @@ public:
|
|||||||
void Register() override
|
void Register() override
|
||||||
{
|
{
|
||||||
if (m_scriptSpellId == SPELL_TORCH_CHECK)
|
if (m_scriptSpellId == SPELL_TORCH_CHECK)
|
||||||
OnEffectHitTarget += SpellEffectFn(spell_midsummer_juggling_torch_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
OnEffectHitTarget += SpellEffectFn(spell_midsummer_juggling_torch::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||||
else
|
else
|
||||||
AfterCast += SpellCastFn(spell_midsummer_juggling_torch_SpellScript::HandleFinish);
|
AfterCast += SpellCastFn(spell_midsummer_juggling_torch::HandleFinish);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SpellScript* GetSpellScript() const override
|
|
||||||
{
|
|
||||||
return new spell_midsummer_juggling_torch_SpellScript();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -589,13 +511,13 @@ void AddSC_event_midsummer_scripts()
|
|||||||
{
|
{
|
||||||
// NPCs
|
// NPCs
|
||||||
new go_midsummer_bonfire();
|
new go_midsummer_bonfire();
|
||||||
new npc_midsummer_bonfire();
|
RegisterCreatureAI(npc_midsummer_bonfire);
|
||||||
new npc_midsummer_torch_target();
|
RegisterCreatureAI(npc_midsummer_torch_target);
|
||||||
|
|
||||||
// Spells
|
// Spells
|
||||||
new spell_gen_crab_disguise();
|
RegisterSpellScript(spell_gen_crab_disguise);
|
||||||
new spell_midsummer_ribbon_pole();
|
RegisterSpellScript(spell_midsummer_ribbon_pole);
|
||||||
new spell_midsummer_torch_quest();
|
RegisterSpellScript(spell_midsummer_torch_quest);
|
||||||
new spell_midsummer_fling_torch();
|
RegisterSpellScript(spell_midsummer_fling_torch);
|
||||||
new spell_midsummer_juggling_torch();
|
RegisterSpellScript(spell_midsummer_juggling_torch);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user