TrinityCore
Loading...
Searching...
No Matches
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
41
69
80
82{
83 // Bloodlord Mandokir
86
87 // Chained Spirit
89};
90
99
104
105struct boss_mandokir : public BossAI
106{
108 {
109 Initialize();
110 }
111
113 {
114 _ohganotSoFast = true;
116 }
117
128
129 void JustEngagedWith(Unit* who) override
130 {
133
135
136 if (!summons.empty())
137 {
138 for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
139 {
140 if (Creature* chainedSpirit = ObjectAccessor::GetCreature(*me, *itr))
141 if (chainedSpirit->GetEntry() == NPC_CHAINED_SPIRIT && chainedSpirit->AI())
142 chainedSpirit->SetFaction(FACTION_NONE);
143 }
144 }
145
150 }
151
152 void JustDied(Unit* /*killer*/) override
153 {
155 _JustDied();
157 }
158
159 void KilledUnit(Unit* victim) override
160 {
161 if (victim->GetTypeId() == TYPEID_PLAYER)
162 {
165 _reviveGUID = victim->GetGUID();
167 }
168 }
169
170 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
171 {
172 if (me->HealthBelowPctDamaged(20, damage) && !me->HasAura(SPELL_FRENZY))
173 {
174 DoCast(me, SPELL_FRENZY, true);
177 }
178 }
179
180 void DoAction(int32 action) override
181 {
182 switch (action)
183 {
186 _ohganotSoFast = false;
187 break;
189 {
190 std::list<Creature*> creatures;
192 creatures.remove_if(Trinity::AnyDeadUnitCheck());
193 creatures.remove_if(Trinity::UnitAuraCheck(true, SPELL_OHGAN_ORDERS_TRIGGER));
195 if (creatures.empty())
196 return;
197
198 for (std::list<Creature*>::iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
199 {
200 if (Creature* chainedSpirit = ObjectAccessor::GetCreature(*me, (*itr)->GetGUID()))
201 {
202 chainedSpirit->AI()->SetGUID(_reviveGUID, DATA_REVIVE_GUID);
203 chainedSpirit->AI()->DoAction(ACTION_REVIVE);
205 }
206 }
207 break;
208 }
209 default:
210 break;
211
212 }
213 }
214
215 uint32 GetData(uint32 type) const override
216 {
217 if (type == DATA_OHGANOT_SO_FAST)
218 return _ohganotSoFast;
219
220 return 0;
221 }
222
223 void SetGUID(ObjectGuid const& guid, int32 /*type*/) override
224 {
225 _reviveGUID = guid;
226 }
227
228 void UpdateAI(uint32 diff) override
229 {
230 if (!UpdateVictim())
231 return;
232
233 events.Update(diff);
234
236 return;
237
238 while (uint32 eventId = events.ExecuteEvent())
239 {
240 switch (eventId)
241 {
245 break;
246 case EVENT_DECAPITATE:
249 break;
251 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
252 {
253 DoCast(target, SPELL_BLOODLETTING, true);
255 }
257 break;
261 else
262 {
265 // Cooldown
268 }
269 break;
272 break;
276 break;
277 default:
278 break;
279 }
280
282 return;
283 }
284 }
285
286private:
290};
291
292struct npc_ohgan : public ScriptedAI
293{
294 npc_ohgan(Creature* creature) : ScriptedAI(creature)
295 {
297 }
298
299 void JustEngagedWith(Unit* /*who*/) override
300 {
302 }
303
304 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
305 {
306 if (damage >= me->GetHealth())
307 {
308 damage = 0;
309 me->AttackStop();
310 me->SetHealth(0);
312 DoCast(me, SPELL_CLEAR_ALL, true);
314
316 mandokir->AI()->DoAction(ACTION_OHGAN_IS_DEATH);
317 }
318 }
319
320 void KilledUnit(Unit* victim) override
321 {
322 if (Creature* creature = victim->ToCreature())
323 {
324 if (creature->GetEntry() == NPC_CHAINED_SPIRIT)
326 }
327 }
328
329private:
331};
332
334{
341
342 void Reset() override
343 {
345 }
346
347 void SetGUID(ObjectGuid const& guid, int32 /*type*/) override
348 {
349 _revivePlayerGUID = guid;
350 }
351
352 void DoAction(int32 action) override
353 {
354 if (action == ACTION_REVIVE)
355 {
356 Position pos;
358 {
359 target->GetNearPoint(me, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 5.0f, target->GetAbsoluteAngle(me));
361 }
362 }
363 }
364
365 void MovementInform(uint32 type, uint32 pointId) override
366 {
367 if (type != POINT_MOTION_TYPE || !_revivePlayerGUID)
368 return;
369
370 if (pointId == POINT_START_REVIVE)
371 {
373 DoCast(target, SPELL_REVIVE);
374
376 }
377 }
378
379 void JustDied(Unit* /*killer*/) override
380 {
382 if (!target || target->IsAlive())
383 return;
384
386 {
387 mandokir->GetAI()->SetGUID(target->GetGUID(), DATA_REVIVE_GUID);
388 mandokir->GetAI()->DoAction(ACTION_START_REVIVE);
389 }
390
392 }
393
394 void UpdateAI(uint32 /*diff*/) override { }
395
396private:
399};
400
401// 96682 - Decapitate
403{
404 void FilterTargets(std::list<WorldObject*>& targets)
405 {
406 if (targets.empty())
407 return;
408
410 targets.clear();
411 targets.push_back(target);
412 }
413
414 void HandleScript(SpellEffIndex /*effIndex*/)
415 {
416 Unit* caster = GetCaster();
417 if (Player* target = GetHitPlayer())
418 caster->CastSpell(target, uint32(GetEffectValueAsInt()), true);
419 }
420
426};
427
428// 96776 - Bloodletting
430{
431 bool Validate(SpellInfo const* /*spell*/) override
432 {
434 }
435
437 {
438 Unit* target = GetTarget();
439 Unit* caster = GetCaster();
440 if (!caster)
441 return;
442
445 args.AddSpellMod(SPELLVALUE_BASE_POINT0, std::max<SpellEffectValue>(7500, CalculatePct(target->GetHealth(), aurEff->GetAmount())));
446
447 caster->CastSpell(target, SPELL_BLOODLETTING_DAMAGE, args);
448 target->CastSpell(caster, SPELL_BLOODLETTING_HEAL, args);
449 }
450
455};
456
457// 96821 - Spirit's Vengeance Cancel
472
474{
475 public:
476 DevastatingSlamTargetSelector(Creature* me, const Unit* victim) : _me(me), _victim(victim) {}
477
479 {
480 if (target == _victim && _me->GetThreatManager().GetThreatListSize() > 1)
481 return true;
482
483 if (target->GetTypeId() != TYPEID_PLAYER)
484 return true;
485
486 return false;
487 }
488
490 Unit const* _victim;
491};
492
493// 96761 - Devastating Slam
495{
496 void FilterTargets(std::list<WorldObject*>& targets)
497 {
498 targets.remove_if(DevastatingSlamTargetSelector(GetCaster()->ToCreature(), GetCaster()->GetVictim()));
499 if (targets.empty())
500 return;
501
503 targets.clear();
504 targets.push_back(target);
505 }
506
507 void HandleScript(SpellEffIndex /*effIndex*/)
508 {
509 Unit* caster = GetCaster();
510 float angle = 0.0f;
511 float x, y, z;
512
513 if (Player* target = GetHitPlayer())
514 {
515 caster->AttackStop();
516 caster->SetOrientation(caster->GetAbsoluteAngle(target));
517 caster->SetFacingTo(caster->GetAbsoluteAngle(target));
518
519 caster->CastSpell(caster, SPELL_DEVASTATING_SLAM, false);
520
521 // HACK: Need better way for pos calculation
522 for (uint8 i = 0; i <= 50; ++i)
523 {
524 angle = rand_norm() * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
525 caster->GetClosePoint(x, y, z, 4.0f, frand(-2.5f, 50.0f), angle);
526
527 caster->CastSpell(Position{ x, y, z }, SPELL_DEVASTATING_SLAM_DAMAGE, true);
528 }
529 }
530 }
531
537};
538
539// 96721 - Ohgan's Orders
541{
542 void FilterTargets(std::list<WorldObject*>& targets)
543 {
544 if (targets.empty())
545 return;
546
548 targets.clear();
549 targets.push_back(target);
550 }
551
552 void HandleScript(SpellEffIndex /*effIndex*/)
553 {
554 Unit* caster = GetCaster();
555 if (Unit* target = GetHitUnit())
556 caster->CastSpell(target, uint32(GetEffectValueAsInt()), true);
557 }
558
564};
565
566// 96722 - Ohgan's Orders
568{
569 void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
570 {
571 Unit* target = GetTarget();
572 if (Unit* caster = GetCaster())
573 {
574 // HACK: research better way
575 caster->ClearUnitState(UNIT_STATE_CASTING);
576 caster->GetMotionMaster()->Clear();
577 caster->GetThreatManager().ResetAllThreat();
578 caster->GetThreatManager().AddThreat(target, 50000000.0f);
579 // TODO: Fixate mechanic
580 }
581 }
582
587};
588
589// 96724 - Reanimate Ohgan
591{
592 void HandleScript(SpellEffIndex /*effIndex*/)
593 {
594 if (Unit* target = GetHitUnit())
595 {
596 target->RemoveAura(SPELL_PERMANENT_FEIGN_DEATH);
597 target->CastSpell(target, SPELL_OHGAN_HEART_VISUAL, true);
598 target->CastSpell(nullptr, SPELL_OHGAN_ORDERS, true);
599 }
600 }
601
606};
607
609{
610 public:
611 achievement_ohganot_so_fast() : AchievementCriteriaScript("achievement_ohganot_so_fast") { }
612
613 bool OnCheck(Player* /*player*/, Unit* target) override
614 {
615 return target && target->GetAI()->GetData(DATA_OHGANOT_SO_FAST);
616 }
617};
618
#define M_PI
Definition Common.h:118
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
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:1383
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ 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.
@ SPELLVALUE_BASE_POINT0
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
@ REACT_PASSIVE
@ MOVEMENTFLAG_HOVER
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
T CalculatePct(T base, U pct)
Definition Util.h:72
Action
SummonGroups
@ SUMMON_GROUP_CHAINED_SPIRIT
@ SAY_DEATH
@ SAY_DISMOUNT_OHGAN
@ SAY_PLAYER_KILL
@ SAY_AGGRO
@ EMOTE_DEVASTATING_SLAM
@ EMOTE_FRENZY
@ SAY_FRENZY
@ SAY_REANIMATE_OHGAN
MandokirMisc
@ DATA_REVIVE_GUID
@ DATA_OHGANOT_SO_FAST
@ POINT_START_REVIVE
@ 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
SpellEffectValue GetAmount() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
Unit * GetTarget() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:174
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void SetTarget(ObjectGuid const &guid) override
DevastatingSlamTargetSelector(Creature *me, const Unit *victim)
bool operator()(WorldObject *target)
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
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={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
static ObjectGuid const Empty
Definition ObjectGuid.h:314
void Clear()
Definition ObjectGuid.h:329
Creature * ToCreature()
Definition Object.h:121
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Player * GetHitPlayer() const
Unit * GetCaster() const
int32 GetEffectValueAsInt() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
bool empty() const
iterator begin()
StorageType::const_iterator const_iterator
iterator end()
size_t GetThreatListSize() const
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:162
virtual uint32 GetData(uint32 id) const
Definition UnitAI.h:74
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void ClearUnitState(uint32 f)
Definition Unit.h:744
void SetHealth(uint64 val)
Definition Unit.cpp:9973
ThreatManager & GetThreatManager()
Definition Unit.h:1078
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool IsAlive() const
Definition Unit.h:1185
UnitAI * GetAI() const
Definition Unit.h:668
void AddUnitMovementFlag(uint32 f)
Definition Unit.h:1732
uint64 GetHealth() const
Definition Unit.h:788
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:793
void SetFacingTo(float const ori, bool force=true)
Definition Unit.cpp:13289
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
bool AttackStop()
Definition Unit.cpp:5965
void SetMountDisplayId(uint32 mountDisplayId)
Definition Unit.h:914
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
Definition Object.cpp:2749
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:1507
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 FilterTargets(std::list< WorldObject * > &targets)
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
void FilterTargets(std::list< WorldObject * > &targets)
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) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
Definition Containers.h:110
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:67
TriggerCastFlags TriggerFlags
CastSpellExtraArgs & AddSpellMod(SpellValueMod mod, int32 val)
constexpr void SetOrientation(float orientation)
Definition Position.h:82
float m_positionZ
Definition Position.h:66
float m_positionX
Definition Position.h:64
float m_positionY
Definition Position.h:65
float GetAbsoluteAngle(float x, float y) const
Definition Position.h:136
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
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