Scripts/Pets: Implemented Elwynn Lamb minipet feature. (#29635)

This commit is contained in:
Mykhailo Redko
2024-02-23 22:33:55 +02:00
committed by GitHub
parent a666bdfc31
commit 6c181a00d5
2 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
-- Creature - 33200 - Elwynn Lamb
DELETE FROM `creature_template_addon` WHERE `entry` = 33200;
INSERT INTO `creature_template_addon` (`entry`, `path_id`, `mount`, `StandState`, `AnimTier`, `VisFlags`, `SheathState`, `PvpFlags`, `emote`, `auras`) VALUES
(33200, 0, 0, 0, 0, 0, 1, 0, 0, '62703');
UPDATE `creature_model_info` SET `BoundingRadius` = 0.65, `CombatReach` = 0.65 WHERE `DisplayID` = 16205;
-- Creature - 33286 - Elwynn Forest Wolf
UPDATE `creature_template` SET `unit_flags` = 768, `AIName` = '', `ScriptName` = 'npc_elwynn_forest_wolf' WHERE `entry` = 33286;
UPDATE `creature_model_info` SET `BoundingRadius` = 0.85 WHERE `DisplayID` = 28545;
-- Spell - 62701 - Elwynn Forest Wolf
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` = 62701;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES
(13, 1, 62701, 0, 0, 31, 0, 3, 33200, 0, 0, 0, 0, '', 'Spell \'Elwynn Forest Wolf\' only targets NPC \'Elwynn Lamb\'');
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_gen_elwynn_forest_wolf';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(62701, 'spell_gen_elwynn_forest_wolf');
-- Spell - 62703 - Elwynn Lamb
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_gen_elwynn_lamb';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(62703, 'spell_gen_elwynn_lamb');

View File

@@ -27,6 +27,7 @@
#include "ScriptedCreature.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
#include "ObjectAccessor.h"
enum PandarenMonkMisc
{
@@ -289,6 +290,127 @@ 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 /*context*/)
{
me->PlayDistanceSound(SOUND_WOLF_HOWL);
me->HandleEmoteCommand(EMOTE_ONESHOT_BATTLE_ROAR);
})
.Schedule(4s, [this](TaskContext /*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
{
PrepareSpellScript(spell_gen_elwynn_forest_wolf);
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
{
PrepareAuraScript(spell_gen_elwynn_lamb);
void HandlePeriodic(AuraEffect const* /*aurEff*/)
{
// Based on WotLK Classic sniffs (3.4.3 52237).
if (!GetTarget()->IsOutdoors() || !roll_chance_i(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);
@@ -299,4 +421,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);
}