TrinityCore
Loading...
Searching...
No Matches
instance_shadowfang_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/* ScriptData
19SDName: Instance_Shadowfang_Keep
20SD%Complete: 90
21SDComment:
22SDCategory: Shadowfang Keep
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "shadowfang_keep.h"
27#include "GameObject.h"
28#include "InstanceScript.h"
29#include "Log.h"
30#include "Map.h"
31#include "ScriptedCreature.h"
32#include "TemporarySummon.h"
33
34#define MAX_ENCOUNTER 4
35
42
48
50{
51 {-148.199f, 2165.647f, 128.448f, 1.026f},
52 {-153.110f, 2168.620f, 128.448f, 1.026f},
53 {-145.905f, 2180.520f, 128.448f, 4.183f},
54 {-140.794f, 2178.037f, 128.448f, 4.090f},
55 {-138.640f, 2170.159f, 136.577f, 2.737f}
56};
57
59{
60public:
62
67
69 {
78
80 std::string str_data;
81
85
89
92
93 void OnCreatureCreate(Creature* creature) override
94 {
95 switch (creature->GetEntry())
96 {
97 case NPC_ASH:
98 uiAshGUID = creature->GetGUID();
99 break;
100 case NPC_ADA:
101 uiAdaGUID = creature->GetGUID();
102 break;
104 uiArchmageArugalGUID = creature->GetGUID();
105 break;
107 _crazedApothecaryGeneratorGUIDs.push_back(creature->GetGUID());
108 break;
109 default:
110 break;
111 }
112 }
113
115 {
116 switch (go->GetEntry())
117 {
120 if (m_auiEncounter[0] == DONE)
122 break;
123 case GO_SORCERER_DOOR:
125 if (m_auiEncounter[2] == DONE)
127 break;
128 case GO_ARUGAL_DOOR:
129 DoorArugalGUID = go->GetGUID();
130 if (m_auiEncounter[3] == DONE)
132 break;
133 }
134 }
135
136 void DoSpeech()
137 {
140
141 if (pAda && pAda->IsAlive() && pAsh && pAsh->IsAlive())
142 {
143 pAda->AI()->Talk(SAY_BOSS_DIE_AD);
144 pAsh->AI()->Talk(SAY_BOSS_DIE_AS);
145 }
146 }
147
148 void SetData(uint32 type, uint32 data) override
149 {
150 switch (type)
151 {
152 case TYPE_FREE_NPC:
153 if (data == DONE)
155 m_auiEncounter[0] = data;
156 break;
157 case TYPE_RETHILGORE:
158 if (data == DONE)
159 DoSpeech();
160 m_auiEncounter[1] = data;
161 break;
162 case TYPE_FENRUS:
163 switch (data)
164 {
165 case DONE:
166 uiTimer = 1000;
167 uiPhase = 1;
168 break;
169 case 7:
171 break;
172 }
173 m_auiEncounter[2] = data;
174 break;
175 case TYPE_NANDOS:
176 if (data == DONE)
177 {
179 if (go->GetGoState() == GO_STATE_READY)
181 }
182 m_auiEncounter[3] = data;
183 break;
186 {
187 if (Creature* generator = instance->GetCreature(guid))
188 generator->CastSpell(nullptr, SPELL_SUMMON_VALENTINE_ADD);
189 }
190 break;
191 default:
192 break;
193 }
194
195 if (data == DONE)
196 {
198
199 std::ostringstream saveStream;
200 saveStream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3];
201
202 str_data = saveStream.str();
203
204 SaveToDB();
206 }
207 }
208
209 uint32 GetData(uint32 type) const override
210 {
211 switch (type)
212 {
213 case TYPE_FREE_NPC:
214 return m_auiEncounter[0];
215 case TYPE_RETHILGORE:
216 return m_auiEncounter[1];
217 case TYPE_FENRUS:
218 return m_auiEncounter[2];
219 case TYPE_NANDOS:
220 return m_auiEncounter[3];
221 }
222 return 0;
223 }
224
225 std::string GetSaveData() override
226 {
227 return str_data;
228 }
229
230 void Load(char const* in) override
231 {
232 if (!in)
233 {
235 return;
236 }
237
239
240 std::istringstream loadStream(in);
241 loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
242
243 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
244 {
245 if (m_auiEncounter[i] == IN_PROGRESS)
247 }
248
250 }
251
252 void Update(uint32 uiDiff) override
253 {
254 if (GetData(TYPE_FENRUS) != DONE)
255 return;
256
258
259 if (!pArchmage || !pArchmage->IsAlive())
260 return;
261
262 if (uiPhase)
263 {
264 if (uiTimer <= uiDiff)
265 {
266 switch (uiPhase)
267 {
268 case 1:
269 {
270 Creature* summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10s);
271 summon->SetImmuneToPC(true);
273 summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true);
274 summon->AI()->Talk(SAY_ARCHMAGE);
275 uiTimer = 2000;
276 uiPhase = 2;
277 break;
278 }
279 case 2:
280 {
285 uiPhase = 0;
286 break;
287 }
288
289 }
290 } else uiTimer -= uiDiff;
291 }
292 }
293
294 private:
296 };
297
298};
299
uint8_t uint8
Definition Define.h:135
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
#define OUT_LOAD_INST_DATA_FAIL
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
#define OUT_SAVE_INST_DATA_COMPLETE
#define OUT_LOAD_INST_DATA_COMPLETE
#define OUT_SAVE_INST_DATA
#define OUT_LOAD_INST_DATA(a)
@ TEMPSUMMON_TIMED_DESPAWN
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:262
Spells
Definition PlayerAI.cpp:32
@ GO_STATE_READY
@ REACT_DEFENSIVE
#define DataHeader
Yells
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
void SetImmuneToPC(bool apply) override
Definition Creature.h:129
void SetReactState(ReactStates st)
Definition Creature.h:119
CreatureAI * AI() const
Definition Creature.h:154
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
void DoUseDoorOrButton(ObjectGuid guid, uint32 withRestoreTime=0, bool useAlternativeState=false)
InstanceMap * instance
void SetHeaders(std::string const &dataHeaders)
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:4430
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4397
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
bool IsAlive() const
Definition Unit.h:1234
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1992
InstanceScript * GetInstanceScript(InstanceMap *map) const override
const Position SpawnLocation[]
@ SPELL_SUMMON_VALENTINE_ADD
@ SPELL_ASHCROMBE_TELEPORT
void AddSC_instance_shadowfang_keep()
#define MAX_ENCOUNTER
@ TYPE_NANDOS
@ TYPE_FENRUS
@ TYPE_RETHILGORE
@ DATA_SPAWN_VALENTINE_ADDS
@ TYPE_FREE_NPC
@ GO_COURTYARD_DOOR
@ GO_SORCERER_DOOR
@ GO_ARUGAL_DOOR
#define SFKScriptName
@ NPC_ADA
@ NPC_ARCHMAGE_ARUGAL
@ NPC_ARUGAL_VOIDWALKER
@ NPC_DND_CRAZED_APOTHECARY_GENERATOR
@ NPC_ASH