TrinityCore
instance_stonecore.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 "CreatureGroups.h"
21#include "GameObject.h"
22#include "InstanceScript.h"
23#include "Map.h"
24#include "stonecore.h"
25
26#define MAX_ENCOUNTER 4
27
28/* Stonecore encounters:
290 - Corborus
301 - Slabhide
312 - Ozruk
323 - High Priestess Azil
33*/
34
35// TO-DO:
36// - Find out spell IDs for both Stonecore Teleporters (spellclick).
37
39{
46 { 0, 0 } // END
47};
48
50{
51 { DATA_CORBORUS, {{ 1056 }} },
52 { DATA_SLABHIDE, {{ 1059 }} },
53 { DATA_OZRUK, {{ 1058 }} },
54 { DATA_HIGH_PRIESTESS_AZIL, {{ 1057 }} }
55};
56
58{
59 public:
61
63 {
65 {
70 }
71
72 void OnGameObjectCreate(GameObject* go) override
73 {
74 switch (go->GetEntry())
75 {
79 break;
81 slabhideRockWallGUIDs.push_back(go->GetGUID());
82 break;
83 default:
84 break;
85 }
86 }
87
88 void OnCreatureCreate(Creature* creature) override
89 {
90 switch (creature->GetEntry())
91 {
95 ActivateTeleporter(creature);
96 break;
97 default:
98 break;
99 }
100
101 // Check if creature is part of Millhouse event
102 creature->SearchFormation();
103 if (CreatureGroup* group = creature->GetFormation())
104 {
105 switch (group->GetLeaderSpawnId())
106 {
108 millhouseTrashGUIDs.push_back(creature->GetGUID());
109 break;
111 millhouseLastGroupGUIDs.push_back(creature->GetGUID());
112 creature->SetReactState(REACT_PASSIVE);
114 break;
115 }
116 }
117
119 }
120
121 bool SetBossState(uint32 type, EncounterState state) override
122 {
123 switch (type)
124 {
125 case DATA_SLABHIDE:
126 // Open rock walls (Slabhide AI handles closing because it must be delayed)
127 if (state != IN_PROGRESS)
129
130 // Activate teleporters
131 if (state == DONE)
132 {
135 }
136 break;
137 default:
138 break;
139 }
140
141 return InstanceScript::SetBossState(type, state);
142 }
143
144 uint32 GetData(uint32 type) const override
145 {
146 switch (type)
147 {
149 return slabhideIntro;
150 default:
151 break;
152 }
153
154 return 0;
155 }
156
157 void SetData(uint32 type, uint32 data) override
158 {
159 switch (type)
160 {
163 break;
166 break;
169 break;
172 break;
175 break;
176 case DATA_SLABHIDE_ROCK_WALL: // Handles rock walls
177 for (std::vector<ObjectGuid>::iterator itr = slabhideRockWallGUIDs.begin(); itr != slabhideRockWallGUIDs.end(); ++itr)
178 HandleGameObject((*itr), data ? true : false);
179 break;
180 default:
181 break;
182 }
183 }
184
185 private:
186 // Face Millhouse and other nearby mobs to Corborus
188 {
190 Millhouse->SetFacingTo(1.570796f);
191 for (GuidVector::const_iterator i = millhouseLastGroupGUIDs.begin(); i != millhouseLastGroupGUIDs.end(); ++i)
192 if (Creature* creature = instance->GetCreature(*i))
193 creature->SetFacingTo(1.570796f);
194 }
195
196 // Knock back Millhouse and other mobs
198 {
200 Millhouse->CastSpell(Millhouse, SPELL_RING_WYRM_KNOCKBACK, true);
201 for (GuidVector::const_iterator itr = millhouseLastGroupGUIDs.begin(); itr != millhouseLastGroupGUIDs.end(); ++itr)
202 if (Creature* creature = instance->GetCreature(*itr))
203 creature->CastSpell(creature, SPELL_RING_WYRM_KNOCKBACK, true);
204 }
205
206 // Despawn all mobs
208 {
210 Millhouse->DespawnOrUnsummon(3s);
211 for (GuidVector::const_iterator itr = millhouseTrashGUIDs.begin(); itr != millhouseTrashGUIDs.end(); ++itr)
212 if (Creature* creature = instance->GetCreature(*itr))
213 creature->DespawnOrUnsummon(3s);
214 for (GuidVector::const_iterator itr = millhouseLastGroupGUIDs.begin(); itr != millhouseLastGroupGUIDs.end(); ++itr)
215 if (Creature* creature = instance->GetCreature(*itr))
216 creature->DespawnOrUnsummon(3s);
217 }
218
219 void ActivateTeleporter(Creature* teleporter)
220 {
221 if (!teleporter)
222 return;
223
224 teleporter->CastSpell(teleporter, SPELL_TELEPORTER_ACTIVE_VISUAL, true);
226 }
227
232
234 };
235
237 {
238 return new instance_stonecore_InstanceScript(map);
239 }
240};
241
243{
244 new instance_stonecore();
245}
uint32_t uint32
Definition: Define.h:142
EncounterState
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
std::vector< ObjectGuid > GuidVector
Definition: ObjectGuid.h:395
@ ANIM_READY2H
@ GO_STATE_READY
@ GO_STATE_ACTIVE
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ UNIT_NPC_FLAG_SPELLCLICK
Definition: UnitDefines.h:321
#define DataHeader
void SetReactState(ReactStates st)
Definition: Creature.h:160
CreatureGroup * GetFormation()
Definition: Creature.h:391
void SearchFormation()
Definition: Creature.cpp:375
void SetGoState(GOState state)
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 LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
void SetNpcFlag(NPCFlags flags)
Definition: Unit.h:982
void SetMeleeAnimKitId(uint16 animKitId)
Definition: Unit.cpp:10575
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
InstanceScript * GetInstanceScript(InstanceMap *map) const override
ObjectData const creatureData[]
void AddSC_instance_stonecore()
#define MAX_ENCOUNTER
DungeonEncounterData const encounters[]
@ DATA_MILLHOUSE_EVENT_KNOCKBACK
Definition: stonecore.h:38
@ DATA_HANDLE_CORBORUS_ROCKDOOR
Definition: stonecore.h:37
@ DATA_HIGH_PRIESTESS_AZIL
Definition: stonecore.h:32
@ DATA_SLABHIDE_INTRO
Definition: stonecore.h:41
@ DATA_CORBORUS
Definition: stonecore.h:29
@ DATA_SLABHIDE_ROCK_WALL
Definition: stonecore.h:42
@ DATA_MILLHOUSE_EVENT_DESPAWN
Definition: stonecore.h:39
@ DATA_SLABHIDE
Definition: stonecore.h:30
@ DATA_STONECORE_TELEPORTER
Definition: stonecore.h:45
@ DATA_OZRUK
Definition: stonecore.h:31
@ DATA_MILLHOUSE_MANASTORM
Definition: stonecore.h:35
@ DATA_STONECORE_TELEPORTER_2
Definition: stonecore.h:46
@ DATA_MILLHOUSE_EVENT_FACE
Definition: stonecore.h:36
@ NPC_MILLHOUSE_MANASTORM
Definition: stonecore.h:55
@ CREATURE_FORMATION_MILLHOUSE_EVENT_LAST_GROUP
Definition: stonecore.h:76
@ NPC_STONECORE_TELEPORTER
Definition: stonecore.h:64
@ SPELL_RING_WYRM_KNOCKBACK
Definition: stonecore.h:72
@ NPC_HIGH_PRIESTESS_AZIL
Definition: stonecore.h:60
@ NPC_CORBORUS
Definition: stonecore.h:57
@ CREATURE_FORMATION_MILLHOUSE_EVENT_TRASH
Definition: stonecore.h:75
@ NPC_STONECORE_TELEPORTER_2
Definition: stonecore.h:65
@ SPELL_TELEPORTER_ACTIVE_VISUAL
Definition: stonecore.h:66
@ GAMEOBJECT_CORBORUS_ROCKDOOR
Definition: stonecore.h:69
@ NPC_SLABHIDE
Definition: stonecore.h:58
@ GAMEOBJECT_SLABHIDE_ROCK_WALL
Definition: stonecore.h:70
#define SCScriptName
Definition: stonecore.h:23
void SetData(uint32 type, uint32 data) override
bool SetBossState(uint32 type, EncounterState state) override