TrinityCore
instance_hyjal.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19SDName: Instance_Mount_Hyjal
20SD%Complete: 100
21SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Hyjal Scripts
22SDCategory: Caverns of Time, Mount Hyjal
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "Creature.h"
27#include "CreatureAI.h"
28#include "GameObject.h"
29#include "hyjal.h"
30#include "InstanceScript.h"
31#include "Log.h"
32#include "Map.h"
33
34/* Battle of Mount Hyjal encounters:
350 - Rage Winterchill event
361 - Anetheron event
372 - Kaz'rogal event
383 - Azgalor event
394 - Archimonde event
40*/
41
43{
45};
46
48{
58 { 0, 0 } // END
59};
60
62{
63 { DATA_RAGEWINTERCHILL, {{ 618 }} },
64 { DATA_ANETHERON, {{ 619 }} },
65 { DATA_KAZROGAL, {{ 620 }} },
66 { DATA_AZGALOR, {{ 621 }} },
67 { DATA_ARCHIMONDE, {{ 622 }} }
68};
69
71{
72public:
74
76 {
78 }
79
81 {
83 {
88
89 RaidDamage = 0;
90 Trash = 0;
91 hordeRetreat = 0;
93
94 ArchiYell = false;
95 }
96
97 void OnGameObjectCreate(GameObject* go) override
98 {
99 switch (go->GetEntry())
100 {
102 HordeGate = go->GetGUID();
103 if (allianceRetreat)
105 else
107 break;
109 ElfGate = go->GetGUID();
110 if (hordeRetreat)
112 else
114 break;
115 case GO_ANCIENT_GEM:
116 m_uiAncientGemGUID.push_back(go->GetGUID());
117 break;
118 }
119
121 }
122
123 void OnCreatureCreate(Creature* creature) override
124 {
125 switch (creature->GetEntry())
126 {
127 case ARCHIMONDE:
129 {
130 creature->SetVisible(false);
131 creature->SetReactState(REACT_PASSIVE);
132 }
133 break;
134 }
135
137 }
138
139 void SetData(uint32 type, uint32 data) override
140 {
141 switch (type)
142 {
144 Trash = 0;
145 break;
146 case DATA_TRASH:
147 if (data)
148 Trash = data;
149 else
150 Trash--;
152 break;
153 case TYPE_RETREAT:
154 if (data == SPECIAL)
155 {
156 if (!m_uiAncientGemGUID.empty())
157 {
158 for (GuidList::const_iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
159 {
160 //don't know how long it expected
161 DoRespawnGameObject(*itr, 24h);
162 }
163 }
164 }
165 break;
167 allianceRetreat = data;
169 break;
171 hordeRetreat = data;
173 break;
174 case DATA_RAIDDAMAGE:
175 RaidDamage += data;
178 break;
180 RaidDamage = 0;
181 break;
182 }
183
184 TC_LOG_DEBUG("scripts", "Instance Hyjal: Instance data updated for event {} (Data={})", type, data);
185 }
186
187 bool SetBossState(uint32 id, EncounterState state) override
188 {
189 if (!InstanceScript::SetBossState(id, state))
190 return false;
191
192 switch (id)
193 {
194 case DATA_AZGALOR:
195 if (state == DONE)
196 {
197 instance->LoadGrid(5581.49f, -3445.63f);
198 if (Creature* archimonde = GetCreature(DATA_ARCHIMONDE))
199 {
200 archimonde->SetVisible(true);
201 archimonde->SetReactState(REACT_AGGRESSIVE);
202
203 if (!ArchiYell)
204 {
205 ArchiYell = true;
206 archimonde->AI()->Talk(YELL_ARCHIMONDE_INTRO);
207 }
208 }
209 }
210 break;
211 }
212
213 return true;
214 }
215
216 uint32 GetData(uint32 type) const override
217 {
218 switch (type)
219 {
220 case DATA_TRASH: return Trash;
222 case DATA_HORDE_RETREAT: return hordeRetreat;
223 case DATA_RAIDDAMAGE: return RaidDamage;
224 }
225 return 0;
226 }
227
228 void AfterDataLoad() override
229 {
231 allianceRetreat = 1;
233 hordeRetreat = 1;
234 }
235
236 protected:
245 };
246};
247
249{
250 new instance_hyjal();
251}
uint32_t uint32
Definition: Define.h:142
EncounterState
@ DONE
@ SPECIAL
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
#define DataHeader
uint32 const EncounterCount
Yells
void SetReactState(ReactStates st)
Definition: Creature.h:160
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
Creature * GetCreature(uint32 type)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
void LoadDungeonEncounterData(T const &encounters)
void DoUpdateWorldState(int32 worldStateId, int32 value)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn=1min)
virtual void OnGameObjectCreate(GameObject *go) override
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
void LoadGrid(float x, float y)
Definition: Map.cpp:405
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
void SetVisible(bool x)
Definition: Unit.cpp:8351
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ KAZROGAL
Definition: hyjal.h:76
@ AZGALOR
Definition: hyjal.h:77
@ TYRANDE
Definition: hyjal.h:71
@ ANETHERON
Definition: hyjal.h:75
@ ARCHIMONDE
Definition: hyjal.h:78
@ NPC_CHANNEL_TARGET
Definition: hyjal.h:80
@ JAINA
Definition: hyjal.h:69
@ RAGE_WINTERCHILL
Definition: hyjal.h:74
@ THRALL
Definition: hyjal.h:70
@ DATA_RAGEWINTERCHILL
Definition: hyjal.h:30
@ TYPE_RETREAT
Definition: hyjal.h:45
@ DATA_TRASH
Definition: hyjal.h:39
@ DATA_TYRANDEWHISPERWIND
Definition: hyjal.h:38
@ DATA_CHANNEL_TARGET
Definition: hyjal.h:46
@ DATA_RAIDDAMAGE
Definition: hyjal.h:43
@ DATA_RESET_RAIDDAMAGE
Definition: hyjal.h:44
@ DATA_THRALL
Definition: hyjal.h:37
@ DATA_KAZROGAL
Definition: hyjal.h:32
@ DATA_AZGALOR
Definition: hyjal.h:33
@ DATA_JAINAPROUDMOORE
Definition: hyjal.h:36
@ DATA_ANETHERON
Definition: hyjal.h:31
@ DATA_ARCHIMONDE
Definition: hyjal.h:34
@ DATA_ALLIANCE_RETREAT
Definition: hyjal.h:41
@ DATA_HORDE_RETREAT
Definition: hyjal.h:42
@ DATA_RESET_TRASH_COUNT
Definition: hyjal.h:40
#define HyjalScriptName
Definition: hyjal.h:23
#define MINRAIDDAMAGE
Definition: hyjal.h:92
@ GO_ANCIENT_GEM
Definition: hyjal.h:87
@ GO_HORDE_ENCAMPMENT_PORTAL
Definition: hyjal.h:85
@ GO_NIGHT_ELF_VILLAGE_PORTAL
Definition: hyjal.h:86
@ WORLD_STATE_ENEMYCOUNT
Definition: hyjal.h:53
@ YELL_ARCHIMONDE_INTRO
ObjectData const creatureData[]
void AddSC_instance_mount_hyjal()
DungeonEncounterData const encounters[]
bool SetBossState(uint32 id, EncounterState state) override
void SetData(uint32 type, uint32 data) override