TrinityCore
Loading...
Searching...
No Matches
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
35
37{
40};
41
50
52{
53 public:
54 boss_epoch() : CreatureScript("boss_epoch") { }
55
56 struct boss_epochAI : public BossAI
57 {
58 boss_epochAI(Creature* creature) : BossAI(creature, DATA_EPOCH), _stepTargetIndex(0) { }
59
65
78
79 void ExecuteEvent(uint32 eventId) override
80 {
81 switch (eventId)
82 {
84 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
87 break;
88 case EVENT_TIME_WARP:
93 break;
94 case EVENT_TIME_STOP:
97 break;
100 events.Repeat(Seconds(12), Seconds(18));
101 break;
102 case EVENT_TIME_STEP:
103 {
104 // In each step, we charge to a random target that was previously hit by SPELL_TIME_STEP_DUMMY
105 // Once we run out of targets, we charge back to the tank, then stop
106 uint32 nTargets = _stepTargets.size();
107 Unit* target = nullptr;
108 while (nTargets > _stepTargetIndex)
109 {
110 uint32 selected = urand(_stepTargetIndex, nTargets - 1);
111 if (_stepTargetIndex != selected)
112 std::swap(_stepTargets[_stepTargetIndex], _stepTargets[selected]);
114 break;
115 }
116 if (target)
118 else
119 target = me->GetVictim();
120
121 if (target)
122 DoCast(target, SPELL_TIME_STEP_CHARGE, true);
123 break;
124 }
125 default:
126 break;
127 }
128 }
129
130 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
131 {
132 if (spellInfo->Id == SPELL_TIME_STEP_DUMMY && me->IsHostileTo(target))
133 {
134 _stepTargets.push_back(target->GetGUID());
136 }
137 }
138
139 void JustDied(Unit* /*killer*/) override
140 {
141 _JustDied();
142 }
143
144 void KilledUnit(Unit* victim) override
145 {
146 if (victim->GetTypeId() == TYPEID_PLAYER)
147 Talk(SAY_SLAY);
148 }
149
150 private:
152 std::vector<ObjectGuid> _stepTargets;
153 };
154
155 CreatureAI* GetAI(Creature* creature) const override
156 {
157 return GetCullingOfStratholmeAI<boss_epochAI>(creature);
158 }
159};
160
162{
163 new boss_epoch();
164}
uint32_t uint32
Definition Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:27
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ DONE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
@ LOOT_MODE_DEFAULT
void AddSC_boss_epoch()
@ SPELL_CURSE_OF_EXERTION
@ SPELL_TIME_STEP_DUMMY
@ SPELL_WOUNDING_STRIKE
@ SPELL_TIME_STEP_CHARGE
@ EVENT_CURSE_OF_EXERTION
@ EVENT_WOUNDING_STRIKE
Yells
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
Creature *const me
Definition CreatureAI.h:82
void RemoveLootMode(uint16 lootMode)
Definition Creature.h:226
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
EncounterState GetBossState(uint32 id) const
TypeID GetTypeId() const
Definition Object.h:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 Id
Definition SpellInfo.h:289
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
Unit * GetVictim() const
Definition Unit.h:859
bool IsHostileTo(WorldObject const *target) const
Definition Object.cpp:2796
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