Skip to content

Commit 46d2739

Browse files
authored
fix(Scripts/AhnKahet): Modernize Amanitar script (#22254)
1 parent 68818ca commit 46d2739

File tree

1 file changed

+40
-94
lines changed

1 file changed

+40
-94
lines changed

src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp

Lines changed: 40 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ enum Creatures
4949

5050
enum Events
5151
{
52-
// Boss
53-
EVENT_RESPAWN = 1,
54-
EVENT_ROOTS,
55-
EVENT_BASH,
56-
EVENT_BOLT,
57-
EVENT_REMOVE_MUSHROOM_POWER,
58-
EVENT_MINI,
59-
6052
// Mushroom
6153
EVENT_GROW,
6254
EVENT_CHECK_PLAYER,
@@ -113,11 +105,46 @@ struct boss_amanitar : public BossAI
113105

114106
void JustEngagedWith(Unit* /*attacker*/) override
115107
{
116-
events.ScheduleEvent(EVENT_ROOTS, 5s, 9s);
117-
events.ScheduleEvent(EVENT_BASH, 10s, 14s);
118-
events.ScheduleEvent(EVENT_BOLT, 15s, 20s);
119-
events.ScheduleEvent(EVENT_MINI, 1s);
120-
events.ScheduleEvent(EVENT_RESPAWN, 40s, 60s);
108+
ScheduleTimedEvent(5s, 9s, [&]{
109+
DoCastRandomTarget(SPELL_ENTANGLING_ROOTS, 1, 100.0f);
110+
}, 10s, 15s);
111+
112+
ScheduleTimedEvent(10s, 14s, [&] {
113+
DoCastVictim(SPELL_BASH, false);
114+
}, 15s, 20s);
115+
116+
ScheduleTimedEvent(15s, 20s, [&] {
117+
DoCastAOE(SPELL_VENOM_BOLT_VOLLEY);
118+
}, 15s, 20s);
119+
120+
ScheduleTimedEvent(40s, 60s, [&] {
121+
while (!_mushroomsDeque.empty())
122+
{
123+
SummonMushroom(_mushroomsDeque.front());
124+
_mushroomsDeque.pop_front();
125+
}
126+
}, 40s, 60s);
127+
128+
for (Position pos : MushroomPositions)
129+
SummonMushroom(pos);
130+
131+
scheduler.Schedule(25s, 32s, [this](TaskContext context) {
132+
if (SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true, -SPELL_MINI))
133+
{
134+
DoCastSelf(SPELL_REMOVE_MUSHROOM_POWER, true);
135+
DoCastAOE(SPELL_MINI);
136+
scheduler.Schedule(29s, [this](TaskContext)
137+
{
138+
DoCastAOE(SPELL_REMOVE_MUSHROOM_POWER, true);
139+
});
140+
141+
context.Repeat(30s, 45s);
142+
}
143+
else
144+
{
145+
context.Repeat(1s);
146+
}
147+
});
121148
}
122149

123150
void JustDied(Unit* /*killer*/) override
@@ -126,11 +153,6 @@ struct boss_amanitar : public BossAI
126153
instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_MINI);
127154
}
128155

129-
void JustSummoned(Creature* summon) override
130-
{
131-
summons.Summon(summon);
132-
}
133-
134156
void SummonedCreatureDies(Creature* summon, Unit* killer) override
135157
{
136158
_mushroomsDeque.push_back(summon->GetPosition());
@@ -143,80 +165,6 @@ struct boss_amanitar : public BossAI
143165
BossAI::EnterEvadeMode(why);
144166
}
145167

146-
void ExecuteEvent(uint32 eventId) override
147-
{
148-
switch (eventId)
149-
{
150-
case EVENT_RESPAWN:
151-
{
152-
while (!_mushroomsDeque.empty())
153-
{
154-
SummonMushroom(_mushroomsDeque.front());
155-
_mushroomsDeque.pop_front();
156-
}
157-
158-
events.Repeat(40s, 60s);
159-
break;
160-
}
161-
case EVENT_ROOTS:
162-
{
163-
if (Unit* pTarget = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
164-
{
165-
DoCast(pTarget, SPELL_ENTANGLING_ROOTS, false);
166-
}
167-
168-
events.Repeat(10s, 15s);
169-
break;
170-
}
171-
case EVENT_BASH:
172-
{
173-
DoCastVictim(SPELL_BASH, false);
174-
events.Repeat(15s, 20s);
175-
break;
176-
}
177-
case EVENT_BOLT:
178-
{
179-
if (Unit* pTarget = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
180-
{
181-
DoCast(pTarget, SPELL_VENOM_BOLT_VOLLEY, false);
182-
}
183-
184-
events.Repeat(15s, 20s);
185-
break;
186-
}
187-
case EVENT_REMOVE_MUSHROOM_POWER:
188-
{
189-
DoCastAOE(SPELL_REMOVE_MUSHROOM_POWER, true);
190-
events.RescheduleEvent(EVENT_MINI, 1s);
191-
break;
192-
}
193-
case EVENT_MINI:
194-
{
195-
if (!mushroomsSummoned)
196-
{
197-
mushroomsSummoned = true;
198-
for (uint8 i = 0; i < MAX_MUSHROOMS_COUNT; ++i)
199-
{
200-
SummonMushroom(MushroomPositions[i]);
201-
}
202-
}
203-
204-
if (SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true, -SPELL_MINI))
205-
{
206-
DoCastSelf(SPELL_REMOVE_MUSHROOM_POWER, true);
207-
DoCastAOE(SPELL_MINI);
208-
events.RescheduleEvent(EVENT_REMOVE_MUSHROOM_POWER, 29s);
209-
}
210-
else
211-
{
212-
events.RepeatEvent(1000);
213-
}
214-
215-
break;
216-
}
217-
}
218-
}
219-
220168
private:
221169
std::deque<Position> _mushroomsDeque;
222170
bool mushroomsSummoned;
@@ -327,9 +275,7 @@ class spell_amanitar_remove_mushroom_power : public AuraScript
327275
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
328276
{
329277
if (Unit* target = GetTarget())
330-
{
331278
target->RemoveAurasDueToSpell(SPELL_HEALTHY_MUSHROOM_POTENT_FUNGUS);
332-
}
333279
}
334280

335281
void Register() override

0 commit comments

Comments
 (0)