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#include "ScriptMgr.h"
19#include "ScriptedCreature.h"
20#include "SpellInfo.h"
21#include "SpellMgr.h"
22#include "the_botanica.h"
23
36
43
50
57
58// 17978 - Thorngrin the Tender
60{
62
63 void Reset() override
64 {
65 _Reset();
67 }
68
70 void MoveInLineOfSight(Unit* who) override
71 {
72 if (!_introDone && who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 75.0f))
73 {
74 _introDone = true;
76 }
77
79 }
80
89
90 void OnSpellStart(SpellInfo const* spell) override
91 {
92 if (spell->Id == SPELL_SACRIFICE)
94 }
95
96 void OnSpellCast(SpellInfo const* spell) override
97 {
98 if (spell->Id == sSpellMgr->GetSpellIdForDifficulty(SPELL_HELLFIRE, me))
100
101 if (spell->Id == SPELL_ENRAGE)
103 }
104
105 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
106 {
107 if (_phase < PHASE_HEALTH_50 && me->HealthBelowPctDamaged(50, damage))
108 {
109 _phase++;
111 }
112 if (_phase < PHASE_HEALTH_20 && me->HealthBelowPctDamaged(20, damage))
113 {
114 _phase++;
116 }
117 }
118
119 void KilledUnit(Unit* /*victim*/) override
120 {
121 Talk(SAY_SLAY);
122 }
123
124 void JustDied(Unit* /*killer*/) override
125 {
126 _JustDied();
128 }
129
130 void UpdateAI(uint32 diff) override
131 {
132 if (!UpdateVictim())
133 return;
134
135 events.Update(diff);
136
138 return;
139
140 while (uint32 eventId = events.ExecuteEvent())
141 {
142 switch (eventId)
143 {
144 case EVENT_SACRIFICE:
145 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
146 DoCast(target, SPELL_SACRIFICE);
147 events.Repeat(25s, 30s);
148 break;
149 case EVENT_HELLFIRE:
151 events.Repeat(15s, 25s);
152 break;
153 case EVENT_ENRAGE:
155 events.Repeat(30s, 40s);
156 break;
157 default:
158 break;
159 }
160
162 return;
163 }
164
166 }
167
168private:
171};
172
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:235
DamageEffectType
Definition Unit.h:352
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:769
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void OnSpellStart(SpellInfo const *spell) override
void MoveInLineOfSight(Unit *who) override
boss_thorngrin_the_tender(Creature *creature)
void OnSpellCast(SpellInfo const *spell) override
@ DATA_THORNGRIN_THE_TENDER
#define RegisterBotanicaCreatureAI(ai_name)