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
  • Loading branch information
Kittnz committed Feb 6, 2016
1 parent d1a185e commit 859b617
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_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 @@ -2572,6 +2572,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 @@ -2597,4 +2661,5 @@ void AddSC_npcs_special()
new npc_imp_in_a_ball();
new npc_stable_master();
new npc_train_wrecker();
new npc_egbert();
}

4 comments on commit 859b617

@Kittnz
Copy link
Member Author

@Kittnz Kittnz commented on 859b617 Feb 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by me , @Rushor , @DevRival

@Aokromes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update core plz.

@Treeston
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-ups are 57a5879 and e064000

@LordUsagi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could've just applied the aura to egbert, 40670, which triggers 40669 periodically and causes a fear movement with a speed increase.

Please sign in to comment.