Skip to content

Commit e13dc98

Browse files
authored
Scripts/AuchenaiCrypts: Modernize Shirrak script (#30938)
1 parent d5470b9 commit e13dc98

File tree

2 files changed

+144
-121
lines changed

2 files changed

+144
-121
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--
2+
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` = 32301;
3+
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
4+
(13,1,32301,0,0,31,0,3,18371,0,0,0,0,"","Group 0: Spell 'Ping Shirrak' (Effect 0) targets creature 'Shirrak the Dead Watcher'");
5+
6+
DELETE FROM `spell_script_names` WHERE `ScriptName` IN('spell_shirrak_ping_shirrak', 'spell_shirrak_inhibit_magic');
7+
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
8+
(32301, 'spell_shirrak_ping_shirrak'),
9+
(32264, 'spell_shirrak_inhibit_magic');
10+
11+
UPDATE `creature_template` SET `flags_extra` = `flags_extra` | 128 WHERE `entry` IN (18374,20308);

src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp

Lines changed: 133 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -15,189 +15,201 @@
1515
* with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
/* ScriptData
19-
Name: Boss_Shirrak_the_dead_watcher
20-
%Complete: 80
21-
Comment: InhibitMagic should stack slower far from the boss, proper Visual for Focus Fire, heroic implemented
22-
Category: Auchindoun, Auchenai Crypts
23-
EndScriptData */
18+
/* Old comment: "Inhibit Magic should stack slower far from the boss" - really? */
2419

20+
#include "ScriptedCreature.h"
2521
#include "ScriptMgr.h"
22+
#include "Spell.h"
23+
#include "SpellScript.h"
24+
#include "SpellInfo.h"
2625
#include "auchenai_crypts.h"
27-
#include "Map.h"
28-
#include "ObjectAccessor.h"
29-
#include "Player.h"
30-
#include "ScriptedCreature.h"
3126

32-
enum Spells
27+
enum ShirrakTexts
3328
{
34-
SPELL_INHIBITMAGIC = 32264,
35-
SPELL_ATTRACTMAGIC = 32265,
36-
SPELL_CARNIVOROUSBITE = 36383,
37-
38-
SPELL_FIERY_BLAST = 32302,
39-
40-
SPELL_FOCUS_FIRE_VISUAL = 42075 //need to find better visual
29+
EMOTE_FOCUSED = 0
4130
};
4231

43-
enum Say
32+
enum ShirrakSpells
4433
{
45-
EMOTE_FOCUSED = 0
34+
SPELL_INHIBIT_MAGIC_PERIODIC = 33460,
35+
SPELL_INHIBIT_MAGIC = 32264,
36+
37+
SPELL_ATTRACT_MAGIC = 32265,
38+
SPELL_CARNIVOROUS_BITE = 36383,
39+
SPELL_FOCUS_FIRE_AURA = 32291,
40+
41+
SPELL_BIRTH = 26262,
42+
SPELL_FOCUS_TARGET_VISUAL = 32286,
43+
SPELL_FIERY_BLAST = 32302,
44+
45+
SPELL_FOCUS_FIRE_DUMMY = 32300,
46+
SPELL_PING_SHIRRAK = 32301
4647
};
4748

48-
enum Creatures
49+
enum ShirrakEvents
4950
{
50-
NPC_FOCUS_FIRE = 18374
51+
EVENT_ATTRACT_MAGIC = 1,
52+
EVENT_CARNIVOROUS_BITE,
53+
EVENT_FOCUS_FIRE
5154
};
5255

56+
// 18371 - Shirrak the Dead Watcher
5357
struct boss_shirrak_the_dead_watcher : public BossAI
5458
{
55-
boss_shirrak_the_dead_watcher(Creature* creature) : BossAI(creature, DATA_SHIRRAK_THE_DEAD_WATCHER)
56-
{
57-
Initialize();
58-
}
59-
60-
void Initialize()
61-
{
62-
Inhibitmagic_Timer = 0;
63-
Attractmagic_Timer = 28000;
64-
Carnivorousbite_Timer = 10000;
65-
FocusFire_Timer = 17000;
66-
FocusedTargetGUID.Clear();
67-
}
68-
69-
uint32 Inhibitmagic_Timer;
70-
uint32 Attractmagic_Timer;
71-
uint32 Carnivorousbite_Timer;
72-
uint32 FocusFire_Timer;
73-
74-
ObjectGuid FocusedTargetGUID;
59+
boss_shirrak_the_dead_watcher(Creature* creature) : BossAI(creature, DATA_SHIRRAK_THE_DEAD_WATCHER) { }
7560

7661
void Reset() override
7762
{
78-
Initialize();
63+
DoCastSelf(SPELL_INHIBIT_MAGIC_PERIODIC);
7964
_Reset();
8065
}
8166

82-
void JustSummoned(Creature* summoned) override
67+
void JustEngagedWith(Unit* who) override
8368
{
84-
if (summoned && summoned->GetEntry() == NPC_FOCUS_FIRE)
85-
{
86-
summoned->CastSpell(summoned, SPELL_FOCUS_FIRE_VISUAL, false);
87-
summoned->SetFaction(me->GetFaction());
88-
summoned->SetLevel(me->GetLevel());
89-
summoned->AddUnitState(UNIT_STATE_ROOT);
90-
91-
if (Unit* pFocusedTarget = ObjectAccessor::GetUnit(*me, FocusedTargetGUID))
92-
summoned->AI()->AttackStart(pFocusedTarget);
93-
}
94-
BossAI::JustSummoned(summoned);
69+
BossAI::JustEngagedWith(who);
70+
events.ScheduleEvent(EVENT_ATTRACT_MAGIC, 30s);
71+
events.ScheduleEvent(EVENT_CARNIVOROUS_BITE, 5s, 10s);
72+
events.ScheduleEvent(EVENT_FOCUS_FIRE, 20s, 30s);
9573
}
9674

9775
void UpdateAI(uint32 diff) override
9876
{
99-
//Inhibitmagic_Timer
100-
if (Inhibitmagic_Timer <= diff)
101-
{
102-
float dist;
103-
Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers();
104-
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
105-
if (Player* i_pl = i->GetSource())
106-
if (i_pl->IsAlive() && (dist = i_pl->GetDistance(me)) < 45)
107-
{
108-
i_pl->RemoveAurasDueToSpell(SPELL_INHIBITMAGIC);
109-
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
110-
if (dist < 35)
111-
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
112-
if (dist < 25)
113-
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
114-
if (dist < 15)
115-
me->AddAura(SPELL_INHIBITMAGIC, i_pl);
116-
}
117-
Inhibitmagic_Timer = 3000 + (rand32() % 1000);
118-
} else Inhibitmagic_Timer -= diff;
119-
120-
//Return since we have no target
12177
if (!UpdateVictim())
12278
return;
12379

124-
//Attractmagic_Timer
125-
if (Attractmagic_Timer <= diff)
126-
{
127-
DoCast(me, SPELL_ATTRACTMAGIC);
128-
Attractmagic_Timer = 30000;
129-
Carnivorousbite_Timer = 1500;
130-
} else Attractmagic_Timer -= diff;
80+
events.Update(diff);
13181

132-
//Carnivorousbite_Timer
133-
if (Carnivorousbite_Timer <= diff)
134-
{
135-
DoCast(me, SPELL_CARNIVOROUSBITE);
136-
Carnivorousbite_Timer = 10000;
137-
} else Carnivorousbite_Timer -= diff;
82+
if (me->HasUnitState(UNIT_STATE_CASTING))
83+
return;
13884

139-
//FocusFire_Timer
140-
if (FocusFire_Timer <= diff)
85+
while (uint32 eventId = events.ExecuteEvent())
14186
{
142-
// Summon Focus Fire & Emote
143-
Unit* target = SelectTarget(SelectTargetMethod::Random, 1);
144-
if (target && target->GetTypeId() == TYPEID_PLAYER && target->IsAlive())
87+
switch (eventId)
14588
{
146-
FocusedTargetGUID = target->GetGUID();
147-
me->SummonCreature(NPC_FOCUS_FIRE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 5500ms);
148-
Talk(EMOTE_FOCUSED, target);
89+
case EVENT_ATTRACT_MAGIC:
90+
DoCastSelf(SPELL_ATTRACT_MAGIC);
91+
events.Repeat(30s);
92+
break;
93+
case EVENT_CARNIVOROUS_BITE:
94+
DoCastSelf(SPELL_CARNIVOROUS_BITE);
95+
events.Repeat(5s, 10s);
96+
break;
97+
case EVENT_FOCUS_FIRE:
98+
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 50, true))
99+
{
100+
DoCast(target, SPELL_FOCUS_FIRE_AURA);
101+
Talk(EMOTE_FOCUSED, target);
102+
}
103+
events.Repeat(15s, 25s);
104+
break;
105+
default:
106+
break;
149107
}
150-
FocusFire_Timer = 15000 + (rand32() % 5000);
151-
} else FocusFire_Timer -= diff;
108+
109+
if (me->HasUnitState(UNIT_STATE_CASTING))
110+
return;
111+
}
152112

153113
DoMeleeAttackIfReady();
154114
}
155115
};
156116

117+
// 18374 - Focus Fire
157118
struct npc_focus_fire : public ScriptedAI
158119
{
159-
npc_focus_fire(Creature* creature) : ScriptedAI(creature)
120+
npc_focus_fire(Creature* creature) : ScriptedAI(creature) { }
121+
122+
void InitializeAI() override
123+
{
124+
me->SetReactState(REACT_PASSIVE);
125+
}
126+
127+
void JustAppeared() override
128+
{
129+
// Should be in this sniffed order but makes it ignore other spell casts, so disabled
130+
// DoCastSelf(SPELL_BIRTH);
131+
DoCastSelf(SPELL_FOCUS_TARGET_VISUAL);
132+
DoCastSelf(SPELL_PING_SHIRRAK);
133+
134+
_scheduler.Schedule(5s, [this](TaskContext /*task*/)
135+
{
136+
DoCastSelf(SPELL_FIERY_BLAST);
137+
});
138+
}
139+
140+
void UpdateAI(uint32 diff) override
141+
{
142+
_scheduler.Update(diff);
143+
}
144+
145+
private:
146+
TaskScheduler _scheduler;
147+
};
148+
149+
// 32301 - Ping Shirrak
150+
class spell_shirrak_ping_shirrak : public SpellScript
151+
{
152+
PrepareSpellScript(spell_shirrak_ping_shirrak);
153+
154+
bool Validate(SpellInfo const* /*spellInfo*/) override
160155
{
161-
Initialize();
156+
return ValidateSpellInfo({ SPELL_FOCUS_FIRE_DUMMY });
162157
}
163158

164-
void Initialize()
159+
void HandleScript(SpellEffIndex /*effIndex*/)
165160
{
166-
FieryBlast_Timer = 3000 + (rand32() % 1000);
167-
fiery1 = fiery2 = true;
161+
GetHitUnit()->CastSpell(GetCaster(), SPELL_FOCUS_FIRE_DUMMY);
168162
}
169163

170-
uint32 FieryBlast_Timer;
171-
bool fiery1, fiery2;
164+
void Register() override
165+
{
166+
OnEffectHitTarget += SpellEffectFn(spell_shirrak_ping_shirrak::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
167+
}
168+
};
172169

173-
void Reset() override
170+
// 32264 - Inhibit Magic
171+
class spell_shirrak_inhibit_magic : public SpellScript
172+
{
173+
PrepareSpellScript(spell_shirrak_inhibit_magic);
174+
175+
void RemoveOldAura(SpellEffIndex /*effIndex*/)
174176
{
175-
Initialize();
177+
GetHitUnit()->RemoveAurasDueToSpell(GetSpellInfo()->Id);
176178
}
177179

178-
void UpdateAI(uint32 diff) override
180+
void TriggerNext()
179181
{
180-
//Return since we have no target
181-
if (!UpdateVictim())
182+
int32 castIndex = GetCastIndex();
183+
if (castIndex >= 3)
182184
return;
183185

184-
//FieryBlast_Timer
185-
if (fiery2 && FieryBlast_Timer <= diff)
186-
{
187-
DoCast(me, SPELL_FIERY_BLAST);
186+
float radiusMod = GetSpellValue()->RadiusMod * 0.66f;
188187

189-
if (fiery1) fiery1 = false;
190-
else if (fiery2) fiery2 = false;
188+
GetCaster()->CastSpell(nullptr, GetSpellInfo()->Id, CastSpellExtraArgs()
189+
.SetTriggerFlags(TRIGGERED_FULL_MASK)
190+
.AddSpellMod(SPELLVALUE_BASE_POINT1, castIndex + 1)
191+
.AddSpellMod(SPELLVALUE_RADIUS_MOD, int32(radiusMod * 10000)));
192+
}
191193

192-
FieryBlast_Timer = 1000;
193-
} else FieryBlast_Timer -= diff;
194+
int32 GetCastIndex() const
195+
{
196+
// we are storing number of casts in a non-effect SPELLVALUE_BASE_POINT1
197+
return GetSpellValue()->EffectBasePoints[EFFECT_1];
198+
}
194199

195-
DoMeleeAttackIfReady();
200+
void Register() override
201+
{
202+
if (!GetSpell() || GetCastIndex() == 0)
203+
OnEffectLaunchTarget += SpellEffectFn(spell_shirrak_inhibit_magic::RemoveOldAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
204+
205+
AfterCast += SpellCastFn(spell_shirrak_inhibit_magic::TriggerNext);
196206
}
197207
};
198208

199209
void AddSC_boss_shirrak_the_dead_watcher()
200210
{
201211
RegisterAuchenaiCryptsCreatureAI(boss_shirrak_the_dead_watcher);
202212
RegisterAuchenaiCryptsCreatureAI(npc_focus_fire);
213+
RegisterSpellScript(spell_shirrak_ping_shirrak);
214+
RegisterSpellScript(spell_shirrak_inhibit_magic);
203215
}

0 commit comments

Comments
 (0)