TrinityCore
Loading...
Searching...
No Matches
boss_selin_fireheart.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/* Cystals should really be a DB creature summon group, having them in `creature` like this will cause tons of despawn/respawn bugs */
19
20#include "ScriptMgr.h"
21#include "InstanceScript.h"
22#include "magisters_terrace.h"
23#include "MotionMaster.h"
24#include "ObjectAccessor.h"
25#include "ScriptedCreature.h"
26
36
38{
39 // Selin
42
43 SPELL_DRAIN_MANA = 46153, // Heroic only
44
45 // Crystal
49};
50
59
65
70
71// 24723 - Selin Fireheart
73{
75
76 void Reset() override
77 {
78 std::list<Creature*> crystals;
80
81 for (Creature* creature : crystals)
82 creature->Respawn(true);
83
84 _Reset();
86 _scheduledEvents = false;
87 }
88
89 void DoAction(int32 action) override
90 {
91 switch (action)
92 {
98 break;
99 default:
100 break;
101 }
102 }
103
105 {
106 if (Creature* crystal = me->FindNearestCreature(NPC_FEL_CRYSTAL, 250.0f))
107 {
110
112 CrystalGUID = crystal->GetGUID();
113
114 float x, y, z;
115 crystal->GetClosePoint(x, y, z, me->GetCombatReach(), CONTACT_DISTANCE);
116
118 me->SetWalk(false);
119 me->GetMotionMaster()->MovePoint(1, x, y, z);
120 }
121 }
122
124 {
125 std::list<Creature*> crystals;
127
128 for (Creature* crystal : crystals)
129 crystal->CastSpell(crystal, SPELL_QUIET_SUICIDE, true);
130 }
131
140
141 void KilledUnit(Unit* victim) override
142 {
143 if (victim->GetTypeId() == TYPEID_PLAYER)
144 Talk(SAY_SLAY);
145 }
146
147 void MovementInform(uint32 type, uint32 id) override
148 {
149 if (type == POINT_MOTION_TYPE && id == 1)
150 {
151 Unit* CrystalChosen = ObjectAccessor::GetUnit(*me, CrystalGUID);
152 if (CrystalChosen && CrystalChosen->IsAlive())
153 {
155 CrystalChosen->CastSpell(me, SPELL_MANA_RAGE, true);
157 }
158 }
159 }
160
161 void JustDied(Unit* /*killer*/) override
162 {
164 _JustDied();
165
167 }
168
169 void UpdateAI(uint32 diff) override
170 {
171 if (!UpdateVictim())
172 return;
173
174 events.Update(diff);
175
177 return;
178
179 while (uint32 eventId = events.ExecuteEvent())
180 {
181 switch (eventId)
182 {
186 break;
189 _scheduledEvents = false;
190 break;
191 case EVENT_DRAIN_MANA:
192 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true))
193 DoCast(target, SPELL_DRAIN_MANA);
195 break;
196 case EVENT_DRAIN_LIFE:
197 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 20.0f, true))
198 DoCast(target, SPELL_DRAIN_LIFE);
200 break;
201 case EVENT_EMPOWER:
202 {
204
206 if (CrystalChosen && CrystalChosen->IsAlive())
207 CrystalChosen->KillSelf();
208
210
213 break;
214 }
215 default:
216 break;
217 }
218
220 return;
221 }
222
223 if (me->GetPowerPct(POWER_MANA) < 10.f)
224 {
226 {
227 _scheduledEvents = true;
228 Milliseconds timer = randtime(3s, 7s);
230
231 if (IsHeroic())
232 {
235 }
236 else
238 }
239 }
240
242 }
243
244private:
247};
248
249// 24722 - Fel Crystal
251{
252 npc_fel_crystal(Creature* creature) : ScriptedAI(creature) { }
253
254 void JustDied(Unit* /*killer*/) override
255 {
256 if (InstanceScript* instance = me->GetInstanceScript())
257 {
258 Creature* selin = instance->GetCreature(DATA_SELIN_FIREHEART);
259 if (selin && selin->IsAlive())
261 }
262 }
263};
264
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ POINT_MOTION_TYPE
#define CONTACT_DISTANCE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition Random.cpp:62
@ POWER_MANA
@ UNIT_FLAG_UNINTERACTIBLE
@ UNIT_STATE_CASTING
Definition Unit.h:235
void AddSC_boss_selin_fireheart()
@ SPELL_MANA_RAGE
@ SPELL_FEL_EXPLOSION
@ SPELL_FEL_CRYSTAL_DUMMY
@ SPELL_DRAIN_MANA
@ SPELL_QUIET_SUICIDE
@ SPELL_DRAIN_LIFE
@ EVENT_DRAIN_CRYSTAL
@ EVENT_DRAIN_LIFE
@ EVENT_DRAIN_MANA
@ EVENT_FEL_EXPLOSION
@ ACTION_SWITCH_PHASE
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
CreatureAI * AI() const
Definition Creature.h:154
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
void Clear()
Definition ObjectGuid.h:150
TypeID GetTypeId() const
Definition Object.h:93
virtual void DoAction(int32)
Definition UnitAI.h:154
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
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
void KillSelf(bool durabilityLoss=true)
Definition Unit.h:1023
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
float GetCombatReach() const override
Definition Unit.h:839
bool SetWalk(bool enable)
Definition Unit.cpp:13268
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
float GetPowerPct(Powers power) const
Definition Unit.h:937
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:955
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition Object.cpp:3153
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2099
@ NPC_FEL_CRYSTAL
#define RegisterMagistersTerraceCreatureAI(ai_name)
@ DATA_SELIN_FIREHEART
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
bool IsHeroic() const
void AttackStart(Unit *) override
void KilledUnit(Unit *victim) override
void MovementInform(uint32 type, uint32 id) override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
void JustEngagedWith(Unit *who) override
boss_selin_fireheart(Creature *creature)
void DoAction(int32 action) override
void JustDied(Unit *) override
npc_fel_crystal(Creature *creature)