diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 6 | ||||
-rw-r--r-- | src/server/scripts/Pet/pet_generic.cpp | 166 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 77 |
3 files changed, 148 insertions, 101 deletions
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index d3979a72246..c940accb449 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3081,12 +3081,6 @@ void SpellMgr::LoadSpellInfoCorrections() { spellInfo->_GetEffect(EFFECT_1).TriggerSpell = 46737; }); - - // Lich Pet - ApplySpellFix({ 70050 }, [](SpellInfo* spellInfo) - { - spellInfo->_GetEffect(EFFECT_0).TriggerSpell = 70049; - }); } // Allows those to crit diff --git a/src/server/scripts/Pet/pet_generic.cpp b/src/server/scripts/Pet/pet_generic.cpp index 1d3c44bfb3d..45f70bd6cb1 100644 --- a/src/server/scripts/Pet/pet_generic.cpp +++ b/src/server/scripts/Pet/pet_generic.cpp @@ -16,19 +16,17 @@ */ /* - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "npc_pet_gen_". + * Spell and creature scripts in this file are not ordered but grouped(all scripts related to same creature in same place). + * Scriptnames of spells and creatures in this file should be prefixed with "spell_pet_gen_" and "npc_pet_gen_" respectively. */ - /* ContentData - npc_pet_gen_pandaren_monk 100% Pandaren Monk drinks and bows with you - EndContentData */ - #include "ScriptMgr.h" #include "MotionMaster.h" #include "PassiveAI.h" #include "Player.h" #include "ScriptedCreature.h" +#include "SpellAuraEffects.h" +#include "SpellScript.h" enum PandarenMonkMisc { @@ -141,26 +139,153 @@ struct npc_pet_gen_soul_trader : public ScriptedAI enum LichPet { - SPELL_LICH_ONSUMMON = 69735, - SPELL_LICH_REMOVE_AURA = 69736 + SPELL_LICH_PET_AURA = 69732, + SPELL_LICH_PET_AURA_ONKILL = 69731, + SPELL_LICH_PET_EMOTE = 70049, + + NPC_LICH_PET = 36979 }; -struct npc_pet_lich : public ScriptedAI +// 69735 - Lich Pet OnSummon +class spell_pet_gen_lich_pet_onsummon : public SpellScript { - npc_pet_lich(Creature* creature) : ScriptedAI(creature) { } + PrepareSpellScript(spell_pet_gen_lich_pet_onsummon); - void OnDespawn() override + bool Validate(SpellInfo const* /*spellInfo*/) override { - if (Unit* owner = me->GetOwner()) - DoCast(owner, SPELL_LICH_REMOVE_AURA); + return ValidateSpellInfo({ SPELL_LICH_PET_AURA }); } - void JustAppeared() override + void HandleScript(SpellEffIndex /*effIndex*/) { - if (Unit* owner = me->GetOwner()) - DoCast(owner, SPELL_LICH_ONSUMMON); + Unit* target = GetHitUnit(); + target->CastSpell(target, SPELL_LICH_PET_AURA, true); + } - CreatureAI::JustAppeared(); + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_pet_gen_lich_pet_onsummon::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; + +// 69736 - Lich Pet Aura Remove +class spell_pet_gen_lich_pet_aura_remove : public SpellScript +{ + PrepareSpellScript(spell_pet_gen_lich_pet_aura_remove); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_LICH_PET_AURA }); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->RemoveAurasDueToSpell(SPELL_LICH_PET_AURA); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_pet_gen_lich_pet_aura_remove::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; + +// 69732 - Lich Pet Aura +class spell_pet_gen_lich_pet_aura : public AuraScript +{ + PrepareAuraScript(spell_pet_gen_lich_pet_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_LICH_PET_AURA_ONKILL }); + } + + bool CheckProc(ProcEventInfo& eventInfo) + { + return (eventInfo.GetProcTarget()->GetTypeId() == TYPEID_PLAYER); + } + + void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); + + Unit* owner = GetUnitOwner(); + + std::list<Creature*> minionList; + owner->GetAllMinionsByEntry(minionList, NPC_LICH_PET); + for (Creature* minion : minionList) + owner->CastSpell(minion, SPELL_LICH_PET_AURA_ONKILL, true); + } + + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_pet_gen_lich_pet_aura::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_pet_gen_lich_pet_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } +}; + +// 70050 - [DND] Lich Pet +class spell_pet_gen_lich_pet_periodic_emote : public AuraScript +{ + PrepareAuraScript(spell_pet_gen_lich_pet_periodic_emote); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_LICH_PET_EMOTE }); + } + + void OnPeriodic(AuraEffect const* /*aurEff*/) + { + // The chance to cast this spell is not 100%. + // Triggered spell roots creature for 3 sec and plays anim and sound (doesn't require any script). + // Emote and sound never shows up in sniffs because both comes from spell visual directly. + // Both 69683 and 70050 can trigger spells at once and are not linked together in any way. + // Effect of 70050 is overlapped by effect of 69683 but not instantly (69683 is a series of spell casts, takes longer to execute). + // However, for some reason emote is not played if creature is idle and only if creature is moving or is already rooted. + // For now it's scripted manually in script below to play emote always. + if (roll_chance_i(50)) + GetTarget()->CastSpell(GetTarget(), SPELL_LICH_PET_EMOTE, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_pet_gen_lich_pet_periodic_emote::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + +// 70049 - [DND] Lich Pet +class spell_pet_gen_lich_pet_emote : public AuraScript +{ + PrepareAuraScript(spell_pet_gen_lich_pet_emote); + + void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->HandleEmoteCommand(EMOTE_ONESHOT_CUSTOM_SPELL_01); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_pet_gen_lich_pet_emote::AfterApply, EFFECT_0, SPELL_AURA_MOD_ROOT, AURA_EFFECT_HANDLE_REAL); + } +}; + +// 69682 - Lil' K.T. Focus +class spell_pet_gen_lich_pet_focus : public SpellScript +{ + PrepareSpellScript(spell_pet_gen_lich_pet_focus); + + bool Validate(SpellInfo const* spellInfo) override + { + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue())); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_pet_gen_lich_pet_focus::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -168,5 +293,10 @@ void AddSC_generic_pet_scripts() { RegisterCreatureAI(npc_pet_gen_pandaren_monk); RegisterCreatureAI(npc_pet_gen_soul_trader); - RegisterCreatureAI(npc_pet_lich); + RegisterSpellScript(spell_pet_gen_lich_pet_onsummon); + RegisterSpellScript(spell_pet_gen_lich_pet_aura_remove); + RegisterSpellScript(spell_pet_gen_lich_pet_aura); + RegisterSpellScript(spell_pet_gen_lich_pet_periodic_emote); + RegisterSpellScript(spell_pet_gen_lich_pet_emote); + RegisterSpellScript(spell_pet_gen_lich_pet_focus); } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index f566bc99e00..559ef5e1a68 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -1965,80 +1965,6 @@ class spell_gen_injured : public SpellScript } }; -enum LichPet -{ - NPC_LICH_PET = 36979, - - SPELL_LICH_PET_AURA = 69732, - SPELL_LICH_PET_AURA_ONKILL = 69731 -}; - -// 69732 - Lich Pet Aura -class spell_gen_lich_pet_aura : public AuraScript -{ - PrepareAuraScript(spell_gen_lich_pet_aura); - - bool CheckProc(ProcEventInfo& eventInfo) - { - return (eventInfo.GetProcTarget()->GetTypeId() == TYPEID_PLAYER); - } - - void HandleProc(AuraEffect const* /* aurEff */, ProcEventInfo& /* eventInfo */) - { - PreventDefaultAction(); - - std::list<Creature*> minionList; - GetUnitOwner()->GetAllMinionsByEntry(minionList, NPC_LICH_PET); - for (Creature* minion : minionList) - if (minion->IsAIEnabled()) - minion->AI()->DoCastSelf(SPELL_LICH_PET_AURA_ONKILL); - } - - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_gen_lich_pet_aura::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_gen_lich_pet_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); - } -}; - -// 69735 - Lich Pet OnSummon -class spell_gen_lich_pet_onsummon : public SpellScript -{ - PrepareSpellScript(spell_gen_lich_pet_onsummon); - - bool Validate(SpellInfo const* /* spellInfo */) override - { - return ValidateSpellInfo({ SPELL_LICH_PET_AURA }); - } - - void HandleScriptEffect(SpellEffIndex /* effIndex */) - { - Unit* target = GetHitUnit(); - target->CastSpell(target, SPELL_LICH_PET_AURA, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_gen_lich_pet_onsummon::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } -}; - -// 69736 - Lich Pet Aura Remove -class spell_gen_lich_pet_aura_remove : public SpellScript -{ - PrepareSpellScript(spell_gen_lich_pet_aura_remove); - - void HandleScriptEffect(SpellEffIndex /* effIndex */) - { - GetHitUnit()->RemoveAurasDueToSpell(SPELL_LICH_PET_AURA); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_gen_lich_pet_aura_remove::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } -}; - class spell_gen_lifeblood : public AuraScript { PrepareAuraScript(spell_gen_lifeblood); @@ -4578,9 +4504,6 @@ void AddSC_generic_spell_scripts() RegisterSpellScript(spell_gen_gnomish_transporter); RegisterSpellScript(spell_gen_gryphon_wyvern_mount_check); RegisterSpellScript(spell_gen_injured); - RegisterSpellScript(spell_gen_lich_pet_aura); - RegisterSpellScript(spell_gen_lich_pet_onsummon); - RegisterSpellScript(spell_gen_lich_pet_aura_remove); RegisterSpellScript(spell_gen_lifeblood); RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_hexlord_lifebloom", SPELL_HEXLORD_MALACRASS_LIFEBLOOM_FINAL_HEAL); RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_tur_ragepaw_lifebloom", SPELL_TUR_RAGEPAW_LIFEBLOOM_FINAL_HEAL); |