Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
example_escort.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
/* ScriptData
7
SDName: Example_Escort
8
SD%Complete: 100
9
SDComment: Script used for testing escortAI
10
SDCategory: Script Examples
11
EndScriptData */
12
13
#include "
ScriptMgr.h
"
14
#include "
ScriptedCreature.h
"
15
#include "
ScriptedGossip.h
"
16
#include "
ScriptedEscortAI.h
"
17
#include "
Player.h
"
18
#include "
CreatureTextMgr.h
"
19
20
enum
Yells
21
{
22
SAY_AGGRO1
= 0,
23
SAY_AGGRO2
= 1,
24
SAY_WP_1
= 2,
25
SAY_WP_2
= 3,
26
SAY_WP_3
= 4,
27
SAY_WP_4
= 5,
28
SAY_DEATH_1
= 6,
29
SAY_DEATH_2
= 7,
30
SAY_DEATH_3
= 8,
31
SAY_SPELL
= 9,
32
SAY_RAND_1
= 10,
33
SAY_RAND_2
= 11
34
};
35
36
enum
Spells
37
{
38
SPELL_DEATH_COIL
= 33130,
39
SPELL_ELIXIR_OF_FORTITUDE
= 3593,
40
SPELL_BLUE_FIREWORK
= 11540
41
};
42
43
enum
Creatures
44
{
45
NPC_FELBOAR
= 21878
46
};
47
48
#define GOSSIP_ITEM_1 "Click to Test Escort(Attack, Run)"
49
#define GOSSIP_ITEM_2 "Click to Test Escort(NoAttack, Walk)"
50
#define GOSSIP_ITEM_3 "Click to Test Escort(NoAttack, Run)"
51
52
class
example_escort
:
public
CreatureScript
53
{
54
public
:
55
example_escort
() :
CreatureScript
(
"example_escort"
) { }
56
57
struct
example_escortAI
:
public
npc_escortAI
58
{
59
// CreatureAI functions
60
example_escortAI
(
Creature
* creature) :
npc_escortAI
(creature) { }
61
62
uint32
m_uiDeathCoilTimer
;
63
uint32
m_uiChatTimer
;
64
65
void
JustSummoned
(
Creature
* summoned)
OVERRIDE
66
{
67
summoned->AI()->AttackStart(
me
);
68
}
69
70
// Pure Virtual Functions (Have to be implemented)
71
void
WaypointReached
(
uint32
waypointId)
OVERRIDE
72
{
73
switch
(waypointId)
74
{
75
case
1:
76
Talk
(
SAY_WP_1
);
77
break
;
78
case
3:
79
Talk
(
SAY_WP_2
);
80
me
->SummonCreature(
NPC_FELBOAR
,
me
->GetPositionX()+5.0f,
me
->GetPositionY()+7.0f,
me
->GetPositionZ(), 0.0f,
TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
, 3000);
81
break
;
82
case
4:
83
if
(
Player
* player =
GetPlayerForEscort
())
84
{
85
//pTmpPlayer is the target of the text
86
Talk
(
SAY_WP_3
, player);
87
//pTmpPlayer is the source of the text
88
sCreatureTextMgr
->SendChat(
me
,
SAY_WP_4
, 0,
CHAT_MSG_ADDON
,
LANG_ADDON
,
TEXT_RANGE_NORMAL
, 0,
TEAM_OTHER
,
false
, player);
89
}
90
break
;
91
}
92
}
93
94
void
EnterCombat
(
Unit
*
/*who*/
)
OVERRIDE
95
{
96
if
(
HasEscortState
(
STATE_ESCORT_ESCORTING
))
97
{
98
if
(
Player
* player =
GetPlayerForEscort
())
99
Talk
(
SAY_AGGRO1
, player);
100
}
101
else
102
Talk
(
SAY_AGGRO2
);
103
}
104
105
void
Reset
()
OVERRIDE
106
{
107
m_uiDeathCoilTimer
= 4000;
108
m_uiChatTimer
= 4000;
109
}
110
111
void
JustDied
(
Unit
* killer)
OVERRIDE
112
{
113
if
(
HasEscortState
(
STATE_ESCORT_ESCORTING
))
114
{
115
if
(
Player
* player =
GetPlayerForEscort
())
116
{
117
// not a likely case, code here for the sake of example
118
if
(killer ==
me
)
119
Talk
(
SAY_DEATH_1
, player);
120
else
121
Talk
(
SAY_DEATH_2
, player);
122
}
123
}
124
else
125
Talk
(
SAY_DEATH_3
);
126
}
127
128
void
UpdateAI
(
uint32
uiDiff)
OVERRIDE
129
{
130
//Must update npc_escortAI
131
npc_escortAI::UpdateAI
(uiDiff);
132
133
//Combat check
134
if
(
me
->GetVictim())
135
{
136
if
(
m_uiDeathCoilTimer
<= uiDiff)
137
{
138
Talk
(
SAY_SPELL
);
139
DoCastVictim
(
SPELL_DEATH_COIL
,
false
);
140
m_uiDeathCoilTimer
= 4000;
141
}
142
else
143
m_uiDeathCoilTimer
-= uiDiff;
144
}
145
else
146
{
147
//Out of combat but being escorted
148
if
(
HasEscortState
(
STATE_ESCORT_ESCORTING
))
149
{
150
if
(
m_uiChatTimer
<= uiDiff)
151
{
152
if
(
me
->HasAura(
SPELL_ELIXIR_OF_FORTITUDE
, 0))
153
{
154
Talk
(
SAY_RAND_1
);
155
DoCast
(
me
,
SPELL_BLUE_FIREWORK
,
false
);
156
}
157
else
158
{
159
Talk
(
SAY_RAND_2
);
160
DoCast
(
me
,
SPELL_ELIXIR_OF_FORTITUDE
,
false
);
161
}
162
163
m_uiChatTimer
= 12000;
164
}
165
else
166
m_uiChatTimer
-= uiDiff;
167
}
168
}
169
}
170
};
171
172
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
173
{
174
return
new
example_escortAI
(creature);
175
}
176
177
bool
OnGossipHello
(
Player
* player,
Creature
* creature)
OVERRIDE
178
{
179
player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
180
player->PrepareGossipMenu(creature, 0);
181
182
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_CHAT
,
GOSSIP_ITEM_1
,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INFO_DEF
+1);
183
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_CHAT
,
GOSSIP_ITEM_2
,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INFO_DEF
+2);
184
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_CHAT
,
GOSSIP_ITEM_3
,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INFO_DEF
+3);
185
186
player->SendPreparedGossip(creature);
187
188
return
true
;
189
}
190
191
bool
OnGossipSelect
(
Player
* player,
Creature
* creature,
uint32
/*sender*/
,
uint32
action)
OVERRIDE
192
{
193
player->PlayerTalkClass->ClearMenus();
194
npc_escortAI
* pEscortAI =
CAST_AI
(
example_escort::example_escortAI
, creature->AI());
195
196
switch
(action)
197
{
198
case
GOSSIP_ACTION_INFO_DEF
+1:
199
player->CLOSE_GOSSIP_MENU();
200
201
if
(pEscortAI)
202
pEscortAI->
Start
(
true
,
true
, player->GetGUID());
203
break
;
204
case
GOSSIP_ACTION_INFO_DEF
+2:
205
player->CLOSE_GOSSIP_MENU();
206
207
if
(pEscortAI)
208
pEscortAI->
Start
(
false
,
false
, player->GetGUID());
209
break
;
210
case
GOSSIP_ACTION_INFO_DEF
+3:
211
player->CLOSE_GOSSIP_MENU();
212
213
if
(pEscortAI)
214
pEscortAI->
Start
(
false
,
true
, player->GetGUID());
215
break
;
216
default
:
217
return
false
;
// nothing defined -> trinity core handling
218
}
219
220
return
true
;
// no default handling -> prevent trinity core handling
221
}
222
};
223
224
void
AddSC_example_escort
()
225
{
226
new
example_escort
();
227
}
Spells
Spells
Definition
BattlegroundIC.h:645
CreatureTextMgr.h
sCreatureTextMgr
#define sCreatureTextMgr
Definition
CreatureTextMgr.h:104
TEXT_RANGE_NORMAL
@ TEXT_RANGE_NORMAL
Definition
CreatureTextMgr.h:32
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
static constexpr TempSummonType TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition
ElunaCompatibility.h:28
GOSSIP_ICON_CHAT
@ GOSSIP_ICON_CHAT
Definition
GossipDef.h:46
Player.h
ScriptMgr.h
ScriptedCreature.h
CAST_AI
#define CAST_AI(a, b)
Definition
ScriptedCreature.h:14
ScriptedEscortAI.h
STATE_ESCORT_ESCORTING
@ STATE_ESCORT_ESCORTING
Definition
ScriptedEscortAI.h:35
ScriptedGossip.h
GOSSIP_SENDER_MAIN
@ GOSSIP_SENDER_MAIN
Definition
ScriptedGossip.h:58
GOSSIP_ACTION_INFO_DEF
@ GOSSIP_ACTION_INFO_DEF
Definition
ScriptedGossip.h:56
ChatMsg::CHAT_MSG_ADDON
@ CHAT_MSG_ADDON
Definition
SharedDefines.h:3663
Language::LANG_ADDON
@ LANG_ADDON
Definition
SharedDefines.h:838
TEAM_OTHER
@ TEAM_OTHER
Definition
SharedDefines.h:884
Creatures
Creatures
Definition
alterac_valley.cpp:28
SPELL_DEATH_COIL
@ SPELL_DEATH_COIL
Definition
chapter1.cpp:34
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::Talk
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
Definition
CreatureAI.cpp:28
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
Player
Definition
Player.h:1289
UnitAI::DoCast
void DoCast(uint32 spellId)
Definition
UnitAI.cpp:110
UnitAI::DoCastVictim
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition
UnitAI.cpp:168
Unit
Definition
Unit.h:1367
example_escort
Definition
example_escort.cpp:53
example_escort::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
example_escort.cpp:172
example_escort::example_escort
example_escort()
Definition
example_escort.cpp:55
example_escort::OnGossipSelect
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
Definition
example_escort.cpp:191
example_escort::OnGossipHello
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
Definition
example_escort.cpp:177
NPC_FELBOAR
@ NPC_FELBOAR
Definition
example_escort.cpp:45
GOSSIP_ITEM_3
#define GOSSIP_ITEM_3
Definition
example_escort.cpp:50
GOSSIP_ITEM_2
#define GOSSIP_ITEM_2
Definition
example_escort.cpp:49
SAY_RAND_2
@ SAY_RAND_2
Definition
example_escort.cpp:33
SAY_AGGRO1
@ SAY_AGGRO1
Definition
example_escort.cpp:22
SAY_WP_3
@ SAY_WP_3
Definition
example_escort.cpp:26
SAY_DEATH_2
@ SAY_DEATH_2
Definition
example_escort.cpp:29
SAY_WP_2
@ SAY_WP_2
Definition
example_escort.cpp:25
SAY_WP_4
@ SAY_WP_4
Definition
example_escort.cpp:27
SAY_DEATH_3
@ SAY_DEATH_3
Definition
example_escort.cpp:30
SAY_RAND_1
@ SAY_RAND_1
Definition
example_escort.cpp:32
SAY_SPELL
@ SAY_SPELL
Definition
example_escort.cpp:31
SAY_DEATH_1
@ SAY_DEATH_1
Definition
example_escort.cpp:28
SAY_AGGRO2
@ SAY_AGGRO2
Definition
example_escort.cpp:23
SAY_WP_1
@ SAY_WP_1
Definition
example_escort.cpp:24
GOSSIP_ITEM_1
#define GOSSIP_ITEM_1
Definition
example_escort.cpp:48
SPELL_DEATH_COIL
@ SPELL_DEATH_COIL
Definition
example_escort.cpp:38
SPELL_BLUE_FIREWORK
@ SPELL_BLUE_FIREWORK
Definition
example_escort.cpp:40
SPELL_ELIXIR_OF_FORTITUDE
@ SPELL_ELIXIR_OF_FORTITUDE
Definition
example_escort.cpp:39
AddSC_example_escort
void AddSC_example_escort()
Definition
example_escort.cpp:224
ScriptedAI::me
Creature * me
Definition
ScriptedCreature.h:182
Yells
Definition
boss_illidan.cpp:256
example_escort::example_escortAI
Definition
example_escort.cpp:58
example_escort::example_escortAI::Reset
void Reset() OVERRIDE
Definition
example_escort.cpp:105
example_escort::example_escortAI::UpdateAI
void UpdateAI(uint32 uiDiff) OVERRIDE
== Triggered Actions Requested ==================
Definition
example_escort.cpp:128
example_escort::example_escortAI::EnterCombat
void EnterCombat(Unit *) OVERRIDE
Definition
example_escort.cpp:94
example_escort::example_escortAI::m_uiDeathCoilTimer
uint32 m_uiDeathCoilTimer
Definition
example_escort.cpp:62
example_escort::example_escortAI::JustDied
void JustDied(Unit *killer) OVERRIDE
Definition
example_escort.cpp:111
example_escort::example_escortAI::example_escortAI
example_escortAI(Creature *creature)
Definition
example_escort.cpp:60
example_escort::example_escortAI::JustSummoned
void JustSummoned(Creature *summoned) OVERRIDE
Definition
example_escort.cpp:65
example_escort::example_escortAI::WaypointReached
void WaypointReached(uint32 waypointId) OVERRIDE
Definition
example_escort.cpp:71
example_escort::example_escortAI::m_uiChatTimer
uint32 m_uiChatTimer
Definition
example_escort.cpp:63
npc_escortAI
Definition
ScriptedEscortAI.h:41
npc_escortAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
ScriptedEscortAI.cpp:209
npc_escortAI::GetPlayerForEscort
Player * GetPlayerForEscort()
Definition
ScriptedEscortAI.h:97
npc_escortAI::HasEscortState
bool HasEscortState(uint32 escortState) const
Definition
ScriptedEscortAI.h:84
npc_escortAI::npc_escortAI
npc_escortAI(Creature *creature)
Definition
ScriptedEscortAI.cpp:24
npc_escortAI::Start
void Start(bool isActiveAttacker=true, bool run=false, uint64 playerGUID=0, Quest const *quest=NULL, bool instantRespawn=false, bool canLoopPath=false, bool resetWaypoints=true)
Definition
ScriptedEscortAI.cpp:420
src
server
scripts
Examples
example_escort.cpp
Generated on
for Project SkyFire Core by
1.17.0