VoidAssault fix
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
--
|
||||
-- Void Assaults (Midnight 12.0.5) + Void Assault "Escalations" (12.0.7)
|
||||
-- open-world invasion framework -- world DB schema.
|
||||
--
|
||||
-- VoidAssaultMgr::LoadFromDB() reads these tables at startup (wired from
|
||||
-- World::SetInitialWorldSettings right after WorldStateMgr::LoadFromDB()).
|
||||
-- Both loaders tolerate a missing/empty table (idle no-op), so a realm without
|
||||
-- this SQL is unaffected. This file is the authoritative recreation of the
|
||||
-- schema that previously only existed on the feature/void-assaults branch.
|
||||
--
|
||||
-- Evidence tags: [DB2] = wago.tools 12.0.7.68887, [SNIFF] = tester capture,
|
||||
-- [RESEARCH] = web design guide (intent only). Seed rows are placeholders that
|
||||
-- drive ONLY the worldstate/rotation spine; no spawns or rewards ship (those are
|
||||
-- CAPTURE-BLOCKED). See C:\dumps\VOID_ASSAULTS_BLUEPRINT.md.
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `void_assault_template` (
|
||||
`Id` INT UNSIGNED NOT NULL,
|
||||
`Type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '0 VoidStrike, 1 VoidIncursion, 2 VoidEscalation',
|
||||
`ZoneId` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`MapId` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`StateWorldStateId` INT NOT NULL DEFAULT 0 COMMENT 'assault meter 29616 or rotation 5207/5208 [SNIFF]',
|
||||
`TimerWorldStateId` INT NOT NULL DEFAULT 0 COMMENT 'next-event unix clock 22984 [SNIFF]',
|
||||
`CountdownWorldStateId` INT NOT NULL DEFAULT 0 COMMENT '1 Hz countdown 28763 [SNIFF]',
|
||||
`PeriodSeconds` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`DurationSeconds` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`MeterCap` INT NOT NULL DEFAULT 0 COMMENT 'escalation fill cap 1000000 [SNIFF], 0 = none',
|
||||
`StrikesPerIncursion` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Void Strikes to trigger an Incursion, 0 = none',
|
||||
`PortalWorldMapA` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Naigtal map 3075 [DB2]',
|
||||
`PortalWorldMapB` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Val map 3047 [DB2]',
|
||||
`HeroicContentTuningId` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Heroic World Tier scaling [DB2 ContentTuning -- CAPTURE-BLOCKED]',
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- Seed rows (placeholders -- drive ONLY the WS/rotation spine; realm-idle):
|
||||
-- Id 1 = 12.0.5 Void Assault in Eversong Woods (area 15968), weekly swap with
|
||||
-- Zul'Aman; Void Strikes feed meter 29616 (cap 1e6), Incursion at 20 strikes.
|
||||
-- Id 2 = 12.0.7 Void "Escalation": portal-world window alternating Naigtal(3075)
|
||||
-- / Val(3047), weekly; carries the world boss + (CAPTURE-BLOCKED) HWT.
|
||||
-- Only ids 1 and 2 are owned by this seed; leave any locally added rows alone.
|
||||
DELETE FROM `void_assault_template` WHERE `Id` IN (1, 2);
|
||||
INSERT INTO `void_assault_template`
|
||||
(`Id`,`Type`,`ZoneId`,`MapId`,`StateWorldStateId`,`TimerWorldStateId`,`CountdownWorldStateId`,`PeriodSeconds`,`DurationSeconds`,`MeterCap`,`StrikesPerIncursion`,`PortalWorldMapA`,`PortalWorldMapB`,`HeroicContentTuningId`) VALUES
|
||||
(1, 0, 15968, 0, 29616, 22984, 28763, 604800, 604800, 1000000, 20, 0, 0, 0),
|
||||
(2, 2, 16943, 3075, 5207, 22984, 28763, 604800, 604800, 0, 0, 3075, 3047, 0);
|
||||
|
||||
-- Spawn mechanism table. Ships EMPTY -- event-actor / world-boss / destructible
|
||||
-- coordinates are CAPTURE-BLOCKED. VoidAssaultMgr iterates whatever rows exist
|
||||
-- and is a safe no-op when empty.
|
||||
CREATE TABLE IF NOT EXISTS `void_assault_spawn` (
|
||||
`AssaultId` INT UNSIGNED NOT NULL,
|
||||
`Kind` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '0 creature, 1 gameobject',
|
||||
`Entry` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`MapId` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '0 = use template MapId',
|
||||
`PosX` FLOAT NOT NULL DEFAULT 0,
|
||||
`PosY` FLOAT NOT NULL DEFAULT 0,
|
||||
`PosZ` FLOAT NOT NULL DEFAULT 0,
|
||||
`Orientation` FLOAT NOT NULL DEFAULT 0,
|
||||
KEY `AssaultId` (`AssaultId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
-- NO spawn rows shipped (CAPTURE-BLOCKED). Reference candidates for when
|
||||
-- coordinates are captured (do NOT insert until verified in Creature.db2):
|
||||
-- Naigtal world boss "Nexus-Captain Leth'ir" 260875 [RESEARCH]
|
||||
-- Val world boss "Imperator Pertinax" 261072 [RESEARCH]
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "QuaternionData.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Timer.h"
|
||||
#include "World.h"
|
||||
#include "WorldStateMgr.h"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@@ -95,8 +96,12 @@ void VoidAssaultMgr::LoadFromDB()
|
||||
|
||||
VoidAssaultState& state = _states[tmpl.Id];
|
||||
state.TemplateId = tmpl.Id;
|
||||
// Schedule the first activation at the next period boundary from server start.
|
||||
state.NextStart = now + static_cast<time_t>(tmpl.PeriodSeconds);
|
||||
// Schedule the first activation. Weekly windows snap to the server's weekly
|
||||
// reset boundary (ComputeNextStart); ComputeNextStart returns 0 here because
|
||||
// LoadFromDB runs before InitQuestResetTimes, so Update() re-derives it on the
|
||||
// first tick once the weekly reset time is populated. Non-weekly windows get
|
||||
// a one-period offset from now.
|
||||
state.NextStart = ComputeNextStart(tmpl, now);
|
||||
state.Active = false;
|
||||
|
||||
++count;
|
||||
@@ -150,6 +155,28 @@ void VoidAssaultMgr::LoadSpawns()
|
||||
TC_LOG_INFO("server.loading", ">> Loaded {} Void assault spawns", _spawns.size());
|
||||
}
|
||||
|
||||
// Weekly-cadence windows (the 12.0.5 assault swap and the 12.0.7 portal-world
|
||||
// escalation) open on the realm's weekly reset boundary. We reuse the existing
|
||||
// weekly-reset time source -- World::GetNextWeeklyQuestsResetTime() -- rather than
|
||||
// counting a raw week from server boot, so the assault window tracks the same
|
||||
// reset the weekly quests roll over on. That value is 0 until
|
||||
// World::InitQuestResetTimes() runs (which is AFTER VoidAssaultMgr::LoadFromDB in
|
||||
// SetInitialWorldSettings); when it is not yet available we return 0 and Update()
|
||||
// retries on a later tick.
|
||||
time_t VoidAssaultMgr::ComputeNextStart(VoidAssaultTemplate const& tmpl, time_t now) const
|
||||
{
|
||||
if (IsWeeklyCadence(tmpl))
|
||||
{
|
||||
time_t const weeklyReset = sWorld->GetNextWeeklyQuestsResetTime();
|
||||
if (weeklyReset > now)
|
||||
return weeklyReset; // next weekly reset boundary
|
||||
return 0; // not initialised yet -> Update() re-derives it
|
||||
}
|
||||
|
||||
// Sub-weekly strike rotations key off the current time.
|
||||
return now + static_cast<time_t>(tmpl.PeriodSeconds);
|
||||
}
|
||||
|
||||
void VoidAssaultMgr::Update(uint32 diff)
|
||||
{
|
||||
// Throttle: 1 Hz is sufficient for the second-resolution countdown worldstate.
|
||||
@@ -172,6 +199,17 @@ void VoidAssaultMgr::Update(uint32 diff)
|
||||
|
||||
if (!state.Active)
|
||||
{
|
||||
// Weekly windows seeded with NextStart == 0 (weekly reset time was not
|
||||
// yet available at LoadFromDB) are snapped to the reset boundary here,
|
||||
// once.
|
||||
if (state.NextStart == 0)
|
||||
{
|
||||
state.NextStart = ComputeNextStart(tmpl, now);
|
||||
if (state.NextStart == 0)
|
||||
continue; // reset time still not ready -> retry next tick
|
||||
BroadcastTimers(tmpl, state); // publish the newly derived next-event clock
|
||||
}
|
||||
|
||||
if (now >= state.NextStart)
|
||||
ActivateAssault(state, tmpl, now);
|
||||
}
|
||||
@@ -220,7 +258,10 @@ void VoidAssaultMgr::ActivateAssault(VoidAssaultState& state, VoidAssaultTemplat
|
||||
void VoidAssaultMgr::DeactivateAssault(VoidAssaultState& state, VoidAssaultTemplate const& tmpl, time_t now)
|
||||
{
|
||||
state.Active = false;
|
||||
state.NextStart = now + static_cast<time_t>(tmpl.PeriodSeconds);
|
||||
// Reschedule. Weekly windows snap to the next weekly reset (by now the reset
|
||||
// framework has advanced GetNextWeeklyQuestsResetTime() past this window);
|
||||
// other windows advance one period. A 0 here is re-derived by Update().
|
||||
state.NextStart = ComputeNextStart(tmpl, now);
|
||||
state.Meter = 0;
|
||||
state.StrikesDone = 0;
|
||||
state.IncursionPhase = false;
|
||||
@@ -241,9 +282,15 @@ void VoidAssaultMgr::DeactivateAssault(VoidAssaultState& state, VoidAssaultTempl
|
||||
|
||||
void VoidAssaultMgr::BroadcastTimers(VoidAssaultTemplate const& tmpl, VoidAssaultState const& state)
|
||||
{
|
||||
// WS 22984 carries the next-event unix timestamp (confirmed on wire).
|
||||
// WS 22984 carries the next-event unix timestamp (confirmed on wire). While a
|
||||
// window is open the next transition is its EndTime; NextStart is only advanced
|
||||
// when the window deactivates, so broadcasting it here would publish a stale
|
||||
// (already-past) clock for the whole active window.
|
||||
if (tmpl.TimerWorldStateId)
|
||||
WorldStateMgr::SetValue(tmpl.TimerWorldStateId, static_cast<int32>(state.NextStart), false, nullptr);
|
||||
{
|
||||
time_t const nextTransition = state.Active ? state.EndTime : state.NextStart;
|
||||
WorldStateMgr::SetValue(tmpl.TimerWorldStateId, static_cast<int32>(nextTransition), false, nullptr);
|
||||
}
|
||||
|
||||
// WS 28763 carries the 1 Hz countdown while the window is active.
|
||||
if (tmpl.CountdownWorldStateId && state.Active)
|
||||
@@ -267,7 +314,14 @@ void VoidAssaultMgr::RotatePortalWorld(VoidAssaultState& state, VoidAssaultTempl
|
||||
return;
|
||||
}
|
||||
|
||||
state.ActiveWorld = (state.Phase % 2 == 0) ? VoidPortalWorld::Naigtal : VoidPortalWorld::Val;
|
||||
// Respect a partially configured template (only one world seeded) instead of
|
||||
// handing back the missing world on the wrong phase parity.
|
||||
if (!tmpl.PortalWorldMapB)
|
||||
state.ActiveWorld = VoidPortalWorld::Naigtal;
|
||||
else if (!tmpl.PortalWorldMapA)
|
||||
state.ActiveWorld = VoidPortalWorld::Val;
|
||||
else
|
||||
state.ActiveWorld = (state.Phase % 2 == 0) ? VoidPortalWorld::Naigtal : VoidPortalWorld::Val;
|
||||
|
||||
// Heroic World Tier: CAPTURE-BLOCKED. The retail toggle is a per-player
|
||||
// Normal/Heroic choice at the portal that re-scales the world via a
|
||||
@@ -287,6 +341,22 @@ VoidAssaultTemplate const* VoidAssaultMgr::GetTemplate(uint32 id) const
|
||||
return itr != _templates.end() ? &itr->second : nullptr;
|
||||
}
|
||||
|
||||
VoidAssaultState const* VoidAssaultMgr::GetState(uint32 id) const
|
||||
{
|
||||
auto itr = _states.find(id);
|
||||
return itr != _states.end() ? &itr->second : nullptr;
|
||||
}
|
||||
|
||||
std::vector<uint32> VoidAssaultMgr::GetAssaultIds() const
|
||||
{
|
||||
std::vector<uint32> ids;
|
||||
ids.reserve(_templates.size());
|
||||
for (auto const& entry : _templates)
|
||||
ids.push_back(entry.first);
|
||||
std::ranges::sort(ids);
|
||||
return ids;
|
||||
}
|
||||
|
||||
bool VoidAssaultMgr::IsAssaultActive(uint32 id) const
|
||||
{
|
||||
auto itr = _states.find(id);
|
||||
@@ -313,9 +383,9 @@ bool VoidAssaultMgr::IsHeroicWorldTier(uint32 id) const
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Escalation-meter mechanism (WS 29616). LIVE. The +500 step and the 1,000,000
|
||||
// cap are confirmed on the wire; the completion FLIP semantics at cap (what runs
|
||||
// besides the meter reset) are CAPTURE-BLOCKED, so at cap we run the documented
|
||||
// default: fire the reward hook and end the window (reschedule).
|
||||
// cap are confirmed on the wire. At cap the window flips into its climactic Void
|
||||
// Incursion phase (FlipToIncursion) and stays open until the Incursion is
|
||||
// completed; the scenario spin-up / completion wire is CAPTURE-BLOCKED.
|
||||
// ---------------------------------------------------------------------------
|
||||
void VoidAssaultMgr::AddAssaultProgress(uint32 templateId, int32 amount)
|
||||
{
|
||||
@@ -355,7 +425,8 @@ void VoidAssaultMgr::OnVoidStrikeCompleted(uint32 templateId)
|
||||
VoidAssaultTemplate const& tmpl = tmplItr->second;
|
||||
|
||||
// Feed the fill-meter directly for every strike (drives the 29616 UI bar).
|
||||
AddAssaultProgress(templateId, tmpl.MeterCap ? VoidAssault::METER_STEP : 0);
|
||||
if (tmpl.MeterCap > 0)
|
||||
AddAssaultProgress(templateId, VoidAssault::METER_STEP);
|
||||
|
||||
if (tmpl.StrikesPerIncursion == 0)
|
||||
return; // this window is not strike-driven
|
||||
@@ -363,9 +434,15 @@ void VoidAssaultMgr::OnVoidStrikeCompleted(uint32 templateId)
|
||||
++state.StrikesDone;
|
||||
TC_LOG_DEBUG("misc", "VoidAssaultMgr: assault {} strikes {}/{}", tmpl.Id, state.StrikesDone, tmpl.StrikesPerIncursion);
|
||||
|
||||
// Enough Strikes -> flip the meter to cap to trigger the Incursion phase.
|
||||
if (state.StrikesDone >= tmpl.StrikesPerIncursion && tmpl.MeterCap > 0)
|
||||
if (state.StrikesDone < tmpl.StrikesPerIncursion)
|
||||
return;
|
||||
|
||||
// Enough Strikes -> flip the meter to cap (or flip directly for a window with
|
||||
// a strike counter but no fill meter) to trigger the Incursion phase.
|
||||
if (tmpl.MeterCap > 0)
|
||||
AddAssaultProgress(templateId, tmpl.MeterCap);
|
||||
else if (!state.IncursionPhase)
|
||||
FlipToIncursion(tmpl, state);
|
||||
}
|
||||
|
||||
// Player-facing Void Strike entry point. Resolves the primary meter-driven assault
|
||||
@@ -420,22 +497,33 @@ void VoidAssaultMgr::FlipToIncursion(VoidAssaultTemplate const& tmpl, VoidAssaul
|
||||
// currency path, advances the escalation/rotation state, and closes the window.
|
||||
// Today invoked by the temporary .voidassault debug command; at integration by the
|
||||
// real Void Incursion completion.
|
||||
void VoidAssaultMgr::CompleteAssault(Player* player)
|
||||
bool VoidAssaultMgr::CompleteAssault(Player* player)
|
||||
{
|
||||
if (!IsEnabled() || !player)
|
||||
return;
|
||||
return false;
|
||||
|
||||
uint32 const id = GetPrimaryAssaultId();
|
||||
if (!id)
|
||||
return;
|
||||
return false;
|
||||
|
||||
auto stateItr = _states.find(id);
|
||||
auto tmplItr = _templates.find(id);
|
||||
if (stateItr == _states.end() || tmplItr == _templates.end())
|
||||
return;
|
||||
return false;
|
||||
VoidAssaultState& state = stateItr->second;
|
||||
VoidAssaultTemplate const& tmpl = tmplItr->second;
|
||||
|
||||
// Rewards belong only to a window that actually reached its climactic Void
|
||||
// Incursion phase. Without this guard a debug "complete" (or a stray script
|
||||
// call) could mint Field Accolade / Voidlight Marl from an idle or still-filling
|
||||
// window.
|
||||
if (!state.Active || !state.IncursionPhase)
|
||||
{
|
||||
TC_LOG_DEBUG("misc", "VoidAssaultMgr: assault {} completion ignored (active {}, incursionPhase {})",
|
||||
tmpl.Id, state.Active, state.IncursionPhase);
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- Reward tail (LIVE mechanism, PLACEHOLDER amounts) ----------------------
|
||||
// Grant the Field Accolade (3405) named in the Void Assaults POI reward text
|
||||
// via the stock ModifyCurrency path (CurrencyGainSource::Script; ModifyCurrency
|
||||
@@ -463,6 +551,7 @@ void VoidAssaultMgr::CompleteAssault(Player* player)
|
||||
// reschedules the next activation (which advances the rotation phase / portal
|
||||
// world on the next ActivateAssault).
|
||||
DeactivateAssault(state, tmpl, GameTime::GetGameTime());
|
||||
return true;
|
||||
}
|
||||
|
||||
// DEBUG/DEV stand-in for the CAPTURE-BLOCKED portal-world activation wire.
|
||||
@@ -484,6 +573,53 @@ void VoidAssaultMgr::DebugForceActivatePrimary()
|
||||
ActivateAssault(stateItr->second, tmplItr->second, GameTime::GetGameTime());
|
||||
}
|
||||
|
||||
// DEBUG/DEV -- unwind a forced test activation: close the window if it is open
|
||||
// (running the normal despawn/reschedule path) or clear its runtime state and
|
||||
// re-schedule it off the normal cadence if it is already idle.
|
||||
void VoidAssaultMgr::DebugResetPrimary()
|
||||
{
|
||||
if (!IsEnabled())
|
||||
return;
|
||||
|
||||
uint32 const id = GetPrimaryAssaultId();
|
||||
if (!id)
|
||||
return;
|
||||
|
||||
auto stateItr = _states.find(id);
|
||||
auto tmplItr = _templates.find(id);
|
||||
if (stateItr == _states.end() || tmplItr == _templates.end())
|
||||
return;
|
||||
|
||||
VoidAssaultState& state = stateItr->second;
|
||||
VoidAssaultTemplate const& tmpl = tmplItr->second;
|
||||
time_t const now = GameTime::GetGameTime();
|
||||
|
||||
if (state.Active)
|
||||
{
|
||||
DeactivateAssault(state, tmpl, now);
|
||||
return;
|
||||
}
|
||||
|
||||
state.Meter = 0;
|
||||
state.StrikesDone = 0;
|
||||
state.IncursionPhase = false;
|
||||
state.IncursionScenarioId = 0;
|
||||
state.NextStart = ComputeNextStart(tmpl, now);
|
||||
|
||||
if (tmpl.StateWorldStateId && tmpl.MeterCap)
|
||||
WorldStateMgr::SetValue(tmpl.StateWorldStateId, 0, false, nullptr);
|
||||
if (tmpl.CountdownWorldStateId)
|
||||
WorldStateMgr::SetValue(tmpl.CountdownWorldStateId, 0, false, nullptr);
|
||||
|
||||
// A 0 here means the weekly reset source is not ready yet; Update() will derive
|
||||
// it and publish the clock on a later tick (do not broadcast a bogus 1970 stamp).
|
||||
if (state.NextStart)
|
||||
BroadcastTimers(tmpl, state);
|
||||
|
||||
TC_LOG_DEBUG("misc", "VoidAssaultMgr: reset assault {} (idle); next start {}",
|
||||
tmpl.Id, static_cast<long long>(state.NextStart));
|
||||
}
|
||||
|
||||
// Resolve the primary meter-driven assault: the lowest Id whose window carries a
|
||||
// fill-meter (MeterCap>0). That is the Void Strike -> Incursion window the core
|
||||
// loop feeds. 0 if none configured.
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
// spawning, world-boss handoff, Heroic World Tier scaling and completion rewards
|
||||
// are stubbed and marked CAPTURE-BLOCKED where wire/DB2 evidence is not in hand.
|
||||
|
||||
#include "Common.h"
|
||||
#include "Define.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include <ctime>
|
||||
@@ -260,6 +261,8 @@ public:
|
||||
|
||||
// --- accessors (used by scripts / debug commands) ---
|
||||
VoidAssaultTemplate const* GetTemplate(uint32 id) const;
|
||||
VoidAssaultState const* GetState(uint32 id) const;
|
||||
std::vector<uint32> GetAssaultIds() const;
|
||||
bool IsAssaultActive(uint32 id) const;
|
||||
int32 GetMeter(uint32 id) const;
|
||||
VoidPortalWorld GetActiveWorld(uint32 id) const;
|
||||
@@ -285,8 +288,10 @@ public:
|
||||
|
||||
// Void Incursion completion: grant the completion reward (Field Accolade 3405,
|
||||
// + Voidlight Marl 3316 secondary) via the stock ModifyCurrency path, advance
|
||||
// the escalation/rotation state, and close out the active window.
|
||||
void CompleteAssault(Player* player);
|
||||
// the escalation/rotation state, and close out the active window. Rewards are
|
||||
// granted ONLY once the window has actually flipped into its Incursion phase
|
||||
// (meter cap); returns false for an idle window or one still filling.
|
||||
bool CompleteAssault(Player* player);
|
||||
|
||||
// DEBUG/DEV ONLY -- TEMPORARY stand-in for the CAPTURE-BLOCKED portal-world
|
||||
// activation wire. Force the primary assault active immediately, off its weekly
|
||||
@@ -295,10 +300,16 @@ public:
|
||||
// activation wire lands.
|
||||
void DebugForceActivatePrimary();
|
||||
|
||||
// DEBUG/DEV ONLY -- close the primary window (if open) and reschedule it off
|
||||
// its normal cadence, clearing meter/strike/incursion state. Also used by the
|
||||
// .voidassault reset command to unwind a forced test activation.
|
||||
void DebugResetPrimary();
|
||||
|
||||
// --- escalation-meter mechanism (WS 29616) ---
|
||||
// Advance the assault meter of window `templateId` by `amount` (defaults to
|
||||
// the +500 step). Broadcasts WS 29616 and, on reaching MeterCap, drives the
|
||||
// Incursion completion path. Safe no-op if inactive / no meter cap.
|
||||
// the +500 step). Broadcasts WS 29616 and, on reaching MeterCap, flips the
|
||||
// window into its climactic Incursion phase. Safe no-op if inactive / no
|
||||
// meter cap.
|
||||
void AddAssaultProgress(uint32 templateId, int32 amount = VoidAssault::METER_STEP);
|
||||
|
||||
// Void Strike completion hook. Increments the strike counter; when it reaches
|
||||
@@ -311,6 +322,16 @@ public:
|
||||
|
||||
private:
|
||||
// Rotation / scheduling core (implemented in skeleton).
|
||||
// Next-activation scheduling. Weekly windows (PeriodSeconds == WEEK -- e.g. the
|
||||
// 12.0.5 assault swap and the 12.0.7 portal-world escalation) align to the
|
||||
// server's weekly quest reset boundary (World::GetNextWeeklyQuestsResetTime),
|
||||
// NOT a wall-clock offset from server boot. Everything else schedules at
|
||||
// now + PeriodSeconds. Returns 0 when the weekly reset time is not available
|
||||
// yet (LoadFromDB runs before InitQuestResetTimes); Update() re-derives it
|
||||
// lazily on a later tick.
|
||||
time_t ComputeNextStart(VoidAssaultTemplate const& tmpl, time_t now) const;
|
||||
static bool IsWeeklyCadence(VoidAssaultTemplate const& tmpl) { return tmpl.PeriodSeconds == uint32(WEEK); }
|
||||
|
||||
void ActivateAssault(VoidAssaultState& state, VoidAssaultTemplate const& tmpl, time_t now);
|
||||
void DeactivateAssault(VoidAssaultState& state, VoidAssaultTemplate const& tmpl, time_t now);
|
||||
void BroadcastTimers(VoidAssaultTemplate const& tmpl, VoidAssaultState const& state);
|
||||
|
||||
@@ -68,6 +68,7 @@ void AddSC_shop_commandscript();
|
||||
void AddSC_smallactivities_commandscript();
|
||||
void AddSC_prey_commandscript();
|
||||
void AddSC_scenario_commandscript();
|
||||
void AddSC_voidassault_commandscript();
|
||||
|
||||
// The name of this function should match:
|
||||
// void Add${NameOfDirectory}Scripts()
|
||||
@@ -125,5 +126,6 @@ void AddCommandsScripts()
|
||||
AddSC_smallactivities_commandscript();
|
||||
AddSC_prey_commandscript();
|
||||
AddSC_scenario_commandscript();
|
||||
AddSC_voidassault_commandscript();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* ScriptData
|
||||
Name: voidassault_commandscript
|
||||
%Complete: 100
|
||||
Comment: Inspect and drive the Void Assault open-world event rotation
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "ChatCommand.h"
|
||||
#include "Player.h"
|
||||
#include "RBAC.h"
|
||||
#include "VoidAssaultMgr.h"
|
||||
|
||||
using namespace Trinity::ChatCommands;
|
||||
|
||||
namespace
|
||||
{
|
||||
char const* GetVoidAssaultTypeName(VoidAssaultType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VoidAssaultType::VoidStrike: return "VoidStrike";
|
||||
case VoidAssaultType::VoidIncursion: return "VoidIncursion";
|
||||
case VoidAssaultType::VoidEscalation: return "VoidEscalation";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
char const* GetVoidPortalWorldName(VoidPortalWorld world)
|
||||
{
|
||||
switch (world)
|
||||
{
|
||||
case VoidPortalWorld::Naigtal: return "Naigtal";
|
||||
case VoidPortalWorld::Val: return "Val";
|
||||
default: return "None";
|
||||
}
|
||||
}
|
||||
|
||||
// Force the primary assault open when it is idle so the debug verbs can be used
|
||||
// without a separate .voidassault start. Returns the primary id (0 = none).
|
||||
uint32 EnsurePrimaryActive()
|
||||
{
|
||||
uint32 const id = sVoidAssaultMgr->GetPrimaryAssaultId();
|
||||
if (id && !sVoidAssaultMgr->IsAssaultActive(id))
|
||||
sVoidAssaultMgr->DebugForceActivatePrimary();
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
class voidassault_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
voidassault_commandscript() : CommandScript("voidassault_commandscript") {}
|
||||
|
||||
std::span<ChatCommandBuilder const> GetCommands() const override
|
||||
{
|
||||
static ChatCommandTable voidAssaultCommandTable =
|
||||
{
|
||||
{ "status", HandleVoidAssaultStatusCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
|
||||
{ "start", HandleVoidAssaultStartCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
|
||||
{ "strike", HandleVoidAssaultStrikeCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
|
||||
{ "fill", HandleVoidAssaultFillCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
|
||||
{ "complete", HandleVoidAssaultCompleteCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::No },
|
||||
{ "reset", HandleVoidAssaultResetCommand, rbac::RBAC_PERM_COMMAND_DEBUG, Console::Yes },
|
||||
};
|
||||
|
||||
static ChatCommandTable commandTable =
|
||||
{
|
||||
{ "voidassault", voidAssaultCommandTable },
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
// .voidassault status - configured windows and their live runtime state
|
||||
static bool HandleVoidAssaultStatusCommand(ChatHandler* handler)
|
||||
{
|
||||
if (!sVoidAssaultMgr->IsEnabled())
|
||||
{
|
||||
handler->SendSysMessage("Void Assaults are not configured (void_assault_template is absent or empty).");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<uint32> const ids = sVoidAssaultMgr->GetAssaultIds();
|
||||
handler->PSendSysMessage("Void Assaults: %u configured, primary %u.",
|
||||
uint32(ids.size()), sVoidAssaultMgr->GetPrimaryAssaultId());
|
||||
|
||||
for (uint32 id : ids)
|
||||
{
|
||||
VoidAssaultTemplate const* tmpl = sVoidAssaultMgr->GetTemplate(id);
|
||||
VoidAssaultState const* state = sVoidAssaultMgr->GetState(id);
|
||||
if (!tmpl || !state)
|
||||
continue;
|
||||
|
||||
handler->PSendSysMessage(" [%u] %s zone %u map %u: %s, meter %d/%d, strikes %u/%u, phase %u",
|
||||
id, GetVoidAssaultTypeName(tmpl->Type), tmpl->ZoneId, tmpl->MapId,
|
||||
state->Active ? "ACTIVE" : "idle", state->Meter, tmpl->MeterCap,
|
||||
state->StrikesDone, tmpl->StrikesPerIncursion, uint32(state->Phase));
|
||||
handler->PSendSysMessage(" next %lld, end %lld, incursion %s (scenario %u), escalations %u, world %s, heroic %s",
|
||||
static_cast<long long>(state->NextStart), static_cast<long long>(state->EndTime),
|
||||
state->IncursionPhase ? "yes" : "no", state->IncursionScenarioId, state->EscalationCount,
|
||||
GetVoidPortalWorldName(state->ActiveWorld), state->HeroicTier ? "yes" : "no");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// .voidassault start - force the primary window open off its rotation timer
|
||||
static bool HandleVoidAssaultStartCommand(ChatHandler* handler)
|
||||
{
|
||||
if (!sVoidAssaultMgr->IsEnabled())
|
||||
{
|
||||
handler->SendSysMessage("Void Assaults are not configured (void_assault_template is absent or empty).");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 const id = sVoidAssaultMgr->GetPrimaryAssaultId();
|
||||
if (!id)
|
||||
{
|
||||
handler->SendSysMessage("No meter-driven Void Assault is configured.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sVoidAssaultMgr->DebugForceActivatePrimary();
|
||||
handler->PSendSysMessage("Void Assault %u forced active.", id);
|
||||
return HandleVoidAssaultStatusCommand(handler);
|
||||
}
|
||||
|
||||
// .voidassault strike - credit one Void Strike for the selected player
|
||||
static bool HandleVoidAssaultStrikeCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayerOrSelf();
|
||||
if (!player)
|
||||
{
|
||||
handler->SendSysMessage("No player selected or in range.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsurePrimaryActive())
|
||||
{
|
||||
handler->SendSysMessage("No meter-driven Void Assault is configured.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sVoidAssaultMgr->OnVoidStrikeCompleted(player);
|
||||
handler->PSendSysMessage("Void Strike credited for %s.", player->GetName().c_str());
|
||||
return HandleVoidAssaultStatusCommand(handler);
|
||||
}
|
||||
|
||||
// .voidassault fill - drive the primary fill-meter straight to its cap
|
||||
static bool HandleVoidAssaultFillCommand(ChatHandler* handler)
|
||||
{
|
||||
uint32 const id = EnsurePrimaryActive();
|
||||
VoidAssaultTemplate const* tmpl = id ? sVoidAssaultMgr->GetTemplate(id) : nullptr;
|
||||
if (!tmpl || tmpl->MeterCap <= 0)
|
||||
{
|
||||
handler->SendSysMessage("The primary Void Assault has no fill meter configured.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sVoidAssaultMgr->AddAssaultProgress(id, tmpl->MeterCap);
|
||||
handler->PSendSysMessage("Void Assault %u meter forced to cap (%d).", id, tmpl->MeterCap);
|
||||
return HandleVoidAssaultStatusCommand(handler);
|
||||
}
|
||||
|
||||
// .voidassault complete - grant the Incursion reward tail and close the window
|
||||
static bool HandleVoidAssaultCompleteCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayerOrSelf();
|
||||
if (!player)
|
||||
{
|
||||
handler->SendSysMessage("No player selected or in range.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sVoidAssaultMgr->CompleteAssault(player))
|
||||
{
|
||||
handler->SendSysMessage("The primary Void Assault is not in its Incursion phase; run .voidassault fill first.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("Void Incursion completed for %s (placeholder rewards granted).", player->GetName().c_str());
|
||||
return HandleVoidAssaultStatusCommand(handler);
|
||||
}
|
||||
|
||||
// .voidassault reset - close/clear the primary window and reschedule it
|
||||
static bool HandleVoidAssaultResetCommand(ChatHandler* handler)
|
||||
{
|
||||
if (!sVoidAssaultMgr->IsEnabled())
|
||||
{
|
||||
handler->SendSysMessage("Void Assaults are not configured (void_assault_template is absent or empty).");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sVoidAssaultMgr->DebugResetPrimary();
|
||||
handler->SendSysMessage("Void Assault reset to its scheduled window.");
|
||||
return HandleVoidAssaultStatusCommand(handler);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_voidassault_commandscript()
|
||||
{
|
||||
new voidassault_commandscript();
|
||||
}
|
||||
Reference in New Issue
Block a user