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/*
19 * Timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "InstanceScript.h"
24#include "MotionMaster.h"
25#include "ScriptedCreature.h"
26#include "SpellScript.h"
27#include "SpellInfo.h"
28#include "steam_vault.h"
29#include "TemporarySummon.h"
30
38
53
62
67
75
76// 17796 - Mekgineer Steamrigger
78{
80
81 void Reset() override
82 {
83 _Reset();
85 }
86
99
100 // Do not despawn mechanics
101 void JustSummoned(Creature* /*summon*/) override { }
102
103 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
104 {
105 if (_phase < PHASE_HEALTH_75 && !IsHeroic() && me->HealthBelowPctDamaged(75, damage))
106 {
107 _phase++;
109 }
110 if (_phase < PHASE_HEALTH_50 && !IsHeroic() && me->HealthBelowPctDamaged(50, damage))
111 {
112 _phase++;
114 }
115 if (_phase < PHASE_HEALTH_25 && !IsHeroic() && me->HealthBelowPctDamaged(25, damage))
116 {
117 _phase++;
119 }
120 }
121
122 void OnSpellCast(SpellInfo const* spellInfo) override
123 {
124 if (spellInfo->Id == SPELL_SUMMON_GNOMES)
126 }
127
128 void KilledUnit(Unit* /*victim*/) override
129 {
130 Talk(SAY_SLAY);
131 }
132
133 void JustDied(Unit* /*killer*/) override
134 {
135 _JustDied();
137 }
138
139 void UpdateAI(uint32 diff) override
140 {
141 if (!UpdateVictim())
142 return;
143
144 events.Update(diff);
145
147 return;
148
149 while (uint32 eventId = events.ExecuteEvent())
150 {
151 switch (eventId)
152 {
155 events.Repeat(35s, 50s);
156 break;
157 case EVENT_SAW_BLADE:
158 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
159 DoCast(target, SPELL_SAW_BLADE);
160 events.Repeat(8s, 15s);
161 break;
165 events.Repeat(20s, 30s);
166 break;
167 case EVENT_SUMMON:
169 break;
170 case EVENT_SUMMON_H:
172 events.Repeat(20s);
173 break;
174 default:
175 break;
176 }
177
179 return;
180 }
181
183 }
184
185private:
187};
188
189// 17951 - Steamrigger Mechanic
191{
193
194 void InitializeAI() override
195 {
196 if (me->IsSummon())
197 {
198 me->SetCorpseDelay(5, true);
200 }
201
203 }
204
205 void Reset() override
206 {
208 }
209
210 void JustAppeared() override
211 {
212 if (TempSummon* summon = me->ToTempSummon())
213 {
214 Unit* summoner = summon->GetSummonerUnit();
215 if (summoner && summoner->IsCreature())
216 {
217 float x, y, z;
218 summoner->GetContactPoint(me, x, y, z);
220 }
221 }
222 }
223
224 void MovementInform(uint32 type, uint32 pointId) override
225 {
226 if (type != POINT_MOTION_TYPE)
227 return;
228
229 if (pointId == POINT_REPAIR)
231 }
232
233 void JustEngagedWith(Unit* /*who*/) override
234 {
236 .Schedule(5s, 10s, [this](TaskContext task)
237 {
239 task.Repeat(5s, 10s);
240 })
241 .Schedule(5s, 15s, [this](TaskContext task)
242 {
244 task.Repeat(5s, 10s);
245 });
246 }
247
248 void UpdateAI(uint32 diff) override
249 {
250 if (!UpdateVictim())
251 return;
252
253 _scheduler.Update(diff);
254
256 }
257
258private:
260};
261
262// 31531 - Summon Gnomes
285
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
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define AuraEffectPeriodicFn(F, I, N)
@ REACT_DEFENSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:249
DamageEffectType
Definition Unit.h:366
void AddSC_boss_mekgineer_steamrigger()
HookList< EffectPeriodicHandler > OnEffectPeriodic
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:128
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:98
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={})
bool IsCreature() const
Definition Object.h:188
uint32 Id
Definition SpellInfo.h:289
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
virtual void InitializeAI()
Definition UnitAI.cpp:36
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
MotionMaster * GetMotionMaster()
Definition Unit.h:1683
TempSummon * ToTempSummon()
Definition Unit.h:1810
bool IsSummon() const
Definition Unit.h:896
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:932
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
void GetContactPoint(WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
Definition Object.cpp:3272
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareAuraScript(spell_mekgineer_steamrigger_summon_gnomes)
@ DATA_MEKGINEER_STEAMRIGGER
Definition steam_vault.h:31
#define RegisterSteamVaultCreatureAI(ai_name)
Definition steam_vault.h:61
bool IsHeroic() const
ScriptedAI(Creature *creature)
void JustEngagedWith(Unit *who) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void OnSpellCast(SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
void MovementInform(uint32 type, uint32 pointId) override