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
53
54static constexpr DungeonEncounterData encounters[] =
55{
56 { DATA_RAGEWINTERCHILL, {{ 618 }} },
57 { DATA_ANETHERON, {{ 619 }} },
58 { DATA_KAZROGAL, {{ 620 }} },
59 { DATA_AZGALOR, {{ 621 }} },
60 { DATA_ARCHIMONDE, {{ 622 }} }
61};
62
64{
65public:
67
69 {
71 }
72
74 {
87
88 void OnGameObjectCreate(GameObject* go) override
89 {
90 switch (go->GetEntry())
91 {
93 HordeGate = go->GetGUID();
96 else
98 break;
100 ElfGate = go->GetGUID();
101 if (hordeRetreat)
103 else
105 break;
106 case GO_ANCIENT_GEM:
107 m_uiAncientGemGUID.push_back(go->GetGUID());
108 break;
109 }
110
112 }
113
114 void OnCreatureCreate(Creature* creature) override
115 {
116 switch (creature->GetEntry())
117 {
118 case ARCHIMONDE:
120 {
121 creature->SetVisible(false);
122 creature->SetReactState(REACT_PASSIVE);
123 }
124 break;
125 }
126
128 }
129
130 void SetData(uint32 type, uint32 data) override
131 {
132 switch (type)
133 {
135 Trash = 0;
136 break;
137 case DATA_TRASH:
138 if (data)
139 Trash = data;
140 else
141 Trash--;
143 break;
144 case TYPE_RETREAT:
145 if (data == SPECIAL)
146 {
147 if (!m_uiAncientGemGUID.empty())
148 {
149 for (GuidList::const_iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
150 {
151 //don't know how long it expected
152 DoRespawnGameObject(*itr, 24h);
153 }
154 }
155 }
156 break;
158 allianceRetreat = data;
160 break;
162 hordeRetreat = data;
164 break;
165 case DATA_RAIDDAMAGE:
166 RaidDamage += data;
169 break;
171 RaidDamage = 0;
172 break;
173 }
174
175 TC_LOG_DEBUG("scripts", "Instance Hyjal: Instance data updated for event {} (Data={})", type, data);
176 }
177
178 bool SetBossState(uint32 id, EncounterState state) override
179 {
180 if (!InstanceScript::SetBossState(id, state))
181 return false;
182
183 switch (id)
184 {
185 case DATA_AZGALOR:
186 if (state == DONE)
187 {
188 instance->LoadGrid(5581.49f, -3445.63f);
189 if (Creature* archimonde = GetCreature(DATA_ARCHIMONDE))
190 {
191 archimonde->SetVisible(true);
192 archimonde->SetReactState(REACT_AGGRESSIVE);
193 archimonde->AI()->DoAction(ACTION_ARCHIMONDE_INTRO);
194 }
195 }
196 break;
197 }
198
199 return true;
200 }
201
202 uint32 GetData(uint32 type) const override
203 {
204 switch (type)
205 {
206 case DATA_TRASH: return Trash;
208 case DATA_HORDE_RETREAT: return hordeRetreat;
209 case DATA_RAIDDAMAGE: return RaidDamage;
210 }
211 return 0;
212 }
213
214 void AfterDataLoad() override
215 {
217 allianceRetreat = 1;
219 hordeRetreat = 1;
220 }
221
222 protected:
230 };
231};
232
234{
235 new instance_hyjal();
236}
uint32_t uint32
Definition Define.h:154
EncounterState
@ DONE
@ SPECIAL
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:173
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:433
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
#define DataHeader
uint32 const EncounterCount
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void SetReactState(ReactStates st)
Definition Creature.h:180
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:370
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint32 GetEntry() const
Definition Object.h:89
void SetVisible(bool x)
Definition Unit.cpp:8787
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ KAZROGAL
Definition hyjal.h:75
@ AZGALOR
Definition hyjal.h:76
@ TYRANDE
Definition hyjal.h:70
@ ANETHERON
Definition hyjal.h:74
@ ARCHIMONDE
Definition hyjal.h:77
@ JAINA
Definition hyjal.h:68
@ RAGE_WINTERCHILL
Definition hyjal.h:73
@ THRALL
Definition hyjal.h:69
@ 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_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
@ ACTION_ARCHIMONDE_INTRO
Definition hyjal.h:93
#define MINRAIDDAMAGE
Definition hyjal.h:118
@ GO_ANCIENT_GEM
Definition hyjal.h:86
@ GO_HORDE_ENCAMPMENT_PORTAL
Definition hyjal.h:84
@ GO_NIGHT_ELF_VILLAGE_PORTAL
Definition hyjal.h:85
@ WORLD_STATE_ENEMYCOUNT
Definition hyjal.h:52
static constexpr ObjectData creatureData[]
void AddSC_instance_mount_hyjal()
static constexpr DungeonEncounterData encounters[]
bool SetBossState(uint32 id, EncounterState state) override
void SetData(uint32 type, uint32 data) override