1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "black_temple.h"
#include "ObjectAccessor.h"
#include "ScriptedCreature.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
enum Spells
{
// Wrathbone Flayer
SPELL_CLEAVE = 15496,
SPELL_IGNORED = 39544,
SPELL_SUMMON_CHANNEL = 40094,
// Angered Soul Fragment
SPELL_GREATER_INVISIBILITY = 41253,
SPELL_ANGER = 41986,
// Illidari Nightlord
SPELL_SHADOW_INFERNO_DAMAGE = 39646
};
enum Creatures
{
NPC_BLOOD_MAGE = 22945,
NPC_DEATHSHAPER = 22882
};
enum Events
{
// Wrathbone Flayer
EVENT_GET_CHANNELERS = 1,
EVENT_SET_CHANNELERS,
EVENT_CLEAVE,
EVENT_IGNORED
};
enum Misc
{
GROUP_OUT_OF_COMBAT = 1
};
struct npc_wrathbone_flayer : public ScriptedAI
{
npc_wrathbone_flayer(Creature* creature) : ScriptedAI(creature)
{
Initialize();
_instance = creature->GetInstanceScript();
}
void Initialize()
{
_enteredCombat = false;
}
void Reset() override
{
_events.ScheduleEvent(EVENT_GET_CHANNELERS, 3s);
Initialize();
_bloodmageList.clear();
_deathshaperList.clear();
}
void JustDied(Unit* /*killer*/) override { }
void JustEngagedWith(Unit* /*who*/) override
{
_events.ScheduleEvent(EVENT_CLEAVE, 5s);
_events.ScheduleEvent(EVENT_IGNORED, 7s);
_enteredCombat = true;
}
void UpdateAI(uint32 diff) override
{
if (!_enteredCombat)
{
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_GET_CHANNELERS:
{
std::list<Creature*> BloodMageList;
me->GetCreatureListWithEntryInGrid(BloodMageList, NPC_BLOOD_MAGE, 15.0f);
if (!BloodMageList.empty())
for (std::list<Creature*>::const_iterator itr = BloodMageList.begin(); itr != BloodMageList.end(); ++itr)
{
_bloodmageList.push_back((*itr)->GetGUID());
if ((*itr)->isDead())
(*itr)->Respawn();
}
std::list<Creature*> DeathShaperList;
me->GetCreatureListWithEntryInGrid(DeathShaperList, NPC_DEATHSHAPER, 15.0f);
if (!DeathShaperList.empty())
for (std::list<Creature*>::const_iterator itr = DeathShaperList.begin(); itr != DeathShaperList.end(); ++itr)
{
_deathshaperList.push_back((*itr)->GetGUID());
if ((*itr)->isDead())
(*itr)->Respawn();
}
_events.ScheduleEvent(EVENT_SET_CHANNELERS, 3s);
break;
}
case EVENT_SET_CHANNELERS:
{
for (ObjectGuid guid : _bloodmageList)
if (Creature* bloodmage = ObjectAccessor::GetCreature(*me, guid))
bloodmage->CastSpell(nullptr, SPELL_SUMMON_CHANNEL);
for (ObjectGuid guid : _deathshaperList)
if (Creature* deathshaper = ObjectAccessor::GetCreature(*me, guid))
deathshaper->CastSpell(nullptr, SPELL_SUMMON_CHANNEL);
_events.ScheduleEvent(EVENT_SET_CHANNELERS, 12s);
break;
}
default:
break;
}
}
}
if (!UpdateVictim())
return;
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_CLEAVE:
DoCastVictim(SPELL_CLEAVE);
_events.ScheduleEvent(EVENT_CLEAVE, 1s, 2s);
break;
case EVENT_IGNORED:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
DoCast(target, SPELL_IGNORED);
_events.ScheduleEvent(EVENT_IGNORED, 10s);
break;
default:
break;
}
}
}
private:
InstanceScript* _instance;
EventMap _events;
GuidList _bloodmageList;
GuidList _deathshaperList;
bool _enteredCombat;
};
struct npc_angered_soul_fragment : public ScriptedAI
{
npc_angered_soul_fragment(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
_scheduler.Schedule(Seconds(1), GROUP_OUT_OF_COMBAT, [this](TaskContext invi)
{
DoCastSelf(SPELL_GREATER_INVISIBILITY);
/* Workaround - On Retail creature appear and "vanish" again periodically, but i cant find packets
with UPDATE_AURA on sniffs about it */
_scheduler.Schedule(Seconds(5), Seconds(10), GROUP_OUT_OF_COMBAT, [this](TaskContext /*context*/)
{
me->RemoveAurasDueToSpell(SPELL_GREATER_INVISIBILITY);
});
invi.Repeat(Seconds(15), Seconds(25));
});
}
void JustEngagedWith(Unit* /*who*/) override
{
me->RemoveAurasDueToSpell(SPELL_GREATER_INVISIBILITY);
_scheduler.CancelGroup(GROUP_OUT_OF_COMBAT);
_scheduler.Schedule(Seconds(1), [this](TaskContext anger)
{
Unit* target = me->GetVictim();
if (target && me->IsWithinMeleeRange(target))
DoCastSelf(SPELL_ANGER);
else
anger.Repeat(Seconds(1));
});
}
void UpdateAI(uint32 diff) override
{
_scheduler.Update(diff);
if (!UpdateVictim())
return;
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
private:
TaskScheduler _scheduler;
};
// 41986 - Anger
class spell_soul_fragment_anger : public SpellScript
{
void HandleKill()
{
if (Creature* caster = GetCaster()->ToCreature())
caster->DespawnOrUnsummon(Milliseconds(200));
}
void Register() override
{
AfterCast += SpellCastFn(spell_soul_fragment_anger::HandleKill);
}
};
// 39645 - Shadow Inferno
class spell_illidari_nightlord_shadow_inferno : public AuraScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_SHADOW_INFERNO_DAMAGE });
}
void OnPeriodic(AuraEffect const* aurEffect)
{
PreventDefaultAction();
int32 bp = aurEffect->GetTickNumber() * aurEffect->GetAmount();
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SHADOW_INFERNO_DAMAGE, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellBP0(bp));
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_illidari_nightlord_shadow_inferno::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
void AddSC_black_temple()
{
RegisterBlackTempleCreatureAI(npc_wrathbone_flayer);
RegisterBlackTempleCreatureAI(npc_angered_soul_fragment);
RegisterSpellScript(spell_soul_fragment_anger);
RegisterSpellScript(spell_illidari_nightlord_shadow_inferno);
}
|