aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKittnz <frederik156@hotmail.com>2016-02-13 12:06:19 +0100
committerKittnz <frederik156@hotmail.com>2016-02-13 12:06:19 +0100
commit2322ef3f501489b5723ebe922c966e7d77b7b55e (patch)
tree035468aac7351f2bfe6f9d577ce47f8cbfc076fb /src
parent98860911e237e147c6ffb544c730a8c37de000eb (diff)
Pet/Misc: Improve Egbert's AI
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/World/npcs_special.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 0fb0bd7943c..bb28f660e1d 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -39,6 +39,7 @@ npc_shadowfiend 100% restore 5% of owner's mana when shadowfiend die f
npc_locksmith 75% list of keys needs to be confirmed
npc_firework 100% NPC's summoned by rockets and rocket clusters, for making them cast visual
npc_train_wrecker 100% Wind-Up Train Wrecker that kills train set
+npc_egbert 100% Egbert run's around
EndContentData */
#include "ScriptMgr.h"
@@ -2574,8 +2575,9 @@ class npc_train_wrecker : public CreatureScript
enum EgbertMisc
{
- EVENT_MOVE_POS = 1,
- EVENT_RETURN = 2
+ SPELL_EGBERT = 40670,
+ SPELL_EGBERT2 = 40669,
+ EVENT_RETURN = 3,
};
class npc_egbert : public CreatureScript
@@ -2583,9 +2585,9 @@ class npc_egbert : public CreatureScript
public:
npc_egbert() : CreatureScript("npc_egbert") {}
- struct npc_egbertAI : public PetAI
+ struct npc_egbertAI : public NullCreatureAI
{
- npc_egbertAI(Creature* creature) : PetAI(creature)
+ npc_egbertAI(Creature* creature) : NullCreatureAI(creature)
{
if (Unit* owner = me->GetCharmerOrOwner())
if (owner->GetMap()->GetEntry()->addon > 1)
@@ -2595,29 +2597,41 @@ public:
void Reset() override
{
_events.Reset();
- _events.ScheduleEvent(EVENT_MOVE_POS, urandms(1, 20));
+ if (Unit* owner = me->GetCharmerOrOwner())
+ me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle());
+ me->CastSpell(me, SPELL_EGBERT);
+ }
+
+ void EnterEvadeMode(EvadeReason why) override
+ {
+ if (!_EnterEvadeMode(why))
+ return;
+
+ Reset();
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
+ if (Unit* owner = me->GetCharmerOrOwner())
+ {
+ if (!me->IsWithinDist(owner, 40.f))
+ {
+ me->RemoveAura(SPELL_EGBERT2);
+ me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle());
+ }
+ }
+
+ if (me->HasAura(SPELL_EGBERT2))
+ _events.ScheduleEvent(EVENT_RETURN, urandms(5, 20));
+
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, urandms(3, 4));
- break;
case EVENT_RETURN:
- if (Unit* owner = me->GetCharmerOrOwner())
- me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle());
- _events.ScheduleEvent(EVENT_MOVE_POS, urandms(1, 20));
+ me->RemoveAura(SPELL_EGBERT2);
break;
default:
break;