Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
mob_anubisath_sentinel.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: npc_anubisath_sentinel
8
SD%Complete: 95
9
SDComment: Shadow storm is not properly implemented in core it should only target ppl outside of melee range.
10
SDCategory: Temple of Ahn'Qiraj
11
EndScriptData */
12
13
#include "
ScriptMgr.h
"
14
#include "
ScriptedCreature.h
"
15
#include "
WorldPacket.h
"
16
17
#include "
Item.h
"
18
#include "
Player.h
"
19
#include "
Spell.h
"
20
21
#include "
Cell.h
"
22
#include "
CellImpl.h
"
23
#include "
GridNotifiers.h
"
24
#include "
GridNotifiersImpl.h
"
25
26
enum
Spells
27
{
28
SPELL_MENDING_BUFF
= 2147,
29
30
SPELL_KNOCK_BUFF
= 21737,
31
SPELL_KNOCK
= 25778,
32
SPELL_MANAB_BUFF
= 812,
33
SPELL_MANAB
= 25779,
34
35
SPELL_REFLECTAF_BUFF
= 13022,
36
SPELL_REFLECTSFr_BUFF
= 19595,
37
SPELL_THORNS_BUFF
= 25777,
38
39
SPELL_THUNDER_BUFF
= 2834,
40
SPELL_THUNDER
= 8732,
41
42
SPELL_MSTRIKE_BUFF
= 9347,
43
SPELL_MSTRIKE
= 24573,
44
45
SPELL_STORM_BUFF
= 2148,
46
SPELL_STORM
= 26546
47
};
48
49
class
npc_anubisath_sentinel
:
public
CreatureScript
50
{
51
public
:
52
npc_anubisath_sentinel
() :
CreatureScript
(
"npc_anubisath_sentinel"
) { }
53
54
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
55
{
56
return
new
aqsentinelAI
(creature);
57
}
58
59
struct
aqsentinelAI
:
public
ScriptedAI
60
{
61
uint32
ability
;
62
int
abselected
;
63
64
void
selectAbility
(
int
asel)
65
{
66
switch
(asel)
67
{
68
case
0:
ability
=
SPELL_MENDING_BUFF
;
break
;
69
case
1:
ability
=
SPELL_KNOCK_BUFF
;
break
;
70
case
2:
ability
=
SPELL_MANAB_BUFF
;
break
;
71
case
3:
ability
=
SPELL_REFLECTAF_BUFF
;
break
;
72
case
4:
ability
=
SPELL_REFLECTSFr_BUFF
;
break
;
73
case
5:
ability
=
SPELL_THORNS_BUFF
;
break
;
74
case
6:
ability
=
SPELL_THUNDER_BUFF
;
break
;
75
case
7:
ability
=
SPELL_MSTRIKE_BUFF
;
break
;
76
case
8:
ability
=
SPELL_STORM_BUFF
;
break
;
77
}
78
}
79
80
aqsentinelAI
(
Creature
* creature) :
ScriptedAI
(creature)
81
{
82
ClearBuddyList
();
83
abselected
= 0;
// just initialization of variable
84
}
85
86
uint64
NearbyGUID
[3];
87
88
void
ClearBuddyList
()
89
{
90
NearbyGUID
[0] =
NearbyGUID
[1] =
NearbyGUID
[2] = 0;
91
}
92
93
void
AddBuddyToList
(
uint64
CreatureGUID)
94
{
95
if
(CreatureGUID ==
me
->GetGUID())
96
return
;
97
98
for
(
int
i=0; i<3; ++i)
99
{
100
if
(
NearbyGUID
[i] == CreatureGUID)
101
return
;
102
if
(!
NearbyGUID
[i])
103
{
104
NearbyGUID
[i] = CreatureGUID;
105
return
;
106
}
107
}
108
}
109
110
void
GiveBuddyMyList
(
Creature
* c)
111
{
112
aqsentinelAI
* cai =
CAST_AI
(
aqsentinelAI
, (c)->AI());
113
for
(
int
i=0; i<3; ++i)
114
if
(
NearbyGUID
[i] &&
NearbyGUID
[i] != c->
GetGUID
())
115
cai->
AddBuddyToList
(
NearbyGUID
[i]);
116
cai->
AddBuddyToList
(
me
->GetGUID());
117
}
118
119
void
SendMyListToBuddies
()
120
{
121
for
(
int
i=0; i<3; ++i)
122
if
(
Creature
* pNearby =
Unit::GetCreature
(*
me
,
NearbyGUID
[i]))
123
GiveBuddyMyList
(pNearby);
124
}
125
126
void
CallBuddiesToAttack
(
Unit
* who)
127
{
128
for
(
int
i=0; i<3; ++i)
129
{
130
Creature
* c =
Unit::GetCreature
(*
me
,
NearbyGUID
[i]);
131
if
(c)
132
{
133
if
(!c->
IsInCombat
())
134
{
135
c->
SetNoCallAssistance
(
true
);
136
if
(c->
AI
())
137
c->
AI
()->
AttackStart
(who);
138
}
139
}
140
}
141
}
142
143
void
AddSentinelsNear
(
Unit
*
/*nears*/
)
144
{
145
std::list<Creature*> assistList;
146
me
->GetCreatureListWithEntryInGrid(assistList, 15264, 70.0f);
147
148
if
(assistList.empty())
149
return
;
150
151
for
(std::list<Creature*>::const_iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
152
AddBuddyToList
((*iter)->GetGUID());
153
}
154
155
int
pickAbilityRandom
(
bool
*chosenAbilities)
156
{
157
for
(
int
t = 0; t < 2; ++t)
158
{
159
for
(
int
i = !t ? (rand()%9) : 0; i < 9; ++i)
160
{
161
if
(!chosenAbilities[i])
162
{
163
chosenAbilities[i] =
true
;
164
return
i;
165
}
166
}
167
}
168
return
0;
// should never happen
169
}
170
171
void
GetOtherSentinels
(
Unit
* who)
172
{
173
bool
*chosenAbilities =
new
bool
[9];
174
memset(chosenAbilities, 0, 9*
sizeof
(
bool
));
175
selectAbility
(
pickAbilityRandom
(chosenAbilities));
176
177
ClearBuddyList
();
178
AddSentinelsNear
(
me
);
179
int
bli;
180
for
(bli = 0; bli < 3; ++bli)
181
{
182
if
(!
NearbyGUID
[bli])
183
break
;
184
185
Creature
* pNearby =
Unit::GetCreature
(*
me
,
NearbyGUID
[bli]);
186
if
(!pNearby)
187
break
;
188
189
AddSentinelsNear
(pNearby);
190
CAST_AI
(
aqsentinelAI
, pNearby->
AI
())->gatherOthersWhenAggro =
false
;
191
CAST_AI
(
aqsentinelAI
, pNearby->
AI
())->selectAbility(
pickAbilityRandom
(chosenAbilities));
192
}
193
/*if (bli < 3)
194
DoYell("I dont have enough buddies.", LANG_NEUTRAL, 0);*/
195
SendMyListToBuddies
();
196
CallBuddiesToAttack
(who);
197
198
delete
[] chosenAbilities;
199
}
200
201
bool
gatherOthersWhenAggro
;
202
203
void
Reset
()
OVERRIDE
204
{
205
if
(!
me
->isDead())
206
{
207
for
(
int
i=0; i<3; ++i)
208
{
209
if
(!
NearbyGUID
[i])
210
continue
;
211
if
(
Creature
* pNearby =
Unit::GetCreature
(*
me
,
NearbyGUID
[i]))
212
{
213
if
(pNearby->isDead())
214
pNearby->Respawn();
215
}
216
}
217
}
218
ClearBuddyList
();
219
gatherOthersWhenAggro
=
true
;
220
}
221
222
void
GainSentinelAbility
(
uint32
id
)
223
{
224
me
->AddAura(
id
,
me
);
225
}
226
227
void
EnterCombat
(
Unit
* who)
OVERRIDE
228
{
229
if
(
gatherOthersWhenAggro
)
230
GetOtherSentinels
(who);
231
232
GainSentinelAbility
(
ability
);
233
DoZoneInCombat
();
234
}
235
236
void
JustDied
(
Unit
*
/*killer*/
)
OVERRIDE
237
{
238
for
(
int
ni=0; ni<3; ++ni)
239
{
240
Creature
* sent =
Unit::GetCreature
(*
me
,
NearbyGUID
[ni]);
241
if
(!sent)
242
continue
;
243
if
(sent->
isDead
())
244
continue
;
245
sent->
ModifyHealth
(
int32
(sent->
CountPctFromMaxHealth
(50)));
246
CAST_AI
(
aqsentinelAI
, sent->
AI
())->GainSentinelAbility(
ability
);
247
}
248
}
249
};
250
};
251
252
void
AddSC_npc_anubisath_sentinel
()
253
{
254
new
npc_anubisath_sentinel
();
255
}
Spells
Spells
Definition
BattlegroundIC.h:645
Cell.h
CellImpl.h
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
GridNotifiers.h
GridNotifiersImpl.h
Item.h
Player.h
ScriptMgr.h
ScriptedCreature.h
CAST_AI
#define CAST_AI(a, b)
Definition
ScriptedCreature.h:14
Spell.h
WorldPacket.h
SPELL_THUNDER
@ SPELL_THUNDER
Definition
chapter5.cpp:205
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::DoZoneInCombat
void DoZoneInCombat(Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
Definition
CreatureAI.cpp:33
Creature
Definition
Creature.h:427
Creature::SetNoCallAssistance
void SetNoCallAssistance(bool val)
Definition
Creature.h:583
Creature::AI
CreatureAI * AI() const
Definition
Creature.h:483
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
Object::GetGUID
uint64 GetGUID() const
Definition
Object.h:119
UnitAI::AttackStart
virtual void AttackStart(Unit *)
Definition
UnitAI.cpp:16
Unit
Definition
Unit.h:1367
Unit::ModifyHealth
int32 ModifyHealth(int32 val)
Definition
Unit.cpp:4023
Unit::GetCreature
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition
Unit.cpp:4905
Unit::CountPctFromMaxHealth
uint32 CountPctFromMaxHealth(int32 pct) const
Definition
Unit.h:1633
Unit::IsInCombat
bool IsInCombat() const
Definition
Unit.h:1896
Unit::isDead
bool isDead() const
Definition
Unit.h:2040
npc_anubisath_sentinel
Definition
mob_anubisath_sentinel.cpp:50
npc_anubisath_sentinel::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
mob_anubisath_sentinel.cpp:54
npc_anubisath_sentinel::npc_anubisath_sentinel
npc_anubisath_sentinel()
Definition
mob_anubisath_sentinel.cpp:52
SPELL_STORM_BUFF
@ SPELL_STORM_BUFF
Definition
mob_anubisath_sentinel.cpp:45
SPELL_MENDING_BUFF
@ SPELL_MENDING_BUFF
Definition
mob_anubisath_sentinel.cpp:28
SPELL_KNOCK_BUFF
@ SPELL_KNOCK_BUFF
Definition
mob_anubisath_sentinel.cpp:30
SPELL_MANAB_BUFF
@ SPELL_MANAB_BUFF
Definition
mob_anubisath_sentinel.cpp:32
SPELL_THORNS_BUFF
@ SPELL_THORNS_BUFF
Definition
mob_anubisath_sentinel.cpp:37
SPELL_REFLECTAF_BUFF
@ SPELL_REFLECTAF_BUFF
Definition
mob_anubisath_sentinel.cpp:35
SPELL_KNOCK
@ SPELL_KNOCK
Definition
mob_anubisath_sentinel.cpp:31
SPELL_STORM
@ SPELL_STORM
Definition
mob_anubisath_sentinel.cpp:46
SPELL_MSTRIKE_BUFF
@ SPELL_MSTRIKE_BUFF
Definition
mob_anubisath_sentinel.cpp:42
SPELL_REFLECTSFr_BUFF
@ SPELL_REFLECTSFr_BUFF
Definition
mob_anubisath_sentinel.cpp:36
SPELL_MANAB
@ SPELL_MANAB
Definition
mob_anubisath_sentinel.cpp:33
SPELL_THUNDER_BUFF
@ SPELL_THUNDER_BUFF
Definition
mob_anubisath_sentinel.cpp:39
SPELL_MSTRIKE
@ SPELL_MSTRIKE
Definition
mob_anubisath_sentinel.cpp:43
AddSC_npc_anubisath_sentinel
void AddSC_npc_anubisath_sentinel()
Definition
mob_anubisath_sentinel.cpp:252
ScriptedAI::me
Creature * me
Definition
ScriptedCreature.h:182
ScriptedAI::ScriptedAI
ScriptedAI(Creature *creature)
Definition
ScriptedCreature.cpp:85
npc_anubisath_sentinel::aqsentinelAI
Definition
mob_anubisath_sentinel.cpp:60
npc_anubisath_sentinel::aqsentinelAI::NearbyGUID
uint64 NearbyGUID[3]
Definition
mob_anubisath_sentinel.cpp:86
npc_anubisath_sentinel::aqsentinelAI::EnterCombat
void EnterCombat(Unit *who) OVERRIDE
Definition
mob_anubisath_sentinel.cpp:227
npc_anubisath_sentinel::aqsentinelAI::AddSentinelsNear
void AddSentinelsNear(Unit *)
Definition
mob_anubisath_sentinel.cpp:143
npc_anubisath_sentinel::aqsentinelAI::GainSentinelAbility
void GainSentinelAbility(uint32 id)
Definition
mob_anubisath_sentinel.cpp:222
npc_anubisath_sentinel::aqsentinelAI::aqsentinelAI
aqsentinelAI(Creature *creature)
Definition
mob_anubisath_sentinel.cpp:80
npc_anubisath_sentinel::aqsentinelAI::AddBuddyToList
void AddBuddyToList(uint64 CreatureGUID)
Definition
mob_anubisath_sentinel.cpp:93
npc_anubisath_sentinel::aqsentinelAI::CallBuddiesToAttack
void CallBuddiesToAttack(Unit *who)
Definition
mob_anubisath_sentinel.cpp:126
npc_anubisath_sentinel::aqsentinelAI::GiveBuddyMyList
void GiveBuddyMyList(Creature *c)
Definition
mob_anubisath_sentinel.cpp:110
npc_anubisath_sentinel::aqsentinelAI::pickAbilityRandom
int pickAbilityRandom(bool *chosenAbilities)
Definition
mob_anubisath_sentinel.cpp:155
npc_anubisath_sentinel::aqsentinelAI::ClearBuddyList
void ClearBuddyList()
Definition
mob_anubisath_sentinel.cpp:88
npc_anubisath_sentinel::aqsentinelAI::Reset
void Reset() OVERRIDE
Definition
mob_anubisath_sentinel.cpp:203
npc_anubisath_sentinel::aqsentinelAI::abselected
int abselected
Definition
mob_anubisath_sentinel.cpp:62
npc_anubisath_sentinel::aqsentinelAI::ability
uint32 ability
Definition
mob_anubisath_sentinel.cpp:61
npc_anubisath_sentinel::aqsentinelAI::JustDied
void JustDied(Unit *) OVERRIDE
Definition
mob_anubisath_sentinel.cpp:236
npc_anubisath_sentinel::aqsentinelAI::selectAbility
void selectAbility(int asel)
Definition
mob_anubisath_sentinel.cpp:64
npc_anubisath_sentinel::aqsentinelAI::GetOtherSentinels
void GetOtherSentinels(Unit *who)
Definition
mob_anubisath_sentinel.cpp:171
npc_anubisath_sentinel::aqsentinelAI::SendMyListToBuddies
void SendMyListToBuddies()
Definition
mob_anubisath_sentinel.cpp:119
npc_anubisath_sentinel::aqsentinelAI::gatherOthersWhenAggro
bool gatherOthersWhenAggro
Definition
mob_anubisath_sentinel.cpp:201
src
server
scripts
Kalimdor
TempleOfAhnQiraj
mob_anubisath_sentinel.cpp
Generated on
for Project SkyFire Core by
1.17.0