TrinityCore
black_temple.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 "black_temple.h"
20#include "ObjectAccessor.h"
21#include "ScriptedCreature.h"
22#include "SpellAuraEffects.h"
23#include "SpellScript.h"
24
26{
27 // Wrathbone Flayer
28 SPELL_CLEAVE = 15496,
31
32 // Angered Soul Fragment
34 SPELL_ANGER = 41986,
35
36 // Illidari Nightlord
38};
39
41{
43 NPC_DEATHSHAPER = 22882
44};
45
47{
48 // Wrathbone Flayer
53};
54
55enum Misc
56{
58};
59
61{
63 {
64 Initialize();
65 _instance = creature->GetInstanceScript();
66 }
67
69 {
70 _enteredCombat = false;
71 }
72
73 void Reset() override
74 {
76 Initialize();
77 _bloodmageList.clear();
78 _deathshaperList.clear();
79 }
80
81 void JustDied(Unit* /*killer*/) override { }
82
83 void JustEngagedWith(Unit* /*who*/) override
84 {
87 _enteredCombat = true;
88 }
89
90 void UpdateAI(uint32 diff) override
91 {
92 if (!_enteredCombat)
93 {
94 _events.Update(diff);
95
96 while (uint32 eventId = _events.ExecuteEvent())
97 {
98 switch (eventId)
99 {
101 {
102 std::list<Creature*> BloodMageList;
103 me->GetCreatureListWithEntryInGrid(BloodMageList, NPC_BLOOD_MAGE, 15.0f);
104
105 if (!BloodMageList.empty())
106 for (std::list<Creature*>::const_iterator itr = BloodMageList.begin(); itr != BloodMageList.end(); ++itr)
107 {
108 _bloodmageList.push_back((*itr)->GetGUID());
109 if ((*itr)->isDead())
110 (*itr)->Respawn();
111 }
112
113 std::list<Creature*> DeathShaperList;
114 me->GetCreatureListWithEntryInGrid(DeathShaperList, NPC_DEATHSHAPER, 15.0f);
115
116 if (!DeathShaperList.empty())
117 for (std::list<Creature*>::const_iterator itr = DeathShaperList.begin(); itr != DeathShaperList.end(); ++itr)
118 {
119 _deathshaperList.push_back((*itr)->GetGUID());
120 if ((*itr)->isDead())
121 (*itr)->Respawn();
122 }
123
125
126 break;
127 }
129 {
130 for (ObjectGuid guid : _bloodmageList)
131 if (Creature* bloodmage = ObjectAccessor::GetCreature(*me, guid))
132 bloodmage->CastSpell(nullptr, SPELL_SUMMON_CHANNEL);
133
134 for (ObjectGuid guid : _deathshaperList)
135 if (Creature* deathshaper = ObjectAccessor::GetCreature(*me, guid))
136 deathshaper->CastSpell(nullptr, SPELL_SUMMON_CHANNEL);
137
139
140 break;
141 }
142 default:
143 break;
144 }
145 }
146 }
147
148 if (!UpdateVictim())
149 return;
150
151 _events.Update(diff);
152
153 while (uint32 eventId = _events.ExecuteEvent())
154 {
155 switch (eventId)
156 {
157 case EVENT_CLEAVE:
160 break;
161 case EVENT_IGNORED:
163 DoCast(target, SPELL_IGNORED);
165 break;
166 default:
167 break;
168 }
169 }
170 }
171
172private:
178};
179
181{
183
184 void Reset() override
185 {
187
189 {
191
192 /* Workaround - On Retail creature appear and "vanish" again periodically, but i cant find packets
193 with UPDATE_AURA on sniffs about it */
195 {
197 });
198
199 invi.Repeat(Seconds(15), Seconds(25));
200 });
201 }
202
203 void JustEngagedWith(Unit* /*who*/) override
204 {
206
208 _scheduler.Schedule(Seconds(1), [this](TaskContext anger)
209 {
210 Unit* target = me->GetVictim();
211 if (target && me->IsWithinMeleeRange(target))
213 else
214 anger.Repeat(Seconds(1));
215 });
216 }
217
218 void UpdateAI(uint32 diff) override
219 {
220 _scheduler.Update(diff);
221
222 if (!UpdateVictim())
223 return;
224
226 return;
227 }
228
229private:
231};
232
233// 41986 - Anger
235{
237 {
238 if (Creature* caster = GetCaster()->ToCreature())
239 caster->DespawnOrUnsummon(Milliseconds(200));
240 }
241
242 void Register() override
243 {
245 }
246};
247
248// 39645 - Shadow Inferno
250{
251 bool Validate(SpellInfo const* /*spellInfo*/) override
252 {
254 }
255
256 void OnPeriodic(AuraEffect const* aurEffect)
257 {
259 int32 bp = aurEffect->GetTickNumber() * aurEffect->GetAmount();
261 }
262
263 void Register() override
264 {
266 }
267};
268
270{
275}
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define SpellCastFn(F)
Definition: SpellScript.h:825
@ UNIT_STATE_CASTING
Definition: Unit.h:270
void AddSC_black_temple()
@ NPC_BLOOD_MAGE
@ NPC_DEATHSHAPER
@ GROUP_OUT_OF_COMBAT
@ SPELL_GREATER_INVISIBILITY
@ SPELL_CLEAVE
@ SPELL_ANGER
@ SPELL_SHADOW_INFERNO_DAMAGE
@ SPELL_SUMMON_CHANNEL
@ SPELL_IGNORED
@ EVENT_GET_CHANNELERS
@ EVENT_SET_CHANNELERS
@ EVENT_CLEAVE
@ EVENT_IGNORED
#define RegisterBlackTempleCreatureAI(ai_name)
Definition: black_temple.h:149
uint32 GetTickNumber() const
int32 GetAmount() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetUnitOwner() const
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
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
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
HookList< CastHandler > AfterCast
Definition: SpellScript.h:824
Unit * GetCaster() const
TaskContext & Repeat(std::chrono::duration< Rep, Period > duration)
TaskScheduler & CancelGroup(group_t group)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
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 IsWithinMeleeRange(Unit const *obj) const
Definition: Unit.h:699
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
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
bool Validate(SpellInfo const *) override
void OnPeriodic(AuraEffect const *aurEffect)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void JustEngagedWith(Unit *) override
npc_angered_soul_fragment(Creature *creature)
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
InstanceScript * _instance
void JustDied(Unit *) override
npc_wrathbone_flayer(Creature *creature)
void Reset() override