Skip to content

Commit

Permalink
Pet/Misc: Implement Egbert's running around
Browse files Browse the repository at this point in the history
Closes #16479

(cherry picked from commit 859b617)
  • Loading branch information
Kittnz authored and Shauren committed Apr 2, 2016
1 parent 33593ce commit a8504c6
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sql/updates/world/2016_04_02_21_world_2016_02_06_00_world.sql
@@ -0,0 +1,2 @@
-- Implement Egbert's running
UPDATE creature_template SET ScriptName = "npc_egbert" WHERE entry = 23258;
65 changes: 65 additions & 0 deletions src/server/scripts/World/npcs_special.cpp
Expand Up @@ -2513,6 +2513,70 @@ class npc_train_wrecker : public CreatureScript
}
};

enum EgbertMisc
{
EVENT_MOVE_POS = 1,
EVENT_RETURN = 2
};

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

struct npc_egbertAI : public PetAI
{
npc_egbertAI(Creature* creature) : PetAI(creature)
{
if (Unit* owner = me->GetCharmerOrOwner())
if (owner->GetMap()->GetEntry()->addon > 1)
me->SetCanFly(true);
}

void Reset() override
{
_events.Reset();
_events.ScheduleEvent(EVENT_MOVE_POS, urand(1.0, 20.0) * IN_MILLISECONDS);
}

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

while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_MOVE_POS:
if (Unit* owner = me->GetCharmerOrOwner())
{
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MovePoint(0, owner->GetPositionX() + frand(-30.0f, 30.0f), owner->GetPositionY() + frand(-30.0f, 30.0f), owner->GetPositionZ());
}
_events.ScheduleEvent(EVENT_RETURN, urand(3.0, 4.0) * IN_MILLISECONDS);
break;
case EVENT_RETURN:
if (Unit* owner = me->GetCharmerOrOwner())
{
me->GetMotionMaster()->MoveFollow(me->GetCharmerOrOwner(), PET_FOLLOW_DIST, me->GetFollowAngle());
}
_events.ScheduleEvent(EVENT_MOVE_POS, urand(1.0, 20.0) * IN_MILLISECONDS);
break;
default:
break;
}
}
}
private:
EventMap _events;
};

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

void AddSC_npcs_special()
{
new npc_air_force_bots();
Expand All @@ -2537,4 +2601,5 @@ void AddSC_npcs_special()
new npc_spring_rabbit();
new npc_imp_in_a_ball();
new npc_train_wrecker();
new npc_egbert();
}

0 comments on commit a8504c6

Please sign in to comment.