aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/SpellMgr.cpp9
-rw-r--r--src/server/scripts/Pet/pet_generic.cpp167
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp77
3 files changed, 149 insertions, 104 deletions
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 6bff4534d36..7eda774f4c7 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -3398,15 +3398,6 @@ void SpellMgr::LoadSpellInfoCorrections()
spellEffectInfo->ApplyAuraName = SPELL_AURA_PERIODIC_TRIGGER_SPELL;
});
});
-
- // Lich Pet
- ApplySpellFix({ 70050 }, [](SpellInfo* spellInfo)
- {
- ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo)
- {
- spellEffectInfo->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 c473b591d5a..f63db95a1a2 100644
--- a/src/server/scripts/Pet/pet_generic.cpp
+++ b/src/server/scripts/Pet/pet_generic.cpp
@@ -16,20 +16,19 @@
*/
/*
- * 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 "PetDefines.h"
#include "Player.h"
#include "ScriptedCreature.h"
+#include "SpellAuraEffects.h"
+#include "SpellScript.h"
+#include "TemporarySummon.h"
enum PandarenMonkMisc
{
@@ -142,26 +141,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* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
+ {
+ PreventDefaultAction();
+
+ Unit* owner = GetUnitOwner();
+
+ std::list<TempSummon*> minionList;
+ owner->GetAllMinionsByEntry(minionList, NPC_LICH_PET);
+ for (TempSummon* 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);
}
};
@@ -169,5 +295,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 615cf7072e0..ed0d1706650 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -2073,80 +2073,6 @@ class spell_gen_increase_stats_buff : public SpellScriptLoader
}
};
-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* /* aurEff */, ProcEventInfo& /* eventInfo */)
- {
- PreventDefaultAction();
-
- std::list<TempSummon*> 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);
- }
-};
-
enum GenericLifebloom
{
SPELL_HEXLORD_MALACRASS_LIFEBLOOM_FINAL_HEAL = 43422,
@@ -5132,9 +5058,6 @@ void AddSC_generic_spell_scripts()
RegisterSpellScriptWithArgs(spell_gen_increase_stats_buff, "spell_pri_power_word_fortitude");
RegisterSpellScriptWithArgs(spell_gen_increase_stats_buff, "spell_pri_shadow_protection");
RegisterSpellScript(spell_gen_interrupt);
- RegisterSpellScript(spell_gen_lich_pet_aura);
- RegisterSpellScript(spell_gen_lich_pet_onsummon);
- RegisterSpellScript(spell_gen_lich_pet_aura_remove);
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);
RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_cenarion_scout_lifebloom", SPELL_CENARION_SCOUT_LIFEBLOOM_FINAL_HEAL);