Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
razorfen_kraul.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "ScriptedEscortAI.h"
9#include "razorfen_kraul.h"
10#include "Player.h"
11#include "PetAI.h"
12#include "SpellScript.h"
13
31
33{
34public:
35 npc_willix() : CreatureScript("npc_willix") { }
36
37 bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
38 {
39 if (quest->GetQuestId() == QUEST_WILLIX_THE_IMPORTER)
40 {
41 CAST_AI(npc_escortAI, (creature->AI()))->Start(true, false, player->GetGUID());
42 creature->AI()->Talk(SAY_READY, player);
43 creature->setFaction(113);
44 }
45
46 return true;
47 }
48
50 {
51 return new npc_willixAI(creature);
52 }
53
54 struct npc_willixAI : public npc_escortAI
55 {
56 npc_willixAI(Creature* creature) : npc_escortAI(creature) { }
57
59 {
60 Player* player = GetPlayerForEscort();
61 if (!player)
62 return;
63
64 switch (waypointId)
65 {
66 case 3:
67 me->HandleEmoteCommand(EMOTE_STATE_POINT);
68 Talk(SAY_POINT, player);
69 break;
70 case 4:
71 me->SummonCreature(ENTRY_BOAR, 2137.66f, 1843.98f, 48.08f, 1.54f, TempSummonType::TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
72 break;
73 case 8:
74 Talk(SAY_BLUELEAF, player);
75 break;
76 case 9:
77 Talk(SAY_DANGER, player);
78 break;
79 case 13:
80 Talk(SAY_BAD, player);
81 break;
82 case 14:
83 me->SummonCreature(ENTRY_BOAR, 2078.91f, 1704.54f, 56.77f, 1.54f, TempSummonType::TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
84 break;
85 case 25:
86 Talk(SAY_THINK, player);
87 break;
88 case 31:
89 Talk(SAY_SOON, player);
90 break;
91 case 42:
92 Talk(SAY_FINALY, player);
93 break;
94 case 43:
95 me->SummonCreature(ENTRY_BOAR, 1956.43f, 1596.97f, 81.75f, 1.54f, TempSummonType::TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
96 break;
97 case 45:
98 Talk(SAY_WIN, player);
101 break;
102 case 46:
103 Talk(SAY_END, player);
104 break;
105 }
106 }
107
108 void Reset() OVERRIDE { }
109
110 void EnterCombat(Unit* /*who*/) OVERRIDE
111 {
113 }
114
116 {
117 summoned->AI()->AttackStart(me);
118 }
119
120 void JustDied(Unit* /*killer*/) OVERRIDE
121 {
122 if (Player* player = GetPlayerForEscort())
123 player->FailQuest(QUEST_WILLIX_THE_IMPORTER);
124 }
125 };
126};
127
135
136struct DistanceOrder //: public std::binary_function<GameObject, GameObject, bool>
137{
139
140 bool operator() (GameObject* first, GameObject* second)
141 {
142 return me->GetDistanceOrder(first, second);
143 }
144
146};
147
149{
150public:
151 npc_snufflenose_gopher() : CreatureScript("npc_snufflenose_gopher") { }
152
154 {
155 return new npc_snufflenose_gopherAI(creature);
156 }
157
159 {
160 npc_snufflenose_gopherAI(Creature* creature) : PetAI(creature) { }
161
163 {
164 IsMovementActive = false;
165 }
166
168 {
169 if (type == POINT_MOTION_TYPE && id == POINT_TUBBER)
170 {
171 if (GameObject* go = me->GetMap()->GetGameObject(TargetTubberGUID))
172 {
173 go->SetRespawnTime(5 * MINUTE);
174 go->Refresh();
176 }
177
178 IsMovementActive = false;
179 }
180 else
181 PetAI::MovementInform(type, id);
182 }
183
185 {
186 std::list<GameObject*> tubbersInRange;
188
189 if (tubbersInRange.empty())
190 return;
191
192 tubbersInRange.sort(DistanceOrder(me));
193 GameObject* nearestTubber = NULL;
194
195 for (std::list<GameObject*>::const_iterator itr = tubbersInRange.begin(); itr != tubbersInRange.end(); ++itr)
196 {
197 if (!(*itr)->isSpawned() && (*itr)->HasFlag(GAMEOBJECT_FIELD_FLAGS, GO_FLAG_INTERACT_COND))
198 {
199 nearestTubber = *itr;
200 break;
201 }
202 }
203
204 if (!nearestTubber)
205 return;
206
207 TargetTubberGUID = nearestTubber->GetGUID();
208
209 // XFurry was wrong...
210 me->GetMotionMaster()->MovePoint(POINT_TUBBER, nearestTubber->GetPositionX(),
211 nearestTubber->GetPositionY(),
212 nearestTubber->GetPositionZ());
213 IsMovementActive = true;
214 }
215
217 {
218 if (!IsMovementActive)
219 PetAI::UpdateAI(diff);
220 }
221
223 {
224 if (action == ACTION_FIND_NEW_TUBBER)
226 }
227
228
231 };
232};
233
235{
236 public:
237 spell_snufflenose_command() : SpellScriptLoader("spell_snufflenose_command") { }
238
240 {
242
244 {
246 }
247
249 {
250 if (Unit* target = GetCaster()->ToPlayer()->GetSelectedUnit())
251 if (target->GetEntry() == NPC_SNUFFLENOSE_GOPHER)
252 target->ToCreature()->AI()->DoAction(ACTION_FIND_NEW_TUBBER);
253 }
254
259 };
260
265};
266
268{
270 new npc_willix();
272}
@ MINUTE
Definition Common.h:119
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition Object.h:55
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition Object.h:71
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &list, WorldObject *source, uint32 entry, float maxSearchRange)
#define CAST_AI(a, b)
@ EMOTE_STATE_POINT
@ GO_FLAG_INTERACT_COND
#define SpellCastFn(F)
@ UNIT_NPC_FLAG_QUESTGIVER
Definition Unit.h:688
@ UNIT_FIELD_NPC_FLAGS
@ GAMEOBJECT_FIELD_FLAGS
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
Creature *const me
Definition CreatureAI.h:56
CreatureScript(const char *name)
uint64 GetGUID() const
Definition Object.h:119
TypeID GetTypeId() const
Definition Object.h:131
PetAI(Creature *c)
Definition PetAI.cpp:28
void MovementInform(uint32 moveType, uint32 data) OVERRIDE
Definition PetAI.cpp:473
void UpdateAI(uint32) OVERRIDE
== Triggered Actions Requested ==================
Definition PetAI.cpp:63
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
HookList< CastHandler > AfterCast
Unit * GetCaster()
SpellScriptLoader(const char *name)
Definition Unit.h:1367
bool OnQuestAccept(Player *player, Creature *creature, Quest const *quest) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
PrepareSpellScript(spell_snufflenose_commandSpellScript)
SpellScript * GetSpellScript() const OVERRIDE
@ SAY_AGGRO1
#define SAY_READY
Definition karazhan.cpp:54
void AddSC_razorfen_kraul()
@ 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
SnufflenoseGopher
@ POINT_TUBBER
@ GO_BLUELEAF_TUBBER
@ ACTION_FIND_NEW_TUBBER
@ NPC_SNUFFLENOSE_GOPHER
bool operator()(GameObject *first, GameObject *second)
DistanceOrder(Creature *me)
float GetPositionZ() const
Definition Object.h:330
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
Creature * me
Player * GetPlayerForEscort()
npc_escortAI(Creature *creature)
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void MovementInform(uint32 type, uint32 id) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
npc_willixAI(Creature *creature)
void WaypointReached(uint32 waypointId) OVERRIDE
void JustDied(Unit *) OVERRIDE
void EnterCombat(Unit *) OVERRIDE
void JustSummoned(Creature *summoned) OVERRIDE
@ SAY_WIN