TrinityCore
Loading...
Searching...
No Matches
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
46
59
60static constexpr DungeonEncounterData encounters[] =
61{
62 { DATA_RAGEWINTERCHILL, {{ 618 }} },
63 { DATA_ANETHERON, {{ 619 }} },
64 { DATA_KAZROGAL, {{ 620 }} },
65 { DATA_AZGALOR, {{ 621 }} },
66 { DATA_ARCHIMONDE, {{ 622 }} }
67};
68
70{
71public:
73
75 {
77 }
78
80 {
95
96 void OnGameObjectCreate(GameObject* go) override
97 {
98 switch (go->GetEntry())
99 {
101 HordeGate = go->GetGUID();
102 if (allianceRetreat)
104 else
106 break;
108 ElfGate = go->GetGUID();
109 if (hordeRetreat)
111 else
113 break;
114 case GO_ANCIENT_GEM:
115 m_uiAncientGemGUID.push_back(go->GetGUID());
116 break;
117 }
118
120 }
121
122 void OnCreatureCreate(Creature* creature) override
123 {
124 switch (creature->GetEntry())
125 {
126 case ARCHIMONDE:
128 {
129 creature->SetVisible(false);
130 creature->SetReactState(REACT_PASSIVE);
131 }
132 break;
133 }
134
136 }
137
138 void SetData(uint32 type, uint32 data) override
139 {
140 switch (type)
141 {
143 Trash = 0;
144 break;
145 case DATA_TRASH:
146 if (data)
147 Trash = data;
148 else
149 Trash--;
151 break;
152 case TYPE_RETREAT:
153 if (data == SPECIAL)
154 {
155 if (!m_uiAncientGemGUID.empty())
156 {
157 for (GuidList::const_iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
158 {
159 //don't know how long it expected
160 DoRespawnGameObject(*itr, 24h);
161 }
162 }
163 }
164 break;
166 allianceRetreat = data;
168 break;
170 hordeRetreat = data;
172 break;
173 case DATA_RAIDDAMAGE:
174 RaidDamage += data;
177 break;
179 RaidDamage = 0;
180 break;
181 }
182
183 TC_LOG_DEBUG("scripts", "Instance Hyjal: Instance data updated for event {} (Data={})", type, data);
184 }
185
186 bool SetBossState(uint32 id, EncounterState state) override
187 {
188 if (!InstanceScript::SetBossState(id, state))
189 return false;
190
191 switch (id)
192 {
193 case DATA_AZGALOR:
194 if (state == DONE)
195 {
196 instance->LoadGrid(5581.49f, -3445.63f);
197 if (Creature* archimonde = GetCreature(DATA_ARCHIMONDE))
198 {
199 archimonde->SetVisible(true);
200 archimonde->SetReactState(REACT_AGGRESSIVE);
201
202 if (!ArchiYell)
203 {
204 ArchiYell = true;
205 archimonde->AI()->Talk(YELL_ARCHIMONDE_INTRO);
206 }
207 }
208 }
209 break;
210 }
211
212 return true;
213 }
214
215 uint32 GetData(uint32 type) const override
216 {
217 switch (type)
218 {
219 case DATA_TRASH: return Trash;
221 case DATA_HORDE_RETREAT: return hordeRetreat;
222 case DATA_RAIDDAMAGE: return RaidDamage;
223 }
224 return 0;
225 }
226
227 void AfterDataLoad() override
228 {
230 allianceRetreat = 1;
232 hordeRetreat = 1;
233 }
234
235 protected:
244 };
245};
246
248{
249 new instance_hyjal();
250}
uint32_t uint32
Definition Define.h:154
EncounterState
@ DONE
@ SPECIAL
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:181
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:433
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
#define DataHeader
uint32 const EncounterCount
Yells
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void SetReactState(ReactStates st)
Definition Creature.h:174
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 DoUpdateWorldState(int32 worldStateId, int32 value)
void LoadObjectData(std::span< ObjectData const > creatureData, std::span< ObjectData const > gameObjectData)
InstanceMap * instance
void SetHeaders(std::string_view dataHeaders)
void LoadDungeonEncounterData(std::span< DungeonEncounterData const > encounters)
EncounterState GetBossState(uint32 id) const
void DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn=1min)
virtual void OnGameObjectCreate(GameObject *go) override
void LoadGrid(float x, float y)
Definition Map.cpp:372
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint32 GetEntry() const
Definition Object.h:89
void SetVisible(bool x)
Definition Unit.cpp:8768
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
static constexpr ObjectData creatureData[]
@ YELL_ARCHIMONDE_INTRO
void AddSC_instance_mount_hyjal()
static constexpr DungeonEncounterData encounters[]
bool SetBossState(uint32 id, EncounterState state) override
void SetData(uint32 type, uint32 data) override