TrinityCore
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 "ScriptedCreature.h"
24#include "SpellInfo.h"
25#include "the_black_morass.h"
26
28{
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
50 // NYI
60
65
71
93
97
99
100 C_COUNCIL_ENFORCER = 17023
102
104{
105 npc_medivh_bm(Creature* creature) : ScriptedAI(creature)
106 {
107 Initialize();
108 instance = creature->GetInstanceScript();
109 }
110
112 {
114 Check_Timer = 0;
115 Life75 = true;
116 Life50 = true;
117 Life25 = true;
118 }
119
121
124
125 bool Life75;
126 bool Life50;
127 bool Life25;
128
129 void Reset() override
130 {
131 Initialize();
132
134 DoCast(me, SPELL_CHANNEL, true);
135 else if (me->HasAura(SPELL_CHANNEL))
137 }
138
139 void MoveInLineOfSight(Unit* who) override
140 {
141 if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
142 {
144 return;
145
148 DoCast(me, SPELL_CHANNEL, false);
149 Check_Timer = 5000;
150 }
151 else if (who->GetTypeId() == TYPEID_UNIT && me->IsWithinDistInMap(who, 15.0f))
152 {
154 return;
155
156 uint32 entry = who->GetEntry();
158 {
159 who->StopMoving();
160 who->CastSpell(me, SPELL_CORRUPT, false);
161 }
162 else if (entry == NPC_AEONUS)
163 {
164 who->StopMoving();
165 who->CastSpell(me, SPELL_CORRUPT_AEONUS, false);
166 }
167 }
168 }
169
170 void AttackStart(Unit* /*who*/) override
171 {
172 //if (instance->GetData(TYPE_MEDIVH) == IN_PROGRESS)
173 // return;
174
175 //ScriptedAI::AttackStart(who);
176 }
177
178 void JustEngagedWith(Unit* /*who*/) override { }
179
180 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
181 {
183 return;
184
185 if (spellInfo->Id == SPELL_CORRUPT_AEONUS)
186 SpellCorrupt_Timer = 1000;
187
188 if (spellInfo->Id == SPELL_CORRUPT)
189 SpellCorrupt_Timer = 3000;
190 }
191
192 void JustDied(Unit* killer) override
193 {
194 if (killer && killer->GetEntry() == me->GetEntry())
195 return;
196
198 }
199
200 void UpdateAI(uint32 diff) override
201 {
203 {
204 if (SpellCorrupt_Timer <= diff)
205 {
207
209 SpellCorrupt_Timer = 1000;
210 else if (me->HasAura(SPELL_CORRUPT))
211 SpellCorrupt_Timer = 3000;
212 else
214 } else SpellCorrupt_Timer -= diff;
215 }
216
217 if (Check_Timer)
218 {
219 if (Check_Timer <= diff)
220 {
222
223 Check_Timer = 5000;
224
225 if (Life25 && pct <= 25)
226 {
228 Life25 = false;
229 }
230 else if (Life50 && pct <= 50)
231 {
233 Life50 = false;
234 }
235 else if (Life75 && pct <= 75)
236 {
238 Life75 = false;
239 }
240
241 //if we reach this it means event was running but at some point reset.
243 {
245 me->Respawn();
246 return;
247 }
248
250 {
251 Talk(SAY_WIN);
252 Check_Timer = 0;
253
256
259 }
260 } else Check_Timer -= diff;
261 }
262
263 //if (!UpdateVictim())
264 //return;
265
266 //DoMeleeAttackIfReady();
267 }
268};
269
270struct Wave
271{
272 uint32 PortalMob[4]; //spawns for portal waves (in order)
273};
274
276{
280};
281
283{
284 npc_time_rift(Creature* creature) : ScriptedAI(creature)
285 {
286 Initialize();
287 instance = creature->GetInstanceScript();
288 }
289
291 {
292 TimeRiftWave_Timer = 15000;
293 mRiftWaveCount = 0;
294 mWaveId = 0;
295 }
296
298
302
303 void Reset() override
304 {
305 Initialize();
306
307 uint8 mPortalCount = instance->GetData(DATA_PORTAL_COUNT);
308
309 if (mPortalCount < 6)
310 mWaveId = 0;
311 else if (mPortalCount > 12)
312 mWaveId = 2;
313 else mWaveId = 1;
314
315 }
316 void JustEngagedWith(Unit* /*who*/) override { }
317
318 void DoSummonAtRift(uint32 creature_entry)
319 {
320 if (!creature_entry)
321 return;
322
324 {
327 return;
328 }
329
330 Position pos = me->GetRandomNearPosition(10.0f);
331
332 //normalize Z-level if we can, if rift is not at ground level.
334
335 if (Unit* Summon = DoSummon(creature_entry, pos, 30s, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT))
337 AddThreat(temp, 0.0f, Summon);
338 }
339
341 {
342 if ((mRiftWaveCount > 2 && mWaveId < 1) || mRiftWaveCount > 3)
343 mRiftWaveCount = 0;
344
345 uint32 entry = 0;
346
348 TC_LOG_DEBUG("scripts", "npc_time_rift: summoning wave Creature (Wave {}, Entry {}).", mRiftWaveCount, entry);
349
351
352 if (entry == NPC_INFINITE_WHELP)
353 {
354 for (uint8 i = 0; i < 3; ++i)
355 DoSummonAtRift(entry);
356 } else DoSummonAtRift(entry);
357 }
358
359 void UpdateAI(uint32 diff) override
360 {
361 if (TimeRiftWave_Timer <= diff)
362 {
364 TimeRiftWave_Timer = 15000;
365 } else TimeRiftWave_Timer -= diff;
366
367 if (me->IsNonMeleeSpellCast(false))
368 return;
369
370 TC_LOG_DEBUG("scripts", "npc_time_rift: not casting anylonger, i need to die.");
372
375 }
376};
377
379{
382}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
#define MAX_HEIGHT
Definition: GridDefines.h:60
@ IN_PROGRESS
@ DONE
@ SPECIAL
@ NOT_STARTED
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition: ObjectDefines.h:66
@ TYPEID_UNIT
Definition: ObjectGuid.h:40
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ JUST_DIED
Definition: Unit.h:247
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
Definition: CreatureAI.cpp:464
void Respawn(bool force=false)
Definition: Creature.cpp:2303
void setDeathState(DeathState s) override
Definition: Creature.cpp:2197
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
virtual ObjectGuid GetGuidData(uint32 type) const override
float GetHeight(PhaseShift const &phaseShift, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition: Map.h:290
float GetWaterLevel(PhaseShift const &phaseShift, float x, float y)
Definition: Map.cpp:1762
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
uint32 const Id
Definition: SpellInfo.h:325
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3685
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:3059
void StopMoving()
Definition: Unit.cpp:10049
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
void RemoveAllAuras()
Definition: Unit.cpp:4242
Map * GetMap() const
Definition: Object.h:624
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
PhaseShift & GetPhaseShift()
Definition: Object.h:523
Position GetRandomNearPosition(float radius)
Definition: Object.cpp:3423
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1147
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:91
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
float m_positionZ
Definition: Position.h:55
float m_positionX
Definition: Position.h:53
float m_positionY
Definition: Position.h:54
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
== Triggered Actions Requested ==================
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)