diff options
| author | sirikfoll <sirikfoll@hotmail.com> | 2016-01-13 23:16:11 -0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2016-04-02 18:32:38 +0200 |
| commit | a962db8b3c2c756a280bd3219214e402152d689a (patch) | |
| tree | d76cb2940d2f633a0e3284e4b0b1af52c7eb15e2 /src | |
| parent | 2fe84d7471f8f5e521ca77825e63b9cff92ba1dc (diff) | |
Core/Scripts Script npc needed for Quest Torch Tossing part2
Script for Npc Torch Tossing Target_Bunny_Controller, responsable for handle the targets rotation for Midsummer Fire Festival quest, Torch Tossing.
(cherry picked from commit 8b74038531ffec2d809083fa73ad29ec693d7c1a)
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/scripts/World/npcs_special.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 87616548350..62d6bce57c9 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -512,6 +512,67 @@ public: }; /*###### +## npc_torch_tossing_target_bunny_controller +######*/ + +enum TorchTossingTarget +{ + NPC_TORCH_TOSSING_TARGET_BUNNY = 25535, + SPELL_TARGET_INDICATOR = 45723 +}; + +class npc_torch_tossing_target_bunny_controller : public CreatureScript +{ +public: + npc_torch_tossing_target_bunny_controller() : CreatureScript("npc_torch_tossing_target_bunny_controller") { } + + struct npc_torch_tossing_target_bunny_controllerAI : public ScriptedAI + { + npc_torch_tossing_target_bunny_controllerAI(Creature* creature) : ScriptedAI(creature) + { + _targetTimer = 3000; + } + + ObjectGuid DoSearchForTargets(ObjectGuid lastTargetGUID) + { + std::list<Creature*> targets; + me->GetCreatureListWithEntryInGrid(targets, NPC_TORCH_TOSSING_TARGET_BUNNY, 60.0f); + targets.remove_if([lastTargetGUID](Creature* creature) { return creature->GetGUID() == lastTargetGUID; }); + + if (!targets.empty()) + { + _lastTargetGUID = Trinity::Containers::SelectRandomContainerElement(targets)->GetGUID(); + + return _lastTargetGUID; + } + return ObjectGuid::Empty; + } + + void UpdateAI(uint32 diff) override + { + if (_targetTimer < diff) + { + if (Unit* target = ObjectAccessor::GetUnit(*me, DoSearchForTargets(_lastTargetGUID))) + target->CastSpell(target, SPELL_TARGET_INDICATOR, true); + + _targetTimer = 3000; + } + else + _targetTimer -= diff; + } + + private: + uint32 _targetTimer; + ObjectGuid _lastTargetGUID; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_torch_tossing_target_bunny_controllerAI(creature); + } +}; + +/*###### ## Triage quest ######*/ @@ -2330,6 +2391,7 @@ void AddSC_npcs_special() new npc_lunaclaw_spirit(); new npc_chicken_cluck(); new npc_dancing_flames(); + new npc_torch_tossing_target_bunny_controller(); new npc_doctor(); new npc_injured_patient(); new npc_garments_of_quests(); |
