From 08cdaec3f2bd2fbd4e3070f97e7a6938696e4cfa Mon Sep 17 00:00:00 2001 From: luis Date: Sun, 31 May 2026 13:38:19 -0300 Subject: [PATCH] missing --- src/server/scripts/Pet/pet_generic.cpp | 151 ++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 15 deletions(-) diff --git a/src/server/scripts/Pet/pet_generic.cpp b/src/server/scripts/Pet/pet_generic.cpp index 1dfdd65ca..861fb4d46 100644 --- a/src/server/scripts/Pet/pet_generic.cpp +++ b/src/server/scripts/Pet/pet_generic.cpp @@ -15,13 +15,14 @@ * with this program. If not, see . */ -/* - * 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. - */ + /* + * 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. + */ #include "ScriptMgr.h" #include "MotionMaster.h" +#include "ObjectAccessor.h" #include "PassiveAI.h" #include "PetDefines.h" #include "Player.h" @@ -41,7 +42,7 @@ enum PandarenMonkMisc struct npc_pet_gen_pandaren_monk : public NullCreatureAI { - npc_pet_gen_pandaren_monk(Creature* creature) : NullCreatureAI(creature) { } + npc_pet_gen_pandaren_monk(Creature* creature) : NullCreatureAI(creature) {} void Reset() override { @@ -113,15 +114,15 @@ private: enum SoulTrader { - SAY_SOUL_TRADER_INTRO = 0, + SAY_SOUL_TRADER_INTRO = 0, - SPELL_ETHEREAL_ONSUMMON = 50052, - SPELL_ETHEREAL_PET_REMOVE_AURA = 50055 + SPELL_ETHEREAL_ONSUMMON = 50052, + SPELL_ETHEREAL_PET_REMOVE_AURA = 50055 }; struct npc_pet_gen_soul_trader : public ScriptedAI { - npc_pet_gen_soul_trader(Creature* creature) : ScriptedAI(creature) { } + npc_pet_gen_soul_trader(Creature* creature) : ScriptedAI(creature) {} void OnDespawn() override { @@ -141,11 +142,11 @@ struct npc_pet_gen_soul_trader : public ScriptedAI enum LichPet { - SPELL_LICH_PET_AURA = 69732, - SPELL_LICH_PET_AURA_ONKILL = 69731, - SPELL_LICH_PET_EMOTE = 70049, + SPELL_LICH_PET_AURA = 69732, + SPELL_LICH_PET_AURA_ONKILL = 69731, + SPELL_LICH_PET_EMOTE = 70049, - NPC_LICH_PET = 36979 + NPC_LICH_PET = 36979 }; // 69735 - Lich Pet OnSummon @@ -265,12 +266,12 @@ class spell_pet_gen_lich_pet_focus : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue())); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt())); } void Register() override @@ -279,6 +280,123 @@ class spell_pet_gen_lich_pet_focus : public SpellScript } }; +enum ElwynnLambMisc +{ + // Spells + SPELL_SLEEPING_SLEEP = 32951, + SPELL_SUICIDE = 45254, + SPELL_ELWYNN_FOREST_WOLF = 62701, + + // Sound + SOUND_WOLF_HOWL = 9036, +}; + +struct npc_elwynn_forest_wolf : public NullCreatureAI +{ + npc_elwynn_forest_wolf(Creature* creature) : NullCreatureAI(creature), _chasing(false) {} + + void IsSummonedBy(WorldObject* summoner) override + { + if (!summoner->IsCreature()) + return; + + _summonerGUID = summoner->GetGUID(); + _ScheduleBeforeChasingEvents(); + } + + void MovementInform(uint32 type, uint32 id) override + { + if (type == CHASE_MOTION_TYPE && id == _summonerGUID.GetCounter()) + _ScheduleAfterChasingEvents(); + } + + void UpdateAI(uint32 diff) override + { + _scheduler.Update(diff); + + if (_chasing && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) + _ScheduleAfterChasingEvents(); + } + +private: + void _ScheduleBeforeChasingEvents() + { + _scheduler.Schedule(1s, [this](TaskContext const& /*context*/) + { + me->PlayDistanceSound(SOUND_WOLF_HOWL); + me->HandleEmoteCommand(EMOTE_ONESHOT_BATTLE_ROAR); + }) + .Schedule(4s, [this](TaskContext const& /*context*/) + { + if (Creature* summoner = ObjectAccessor::GetCreature(*me, _summonerGUID)) + if (me->Attack(summoner, false)) + me->GetMotionMaster()->MoveChase(summoner); + + _chasing = true; + }); + } + + void _ScheduleAfterChasingEvents() + { + _chasing = false; + me->GetMotionMaster()->Clear(); + + _scheduler.Schedule(2s, [this](TaskContext /*context*/) + { + DoCastAOE(SPELL_ELWYNN_FOREST_WOLF); + }) + .Schedule(4s, [this](TaskContext /*context*/) + { + DoCastSelf(SPELL_SLEEPING_SLEEP); + me->DespawnOrUnsummon(7s); + }); + } + + ObjectGuid _summonerGUID; + bool _chasing; + TaskScheduler _scheduler; +}; + +// 62701 - Elwynn Forest Wolf +class spell_gen_elwynn_forest_wolf : public SpellScript +{ + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_SUICIDE }); + } + + void HandleDummy(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (Creature* target = GetHitCreature()) + { + target->CastSpell(target, SPELL_SUICIDE, true); + target->DespawnOrUnsummon(4s); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_gen_elwynn_forest_wolf::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + +// 62703 - Elwynn Lamb +class spell_gen_elwynn_lamb : public AuraScript +{ + void HandlePeriodic(AuraEffect const* /*aurEff*/) + { + // Based on WotLK Classic sniffs (3.4.3 52237). + if (!GetTarget()->IsOutdoors() || !roll_chance(5)) + PreventDefaultAction(); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_elwynn_lamb::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + void AddSC_generic_pet_scripts() { RegisterCreatureAI(npc_pet_gen_pandaren_monk); @@ -289,4 +407,7 @@ void AddSC_generic_pet_scripts() RegisterSpellScript(spell_pet_gen_lich_pet_periodic_emote); RegisterSpellScript(spell_pet_gen_lich_pet_emote); RegisterSpellScript(spell_pet_gen_lich_pet_focus); + RegisterCreatureAI(npc_elwynn_forest_wolf); + RegisterSpellScript(spell_gen_elwynn_forest_wolf); + RegisterSpellScript(spell_gen_elwynn_lamb); }