diff options
author | zwerg <seaofgreen@gmx.net> | 2012-02-08 22:49:40 +0000 |
---|---|---|
committer | Nay <dnpd.dd@gmail.com> | 2012-02-08 22:49:40 +0000 |
commit | cd7b0c2635855fb1e497edf02c50c01e7aa46853 (patch) | |
tree | adc286c28acc2144657cf1cb90cb9153e33444d5 /src | |
parent | 8a1f3a600fe28831c8653fe8261747118f0b5dba (diff) |
Scripts/Noblegarden: Fix Spring Fling achievements
Closes #1070
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/World/npcs_special.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index fda2ececf1f..13609a490e5 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -3050,6 +3050,100 @@ public: } }; +/*##### +# npc_spring_rabbit +#####*/ + +enum rabbitSpells +{ + SPELL_SPRING_FLING = 61875, + SPELL_SPRING_RABBIT_JUMP = 61724, + SPELL_SPRING_RABBIT_WANDER = 61726, + SPELL_SUMMON_BABY_BUNNY = 61727, + SPELL_SPRING_RABBIT_IN_LOVE = 61728, + NPC_SPRING_RABBIT = 32791 +}; + +class npc_spring_rabbit : public CreatureScript +{ +public: + npc_spring_rabbit() : CreatureScript("npc_spring_rabbit") { } + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_spring_rabbitAI(creature); + } + + struct npc_spring_rabbitAI : public ScriptedAI + { + npc_spring_rabbitAI(Creature* c) : ScriptedAI(c) { } + + bool inLove; + uint32 jumpTimer; + uint32 bunnyTimer; + uint32 searchTimer; + uint64 rabbitGUID; + + void Reset() + { + inLove = false; + rabbitGUID = 0; + jumpTimer = urand(5000, 10000); + bunnyTimer = urand(10000, 20000); + searchTimer = urand(5000, 10000); + if (Unit* owner = me->GetOwner()) + me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + } + + void EnterCombat(Unit * /*who*/) { } + + void DoAction(const int32 /*param*/) + { + inLove = true; + if (Unit* owner = me->GetOwner()) + owner->CastSpell(owner, SPELL_SPRING_FLING, true); + } + + void UpdateAI(const uint32 diff) + { + if (inLove) + { + if (jumpTimer <= diff) + { + if (Unit* rabbit = Unit::GetUnit(*me, rabbitGUID)) + DoCast(rabbit, SPELL_SPRING_RABBIT_JUMP); + jumpTimer = urand(5000, 10000); + } else jumpTimer -= diff; + + if (bunnyTimer <= diff) + { + DoCast(SPELL_SUMMON_BABY_BUNNY); + bunnyTimer = urand(20000, 40000); + } else bunnyTimer -= diff; + } + else + { + if (searchTimer <= diff) + { + if (Creature* rabbit = me->FindNearestCreature(NPC_SPRING_RABBIT, 10.0f)) + { + if (rabbit == me || rabbit->HasAura(SPELL_SPRING_RABBIT_IN_LOVE)) + return; + + me->AddAura(SPELL_SPRING_RABBIT_IN_LOVE, me); + DoAction(1); + rabbit->AddAura(SPELL_SPRING_RABBIT_IN_LOVE, rabbit); + rabbit->AI()->DoAction(1); + rabbit->CastSpell(rabbit, SPELL_SPRING_RABBIT_JUMP, true); + rabbitGUID = rabbit->GetGUID(); + } + searchTimer = urand(5000, 10000); + } else searchTimer -= diff; + } + } + }; +}; + void AddSC_npcs_special() { new npc_air_force_bots; @@ -3083,5 +3177,6 @@ void AddSC_npcs_special() new npc_fire_elemental; new npc_earth_elemental; new npc_firework; + new npc_spring_rabbit(); } |