aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/world/2016_04_02_21_world_2016_02_06_00_world.sql2
-rw-r--r--src/server/scripts/World/npcs_special.cpp65
2 files changed, 67 insertions, 0 deletions
diff --git a/sql/updates/world/2016_04_02_21_world_2016_02_06_00_world.sql b/sql/updates/world/2016_04_02_21_world_2016_02_06_00_world.sql
new file mode 100644
index 00000000000..d303a8b5b85
--- /dev/null
+++ b/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;
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 4279d2517cb..5fbfeddbfc3 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -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();
@@ -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();
}