Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_hyjal.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_Mount_Hyjal
8SD%Complete: 100
9SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Hyjal Scripts
10SDCategory: Caverns of Time, Mount Hyjal
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "InstanceScript.h"
15#include "ScriptedCreature.h"
16#include "hyjal_trash.h"
17#include "Player.h"
18#include "WorldPacket.h"
19#include "Opcodes.h"
20#include "WorldSession.h"
21
22/* Battle of Mount Hyjal encounters:
230 - Rage Winterchill event
241 - Anetheron event
252 - Kaz'rogal event
263 - Azgalor event
274 - Archimonde event
28*/
29
30#define YELL_EFFORTS "All of your efforts have been in vain, for the draining of the World Tree has already begun. Soon the heart of your world will beat no more."
31#define YELL_EFFORTS_NAME "Archimonde"
32
34{
35public:
36 instance_hyjal() : InstanceMapScript("instance_hyjal", 534) { }
37
42
44 {
46
48 {
49 memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
50
51 m_uiAncientGemGUID.clear();
52
54 Anetheron = 0;
55 Kazrogal = 0;
56 Azgalor = 0;
57 Archimonde = 0;
59 Thrall = 0;
61 HordeGate = 0;
62 ElfGate = 0;
63 RaidDamage = 0;
64 Trash = 0;
65 hordeRetreat = 0;
67
68 ArchiYell = false;
69 }
70
72 {
73 for (uint8 i = 0; i < EncounterCount; ++i)
75 return true;
76
77 return false;
78 }
79
81 {
82 switch (go->GetEntry())
83 {
85 HordeGate = go->GetGUID();
87 HandleGameObject(0, true, go);
88 else
89 HandleGameObject(0, false, go);
90 break;
92 ElfGate = go->GetGUID();
93 if (hordeRetreat)
94 HandleGameObject(0, true, go);
95 else
96 HandleGameObject(0, false, go);
97 break;
98 case GO_ANCIENT_GEM:
99 m_uiAncientGemGUID.push_back(go->GetGUID());
100 break;
101 }
102 }
103
105 {
106 switch (creature->GetEntry())
107 {
108 case RAGE_WINTERCHILL: RageWinterchill = creature->GetGUID(); break;
109 case ANETHERON: Anetheron = creature->GetGUID(); break;
110 case KAZROGAL: Kazrogal = creature->GetGUID(); break;
111 case AZGALOR: Azgalor = creature->GetGUID(); break;
112 case ARCHIMONDE: Archimonde = creature->GetGUID(); break;
113 case JAINA: JainaProudmoore = creature->GetGUID(); break;
114 case THRALL: Thrall = creature->GetGUID(); break;
115 case TYRANDE: TyrandeWhisperwind = creature->GetGUID(); break;
116 }
117 }
118
119 uint64 GetData64(uint32 identifier) const OVERRIDE
120 {
121 switch (identifier)
122 {
124 case DATA_ANETHERON: return Anetheron;
125 case DATA_KAZROGAL: return Kazrogal;
126 case DATA_AZGALOR: return Azgalor;
127 case DATA_ARCHIMONDE: return Archimonde;
129 case DATA_THRALL: return Thrall;
131 }
132
133 return 0;
134 }
135
136 void SetData(uint32 type, uint32 data) OVERRIDE
137 {
138 switch (type)
139 {
141 m_auiEncounter[0] = data;
142 break;
144 m_auiEncounter[1] = data;
145 break;
147 m_auiEncounter[2] = data;
148 break;
150 {
151 m_auiEncounter[3] = data;
152 if (data == DONE)
153 {
154 if (ArchiYell)
155 break;
156
157 ArchiYell = true;
158
159 Creature* creature = instance->GetCreature(Azgalor);
160 if (creature)
161 {
162 Creature* unit = creature->SummonCreature(NPC_WORLD_TRIGGER_TINY, creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), 0, TempSummonType::TEMPSUMMON_TIMED_DESPAWN, 10000);
163
164 Map* map = creature->GetMap();
165 if (map->IsRaid() && unit)
166 {
167 unit->SetVisible(false);
168 Map::PlayerList const &PlayerList = map->GetPlayers();
169 if (PlayerList.isEmpty())
170 return;
171
172 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
173 {
174 if (i->GetSource())
175 {
176 WorldPacket packet(SMSG_MESSAGECHAT, 200);
177 unit->MonsterYell(YELL_EFFORTS, Language::LANG_UNIVERSAL, i->GetSource());
178 i->GetSource()->GetSession()->SendPacket(&packet);
179
180 ObjectGuid guid = unit->GetGUID();
181
182 WorldPacket data2(SMSG_PLAY_SOUND, 4 + 9);
183 data2.WriteBit(guid[2]);
184 data2.WriteBit(guid[3]);
185 data2.WriteBit(guid[7]);
186 data2.WriteBit(guid[6]);
187 data2.WriteBit(guid[0]);
188 data2.WriteBit(guid[5]);
189 data2.WriteBit(guid[4]);
190 data2.WriteBit(guid[1]);
191 data2 << uint32(10986);
192 data2.WriteByteSeq(guid[3]);
193 data2.WriteByteSeq(guid[2]);
194 data2.WriteByteSeq(guid[4]);
195 data2.WriteByteSeq(guid[7]);
196 data2.WriteByteSeq(guid[5]);
197 data2.WriteByteSeq(guid[0]);
198 data2.WriteByteSeq(guid[6]);
199 data2.WriteByteSeq(guid[1]);
200 i->GetSource()->GetSession()->SendPacket(&data2);
201 }
202 }
203 }
204 }
205 }
206 }
207 break;
209 m_auiEncounter[4] = data;
210 break;
212 Trash = 0;
213 break;
214 case DATA_TRASH:
215 if (data)
216 Trash = data;
217 else
218 Trash--;
220 break;
221 case TYPE_RETREAT:
222 if (data == SPECIAL)
223 {
224 if (!m_uiAncientGemGUID.empty())
225 {
226 for (std::list<uint64>::const_iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
227 {
228 //don't know how long it expected
230 }
231 }
232 }
233 break;
235 allianceRetreat = data;
237 SaveToDB();
238 break;
240 hordeRetreat = data;
242 SaveToDB();
243 break;
244 case DATA_RAIDDAMAGE:
245 RaidDamage += data;
248 break;
250 RaidDamage = 0;
251 break;
252 }
253
254 SF_LOG_DEBUG("scripts", "Instance Hyjal: Instance data updated for event %u (Data=%u)", type, data);
255
256 if (data == DONE)
257 {
259
260 std::ostringstream saveStream;
261 saveStream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' '
262 << m_auiEncounter[3] << ' ' << m_auiEncounter[4]
263 << ' ' << allianceRetreat << ' ' << hordeRetreat
264 << ' ' << RaidDamage;
265
266 str_data = saveStream.str();
267
268 SaveToDB();
270 }
271 }
272
274 {
275 switch (type)
276 {
278 case DATA_ANETHERONEVENT: return m_auiEncounter[1];
279 case DATA_KAZROGALEVENT: return m_auiEncounter[2];
280 case DATA_AZGALOREVENT: return m_auiEncounter[3];
281 case DATA_ARCHIMONDEEVENT: return m_auiEncounter[4];
282 case DATA_TRASH: return Trash;
284 case DATA_HORDE_RETREAT: return hordeRetreat;
285 case DATA_RAIDDAMAGE: return RaidDamage;
286 }
287 return 0;
288 }
289
290 std::string GetSaveData() OVERRIDE
291 {
292 return str_data;
293 }
294
295 void Load(const char* in) OVERRIDE
296 {
297 if (!in)
298 {
300 return;
301 }
302
304 std::istringstream loadStream(in);
306 for (uint8 i = 0; i < EncounterCount; ++i)
307 if (m_auiEncounter[i] == IN_PROGRESS) // Do not load an encounter as IN_PROGRESS - reset it instead.
310 }
311
312 protected:
314 std::string str_data;
315 std::list<uint64> m_uiAncientGemGUID;
331 };
332};
333
335{
336 new instance_hyjal();
337}
@ DAY
Definition Common.h:121
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
@ SPECIAL
@ 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
uint32 const EncounterCount
bool WriteBit(uint32 bit)
Definition ByteBuffer.h:164
void WriteByteSeq(uint8 b)
Definition ByteBuffer.h:227
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void HandleGameObject(uint64 guid, bool open, GameObject *go=NULL)
void DoRespawnGameObject(uint64 guid, uint32 timeToDespawn=MINUTE)
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue)
bool isEmpty() const
Definition LinkedList.h:86
Definition Map.h:238
MapRefManager PlayerList
Definition Map.h:406
bool IsRaid() const
Definition Map.h:372
PlayerList const & GetPlayers() const
Definition Map.h:407
iterator end()
iterator begin()
LinkedListHead::Iterator< MapReference const > const_iterator
uint64 GetGUID() const
Definition Object.h:119
void SetVisible(bool x)
Definition Unit.cpp:4163
Map * GetMap() const
Definition Object.h:740
void MonsterYell(const char *text, Language language, WorldObject const *target)
Definition Object.cpp:2411
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition Object.cpp:2703
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
@ SMSG_MESSAGECHAT
Definition Opcodes.h:779
@ SMSG_PLAY_SOUND
Definition Opcodes.h:883
@ WORLD_STATE_ENEMYCOUNT
Definition hyjal.h:41
@ KAZROGAL
Definition hyjal.h:64
@ AZGALOR
Definition hyjal.h:65
@ TYRANDE
Definition hyjal.h:59
@ ANETHERON
Definition hyjal.h:63
@ ARCHIMONDE
Definition hyjal.h:66
@ JAINA
Definition hyjal.h:57
@ RAGE_WINTERCHILL
Definition hyjal.h:62
@ THRALL
Definition hyjal.h:58
@ NPC_WORLD_TRIGGER_TINY
Definition hyjal.h:67
@ GO_ANCIENT_GEM
Definition hyjal.h:74
@ GO_HORDE_ENCAMPMENT_PORTAL
Definition hyjal.h:72
@ GO_NIGHT_ELF_VILLAGE_PORTAL
Definition hyjal.h:73
@ DATA_RAGEWINTERCHILL
Definition hyjal.h:24
@ TYPE_RETREAT
Definition hyjal.h:34
@ DATA_RAGEWINTERCHILLEVENT
Definition hyjal.h:25
@ DATA_TRASH
Definition hyjal.h:28
@ DATA_TYRANDEWHISPERWIND
Definition hyjal.h:27
@ DATA_RAIDDAMAGE
Definition hyjal.h:32
@ DATA_RESET_RAIDDAMAGE
Definition hyjal.h:33
@ DATA_THRALL
Definition hyjal.h:26
@ DATA_KAZROGAL
Definition hyjal.h:22
@ DATA_KAZROGALEVENT
Definition hyjal.h:23
@ DATA_ARCHIMONDEEVENT
Definition hyjal.h:18
@ DATA_AZGALOREVENT
Definition hyjal.h:20
@ DATA_ANETHERONEVENT
Definition hyjal.h:16
@ DATA_AZGALOR
Definition hyjal.h:19
@ DATA_JAINAPROUDMOORE
Definition hyjal.h:21
@ DATA_ANETHERON
Definition hyjal.h:15
@ DATA_ARCHIMONDE
Definition hyjal.h:17
@ DATA_ALLIANCE_RETREAT
Definition hyjal.h:30
@ DATA_HORDE_RETREAT
Definition hyjal.h:31
@ DATA_RESET_TRASH_COUNT
Definition hyjal.h:29
#define MINRAIDDAMAGE
Definition hyjal_trash.h:12
void AddSC_instance_mount_hyjal()
#define YELL_EFFORTS
float GetPositionZ() const
Definition Object.h:330
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
void SetData(uint32 type, uint32 data) OVERRIDE
uint64 GetData64(uint32 identifier) const OVERRIDE