Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
instance_old_hillsbrad.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: Instance_Old_Hillsbrad
8
SD%Complete: 75
9
SDComment: If thrall escort fail, all parts will reset. In future, save sub-parts and continue from last known.
10
SDCategory: Caverns of Time, Old Hillsbrad Foothills
11
EndScriptData */
12
13
#include "
ScriptMgr.h
"
14
#include "
ScriptedCreature.h
"
15
#include "
InstanceScript.h
"
16
#include "
old_hillsbrad.h
"
17
#include "
Player.h
"
18
19
#define MAX_ENCOUNTER 6
20
21
#define THRALL_ENTRY 17876
22
#define TARETHA_ENTRY 18887
23
#define EPOCH_ENTRY 18096
24
25
#define DRAKE_ENTRY 17848
26
27
#define QUEST_ENTRY_DIVERSION 10283
28
#define LODGE_QUEST_TRIGGER 20155
29
30
class
instance_old_hillsbrad
:
public
InstanceMapScript
31
{
32
public
:
33
instance_old_hillsbrad
() :
InstanceMapScript
(
"instance_old_hillsbrad"
, 560) { }
34
35
InstanceScript
*
GetInstanceScript
(
InstanceMap
* map)
const
OVERRIDE
36
{
37
return
new
instance_old_hillsbrad_InstanceMapScript
(map);
38
}
39
40
struct
instance_old_hillsbrad_InstanceMapScript
:
public
InstanceScript
41
{
42
instance_old_hillsbrad_InstanceMapScript
(
Map
* map) :
InstanceScript
(map) { }
43
44
uint32
m_auiEncounter
[
MAX_ENCOUNTER
];
45
uint32
mBarrelCount
;
46
uint32
mThrallEventCount
;
47
48
uint64
ThrallGUID
;
49
uint64
TarethaGUID
;
50
uint64
EpochGUID
;
51
52
void
Initialize
()
OVERRIDE
53
{
54
memset(&
m_auiEncounter
, 0,
sizeof
(
m_auiEncounter
));
55
56
mBarrelCount
= 0;
57
mThrallEventCount
= 0;
58
ThrallGUID
= 0;
59
TarethaGUID
= 0;
60
EpochGUID
= 0;
61
}
62
63
Player
*
GetPlayerInMap
()
64
{
65
Map::PlayerList
const
& players =
instance
->GetPlayers();
66
67
if
(!players.
isEmpty
())
68
{
69
for
(
Map::PlayerList::const_iterator
itr = players.
begin
(); itr != players.
end
(); ++itr)
70
{
71
if
(
Player
* player = itr->GetSource())
72
return
player;
73
}
74
}
75
76
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: GetPlayerInMap, but PlayerList is empty!"
);
77
return
NULL;
78
}
79
80
void
UpdateQuestCredit
()
81
{
82
Map::PlayerList
const
& players =
instance
->GetPlayers();
83
84
if
(!players.
isEmpty
())
85
{
86
for
(
Map::PlayerList::const_iterator
itr = players.
begin
(); itr != players.
end
(); ++itr)
87
{
88
if
(
Player
* player = itr->GetSource())
89
player->KilledMonsterCredit(
LODGE_QUEST_TRIGGER
, 0);
90
}
91
}
92
}
93
94
void
OnCreatureCreate
(
Creature
* creature)
OVERRIDE
95
{
96
switch
(creature->GetEntry())
97
{
98
case
THRALL_ENTRY
:
99
ThrallGUID
= creature->GetGUID();
100
break
;
101
case
TARETHA_ENTRY
:
102
TarethaGUID
= creature->GetGUID();
103
break
;
104
case
EPOCH_ENTRY
:
105
EpochGUID
= creature->GetGUID();
106
break
;
107
}
108
}
109
110
void
SetData
(
uint32
type,
uint32
data)
OVERRIDE
111
{
112
Player
* player =
GetPlayerInMap
();
113
114
if
(!player)
115
{
116
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any player."
, type, data);
117
return
;
118
}
119
120
switch
(type)
121
{
122
case
TYPE_BARREL_DIVERSION
:
123
{
124
if
(data ==
IN_PROGRESS
)
125
{
126
if
(
mBarrelCount
>= 5)
127
return
;
128
129
++
mBarrelCount
;
130
DoUpdateWorldState
(
WORLD_STATE_OH
,
mBarrelCount
);
131
132
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u"
,
mBarrelCount
);
133
134
m_auiEncounter
[0] =
IN_PROGRESS
;
135
136
if
(
mBarrelCount
== 5)
137
{
138
UpdateQuestCredit
();
139
player->
SummonCreature
(
DRAKE_ENTRY
, 2128.43f, 71.01f, 64.42f, 1.74f,
TempSummonType::TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
, 1800000);
140
m_auiEncounter
[0] =
DONE
;
141
}
142
}
143
break
;
144
}
145
case
TYPE_THRALL_EVENT
:
146
{
147
if
(data ==
FAIL
)
148
{
149
if
(
mThrallEventCount
<= 20)
150
{
151
++
mThrallEventCount
;
152
m_auiEncounter
[1] =
NOT_STARTED
;
153
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events."
,
mThrallEventCount
);
154
m_auiEncounter
[2] =
NOT_STARTED
;
155
m_auiEncounter
[3] =
NOT_STARTED
;
156
m_auiEncounter
[4] =
NOT_STARTED
;
157
m_auiEncounter
[5] =
NOT_STARTED
;
158
}
159
else
if
(
mThrallEventCount
> 20)
160
{
161
m_auiEncounter
[1] = data;
162
m_auiEncounter
[2] = data;
163
m_auiEncounter
[3] = data;
164
m_auiEncounter
[4] = data;
165
m_auiEncounter
[5] = data;
166
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events."
,
mThrallEventCount
);
167
}
168
}
169
else
170
m_auiEncounter
[1] = data;
171
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: Thrall escort event adjusted to data %u."
, data);
172
break
;
173
}
174
case
TYPE_THRALL_PART1
:
175
m_auiEncounter
[2] = data;
176
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: Thrall event part I adjusted to data %u."
, data);
177
break
;
178
case
TYPE_THRALL_PART2
:
179
m_auiEncounter
[3] = data;
180
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: Thrall event part II adjusted to data %u."
, data);
181
break
;
182
case
TYPE_THRALL_PART3
:
183
m_auiEncounter
[4] = data;
184
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: Thrall event part III adjusted to data %u."
, data);
185
break
;
186
case
TYPE_THRALL_PART4
:
187
m_auiEncounter
[5] = data;
188
SF_LOG_DEBUG
(
"scripts"
,
"Instance Old Hillsbrad: Thrall event part IV adjusted to data %u."
, data);
189
break
;
190
}
191
}
192
193
uint32
GetData
(
uint32
data)
const
OVERRIDE
194
{
195
switch
(data)
196
{
197
case
TYPE_BARREL_DIVERSION
:
198
return
m_auiEncounter
[0];
199
case
TYPE_THRALL_EVENT
:
200
return
m_auiEncounter
[1];
201
case
TYPE_THRALL_PART1
:
202
return
m_auiEncounter
[2];
203
case
TYPE_THRALL_PART2
:
204
return
m_auiEncounter
[3];
205
case
TYPE_THRALL_PART3
:
206
return
m_auiEncounter
[4];
207
case
TYPE_THRALL_PART4
:
208
return
m_auiEncounter
[5];
209
}
210
return
0;
211
}
212
213
uint64
GetData64
(
uint32
data)
const
OVERRIDE
214
{
215
switch
(data)
216
{
217
case
DATA_THRALL
:
218
return
ThrallGUID
;
219
case
DATA_TARETHA
:
220
return
TarethaGUID
;
221
case
DATA_EPOCH
:
222
return
EpochGUID
;
223
}
224
return
0;
225
}
226
};
227
};
228
229
void
AddSC_instance_old_hillsbrad
()
230
{
231
new
instance_old_hillsbrad
();
232
}
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
InstanceScript.h
IN_PROGRESS
@ IN_PROGRESS
Definition
InstanceScript.h:47
FAIL
@ FAIL
Definition
InstanceScript.h:48
DONE
@ DONE
Definition
InstanceScript.h:49
NOT_STARTED
@ NOT_STARTED
Definition
InstanceScript.h:46
SF_LOG_DEBUG
#define SF_LOG_DEBUG(filterType__,...)
Definition
Log.h:134
TempSummonType::TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
Definition
Object.h:68
Player.h
ScriptMgr.h
ScriptedCreature.h
Creature
Definition
Creature.h:427
InstanceMap
Definition
Map.h:637
InstanceMapScript::InstanceMapScript
InstanceMapScript(const char *name, uint32 mapId)
Definition
ScriptMgr.cpp:1412
InstanceScript
Definition
InstanceScript.h:123
InstanceScript::InstanceScript
InstanceScript(Map *map)
Definition
InstanceScript.h:125
InstanceScript::instance
Map * instance
Definition
InstanceScript.h:129
InstanceScript::DoUpdateWorldState
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue)
Definition
InstanceScript.cpp:284
LinkedListHead::isEmpty
bool isEmpty() const
Definition
LinkedList.h:86
Map
Definition
Map.h:238
Map::PlayerList
MapRefManager PlayerList
Definition
Map.h:406
MapRefManager::end
iterator end()
Definition
MapRefManager.h:25
MapRefManager::begin
iterator begin()
Definition
MapRefManager.h:24
MapRefManager::const_iterator
LinkedListHead::Iterator< MapReference const > const_iterator
Definition
MapRefManager.h:17
Player
Definition
Player.h:1289
WorldObject::SummonCreature
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition
Object.cpp:2703
instance_old_hillsbrad
Definition
instance_old_hillsbrad.cpp:31
instance_old_hillsbrad::GetInstanceScript
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
Definition
instance_old_hillsbrad.cpp:35
instance_old_hillsbrad::instance_old_hillsbrad
instance_old_hillsbrad()
Definition
instance_old_hillsbrad.cpp:33
DATA_EPOCH
@ DATA_EPOCH
Definition
culling_of_stratholme.h:25
DATA_THRALL
@ DATA_THRALL
Definition
hyjal.h:26
AddSC_instance_old_hillsbrad
void AddSC_instance_old_hillsbrad()
Definition
instance_old_hillsbrad.cpp:229
THRALL_ENTRY
#define THRALL_ENTRY
Definition
instance_old_hillsbrad.cpp:21
LODGE_QUEST_TRIGGER
#define LODGE_QUEST_TRIGGER
Definition
instance_old_hillsbrad.cpp:28
EPOCH_ENTRY
#define EPOCH_ENTRY
Definition
instance_old_hillsbrad.cpp:23
TARETHA_ENTRY
#define TARETHA_ENTRY
Definition
instance_old_hillsbrad.cpp:22
DRAKE_ENTRY
#define DRAKE_ENTRY
Definition
instance_old_hillsbrad.cpp:25
MAX_ENCOUNTER
#define MAX_ENCOUNTER
Definition
instance_old_hillsbrad.cpp:19
old_hillsbrad.h
WORLD_STATE_OH
@ WORLD_STATE_OH
Definition
old_hillsbrad.h:26
TYPE_THRALL_PART1
@ TYPE_THRALL_PART1
Definition
old_hillsbrad.h:13
TYPE_THRALL_PART4
@ TYPE_THRALL_PART4
Definition
old_hillsbrad.h:16
TYPE_THRALL_EVENT
@ TYPE_THRALL_EVENT
Definition
old_hillsbrad.h:12
DATA_TARETHA
@ DATA_TARETHA
Definition
old_hillsbrad.h:19
TYPE_THRALL_PART3
@ TYPE_THRALL_PART3
Definition
old_hillsbrad.h:15
TYPE_THRALL_PART2
@ TYPE_THRALL_PART2
Definition
old_hillsbrad.h:14
TYPE_BARREL_DIVERSION
@ TYPE_BARREL_DIVERSION
Definition
old_hillsbrad.h:11
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript
Definition
instance_old_hillsbrad.cpp:41
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::ThrallGUID
uint64 ThrallGUID
Definition
instance_old_hillsbrad.cpp:48
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::m_auiEncounter
uint32 m_auiEncounter[MAX_ENCOUNTER]
Definition
instance_old_hillsbrad.cpp:44
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::EpochGUID
uint64 EpochGUID
Definition
instance_old_hillsbrad.cpp:50
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::UpdateQuestCredit
void UpdateQuestCredit()
Definition
instance_old_hillsbrad.cpp:80
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::instance_old_hillsbrad_InstanceMapScript
instance_old_hillsbrad_InstanceMapScript(Map *map)
Definition
instance_old_hillsbrad.cpp:42
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::GetData64
uint64 GetData64(uint32 data) const OVERRIDE
Definition
instance_old_hillsbrad.cpp:213
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::SetData
void SetData(uint32 type, uint32 data) OVERRIDE
Definition
instance_old_hillsbrad.cpp:110
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::GetData
uint32 GetData(uint32 data) const OVERRIDE
Definition
instance_old_hillsbrad.cpp:193
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::mBarrelCount
uint32 mBarrelCount
Definition
instance_old_hillsbrad.cpp:45
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::OnCreatureCreate
void OnCreatureCreate(Creature *creature) OVERRIDE
Definition
instance_old_hillsbrad.cpp:94
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::TarethaGUID
uint64 TarethaGUID
Definition
instance_old_hillsbrad.cpp:49
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::mThrallEventCount
uint32 mThrallEventCount
Definition
instance_old_hillsbrad.cpp:46
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::GetPlayerInMap
Player * GetPlayerInMap()
Definition
instance_old_hillsbrad.cpp:63
instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::Initialize
void Initialize() OVERRIDE
Definition
instance_old_hillsbrad.cpp:52
src
server
scripts
Kalimdor
CavernsOfTime
EscapeFromDurnholdeKeep
instance_old_hillsbrad.cpp
Generated on
for Project SkyFire Core by
1.17.0