TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
instance_utgarde_keep.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 "GameObject.h"
21#include "InstanceScript.h"
22#include "utgarde_keep.h"
23
25{
28 { 0, 0, DOOR_TYPE_ROOM } // END
29};
30
32{
35 { 0, 0 }
36};
37
39{
40 public:
42
44 {
46 {
51 }
52
53 void OnCreatureCreate(Creature* creature) override
54 {
55 switch (creature->GetEntry())
56 {
58 PrinceKelesethGUID = creature->GetGUID();
59 break;
60 case NPC_SKARVALD:
61 SkarvaldGUID = creature->GetGUID();
62 AddMinion(creature, true);
63 break;
64 case NPC_DALRONN:
65 DalronnGUID = creature->GetGUID();
66 AddMinion(creature, true);
67 break;
68 case NPC_INGVAR:
69 IngvarGUID = creature->GetGUID();
70 break;
71 default:
72 break;
73 }
74 }
75
76 void OnCreatureRemove(Creature* creature) override
77 {
78 switch (creature->GetEntry())
79 {
80 case NPC_SKARVALD:
81 case NPC_DALRONN:
82 AddMinion(creature, false);
83 break;
84 default:
85 break;
86 }
87 }
88
89 void OnGameObjectCreate(GameObject* go) override
90 {
92
93 switch (go->GetEntry())
94 {
95 case GO_BELLOW_1:
96 Forges[0].BellowGUID = go->GetGUID();
98 break;
99 case GO_BELLOW_2:
100 Forges[1].BellowGUID = go->GetGUID();
102 break;
103 case GO_BELLOW_3:
104 Forges[2].BellowGUID = go->GetGUID();
106 break;
107 case GO_FORGEFIRE_1:
108 Forges[0].FireGUID = go->GetGUID();
110 break;
111 case GO_FORGEFIRE_2:
112 Forges[1].FireGUID = go->GetGUID();
114 break;
115 case GO_FORGEFIRE_3:
116 Forges[2].FireGUID = go->GetGUID();
118 break;
120 Forges[0].AnvilGUID = go->GetGUID();
122 break;
124 Forges[1].AnvilGUID = go->GetGUID();
126 break;
128 Forges[2].AnvilGUID = go->GetGUID();
130 break;
131 default:
132 break;
133 }
134 }
135
136 ObjectGuid GetGuidData(uint32 type) const override
137 {
138 switch (type)
139 {
141 return PrinceKelesethGUID;
142 case DATA_SKARVALD:
143 return SkarvaldGUID;
144 case DATA_DALRONN:
145 return DalronnGUID;
146 case DATA_INGVAR:
147 return IngvarGUID;
148 default:
149 break;
150 }
151
152 return ObjectGuid::Empty;
153 }
154
155 void SetData(uint32 type, uint32 data) override
156 {
157 switch (type)
158 {
159 case DATA_FORGE_1:
160 case DATA_FORGE_2:
161 case DATA_FORGE_3:
162 {
163 uint8 i = type - DATA_FORGE_1;
164 HandleGameObject(Forges[i].AnvilGUID, data != NOT_STARTED);
165 HandleGameObject(Forges[i].BellowGUID, data != NOT_STARTED);
166 HandleGameObject(Forges[i].FireGUID, data != NOT_STARTED);
167 Forges[i].Event = data;
168
169 if (data == DONE)
170 SaveToDB();
171 break;
172 }
173 default:
174 break;
175 }
176 }
177
178 void WriteSaveDataMore(std::ostringstream& data) override
179 {
180 for (uint8 i = 0; i < 3; ++i)
181 data << Forges[i].Event << ' ';
182 }
183
184 void ReadSaveDataMore(std::istringstream& data) override
185 {
186 for (uint8 i = 0; i < 3; ++i)
187 data >> Forges[i].Event;
188 }
189
190 protected:
192
197 };
198
200 {
202 }
203};
204
206{
208}
uint8_t uint8
Definition: Define.h:135
uint32_t uint32
Definition: Define.h:133
@ DONE
@ NOT_STARTED
@ DOOR_TYPE_ROOM
@ DOOR_TYPE_PASSAGE
#define DataHeader
uint32 const EncounterCount
void SetBossNumber(uint32 number)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
void AddMinion(Creature *minion, bool add)
virtual void OnGameObjectCreate(GameObject *go) override
void LoadMinionData(MinionData const *data)
void LoadDoorData(DoorData const *data)
void SetHeaders(std::string const &dataHeaders)
static ObjectGuid const Empty
Definition: ObjectGuid.h:132
uint32 GetEntry() const
Definition: Object.h:80
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:77
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ DATA_PRINCE_KELESETH
@ NPC_PRINCE_KELESETH
void AddSC_instance_utgarde_keep()
MinionData const minionData[]
DoorData const doorData[]
ObjectGuid AnvilGUID
Definition: utgarde_keep.h:83
ObjectGuid BellowGUID
Definition: utgarde_keep.h:84
uint32 Event
Definition: utgarde_keep.h:87
ObjectGuid FireGUID
Definition: utgarde_keep.h:85
@ DATA_DALRONN
Definition: utgarde_keep.h:37
@ DATA_FORGE_2
Definition: utgarde_keep.h:40
@ DATA_SKARVALD_DALRONN
Definition: utgarde_keep.h:32
@ DATA_FORGE_1
Definition: utgarde_keep.h:39
@ DATA_FORGE_3
Definition: utgarde_keep.h:41
@ DATA_SKARVALD
Definition: utgarde_keep.h:36
@ DATA_INGVAR
Definition: utgarde_keep.h:33
@ GO_FORGEFIRE_3
Definition: utgarde_keep.h:69
@ GO_GIANT_PORTCULLIS_1
Definition: utgarde_keep.h:75
@ GO_BELLOW_3
Definition: utgarde_keep.h:65
@ GO_GLOWING_ANVIL_1
Definition: utgarde_keep.h:71
@ GO_GLOWING_ANVIL_2
Definition: utgarde_keep.h:72
@ GO_BELLOW_1
Definition: utgarde_keep.h:63
@ GO_GIANT_PORTCULLIS_2
Definition: utgarde_keep.h:76
@ GO_BELLOW_2
Definition: utgarde_keep.h:64
@ GO_FORGEFIRE_2
Definition: utgarde_keep.h:68
@ GO_GLOWING_ANVIL_3
Definition: utgarde_keep.h:73
@ GO_FORGEFIRE_1
Definition: utgarde_keep.h:67
#define UKScriptName
Definition: utgarde_keep.h:23
@ NPC_SKARVALD
Definition: utgarde_keep.h:47
@ NPC_INGVAR
Definition: utgarde_keep.h:49
@ NPC_DALRONN
Definition: utgarde_keep.h:48