TrinityCore
boss_mandokir.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 "zulgurub.h"
19#include "Containers.h"
20#include "GridNotifiers.h"
21#include "InstanceScript.h"
22#include "ObjectAccessor.h"
23#include "MotionMaster.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "ScriptMgr.h"
27#include "SpellAuraEffects.h"
28#include "SpellScript.h"
29
31{
39 SAY_DEATH = 7
40};
41
43{
44 // Bloodlord Mandokir
52 SPELL_FRENZY = 96800,
58
59 // Chained Spirit
60 SPELL_REVIVE = 96484,
61
62 // Ohgan
68};
69
71{
72 // Bloodlord Mandokir
79};
80
82{
83 // Bloodlord Mandokir
86
87 // Chained Spirit
89};
90
91enum Misc
92{
94
96
97};
98
100{
103
104struct boss_mandokir : public BossAI
105{
107 {
108 Initialize();
109 }
110
112 {
113 _ohganotSoFast = true;
115 }
116
117 void Reset() override
118 {
120
121 _Reset();
122
124 Initialize();
126 }
127
128 void JustEngagedWith(Unit* who) override
129 {
132
134
135 if (!summons.empty())
136 {
137 for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
138 {
139 if (Creature* chainedSpirit = ObjectAccessor::GetCreature(*me, *itr))
140 if (chainedSpirit->GetEntry() == NPC_CHAINED_SPIRIT && chainedSpirit->AI())
141 chainedSpirit->SetFaction(FACTION_NONE);
142 }
143 }
144
149 }
150
151 void JustDied(Unit* /*killer*/) override
152 {
154 _JustDied();
156 }
157
158 void KilledUnit(Unit* victim) override
159 {
160 if (victim->GetTypeId() == TYPEID_PLAYER)
161 {
164 _reviveGUID = victim->GetGUID();
166 }
167 }
168
169 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
170 {
171 if (me->HealthBelowPctDamaged(20, damage) && !me->HasAura(SPELL_FRENZY))
172 {
173 DoCast(me, SPELL_FRENZY, true);
176 }
177 }
178
179 void DoAction(int32 action) override
180 {
181 switch (action)
182 {
185 _ohganotSoFast = false;
186 break;
188 {
189 std::list<Creature*> creatures;
191 creatures.remove_if(Trinity::AnyDeadUnitCheck());
192 creatures.remove_if(Trinity::UnitAuraCheck(true, SPELL_OHGAN_ORDERS_TRIGGER));
194 if (creatures.empty())
195 return;
196
197 for (std::list<Creature*>::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
198 {
199 if (Creature* chainedSpirit = ObjectAccessor::GetCreature(*me, (*itr)->GetGUID()))
200 {
201 chainedSpirit->AI()->SetGUID(_reviveGUID);
202 chainedSpirit->AI()->DoAction(ACTION_REVIVE);
204 }
205 }
206 break;
207 }
208 default:
209 break;
210
211 }
212 }
213
214 uint32 GetData(uint32 type) const override
215 {
216 if (type == DATA_OHGANOT_SO_FAST)
217 return _ohganotSoFast;
218
219 return 0;
220 }
221
222 void SetGUID(ObjectGuid const& guid, int32 /*type = 0 */) override
223 {
224 _reviveGUID = guid;
225 }
226
227 void UpdateAI(uint32 diff) override
228 {
229 if (!UpdateVictim())
230 return;
231
232 events.Update(diff);
233
235 return;
236
237 while (uint32 eventId = events.ExecuteEvent())
238 {
239 switch (eventId)
240 {
244 break;
245 case EVENT_DECAPITATE:
248 break;
250 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
251 {
252 DoCast(target, SPELL_BLOODLETTING, true);
254 }
256 break;
260 else
261 {
264 // Cooldown
267 }
268 break;
271 break;
275 break;
276 default:
277 break;
278 }
279
281 return;
282 }
283 }
284
285private:
289};
290
291struct npc_ohgan : public ScriptedAI
292{
293 npc_ohgan(Creature* creature) : ScriptedAI(creature)
294 {
296 }
297
298 void JustEngagedWith(Unit* /*who*/) override
299 {
301 }
302
303 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
304 {
305 if (damage >= me->GetHealth())
306 {
307 damage = 0;
308 me->AttackStop();
309 me->SetHealth(0);
311 DoCast(me, SPELL_CLEAR_ALL, true);
313
315 mandokir->AI()->DoAction(ACTION_OHGAN_IS_DEATH);
316 }
317 }
318
319 void KilledUnit(Unit* victim) override
320 {
321 if (Creature* creature = victim->ToCreature())
322 {
323 if (creature->GetEntry() == NPC_CHAINED_SPIRIT)
325 }
326 }
327
328private:
330};
331
333{
335 {
338 me->SetReactState(REACT_PASSIVE); // correct?
339 }
340
341 void Reset() override
342 {
344 }
345
346 void SetGUID(ObjectGuid const& guid, int32 /*type = 0 */) override
347 {
348 _revivePlayerGUID = guid;
349 }
350
351 void DoAction(int32 action) override
352 {
353 if (action == ACTION_REVIVE)
354 {
355 Position pos;
357 {
358 target->GetNearPoint(me, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 5.0f, target->GetAbsoluteAngle(me));
360 }
361 }
362 }
363
364 void MovementInform(uint32 type, uint32 pointId) override
365 {
366 if (type != POINT_MOTION_TYPE || !_revivePlayerGUID)
367 return;
368
369 if (pointId == POINT_START_REVIVE)
370 {
372 DoCast(target, SPELL_REVIVE);
373
375 }
376 }
377
378 void JustDied(Unit* /*killer*/) override
379 {
381 if (!target || target->IsAlive())
382 return;
383
385 {
386 mandokir->GetAI()->SetGUID(target->GetGUID());
387 mandokir->GetAI()->DoAction(ACTION_START_REVIVE);
388 }
389
391 }
392
393 void UpdateAI(uint32 /*diff*/) override { }
394
395private:
398};
399
400// 96682 - Decapitate
402{
403 void FilterTargets(std::list<WorldObject*>& targets)
404 {
405 if (targets.empty())
406 return;
407
409 targets.clear();
410 targets.push_back(target);
411 }
412
413 void HandleScript(SpellEffIndex /*effIndex*/)
414 {
415 Unit* caster = GetCaster();
416 if (Player* target = GetHitPlayer())
417 caster->CastSpell(target, uint32(GetEffectValue()), true);
418 }
419
420 void Register() override
421 {
424 }
425};
426
427// 96776 - Bloodletting
429{
430 bool Validate(SpellInfo const* /*spell*/) override
431 {
433 }
434
436 {
437 Unit* target = GetTarget();
438 Unit* caster = GetCaster();
439 if (!caster)
440 return;
441
444 args.AddSpellMod(SPELLVALUE_BASE_POINT0, std::max<int32>(7500, target->CountPctFromCurHealth(aurEff->GetAmount())));
445
446 caster->CastSpell(target, SPELL_BLOODLETTING_DAMAGE, args);
447 target->CastSpell(caster, SPELL_BLOODLETTING_HEAL, args);
448 }
449
450 void Register() override
451 {
453 }
454};
455
456// 96821 - Spirit's Vengeance Cancel
458{
459 void HandleScript(SpellEffIndex /*effIndex*/)
460 {
461 if (Player* target = GetHitPlayer())
462 target->RemoveAura(uint32(GetEffectValue()));
463 }
464
465 void Register() override
466 {
469 }
470};
471
473{
474 public:
475 DevastatingSlamTargetSelector(Creature* me, const Unit* victim) : _me(me), _victim(victim) {}
476
478 {
479 if (target == _victim && _me->GetThreatManager().GetThreatListSize() > 1)
480 return true;
481
482 if (target->GetTypeId() != TYPEID_PLAYER)
483 return true;
484
485 return false;
486 }
487
489 Unit const* _victim;
490};
491
492// 96761 - Devastating Slam
494{
495 void FilterTargets(std::list<WorldObject*>& targets)
496 {
497 targets.remove_if(DevastatingSlamTargetSelector(GetCaster()->ToCreature(), GetCaster()->GetVictim()));
498 if (targets.empty())
499 return;
500
502 targets.clear();
503 targets.push_back(target);
504 }
505
506 void HandleScript(SpellEffIndex /*effIndex*/)
507 {
508 Unit* caster = GetCaster();
509 float angle = 0.0f;
510 float x, y, z;
511
512 if (Player* target = GetHitPlayer())
513 {
514 caster->AttackStop();
515 caster->SetOrientation(caster->GetAbsoluteAngle(target));
516 caster->SetFacingTo(caster->GetAbsoluteAngle(target));
517
518 caster->CastSpell(caster, SPELL_DEVASTATING_SLAM, false);
519
520 // HACK: Need better way for pos calculation
521 for (uint8 i = 0; i <= 50; ++i)
522 {
523 angle = rand_norm() * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
524 caster->GetClosePoint(x, y, z, 4.0f, frand(-2.5f, 50.0f), angle);
525
526 caster->CastSpell(Position{ x, y, z }, SPELL_DEVASTATING_SLAM_DAMAGE, true);
527 }
528 }
529 }
530
531 void Register() override
532 {
535 }
536};
537
538// 96721 - Ohgan's Orders
540{
541 void FilterTargets(std::list<WorldObject*>& targets)
542 {
543 if (targets.empty())
544 return;
545
547 targets.clear();
548 targets.push_back(target);
549 }
550
551 void HandleScript(SpellEffIndex /*effIndex*/)
552 {
553 Unit* caster = GetCaster();
554 if (Unit* target = GetHitUnit())
555 caster->CastSpell(target, uint32(GetEffectValue()), true);
556 }
557
558 void Register() override
559 {
562 }
563};
564
565// 96722 - Ohgan's Orders
567{
568 void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
569 {
570 Unit* target = GetTarget();
571 if (Unit* caster = GetCaster())
572 {
573 // HACK: research better way
574 caster->ClearUnitState(UNIT_STATE_CASTING);
575 caster->GetMotionMaster()->Clear();
576 caster->GetThreatManager().ResetAllThreat();
577 caster->GetThreatManager().AddThreat(target, 50000000.0f);
578 // TODO: Fixate mechanic
579 }
580 }
581
582 void Register() override
583 {
585 }
586};
587
588// 96724 - Reanimate Ohgan
590{
591 void HandleScript(SpellEffIndex /*effIndex*/)
592 {
593 if (Unit* target = GetHitUnit())
594 {
595 target->RemoveAura(SPELL_PERMANENT_FEIGN_DEATH);
596 target->CastSpell(target, SPELL_OHGAN_HEART_VISUAL, true);
597 target->CastSpell(nullptr, SPELL_OHGAN_ORDERS, true);
598 }
599 }
600
601 void Register() override
602 {
604 }
605};
606
608{
609 public:
610 achievement_ohganot_so_fast() : AchievementCriteriaScript("achievement_ohganot_so_fast") { }
611
612 bool OnCheck(Player* /*player*/, Unit* target) override
613 {
614 return target && target->GetAI()->GetData(DATA_OHGANOT_SO_FAST);
615 }
616};
617
619{
631}
#define M_PI
Definition: Common.h:115
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
float frand(float min, float max)
Definition: Random.cpp:55
float rand_norm()
Definition: Random.cpp:75
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENTRY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_FORCE_CAST
@ FACTION_NONE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_DUMMY
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:196
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ MOVEMENTFLAG_HOVER
Definition: UnitDefines.h:386
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
Action
SummonGroups
@ SUMMON_GROUP_CHAINED_SPIRIT
@ DATA_OHGANOT_SO_FAST
@ POINT_START_REVIVE
@ SAY_DEATH
@ SAY_DISMOUNT_OHGAN
@ SAY_PLAYER_KILL
@ SAY_AGGRO
@ EMOTE_DEVASTATING_SLAM
@ EMOTE_FRENZY
@ SAY_FRENZY
@ SAY_REANIMATE_OHGAN
@ SPELL_OHGAN_ORDERS_TRIGGER
@ SPELL_DEVASTATING_SLAM
@ SPELL_OHGAN_HEART_VISUAL
@ SPELL_REVIVE
@ SPELL_SPIRIT_VENGEANCE_CANCEL
@ SPELL_BLOODLETTING
@ SPELL_OHGAN_ORDERS
@ SPELL_BLOODLETTING_DAMAGE
@ SPELL_REANIMATE_OHGAN
@ SPELL_DECAPITATE
@ SPELL_DEVASTATING_SLAM_DAMAGE
@ SPELL_FRENZY
@ SPELL_BLOODLORD_AURA
@ SPELL_CLEAR_ALL
@ SPELL_BLOODLETTING_HEAL
@ SPELL_PERMANENT_FEIGN_DEATH
@ SPELL_LEVEL_UP
@ SPELL_DEVASTATING_SLAM_TRIGGER
@ SPELL_SUMMON_OHGAN
@ ACTION_START_REVIVE
@ ACTION_OHGAN_IS_DEATH
@ ACTION_REVIVE
@ EVENT_DECAPITATE
@ EVENT_BLOODLETTING
@ EVENT_DEVASTATING_SLAM
@ EVENT_SUMMON_OHGAN
@ EVENT_REANIMATE_OHGAN_COOLDOWN
@ EVENT_REANIMATE_OHGAN
void AddSC_boss_mandokir()
Yells
int32 GetAmount() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetCaster() const
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
void SetTarget(ObjectGuid const &guid) override
Definition: Creature.cpp:3419
DevastatingSlamTargetSelector(Creature *me, const Unit *victim)
bool operator()(WorldObject *target)
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
virtual ObjectGuid GetGuidData(uint32 type) const override
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
void Clear()
Definition: ObjectGuid.h:286
static Creature * ToCreature(Object *o)
Definition: Object.h:219
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Player * GetHitPlayer() const
Unit * GetCaster() const
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
bool empty() const
iterator begin()
StorageType::const_iterator const_iterator
iterator end()
size_t GetThreatListSize() const
virtual uint32 GetData(uint32) const
Definition: UnitAI.h:73
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void ClearUnitState(uint32 f)
Definition: Unit.h:733
void SetHealth(uint64 val)
Definition: Unit.cpp:9346
ThreatManager & GetThreatManager()
Definition: Unit.h:1063
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
UnitAI * GetAI() const
Definition: Unit.h:660
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:1661
uint64 GetHealth() const
Definition: Unit.h:776
uint64 CountPctFromCurHealth(int32 pct) const
Definition: Unit.h:786
void SetFacingTo(float const ori, bool force=true)
Definition: Unit.cpp:12653
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
bool AttackStop()
Definition: Unit.cpp:5781
void SetMountDisplayId(uint32 mountDisplayId)
Definition: Unit.h:900
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
Definition: Object.cpp:3403
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition: Object.cpp:2131
bool OnCheck(Player *, Unit *target) override
bool Validate(SpellInfo const *) override
void HandleEffectPeriodic(AuraEffect const *aurEff)
void HandleScript(SpellEffIndex)
void FilterTargets(std::list< WorldObject * > &targets)
void HandleScript(SpellEffIndex)
void FilterTargets(std::list< WorldObject * > &targets)
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
void FilterTargets(std::list< WorldObject * > &targets)
void HandleScript(SpellEffIndex)
void HandleScript(SpellEffIndex)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:109
void RandomResize(C &container, std::size_t requestedSize)
Definition: Containers.h:67
TriggerCastFlags TriggerFlags
Definition: SpellDefines.h:478
CastSpellExtraArgs & AddSpellMod(SpellValueMod mod, int32 val)
Definition: SpellDefines.h:474
constexpr void SetOrientation(float orientation)
Definition: Position.h:71
float m_positionZ
Definition: Position.h:55
float m_positionX
Definition: Position.h:53
float m_positionY
Definition: Position.h:54
float GetAbsoluteAngle(float x, float y) const
Definition: Position.h:125
void KilledUnit(Unit *victim) override
void JustDied(Unit *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void Reset() override
void UpdateAI(uint32 diff) override
bool _reanimateOhganCooldown
boss_mandokir(Creature *creature)
uint32 GetData(uint32 type) const override
ObjectGuid _reviveGUID
void JustEngagedWith(Unit *who) override
void DoAction(int32 action) override
void SetGUID(ObjectGuid const &guid, int32) override
void Reset() override
ObjectGuid _revivePlayerGUID
void UpdateAI(uint32) override
void JustDied(Unit *) override
void MovementInform(uint32 type, uint32 pointId) override
InstanceScript * _instance
npc_chained_spirit(Creature *creature)
void DoAction(int32 action) override
void SetGUID(ObjectGuid const &guid, int32) override
void JustEngagedWith(Unit *) override
void KilledUnit(Unit *victim) override
npc_ohgan(Creature *creature)
InstanceScript * _instance
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
@ NPC_CHAINED_SPIRIT
Definition: zulgurub.h:61
#define RegisterZulGurubCreatureAI(ai_name)
Definition: zulgurub.h:98
@ DATA_MANDOKIR
Definition: zulgurub.h:31