Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
shadowfang_keep.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: Shadowfang_Keep
8
SD%Complete: 75
9
SDComment: npc_shadowfang_prisoner using escortAI for movement to door. Might need additional code in case being attacked. Add proper texts/say().
10
SDCategory: Shadowfang Keep
11
EndScriptData */
12
13
/* ContentData
14
npc_shadowfang_prisoner
15
EndContentData */
16
17
#include "
ScriptMgr.h
"
18
#include "
ScriptedCreature.h
"
19
#include "
ScriptedGossip.h
"
20
#include "
SpellScript.h
"
21
#include "
SpellAuraEffects.h
"
22
#include "
ScriptedEscortAI.h
"
23
#include "
shadowfang_keep.h
"
24
#include "
Player.h
"
25
26
/*######
27
## npc_shadowfang_prisoner
28
######*/
29
30
enum
Yells
31
{
32
SAY_FREE_AS
= 0,
33
SAY_OPEN_DOOR_AS
= 1,
34
SAY_POST_DOOR_AS
= 2,
35
SAY_FREE_AD
= 0,
36
SAY_OPEN_DOOR_AD
= 1,
37
SAY_POST1_DOOR_AD
= 2,
38
SAY_POST2_DOOR_AD
= 3
39
};
40
41
enum
Spells
42
{
43
SPELL_UNLOCK
= 6421,
44
45
SPELL_DARK_OFFERING
= 7154
46
};
47
48
enum
Creatures
49
{
50
NPC_ASH
= 3850
51
};
52
53
#define GOSSIP_ITEM_DOOR "Thanks, I'll follow you to the door."
54
55
class
npc_shadowfang_prisoner
:
public
CreatureScript
56
{
57
public
:
58
npc_shadowfang_prisoner
() :
CreatureScript
(
"npc_shadowfang_prisoner"
) { }
59
60
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
61
{
62
return
new
npc_shadowfang_prisonerAI
(creature);
63
}
64
65
bool
OnGossipSelect
(
Player
* player,
Creature
* creature,
uint32
/*sender*/
,
uint32
action)
OVERRIDE
66
{
67
player->PlayerTalkClass->ClearMenus();
68
if
(action ==
GOSSIP_ACTION_INFO_DEF
+1)
69
{
70
player->CLOSE_GOSSIP_MENU();
71
72
if
(
npc_escortAI
* pEscortAI =
CAST_AI
(
npc_shadowfang_prisoner::npc_shadowfang_prisonerAI
, creature->AI()))
73
pEscortAI->Start(
false
,
false
);
74
}
75
return
true
;
76
}
77
78
bool
OnGossipHello
(
Player
* player,
Creature
* creature)
OVERRIDE
79
{
80
InstanceScript
* instance = creature->GetInstanceScript();
81
82
if
(instance && instance->
GetData
(
TYPE_FREE_NPC
) !=
DONE
&& instance->
GetData
(
TYPE_RETHILGORE
) ==
DONE
)
83
player->ADD_GOSSIP_ITEM(
GOSSIP_ICON_CHAT
,
GOSSIP_ITEM_DOOR
,
GOSSIP_SENDER_MAIN
,
GOSSIP_ACTION_INFO_DEF
+1);
84
85
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
86
87
return
true
;
88
}
89
90
struct
npc_shadowfang_prisonerAI
:
public
npc_escortAI
91
{
92
npc_shadowfang_prisonerAI
(
Creature
* creature) :
npc_escortAI
(creature)
93
{
94
instance
= creature->
GetInstanceScript
();
95
}
96
97
InstanceScript
*
instance
;
98
99
void
WaypointReached
(
uint32
waypointId)
OVERRIDE
100
{
101
switch
(waypointId)
102
{
103
case
0:
104
if
(
me
->GetEntry() ==
NPC_ASH
)
105
Talk
(
SAY_FREE_AS
);
106
else
107
Talk
(
SAY_FREE_AD
);
108
break
;
109
case
10:
110
if
(
me
->GetEntry() ==
NPC_ASH
)
111
Talk
(
SAY_OPEN_DOOR_AS
);
112
else
113
Talk
(
SAY_OPEN_DOOR_AD
);
114
break
;
115
case
11:
116
if
(
me
->GetEntry() ==
NPC_ASH
)
117
DoCast
(
me
,
SPELL_UNLOCK
);
118
break
;
119
case
12:
120
if
(
me
->GetEntry() ==
NPC_ASH
)
121
Talk
(
SAY_POST_DOOR_AS
);
122
else
123
Talk
(
SAY_POST1_DOOR_AD
);
124
125
if
(
instance
)
126
instance
->SetData(
TYPE_FREE_NPC
,
DONE
);
127
break
;
128
case
13:
129
if
(
me
->GetEntry() !=
NPC_ASH
)
130
Talk
(
SAY_POST2_DOOR_AD
);
131
break
;
132
}
133
}
134
135
void
Reset
()
OVERRIDE
{ }
136
void
EnterCombat
(
Unit
*
/*who*/
)
OVERRIDE
{ }
137
};
138
139
};
140
141
class
npc_arugal_voidwalker
:
public
CreatureScript
142
{
143
public
:
144
npc_arugal_voidwalker
() :
CreatureScript
(
"npc_arugal_voidwalker"
) { }
145
146
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
147
{
148
return
new
npc_arugal_voidwalkerAI
(creature);
149
}
150
151
struct
npc_arugal_voidwalkerAI
:
public
ScriptedAI
152
{
153
npc_arugal_voidwalkerAI
(
Creature
* creature) :
ScriptedAI
(creature)
154
{
155
instance
= creature->
GetInstanceScript
();
156
}
157
158
InstanceScript
*
instance
;
159
160
uint32
uiDarkOffering
;
161
162
void
Reset
()
OVERRIDE
163
{
164
uiDarkOffering
= urand(200, 1000);
165
}
166
167
void
UpdateAI
(
uint32
uiDiff)
OVERRIDE
168
{
169
if
(!
UpdateVictim
())
170
return
;
171
172
if
(
uiDarkOffering
<= uiDiff)
173
{
174
if
(
Creature
* pFriend =
me
->FindNearestCreature(
me
->GetEntry(), 25.0f,
true
))
175
DoCast
(pFriend,
SPELL_DARK_OFFERING
);
176
else
177
DoCast
(
me
,
SPELL_DARK_OFFERING
);
178
uiDarkOffering
= urand(4400, 12500);
179
}
else
uiDarkOffering
-= uiDiff;
180
181
DoMeleeAttackIfReady
();
182
}
183
184
void
JustDied
(
Unit
*
/*killer*/
)
OVERRIDE
185
{
186
if
(
instance
)
187
instance
->SetData(
TYPE_FENRUS
,
instance
->GetData(
TYPE_FENRUS
) + 1);
188
}
189
};
190
191
};
192
193
class
spell_shadowfang_keep_haunting_spirits
:
public
SpellScriptLoader
194
{
195
public
:
196
spell_shadowfang_keep_haunting_spirits
() :
SpellScriptLoader
(
"spell_shadowfang_keep_haunting_spirits"
) { }
197
198
class
spell_shadowfang_keep_haunting_spirits_AuraScript
:
public
AuraScript
199
{
200
PrepareAuraScript
(
spell_shadowfang_keep_haunting_spirits_AuraScript
);
201
202
void
CalcPeriodic
(
AuraEffect
const
*
/*aurEff*/
,
bool
& isPeriodic,
int32
& amplitude)
203
{
204
isPeriodic =
true
;
205
amplitude = (irand(0, 60) + 30) *
IN_MILLISECONDS
;
206
}
207
208
void
HandleDummyTick
(
AuraEffect
const
* aurEff)
209
{
210
GetTarget
()->
CastSpell
((
Unit
*)NULL, aurEff->
GetAmount
(),
true
);
211
}
212
213
void
HandleUpdatePeriodic
(
AuraEffect
* aurEff)
214
{
215
aurEff->
CalculatePeriodic
(
GetCaster
());
216
}
217
218
void
Register
()
OVERRIDE
219
{
220
DoEffectCalcPeriodic
+=
AuraEffectCalcPeriodicFn
(
spell_shadowfang_keep_haunting_spirits_AuraScript::CalcPeriodic
,
EFFECT_0
,
SPELL_AURA_DUMMY
);
221
OnEffectPeriodic
+=
AuraEffectPeriodicFn
(
spell_shadowfang_keep_haunting_spirits_AuraScript::HandleDummyTick
,
EFFECT_0
,
SPELL_AURA_DUMMY
);
222
OnEffectUpdatePeriodic
+=
AuraEffectUpdatePeriodicFn
(
spell_shadowfang_keep_haunting_spirits_AuraScript::HandleUpdatePeriodic
,
EFFECT_0
,
SPELL_AURA_DUMMY
);
223
}
224
};
225
226
AuraScript
*
GetAuraScript
() const
OVERRIDE
227
{
228
return
new
spell_shadowfang_keep_haunting_spirits_AuraScript
();
229
}
230
};
231
232
void
AddSC_shadowfang_keep
()
233
{
234
new
npc_shadowfang_prisoner
();
235
new
npc_arugal_voidwalker
();
236
new
spell_shadowfang_keep_haunting_spirits
();
237
}
Spells
Spells
Definition
BattlegroundIC.h:645
IN_MILLISECONDS
@ IN_MILLISECONDS
Definition
Common.h:125
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
GOSSIP_ICON_CHAT
@ GOSSIP_ICON_CHAT
Definition
GossipDef.h:46
DONE
@ DONE
Definition
InstanceScript.h:49
Player.h
ScriptMgr.h
ScriptedCreature.h
CAST_AI
#define CAST_AI(a, b)
Definition
ScriptedCreature.h:14
ScriptedEscortAI.h
ScriptedGossip.h
GOSSIP_SENDER_MAIN
@ GOSSIP_SENDER_MAIN
Definition
ScriptedGossip.h:58
GOSSIP_ACTION_INFO_DEF
@ GOSSIP_ACTION_INFO_DEF
Definition
ScriptedGossip.h:56
EFFECT_0
@ EFFECT_0
Definition
SharedDefines.h:18
SPELL_AURA_DUMMY
@ SPELL_AURA_DUMMY
Definition
SpellAuraDefines.h:51
SpellAuraEffects.h
SpellScript.h
AuraEffectPeriodicFn
#define AuraEffectPeriodicFn(F, I, N)
Definition
SpellScript.h:669
AuraEffectUpdatePeriodicFn
#define AuraEffectUpdatePeriodicFn(F, I, N)
Definition
SpellScript.h:675
AuraEffectCalcPeriodicFn
#define AuraEffectCalcPeriodicFn(F, I, N)
Definition
SpellScript.h:687
Creatures
Creatures
Definition
alterac_valley.cpp:28
AuraEffect
Definition
SpellAuraEffects.h:18
AuraEffect::CalculatePeriodic
void CalculatePeriodic(Unit *caster, bool resetPeriodicTimer=true, bool load=false)
Definition
SpellAuraEffects.cpp:631
AuraEffect::GetAmount
int32 GetAmount() const
Definition
SpellAuraEffects.h:42
AuraScript
Definition
SpellScript.h:436
AuraScript::DoEffectCalcPeriodic
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
Definition
SpellScript.h:686
AuraScript::OnEffectPeriodic
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition
SpellScript.h:668
AuraScript::AuraScript
AuraScript()
Definition
SpellScript.h:597
AuraScript::GetCaster
Unit * GetCaster() const
Definition
SpellScript.cpp:940
AuraScript::OnEffectUpdatePeriodic
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
Definition
SpellScript.h:674
AuraScript::GetTarget
Unit * GetTarget() const
Definition
SpellScript.cpp:1085
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::Talk
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
Definition
CreatureAI.cpp:28
CreatureAI::UpdateVictim
bool UpdateVictim()
Definition
CreatureAI.cpp:192
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
InstanceScript
Definition
InstanceScript.h:123
Player
Definition
Player.h:1289
SpellScriptLoader::SpellScriptLoader
SpellScriptLoader(const char *name)
Definition
ScriptMgr.cpp:1372
UnitAI::DoMeleeAttackIfReady
void DoMeleeAttackIfReady()
Definition
UnitAI.cpp:28
UnitAI::DoCast
void DoCast(uint32 spellId)
Definition
UnitAI.cpp:110
Unit
Definition
Unit.h:1367
Unit::CastSpell
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
Definition
UnitCombat.cpp:324
WorldObject::GetInstanceScript
InstanceScript * GetInstanceScript()
Definition
Object.cpp:1612
ZoneScript::GetData
virtual uint32 GetData(uint32) const
Definition
ZoneScript.h:36
npc_arugal_voidwalker
Definition
shadowfang_keep.cpp:142
npc_arugal_voidwalker::npc_arugal_voidwalker
npc_arugal_voidwalker()
Definition
shadowfang_keep.cpp:144
npc_arugal_voidwalker::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
shadowfang_keep.cpp:146
npc_shadowfang_prisoner
Definition
shadowfang_keep.cpp:56
npc_shadowfang_prisoner::OnGossipSelect
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
Definition
shadowfang_keep.cpp:65
npc_shadowfang_prisoner::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
shadowfang_keep.cpp:60
npc_shadowfang_prisoner::OnGossipHello
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
Definition
shadowfang_keep.cpp:78
npc_shadowfang_prisoner::npc_shadowfang_prisoner
npc_shadowfang_prisoner()
Definition
shadowfang_keep.cpp:58
spell_shadowfang_keep_haunting_spirits::spell_shadowfang_keep_haunting_spirits_AuraScript
Definition
shadowfang_keep.cpp:199
spell_shadowfang_keep_haunting_spirits::spell_shadowfang_keep_haunting_spirits_AuraScript::HandleUpdatePeriodic
void HandleUpdatePeriodic(AuraEffect *aurEff)
Definition
shadowfang_keep.cpp:213
spell_shadowfang_keep_haunting_spirits::spell_shadowfang_keep_haunting_spirits_AuraScript::HandleDummyTick
void HandleDummyTick(AuraEffect const *aurEff)
Definition
shadowfang_keep.cpp:208
spell_shadowfang_keep_haunting_spirits::spell_shadowfang_keep_haunting_spirits_AuraScript::PrepareAuraScript
PrepareAuraScript(spell_shadowfang_keep_haunting_spirits_AuraScript)
spell_shadowfang_keep_haunting_spirits::spell_shadowfang_keep_haunting_spirits_AuraScript::Register
void Register() OVERRIDE
Definition
shadowfang_keep.cpp:218
spell_shadowfang_keep_haunting_spirits::spell_shadowfang_keep_haunting_spirits_AuraScript::CalcPeriodic
void CalcPeriodic(AuraEffect const *, bool &isPeriodic, int32 &litude)
Definition
shadowfang_keep.cpp:202
spell_shadowfang_keep_haunting_spirits
Definition
shadowfang_keep.cpp:194
spell_shadowfang_keep_haunting_spirits::GetAuraScript
AuraScript * GetAuraScript() const OVERRIDE
Definition
shadowfang_keep.cpp:226
spell_shadowfang_keep_haunting_spirits::spell_shadowfang_keep_haunting_spirits
spell_shadowfang_keep_haunting_spirits()
Definition
shadowfang_keep.cpp:196
NPC_ASH
@ NPC_ASH
Definition
instance_shadowfang_keep.cpp:30
NPC_ASH
@ NPC_ASH
Definition
shadowfang_keep.cpp:50
SAY_OPEN_DOOR_AS
@ SAY_OPEN_DOOR_AS
Definition
shadowfang_keep.cpp:33
SAY_OPEN_DOOR_AD
@ SAY_OPEN_DOOR_AD
Definition
shadowfang_keep.cpp:36
SAY_POST1_DOOR_AD
@ SAY_POST1_DOOR_AD
Definition
shadowfang_keep.cpp:37
SAY_FREE_AD
@ SAY_FREE_AD
Definition
shadowfang_keep.cpp:35
SAY_FREE_AS
@ SAY_FREE_AS
Definition
shadowfang_keep.cpp:32
SAY_POST_DOOR_AS
@ SAY_POST_DOOR_AS
Definition
shadowfang_keep.cpp:34
SAY_POST2_DOOR_AD
@ SAY_POST2_DOOR_AD
Definition
shadowfang_keep.cpp:38
SPELL_DARK_OFFERING
@ SPELL_DARK_OFFERING
Definition
shadowfang_keep.cpp:45
SPELL_UNLOCK
@ SPELL_UNLOCK
Definition
shadowfang_keep.cpp:43
AddSC_shadowfang_keep
void AddSC_shadowfang_keep()
Definition
shadowfang_keep.cpp:232
GOSSIP_ITEM_DOOR
#define GOSSIP_ITEM_DOOR
Definition
shadowfang_keep.cpp:53
shadowfang_keep.h
TYPE_FENRUS
@ TYPE_FENRUS
Definition
shadowfang_keep.h:13
TYPE_RETHILGORE
@ TYPE_RETHILGORE
Definition
shadowfang_keep.h:12
TYPE_FREE_NPC
@ TYPE_FREE_NPC
Definition
shadowfang_keep.h:11
ScriptedAI::me
Creature * me
Definition
ScriptedCreature.h:182
ScriptedAI::ScriptedAI
ScriptedAI(Creature *creature)
Definition
ScriptedCreature.cpp:85
Yells
Definition
boss_illidan.cpp:256
npc_arugal_voidwalker::npc_arugal_voidwalkerAI
Definition
shadowfang_keep.cpp:152
npc_arugal_voidwalker::npc_arugal_voidwalkerAI::uiDarkOffering
uint32 uiDarkOffering
Definition
shadowfang_keep.cpp:160
npc_arugal_voidwalker::npc_arugal_voidwalkerAI::instance
InstanceScript * instance
Definition
shadowfang_keep.cpp:158
npc_arugal_voidwalker::npc_arugal_voidwalkerAI::npc_arugal_voidwalkerAI
npc_arugal_voidwalkerAI(Creature *creature)
Definition
shadowfang_keep.cpp:153
npc_arugal_voidwalker::npc_arugal_voidwalkerAI::Reset
void Reset() OVERRIDE
Definition
shadowfang_keep.cpp:162
npc_arugal_voidwalker::npc_arugal_voidwalkerAI::UpdateAI
void UpdateAI(uint32 uiDiff) OVERRIDE
== Triggered Actions Requested ==================
Definition
shadowfang_keep.cpp:167
npc_arugal_voidwalker::npc_arugal_voidwalkerAI::JustDied
void JustDied(Unit *) OVERRIDE
Definition
shadowfang_keep.cpp:184
npc_escortAI
Definition
ScriptedEscortAI.h:41
npc_escortAI::npc_escortAI
npc_escortAI(Creature *creature)
Definition
ScriptedEscortAI.cpp:24
npc_shadowfang_prisoner::npc_shadowfang_prisonerAI
Definition
shadowfang_keep.cpp:91
npc_shadowfang_prisoner::npc_shadowfang_prisonerAI::instance
InstanceScript * instance
Definition
shadowfang_keep.cpp:97
npc_shadowfang_prisoner::npc_shadowfang_prisonerAI::npc_shadowfang_prisonerAI
npc_shadowfang_prisonerAI(Creature *creature)
Definition
shadowfang_keep.cpp:92
npc_shadowfang_prisoner::npc_shadowfang_prisonerAI::EnterCombat
void EnterCombat(Unit *) OVERRIDE
Definition
shadowfang_keep.cpp:136
npc_shadowfang_prisoner::npc_shadowfang_prisonerAI::WaypointReached
void WaypointReached(uint32 waypointId) OVERRIDE
Definition
shadowfang_keep.cpp:99
npc_shadowfang_prisoner::npc_shadowfang_prisonerAI::Reset
void Reset() OVERRIDE
Definition
shadowfang_keep.cpp:135
src
server
scripts
EasternKingdoms
ShadowfangKeep
shadowfang_keep.cpp
Generated on
for Project SkyFire Core by
1.17.0