TrinityCore
Loading...
Searching...
No Matches
boss_landslide.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 "maraudon.h"
20#include "ScriptedCreature.h"
21
28
29// 12203 - Landslide
31{
32 boss_landslide(Creature* creature) : ScriptedAI(creature), _landslide(false) { }
33
34 void Reset() override
35 {
37 _landslide = false;
38 }
39
40 void JustEngagedWith(Unit* /*who*/) override
41 {
43 .SetValidator([this]
44 {
46 })
47 .Schedule(5s, 10s, [this](TaskContext task)
48 {
50 task.Repeat(15s, 25s);
51 })
52 .Schedule(10s, 15s, [this](TaskContext task)
53 {
55 task.Repeat(10s, 20s);
56 });
57 }
58
59 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
60 {
61 if (!_landslide && me->HealthBelowPctDamaged(50, damage))
62 {
63 _landslide = true;
64
65 _scheduler.Schedule(0s, [this](TaskContext task)
66 {
68 task.Repeat(30s, 40s);
69 });
70 }
71 }
72
73 void UpdateAI(uint32 diff) override
74 {
75 if (!UpdateVictim())
76 return;
77
78 _scheduler.Update(diff, [this]
79 {
81 });
82 }
83
84private:
87};
88
uint32_t uint32
Definition Define.h:133
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
LandslideSpells
@ SPELL_TRAMPLE
@ SPELL_LANDSLIDE
@ SPELL_KNOCK_AWAY
void AddSC_boss_landslide()
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
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)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Definition Unit.h:769
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
#define RegisterMaraudonCreatureAI(ai_name)
Definition maraudon.h:31
boss_landslide(Creature *creature)
void JustEngagedWith(Unit *) override
TaskScheduler _scheduler
void Reset() override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override