TrinityCore
Loading...
Searching...
No Matches
boss_blackheart_the_inciter.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/*
19 * Timers requires to be revisited
20 * SPELL_CHARM_BREAK_HARDCODED is NYI. Don't know what is the purpose of this spell
21 * Blackheart should engage all creatures in his room on aggro
22 * Waypoint script requires rewrite
23 * For unknown reason only current Blackheart's victim runs to attack other player while charmed
24 */
25
26#include "ScriptMgr.h"
27#include "InstanceScript.h"
28#include "Player.h"
29#include "PlayerAI.h"
30#include "ScriptedCreature.h"
31#include "SpellInfo.h"
32#include "SpellScript.h"
33#include "shadow_labyrinth.h"
34#include "TemporarySummon.h"
35
43
45{
46 // Blackheart - Combat
49 SPELL_CHARGE = 33709,
50
51 // Blackheart - Combat - Misc
52 SPELL_LAUGH = 33722,
53
54 // Dummy
55 SPELL_THREAT = 34915,
60
61 // Scripts
67};
68
75
84
85// 18667 - Blackheart the Inciter
87{
89
100
101 void OnSpellCast(SpellInfo const* spellInfo) override
102 {
103 if (spellInfo->Id == SPELL_INCITE_CHAOS)
104 {
107 }
108 }
109
110 void KilledUnit(Unit* /*who*/) override
111 {
112 Talk(SAY_SLAY);
113 }
114
115 void JustDied(Unit* /*killer*/) override
116 {
117 _JustDied();
119 }
120
121 void UpdateAI(uint32 diff) override
122 {
123 if (!UpdateVictim())
124 return;
125
126 events.Update(diff);
127
129 return;
130
131 while (uint32 eventId = events.ExecuteEvent())
132 {
133 switch (eventId)
134 {
137 {
140 }
141 events.Repeat(50s, 80s);
142 break;
143 case EVENT_WAR_STOMP:
145 events.Repeat(15s, 30s);
146 break;
149 DoCast(target, SPELL_CHARGE);
150 events.Repeat(15s, 25s);
151 break;
152 default:
153 break;
154 }
155
157 return;
158 }
159
161 }
162};
163
165{
167
168 bool CanAIAttack(Unit const* target) const override
169 {
170 if (target->GetEntry() == NPC_BLACKHEART)
171 return false;
172
174 }
175
176 Unit* SelectAttackTarget() const override
177 {
178 if (InstanceScript* instance = me->GetInstanceScript())
179 if (Creature* creature = instance->GetCreature(DATA_BLACKHEART_THE_INCITER))
180 if (Unit* target = creature->AI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true))
181 return target;
182
183 return nullptr;
184 }
185};
186
187// 19300, 19301, 19302, 19303, 19304 - Blackheart the Inciter
189{
190 npc_blackheart_the_inciter_dummy(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
191
197
198 void JustAppeared() override
199 {
201 DoCast(creature, SPELL_THREAT);
202
203 if (TempSummon* summon = me->ToTempSummon())
204 if (Unit* summoner = summon->GetSummonerUnit())
206
208 .SetValidator([this]
209 {
211 })
212 .Schedule(5s, [this](TaskContext /*task*/)
213 {
215 })
216 .Schedule(5s, 10s, [this](TaskContext task)
217 {
218 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
219 DoCast(target, SPELL_DUMMY_NUKE);
220 task.Repeat(2s, 4s);
221 });
222 }
223
224 void UpdateAI(uint32 diff) override
225 {
226 UpdateVictim();
227
228 _scheduler.Update(diff);
229 }
230
232 {
233 return new BlackheartCharmedPlayerAI(player);
234 }
235
236private:
239};
240
241// 33676 - Incite Chaos
243{
245
246public:
247 bool Validate(SpellInfo const* /*spellInfo*/) override
248 {
250 }
251
252 void HandleScript(SpellEffIndex /*effIndex*/)
253 {
254 GetHitUnit()->CastSpell(nullptr, InciteChaosSummonSpells[std::min(_targetCount, InciteChaosSummonSpells.size() - 1)], true);
255 _targetCount++;
256 }
257
262
263private:
264 std::size_t _targetCount = 0;
265};
266
267// 33684 - Incite Chaos
269{
271
272 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
273 {
274 if (Unit* caster = GetCaster())
275 if (Creature* creature = caster->ToCreature())
276 creature->DespawnOrUnsummon();
277 }
278
283};
284
uint32_t uint32
Definition Define.h:133
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_MOD_CHARM
#define SpellEffectFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:249
static constexpr std::array< uint32, 5 > InciteChaosSummonSpells
void AddSC_boss_blackheart_the_inciter()
HookList< EffectApplyHandler > AfterEffectRemove
Unit * GetCaster() const
bool CanAIAttack(Unit const *target) const override
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetDisplayId(uint32 modelId) override
void SetReactState(ReactStates st)
Definition Creature.h:128
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:195
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Creature * GetCreature(uint32 type)
static Creature * ToCreature(Object *o)
Definition Object.h:189
uint32 GetEntry() const
Definition Object.h:81
Player *const me
Definition PlayerAI.h:52
bool CanAIAttack(Unit const *who) const override
Definition PlayerAI.cpp:625
SimpleCharmedPlayerAI(Player *player)
Definition PlayerAI.h:98
uint32 Id
Definition SpellInfo.h:289
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
uint32 GetThreatListPlayerCount(bool includeOffline=false) const
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
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 DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:783
ThreatManager & GetThreatManager()
Definition Unit.h:1169
TempSummon * ToTempSummon()
Definition Unit.h:1810
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1088
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareAuraScript(spell_blackheart_incite_chaos_charm)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
PrepareSpellScript(spell_blackheart_incite_chaos)
bool Validate(SpellInfo const *) override
@ NPC_BLACKHEART
#define RegisterShadowLabyrinthCreatureAI(ai_name)
@ DATA_BLACKHEART_THE_INCITER
void ResetThreatList(Unit *who=nullptr)
void OnSpellCast(SpellInfo const *spellInfo) override
PlayerAI * GetAIForCharmedPlayer(Player *player) override