TrinityCore
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#include "InstanceScript.h"
19#include "Map.h"
20#include "ObjectAccessor.h"
21#include "PassiveAI.h"
22#include "Player.h"
23#include "PlayerAI.h"
24#include "ScriptMgr.h"
25#include "ScriptedCreature.h"
26#include "SpellScript.h"
27#include "shadow_labyrinth.h"
28
30{
36
37 //below, not used
42 SAY2_DEATH = 9
43};
44
46{
48 SPELL_INCITE_CHAOS_B = 33684, //debuff applied to each member of party
49 SPELL_CHARGE = 33709,
50 SPELL_WAR_STOMP = 33707
51};
52
54{
58};
59
61{
63};
64
66{
68 void OnCharmed(bool isNew) override
69 {
70 if (me->GetMap()->IsDungeon())
72 {
73 blackheart->AI()->SetData(0, me->IsCharmed());
74 blackheart->GetThreatManager().AddThreat(me, 0.0f);
75 }
77 }
78};
79
81{
83
84 void Reset() override
85 {
87 _Reset();
88 }
89
90 void JustEngagedWith(Unit* who) override
91 {
96
98 }
99
100 void KilledUnit(Unit* who) override
101 {
102 if (who->GetTypeId() == TYPEID_PLAYER)
103 Talk(SAY_SLAY);
104 }
105
106 void JustDied(Unit* /*killer*/) override
107 {
108 _JustDied();
110 }
111
113 void SetData(uint32 /*index*/, uint32 data) override
114 {
115 if (data)
116 ++charmCount;
117 else
118 {
119 if (!charmCount)
120 EnterEvadeMode(EvadeReason::Other); // sanity check
121 --charmCount;
122 }
123 if (charmCount)
125 else
127 }
128
129 void UpdateAI(uint32 diff) override
130 {
131 events.Update(diff);
133 return;
134
136 return;
137
138 while (uint32 eventId = events.ExecuteEvent())
139 {
140 switch (eventId)
141 {
143 {
145 {
148 }
150 break;
151 }
154 DoCast(target, SPELL_CHARGE);
156 break;
157 case EVENT_WAR_STOMP:
160 break;
161 }
162
164 return;
165 }
166 }
167
168 void WaypointReached(uint32 waypointId, uint32 pathId) override
169 {
170 if (pathId != PATH_BLACKHEART_IDLE)
171 return;
172
173 if (waypointId == 2)
174 Talk(SAY_DEATH); // ?
175 else if (waypointId == 3)
176 Talk(SAY_AGGRO); // ?
177 }
178};
179
181{
185 void IsSummonedBy(WorldObject* whoWO) override
186 {
187 Unit* who = whoWO->ToUnit();
188 if (!who)
189 return;
190 me->CastSpell(who, SPELL_INCITE_CHAOS_B, true);
191
192 // ensure everyone is in combat with everyone
194 for (ObjectGuid const& guid : *dummies)
195 if (Creature* trigger = ObjectAccessor::GetCreature(*me, guid))
196 if (me->GetEntry() != trigger->GetEntry())
197 {
198 me->GetThreatManager().AddThreat(trigger, 0.0f);
199 trigger->GetThreatManager().AddThreat(who, 0.0f);
200 for (Unit* other : trigger->m_Controlled)
201 {
202 me->GetThreatManager().AddThreat(other, 0.0f);
203 other->GetThreatManager().AddThreat(who, 0.0f);
204 }
205 }
206 }
207
208 void UpdateAI(uint32 /*diff*/) override
209 {
210 if (me->m_Controlled.empty())
212 }
213
215 {
216 return new BlackheartCharmedPlayerAI(player);
217 }
218};
219
220// 33676 - Incite Chaos
222{
223 bool Validate(SpellInfo const* /*spell*/) override
224 {
226 }
227
228 static const uint8 NUM_INCITE_SPELLS = 5;
231 void HandleDummy(SpellEffIndex /*effIndex*/)
232 {
233 if (Unit* target = GetHitUnit())
234 {
235 target->CastSpell(nullptr, INCITE_SPELLS[i], true);
236 i = (i + 1) % NUM_INCITE_SPELLS;
237 }
238 }
239
240 void Register() override
241 {
243 }
244};
246
248{
252}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition: ObjectGuid.h:396
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ EVENT_CHARGE
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
@ UNIT_STATE_CASTING
Definition: Unit.h:270
void AddSC_boss_blackheart_the_inciter()
void OnCharmed(bool isNew) override
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
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
bool HasReactState(ReactStates state) const
Definition: Creature.h:162
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
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
virtual ObjectGuid GetGuidData(uint32 type) const override
bool IsDungeon() const
Definition: Map.cpp:3238
NullCreatureAI(Creature *creature, uint32 scriptId={})
Definition: PassiveAI.cpp:33
static Unit * ToUnit(Object *o)
Definition: Object.h:225
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
Player *const me
Definition: PlayerAI.h:51
void OnCharmed(bool isNew) override
Definition: PlayerAI.cpp:1288
SimpleCharmedPlayerAI(Player *player)
Definition: PlayerAI.h:97
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
void AddThreat(Unit *target, float amount, SpellInfo const *spell=nullptr, bool ignoreModifiers=false, bool ignoreRedirects=false)
== AFFECT MY THREAT LIST ==
size_t GetThreatListSize() const
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 DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool IsCharmed() const
Definition: Unit.h:1215
ThreatManager & GetThreatManager()
Definition: Unit.h:1063
ControlList m_Controlled
Definition: Unit.h:1211
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
Map * GetMap() const
Definition: Object.h:624
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
bool Validate(SpellInfo const *) override
static const uint32 INCITE_SPELLS[NUM_INCITE_SPELLS]
GuidUnorderedSet const * GetBlackheartDummies(InstanceScript const *s)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ NPC_BLACKHEART_DUMMY1
@ NPC_BLACKHEART_DUMMY5
#define RegisterShadowLabyrinthCreatureAI(ai_name)
@ DATA_BLACKHEART_THE_INCITER
void ResetThreatList(Unit *who=nullptr)
void IsSummonedBy(WorldObject *whoWO) override
PlayerAI * GetAIForCharmedPlayer(Player *player) override
void WaypointReached(uint32 waypointId, uint32 pathId) override
void SetData(uint32, uint32 data) override
void JustEngagedWith(Unit *who) override