TrinityCore
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#include "ScriptMgr.h"
19#include "InstanceScript.h"
20#include "magisters_terrace.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "ScriptedCreature.h"
24
25enum Says
26{
33};
34
36{
37 // Crystal effect spells
39 SPELL_MANA_RAGE = 44320, // This spell triggers 44321, which changes scale and regens mana Requires an entry in spell_script_target
40
41 // Selin's spells
44
45 SPELL_DRAIN_MANA = 46153 // Heroic only
46};
47
49{
51 PHASE_DRAIN = 2
52};
53
55{
61};
62
63enum Misc
64{
66};
67
68// @todo crystals should really be a DB creature summon group, having them in `creature` like this will cause tons of despawn/respawn bugs
70{
71 public:
72 boss_selin_fireheart() : CreatureScript("boss_selin_fireheart") { }
73
75 {
77
78 void Reset() override
79 {
80 std::list<Creature*> crystals;
82
83 for (Creature* creature : crystals)
84 creature->Respawn(true);
85
86 _Reset();
88 _scheduledEvents = false;
89 }
90
91 void DoAction(int32 action) override
92 {
93 switch (action)
94 {
100 break;
101 default:
102 break;
103 }
104 }
105
107 {
108 if (Creature* crystal = me->FindNearestCreature(NPC_FEL_CRYSTAL, 250.0f))
109 {
112
114 CrystalGUID = crystal->GetGUID();
115
116 float x, y, z;
117 crystal->GetClosePoint(x, y, z, me->GetCombatReach(), CONTACT_DISTANCE);
118
120 me->SetWalk(false);
121 me->GetMotionMaster()->MovePoint(1, x, y, z);
122 }
123 }
124
126 {
127 std::list<Creature*> crystals;
129
130 for (Creature* crystal : crystals)
131 crystal->KillSelf();
132 }
133
134 void JustEngagedWith(Unit* who) override
135 {
138
141 }
142
143 void KilledUnit(Unit* victim) override
144 {
145 if (victim->GetTypeId() == TYPEID_PLAYER)
146 Talk(SAY_KILL);
147 }
148
149 void MovementInform(uint32 type, uint32 id) override
150 {
151 if (type == POINT_MOTION_TYPE && id == 1)
152 {
153 Unit* CrystalChosen = ObjectAccessor::GetUnit(*me, CrystalGUID);
154 if (CrystalChosen && CrystalChosen->IsAlive())
155 {
156 CrystalChosen->SetUninteractible(false);
157 CrystalChosen->CastSpell(me, SPELL_MANA_RAGE, true);
159 }
160 }
161 }
162
163 void JustDied(Unit* /*killer*/) override
164 {
166 _JustDied();
167
169 }
170
171 void UpdateAI(uint32 diff) override
172 {
173 if (!UpdateVictim())
174 return;
175
176 events.Update(diff);
177
179 return;
180
181 while (uint32 eventId = events.ExecuteEvent())
182 {
183 switch (eventId)
184 {
188 break;
191 _scheduledEvents = false;
192 break;
193 case EVENT_DRAIN_MANA:
194 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true))
195 DoCast(target, SPELL_DRAIN_MANA);
197 break;
198 case EVENT_DRAIN_LIFE:
199 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 20.0f, true))
200 DoCast(target, SPELL_DRAIN_LIFE);
202 break;
203 case EVENT_EMPOWER:
204 {
206
208 if (CrystalChosen && CrystalChosen->IsAlive())
209 CrystalChosen->KillSelf();
210
212
215 break;
216 }
217 default:
218 break;
219 }
220
222 return;
223 }
224
225 if (me->GetPowerPct(POWER_MANA) < 10.f)
226 {
228 {
229 _scheduledEvents = true;
230 Milliseconds timer = randtime(3s, 7s);
232
233 if (IsHeroic())
234 {
237 }
238 else
240 }
241 }
242 }
243
244 private:
247 };
248
249 CreatureAI* GetAI(Creature* creature) const override
250 {
251 return GetMagistersTerraceAI<boss_selin_fireheartAI>(creature);
252 };
253};
254
256{
257 public:
258 npc_fel_crystal() : CreatureScript("npc_fel_crystal") { }
259
261 {
262 npc_fel_crystalAI(Creature* creature) : ScriptedAI(creature) { }
263
264 void JustDied(Unit* /*killer*/) override
265 {
266 if (InstanceScript* instance = me->GetInstanceScript())
267 {
268 Creature* selin = instance->GetCreature(DATA_SELIN_FIREHEART);
269 if (selin && selin->IsAlive())
271 }
272 }
273 };
274
275 CreatureAI* GetAI(Creature* creature) const override
276 {
277 return GetMagistersTerraceAI<npc_fel_crystalAI>(creature);
278 };
279};
280
282{
284 new npc_fel_crystal();
285}
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ POINT_MOTION_TYPE
#define CONTACT_DISTANCE
Definition: ObjectDefines.h:23
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition: Random.cpp:62
@ POWER_MANA
@ UNIT_STATE_CASTING
Definition: Unit.h:270
Says
void AddSC_boss_selin_fireheart()
@ SAY_EMPOWERED
@ EMOTE_CRYSTAL
@ ACTION_SWITCH_PHASE
@ SPELL_MANA_RAGE
@ SPELL_FEL_EXPLOSION
@ SPELL_FEL_CRYSTAL_DUMMY
@ SPELL_DRAIN_MANA
@ SPELL_DRAIN_LIFE
@ PHASE_NORMAL
@ EVENT_DRAIN_CRYSTAL
@ EVENT_DRAIN_LIFE
@ EVENT_DRAIN_MANA
@ EVENT_FEL_EXPLOSION
@ EVENT_EMPOWER
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void Clear()
Definition: ObjectGuid.h:286
TypeID GetTypeId() const
Definition: Object.h:173
virtual void DoAction(int32)
Definition: UnitAI.h:72
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
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
float GetCombatReach() const override
Definition: Unit.h:694
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
bool SetWalk(bool enable)
Definition: Unit.cpp:12707
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
float GetPowerPct(Powers power) const
Definition: Unit.h:807
void KillSelf(bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.h:921
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition: Object.cpp:3312
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
@ NPC_FEL_CRYSTAL
@ 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
== Triggered Actions Requested ==================
void MovementInform(uint32 type, uint32 id) override