TrinityCore
boss_chrono_lord_epoch.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
19#include "InstanceScript.h"
20#include "ObjectAccessor.h"
21#include "ScriptedCreature.h"
22#include "ScriptMgr.h"
23#include "SpellInfo.h"
24#include <vector>
25
27{
32};
33
34#define SPELL_TIME_STEP_CHARGE DUNGEON_MODE(52737,58829)
35#define SPELL_WOUNDING_STRIKE DUNGEON_MODE(52771,58830)
36
38{
41};
42
44{
50};
51
53{
54 public:
55 boss_epoch() : CreatureScript("boss_epoch") { }
56
57 struct boss_epochAI : public BossAI
58 {
59 boss_epochAI(Creature* creature) : BossAI(creature, DATA_EPOCH), _stepTargetIndex(0) { }
60
61 void InitializeAI() override
62 {
65 }
66
67 void JustEngagedWith(Unit* who) override
68 {
70
72 _stepTargets.clear();
76 if (IsHeroic())
78 }
79
80 void ExecuteEvent(uint32 eventId) override
81 {
82 switch (eventId)
83 {
85 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
88 break;
89 case EVENT_TIME_WARP:
94 break;
95 case EVENT_TIME_STOP:
98 break;
101 events.Repeat(Seconds(12), Seconds(18));
102 break;
103 case EVENT_TIME_STEP:
104 {
105 // In each step, we charge to a random target that was previously hit by SPELL_TIME_STEP_DUMMY
106 // Once we run out of targets, we charge back to the tank, then stop
107 uint32 nTargets = _stepTargets.size();
108 Unit* target = nullptr;
109 while (nTargets > _stepTargetIndex)
110 {
111 uint32 selected = urand(_stepTargetIndex, nTargets - 1);
112 if (_stepTargetIndex != selected)
113 std::swap(_stepTargets[_stepTargetIndex], _stepTargets[selected]);
115 break;
116 }
117 if (target)
119 else
120 target = me->GetVictim();
121
122 if (target)
123 DoCast(target, SPELL_TIME_STEP_CHARGE, true);
124 break;
125 }
126 default:
127 break;
128 }
129 }
130
131 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
132 {
133 if (spellInfo->Id == SPELL_TIME_STEP_DUMMY && me->IsHostileTo(target))
134 {
135 _stepTargets.push_back(target->GetGUID());
137 }
138 }
139
140 void JustDied(Unit* /*killer*/) override
141 {
142 _JustDied();
143 }
144
145 void KilledUnit(Unit* victim) override
146 {
147 if (victim->GetTypeId() == TYPEID_PLAYER)
148 Talk(SAY_SLAY);
149 }
150
151 private:
153 std::vector<ObjectGuid> _stepTargets;
154 };
155
156 CreatureAI* GetAI(Creature* creature) const override
157 {
158 return GetCullingOfStratholmeAI<boss_epochAI>(creature);
159 }
160};
161
163{
164 new boss_epoch();
165}
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ DONE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
@ LOOT_MODE_DEFAULT
Definition: SharedDefines.h:77
void AddSC_boss_epoch()
#define SPELL_TIME_STEP_CHARGE
@ SPELL_CURSE_OF_EXERTION
@ SPELL_TIME_STEP_DUMMY
#define SPELL_WOUNDING_STRIKE
@ EVENT_CURSE_OF_EXERTION
@ EVENT_WOUNDING_STRIKE
Yells
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
void RemoveLootMode(uint16 lootMode)
Definition: Creature.h:299
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:52
EncounterState GetBossState(uint32 id) const
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
uint32 const Id
Definition: SpellInfo.h:325
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
Unit * GetVictim() const
Definition: Unit.h:715
bool IsHostileTo(WorldObject const *target) const
Definition: Object.cpp:2860
CreatureAI * GetAI(Creature *creature) const override
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
bool IsHeroic() const
std::vector< ObjectGuid > _stepTargets
void ExecuteEvent(uint32 eventId) override
void JustEngagedWith(Unit *who) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void KilledUnit(Unit *victim) override