TrinityCore
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 "the_botanica.h"
21
22enum Says
23{
31 EMOTE_ENRAGE = 7
32};
33
35{
38 SPELL_ENRAGE = 34670
39};
40
42{
45 EVENT_ENRAGE = 3
46};
47
49{
50 public: boss_thorngrin_the_tender() : CreatureScript("thorngrin_the_tender") { }
51
53 {
55 {
56 Initialize();
57 }
58
60 {
61 _phase1 = true;
62 _phase2 = true;
63 }
64
65 void Reset() override
66 {
67 _Reset();
68 Initialize();
69 }
70
71 void JustEngagedWith(Unit* who) override
72 {
76 if (IsHeroic())
77 events.ScheduleEvent(EVENT_HELLFIRE, 17400ms, 19300ms);
78 else
81 }
82
83 void KilledUnit(Unit* /*victim*/) override
84 {
86 }
87
88 void JustDied(Unit* /*killer*/) override
89 {
90 _JustDied();
92 }
93
94 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
95 {
96 if (me->HealthBelowPctDamaged(50, damage) && _phase1)
97 {
98 _phase1 = false;
100 }
101 if (me->HealthBelowPctDamaged(20, damage) && _phase2)
102 {
103 _phase2 = false;
105 }
106 }
107
108 void UpdateAI(uint32 diff) override
109 {
110 if (!UpdateVictim())
111 return;
112
113 events.Update(diff);
114
116 return;
117
118 while (uint32 eventId = events.ExecuteEvent())
119 {
120 switch (eventId)
121 {
122 case EVENT_SACRIFICE:
123 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
124 {
126 DoCast(target, SPELL_SACRIFICE, true);
127 }
129 break;
130 case EVENT_HELLFIRE:
133 if (IsHeroic())
134 events.ScheduleEvent(EVENT_HELLFIRE, 17400ms, 19300ms);
135 else
137 break;
138 case EVENT_ENRAGE:
142 break;
143 default:
144 break;
145 }
146
148 return;
149 }
150 }
151
152 private:
155 };
156
157 CreatureAI* GetAI(Creature* creature) const override
158 {
159 return GetBotanicaAI<boss_thorngrin_the_tenderAI>(creature);
160 }
161};
162
164{
166}
uint32_t uint32
Definition: Define.h:142
Spells
Definition: PlayerAI.cpp:32
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
Says
void AddSC_boss_thorngrin_the_tender()
void JustEngagedWith(Unit *who) override
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
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
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:627
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
CreatureAI * GetAI(Creature *creature) const override
bool IsHeroic() const
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
@ DATA_THORNGRIN_THE_TENDER
Definition: the_botanica.h:32