diff options
author | offl <11556157+offl@users.noreply.github.com> | 2022-06-30 22:32:09 +0300 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-09-05 19:46:54 +0200 |
commit | d68abbf705a870009213d8558de2884950875029 (patch) | |
tree | ed82d5833c35c9cb99af1e5c2b0ff12395dd9b6f | |
parent | b0164fb2b9cc35663e337d48660d5bca1e973d99 (diff) |
Scripts/Pets: Update Lil' K.T. (#28071)
(cherry picked from commit dfd1692e3136606e4633db45cba0871316c0d651)
-rw-r--r-- | sql/updates/world/master/2022_09_05_14_world_2022_06_30_00_world.sql | 55 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 9 | ||||
-rw-r--r-- | src/server/scripts/Pet/pet_generic.cpp | 167 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 77 |
4 files changed, 204 insertions, 104 deletions
diff --git a/sql/updates/world/master/2022_09_05_14_world_2022_06_30_00_world.sql b/sql/updates/world/master/2022_09_05_14_world_2022_06_30_00_world.sql new file mode 100644 index 00000000000..5201a0ef842 --- /dev/null +++ b/sql/updates/world/master/2022_09_05_14_world_2022_06_30_00_world.sql @@ -0,0 +1,55 @@ +-- +UPDATE `spell_script_names` SET `ScriptName` = 'spell_pet_gen_lich_pet_onsummon' WHERE `ScriptName` = 'spell_gen_lich_pet_onsummon'; +UPDATE `spell_script_names` SET `ScriptName` = 'spell_pet_gen_lich_pet_aura_remove' WHERE `ScriptName` = 'spell_gen_lich_pet_aura_remove'; +UPDATE `spell_script_names` SET `ScriptName` = 'spell_pet_gen_lich_pet_aura' WHERE `ScriptName` = 'spell_gen_lich_pet_aura'; + +DELETE FROM `spell_script_names` WHERE `ScriptName` IN ( +'spell_pet_gen_lich_pet_periodic_emote', +'spell_pet_gen_lich_pet_emote', +'spell_pet_gen_lich_pet_focus'); +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(70050,'spell_pet_gen_lich_pet_periodic_emote'), +(70049,'spell_pet_gen_lich_pet_emote'), +(69682,'spell_pet_gen_lich_pet_focus'); + +DELETE FROM `spell_linked_spell` WHERE `spell_trigger` = 70049; +DELETE FROM `spell_scripts` WHERE `id` IN (69731,69682); + +UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = 36979; +DELETE FROM `smart_scripts` WHERE `entryorguid` = 36979 AND `source_type` = 0; +DELETE FROM `smart_scripts` WHERE `entryorguid` IN (3697900,3697901) AND `source_type` = 9; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`event_param5`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_param4`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(36979,0,0,0,11,0,100,0,0,0,0,0,0,11,69735,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Spawn - Cast 'Lich Pet OnSummon'"), +(36979,0,1,0,86,0,100,0,0,0,0,0,0,11,69736,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Despawn - Cast 'Lich Pet Aura Remove'"), +(36979,0,2,0,8,0,100,0,69731,0,0,0,0,80,3697900,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Spellhit 'Lich Pet Aura OnKill' - Run Script"), +(36979,0,3,0,83,0,100,0,69681,0,0,0,0,80,3697901,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Spell Cast 'Lil' Frost Blast' - Run Script"), + +-- Movement is definitely paused in both cases. +-- If we root creature, and if both emote event and critter event will be executed at once, root will be cleared on aura remove, in other +-- words before we clean it manually in script. That will screw up entire critter event. And doesn't really look like it should be rooted, +-- more like movement is stopped. But packets are different. + +-- The only way they can temporarily stop movement here is replace one action list by another. +-- But that would mean they somehow overwrited default pet follow by scripted follow, would be weird. +-- Actually we have a bunch of guardians and their default follow movement is somehow completely ignored by creature: Khadgar's Servant, +-- Ancestral Spirit Wolf. Both actually are scripted on retail using only one action list which handles everything from spawn to despawn. +-- At the same time Fel Guard Hound follows owner after spawn by default but has again one action list which interrupts default follow +-- movement and resumes it after action list is finished. Kindal Moonweaver is a bit different because follow movement is launched from +-- very first action list and is paused by another she executes(https://youtu.be/GV64q-i420o?t=115). +-- So it looks like execution of any action list pauses follow movement no matter is it scripted or is default. Will such global mechanic +-- work always without any problems? No idea. Something to think of. + +(3697900,9,0,0,0,0,100,0,0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Stop Follow"), +(3697900,9,1,0,0,0,100,0,0,0,0,0,0,4,16493,0,1,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Play Sound 16493"), +(3697900,9,2,0,0,0,100,0,0,0,0,0,0,17,451,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Set Emote State 451"), +(3697900,9,3,0,0,0,100,0,1000,1000,0,0,0,17,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Set Emote State 0"), +(3697900,9,4,0,0,0,100,0,3000,3000,0,0,0,29,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Start Follow Owner"), + +(3697901,9,0,0,0,0,100,0,0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Stop Follow"), +(3697901,9,1,0,0,0,100,0,2000,2000,0,0,0,4,16493,0,1,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Play Sound 16493"), +(3697901,9,2,0,0,0,100,0,0,0,0,0,0,17,451,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Set Emote State 451"), +(3697901,9,3,0,0,0,100,0,1000,1000,0,0,0,17,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Set Emote State 0"), +(3697901,9,4,0,0,0,100,0,3000,3000,0,0,0,29,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,"Lil' K.T. - On Script - Start Follow Owner"); + +-- Never was needed, never will work the way author expected +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 17 AND `SourceEntry` IN (71849,69683); 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); |