Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_sunwell_plateau.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_Sunwell_Plateau
8SD%Complete: 25
9SDComment: VERIFY SCRIPT
10SDCategory: Sunwell_Plateau
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "InstanceScript.h"
15#include "sunwell_plateau.h"
16#include "Player.h"
17
18#define MAX_ENCOUNTER 6
19
20/* Sunwell Plateau:
210 - Kalecgos and Sathrovarr
221 - Brutallus
232 - Felmyst
243 - Eredar Twins (Alythess and Sacrolash)
254 - M'uru
265 - Kil'Jaeden
27*/
28
30{
31public:
32 instance_sunwell_plateau() : InstanceMapScript("instance_sunwell_plateau", 580) { }
33
38
40 {
42
44
60
62 uint64 ForceField; // Kalecgos Encounter
64 uint64 FireBarrier; // Felmysts Encounter
65 uint64 MurusGate[2]; // Murus Encounter
66
67 /*** Misc ***/
69 std::vector<uint64> SpectralRealmList;
70
72 {
73 memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
74
75 /*** Creatures ***/
78 Sathrovarr = 0;
79 Brutallus = 0;
80 Madrigosa = 0;
81 Felmyst = 0;
82 Alythess = 0;
83 Sacrolash = 0;
84 Muru = 0;
85 KilJaeden = 0;
87 Anveena = 0;
88 KalecgosKJ = 0;
90
91 /*** GameObjects ***/
92 ForceField = 0;
93 FireBarrier = 0;
94 MurusGate[0] = 0;
95 MurusGate[1] = 0;
96 KalecgosWall[0] = 0;
97 KalecgosWall[1] = 0;
98
99 /*** Misc ***/
100 SpectralRealmTimer = 5000;
101 }
102
104 {
105 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
106 if (m_auiEncounter[i] == IN_PROGRESS)
107 return true;
108
109 return false;
110 }
111
112 Player const* GetPlayerInMap() const
113 {
114 Map::PlayerList const& players = instance->GetPlayers();
115
116 if (!players.isEmpty())
117 {
118 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
119 {
120 Player* player = itr->GetSource();
121 if (player && !player->HasAura(45839, 0))
122 return player;
123 }
124 }
125 else
126 SF_LOG_DEBUG("scripts", "Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!");
127
128 return NULL;
129 }
130
132 {
133 switch (creature->GetEntry())
134 {
135 case 24850: Kalecgos_Dragon = creature->GetGUID(); break;
136 case 24891: Kalecgos_Human = creature->GetGUID(); break;
137 case 24892: Sathrovarr = creature->GetGUID(); break;
138 case 24882: Brutallus = creature->GetGUID(); break;
139 case 24895: Madrigosa = creature->GetGUID(); break;
140 case 25038: Felmyst = creature->GetGUID(); break;
141 case 25166: Alythess = creature->GetGUID(); break;
142 case 25165: Sacrolash = creature->GetGUID(); break;
143 case 25741: Muru = creature->GetGUID(); break;
144 case 25315: KilJaeden = creature->GetGUID(); break;
145 case 25608: KilJaedenController = creature->GetGUID(); break;
146 case 26046: Anveena = creature->GetGUID(); break;
147 case 25319: KalecgosKJ = creature->GetGUID(); break;
148 }
149 }
150
152 {
153 switch (go->GetEntry())
154 {
155 case 188421: ForceField = go->GetGUID(); break;
156 case 188523: KalecgosWall[0] = go->GetGUID(); break;
157 case 188524: KalecgosWall[0] = go->GetGUID(); break;
158 case 188075:
159 if (m_auiEncounter[2] == DONE)
160 HandleGameObject(0, true, go);
161 FireBarrier = go->GetGUID();
162 break;
163 case 187990: MurusGate[0] = go->GetGUID(); break;
164 case 188118:
165 if (m_auiEncounter[4] == DONE)
166 HandleGameObject(0, true, go);
167 MurusGate[1]= go->GetGUID();
168 break;
169 }
170 }
171
173 {
174 switch (id)
175 {
176 case DATA_KALECGOS_EVENT: return m_auiEncounter[0];
177 case DATA_BRUTALLUS_EVENT: return m_auiEncounter[1];
178 case DATA_FELMYST_EVENT: return m_auiEncounter[2];
180 case DATA_MURU_EVENT: return m_auiEncounter[4];
181 case DATA_KILJAEDEN_EVENT: return m_auiEncounter[5];
182 }
183 return 0;
184 }
185
187 {
188 switch (id)
189 {
192 case DATA_SATHROVARR: return Sathrovarr;
193 case DATA_GO_FORCEFIELD: return ForceField;
194 case DATA_BRUTALLUS: return Brutallus;
195 case DATA_MADRIGOSA: return Madrigosa;
196 case DATA_FELMYST: return Felmyst;
197 case DATA_ALYTHESS: return Alythess;
198 case DATA_SACROLASH: return Sacrolash;
199 case DATA_MURU: return Muru;
200 case DATA_KILJAEDEN: return KilJaeden;
202 case DATA_ANVEENA: return Anveena;
203 case DATA_KALECGOS_KJ: return KalecgosKJ;
204 case DATA_PLAYER_GUID:
205 Player const* target = GetPlayerInMap();
206 return target ? target->GetGUID() : 0;
207 }
208 return 0;
209 }
210
212 {
213 switch (id)
214 {
216 {
217 if (data == NOT_STARTED || data == DONE)
218 {
222 }
223 else if (data == IN_PROGRESS)
224 {
228 }
229 m_auiEncounter[0] = data;
230 }
231 break;
232 case DATA_BRUTALLUS_EVENT: m_auiEncounter[1] = data; break;
234 if (data == DONE)
236 m_auiEncounter[2] = data; break;
237 case DATA_EREDAR_TWINS_EVENT: m_auiEncounter[3] = data; break;
238 case DATA_MURU_EVENT:
239 switch (data)
240 {
241 case DONE:
242 HandleGameObject(MurusGate[0], true);
243 HandleGameObject(MurusGate[1], true);
244 break;
245 case IN_PROGRESS:
246 HandleGameObject(MurusGate[0], false);
247 HandleGameObject(MurusGate[1], false);
248 break;
249 case NOT_STARTED:
250 HandleGameObject(MurusGate[0], true);
251 HandleGameObject(MurusGate[1], false);
252 break;
253 }
254 m_auiEncounter[4] = data; break;
255 case DATA_KILJAEDEN_EVENT: m_auiEncounter[5] = data; break;
256 }
257
258 if (data == DONE)
259 SaveToDB();
260 }
261
262 std::string GetSaveData() OVERRIDE
263 {
265 std::ostringstream stream;
266 stream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3] << ' '
267 << m_auiEncounter[4] << ' ' << m_auiEncounter[5];
268
270 return stream.str();
271 }
272
273 void Load(char const* in) OVERRIDE
274 {
275 if (!in)
276 {
278 return;
279 }
280
282 std::istringstream stream(in);
283 stream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
284 >> m_auiEncounter[4] >> m_auiEncounter[5];
285 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
286 if (m_auiEncounter[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead.
289 }
290 };
291};
292
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
#define OUT_LOAD_INST_DATA_FAIL
@ IN_PROGRESS
@ 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
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
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
uint64 GetGUID() const
Definition Object.h:119
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
void AddSC_instance_sunwell_plateau()
#define MAX_ENCOUNTER
@ DATA_KILJAEDEN_CONTROLLER
@ DATA_BRUTALLUS
@ DATA_MURU
@ DATA_SATHROVARR
@ DATA_KILJAEDEN
@ DATA_FELMYST
@ DATA_ALYTHESS
@ DATA_ANVEENA
@ DATA_KALECGOS_HUMAN
@ DATA_GO_FORCEFIELD
@ DATA_SACROLASH
@ DATA_KALECGOS_DRAGON
@ DATA_PLAYER_GUID
@ DATA_KALECGOS_KJ
@ DATA_MADRIGOSA
@ DATA_MURU_EVENT
@ DATA_FELMYST_EVENT
@ DATA_KALECGOS_EVENT
@ DATA_EREDAR_TWINS_EVENT
@ DATA_BRUTALLUS_EVENT
@ DATA_KILJAEDEN_EVENT