TrinityCore
Loading...
Searching...
No Matches
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
45
54
59
60// 22953 - Wrathbone Flayer
62{
64 {
65 Initialize();
66 _instance = creature->GetInstanceScript();
67 }
68
70 {
71 _enteredCombat = false;
72 }
73
74 void Reset() override
75 {
77 Initialize();
78 _bloodmageList.clear();
79 _deathshaperList.clear();
80 }
81
82 void JustDied(Unit* /*killer*/) override { }
83
84 void JustEngagedWith(Unit* /*who*/) override
85 {
88 _enteredCombat = true;
89 }
90
91 void UpdateAI(uint32 diff) override
92 {
93 if (!_enteredCombat)
94 {
95 _events.Update(diff);
96
97 while (uint32 eventId = _events.ExecuteEvent())
98 {
99 switch (eventId)
100 {
102 {
103 std::list<Creature*> BloodMageList;
104 me->GetCreatureListWithEntryInGrid(BloodMageList, NPC_BLOOD_MAGE, 15.0f);
105
106 if (!BloodMageList.empty())
107 for (std::list<Creature*>::const_iterator itr = BloodMageList.begin(); itr != BloodMageList.end(); ++itr)
108 {
109 _bloodmageList.push_back((*itr)->GetGUID());
110 if ((*itr)->isDead())
111 (*itr)->Respawn();
112 }
113
114 std::list<Creature*> DeathShaperList;
115 me->GetCreatureListWithEntryInGrid(DeathShaperList, NPC_DEATHSHAPER, 15.0f);
116
117 if (!DeathShaperList.empty())
118 for (std::list<Creature*>::const_iterator itr = DeathShaperList.begin(); itr != DeathShaperList.end(); ++itr)
119 {
120 _deathshaperList.push_back((*itr)->GetGUID());
121 if ((*itr)->isDead())
122 (*itr)->Respawn();
123 }
124
126
127 break;
128 }
130 {
131 for (ObjectGuid guid : _bloodmageList)
132 if (Creature* bloodmage = ObjectAccessor::GetCreature(*me, guid))
133 bloodmage->CastSpell(nullptr, SPELL_SUMMON_CHANNEL);
134
135 for (ObjectGuid guid : _deathshaperList)
136 if (Creature* deathshaper = ObjectAccessor::GetCreature(*me, guid))
137 deathshaper->CastSpell(nullptr, SPELL_SUMMON_CHANNEL);
138
139 _events.Repeat(12s);
140
141 break;
142 }
143 default:
144 break;
145 }
146 }
147 }
148
149 if (!UpdateVictim())
150 return;
151
152 _events.Update(diff);
153
154 while (uint32 eventId = _events.ExecuteEvent())
155 {
156 switch (eventId)
157 {
158 case EVENT_CLEAVE:
160 _events.Repeat(1s, 2s);
161 break;
162 case EVENT_IGNORED:
164 DoCast(target, SPELL_IGNORED);
165 _events.Repeat(10s);
166 break;
167 default:
168 break;
169 }
170 }
172 }
173
174private:
180};
181
182// 23398 - Angered Soul Fragment
184{
186
187 void Reset() override
188 {
190
192 {
194
195 /* Workaround - On Retail creature appear and "vanish" again periodically, but i cant find packets
196 with UPDATE_AURA on sniffs about it */
197 _scheduler.Schedule(5s, 10s, GROUP_OUT_OF_COMBAT, [this](TaskContext /*context*/)
198 {
200 });
201
202 invi.Repeat(15s, 25s);
203 });
204 }
205
206 void JustEngagedWith(Unit* /*who*/) override
207 {
209
211 _scheduler.Schedule(1s, [this](TaskContext anger)
212 {
213 Unit* target = me->GetVictim();
214 if (target && me->IsWithinMeleeRange(target))
216 else
217 anger.Repeat(1s);
218 });
219 }
220
221 void UpdateAI(uint32 diff) override
222 {
223 _scheduler.Update(diff);
224
225 if (!UpdateVictim())
226 return;
227
229 return;
230
232 }
233
234private:
236};
237
238// 41986 - Anger
240{
242
244 {
245 if (Creature* caster = GetCaster()->ToCreature())
246 caster->DespawnOrUnsummon(Milliseconds(200));
247 }
248
253};
254
255// 39645 - Shadow Inferno
277
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
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:261
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
@ EFFECT_0
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCastFn(F)
@ UNIT_STATE_CASTING
Definition Unit.h:235
BlackTempleEvents
@ EVENT_GET_CHANNELERS
@ EVENT_SET_CHANNELERS
@ EVENT_CLEAVE
@ EVENT_IGNORED
void AddSC_black_temple()
BlackTempleSpells
@ SPELL_GREATER_INVISIBILITY
@ SPELL_CLEAVE
@ SPELL_ANGER
@ SPELL_SHADOW_INFERNO_DAMAGE
@ SPELL_SUMMON_CHANNEL
@ SPELL_IGNORED
BlackTempleCreatures
@ NPC_BLOOD_MAGE
@ NPC_DEATHSHAPER
BlackTempleMisc
@ GROUP_OUT_OF_COMBAT
#define RegisterBlackTempleCreatureAI(ai_name)
uint32 GetTickNumber() const
int32 GetAmount() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetUnitOwner() const
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
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
HookList< CastHandler > AfterCast
Unit * GetCaster() const
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
TaskScheduler & CancelGroup(group_t const group)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
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:769
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:844
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
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
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareAuraScript(spell_illidari_nightlord_shadow_inferno)
bool Validate(SpellInfo const *) override
void OnPeriodic(AuraEffect const *aurEffect)
PrepareSpellScript(spell_soul_fragment_anger)
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