Skip to content

Commit

Permalink
Fix build & tabs
Browse files Browse the repository at this point in the history
(cherry picked from commit 57a5879)
  • Loading branch information
Kittnz authored and Shauren committed Apr 2, 2016
1 parent a8504c6 commit 422c8a9
Showing 1 changed file with 56 additions and 55 deletions.
111 changes: 56 additions & 55 deletions src/server/scripts/World/npcs_special.cpp
Expand Up @@ -57,6 +57,7 @@ EndContentData */
#include "CellImpl.h"
#include "SpellAuras.h"
#include "Pet.h"
#include "PetAI.h"
#include "CreatureTextMgr.h"
#include "SpellHistory.h"

Expand Down Expand Up @@ -2515,66 +2516,66 @@ class npc_train_wrecker : public CreatureScript

enum EgbertMisc
{
EVENT_MOVE_POS = 1,
EVENT_RETURN = 2
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);
}
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()
Expand Down

0 comments on commit 422c8a9

Please sign in to comment.