Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_stratholme.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
7SDName: instance_stratholme
8SD%Complete: 50
9SDComment: In progress. Undead side 75% implemented. Save/load not implemented.
10SDCategory: Stratholme
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "InstanceScript.h"
16#include "stratholme.h"
17#include "Player.h"
18
19enum Misc
20{
22};
23
29
31{
32 public:
33 instance_stratholme() : InstanceMapScript("instance_stratholme", 329) { }
34
36 {
40
42
44
55
58 std::set<uint64> crystalsGUID;
59 std::set<uint64> abomnationGUID;
61
63 {
64 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
66
67 for (uint8 i = 0; i < 5; ++i)
68 IsSilverHandDead[i] = false;
69
72 ziggurat1GUID = 0;
73 ziggurat2GUID = 0;
74 ziggurat3GUID = 0;
75 ziggurat4GUID = 0;
76 ziggurat5GUID = 0;
79 portElderGUID = 0;
80
81 baronGUID = 0;
83 crystalsGUID.clear();
84 abomnationGUID.clear();
85 }
86
88 {
89 //change to DONE when crystals implemented
91 {
94 return true;
95 }
96
97 SF_LOG_DEBUG("scripts", "Instance Stratholme: Cannot open slaugther square yet.");
98 return false;
99 }
100
101 //if withRestoreTime true, then newState will be ignored and GO should be restored to original state after 10 seconds
102 void UpdateGoState(uint64 goGuid, uint32 newState, bool withRestoreTime)
103 {
104 if (!goGuid)
105 return;
106
107 if (GameObject* go = instance->GetGameObject(goGuid))
108 {
109 if (withRestoreTime)
110 go->UseDoorOrButton(10);
111 else
112 go->SetGoState((GOState)newState);
113 }
114 }
115
117 {
118 switch (creature->GetEntry())
119 {
120 case NPC_BARON:
121 baronGUID = creature->GetGUID();
122 break;
124 ysidaTriggerGUID = creature->GetGUID();
125 break;
126 case NPC_CRYSTAL:
127 crystalsGUID.insert(creature->GetGUID());
128 break;
129 case NPC_ABOM_BILE:
130 case NPC_ABOM_VENOM:
131 abomnationGUID.insert(creature->GetGUID());
132 break;
133 }
134 }
135
137 {
138 switch (creature->GetEntry())
139 {
140 case NPC_CRYSTAL:
141 crystalsGUID.erase(creature->GetGUID());
142 break;
143 case NPC_ABOM_BILE:
144 case NPC_ABOM_VENOM:
145 abomnationGUID.erase(creature->GetGUID());
146 break;
147 }
148 }
149
151 {
152 switch (go->GetEntry())
153 {
155 serviceEntranceGUID = go->GetGUID();
156 break;
158 //weird, but unless flag is set, client will not respond as expected. DB bug?
160 gauntletGate1GUID = go->GetGUID();
161 break;
162 case GO_ZIGGURAT1:
163 ziggurat1GUID = go->GetGUID();
165 HandleGameObject(0, true, go);
166 break;
167 case GO_ZIGGURAT2:
168 ziggurat2GUID = go->GetGUID();
170 HandleGameObject(0, true, go);
171 break;
172 case GO_ZIGGURAT3:
173 ziggurat3GUID = go->GetGUID();
175 HandleGameObject(0, true, go);
176 break;
177 case GO_ZIGGURAT4:
178 ziggurat4GUID = go->GetGUID();
180 HandleGameObject(0, true, go);
181 break;
182 case GO_ZIGGURAT5:
183 ziggurat5GUID = go->GetGUID();
185 HandleGameObject(0, true, go);
186 break;
187 case GO_PORT_GAUNTLET:
188 portGauntletGUID = go->GetGUID();
190 HandleGameObject(0, true, go);
191 break;
193 portSlaugtherGUID = go->GetGUID();
195 HandleGameObject(0, true, go);
196 break;
197 case GO_PORT_ELDERS:
198 portElderGUID = go->GetGUID();
199 break;
200 }
201 }
202
203 void SetData(uint32 type, uint32 data) OVERRIDE
204 {
205 switch (type)
206 {
207 case TYPE_BARON_RUN:
208 switch (data)
209 {
210 case IN_PROGRESS:
212 break;
213 EncounterState[0] = data;
214 events.ScheduleEvent(EVENT_BARON_RUN, 2700000);
215 SF_LOG_DEBUG("scripts", "Instance Stratholme: Baron run in progress.");
216 break;
217 case FAIL:
219 EncounterState[0] = data;
220 break;
221 case DONE:
222 EncounterState[0] = data;
223 if (Creature* ysidaTrigger = instance->GetCreature(ysidaTriggerGUID))
224 {
225 Position ysidaPos;
226 ysidaTrigger->GetPosition(&ysidaPos);
227 ysidaTrigger->SummonCreature(NPC_YSIDA, ysidaPos, TempSummonType::TEMPSUMMON_TIMED_DESPAWN, 1800000);
228 }
229 events.CancelEvent(EVENT_BARON_RUN);
230 break;
231 }
232 break;
233 case TYPE_BARONESS:
234 EncounterState[1] = data;
235 if (data == IN_PROGRESS)
236 {
238 //change to DONE when crystals implemented
240 }
241 break;
242 case TYPE_NERUB:
243 EncounterState[2] = data;
244 if (data == IN_PROGRESS)
245 {
247 //change to DONE when crystals implemented
249 }
250 break;
251 case TYPE_PALLID:
252 EncounterState[3] = data;
253 if (data == IN_PROGRESS)
254 {
256 //change to DONE when crystals implemented
258 }
259 break;
260 case TYPE_RAMSTEIN:
261 if (data == IN_PROGRESS)
262 {
264
265 uint32 count = abomnationGUID.size();
266 for (std::set<uint64>::const_iterator i = abomnationGUID.begin(); i != abomnationGUID.end(); ++i)
267 {
268 if (Creature* pAbom = instance->GetCreature(*i))
269 if (!pAbom->IsAlive())
270 --count;
271 }
272
273 if (!count)
274 {
275 //a bit itchy, it should close the door after 10 secs, but it doesn't. skipping it for now.
276 //UpdateGoState(ziggurat4GUID, 0, true);
277 if (Creature* pBaron = instance->GetCreature(baronGUID))
278 pBaron->SummonCreature(NPC_RAMSTEIN, 4032.84f, -3390.24f, 119.73f, 4.71f, TempSummonType::TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 1800000);
279 SF_LOG_DEBUG("scripts", "Instance Stratholme: Ramstein spawned.");
280 }
281 else
282 SF_LOG_DEBUG("scripts", "Instance Stratholme: %u Abomnation left to kill.", count);
283 }
284
285 if (data == NOT_STARTED)
287
288 if (data == DONE)
289 {
290 events.ScheduleEvent(EVENT_SLAUGHTER_SQUARE, 60000);
291 SF_LOG_DEBUG("scripts", "Instance Stratholme: Slaugther event will continue in 1 minute.");
292 }
293 EncounterState[4] = data;
294 break;
295 case TYPE_BARON:
296 if (data == IN_PROGRESS)
297 {
301 {
303 Map::PlayerList const& players = instance->GetPlayers();
304 if (!players.isEmpty())
305 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
306 if (Player* player = itr->GetSource())
307 if (player->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE)
308 player->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
309
311 }
312 }
313 if (data == DONE || data == NOT_STARTED)
314 {
317 }
318 if (data == DONE)
320 EncounterState[5] = data;
321 break;
322 case TYPE_SH_AELMAR:
323 IsSilverHandDead[0] = (data) ? true : false;
324 break;
325 case TYPE_SH_CATHELA:
326 IsSilverHandDead[1] = (data) ? true : false;
327 break;
328 case TYPE_SH_GREGOR:
329 IsSilverHandDead[2] = (data) ? true : false;
330 break;
331 case TYPE_SH_NEMAS:
332 IsSilverHandDead[3] = (data) ? true : false;
333 break;
334 case TYPE_SH_VICAR:
335 IsSilverHandDead[4] = (data) ? true : false;
336 break;
337 }
338
339 if (data == DONE)
340 SaveToDB();
341 }
342
343 std::string GetSaveData() OVERRIDE
344 {
346
347 std::ostringstream saveStream;
348 saveStream << EncounterState[0] << ' ' << EncounterState[1] << ' ' << EncounterState[2] << ' '
349 << EncounterState[3] << ' ' << EncounterState[4] << ' ' << EncounterState[5];
350
352 return saveStream.str();
353 }
354
355 void Load(const char* in) OVERRIDE
356 {
357 if (!in)
358 {
360 return;
361 }
362
364
365 std::istringstream loadStream(in);
366 loadStream >> EncounterState[0] >> EncounterState[1] >> EncounterState[2] >> EncounterState[3]
367 >> EncounterState[4] >> EncounterState[5];
368
369 // Do not reset 1, 2 and 3. they are not set to done, yet .
370 if (EncounterState[0] == IN_PROGRESS)
372 if (EncounterState[4] == IN_PROGRESS)
374 if (EncounterState[5] == IN_PROGRESS)
376
378 }
379
381 {
382 switch (type)
383 {
384 case TYPE_SH_QUEST:
386 return 1;
387 return 0;
388 case TYPE_BARON_RUN:
389 return EncounterState[0];
390 case TYPE_BARONESS:
391 return EncounterState[1];
392 case TYPE_NERUB:
393 return EncounterState[2];
394 case TYPE_PALLID:
395 return EncounterState[3];
396 case TYPE_RAMSTEIN:
397 return EncounterState[4];
398 case TYPE_BARON:
399 return EncounterState[5];
400 }
401 return 0;
402 }
403
405 {
406 switch (data)
407 {
408 case DATA_BARON:
409 return baronGUID;
411 return ysidaTriggerGUID;
412 }
413 return 0;
414 }
415
417 {
418 events.Update(diff);
419
420 while (uint32 eventId = events.ExecuteEvent())
421 {
422 switch (eventId)
423 {
424 case EVENT_BARON_RUN:
427 SF_LOG_DEBUG("scripts", "Instance Stratholme: Baron run event reached end. Event has state %u.", GetData(TYPE_BARON_RUN));
428 break;
430 if (Creature* baron = instance->GetCreature(baronGUID))
431 {
432 for (uint8 i = 0; i < 4; ++i)
433 baron->SummonCreature(NPC_BLACK_GUARD, 4032.84f, -3390.24f, 119.73f, 4.71f, TempSummonType::TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 1800000);
434
437 SF_LOG_DEBUG("scripts", "Instance Stratholme: Black guard sentries spawned. Opening gates to baron.");
438 }
439 break;
440 default:
441 break;
442 }
443 }
444 }
445 };
446
451};
452
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
GOState
Definition GameObject.h:575
#define OUT_LOAD_INST_DATA_FAIL
@ IN_PROGRESS
@ FAIL
@ DONE
@ NOT_STARTED
#define OUT_SAVE_INST_DATA_COMPLETE
#define OUT_LOAD_INST_DATA_COMPLETE
#define OUT_SAVE_INST_DATA
#define OUT_LOAD_INST_DATA(a)
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
@ TEMPSUMMON_TIMED_DESPAWN
Definition Object.h:70
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
Definition Object.h:68
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:89
@ GO_FLAG_LOCKED
@ GAMEOBJECT_FIELD_FLAGS
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
void HandleGameObject(uint64 guid, bool open, GameObject *go=NULL)
bool isEmpty() const
Definition LinkedList.h:86
Definition Map.h:238
MapRefManager PlayerList
Definition Map.h:406
iterator end()
iterator begin()
LinkedListHead::Iterator< MapReference const > const_iterator
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
#define MAX_ENCOUNTER
@ MAX_ENCOUNTER
void AddSC_instance_stratholme()
@ EVENT_SLAUGHTER_SQUARE
@ EVENT_BARON_RUN
@ SPELL_BARON_ULTIMATUM
Definition stratholme.h:66
@ QUEST_DEAD_MAN_PLEA
Definition stratholme.h:61
@ NPC_YSIDA
Definition stratholme.h:41
@ NPC_BLACK_GUARD
Definition stratholme.h:40
@ NPC_RAMSTEIN
Definition stratholme.h:37
@ NPC_BARON
Definition stratholme.h:34
@ NPC_CRYSTAL
Definition stratholme.h:33
@ NPC_ABOM_BILE
Definition stratholme.h:38
@ NPC_ABOM_VENOM
Definition stratholme.h:39
@ NPC_YSIDA_TRIGGER
Definition stratholme.h:35
@ GO_GAUNTLET_GATE1
Definition stratholme.h:48
@ GO_ZIGGURAT1
Definition stratholme.h:49
@ GO_ZIGGURAT3
Definition stratholme.h:51
@ GO_ZIGGURAT4
Definition stratholme.h:52
@ GO_ZIGGURAT2
Definition stratholme.h:50
@ GO_ZIGGURAT5
Definition stratholme.h:53
@ GO_PORT_ELDERS
Definition stratholme.h:56
@ GO_SERVICE_ENTRANCE
Definition stratholme.h:47
@ GO_PORT_GAUNTLET
Definition stratholme.h:54
@ GO_PORT_SLAUGTHER
Definition stratholme.h:55
@ TYPE_SH_CATHELA
Definition stratholme.h:24
@ DATA_BARON
Definition stratholme.h:20
@ TYPE_PALLID
Definition stratholme.h:14
@ TYPE_SH_AELMAR
Definition stratholme.h:28
@ DATA_YSIDA_TRIGGER
Definition stratholme.h:21
@ TYPE_BARONESS
Definition stratholme.h:12
@ TYPE_SH_GREGOR
Definition stratholme.h:25
@ TYPE_SH_NEMAS
Definition stratholme.h:26
@ TYPE_NERUB
Definition stratholme.h:13
@ TYPE_BARON
Definition stratholme.h:16
@ TYPE_SH_VICAR
Definition stratholme.h:27
@ TYPE_RAMSTEIN
Definition stratholme.h:15
@ TYPE_BARON_RUN
Definition stratholme.h:11
@ TYPE_SH_QUEST
Definition stratholme.h:23
void GetPosition(float &x, float &y) const
Definition Object.h:333
void UpdateGoState(uint64 goGuid, uint32 newState, bool withRestoreTime)