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 }
171 }
172
173private:
179};
180
181// 23398 - Angered Soul Fragment
183{
185
186 void Reset() override
187 {
189
191 {
193
194 /* Workaround - On Retail creature appear and "vanish" again periodically, but i cant find packets
195 with UPDATE_AURA on sniffs about it */
196 _scheduler.Schedule(5s, 10s, GROUP_OUT_OF_COMBAT, [this](TaskContext const& /*context*/)
197 {
199 });
200
201 invi.Repeat(15s, 25s);
202 });
203 }
204
205 void JustEngagedWith(Unit* /*who*/) override
206 {
208
210 _scheduler.Schedule(1s, [this](TaskContext& anger)
211 {
212 Unit* target = me->GetVictim();
213 if (target && me->IsWithinMeleeRange(target))
215 else
216 anger.Repeat(1s);
217 });
218 }
219
220 void UpdateAI(uint32 diff) override
221 {
222 _scheduler.Update(diff);
223
224 if (!UpdateVictim())
225 return;
226
228 return;
229 }
230
231private:
233};
234
235// 41986 - Anger
237{
239 {
240 if (Creature* caster = GetCaster()->ToCreature())
241 caster->DespawnOrUnsummon(Milliseconds(200));
242 }
243
248};
249
250// 39645 - Shadow Inferno
270
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:433
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_0
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
double SpellEffectValue
This is a double instead of float to be able to store full range of int32.
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCastFn(F)
@ UNIT_STATE_CASTING
Definition Unit.h:290
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
SpellEffectValue GetAmount() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetUnitOwner() const
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
HookList< CastHandler > AfterCast
Unit * GetCaster() const
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelGroup(group_t group)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:722
Unit * GetVictim() const
Definition Unit.h:738
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
InstanceScript * GetInstanceScript() const
Definition Object.cpp:394
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition Object.cpp:2663
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
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