TrinityCore
Loading...
Searching...
No Matches
boss_thorngrin_the_tender.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/*
19 * Timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "ScriptedCreature.h"
24#include "SpellInfo.h"
25#include "SpellMgr.h"
26#include "the_botanica.h"
27
40
47
54
61
62// 17978 - Thorngrin the Tender
64{
66
67 void Reset() override
68 {
69 _Reset();
71 }
72
74 void MoveInLineOfSight(Unit* who) override
75 {
76 if (!_introDone && who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 75.0f))
77 {
78 _introDone = true;
80 }
81
83 }
84
85 void JustEngagedWith(Unit* who) override
86 {
88
90
94 }
95
96 void OnSpellStart(SpellInfo const* spellInfo) override
97 {
98 if (spellInfo->Id == SPELL_SACRIFICE)
100 }
101
102 void OnSpellCast(SpellInfo const* spellInfo) override
103 {
104 if (spellInfo->Id == sSpellMgr->GetSpellIdForDifficulty(SPELL_HELLFIRE, me))
106
107 if (spellInfo->Id == SPELL_ENRAGE)
109 }
110
111 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
112 {
113 if (_phase < PHASE_HEALTH_50 && me->HealthBelowPctDamaged(50, damage))
114 {
115 _phase++;
117 }
118
119 if (_phase < PHASE_HEALTH_20 && me->HealthBelowPctDamaged(20, damage))
120 {
121 _phase++;
123 }
124 }
125
126 void KilledUnit(Unit* /*victim*/) override
127 {
128 Talk(SAY_SLAY);
129 }
130
131 void JustDied(Unit* /*killer*/) override
132 {
133 _JustDied();
135 }
136
137 void UpdateAI(uint32 diff) override
138 {
139 if (!UpdateVictim())
140 return;
141
142 events.Update(diff);
143
145 return;
146
147 while (uint32 eventId = events.ExecuteEvent())
148 {
149 switch (eventId)
150 {
151 case EVENT_SACRIFICE:
152 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
153 DoCast(target, SPELL_SACRIFICE);
154 events.Repeat(25s, 30s);
155 break;
156 case EVENT_HELLFIRE:
158 events.Repeat(15s, 25s);
159 break;
160 case EVENT_ENRAGE:
162 events.Repeat(30s, 40s);
163 break;
164 default:
165 break;
166 }
167
169 return;
170 }
171
173 }
174
175private:
178};
179
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
#define sSpellMgr
Definition SpellMgr.h:738
@ UNIT_STATE_CASTING
Definition Unit.h:249
DamageEffectType
Definition Unit.h:366
void AddSC_boss_thorngrin_the_tender()
void JustEngagedWith(Unit *who) override
EventMap events
virtual void MoveInLineOfSight(Unit *)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
TypeID GetTypeId() const
Definition Object.h:93
uint32 Id
Definition SpellInfo.h:289
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:783
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1193
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
void OnSpellStart(SpellInfo const *spellInfo) override
void OnSpellCast(SpellInfo const *spellInfo) override
void JustEngagedWith(Unit *who) override
void MoveInLineOfSight(Unit *who) override
boss_thorngrin_the_tender(Creature *creature)
@ DATA_THORNGRIN_THE_TENDER
#define RegisterBotanicaCreatureAI(ai_name)