TrinityCore
Loading...
Searching...
No Matches
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
47
48static constexpr DungeonEncounterData encounters[] =
49{
50 { DATA_CORBORUS, {{ 1056 }} },
51 { DATA_SLABHIDE, {{ 1059 }} },
52 { DATA_OZRUK, {{ 1058 }} },
53 { DATA_HIGH_PRIESTESS_AZIL, {{ 1057 }} }
54};
55
57{
58 public:
60
62 {
70
71 void OnGameObjectCreate(GameObject* go) override
72 {
73 switch (go->GetEntry())
74 {
78 break;
80 slabhideRockWallGUIDs.push_back(go->GetGUID());
81 break;
82 default:
83 break;
84 }
85 }
86
87 void OnCreatureCreate(Creature* creature) override
88 {
89 switch (creature->GetEntry())
90 {
94 ActivateTeleporter(creature);
95 break;
96 default:
97 break;
98 }
99
100 // Check if creature is part of Millhouse event
101 creature->SearchFormation();
102 if (CreatureGroup* group = creature->GetFormation())
103 {
104 switch (group->GetLeaderSpawnId())
105 {
107 millhouseTrashGUIDs.push_back(creature->GetGUID());
108 break;
110 millhouseLastGroupGUIDs.push_back(creature->GetGUID());
111 creature->SetReactState(REACT_PASSIVE);
113 break;
114 }
115 }
116
118 }
119
120 bool SetBossState(uint32 type, EncounterState state) override
121 {
122 switch (type)
123 {
124 case DATA_SLABHIDE:
125 // Open rock walls (Slabhide AI handles closing because it must be delayed)
126 if (state != IN_PROGRESS)
128
129 // Activate teleporters
130 if (state == DONE)
131 {
134 }
135 break;
136 default:
137 break;
138 }
139
140 return InstanceScript::SetBossState(type, state);
141 }
142
143 uint32 GetData(uint32 type) const override
144 {
145 switch (type)
146 {
148 return slabhideIntro;
149 default:
150 break;
151 }
152
153 return 0;
154 }
155
156 void SetData(uint32 type, uint32 data) override
157 {
158 switch (type)
159 {
162 break;
165 break;
168 break;
171 break;
174 break;
175 case DATA_SLABHIDE_ROCK_WALL: // Handles rock walls
176 for (std::vector<ObjectGuid>::iterator itr = slabhideRockWallGUIDs.begin(); itr != slabhideRockWallGUIDs.end(); ++itr)
177 HandleGameObject((*itr), data ? true : false);
178 break;
179 default:
180 break;
181 }
182 }
183
184 private:
185 // Face Millhouse and other nearby mobs to Corborus
187 {
189 Millhouse->SetFacingTo(1.570796f);
190 for (GuidVector::const_iterator i = millhouseLastGroupGUIDs.begin(); i != millhouseLastGroupGUIDs.end(); ++i)
191 if (Creature* creature = instance->GetCreature(*i))
192 creature->SetFacingTo(1.570796f);
193 }
194
195 // Knock back Millhouse and other mobs
197 {
199 Millhouse->CastSpell(Millhouse, SPELL_RING_WYRM_KNOCKBACK, true);
200 for (GuidVector::const_iterator itr = millhouseLastGroupGUIDs.begin(); itr != millhouseLastGroupGUIDs.end(); ++itr)
201 if (Creature* creature = instance->GetCreature(*itr))
202 creature->CastSpell(creature, SPELL_RING_WYRM_KNOCKBACK, true);
203 }
204
205 // Despawn all mobs
207 {
209 Millhouse->DespawnOrUnsummon(3s);
210 for (GuidVector::const_iterator itr = millhouseTrashGUIDs.begin(); itr != millhouseTrashGUIDs.end(); ++itr)
211 if (Creature* creature = instance->GetCreature(*itr))
212 creature->DespawnOrUnsummon(3s);
213 for (GuidVector::const_iterator itr = millhouseLastGroupGUIDs.begin(); itr != millhouseLastGroupGUIDs.end(); ++itr)
214 if (Creature* creature = instance->GetCreature(*itr))
215 creature->DespawnOrUnsummon(3s);
216 }
217
218 void ActivateTeleporter(Creature* teleporter)
219 {
220 if (!teleporter)
221 return;
222
223 teleporter->CastSpell(teleporter, SPELL_TELEPORTER_ACTIVE_VISUAL, true);
225 }
226
231
233 };
234
236 {
237 return new instance_stonecore_InstanceScript(map);
238 }
239};
240
uint32_t uint32
Definition Define.h:154
EncounterState
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:434
@ ANIM_READY2H
@ GO_STATE_READY
@ GO_STATE_ACTIVE
@ REACT_PASSIVE
@ UNIT_NPC_FLAG_SPELLCLICK
#define DataHeader
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void SetReactState(ReactStates st)
Definition Creature.h:174
CreatureGroup * GetFormation()
Definition Creature.h:406
void SearchFormation()
Definition Creature.cpp:393
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 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
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
uint32 GetEntry() const
Definition Object.h:89
void SetNpcFlag(NPCFlags flags)
Definition Unit.h:997
void SetMeleeAnimKitId(uint16 animKitId)
Definition Unit.cpp:11208
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
void AddSC_instance_stonecore()
#define MAX_ENCOUNTER
static constexpr DungeonEncounterData 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
bool SetBossState(uint32 type, EncounterState state) override