TrinityCore
Loading...
Searching...
No Matches
boss_mograine_and_whitemane.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 "scarlet_monastery.h"
19#include "InstanceScript.h"
20#include "MotionMaster.h"
21#include "ScriptedCreature.h"
22#include "ScriptMgr.h"
23#include "SpellAuras.h"
24#include "SpellInfo.h"
25#include "Timer.h"
26
28{
29 // Mograine
33
34 // Whitemaine
38};
39
56
68
73
74Position const WhitemaneIntroMovePos = { 1163.113370f, 1398.856812f, 32.527786f, 0.f };
75
76// Scarlet Commander Mograine - 3976
78{
79public:
84
86 {
87 _fakeDeath = false;
88 _canDie = true;
89 }
90
105
106 void JustEngagedWith(Unit* who) override
107 {
109
111
112 // Call for help (from old script)
114
115 // Just to be sure it's MOTION_SLOT_DEFAULT is static
117
118 // Schedule events
121 }
122
123 void KilledUnit(Unit* who) override
124 {
125 if (who->GetTypeId() != TYPEID_PLAYER)
126 return;
127
129 {
132 }
133 }
134
135 void ExecuteEvent(uint32 eventId) override
136 {
137 switch (eventId)
138 {
141 events.Repeat(10s);
142 break;
145 events.Repeat(60s);
146 break;
147 default:
148 break;
149 }
150 }
151
152 void DamageTaken(Unit* /*who*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
153 {
154 if (damage >= me->GetHealth() && !_fakeDeath)
155 {
156 _fakeDeath = true;
157 _canDie = false;
158
159 // Open the door
161
162 // Tell whitemane to move
163 if (Creature* whitemane = instance->GetCreature(DATA_WHITEMANE))
164 {
165 whitemane->GetMotionMaster()->MovePoint(0, WhitemaneIntroMovePos);
166 DoZoneInCombat(whitemane);
167 }
168
175 me->SetReactState(REACT_PASSIVE); // prevent Mograine from attacking while fake death
176
177 // Stop moving
179 }
180
181 if (!_canDie && damage >= me->GetHealth())
182 damage = 0;
183 }
184
185 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
186 {
187 // Casted from Whitemane
188 if (spellInfo->Id == SPELL_SCARLET_RESURRECTION)
189 {
190 scheduler.Schedule(3s, [this](TaskContext /*context*/)
191 {
192 // Say text
194
197 });
198
199 scheduler.Schedule(5s, [this](TaskContext /*context*/)
200 {
201 // Schedule events after ressurrect
204
205 // We can now die
208 _canDie = true;
210 });
211 }
212 }
213
214 void UpdateAI(uint32 diff) override
215 {
216 if (!UpdateVictim())
217 return;
218
219 events.Update(diff);
220 scheduler.Update(diff);
221
223 return;
224
225 while (uint32 eventId = events.ExecuteEvent())
226 {
227 ExecuteEvent(eventId);
229 return;
230 }
231
233 }
234
235private:
239};
240
241// High Inquisitor Whitemane - 3977
243{
244public:
245 boss_high_inquisitor_whitemane(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _killYellTimer(0s)
246 {
247 Initialize();
248 }
249
251 {
253 _canDie = true;
254 }
255
256 void Reset() override
257 {
258 Initialize();
259
260 _events.Reset();
263
266 }
267
268 void JustEngagedWith(Unit* /*who*/) override
269 {
271
272 // Just to be sure it's MOTION_SLOT_DEFAULT is static
274
275 // Start events after 5 seconds
276 _scheduler.Schedule(5s, [this](TaskContext /*context*/)
277 {
281 });
282 }
283
284 void KilledUnit(Unit* who) override
285 {
286 if (who->GetTypeId() != TYPEID_PLAYER)
287 return;
288
290 {
293 }
294 }
295
296 void UpdateAI(const uint32 diff) override
297 {
298 if (!UpdateVictim())
299 return;
300
301 _events.Update(diff);
302 _scheduler.Update(diff);
303
304 if (!_killYellTimer.Passed())
306
308 return;
309
310 while (uint32 eventId = _events.ExecuteEvent())
311 {
312 switch (eventId)
313 {
314 case EVENT_HEAL:
315 {
316 Creature* target = nullptr;
317 if (HealthBelowPct(75))
318 target = me;
320 {
321 if (mograine->IsAlive() && mograine->HealthBelowPct(75))
322 target = mograine;
323 }
324
325 if (target)
326 DoCast(target, SPELL_HEAL);
327
328 _events.Repeat(13s);
329 break;
330 }
333 _events.Repeat(15s);
334 break;
335 case EVENT_HOLY_SMITE:
337 _events.Repeat(6s);
338 break;
339 default:
340 break;
341 }
342
344 return;
345 }
346
349 }
350
351 void DamageTaken(Unit* /*who*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
352 {
353 // When Whitemane falls below 50% cast Deep sleep and schedule to ressurrect
355 {
357 _canDie = false;
358
359 // Cancel all combat events
363
365
366 // Sleep all players
368
370 {
373
374 Position movePosition = mograine->GetPosition();
375
376 // Get a position within 2 yards of mograine, and facing him
377 me->MovePosition(movePosition, 2.0f, me->GetRelativeAngle(movePosition));
379 }
380 }
381
382 if (!_canDie && damage >= me->GetHealth())
383 damage = 0;
384 }
385
386 void MovementInform(uint32 type, uint32 id) override
387 {
389 return;
390
393
394 // After 3 seconds cast scarlet ressurection
395 _scheduler.Schedule(3s, [this](TaskContext /*context*/)
396 {
399 else
401 });
402 }
403
404 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
405 {
406 if (target->GetEntry() == NPC_MOGRAINE && spellInfo->Id == SPELL_SCARLET_RESURRECTION)
408 }
409
410private:
412 {
414
415 // Schedule events again
419
420 _canDie = true;
421
423
424 if (me->GetVictim())
426 }
427
434};
435
uint32_t uint32
Definition Define.h:133
@ MOTION_PRIORITY_NORMAL
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
#define VISIBLE_RANGE
Definition ScriptMgr.h:91
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STAND_STATE_DEAD
Definition UnitDefines.h:41
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:34
@ UNIT_FLAG_NON_ATTACKABLE
@ UNIT_FLAG_UNINTERACTIBLE
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
Position const WhitemaneIntroMovePos
void AddSC_boss_mograine_and_whitemane()
@ POINT_WHITEMANE_MOVE_TO_MOGRAINE
mograine
Definition chapter5.cpp:33
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void CallForHelp(float fRadius)
bool HasReactState(ReactStates state) const
Definition Creature.h:121
void SetReactState(ReactStates st)
Definition Creature.h:119
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void CancelEvent(EventId eventId)
Definition EventMap.cpp:151
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
Creature * GetCreature(uint32 type)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
GameObject * GetGameObject(uint32 type)
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
static ObjectGuid const Empty
Definition ObjectGuid.h:140
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
uint32 Id
Definition SpellInfo.h:289
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3093
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
void ClearComboPointHolders()
Definition Unit.cpp:10528
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13259
void ClearAllReactives()
Definition Unit.cpp:10534
uint32 GetHealth() const
Definition Unit.h:913
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
void SetStandState(UnitStandStateType state)
Definition Unit.cpp:10363
void RemoveAllAuras()
Definition Unit.cpp:4157
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:955
void MovePosition(Position &pos, float dist, float angle)
Definition Object.cpp:3277
@ DATA_MOGRAINE
@ DATA_WHITEMANE
@ DATA_MOGRAINE_AND_WHITE_EVENT
@ DATA_HIGH_INQUISITORS_DOOR
#define RegisterScarletMonasteryCreatureAI(ai)
@ NPC_MOGRAINE
float GetRelativeAngle(float x, float y) const
Definition Position.h:139
void GetPosition(float &x, float &y) const
Definition Position.h:84
bool HealthBelowPct(uint32 pct) const
void Update(int32 diff)
Definition Timer.h:121
bool Passed() const
Definition Timer.h:131
void Reset(int32 expiry)
Definition Timer.h:136
void UpdateAI(const uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void MovementInform(uint32 type, uint32 id) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override