aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/Battlegrounds/DeephaulRavine/battleground_deephaul_ravine.cpp3
-rw-r--r--src/server/scripts/Battlegrounds/EyeOfTheStorm/battleground_eye_of_the_storm.cpp3
-rw-r--r--src/server/scripts/Battlegrounds/IsleOfConquest/battleground_isle_of_conquest.cpp2
-rw-r--r--src/server/scripts/Battlegrounds/SilvershardMines/battleground_silvershard_mines.cpp3
-rw-r--r--src/server/scripts/Battlegrounds/TwinPeaks/battleground_twin_peaks.cpp3
-rw-r--r--src/server/scripts/Battlegrounds/WarsongGulch/battleground_warsong_gulch.cpp3
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp38
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp58
8 files changed, 57 insertions, 56 deletions
diff --git a/src/server/scripts/Battlegrounds/DeephaulRavine/battleground_deephaul_ravine.cpp b/src/server/scripts/Battlegrounds/DeephaulRavine/battleground_deephaul_ravine.cpp
index 663a6170963..8be231534ab 100644
--- a/src/server/scripts/Battlegrounds/DeephaulRavine/battleground_deephaul_ravine.cpp
+++ b/src/server/scripts/Battlegrounds/DeephaulRavine/battleground_deephaul_ravine.cpp
@@ -743,7 +743,8 @@ struct battleground_deephaul_ravine : BattlegroundScript
return false;
}
- void DoForLeaders(std::function<void(Creature*)> const& fn) const
+ template <std::invocable<Creature*> Action>
+ void DoForLeaders(Action const& fn) const
{
for (ObjectGuid const& guid : _leaderGUIDs)
if (Creature* creature = battlegroundMap->GetCreature(guid))
diff --git a/src/server/scripts/Battlegrounds/EyeOfTheStorm/battleground_eye_of_the_storm.cpp b/src/server/scripts/Battlegrounds/EyeOfTheStorm/battleground_eye_of_the_storm.cpp
index 3c8ef48438e..107b003fe78 100644
--- a/src/server/scripts/Battlegrounds/EyeOfTheStorm/battleground_eye_of_the_storm.cpp
+++ b/src/server/scripts/Battlegrounds/EyeOfTheStorm/battleground_eye_of_the_storm.cpp
@@ -367,7 +367,8 @@ struct battleground_eye_of_the_storm : BattlegroundScript
return baseCount;
}
- void DoForFlagKeepers(std::function<void(Player*)> const& action) const
+ template <std::invocable<Player*> Action>
+ void DoForFlagKeepers(Action const& action) const
{
if (GameObject const* flag = battlegroundMap->GetGameObject(_flagGUID))
if (Player* carrier = ObjectAccessor::FindPlayer(flag->GetFlagCarrierGUID()))
diff --git a/src/server/scripts/Battlegrounds/IsleOfConquest/battleground_isle_of_conquest.cpp b/src/server/scripts/Battlegrounds/IsleOfConquest/battleground_isle_of_conquest.cpp
index 5d55df8d6b7..fb48e239129 100644
--- a/src/server/scripts/Battlegrounds/IsleOfConquest/battleground_isle_of_conquest.cpp
+++ b/src/server/scripts/Battlegrounds/IsleOfConquest/battleground_isle_of_conquest.cpp
@@ -339,7 +339,7 @@ struct battleground_isle_of_conquest : BattlegroundScript
{
BattlegroundScript::OnStart();
- auto gameobjectAction = [&](GuidVector const& guids, std::function<void(GameObject*)> const& action) -> void
+ auto gameobjectAction = [&]<std::invocable<GameObject*> Action>(GuidVector const& guids, Action const& action) -> void
{
for (ObjectGuid const& guid : guids)
if (GameObject* gameObject = battlegroundMap->GetGameObject(guid))
diff --git a/src/server/scripts/Battlegrounds/SilvershardMines/battleground_silvershard_mines.cpp b/src/server/scripts/Battlegrounds/SilvershardMines/battleground_silvershard_mines.cpp
index 30721e47425..e23de84bab0 100644
--- a/src/server/scripts/Battlegrounds/SilvershardMines/battleground_silvershard_mines.cpp
+++ b/src/server/scripts/Battlegrounds/SilvershardMines/battleground_silvershard_mines.cpp
@@ -715,7 +715,8 @@ public:
}
}
- void DoForPlayersInControlZone(std::function<void(GameObject const*, Player*)> const& fn) const
+ template <std::invocable<GameObject const*, Player*> Action>
+ void DoForPlayersInControlZone(Action const& fn) const
{
if (GameObject const* controlZone = GetControlZone())
for (ObjectGuid const& playerGuid : *controlZone->GetInsidePlayers())
diff --git a/src/server/scripts/Battlegrounds/TwinPeaks/battleground_twin_peaks.cpp b/src/server/scripts/Battlegrounds/TwinPeaks/battleground_twin_peaks.cpp
index 0a0b37e4a16..f71cf0e5017 100644
--- a/src/server/scripts/Battlegrounds/TwinPeaks/battleground_twin_peaks.cpp
+++ b/src/server/scripts/Battlegrounds/TwinPeaks/battleground_twin_peaks.cpp
@@ -190,7 +190,8 @@ struct battleground_twin_peaks : BattlegroundScript
TriggerGameEvent(TwinPeaks::Events::StartBattle);
}
- void DoForFlagKeepers(std::function<void(Player*)> const& action) const
+ template <std::invocable<Player*> Action>
+ void DoForFlagKeepers(Action const& action) const
{
for (ObjectGuid flagGUID : _flags)
if (GameObject const* flag = battlegroundMap->GetGameObject(flagGUID))
diff --git a/src/server/scripts/Battlegrounds/WarsongGulch/battleground_warsong_gulch.cpp b/src/server/scripts/Battlegrounds/WarsongGulch/battleground_warsong_gulch.cpp
index be76b69abf1..f658211a1bf 100644
--- a/src/server/scripts/Battlegrounds/WarsongGulch/battleground_warsong_gulch.cpp
+++ b/src/server/scripts/Battlegrounds/WarsongGulch/battleground_warsong_gulch.cpp
@@ -227,7 +227,8 @@ struct battleground_warsong_gulch : BattlegroundScript
battleground->RewardHonorToTeam(battleground->GetBonusHonorFromKill(_honorEndKills), HORDE);
}
- void DoForFlagKeepers(std::function<void(Player*)> const& action) const
+ template <std::invocable<Player*> Action>
+ void DoForFlagKeepers(Action const& action) const
{
for (ObjectGuid flagGUID : _flags)
if (GameObject const* flag = battlegroundMap->GetGameObject(flagGUID))
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
index b21e77530e0..762eafebd85 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
@@ -637,12 +637,12 @@ struct npc_high_overlord_saurfang_icc : public ScriptedAI
return false;
}
- void GuardBroadcast(std::function<void(Creature*)>&& action) const
+ void GuardBroadcast(int32 action) const
{
std::vector<Creature*> guardList;
GetCreatureListWithEntryInGrid(guardList, me, NPC_SE_KOR_KRON_REAVER, 100.0f);
for (Creature* guard : guardList)
- action(guard);
+ guard->AI()->DoAction(action);
}
void DoAction(int32 action) override
@@ -681,19 +681,13 @@ struct npc_high_overlord_saurfang_icc : public ScriptedAI
_events.ScheduleEvent(EVENT_OUTRO_HORDE_5, 30s); // move
me->SetDisableGravity(false);
me->GetMotionMaster()->MoveFall();
- GuardBroadcast([](Creature* guard)
- {
- guard->AI()->DoAction(ACTION_DESPAWN);
- });
+ GuardBroadcast(ACTION_DESPAWN);
break;
}
case ACTION_INTERRUPT_INTRO:
{
_events.Reset();
- GuardBroadcast([](Creature* guard)
- {
- guard->AI()->DoAction(ACTION_DESPAWN);
- });
+ GuardBroadcast(ACTION_DESPAWN);
break;
}
default:
@@ -774,10 +768,7 @@ struct npc_high_overlord_saurfang_icc : public ScriptedAI
break;
case EVENT_INTRO_HORDE_8:
Talk(SAY_INTRO_HORDE_8);
- GuardBroadcast([](Creature* guard)
- {
- guard->AI()->DoAction(ACTION_CHARGE);
- });
+ GuardBroadcast(ACTION_CHARGE);
me->GetMotionMaster()->MoveCharge(chargePos[0].GetPositionX(), chargePos[0].GetPositionY(), chargePos[0].GetPositionZ(), 8.5f, POINT_CHARGE);
break;
case EVENT_OUTRO_HORDE_2: // say
@@ -834,12 +825,12 @@ struct npc_muradin_bronzebeard_icc : public ScriptedAI
return false;
}
- void GuardBroadcast(std::function<void(Creature*)>&& action) const
+ void GuardBroadcast(int32 action) const
{
std::vector<Creature*> guardList;
GetCreatureListWithEntryInGrid(guardList, me, NPC_SE_SKYBREAKER_MARINE, 100.0f);
for (Creature* guard : guardList)
- action(guard);
+ guard->AI()->DoAction(action);
}
void DoAction(int32 action) override
@@ -874,10 +865,7 @@ struct npc_muradin_bronzebeard_icc : public ScriptedAI
Talk(SAY_OUTRO_ALLIANCE_1);
me->SetDisableGravity(false);
me->GetMotionMaster()->MoveFall();
- GuardBroadcast([](Creature* guard)
- {
- guard->AI()->DoAction(ACTION_DESPAWN);
- });
+ GuardBroadcast(ACTION_DESPAWN);
// temp until outro fully done - to put deathbringer on respawn timer (until next reset)
if (Creature* deathbringer = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_DEATHBRINGER_SAURFANG)))
@@ -886,10 +874,7 @@ struct npc_muradin_bronzebeard_icc : public ScriptedAI
}
case ACTION_INTERRUPT_INTRO:
_events.Reset();
- GuardBroadcast([](Creature* guard)
- {
- guard->AI()->DoAction(ACTION_DESPAWN);
- });
+ GuardBroadcast(ACTION_DESPAWN);
break;
}
}
@@ -932,10 +917,7 @@ struct npc_muradin_bronzebeard_icc : public ScriptedAI
break;
case EVENT_INTRO_ALLIANCE_5:
Talk(SAY_INTRO_ALLIANCE_5);
- GuardBroadcast([](Creature* guard)
- {
- guard->AI()->DoAction(ACTION_CHARGE);
- });
+ GuardBroadcast(ACTION_CHARGE);
me->GetMotionMaster()->MoveCharge(chargePos[0].GetPositionX(), chargePos[0].GetPositionY(), chargePos[0].GetPositionZ(), 8.5f, POINT_CHARGE);
break;
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
index 6a2289b5642..9a2fe5e8926 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
@@ -160,12 +160,25 @@ static Player* FindEligibleTarget(Creature const* me, bool isGateOpen)
}
/* Wave data */
-typedef std::pair<uint32, uint8> GothikWaveEntry; // (npcEntry, npcCount)
-typedef std::set<GothikWaveEntry> GothikWave;
-typedef std::pair<GothikWave, uint8> GothikWaveInfo; // (wave, secondsToNext)
-typedef std::vector<GothikWaveInfo> GothikWaveData;
-const GothikWaveData waves10 =
+struct GothikWaveEntry
{
+ uint32 CreatureId = 0;
+ uint32 Count = 0;
+};
+
+struct GothikWaveInfo
+{
+ constexpr GothikWaveInfo(std::initializer_list<GothikWaveEntry> waves, int64 timeToNextWave) : TimeToNextWave(timeToNextWave)
+ {
+ std::ranges::copy_n(waves.begin(), std::min(std::ranges::ssize(waves), std::ranges::ssize(Creatures)), Creatures.begin());
+ }
+
+ std::array<GothikWaveEntry, 3> Creatures;
+ Seconds TimeToNextWave;
+};
+
+static constexpr std::array<GothikWaveInfo, 19> waves10 =
+{ {
{
{{NPC_LIVE_TRAINEE, 2}},
20},
@@ -223,10 +236,10 @@ const GothikWaveData waves10 =
{
{{NPC_LIVE_TRAINEE, 2}},
0}
-};
+} };
-const GothikWaveData waves25 =
-{
+static constexpr std::array<GothikWaveInfo, 18> waves25 =
+{ {
{
{{NPC_LIVE_TRAINEE, 3}},
20},
@@ -281,7 +294,7 @@ const GothikWaveData waves25 =
{
{{NPC_LIVE_RIDER, 1}, {NPC_LIVE_KNIGHT, 2}, {NPC_LIVE_TRAINEE, 3}},
0}
-};
+} };
// GUID of first trigger NPC (used as offset for guid checks)
// 0-1 are living side soul triggers, 2-3 are spectral side soul triggers, 4 is living rider spawn trigger, 5-7 are living other spawn trigger, 8-12 are skull pile triggers
@@ -426,7 +439,7 @@ struct boss_gothik : public BossAI
{
case EVENT_SUMMON:
{
- if (RAID_MODE(waves10,waves25).size() <= _waveCount) // bounds check
+ if (RAID_MODE(waves10.size(), waves25.size()) <= _waveCount) // bounds check
{
TC_LOG_INFO("scripts", "GothikAI: Wave count {} is out of range for difficulty {}.", _waveCount, static_cast<uint32>(GetDifficulty()));
break;
@@ -434,8 +447,9 @@ struct boss_gothik : public BossAI
std::list<Creature*> triggers;
me->GetCreatureListWithEntryInGrid(triggers, NPC_TRIGGER, 150.0f);
- for (GothikWaveEntry entry : RAID_MODE(waves10, waves25)[_waveCount].first)
- for (uint8 i = 0; i < entry.second; ++i)
+ for (GothikWaveEntry entry : RAID_MODE(waves10[_waveCount], waves25[_waveCount]).Creatures)
+ {
+ for (uint32 i = 0; i < entry.Count; ++i)
{
// GUID layout is as follows:
// CGUID+4: center (back of platform) - primary rider spawn
@@ -443,7 +457,7 @@ struct boss_gothik : public BossAI
// CGUID+6: center (front of platform) - second spawn
// CGUID+7: south (front of platform) - primary trainee spawn
uint32 targetDBGuid;
- switch (entry.first)
+ switch (entry.CreatureId)
{
case NPC_LIVE_RIDER: // only spawns from center (back) > north
targetDBGuid = (CGUID_TRIGGER + 4) + (i % 2);
@@ -455,19 +469,17 @@ struct boss_gothik : public BossAI
targetDBGuid = (CGUID_TRIGGER + 7) - (i % 3);
break;
default:
- targetDBGuid = 0;
+ continue;
}
- for (Creature* trigger : triggers)
- if (trigger && trigger->GetSpawnId() == targetDBGuid)
- {
- DoSummon(entry.first, trigger, 1.0f, 15s, TEMPSUMMON_CORPSE_TIMED_DESPAWN);
- break;
- }
+ auto triggerItr = std::ranges::find(triggers, targetDBGuid, [](Creature const* trigger) { return trigger->GetSpawnId(); });
+ if (triggerItr != triggers.end())
+ DoSummon(entry.CreatureId, *triggerItr, 1.0f, 15s, TEMPSUMMON_CORPSE_TIMED_DESPAWN);
}
+ }
- if (uint8 timeToNext = RAID_MODE(waves10, waves25)[_waveCount].second)
- events.Repeat(Seconds(timeToNext));
+ if (Seconds timeToNext = RAID_MODE(waves10[_waveCount], waves25[_waveCount]).TimeToNextWave; timeToNext > 0s)
+ events.Repeat(timeToNext);
++_waveCount;
break;
@@ -532,6 +544,8 @@ struct boss_gothik : public BossAI
case EVENT_INTRO_4:
Talk(SAY_INTRO_4);
break;
+ default:
+ break;
}
}
}