TrinityCore
Loading...
Searching...
No Matches
instance_karazhan.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#include "ScriptMgr.h"
19#include "Creature.h"
20#include "CreatureAI.h"
21#include "GameObject.h"
22#include "InstanceScript.h"
23#include "karazhan.h"
24#include "Map.h"
25
26/*
270 - Attumen + Midnight (optional)
281 - Moroes
292 - Maiden of Virtue (optional)
303 - Hyakiss the Lurker / Rokad the Ravager / Shadikith the Glider
314 - Opera Event
325 - Curator
336 - Shade of Aran (optional)
347 - Terestian Illhoof (optional)
358 - Netherspite (optional)
369 - Chess Event
3710 - Prince Malchezzar
3811 - Nightbane
39*/
40
41static constexpr ObjectData creatureData[] =
42{
46 { 0, 0 } // END
47};
48
57
59{
60 { -10960.981445f, -1940.138428f, 46.178097f, 4.12f }, // Hyakiss the Lurker
61 { -10945.769531f, -2040.153320f, 49.474438f, 0.077f }, // Shadikith the Glider
62 { -10899.903320f, -2085.573730f, 49.474449f, 1.38f } // Rokad the Ravager
63};
64
66{
67public:
69
71 {
73 }
74
76 {
87
88 void OnCreatureCreate(Creature* creature) override
89 {
91
92 switch (creature->GetEntry())
93 {
94 case NPC_KILREK:
95 KilrekGUID = creature->GetGUID();
96 break;
98 TerestianGUID = creature->GetGUID();
99 break;
100 case NPC_MOROES:
101 MoroesGUID = creature->GetGUID();
102 break;
103 case NPC_NIGHTBANE:
104 NightbaneGUID = creature->GetGUID();
105 break;
106 default:
107 break;
108 }
109 }
110
111 void OnUnitDeath(Unit* unit) override
112 {
113 Creature* creature = unit->ToCreature();
114 if (!creature)
115 return;
116
117 switch (creature->GetEntry())
118 {
121 case NPC_SHADOWBAT:
124 case NPC_PHASE_HOUND:
125 case NPC_DREADBEAST:
126 case NPC_SHADOWBEAST:
128 {
131 {
133 {
136 break;
139 break;
142 break;
143 }
144 }
145 }
146 break;
151 break;
152 default:
153 break;
154 }
155 }
156
157 void SetData(uint32 type, uint32 data) override
158 {
159 switch (type)
160 {
162 OperaEvent = data;
163 break;
165 if (data == SPECIAL)
166 ++OzDeathCount;
167 break;
168 default:
169 break;
170 }
171 }
172
173 bool SetBossState(uint32 type, EncounterState state) override
174 {
175 if (!InstanceScript::SetBossState(type, state))
176 return false;
177
178 switch (type)
179 {
181 if (state == DONE)
182 {
188 go->ActivateObject(GameObjectActions::Unlock);
189 if (Creature* barnes = GetCreature(DATA_BARNES))
190 barnes->AI()->DoAction(ACTION_OPERA_FINISHED);
192 }
193 else if (state == FAIL)
194 {
195 OzDeathCount = 0;
200 if (Creature* barnes = GetCreature(DATA_BARNES))
201 barnes->AI()->DoAction(ACTION_OPERA_FINISHED);
202 }
203 break;
204 case DATA_CHESS:
205 if (state == DONE)
207 break;
208 default:
209 break;
210 }
211
212 return true;
213 }
214
215 void SetGuidData(uint32 type, ObjectGuid data) override
216 {
217 if (type == DATA_IMAGE_OF_MEDIVH)
218 ImageGUID = data;
219 }
220
222 {
224
225 switch (go->GetEntry())
226 {
230 break;
234 break;
236 LibraryDoor = go->GetGUID();
237 break;
238 case GO_MASSIVE_DOOR:
239 MassiveDoor = go->GetGUID();
240 break;
242 GamesmansDoor = go->GetGUID();
243 break;
246 break;
248 NetherspaceDoor = go->GetGUID();
249 break;
251 MastersTerraceDoor[0] = go->GetGUID();
252 break;
254 MastersTerraceDoor[1] = go->GetGUID();
255 break;
259 break;
262 break;
263 case GO_BLACKENED_URN:
265 break;
266 }
267 }
268
269 uint32 GetData(uint32 type) const override
270 {
271 switch (type)
272 {
274 return OperaEvent;
276 return OzDeathCount;
277 }
278
279 return 0;
280 }
281
282 ObjectGuid GetGuidData(uint32 type) const override
283 {
284 switch (type)
285 {
286 case DATA_KILREK:
287 return KilrekGUID;
288 case DATA_TERESTIAN:
289 return TerestianGUID;
290 case DATA_MOROES:
291 return MoroesGUID;
292 case DATA_NIGHTBANE:
293 return NightbaneGUID;
295 return LibraryDoor;
297 return MassiveDoor;
299 return GamesmansDoor;
301 return GamesmansExitDoor;
303 return NetherspaceDoor;
305 return MastersTerraceDoor[0];
307 return MastersTerraceDoor[1];
309 return ImageGUID;
311 return BlackenedUrnGUID;
312 }
313
314 return ObjectGuid::Empty;
315 }
316
317 private:
323 ObjectGuid LibraryDoor; // Door at Shade of Aran
324 ObjectGuid MassiveDoor; // Door at Netherspite
325 ObjectGuid GamesmansDoor; // Door before Chess
326 ObjectGuid GamesmansExitDoor; // Door after Chess
327 ObjectGuid NetherspaceDoor; // Door at Malchezaar
332
333 protected:
336 };
337};
338
340{
341 new instance_karazhan();
342}
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint32_t uint32
Definition Define.h:133
EncounterState
@ FAIL
@ DONE
@ SPECIAL
@ TO_BE_DECIDED
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define DataHeader
uint32 const EncounterCount
void ActivateObject(GameObjectActions action, WorldObject *spellCaster=nullptr, uint32 spellId=0, int32 effectIndex=-1)
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
void UpdateEncounterStateForKilledCreature(uint32 creatureId, Unit *source)
EncounterState GetBossState(uint32 id) const
void DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn=1min)
virtual void OnGameObjectCreate(GameObject *go) override
GameObject * GetGameObject(uint32 type)
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1853
static ObjectGuid const Empty
Definition ObjectGuid.h:140
static Creature * ToCreature(Object *o)
Definition Object.h:189
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
Definition Unit.h:783
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
const Position OptionalSpawn[]
static constexpr ObjectData gameObjectData[]
void AddSC_instance_karazhan()
@ NPC_VAMPIRIC_SHADOWBAT
Definition karazhan.h:94
@ NPC_JULIANNE
Definition karazhan.h:83
@ NPC_PHASE_HOUND
Definition karazhan.h:96
@ NPC_GREATER_SHADOWBAT
Definition karazhan.h:95
@ NPC_SHADOWBEAST
Definition karazhan.h:98
@ NPC_TERESTIAN_ILLHOOF
Definition karazhan.h:80
@ NPC_MOROES
Definition karazhan.h:81
@ NPC_ROKAD_THE_RAVAGER
Definition karazhan.h:78
@ NPC_SHADOWBAT
Definition karazhan.h:93
@ NPC_HYAKISS_THE_LURKER
Definition karazhan.h:77
@ NPC_KILREK
Definition karazhan.h:99
@ NPC_ROMULO
Definition karazhan.h:84
@ NPC_NIGHTBANE
Definition karazhan.h:85
@ NPC_BARNES
Definition karazhan.h:82
@ NPC_SHADIKITH_THE_GLIDER
Definition karazhan.h:79
@ NPC_DREADBEAST
Definition karazhan.h:97
@ NPC_COLDMIST_WIDOW
Definition karazhan.h:91
@ NPC_COLDMIST_STALKER
Definition karazhan.h:92
@ ACTION_OPERA_FINISHED
Definition karazhan.h:121
#define KZScriptName
Definition karazhan.h:23
@ OPTIONAL_BOSS_REQUIRED_DEATH_COUNT
Definition karazhan.h:126
@ EVENT_HOOD
Definition karazhan.h:70
@ EVENT_OZ
Definition karazhan.h:71
@ EVENT_RAJ
Definition karazhan.h:72
@ DATA_KILREK
Definition karazhan.h:43
@ DATA_GO_STAGE_CURTAIN
Definition karazhan.h:62
@ DATA_ROMULO
Definition karazhan.h:57
@ DATA_GO_MASSIVE_DOOR
Definition karazhan.h:45
@ DATA_GO_GAME_EXIT_DOOR
Definition karazhan.h:48
@ DATA_OPTIONAL_BOSS
Definition karazhan.h:33
@ DATA_JULIANNE
Definition karazhan.h:56
@ DATA_IMAGE_OF_MEDIVH
Definition karazhan.h:50
@ DATA_OPERA_OZ_DEATH_COUNT
Definition karazhan.h:60
@ DATA_CHESS
Definition karazhan.h:39
@ DATA_BARNES
Definition karazhan.h:55
@ DATA_MASTERS_TERRACE_DOOR_1
Definition karazhan.h:51
@ DATA_TERESTIAN
Definition karazhan.h:37
@ DATA_GO_GAME_DOOR
Definition karazhan.h:47
@ DATA_OPERA_VARIATION
Definition karazhan.h:59
@ DATA_MOROES
Definition karazhan.h:31
@ DATA_GO_SIDE_ENTRANCE_DOOR
Definition karazhan.h:65
@ DATA_GO_LIBRARY_DOOR
Definition karazhan.h:44
@ DATA_GO_STAGE_DOOR_LEFT
Definition karazhan.h:63
@ DATA_GO_BLACKENED_URN
Definition karazhan.h:53
@ DATA_NIGHTBANE
Definition karazhan.h:41
@ DATA_MASTERS_TERRACE_DOOR_2
Definition karazhan.h:52
@ DATA_OPERA_PERFORMANCE
Definition karazhan.h:34
@ DATA_GO_STAGE_DOOR_RIGHT
Definition karazhan.h:64
@ DATA_GO_NETHER_DOOR
Definition karazhan.h:46
@ GO_BLACKENED_URN
Definition karazhan.h:116
@ GO_STAGE_DOOR_RIGHT
Definition karazhan.h:106
@ GO_STAGE_CURTAIN
Definition karazhan.h:104
@ GO_PRIVATE_LIBRARY_DOOR
Definition karazhan.h:107
@ GO_MASSIVE_DOOR
Definition karazhan.h:108
@ GO_STAGE_DOOR_LEFT
Definition karazhan.h:105
@ GO_NETHERSPACE_DOOR
Definition karazhan.h:111
@ GO_GAMESMAN_HALL_EXIT_DOOR
Definition karazhan.h:110
@ GO_SIDE_ENTRANCE_DOOR
Definition karazhan.h:114
@ GO_MASTERS_TERRACE_DOOR
Definition karazhan.h:112
@ GO_MASTERS_TERRACE_DOOR2
Definition karazhan.h:113
@ GO_GAMESMAN_HALL_DOOR
Definition karazhan.h:109
@ GO_DUST_COVERED_CHEST
Definition karazhan.h:115
bool SetBossState(uint32 type, EncounterState state) override
void SetGuidData(uint32 type, ObjectGuid data) override