TrinityCore
Loading...
Searching...
No Matches
boss_mekgineer_steamrigger.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/* Timers requires update */
19
20#include "ScriptMgr.h"
21#include "ScriptedCreature.h"
22#include "SpellScript.h"
23#include "InstanceScript.h"
24#include "MotionMaster.h"
25#include "steam_vault.h"
26
34
49
58
63
71
72// 17796 - Mekgineer Steamrigger
74{
76
77 void Reset() override
78 {
79 _Reset();
81 }
82
93
94 // Do not despawn mechanics
95 void JustSummoned(Creature* /*summon*/) override { }
96
97 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
98 {
99 if (_phase < PHASE_HEALTH_75 && !IsHeroic() && me->HealthBelowPctDamaged(75, damage))
100 {
101 _phase++;
103 }
104 if (_phase < PHASE_HEALTH_50 && !IsHeroic() && me->HealthBelowPctDamaged(50, damage))
105 {
106 _phase++;
108 }
109 if (_phase < PHASE_HEALTH_25 && !IsHeroic() && me->HealthBelowPctDamaged(25, damage))
110 {
111 _phase++;
113 }
114 }
115
116 void KilledUnit(Unit* /*victim*/) override
117 {
118 Talk(SAY_SLAY);
119 }
120
121 void JustDied(Unit* /*killer*/) override
122 {
124 _JustDied();
125 }
126
127 void UpdateAI(uint32 diff) override
128 {
129 if (!UpdateVictim())
130 return;
131
132 events.Update(diff);
133
135 return;
136
137 while (uint32 eventId = events.ExecuteEvent())
138 {
139 switch (eventId)
140 {
141 case EVENT_SHRINK:
143 events.Repeat(15s, 25s);
144 break;
145 case EVENT_SAW_BLADE:
147 DoCast(target, SPELL_SAW_BLADE);
148 events.Repeat(10s, 20s);
149 break;
153 events.Repeat(15s, 25s);
154 break;
155 case EVENT_SUMMON:
158 break;
159 case EVENT_SUMMON_H:
161 events.Repeat(20s);
162 break;
163 default:
164 break;
165 }
166
168 return;
169 }
170
172 }
173
174private:
176};
177
178// 17951 - Steamrigger Mechanic
180{
182
183 void Reset() override
184 {
186 }
187
188 void IsSummonedBy(WorldObject* ownerWO) override
189 {
191
192 Creature* owner = ownerWO->ToCreature();
193 if (!owner)
194 return;
195
196 float x, y, z;
197 owner->GetContactPoint(me, x, y, z);
199 }
200
201 void MovementInform(uint32 type, uint32 pointId) override
202 {
203 if (type != POINT_MOTION_TYPE)
204 return;
205
206 if (pointId == POINT_REPAIR)
208 }
209
210 void JustEngagedWith(Unit* /*who*/) override
211 {
212 _scheduler.Schedule(5s, 10s, [this](TaskContext task)
213 {
215 task.Repeat(5s, 10s);
216 });
217
218 _scheduler.Schedule(5s, [this](TaskContext task)
219 {
221 task.Repeat(5s);
222 });
223 }
224
225 void UpdateAI(uint32 diff) override
226 {
227 if (!UpdateVictim())
228 return;
229
230 _scheduler.Update(diff);
231
233 }
234
235private:
237};
238
239// 31531 - Summon Gnomes
262
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ POINT_MOTION_TYPE
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
@ EFFECT_0
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_DEFENSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
void AddSC_boss_mekgineer_steamrigger()
HookList< EffectApplyHandler > AfterEffectRemove
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
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
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
static Creature * ToCreature(Object *o)
Definition Object.h:186
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
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
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
void GetContactPoint(WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
Definition Object.cpp:3271
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_mekgineer_steamrigger_summon_gnomes)
@ DATA_MEKGINEER_STEAMRIGGER
Definition steam_vault.h:31
#define RegisterSteamVaultCreatureAI(ai_name)
Definition steam_vault.h:70
bool IsHeroic() const
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
void MovementInform(uint32 type, uint32 pointId) override
void IsSummonedBy(WorldObject *ownerWO) override