TrinityCore
Loading...
Searching...
No Matches
razorfen_kraul.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "GameObject.h"
20#include "MotionMaster.h"
21#include "ObjectAccessor.h"
22#include "PetAI.h"
23#include "razorfen_kraul.h"
24#include "ScriptedCreature.h"
25#include "SpellScript.h"
26
34
36{
37public:
38 npc_snufflenose_gopher() : CreatureScript("npc_snufflenose_gopher") { }
39
40 CreatureAI* GetAI(Creature* creature) const override
41 {
42 return GetRazorfenKraulAI<npc_snufflenose_gopherAI>(creature);
43 }
44
46 {
48 {
49 IsMovementActive = false;
50 }
51
52 void Reset() override
53 {
54 IsMovementActive = false;
56 }
57
58 void MovementInform(uint32 type, uint32 id) override
59 {
60 if (type == POINT_MOTION_TYPE && id == POINT_TUBBER)
61 {
63 {
64 go->SetRespawnTime(5 * MINUTE);
65 go->Refresh();
66 go->RemoveFlag(GO_FLAG_INTERACT_COND);
67 }
68
69 IsMovementActive = false;
70 }
71 else
72 PetAI::MovementInform(type, id);
73 }
74
76 {
77 std::list<GameObject*> tubbersInRange;
79
80 if (tubbersInRange.empty())
81 return;
82
83 tubbersInRange.remove_if([](GameObject* go)
84 {
85 return go->isSpawned() || !go->HasFlag(GO_FLAG_INTERACT_COND);
86 });
87
88 tubbersInRange.sort(Trinity::ObjectDistanceOrderPred(me));
89
90 GameObject* nearestTubber = tubbersInRange.front();
91 if (!nearestTubber)
92 return;
93
94 TargetTubberGUID = nearestTubber->GetGUID();
95
96 // XFurry was wrong...
98 nearestTubber->GetPositionY(),
99 nearestTubber->GetPositionZ());
100 IsMovementActive = true;
101 }
102
103 void UpdateAI(uint32 diff) override
104 {
105 if (!IsMovementActive)
106 PetAI::UpdateAI(diff);
107 }
108
109 void DoAction(int32 action) override
110 {
111 if (action == ACTION_FIND_NEW_TUBBER)
113 }
114
117 };
118};
119
121{
122 public:
123 spell_snufflenose_command() : SpellScriptLoader("spell_snufflenose_command") { }
124
126 {
127 void HandleEffect(SpellEffIndex /*effIndex*/)
128 {
129 if (Creature* target = GetHitCreature())
130 if (target->GetEntry() == NPC_SNUFFLENOSE_GOPHER)
131 target->AI()->DoAction(ACTION_FIND_NEW_TUBBER);
132 }
133
138 };
139
140 SpellScript* GetSpellScript() const override
141 {
143 }
144};
145
@ MINUTE
Definition Common.h:32
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
void GetGameObjectListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ GO_FLAG_INTERACT_COND
#define SpellEffectFn(F, I, N)
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
Creature *const me
Definition CreatureAI.h:63
bool HasFlag(GameObjectFlags flags) const
Definition GameObject.h:282
bool isSpawned() const
Definition GameObject.h:265
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
void Clear()
Definition ObjectGuid.h:329
Definition PetAI.h:30
void MovementInform(uint32 type, uint32 id) override
Definition PetAI.cpp:440
void UpdateAI(uint32) override
Definition PetAI.cpp:55
Creature * GetHitCreature() const
HookList< EffectHandler > OnEffectHitTarget
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
SpellScript * GetSpellScript() const override
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
void AddSC_razorfen_kraul()
SnufflenoseGopher
@ POINT_TUBBER
@ GO_BLUELEAF_TUBBER
@ ACTION_FIND_NEW_TUBBER
@ NPC_SNUFFLENOSE_GOPHER
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetPositionZ() const
Definition Position.h:89
void MovementInform(uint32 type, uint32 id) override
CreatureAI * GetAI(Creature *creature) const override