Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
the_black_morass.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/*
7Name: The_Black_Morass
8%Complete: 30
9Comment: Misc NPC's and mobs for instance. Most here far from complete.
10Category: Caverns of Time, The Black Morass
11*/
12
13/* ContentData
14npc_medivh_bm
15npc_time_rift
16npc_saat
17EndContentData */
18
19#include "ScriptMgr.h"
20#include "ScriptedCreature.h"
21#include "ScriptedGossip.h"
22#include "the_black_morass.h"
23#include "Player.h"
24#include "SpellInfo.h"
25
27{
28 SAY_ENTER = 0, //where does this belong?
37
39 SPELL_PORTAL_RUNE = 32570, //aura(portal on ground effect)
40
41 SPELL_BLACK_CRYSTAL = 32563, //aura
42 SPELL_PORTAL_CRYSTAL = 32564, //summon
43
44 SPELL_BANISH_PURPLE = 32566, //aura
45 SPELL_BANISH_GREEN = 32567, //aura
46
49
51};
52
54{
55public:
56 npc_medivh_bm() : CreatureScript("npc_medivh_bm") { }
57
59 {
60 return new npc_medivh_bmAI(creature);
61 }
62
64 {
65 npc_medivh_bmAI(Creature* creature) : ScriptedAI(creature)
66 {
67 instance = creature->GetInstanceScript();
68 }
69
71
74
75 bool Life75;
76 bool Life50;
77 bool Life25;
78
80 {
82 Check_Timer = 0;
83 Life75 = true;
84 Life50 = true;
85 Life25 = true;
86
87 if (!instance)
88 return;
89
90 if (instance->GetData(TYPE_MEDIVH) == IN_PROGRESS)
91 DoCast(me, SPELL_CHANNEL, true);
92 else if (me->HasAura(SPELL_CHANNEL))
93 me->RemoveAura(SPELL_CHANNEL);
94
96 }
97
99
100 {
101 if (!instance)
102 return;
103
104 if (who->GetTypeId() == TypeID::TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
105 {
106 if (instance->GetData(TYPE_MEDIVH) == IN_PROGRESS || instance->GetData(TYPE_MEDIVH) == DONE)
107 return;
108
111 DoCast(me, SPELL_CHANNEL, false);
112 Check_Timer = 5000;
113 }
114 else if (who->GetTypeId() == TypeID::TYPEID_UNIT && me->IsWithinDistInMap(who, 15.0f))
115 {
116 if (instance->GetData(TYPE_MEDIVH) != IN_PROGRESS)
117 return;
118
119 uint32 entry = who->GetEntry();
121 {
122 who->StopMoving();
123 who->CastSpell(me, SPELL_CORRUPT, false);
124 }
125 else if (entry == NPC_AEONUS)
126 {
127 who->StopMoving();
128 who->CastSpell(me, SPELL_CORRUPT_AEONUS, false);
129 }
130 }
131 }
132
133 void AttackStart(Unit* /*who*/) OVERRIDE
134 {
135 //if (instance && instance->GetData(TYPE_MEDIVH) == IN_PROGRESS)
136 //return;
137
138 //ScriptedAI::AttackStart(who);
139 }
140
141 void EnterCombat(Unit* /*who*/) OVERRIDE { }
142
143 void SpellHit(Unit* /*caster*/, const SpellInfo* spell) OVERRIDE
144 {
146 return;
147
148 if (spell->Id == SPELL_CORRUPT_AEONUS)
149 SpellCorrupt_Timer = 1000;
150
151 if (spell->Id == SPELL_CORRUPT)
152 SpellCorrupt_Timer = 3000;
153 }
154
155 void JustDied(Unit* killer) OVERRIDE
156 {
157 if (killer->GetEntry() == me->GetEntry())
158 return;
159
161 }
162
164 {
165 if (!instance)
166 return;
167
169 {
170 if (SpellCorrupt_Timer <= diff)
171 {
172 instance->SetData(TYPE_MEDIVH, SPECIAL);
173
174 if (me->HasAura(SPELL_CORRUPT_AEONUS))
175 SpellCorrupt_Timer = 1000;
176 else if (me->HasAura(SPELL_CORRUPT))
177 SpellCorrupt_Timer = 3000;
178 else
180 } else SpellCorrupt_Timer -= diff;
181 }
182
183 if (Check_Timer)
184 {
185 if (Check_Timer <= diff)
186 {
187 uint32 pct = instance->GetData(DATA_SHIELD);
188
189 Check_Timer = 5000;
190
191 if (Life25 && pct <= 25)
192 {
194 Life25 = false;
195 }
196 else if (Life50 && pct <= 50)
197 {
199 Life50 = false;
200 }
201 else if (Life75 && pct <= 75)
202 {
204 Life75 = false;
205 }
206
207 //if we reach this it means event was running but at some point reset.
208 if (instance->GetData(TYPE_MEDIVH) == NOT_STARTED)
209 {
210 me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
211 me->RemoveCorpse();
212 me->Respawn();
213 return;
214 }
215
216 if (instance->GetData(TYPE_RIFT) == DONE)
217 {
218 Talk(SAY_WIN);
219 Check_Timer = 0;
220
221 if (me->HasAura(SPELL_CHANNEL))
222 me->RemoveAura(SPELL_CHANNEL);
223
225 instance->SetData(TYPE_MEDIVH, DONE);
226 }
227 } else Check_Timer -= diff;
228 }
229
230 //if (!UpdateVictim())
231 //return;
232
233 //DoMeleeAttackIfReady();
234 }
235 };
236};
237
238struct Wave
239{
240 uint32 PortalMob[4]; //spawns for portal waves (in order)
241};
242
249
251{
252public:
253 npc_time_rift() : CreatureScript("npc_time_rift") { }
254
256 {
257 return new npc_time_riftAI(creature);
258 }
259
261 {
262 npc_time_riftAI(Creature* creature) : ScriptedAI(creature)
263 {
264 instance = creature->GetInstanceScript();
265 }
266
268
273
275 {
276 TimeRiftWave_Timer = 15000;
277 mRiftWaveCount = 0;
278
279 if (!instance)
280 return;
281
283
284 if (mPortalCount < 6)
285 mWaveId = 0;
286 else if (mPortalCount > 12)
287 mWaveId = 2;
288 else mWaveId = 1;
289 }
290
291 void EnterCombat(Unit* /*who*/) OVERRIDE { }
292
293 void DoSummonAtRift(uint32 creature_entry)
294 {
295 if (!creature_entry)
296 return;
297
298 if (instance && instance->GetData(TYPE_MEDIVH) != IN_PROGRESS)
299 {
300 me->InterruptNonMeleeSpells(true);
301 me->RemoveAllAuras();
302 return;
303 }
304
305 Position pos;
306 me->GetRandomNearPosition(pos, 10.0f);
307
308 //normalize Z-level if we can, if rift is not at ground level.
309 pos.m_positionZ = std::max(me->GetMap()->GetHeight(pos.m_positionX, pos.m_positionY, MAX_HEIGHT), me->GetMap()->GetWaterLevel(pos.m_positionX, pos.m_positionY));
310
311 if (Unit* Summon = DoSummon(creature_entry, pos, 30000, TempSummonType::TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT))
312 if (Unit* temp = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_MEDIVH) : 0))
313 Summon->AddThreat(temp, 0.0f);
314 }
315
317 {
318 if ((mRiftWaveCount > 2 && mWaveId < 1) || mRiftWaveCount > 3)
319 mRiftWaveCount = 0;
320
321 uint32 entry = 0;
322
323 entry = PortalWaves[mWaveId].PortalMob[mRiftWaveCount];
324 SF_LOG_DEBUG("scripts", "npc_time_rift: summoning wave Creature (Wave %u, Entry %u).", mRiftWaveCount, entry);
325
327
328 if (entry == NPC_INFINITE_WHELP)
329 {
330 for (uint8 i = 0; i < 3; ++i)
331 DoSummonAtRift(entry);
332 } else DoSummonAtRift(entry);
333 }
334
336 {
337 if (!instance)
338 return;
339
340 if (TimeRiftWave_Timer <= diff)
341 {
343 TimeRiftWave_Timer = 15000;
344 } else TimeRiftWave_Timer -= diff;
345
346 if (me->IsNonMeleeSpellCasted(false))
347 return;
348
349 SF_LOG_DEBUG("scripts", "npc_time_rift: not casting anylonger, i need to die.");
350 me->setDeathState(DeathState::JUST_DIED);
351
352 if (instance->GetData(TYPE_RIFT) == IN_PROGRESS)
353 instance->SetData(TYPE_RIFT, SPECIAL);
354 }
355 };
356};
357
359{
362};
363
364#define GOSSIP_ITEM_OBTAIN "[PH] Obtain Chrono-Beacon"
365
367{
368public:
369 npc_saat() : CreatureScript("npc_saat") { }
370
371 bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
372 {
373 player->PlayerTalkClass->ClearMenus();
374 if (action == GOSSIP_ACTION_INFO_DEF+1)
375 {
376 player->CLOSE_GOSSIP_MENU();
377 creature->CastSpell(player, SPELL_CHRONO_BEACON, false);
378 }
379 return true;
380 }
381
382 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
383 {
384 if (creature->IsQuestGiver())
385 player->PrepareQuestMenu(creature->GetGUID());
386
387 if (player->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(ITEM_CHRONO_BEACON))
388 {
390 player->SEND_GOSSIP_MENU(10000, creature->GetGUID());
391 return true;
392 }
393 else if (player->GetQuestRewardStatus(QUEST_OPENING_PORTAL) && !player->HasItemCount(ITEM_CHRONO_BEACON))
394 {
396 player->SEND_GOSSIP_MENU(10001, creature->GetGUID());
397 return true;
398 }
399
400 player->SEND_GOSSIP_MENU(10002, creature->GetGUID());
401 return true;
402 }
403};
404
406{
407 new npc_medivh_bm();
408 new npc_time_rift();
409 new npc_saat();
410}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:46
@ IN_PROGRESS
@ DONE
@ SPECIAL
@ NOT_STARTED
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
#define MAX_HEIGHT
Definition Map.h:141
@ TYPEID_PLAYER
Definition Object.h:55
@ TYPEID_UNIT
Definition Object.h:54
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition Object.h:71
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:89
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ SPELL_SCHOOL_MASK_NORMAL
@ JUST_DIED
Definition Unit.h:504
@ DIRECT_DAMAGE
Definition Unit.h:614
@ SAY_INTRO
#define SAY_DEATH
@ SPELL_CHANNEL
Creature * DoSummon(uint32 entry, Position const &pos, uint32 despawnTime=30000, TempSummonType summonType=TempSummonType::TEMPSUMMON_CORPSE_TIMED_DESPAWN)
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
CreatureScript(const char *name)
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Definition Unit.h:1367
static Unit * GetUnit(WorldObject &object, uint64 guid)
Definition Unit.cpp:4895
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
CreatureAI * GetAI(Creature *creature) const OVERRIDE
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
float m_positionZ
Definition Object.h:289
float m_positionX
Definition Object.h:287
float m_positionY
Definition Object.h:288
Creature * me
ScriptedAI(Creature *creature)
Definition hyjalAI.h:31
uint32 PortalMob[4]
void JustDied(Unit *killer) OVERRIDE
void MoveInLineOfSight(Unit *who) OVERRIDE
void SpellHit(Unit *, const SpellInfo *spell) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void DoSummonAtRift(uint32 creature_entry)
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
#define GOSSIP_ITEM_OBTAIN
void AddSC_the_black_morass()
@ SPELL_CORRUPT
@ SAY_DEATH
@ SPELL_BLACK_CRYSTAL
@ SAY_WEAK75
@ SAY_WEAK50
@ SAY_WEAK25
@ SAY_WIN
@ SAY_ORCS_ENTER
@ C_COUNCIL_ENFORCER
@ SPELL_CHANNEL
@ SAY_ORCS_ANSWER
@ SPELL_PORTAL_CRYSTAL
@ SPELL_PORTAL_RUNE
@ SPELL_CORRUPT_AEONUS
@ SPELL_BANISH_PURPLE
@ SAY_INTRO
@ SPELL_BANISH_GREEN
static Wave PortalWaves[]
@ SPELL_CHRONO_BEACON
@ ITEM_CHRONO_BEACON
@ QUEST_OPENING_PORTAL
@ NPC_AEONUS
@ NPC_INFINITE_EXECUTIONER
@ NPC_INFINITE_WHELP
@ NPC_INFINITE_VANQUISHER
@ NPC_INFINITE_CRONOMANCER
@ NPC_INFINITE_ASSASIN
@ DATA_MEDIVH
@ DATA_PORTAL_COUNT
@ TYPE_MEDIVH
@ TYPE_RIFT
@ DATA_SHIELD