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 }
182
183private:
185};
186
187// 17951 - Steamrigger Mechanic
189{
191
192 void InitializeAI() override
193 {
194 if (me->IsSummon())
195 {
196 me->SetCorpseDelay(5, true);
198 }
199
201 }
202
203 void Reset() override
204 {
206 }
207
208 void JustAppeared() override
209 {
210 if (TempSummon* summon = me->ToTempSummon())
211 {
212 Unit* summoner = summon->GetSummonerUnit();
213 if (summoner && summoner->IsCreature())
214 {
215 float x, y, z;
216 summoner->GetContactPoint(me, x, y, z);
218 }
219 }
220 }
221
222 void MovementInform(uint32 type, uint32 pointId) override
223 {
224 if (type != POINT_MOTION_TYPE)
225 return;
226
227 if (pointId == POINT_REPAIR)
229 }
230
231 void JustEngagedWith(Unit* /*who*/) override
232 {
234 .Schedule(5s, 10s, [this](TaskContext& task)
235 {
237 task.Repeat(5s, 10s);
238 })
239 .Schedule(5s, 15s, [this](TaskContext& task)
240 {
242 task.Repeat(5s, 10s);
243 });
244 }
245
246 void UpdateAI(uint32 diff) override
247 {
248 if (!UpdateVictim())
249 return;
250
251 _scheduler.Update(diff);
252 }
253
254private:
256};
257
258// 31531 - Summon Gnomes
260{
261 bool Validate(SpellInfo const* /*spellInfo*/) override
262 {
264 }
265
266 void OnPeriodic(AuraEffect const* /*aurEff*/)
267 {
268 Unit* target = GetTarget();
269 target->CastSpell(nullptr, SPELL_SUMMON_GNOME_1, true);
270 target->CastSpell(nullptr, SPELL_SUMMON_GNOME_2, true);
271 target->CastSpell(nullptr, SPELL_SUMMON_GNOME_3, true);
272 }
273
278};
279
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_0
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define AuraEffectPeriodicFn(F, I, N)
@ REACT_DEFENSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
void AddSC_boss_mekgineer_steamrigger()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
bool IsCreature() const
Definition BaseEntity.h:172
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:118
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void InitializeAI()
Definition UnitAI.cpp:35
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
TempSummon * ToTempSummon()
Definition Unit.h:1844
bool IsSummon() const
Definition Unit.h:761
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void GetContactPoint(WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
Definition Object.cpp:2781
@ DATA_MEKGINEER_STEAMRIGGER
Definition steam_vault.h:31
#define RegisterSteamVaultCreatureAI(ai_name)
Definition steam_vault.h:61
bool IsHeroic() const
ScriptedAI(Creature *creature, uint32 scriptId=0) noexcept
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