Skip to content

Commit

Permalink
Pet/Misc: Implement Pandaran Monk's pet abilitys
Browse files Browse the repository at this point in the history
(cherry picked from commit 64d1add)
  • Loading branch information
Kittnz authored and Shauren committed Apr 2, 2016
1 parent f3fda53 commit c4b6e08
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sql/updates/world/2016_02_06_11.sql
@@ -0,0 +1,2 @@
-- Implement Pandaran Monk's pet abilitys
UPDATE creature_template SET ScriptName = "npc_pandaren_monk" WHERE entry = 36911;
95 changes: 95 additions & 0 deletions src/server/scripts/World/npcs_special.cpp
Expand Up @@ -2575,6 +2575,100 @@ class npc_egbert : public CreatureScript
}
};

enum PandarenMonkMisc
{
SPELL_PANDAREN_MONK = 69800,
EVENT_FOCUS = 1,
EVENT_EMOTE = 2,
EVENT_FOLLOW = 3,
EVENT_DRINK = 4
};

class npc_pandaren_monk : public CreatureScript
{
public:
npc_pandaren_monk() : CreatureScript("npc_pandaren_monk") {}

struct npc_pandaren_monkAI : public NullCreatureAI
{
npc_pandaren_monkAI(Creature* creature) : NullCreatureAI(creature) { }

void Reset() override
{
_events.Reset();
_events.ScheduleEvent(EVENT_FOCUS, 1000);
}

void EnterEvadeMode(EvadeReason why) override
{
if (!_EnterEvadeMode(why))
return;

Reset();
}

void ReceiveEmote(Player* player, uint32 emote) override
{
if (Unit* owner = me->GetCharmerOrOwner())
{
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
me->StopMoving();

switch (emote)
{
case TEXT_EMOTE_BOW:
_events.ScheduleEvent(EVENT_FOCUS, 1000);
break;
case TEXT_EMOTE_DRINK:
_events.ScheduleEvent(EVENT_DRINK, 1000);
break;
}
}
}

void UpdateAI(uint32 diff) override
{
_events.Update(diff);

if (Unit* owner = me->GetCharmerOrOwner())
if (!me->IsWithinDist(owner, 30.f))
me->InterruptSpell(CURRENT_CHANNELED_SPELL);

while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_FOCUS:
if (Unit* owner = me->GetCharmerOrOwner())
me->SetFacingToObject(owner);
_events.ScheduleEvent(EVENT_EMOTE, 1000);
break;
case EVENT_EMOTE:
me->HandleEmoteCommand(EMOTE_ONESHOT_BOW);
_events.ScheduleEvent(EVENT_FOLLOW, 1000);
break;
case EVENT_FOLLOW:
if (Unit* owner = me->GetCharmerOrOwner())
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
break;
case EVENT_DRINK:
me->CastSpell(me, SPELL_PANDAREN_MONK, false);
break;
default:
break;
}
}
}
private:
EventMap _events;
};

CreatureAI* GetAI(Creature* creature) const
{
return new npc_pandaren_monkAI(creature);
}
};

void AddSC_npcs_special()
{
new npc_air_force_bots();
Expand All @@ -2600,4 +2694,5 @@ void AddSC_npcs_special()
new npc_imp_in_a_ball();
new npc_train_wrecker();
new npc_egbert();
new npc_pandaren_monk();
}

0 comments on commit c4b6e08

Please sign in to comment.