TrinityCore
Loading...
Searching...
No Matches
boss_garr.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/* ScriptData
19SDName: Boss_Garr
20SD%Complete: 50
21SDComment: Adds NYI
22SDCategory: Molten Core
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "molten_core.h"
27#include "ScriptedCreature.h"
28
30{
31 // Garr
34 SPELL_ENRAGE = 19516,
36
37 // Adds
40};
41
47
48struct boss_garr : public BossAI
49{
50 boss_garr(Creature* creature) : BossAI(creature, BOSS_GARR) { }
51
58
59 void UpdateAI(uint32 diff) override
60 {
61 if (!UpdateVictim())
62 return;
63
64 events.Update(diff);
65
67 return;
68
69 while (uint32 eventId = events.ExecuteEvent())
70 {
71 switch (eventId)
72 {
76 break;
80 break;
81 default:
82 break;
83 }
84
86 return;
87 }
88 }
89};
90
92{
93 npc_firesworn(Creature* creature) : ScriptedAI(creature) { }
94
96 {
97 // Timers for this are probably wrong
98 _scheduler.Schedule(4s, [this](TaskContext& context)
99 {
101 DoCast(target, SPELL_IMMOLATE);
102
103 context.Repeat(5s, 10s);
104 });
105
106 // Separation Anxiety - Periodically check if Garr is nearby
107 // ...and enrage if he is not.
108 _scheduler.Schedule(3s, [this](TaskContext& context)
109 {
110 if (!me->FindNearestCreature(NPC_GARR, 20.0f))
114
115 context.Repeat();
116 });
117 }
118
119 void Reset() override
120 {
122 }
123
124 void JustEngagedWith(Unit* /*who*/) override
125 {
127 }
128
129 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
130 {
131 uint32 const health10pct = me->CountPctFromMaxHealth(10);
132 uint32 health = me->GetHealth();
133 if (int32(health) - int32(damage) < int32(health10pct))
134 {
135 damage = 0;
138 }
139 }
140
141 void UpdateAI(uint32 diff) override
142 {
143 if (!UpdateVictim())
144 return;
145
146 _scheduler.Update(diff);
147 }
148
149private:
151};
152
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
Spells
Definition PlayerAI.cpp:32
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ SPELL_ANTIMAGIC_PULSE
Definition boss_garr.cpp:32
@ SPELL_ENRAGE
Definition boss_garr.cpp:34
@ SPELL_SEPARATION_ANXIETY
Definition boss_garr.cpp:35
@ SPELL_MAGMA_SHACKLES
Definition boss_garr.cpp:33
@ SPELL_IMMOLATE
Definition boss_garr.cpp:39
@ SPELL_ERUPTION
Definition boss_garr.cpp:38
void AddSC_boss_garr()
@ EVENT_MAGMA_SHACKLES
Definition boss_garr.cpp:45
@ EVENT_ANTIMAGIC_PULSE
Definition boss_garr.cpp:44
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
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
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
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 DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
uint64 CountPctFromMaxHealth(float pct) const
Definition Unit.h:797
uint64 GetHealth() const
Definition Unit.h:788
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
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1517
#define RegisterMoltenCoreCreatureAI(ai_name)
Definition molten_core.h:84
@ NPC_GARR
Definition molten_core.h:57
@ BOSS_GARR
Definition molten_core.h:33
boss_garr(Creature *creature)
Definition boss_garr.cpp:50
void JustEngagedWith(Unit *victim) override
Definition boss_garr.cpp:52
void UpdateAI(uint32 diff) override
Definition boss_garr.cpp:59
npc_firesworn(Creature *creature)
Definition boss_garr.cpp:93
void UpdateAI(uint32 diff) override
TaskScheduler _scheduler
void ScheduleTasks()
Definition boss_garr.cpp:95
void Reset() override
void JustEngagedWith(Unit *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override