Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
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
14
enum
Willix
15
{
16
SAY_READY
= 0,
17
SAY_POINT
= 1,
18
SAY_AGGRO1
= 2,
19
SAY_BLUELEAF
= 3,
20
SAY_DANGER
= 4,
21
SAY_BAD
= 5,
22
SAY_THINK
= 6,
23
SAY_SOON
= 7,
24
SAY_FINALY
= 8,
25
SAY_WIN
= 9,
26
SAY_END
= 10,
27
28
QUEST_WILLIX_THE_IMPORTER
= 1144,
29
ENTRY_BOAR
= 4514
30
};
31
32
class
npc_willix
:
public
CreatureScript
33
{
34
public
:
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
49
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
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
58
void
WaypointReached
(
uint32
waypointId)
OVERRIDE
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);
99
me
->SetFlag(
UNIT_FIELD_NPC_FLAGS
,
UNIT_NPC_FLAG_QUESTGIVER
);
100
player->
GroupEventHappens
(
QUEST_WILLIX_THE_IMPORTER
,
me
);
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
{
112
Talk
(
SAY_AGGRO1
);
113
}
114
115
void
JustSummoned
(
Creature
* summoned)
OVERRIDE
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
128
enum
SnufflenoseGopher
129
{
130
NPC_SNUFFLENOSE_GOPHER
= 4781,
131
GO_BLUELEAF_TUBBER
= 20920,
132
ACTION_FIND_NEW_TUBBER
= 0,
133
POINT_TUBBER
= 0
134
};
135
136
struct
DistanceOrder
//: public std::binary_function<GameObject, GameObject, bool>
137
{
138
DistanceOrder
(
Creature
*
me
) :
me
(
me
) { }
139
140
bool
operator()
(
GameObject
* first,
GameObject
* second)
141
{
142
return
me
->GetDistanceOrder(first, second);
143
}
144
145
Creature
*
me
;
146
};
147
148
struct
npc_snufflenose_gopher
:
public
CreatureScript
149
{
150
public
:
151
npc_snufflenose_gopher
() :
CreatureScript
(
"npc_snufflenose_gopher"
) { }
152
153
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
154
{
155
return
new
npc_snufflenose_gopherAI
(creature);
156
}
157
158
struct
npc_snufflenose_gopherAI
:
public
PetAI
159
{
160
npc_snufflenose_gopherAI
(
Creature
* creature) :
PetAI
(creature) { }
161
162
void
Reset
()
OVERRIDE
163
{
164
IsMovementActive
=
false
;
165
}
166
167
void
MovementInform
(
uint32
type,
uint32
id
)
OVERRIDE
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();
175
go->RemoveFlag(
GAMEOBJECT_FIELD_FLAGS
,
GO_FLAG_INTERACT_COND
);
176
}
177
178
IsMovementActive
=
false
;
179
}
180
else
181
PetAI::MovementInform
(type,
id
);
182
}
183
184
void
DoFindNewTubber
()
185
{
186
std::list<GameObject*> tubbersInRange;
187
GetGameObjectListWithEntryInGrid
(tubbersInRange,
me
,
GO_BLUELEAF_TUBBER
, 40.0f);
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
216
void
UpdateAI
(
uint32
diff)
OVERRIDE
217
{
218
if
(!
IsMovementActive
)
219
PetAI::UpdateAI
(diff);
220
}
221
222
void
DoAction
(
int32
action)
OVERRIDE
223
{
224
if
(action ==
ACTION_FIND_NEW_TUBBER
)
225
DoFindNewTubber
();
226
}
227
228
229
bool
IsMovementActive
;
230
uint64
TargetTubberGUID
;
231
};
232
};
233
234
class
spell_snufflenose_command
:
public
SpellScriptLoader
235
{
236
public
:
237
spell_snufflenose_command
() :
SpellScriptLoader
(
"spell_snufflenose_command"
) { }
238
239
class
spell_snufflenose_commandSpellScript
:
public
SpellScript
240
{
241
PrepareSpellScript
(
spell_snufflenose_commandSpellScript
);
242
243
bool
Load
()
OVERRIDE
244
{
245
return
GetCaster
()->
GetTypeId
() ==
TypeID::TYPEID_PLAYER
;
246
}
247
248
void
HandleAfterCast
()
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
255
void
Register
()
OVERRIDE
256
{
257
AfterCast
+=
SpellCastFn
(
spell_snufflenose_commandSpellScript::HandleAfterCast
);
258
}
259
};
260
261
SpellScript
*
GetSpellScript
() const
OVERRIDE
262
{
263
return
new
spell_snufflenose_commandSpellScript
();
264
}
265
};
266
267
void
AddSC_razorfen_kraul
()
268
{
269
new
npc_snufflenose_gopher
();
270
new
npc_willix
();
271
new
spell_snufflenose_command
();
272
}
MINUTE
@ MINUTE
Definition
Common.h:119
int32
std::int32_t int32
Definition
Define.h:73
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
uint64
std::uint64_t uint64
Definition
Define.h:76
POINT_MOTION_TYPE
@ POINT_MOTION_TYPE
Definition
MotionMaster.h:33
TypeID::TYPEID_PLAYER
@ TYPEID_PLAYER
Definition
Object.h:55
TempSummonType::TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition
Object.h:71
PetAI.h
Player.h
ScriptMgr.h
GetGameObjectListWithEntryInGrid
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &list, WorldObject *source, uint32 entry, float maxSearchRange)
Definition
ScriptedCreature.cpp:677
ScriptedCreature.h
CAST_AI
#define CAST_AI(a, b)
Definition
ScriptedCreature.h:14
ScriptedEscortAI.h
EMOTE_STATE_POINT
@ EMOTE_STATE_POINT
Definition
SharedDefines.h:2158
GO_FLAG_INTERACT_COND
@ GO_FLAG_INTERACT_COND
Definition
SharedDefines.h:1840
SpellScript.h
SpellCastFn
#define SpellCastFn(F)
Definition
SpellScript.h:256
UNIT_NPC_FLAG_QUESTGIVER
@ UNIT_NPC_FLAG_QUESTGIVER
Definition
Unit.h:688
UNIT_FIELD_NPC_FLAGS
@ UNIT_FIELD_NPC_FLAGS
Definition
UpdateFields.h:107
GAMEOBJECT_FIELD_FLAGS
@ GAMEOBJECT_FIELD_FLAGS
Definition
UpdateFields.h:250
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::Talk
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
Definition
CreatureAI.cpp:28
CreatureAI::me
Creature *const me
Definition
CreatureAI.h:56
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
GameObject
Definition
GameObject.h:629
Object::GetGUID
uint64 GetGUID() const
Definition
Object.h:119
Object::GetTypeId
TypeID GetTypeId() const
Definition
Object.h:131
PetAI::PetAI
PetAI(Creature *c)
Definition
PetAI.cpp:28
PetAI::MovementInform
void MovementInform(uint32 moveType, uint32 data) OVERRIDE
Definition
PetAI.cpp:473
PetAI::UpdateAI
void UpdateAI(uint32) OVERRIDE
== Triggered Actions Requested ==================
Definition
PetAI.cpp:63
Player
Definition
Player.h:1289
Player::GroupEventHappens
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition
PlayerQuestState.cpp:1593
Quest
Definition
QuestDef.h:255
SpellScript
Definition
SpellScript.h:139
SpellScript::AfterCast
HookList< CastHandler > AfterCast
Definition
SpellScript.h:255
SpellScript::GetCaster
Unit * GetCaster()
Definition
SpellScript.cpp:352
SpellScriptLoader::SpellScriptLoader
SpellScriptLoader(const char *name)
Definition
ScriptMgr.cpp:1372
Unit
Definition
Unit.h:1367
npc_willix
Definition
razorfen_kraul.cpp:33
npc_willix::OnQuestAccept
bool OnQuestAccept(Player *player, Creature *creature, Quest const *quest) OVERRIDE
Definition
razorfen_kraul.cpp:37
npc_willix::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
razorfen_kraul.cpp:49
npc_willix::npc_willix
npc_willix()
Definition
razorfen_kraul.cpp:35
spell_snufflenose_command::spell_snufflenose_commandSpellScript
Definition
razorfen_kraul.cpp:240
spell_snufflenose_command::spell_snufflenose_commandSpellScript::Load
bool Load() OVERRIDE
Definition
razorfen_kraul.cpp:243
spell_snufflenose_command::spell_snufflenose_commandSpellScript::HandleAfterCast
void HandleAfterCast()
Definition
razorfen_kraul.cpp:248
spell_snufflenose_command::spell_snufflenose_commandSpellScript::Register
void Register() OVERRIDE
Definition
razorfen_kraul.cpp:255
spell_snufflenose_command::spell_snufflenose_commandSpellScript::PrepareSpellScript
PrepareSpellScript(spell_snufflenose_commandSpellScript)
spell_snufflenose_command
Definition
razorfen_kraul.cpp:235
spell_snufflenose_command::GetSpellScript
SpellScript * GetSpellScript() const OVERRIDE
Definition
razorfen_kraul.cpp:261
spell_snufflenose_command::spell_snufflenose_command
spell_snufflenose_command()
Definition
razorfen_kraul.cpp:237
SAY_AGGRO1
@ SAY_AGGRO1
Definition
example_escort.cpp:22
SAY_READY
#define SAY_READY
Definition
karazhan.cpp:54
AddSC_razorfen_kraul
void AddSC_razorfen_kraul()
Definition
razorfen_kraul.cpp:267
Willix
Willix
Definition
razorfen_kraul.cpp:15
QUEST_WILLIX_THE_IMPORTER
@ QUEST_WILLIX_THE_IMPORTER
Definition
razorfen_kraul.cpp:28
SAY_BLUELEAF
@ SAY_BLUELEAF
Definition
razorfen_kraul.cpp:19
SAY_AGGRO1
@ SAY_AGGRO1
Definition
razorfen_kraul.cpp:18
SAY_WIN
@ SAY_WIN
Definition
razorfen_kraul.cpp:25
SAY_FINALY
@ SAY_FINALY
Definition
razorfen_kraul.cpp:24
SAY_END
@ SAY_END
Definition
razorfen_kraul.cpp:26
SAY_THINK
@ SAY_THINK
Definition
razorfen_kraul.cpp:22
SAY_DANGER
@ SAY_DANGER
Definition
razorfen_kraul.cpp:20
ENTRY_BOAR
@ ENTRY_BOAR
Definition
razorfen_kraul.cpp:29
SAY_READY
@ SAY_READY
Definition
razorfen_kraul.cpp:16
SAY_BAD
@ SAY_BAD
Definition
razorfen_kraul.cpp:21
SAY_SOON
@ SAY_SOON
Definition
razorfen_kraul.cpp:23
SAY_POINT
@ SAY_POINT
Definition
razorfen_kraul.cpp:17
SnufflenoseGopher
SnufflenoseGopher
Definition
razorfen_kraul.cpp:129
POINT_TUBBER
@ POINT_TUBBER
Definition
razorfen_kraul.cpp:133
GO_BLUELEAF_TUBBER
@ GO_BLUELEAF_TUBBER
Definition
razorfen_kraul.cpp:131
ACTION_FIND_NEW_TUBBER
@ ACTION_FIND_NEW_TUBBER
Definition
razorfen_kraul.cpp:132
NPC_SNUFFLENOSE_GOPHER
@ NPC_SNUFFLENOSE_GOPHER
Definition
razorfen_kraul.cpp:130
razorfen_kraul.h
DistanceOrder
Definition
razorfen_kraul.cpp:137
DistanceOrder::operator()
bool operator()(GameObject *first, GameObject *second)
Definition
razorfen_kraul.cpp:140
DistanceOrder::DistanceOrder
DistanceOrder(Creature *me)
Definition
razorfen_kraul.cpp:138
DistanceOrder::me
Creature * me
Definition
razorfen_kraul.cpp:145
Position::GetPositionZ
float GetPositionZ() const
Definition
Object.h:330
Position::GetPositionX
float GetPositionX() const
Definition
Object.h:328
Position::GetPositionY
float GetPositionY() const
Definition
Object.h:329
ScriptedAI::me
Creature * me
Definition
ScriptedCreature.h:182
npc_escortAI
Definition
ScriptedEscortAI.h:41
npc_escortAI::GetPlayerForEscort
Player * GetPlayerForEscort()
Definition
ScriptedEscortAI.h:97
npc_escortAI::npc_escortAI
npc_escortAI(Creature *creature)
Definition
ScriptedEscortAI.cpp:24
npc_snufflenose_gopher::npc_snufflenose_gopherAI
Definition
razorfen_kraul.cpp:159
npc_snufflenose_gopher::npc_snufflenose_gopherAI::IsMovementActive
bool IsMovementActive
Definition
razorfen_kraul.cpp:229
npc_snufflenose_gopher::npc_snufflenose_gopherAI::npc_snufflenose_gopherAI
npc_snufflenose_gopherAI(Creature *creature)
Definition
razorfen_kraul.cpp:160
npc_snufflenose_gopher::npc_snufflenose_gopherAI::Reset
void Reset() OVERRIDE
Definition
razorfen_kraul.cpp:162
npc_snufflenose_gopher::npc_snufflenose_gopherAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
razorfen_kraul.cpp:216
npc_snufflenose_gopher::npc_snufflenose_gopherAI::TargetTubberGUID
uint64 TargetTubberGUID
Definition
razorfen_kraul.cpp:230
npc_snufflenose_gopher::npc_snufflenose_gopherAI::MovementInform
void MovementInform(uint32 type, uint32 id) OVERRIDE
Definition
razorfen_kraul.cpp:167
npc_snufflenose_gopher::npc_snufflenose_gopherAI::DoFindNewTubber
void DoFindNewTubber()
Definition
razorfen_kraul.cpp:184
npc_snufflenose_gopher::npc_snufflenose_gopherAI::DoAction
void DoAction(int32 action) OVERRIDE
Definition
razorfen_kraul.cpp:222
npc_snufflenose_gopher
Definition
razorfen_kraul.cpp:149
npc_snufflenose_gopher::npc_snufflenose_gopher
npc_snufflenose_gopher()
Definition
razorfen_kraul.cpp:151
npc_snufflenose_gopher::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
razorfen_kraul.cpp:153
npc_willix::npc_willixAI
Definition
razorfen_kraul.cpp:55
npc_willix::npc_willixAI::npc_willixAI
npc_willixAI(Creature *creature)
Definition
razorfen_kraul.cpp:56
npc_willix::npc_willixAI::Reset
void Reset() OVERRIDE
Definition
razorfen_kraul.cpp:108
npc_willix::npc_willixAI::WaypointReached
void WaypointReached(uint32 waypointId) OVERRIDE
Definition
razorfen_kraul.cpp:58
npc_willix::npc_willixAI::JustDied
void JustDied(Unit *) OVERRIDE
Definition
razorfen_kraul.cpp:120
npc_willix::npc_willixAI::EnterCombat
void EnterCombat(Unit *) OVERRIDE
Definition
razorfen_kraul.cpp:110
npc_willix::npc_willixAI::JustSummoned
void JustSummoned(Creature *summoned) OVERRIDE
Definition
razorfen_kraul.cpp:115
SAY_WIN
@ SAY_WIN
Definition
the_black_morass.cpp:34
src
server
scripts
Kalimdor
RazorfenKraul
razorfen_kraul.cpp
Generated on
for Project SkyFire Core by
1.17.0