refactor(Scripts/TempleOfAhnQiraj): Clean up script files (#17718)

* refactor(Scripts/TempleOfAhnQiraj): Clean up script files

* Update src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_ouro.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

---------

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Andrew
2023-11-15 14:17:29 -03:00
committed by GitHub
parent 590c2d7ea1
commit 03612e8bff
7 changed files with 131 additions and 238 deletions

View File

@@ -19,7 +19,6 @@
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "temple_of_ahnqiraj.h"
#include "TaskScheduler.h"
enum Spells
{

View File

@@ -168,8 +168,6 @@ struct boss_eye_of_cthun : public BossAI
if (pPortal)
pPortal->SetReactState(REACT_PASSIVE);
scheduler.CancelAll();
BossAI::Reset();
}
@@ -330,15 +328,6 @@ struct boss_eye_of_cthun : public BossAI
});
}
void UpdateAI(uint32 diff) override
{
//Check if we have a target
if (!UpdateVictim())
return;
scheduler.Update(diff);
}
void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override
{
//Only if it will kill
@@ -402,7 +391,6 @@ struct boss_cthun : public BossAI
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
BossAI::Reset();
scheduler.CancelAll();
}
void JustEngagedWith(Unit* /*who*/) override
@@ -622,7 +610,7 @@ struct npc_eye_tentacle : public ScriptedAI
void Reset() override
{
DoZoneInCombat();
_scheduler.Schedule(500ms, [this](TaskContext /*task*/)
scheduler.Schedule(500ms, [this](TaskContext /*task*/)
{
DoCastAOE(SPELL_GROUND_RUPTURE);
})
@@ -634,7 +622,7 @@ struct npc_eye_tentacle : public ScriptedAI
void JustEngagedWith(Unit* /*who*/) override
{
_scheduler.Schedule(1s, 5s, [this](TaskContext context)
scheduler.Schedule(1s, 5s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, NotInStomachSelector()))
{
@@ -651,11 +639,10 @@ struct npc_eye_tentacle : public ScriptedAI
if (!UpdateVictim())
return;
_scheduler.Update(diff);
scheduler.Update(diff);
}
private:
TaskScheduler _scheduler;
ObjectGuid _portalGUID;
};
@@ -693,24 +680,24 @@ struct npc_claw_tentacle : public ScriptedAI
void Reset() override
{
_scheduler.Schedule(Milliseconds(500), [this](TaskContext /*task*/)
{
DoCastAOE(SPELL_GROUND_RUPTURE);
}).Schedule(Minutes(5), [this](TaskContext /*task*/)
{
me->DespawnOrUnsummon();
});
scheduler.Schedule(Milliseconds(500), [this](TaskContext /*task*/)
{
DoCastAOE(SPELL_GROUND_RUPTURE);
}).Schedule(Minutes(5), [this](TaskContext /*task*/)
{
me->DespawnOrUnsummon();
});
}
void JustEngagedWith(Unit* /*who*/) override
{
DoZoneInCombat();
_scheduler.Schedule(2s, [this](TaskContext context)
{
DoCastVictim(SPELL_HAMSTRING);
context.Repeat(5s);
});
scheduler.Schedule(2s, [this](TaskContext context)
{
DoCastVictim(SPELL_HAMSTRING);
context.Repeat(5s);
});
}
void UpdateAI(uint32 diff) override
@@ -719,13 +706,12 @@ struct npc_claw_tentacle : public ScriptedAI
if (!UpdateVictim())
return;
_scheduler.Update(diff);
scheduler.Update(diff);
DoMeleeAttackIfReady();
}
private:
TaskScheduler _scheduler;
ObjectGuid _portalGUID;
};
@@ -765,10 +751,10 @@ struct npc_giant_claw_tentacle : public ScriptedAI
void Reset() override
{
_scheduler.Schedule(500ms, [this](TaskContext /*task*/)
{
DoCastAOE(SPELL_MASSIVE_GROUND_RUPTURE);
});
scheduler.Schedule(500ms, [this](TaskContext /*task*/)
{
DoCastAOE(SPELL_MASSIVE_GROUND_RUPTURE);
});
}
void JustEngagedWith(Unit* /*who*/) override
@@ -780,7 +766,7 @@ struct npc_giant_claw_tentacle : public ScriptedAI
void ScheduleTasks()
{
// Check if a target is in melee range
_scheduler.Schedule(10s, [this](TaskContext task)
scheduler.Schedule(10s, [this](TaskContext task)
{
if (Unit* target = me->GetVictim())
{
@@ -830,13 +816,13 @@ struct npc_giant_claw_tentacle : public ScriptedAI
me->SetHealth(me->GetMaxHealth());
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
_scheduler.CancelAll();
scheduler.CancelAll();
_canAttack = false;
_scheduler.Schedule(5s, [this](TaskContext /*task*/)
{
Emerge();
});
scheduler.Schedule(5s, [this](TaskContext /*task*/)
{
Emerge();
});
}
void Emerge()
@@ -866,7 +852,7 @@ struct npc_giant_claw_tentacle : public ScriptedAI
if (!UpdateVictim())
return;
_scheduler.Update(diff);
scheduler.Update(diff);
if (_canAttack)
{
@@ -875,7 +861,6 @@ struct npc_giant_claw_tentacle : public ScriptedAI
}
private:
TaskScheduler _scheduler;
ObjectGuid _portalGUID;
bool _canAttack;
};
@@ -914,18 +899,18 @@ struct npc_giant_eye_tentacle : public ScriptedAI
void Reset() override
{
_scheduler.Schedule(500ms, [this](TaskContext /*task*/)
scheduler.Schedule(500ms, [this](TaskContext /*task*/)
{
DoCastAOE(SPELL_MASSIVE_GROUND_RUPTURE);
}).Schedule(1s, 5s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, NotInStomachSelector()))
{
DoCastAOE(SPELL_MASSIVE_GROUND_RUPTURE);
}).Schedule(1s, 5s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, NotInStomachSelector()))
{
DoCast(target, SPELL_GREEN_BEAM);
}
DoCast(target, SPELL_GREEN_BEAM);
}
context.Repeat(2100ms);
});
context.Repeat(2100ms);
});
}
void JustEngagedWith(Unit* /*who*/) override
@@ -939,11 +924,10 @@ struct npc_giant_eye_tentacle : public ScriptedAI
if (!UpdateVictim())
return;
_scheduler.Update(diff);
scheduler.Update(diff);
}
private:
TaskScheduler _scheduler;
ObjectGuid _portalGUID;
};

View File

@@ -17,7 +17,6 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "TaskScheduler.h"
#include "temple_of_ahnqiraj.h"
enum Spells
@@ -58,9 +57,7 @@ struct boss_fankriss : public BossAI
void Reset() override
{
_scheduler.CancelAll();
summonWormSpells = { SPELL_SUMMON_WORM_1, SPELL_SUMMON_WORM_2, SPELL_SUMMON_WORM_3};
BossAI::Reset();
}
@@ -87,11 +84,9 @@ struct boss_fankriss : public BossAI
void JustEngagedWith(Unit* who) override
{
_scheduler.CancelAll();
BossAI::JustEngagedWith(who);
_scheduler
.Schedule(7s, 14s, [this](TaskContext context)
scheduler.Schedule(7s, 14s, [this](TaskContext context)
{
DoCastVictim(SPELL_MORTAL_WOUND);
context.Repeat();
@@ -114,18 +109,7 @@ struct boss_fankriss : public BossAI
});
}
void UpdateAI(uint32 diff) override
{
//Return since we have no target
if (!UpdateVictim())
return;
_scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
std::vector<uint32> summonWormSpells;
};

View File

@@ -22,7 +22,6 @@
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "TaskScheduler.h"
#include "temple_of_ahnqiraj.h"
enum Spells
@@ -109,7 +108,6 @@ struct boss_ouro : public BossAI
{
SetCombatMovement(false);
me->SetControlled(true, UNIT_STATE_ROOT);
_scheduler.SetValidator([this] { return !me->HasUnitState(UNIT_STATE_CASTING); });
}
bool CanAIAttack(Unit const* victim) const override
@@ -123,8 +121,8 @@ struct boss_ouro : public BossAI
{
DoCastSelf(SPELL_BERSERK, true);
_enraged = true;
_scheduler.CancelGroup(GROUP_PHASE_TRANSITION);
_scheduler.Schedule(1s, [this](TaskContext context)
scheduler.CancelGroup(GROUP_PHASE_TRANSITION);
scheduler.Schedule(1s, [this](TaskContext context)
{
if (!IsPlayerWithinMeleeRange())
DoSpellAttackToRandomTargetIfReady(SPELL_BOULDER);
@@ -150,8 +148,8 @@ struct boss_ouro : public BossAI
_submergeMelee = 0;
_submerged = true;
DoCastSelf(SPELL_OURO_SUBMERGE_VISUAL);
_scheduler.CancelGroup(GROUP_EMERGED);
_scheduler.CancelGroup(GROUP_PHASE_TRANSITION);
scheduler.CancelGroup(GROUP_EMERGED);
scheduler.CancelGroup(GROUP_PHASE_TRANSITION);
if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 10.f))
{
@@ -206,8 +204,7 @@ struct boss_ouro : public BossAI
DoCastSelf(SPELL_SUMMON_SANDWORM_BASE, true);
me->SetReactState(REACT_AGGRESSIVE);
CastGroundRupture();
_scheduler
.Schedule(20s, GROUP_EMERGED, [this](TaskContext context)
scheduler.Schedule(20s, GROUP_EMERGED, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 0.0f, true))
{
@@ -265,7 +262,7 @@ struct boss_ouro : public BossAI
void Reset() override
{
instance->SetBossState(DATA_OURO, NOT_STARTED);
_scheduler.CancelAll();
scheduler.CancelAll();
_submergeMelee = 0;
_submerged = false;
_enraged = false;
@@ -286,7 +283,6 @@ struct boss_ouro : public BossAI
void JustEngagedWith(Unit* who) override
{
Emerge();
BossAI::JustEngagedWith(who);
}
@@ -294,14 +290,11 @@ struct boss_ouro : public BossAI
{
UpdateVictim();
_scheduler.Update(diff, [this]
{
DoMeleeAttackIfReady();
});
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
protected:
TaskScheduler _scheduler;
bool _enraged;
uint8 _submergeMelee;
bool _submerged;
@@ -338,16 +331,16 @@ struct npc_dirt_mound : ScriptedAI
void JustEngagedWith(Unit* /*who*/) override
{
DoZoneInCombat();
_scheduler.Schedule(30s, [this](TaskContext /*context*/)
{
DoCastSelf(SPELL_SUMMON_SCARABS, true);
me->DespawnOrUnsummon(1000);
})
scheduler.Schedule(30s, [this](TaskContext /*context*/)
{
DoCastSelf(SPELL_SUMMON_SCARABS, true);
me->DespawnOrUnsummon(1000);
})
.Schedule(100ms, [this](TaskContext context)
{
ChaseNewTarget();
context.Repeat(5s, 10s);
});
{
ChaseNewTarget();
context.Repeat(5s, 10s);
});
}
void ChaseNewTarget()
@@ -365,7 +358,7 @@ struct npc_dirt_mound : ScriptedAI
if (!UpdateVictim())
return;
_scheduler.Update(diff);
scheduler.Update(diff);
}
void Reset() override
@@ -389,7 +382,6 @@ struct npc_dirt_mound : ScriptedAI
}
protected:
TaskScheduler _scheduler;
uint32 _ouroHealth;
InstanceScript* _instance;
};

View File

@@ -19,7 +19,6 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "TaskScheduler.h"
#include "temple_of_ahnqiraj.h"
enum Spells
@@ -88,11 +87,6 @@ struct boss_twinemperorsAI : public BossAI
boss_twinemperorsAI(Creature* creature): BossAI(creature, DATA_TWIN_EMPERORS), _introDone(false)
{
me->SetStandState(UNIT_STAND_STATE_KNEEL);
_scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
Creature* GetTwin()
@@ -132,8 +126,6 @@ struct boss_twinemperorsAI : public BossAI
if (Creature* twin = GetTwin())
if (!twin->IsInEvadeMode())
twin->AI()->EnterEvadeMode(why);
_scheduler.CancelAll();
}
void JustDied(Unit* killer) override
@@ -152,7 +144,7 @@ struct boss_twinemperorsAI : public BossAI
if (action == ACTION_CANCEL_INTRO)
{
_introDone = true;
_scheduler.CancelGroup(GROUP_INTRO);
scheduler.CancelGroup(GROUP_INTRO);
return;
}
@@ -161,32 +153,31 @@ struct boss_twinemperorsAI : public BossAI
DoResetThreatList();
me->SetReactState(REACT_PASSIVE);
DoCastSelf(SPELL_TWIN_TELEPORT_VISUAL, true);
_scheduler.DelayAll(2300ms);
_scheduler.Schedule(2s, [this](TaskContext /*context*/)
scheduler.DelayAll(2300ms);
scheduler.Schedule(2s, [this](TaskContext /*context*/)
{
me->SetReactState(REACT_AGGRESSIVE);
me->SetControlled(false, UNIT_STATE_ROOT);
if (Unit* victim = me->SelectNearestTarget())
{
me->SetReactState(REACT_AGGRESSIVE);
me->SetControlled(false, UNIT_STATE_ROOT);
if (Unit* victim = me->SelectNearestTarget())
{
me->AddThreat(victim, 2000.f);
AttackStart(victim);
}
});
me->AddThreat(victim, 2000.f);
AttackStart(victim);
}
});
}
if (action != ACTION_START_INTRO)
return;
_scheduler.Schedule(5s, [this](TaskContext /*context*/)
{
me->SetStandState(UNIT_STAND_STATE_STAND);
me->LoadEquipment(1, true);
});
scheduler.Schedule(5s, [this](TaskContext /*context*/)
{
me->SetStandState(UNIT_STAND_STATE_STAND);
me->LoadEquipment(1, true);
});
if (IAmVeklor())
{
_scheduler
.Schedule(12s, GROUP_INTRO, [this](TaskContext /*context*/)
scheduler.Schedule(12s, GROUP_INTRO, [this](TaskContext /*context*/)
{
Talk(SAY_INTRO_0);
})
@@ -211,8 +202,7 @@ struct boss_twinemperorsAI : public BossAI
}
else
{
_scheduler
.Schedule(17s, GROUP_INTRO, [this](TaskContext /*context*/)
scheduler.Schedule(17s, GROUP_INTRO, [this](TaskContext /*context*/)
{
Talk(SAY_INTRO_0);
})
@@ -252,8 +242,7 @@ struct boss_twinemperorsAI : public BossAI
if (!twin->IsInCombat())
twin->AI()->AttackStart(who);
_scheduler
.Schedule(15min, [this](TaskContext /*context*/)
scheduler.Schedule(15min, [this](TaskContext /*context*/)
{
if (IAmVeklor())
{
@@ -280,17 +269,16 @@ struct boss_twinemperorsAI : public BossAI
if (!UpdateVictim() && _introDone)
return;
_scheduler.Update(diff, [this]
{
if (!IAmVeklor())
DoMeleeAttackIfReady();
});
scheduler.Update(diff, [this]
{
if (!IAmVeklor())
DoMeleeAttackIfReady();
});
}
virtual bool IAmVeklor() = 0;
protected:
TaskScheduler _scheduler;
bool _introDone;
};
@@ -306,8 +294,7 @@ struct boss_veknilash : public boss_twinemperorsAI
DoPlaySoundToSet(me, SOUND_VN_AGGRO);
_scheduler
.Schedule(14s, [this](TaskContext context)
scheduler.Schedule(14s, [this](TaskContext context)
{
DoCastRandomTarget(SPELL_UPPERCUT, 0, me->GetMeleeReach(), true);
context.Repeat(4s, 15s);
@@ -337,8 +324,7 @@ struct boss_veklor : public boss_twinemperorsAI
DoPlaySoundToSet(me, SOUND_VK_AGGRO);
_scheduler
.Schedule(4s, [this](TaskContext context)
scheduler.Schedule(4s, [this](TaskContext context)
{
if (me->GetVictim())
{

View File

@@ -19,7 +19,6 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "TaskScheduler.h"
#include "temple_of_ahnqiraj.h"
enum Spells
@@ -118,9 +117,7 @@ struct boss_viscidus : public BossAI
void Reset() override
{
BossAI::Reset();
events.Reset();
SoftReset();
_scheduler.CancelAll();
me->RemoveAurasDueToSpell(SPELL_VISCIDUS_SHRINKS);
}
@@ -133,17 +130,6 @@ struct boss_viscidus : public BossAI
me->RemoveAurasDueToSpell(SPELL_INVIS_SELF);
}
void JustDied(Unit* /*killer*/) override
{
events.Reset();
summons.DespawnAll(10 * IN_MILLISECONDS);
if (instance)
{
instance->SetBossState(DATA_VISCIDUS, DONE);
instance->SaveToDB();
}
}
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType effType, SpellSchoolMask spellSchoolMask) override
{
if (me->HealthBelowPct(5))
@@ -184,8 +170,7 @@ struct boss_viscidus : public BossAI
me->AttackStop();
me->CastStop();
me->HandleEmoteCommand(EMOTE_ONESHOT_FLYDEATH); // not found in sniff, this is the best one I found
_scheduler
.Schedule(2500ms, [this](TaskContext /*context*/)
scheduler.Schedule(2500ms, [this](TaskContext /*context*/)
{
DoCastSelf(SPELL_EXPLODE_TRIGGER, true);
})
@@ -295,7 +280,7 @@ struct boss_viscidus : public BossAI
return;
events.Update(diff);
_scheduler.Update(diff);
scheduler.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
@@ -330,7 +315,6 @@ struct boss_viscidus : public BossAI
private:
uint8 _hitcounter;
uint8 _phase;
TaskScheduler _scheduler;
};
struct boss_glob_of_viscidus : public ScriptedAI
@@ -343,8 +327,8 @@ struct boss_glob_of_viscidus : public ScriptedAI
void InitializeAI() override
{
me->SetInCombatWithZone();
_scheduler.CancelAll();
_scheduler.Schedule(2400ms, [this](TaskContext context)
scheduler.CancelAll();
scheduler.Schedule(2400ms, [this](TaskContext context)
{
me->GetMotionMaster()->MovePoint(ROOM_CENTER, roomCenter);
float topSpeed = me->GetSpeedRate(MOVE_RUN) + 0.2142855f * 4;
@@ -368,11 +352,8 @@ struct boss_glob_of_viscidus : public ScriptedAI
void UpdateAI(uint32 diff) override
{
_scheduler.Update(diff);
scheduler.Update(diff);
}
protected:
TaskScheduler _scheduler;
};
struct npc_toxic_slime : public ScriptedAI

View File

@@ -21,7 +21,6 @@
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "temple_of_ahnqiraj.h"
#include "TaskScheduler.h"
enum Spells
{
@@ -72,13 +71,11 @@ enum Spells
struct npc_anubisath_defender : public ScriptedAI
{
npc_anubisath_defender(Creature* creature) : ScriptedAI(creature)
{
}
npc_anubisath_defender(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
scheduler.CancelAll();
_enraged = false;
}
@@ -88,7 +85,7 @@ struct npc_anubisath_defender : public ScriptedAI
if (urand(0, 1))
{
_scheduler.Schedule(6s, 10s, [this](TaskContext context)
scheduler.Schedule(6s, 10s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 1))
DoCast(target, SPELL_METEOR, true);
@@ -97,7 +94,7 @@ struct npc_anubisath_defender : public ScriptedAI
}
else
{
_scheduler.Schedule(6s, 10s, [this](TaskContext context)
scheduler.Schedule(6s, 10s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 1))
DoCast(target, SPELL_PLAGUE, true);
@@ -107,7 +104,7 @@ struct npc_anubisath_defender : public ScriptedAI
if (urand(0, 1))
{
_scheduler.Schedule(5s, 8s, [this](TaskContext context)
scheduler.Schedule(5s, 8s, [this](TaskContext context)
{
DoCastAOE(SPELL_THUNDERCLAP, true);
context.Repeat(5s, 8s);
@@ -115,7 +112,7 @@ struct npc_anubisath_defender : public ScriptedAI
}
else
{
_scheduler.Schedule(5s, 8s, [this](TaskContext context)
scheduler.Schedule(5s, 8s, [this](TaskContext context)
{
DoCastAOE(SPELL_SHADOW_STORM, true);
context.Repeat(5s, 8s);
@@ -124,7 +121,7 @@ struct npc_anubisath_defender : public ScriptedAI
if (urand(0, 1))
{
_scheduler.Schedule(3s, 5s, [this](TaskContext context)
scheduler.Schedule(3s, 5s, [this](TaskContext context)
{
DoCastSelf(SPELL_SUMMON_WARRIOR, true);
context.Repeat(12s, 16s);
@@ -132,7 +129,7 @@ struct npc_anubisath_defender : public ScriptedAI
}
else
{
_scheduler.Schedule(3s, 5s, [this](TaskContext context)
scheduler.Schedule(3s, 5s, [this](TaskContext context)
{
DoCastAOE(SPELL_SUMMON_SWARMGUARD, true);
context.Repeat(12s, 16s);
@@ -171,31 +168,28 @@ struct npc_anubisath_defender : public ScriptedAI
return;
}
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
bool _enraged;
};
struct npc_vekniss_stinger : public ScriptedAI
{
npc_vekniss_stinger(Creature* creature) : ScriptedAI(creature)
{
}
npc_vekniss_stinger(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
scheduler.CancelAll();
}
void JustEngagedWith(Unit* who) override
{
DoCast(who ,who->HasAura(SPELL_VEKNISS_CATALYST) ? SPELL_STINGER_CHARGE_BUFFED : SPELL_STINGER_CHARGE_NORMAL, true);
_scheduler.Schedule(6s, [this](TaskContext context)
scheduler.Schedule(6s, [this](TaskContext context)
{
Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [&](Unit* u)
{
@@ -225,44 +219,35 @@ struct npc_vekniss_stinger : public ScriptedAI
return;
}
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
};
struct npc_obsidian_eradicator : public ScriptedAI
{
npc_obsidian_eradicator(Creature* creature) : ScriptedAI(creature)
{
}
npc_obsidian_eradicator(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
scheduler.CancelAll();
me->SetPower(POWER_MANA, 0);
_targetGUIDs.clear();
}
void JustEngagedWith(Unit* /*who*/) override
{
_scheduler.Schedule(3500ms, [this](TaskContext context)
scheduler.Schedule(3500ms, [this](TaskContext context)
{
if (_targetGUIDs.empty())
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
me->GetMap()->DoForAllPlayers([&](Player* player)
{
if (Player* player = itr->GetSource())
if (player->IsAlive() && !player->IsGameMaster() && !player->IsSpectator() && player->GetPower(POWER_MANA) > 0)
{
if (player->IsAlive() && !player->IsGameMaster() && !player->IsSpectator() && player->GetPower(POWER_MANA) > 0)
{
_targetGUIDs.push_back(player->GetGUID());
}
_targetGUIDs.push_back(player->GetGUID());
}
}
});
Acore::Containers::RandomResize(_targetGUIDs, 10);
}
@@ -291,31 +276,28 @@ struct npc_obsidian_eradicator : public ScriptedAI
return;
}
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
GuidList _targetGUIDs;
};
struct npc_anubisath_warder : public ScriptedAI
{
npc_anubisath_warder(Creature* creature) : ScriptedAI(creature)
{
}
npc_anubisath_warder(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
scheduler.CancelAll();
}
void JustEngagedWith(Unit* /*who*/) override
{
if (urand(0, 1))
{
_scheduler.Schedule(5s, 5s, [this](TaskContext context)
scheduler.Schedule(5s, 5s, [this](TaskContext context)
{
DoCastAOE(SPELL_FEAR, true);
context.Repeat(20s, 20s);
@@ -323,7 +305,7 @@ struct npc_anubisath_warder : public ScriptedAI
}
else
{
_scheduler.Schedule(5s, 5s, [this](TaskContext context)
scheduler.Schedule(5s, 5s, [this](TaskContext context)
{
DoCastAOE(SPELL_ENTAGLING_ROOTS, true);
context.Repeat(20s, 20s);
@@ -332,7 +314,7 @@ struct npc_anubisath_warder : public ScriptedAI
if (urand(0, 1))
{
_scheduler.Schedule(4s, 4s, [this](TaskContext context)
scheduler.Schedule(4s, 4s, [this](TaskContext context)
{
DoCastAOE(SPELL_SILENCE, true);
context.Repeat(15s, 15s);
@@ -340,14 +322,14 @@ struct npc_anubisath_warder : public ScriptedAI
}
else
{
_scheduler.Schedule(4s, 4s, [this](TaskContext context)
scheduler.Schedule(4s, 4s, [this](TaskContext context)
{
DoCastAOE(SPELL_DUST_CLOUD, true);
context.Repeat(15s, 15s);
});
}
_scheduler.Schedule(2s, 2s, [this](TaskContext context)
scheduler.Schedule(2s, 2s, [this](TaskContext context)
{
DoCastAOE(SPELL_FIRE_NOVA, true);
context.Repeat(8s, 15s);
@@ -361,44 +343,35 @@ struct npc_anubisath_warder : public ScriptedAI
return;
}
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
};
struct npc_obsidian_nullifier : public ScriptedAI
{
npc_obsidian_nullifier(Creature* creature) : ScriptedAI(creature)
{
}
npc_obsidian_nullifier(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
scheduler.CancelAll();
me->SetPower(POWER_MANA, 0);
_targetGUIDs.clear();
}
void JustEngagedWith(Unit* /*who*/) override
{
_scheduler.Schedule(6s, [this](TaskContext context)
scheduler.Schedule(6s, [this](TaskContext context)
{
if (_targetGUIDs.empty())
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
me->GetMap()->DoForAllPlayers([&](Player* player)
{
if (Player* player = itr->GetSource())
if (player->IsAlive() && !player->IsGameMaster() && !player->IsSpectator() && player->GetPower(POWER_MANA) > 0)
{
if (player->IsAlive() && !player->IsGameMaster() && !player->IsSpectator() && player->GetPower(POWER_MANA) > 0)
{
_targetGUIDs.push_back(player->GetGUID());
}
_targetGUIDs.push_back(player->GetGUID());
}
}
});
Acore::Containers::RandomResize(_targetGUIDs, 11);
}
@@ -432,26 +405,23 @@ struct npc_obsidian_nullifier : public ScriptedAI
return;
}
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
GuidList _targetGUIDs;
};
struct npc_ahnqiraji_critter : public ScriptedAI
{
npc_ahnqiraji_critter(Creature* creature) : ScriptedAI(creature)
{
}
npc_ahnqiraji_critter(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
me->RestoreFaction();
_scheduler.CancelAll();
scheduler.CancelAll();
// Don't attack nearby players randomly if they are the Twin's pet bugs.
if (CreatureData const* crData = me->GetCreatureData())
@@ -465,7 +435,7 @@ struct npc_ahnqiraji_critter : public ScriptedAI
}
}
_scheduler.Schedule(100ms, [this](TaskContext context)
scheduler.Schedule(100ms, [this](TaskContext context)
{
if (Player* player = me->SelectNearestPlayer(10.f))
{
@@ -481,11 +451,11 @@ struct npc_ahnqiraji_critter : public ScriptedAI
void JustEngagedWith(Unit* /*who*/) override
{
_scheduler.CancelAll();
scheduler.CancelAll();
if (me->GetEntry() == NPC_QIRAJI_SCORPION)
{
_scheduler.Schedule(2s, 5s, [this](TaskContext context)
scheduler.Schedule(2s, 5s, [this](TaskContext context)
{
DoCastVictim(SPELL_PIERCE_ARMOR, true);
context.Repeat(5s, 9s);
@@ -508,7 +478,7 @@ struct npc_ahnqiraji_critter : public ScriptedAI
void UpdateAI(uint32 diff) override
{
_scheduler.Update(diff);
scheduler.Update(diff);
if (!UpdateVictim())
{
@@ -517,9 +487,6 @@ struct npc_ahnqiraji_critter : public ScriptedAI
DoMeleeAttackIfReady();
}
private:
TaskScheduler _scheduler;
};
enum NPCs