Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_shadowfang_keep.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/* ScriptData
7SDName: Instance_Shadowfang_Keep
8SD%Complete: 90
9SDComment:
10SDCategory: Shadowfang Keep
11EndScriptData */
12
13#include "ScriptedCreature.h"
14#include "ScriptMgr.h"
15#include "InstanceScript.h"
16#include "shadowfang_keep.h"
17#include "TemporarySummon.h"
18
19#define MAX_ENCOUNTER 4
20
27
35
37{
38 GO_COURTYARD_DOOR = 18895, //door to open when talking to NPC's
39 GO_SORCERER_DOOR = 18972, //door to open when Fenrus the Devourer
40 GO_ARUGAL_DOOR = 18971 //door to open when Wolf Master Nandos
41};
42
44{
46};
47
49{
50 {-148.199f, 2165.647f, 128.448f, 1.026f},
51 {-153.110f, 2168.620f, 128.448f, 1.026f},
52 {-145.905f, 2180.520f, 128.448f, 4.183f},
53 {-140.794f, 2178.037f, 128.448f, 4.090f},
54 {-138.640f, 2170.159f, 136.577f, 2.737f}
55};
57{
58public:
59 instance_shadowfang_keep() : InstanceMapScript("instance_shadowfang_keep", 33) { }
60
65
67 {
69
71 std::string str_data;
72
76
80
83
85 {
86 memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
87
88 uiAshGUID = 0;
89 uiAdaGUID = 0;
91
95
96 uiPhase = 0;
97 uiTimer = 0;
98 }
99
101 {
102 switch (creature->GetEntry())
103 {
104 case NPC_ASH: uiAshGUID = creature->GetGUID(); break;
105 case NPC_ADA: uiAdaGUID = creature->GetGUID(); break;
106 case NPC_ARCHMAGE_ARUGAL: uiArchmageArugalGUID = creature->GetGUID(); break;
107 }
108 }
109
111 {
112 switch (go->GetEntry())
113 {
115 DoorCourtyardGUID = go->GetGUID();
116 if (m_auiEncounter[0] == DONE)
117 HandleGameObject(0, true, go);
118 break;
119 case GO_SORCERER_DOOR:
120 DoorSorcererGUID = go->GetGUID();
121 if (m_auiEncounter[2] == DONE)
122 HandleGameObject(0, true, go);
123 break;
124 case GO_ARUGAL_DOOR:
125 DoorArugalGUID = go->GetGUID();
126 if (m_auiEncounter[3] == DONE)
127 HandleGameObject(0, true, go);
128 break;
129 }
130 }
131
132 void DoSpeech()
133 {
134 Creature* pAda = instance->GetCreature(uiAdaGUID);
135 Creature* pAsh = instance->GetCreature(uiAshGUID);
136
137 if (pAda && pAda->IsAlive() && pAsh && pAsh->IsAlive())
138 {
139 pAda->AI()->Talk(SAY_BOSS_DIE_AD);
140 pAsh->AI()->Talk(SAY_BOSS_DIE_AS);
141 }
142 }
143
144 void SetData(uint32 type, uint32 data) OVERRIDE
145 {
146 switch (type)
147 {
148 case TYPE_FREE_NPC:
149 if (data == DONE)
151 m_auiEncounter[0] = data;
152 break;
153 case TYPE_RETHILGORE:
154 if (data == DONE)
155 DoSpeech();
156 m_auiEncounter[1] = data;
157 break;
158 case TYPE_FENRUS:
159 switch (data)
160 {
161 case DONE:
162 uiTimer = 1000;
163 uiPhase = 1;
164 break;
165 case 7:
167 break;
168 }
169 m_auiEncounter[2] = data;
170 break;
171 case TYPE_NANDOS:
172 if (data == DONE)
174 m_auiEncounter[3] = data;
175 break;
176 }
177
178 if (data == DONE)
179 {
181
182 std::ostringstream saveStream;
183 saveStream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3];
184
185 str_data = saveStream.str();
186
187 SaveToDB();
189 }
190 }
191
193 {
194 switch (type)
195 {
196 case TYPE_FREE_NPC:
197 return m_auiEncounter[0];
198 case TYPE_RETHILGORE:
199 return m_auiEncounter[1];
200 case TYPE_FENRUS:
201 return m_auiEncounter[2];
202 case TYPE_NANDOS:
203 return m_auiEncounter[3];
204 }
205 return 0;
206 }
207
208 std::string GetSaveData() OVERRIDE
209 {
210 return str_data;
211 }
212
213 void Load(const char* in) OVERRIDE
214 {
215 if (!in)
216 {
218 return;
219 }
220
222
223 std::istringstream loadStream(in);
224 loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
225
226 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
227 {
228 if (m_auiEncounter[i] == IN_PROGRESS)
230 }
231
233 }
234
235 void Update(uint32 uiDiff)
236 {
237 if (GetData(TYPE_FENRUS) != DONE)
238 return;
239
240 Creature* pArchmage = instance->GetCreature(uiArchmageArugalGUID);
241
242 if (!pArchmage || !pArchmage->IsAlive())
243 return;
244
245 if (uiPhase)
246 {
247 if (uiTimer <= uiDiff)
248 {
249 switch (uiPhase)
250 {
251 case 1:
252 {
253 Creature* summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000);
256 summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true);
257 summon->AI()->Talk(SAY_ARCHMAGE);
258 uiTimer = 2000;
259 uiPhase = 2;
260 break;
261 }
262 case 2:
263 {
268 uiPhase = 0;
269 break;
270 }
271
272 }
273 } else uiTimer -= uiDiff;
274 }
275 }
276 };
277
278};
279
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
static constexpr TempSummonType TEMPSUMMON_TIMED_DESPAWN
static constexpr TempSummonType TEMPSUMMON_CORPSE_TIMED_DESPAWN
#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)
@ REACT_DEFENSIVE
Definition Unit.h:1157
@ UNIT_FLAG_IMMUNE_TO_PC
Definition Unit.h:633
@ UNIT_FIELD_FLAGS
Creatures
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
void SetReactState(ReactStates st)
Definition Creature.h:460
CreatureAI * AI() const
Definition Creature.h:483
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
void DoUseDoorOrButton(uint64 guid, uint32 withRestoreTime=0, bool useAlternativeState=false)
void HandleGameObject(uint64 guid, bool open, GameObject *go=NULL)
Definition Map.h:238
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
uint32 GetEntry() const
Definition Object.h:125
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
bool IsAlive() const
Definition Unit.h:2032
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition Object.cpp:2703
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
const Position SpawnLocation[]
@ SPELL_ASHCROMBE_TELEPORT
void AddSC_instance_shadowfang_keep()
#define MAX_ENCOUNTER
@ TYPE_NANDOS
@ TYPE_FENRUS
@ TYPE_RETHILGORE
@ TYPE_FREE_NPC