TrinityCore
Loading...
Searching...
No Matches
the_black_morass.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 "InstanceScript.h"
20#include "Log.h"
21#include "Map.h"
22#include "ObjectAccessor.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "ScriptedGossip.h"
26#include "SpellInfo.h"
27#include "the_black_morass.h"
28
30{
39
41 SPELL_PORTAL_RUNE = 32570, // aura(portal on ground effect)
42
43 SPELL_BLACK_CRYSTAL = 32563, // aura
44 SPELL_PORTAL_CRYSTAL = 32564, // summon
45
46 SPELL_BANISH_PURPLE = 32566, // aura
47 SPELL_BANISH_GREEN = 32567, // aura
48
51
52 // NYI
62
67
73
95
99
101
102 C_COUNCIL_ENFORCER = 17023
104
106{
107 npc_medivh_bm(Creature* creature) : ScriptedAI(creature)
108 {
109 Initialize();
110 instance = creature->GetInstanceScript();
111 }
112
114 {
116 Check_Timer = 0;
117 Life75 = true;
118 Life50 = true;
119 Life25 = true;
120 }
121
123
126
127 bool Life75;
128 bool Life50;
129 bool Life25;
130
131 void Reset() override
132 {
133 Initialize();
134
136 DoCast(me, SPELL_CHANNEL, true);
137 else if (me->HasAura(SPELL_CHANNEL))
139 }
140
141 void MoveInLineOfSight(Unit* who) override
142 {
143 if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
144 {
146 return;
147
150 DoCast(me, SPELL_CHANNEL, false);
151 Check_Timer = 5000;
152 }
153 else if (who->GetTypeId() == TYPEID_UNIT && me->IsWithinDistInMap(who, 15.0f))
154 {
156 return;
157
158 uint32 entry = who->GetEntry();
160 {
161 who->StopMoving();
162 who->CastSpell(me, SPELL_CORRUPT, false);
163 }
164 else if (entry == NPC_AEONUS)
165 {
166 who->StopMoving();
167 who->CastSpell(me, SPELL_CORRUPT_AEONUS, false);
168 }
169 }
170 }
171
172 void AttackStart(Unit* /*who*/) override
173 {
174 //if (instance->GetData(TYPE_MEDIVH) == IN_PROGRESS)
175 // return;
176
177 //ScriptedAI::AttackStart(who);
178 }
179
180 void JustEngagedWith(Unit* /*who*/) override { }
181
182 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
183 {
185 return;
186
187 if (spellInfo->Id == SPELL_CORRUPT_AEONUS)
188 SpellCorrupt_Timer = 1000;
189
190 if (spellInfo->Id == SPELL_CORRUPT)
191 SpellCorrupt_Timer = 3000;
192 }
193
194 void JustDied(Unit* killer) override
195 {
196 if (killer && killer->GetEntry() == me->GetEntry())
197 return;
198
200 }
201
202 void UpdateAI(uint32 diff) override
203 {
205 {
206 if (SpellCorrupt_Timer <= diff)
207 {
209
211 SpellCorrupt_Timer = 1000;
212 else if (me->HasAura(SPELL_CORRUPT))
213 SpellCorrupt_Timer = 3000;
214 else
216 } else SpellCorrupt_Timer -= diff;
217 }
218
219 if (Check_Timer)
220 {
221 if (Check_Timer <= diff)
222 {
224
225 Check_Timer = 5000;
226
227 if (Life25 && pct <= 25)
228 {
230 Life25 = false;
231 }
232 else if (Life50 && pct <= 50)
233 {
235 Life50 = false;
236 }
237 else if (Life75 && pct <= 75)
238 {
240 Life75 = false;
241 }
242
243 //if we reach this it means event was running but at some point reset.
245 {
247 me->Respawn();
248 return;
249 }
250
252 {
253 Talk(SAY_WIN);
254 Check_Timer = 0;
255
258
261 }
262 } else Check_Timer -= diff;
263 }
264
265 //if (!UpdateVictim())
266 //return;
267
268 //DoMeleeAttackIfReady();
269 }
270};
271
272struct Wave
273{
274 uint32 PortalMob[4]; //spawns for portal waves (in order)
275};
276
283
285{
286 npc_time_rift(Creature* creature) : ScriptedAI(creature)
287 {
288 Initialize();
289 instance = creature->GetInstanceScript();
290 }
291
293 {
294 TimeRiftWave_Timer = 15000;
295 mRiftWaveCount = 0;
296 mWaveId = 0;
297 }
298
300
304
305 void Reset() override
306 {
307 Initialize();
308
309 uint8 mPortalCount = instance->GetData(DATA_PORTAL_COUNT);
310
311 if (mPortalCount < 6)
312 mWaveId = 0;
313 else if (mPortalCount > 12)
314 mWaveId = 2;
315 else mWaveId = 1;
316
317 }
318 void JustEngagedWith(Unit* /*who*/) override { }
319
320 void DoSummonAtRift(uint32 creature_entry)
321 {
322 if (!creature_entry)
323 return;
324
326 {
329 return;
330 }
331
332 Position pos = me->GetRandomNearPosition(10.0f);
333
334 //normalize Z-level if we can, if rift is not at ground level.
336
337 if (Unit* Summon = DoSummon(creature_entry, pos, 30s, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT))
339 AddThreat(temp, 0.0f, Summon);
340 }
341
343 {
344 if ((mRiftWaveCount > 2 && mWaveId < 1) || mRiftWaveCount > 3)
345 mRiftWaveCount = 0;
346
347 uint32 entry = 0;
348
350 TC_LOG_DEBUG("scripts", "npc_time_rift: summoning wave Creature (Wave {}, Entry {}).", mRiftWaveCount, entry);
351
353
354 if (entry == NPC_INFINITE_WHELP)
355 {
356 for (uint8 i = 0; i < 3; ++i)
357 DoSummonAtRift(entry);
358 } else DoSummonAtRift(entry);
359 }
360
361 void UpdateAI(uint32 diff) override
362 {
363 if (TimeRiftWave_Timer <= diff)
364 {
366 TimeRiftWave_Timer = 15000;
367 } else TimeRiftWave_Timer -= diff;
368
369 if (me->IsNonMeleeSpellCast(false))
370 return;
371
372 TC_LOG_DEBUG("scripts", "npc_time_rift: not casting anylonger, i need to die.");
374
377 }
378};
379
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ IN_PROGRESS
@ DONE
@ SPECIAL
@ NOT_STARTED
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
#define MAX_HEIGHT
Definition Map.h:240
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
@ TYPEID_UNIT
Definition ObjectGuid.h:38
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ JUST_DIED
Definition Unit.h:212
Creature *const me
Definition CreatureAI.h:82
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
void Respawn(bool force=false)
void setDeathState(DeathState s) override
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
virtual ObjectGuid GetGuidData(uint32 type) const override
float GetWaterLevel(float x, float y) const
Definition Map.cpp:2862
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.cpp:2484
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
uint32 Id
Definition SpellInfo.h:289
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3638
void StopMoving(bool force=false)
Definition Unit.cpp:10312
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3093
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:3063
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
void RemoveAllAuras()
Definition Unit.cpp:4157
Map * GetMap() const
Definition Object.h:449
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
Position GetRandomNearPosition(float radius)
Definition Object.cpp:3264
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:55
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:56
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
float m_positionZ
Definition Position.h:58
float m_positionX
Definition Position.h:56
float m_positionY
Definition Position.h:57
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
Definition hyjalAI.h:47
uint32 PortalMob[4]
void Reset() override
npc_medivh_bm(Creature *creature)
void JustEngagedWith(Unit *) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void JustDied(Unit *killer) override
InstanceScript * instance
void MoveInLineOfSight(Unit *who) override
void AttackStart(Unit *) override
void UpdateAI(uint32 diff) override
InstanceScript * instance
void DoSummonAtRift(uint32 creature_entry)
void JustEngagedWith(Unit *) override
npc_time_rift(Creature *creature)
void UpdateAI(uint32 diff) override
void Reset() override
void AddSC_the_black_morass()
@ SPELL_CORRUPT
@ SAY_DEATH
@ SPELL_SUMMON_INFINITE_CHRONO_LORD
@ SPELL_BLACK_CRYSTAL
@ SPELL_TIME_RIFT_3_READY
@ SPELL_TIME_RIFT_1_READY
@ SPELL_SUMMON_RIFT_KEEPER
@ SAY_WEAK75
@ SAY_WEAK50
@ SPELL_SUMMON_INFINITE_CHRONOMANCER
@ SPELL_TIME_RIFT_4_READY
@ SAY_WEAK25
@ SPELL_SUMMON_RIFT_LORD_2
@ SPELL_TIME_RIFT_CHANNEL
@ SAY_WIN
@ SPELL_SUMMON_TIME_RIFT_EFFECT_1
@ SPELL_MEDIVH_SHIELD
@ SPELL_SUMMON_TIME_RIFT
@ SPELL_SUMMON_TIME_RIFT_PERIODIC_5
@ SPELL_SUMMON_TEMPORUS
@ SAY_ORCS_ENTER
@ SPELL_TIME_RIFT_CHANNEL_TRIGGER
@ SPELL_SUMMON_INFINITE_EXECUTIONER
@ C_COUNCIL_ENFORCER
@ SPELL_TIME_RIFT_PERIODIC
@ SPELL_CHANNEL
@ SPELL_SUMMON_RIFT_KEEPER_2
@ SPELL_SUMMON_INFINITE_ASSASSIN
@ SPELL_SUMMON_TIME_RIFT_PERIODIC_75
@ SAY_ORCS_ANSWER
@ SPELL_SUMMON_TIME_RIFT_EFFECT_2
@ SPELL_SUMMON_TIME_RIFT_PERIODIC_90
@ SPELL_SUMMON_INFINITE_VANQUISHER
@ SPELL_SUMMON_INFINITE_TIMEREAVER
@ SPELL_PORTAL_CRYSTAL
@ SPELL_PORTAL_RUNE
@ SPELL_SUMMON_INFINITE_ASSASSIN_2
@ SPELL_TIME_RIFT_2_READY
@ SPELL_SUMMON_INFINITE_EXECUTIONER_2
@ SPELL_SUMMON_TIME_RIFT_EFFECT_4
@ SPELL_THE_BLACK_MORASS_COMPLETE
@ SPELL_CLOSE_TIME_RIFT_EFFECT
@ SPELL_MEDIVH_DIES
@ SPELL_CORRUPT_AEONUS
@ SPELL_CLOSE_TIME_RIFT_TRIGGER
@ SPELL_SUMMON_INFINITE_WHELP
@ SPELL_SUMMON_TIME_RIFT_PERIODIC_30
@ SAY_ENTER
@ SPELL_SUMMON_AEONUS
@ SPELL_SUMMON_RIFT_LORD
@ SPELL_BANISH_PURPLE
@ SPELL_SUMMON_INFINITE_CHRONOMANCER_2
@ SPELL_SUMMON_TIME_RIFT_EFFECT_3
@ SPELL_SUMMON_INFINITE_VANQUISHER_2
@ SPELL_SUMMON_TIME_RIFT_PERIODIC_120
@ SPELL_TIME_RIFT_READY_PRIMER
@ SPELL_SUMMON_TIME_RIFT_PERIODIC_45
@ SPELL_SUMMON_CHRONO_LORD_DEJA
@ SPELL_BANISH_GREEN
@ SPELL_MEDIVH_LIVES
static Wave PortalWaves[]
@ 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
#define RegisterBlackMorassCreatureAI(ai_name)