TrinityCore
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 "Player.h"
24#include "razorfen_kraul.h"
25#include "ScriptedEscortAI.h"
26#include "SpellScript.h"
27
29{
40 SAY_END = 10,
41
43 ENTRY_BOAR = 4514,
44
45 PATH_ESCORT_WILLIX = 36066
46};
47
49{
50public:
51 npc_willix() : CreatureScript("npc_willix") { }
52
53 struct npc_willixAI : public EscortAI
54 {
55 npc_willixAI(Creature* creature) : EscortAI(creature) { }
56
57 void OnQuestAccept(Player* player, Quest const* quest) override
58 {
60 {
62 Start(true, player->GetGUID());
63 Talk(SAY_READY, player);
65 }
66 }
67
68 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
69 {
70 Player* player = GetPlayerForEscort();
71 if (!player)
72 return;
73
74 switch (waypointId)
75 {
76 case 3:
78 Talk(SAY_POINT, player);
79 break;
80 case 4:
81 me->SummonCreature(ENTRY_BOAR, 2137.66f, 1843.98f, 48.08f, 1.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25s);
82 break;
83 case 8:
84 Talk(SAY_BLUELEAF, player);
85 break;
86 case 9:
87 Talk(SAY_DANGER, player);
88 break;
89 case 13:
90 Talk(SAY_BAD, player);
91 break;
92 case 14:
93 me->SummonCreature(ENTRY_BOAR, 2078.91f, 1704.54f, 56.77f, 1.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25s);
94 break;
95 case 25:
96 Talk(SAY_THINK, player);
97 break;
98 case 31:
99 Talk(SAY_SOON, player);
100 break;
101 case 42:
102 Talk(SAY_FINALY, player);
103 break;
104 case 43:
105 me->SummonCreature(ENTRY_BOAR, 1956.43f, 1596.97f, 81.75f, 1.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25s);
106 break;
107 case 45:
108 Talk(SAY_WIN, player);
111 break;
112 case 46:
113 Talk(SAY_END, player);
114 break;
115 }
116 }
117
118 void Reset() override { }
119
120 void JustEngagedWith(Unit* who) override
121 {
122 Talk(SAY_AGGRO1, who);
123 }
124
125 void JustSummoned(Creature* summoned) override
126 {
127 summoned->AI()->AttackStart(me);
128 }
129
130 void JustDied(Unit* /*killer*/) override
131 {
132 if (Player* player = GetPlayerForEscort())
133 player->FailQuest(QUEST_WILLIX_THE_IMPORTER);
134 }
135 };
136
137 CreatureAI* GetAI(Creature* creature) const override
138 {
139 return GetRazorfenKraulAI<npc_willixAI>(creature);
140 }
141};
142
144{
148 POINT_TUBBER = 0
150
152{
153public:
154 npc_snufflenose_gopher() : CreatureScript("npc_snufflenose_gopher") { }
155
156 CreatureAI* GetAI(Creature* creature) const override
157 {
158 return GetRazorfenKraulAI<npc_snufflenose_gopherAI>(creature);
159 }
160
162 {
164 {
165 IsMovementActive = false;
166 }
167
168 void Reset() override
169 {
170 IsMovementActive = false;
172 }
173
174 void MovementInform(uint32 type, uint32 id) override
175 {
176 if (type == POINT_MOTION_TYPE && id == POINT_TUBBER)
177 {
179 {
180 go->SetRespawnTime(5 * MINUTE);
181 go->Refresh();
182 go->RemoveFlag(GO_FLAG_INTERACT_COND);
183 }
184
185 IsMovementActive = false;
186 }
187 else
188 PetAI::MovementInform(type, id);
189 }
190
192 {
193 std::list<GameObject*> tubbersInRange;
195
196 if (tubbersInRange.empty())
197 return;
198
199 tubbersInRange.remove_if([](GameObject* go)
200 {
201 return go->isSpawned() || !go->HasFlag(GO_FLAG_INTERACT_COND);
202 });
203
204 tubbersInRange.sort(Trinity::ObjectDistanceOrderPred(me));
205
206 GameObject* nearestTubber = tubbersInRange.front();
207 if (!nearestTubber)
208 return;
209
210 TargetTubberGUID = nearestTubber->GetGUID();
211
212 // XFurry was wrong...
214 nearestTubber->GetPositionY(),
215 nearestTubber->GetPositionZ());
216 IsMovementActive = true;
217 }
218
219 void UpdateAI(uint32 diff) override
220 {
221 if (!IsMovementActive)
222 PetAI::UpdateAI(diff);
223 }
224
225 void DoAction(int32 action) override
226 {
227 if (action == ACTION_FIND_NEW_TUBBER)
229 }
230
233 };
234};
235
237{
238 public:
239 spell_snufflenose_command() : SpellScriptLoader("spell_snufflenose_command") { }
240
242 {
243 void HandleEffect(SpellEffIndex /*effIndex*/)
244 {
245 if (Creature* target = GetHitCreature())
246 if (target->GetEntry() == NPC_SNUFFLENOSE_GOPHER)
247 target->AI()->DoAction(ACTION_FIND_NEW_TUBBER);
248 }
249
250 void Register() override
251 {
253 }
254 };
255
256 SpellScript* GetSpellScript() const override
257 {
259 }
260};
261
263{
265 new npc_willix();
267}
@ MINUTE
Definition: Common.h:29
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition: ObjectDefines.h:66
void GetGameObjectListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ EMOTE_STATE_POINT
@ SPELL_EFFECT_DUMMY
@ GO_FLAG_INTERACT_COND
@ FACTION_ESCORTEE_N_NEUTRAL_PASSIVE
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
@ UNIT_NPC_FLAG_QUESTGIVER
Definition: UnitDefines.h:298
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
CreatureAI * AI() const
Definition: Creature.h:214
bool HasFlag(GameObjectFlags flags) const
Definition: GameObject.h:273
bool isSpawned() const
Definition: GameObject.h:256
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void Clear()
Definition: ObjectGuid.h:286
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Definition: PetAI.h:30
void MovementInform(uint32 type, uint32 id) override
Definition: PetAI.cpp:440
void UpdateAI(uint32) override
Definition: PetAI.cpp:55
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition: Player.cpp:16598
uint32 GetQuestId() const
Definition: QuestDef.h:587
Creature * GetHitCreature() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
Definition: Unit.h:627
void SetFaction(uint32 faction) override
Definition: Unit.h:859
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetNpcFlag(NPCFlags flags)
Definition: Unit.h:982
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
CreatureAI * GetAI(Creature *creature) const override
SpellScript * GetSpellScript() const override
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
void AddSC_razorfen_kraul()
Willix
@ QUEST_WILLIX_THE_IMPORTER
@ SAY_BLUELEAF
@ SAY_AGGRO1
@ SAY_WIN
@ SAY_FINALY
@ SAY_END
@ SAY_THINK
@ SAY_DANGER
@ ENTRY_BOAR
@ SAY_READY
@ SAY_BAD
@ SAY_SOON
@ SAY_POINT
@ PATH_ESCORT_WILLIX
SnufflenoseGopher
@ POINT_TUBBER
@ GO_BLUELEAF_TUBBER
@ ACTION_FIND_NEW_TUBBER
@ NPC_SNUFFLENOSE_GOPHER
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
void LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetPositionZ() const
Definition: Position.h:78
void MovementInform(uint32 type, uint32 id) override
CreatureAI * GetAI(Creature *creature) const override
void OnQuestAccept(Player *player, Quest const *quest) override
void JustDied(Unit *) override
npc_willixAI(Creature *creature)
void JustSummoned(Creature *summoned) override
void JustEngagedWith(Unit *who) override
void WaypointReached(uint32 waypointId, uint32) override