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
54
56{
57public:
59
61 {
63 }
64
66 {
78
79 void OnGameObjectCreate(GameObject* go) override
80 {
81 switch (go->GetEntry())
82 {
84 HordeGate = go->GetGUID();
87 else
89 break;
91 ElfGate = go->GetGUID();
92 if (hordeRetreat)
94 else
96 break;
97 case GO_ANCIENT_GEM:
98 m_uiAncientGemGUID.push_back(go->GetGUID());
99 break;
100 }
101
103 }
104
105 void OnCreatureCreate(Creature* creature) override
106 {
107 switch (creature->GetEntry())
108 {
109 case ARCHIMONDE:
111 {
112 creature->SetVisible(false);
113 creature->SetReactState(REACT_PASSIVE);
114 }
115 break;
116 }
117
119 }
120
121 void SetData(uint32 type, uint32 data) override
122 {
123 switch (type)
124 {
126 Trash = 0;
127 break;
128 case DATA_TRASH:
129 if (data)
130 Trash = data;
131 else
132 Trash--;
134 break;
135 case TYPE_RETREAT:
136 if (data == SPECIAL)
137 {
138 if (!m_uiAncientGemGUID.empty())
139 {
140 for (GuidList::const_iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
141 {
142 //don't know how long it expected
143 DoRespawnGameObject(*itr, 24h);
144 }
145 }
146 }
147 break;
149 allianceRetreat = data;
151 SaveToDB();
152 break;
154 hordeRetreat = data;
156 SaveToDB();
157 break;
158 case DATA_RAIDDAMAGE:
159 RaidDamage += data;
162 break;
164 RaidDamage = 0;
165 break;
166 }
167
168 TC_LOG_DEBUG("scripts", "Instance Hyjal: Instance data updated for event {} (Data={})", type, data);
169 }
170
171 bool SetBossState(uint32 id, EncounterState state) override
172 {
173 if (!InstanceScript::SetBossState(id, state))
174 return false;
175
176 switch (id)
177 {
178 case DATA_AZGALOR:
179 if (state == DONE)
180 {
181 instance->LoadGrid(5581.49f, -3445.63f);
182 if (Creature* archimonde = GetCreature(DATA_ARCHIMONDE))
183 {
184 archimonde->SetVisible(true);
185 archimonde->SetReactState(REACT_AGGRESSIVE);
186 archimonde->AI()->DoAction(ACTION_ARCHIMONDE_INTRO);
187 }
188 }
189 break;
190 }
191
192 return true;
193 }
194
195 void ReadSaveDataMore(std::istringstream& loadStream) override
196 {
197 loadStream >> allianceRetreat >> hordeRetreat >> RaidDamage;
198 }
199
200 void WriteSaveDataMore(std::ostringstream& saveStream) override
201 {
202 saveStream << allianceRetreat << ' ' << hordeRetreat << ' ' << RaidDamage;
203 }
204
205 uint32 GetData(uint32 type) const override
206 {
207 switch (type)
208 {
209 case DATA_TRASH: return Trash;
211 case DATA_HORDE_RETREAT: return hordeRetreat;
212 case DATA_RAIDDAMAGE: return RaidDamage;
213 }
214 return 0;
215 }
216
217 protected:
225 };
226};
227
229{
230 new instance_hyjal();
231}
uint32_t uint32
Definition Define.h:133
EncounterState
@ DONE
@ SPECIAL
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:261
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
#define DataHeader
uint32 const EncounterCount
void SetReactState(ReactStates st)
Definition Creature.h:119
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)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn=1min)
virtual void OnGameObjectCreate(GameObject *go) override
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue)
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
void LoadGrid(float x, float y)
Definition Map.cpp:578
static ObjectGuid const Empty
Definition ObjectGuid.h:140
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void SetVisible(bool x)
Definition Unit.cpp:8513
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
ObjectData const creatureData[]
void AddSC_instance_mount_hyjal()
bool SetBossState(uint32 id, EncounterState state) override
void SetData(uint32 type, uint32 data) override
void WriteSaveDataMore(std::ostringstream &saveStream) override
void ReadSaveDataMore(std::istringstream &loadStream) override