Enable finite automatic convoy startup and scoped gunner skill

This commit is contained in:
2026-09-20 08:23:19 +02:00
parent 782c163c68
commit 5bd66d76ca
44 changed files with 3694 additions and 48 deletions
+26 -1
View File
@@ -98,6 +98,7 @@ class ERR_HQ : ERR_CommandService
protected ref ERR_HQWatch m_Watch = new ERR_HQWatch();
protected ref ERR_MortarLogistics m_Logistics;
protected ref ERR_InfantryResupply m_Resupply;
protected ref ERR_ConvoyStartup m_ConvoyStartup;
protected ref array<ref ERR_HQUnit> m_Units = {};
protected ref array<ref ERR_HQReport> m_Contacts = {};
protected ref ERR_HQMemory m_Memory = new ERR_HQMemory();
@@ -111,7 +112,7 @@ class ERR_HQ : ERR_CommandService
protected float m_NextNetwork;
protected float m_NextAssignment;
void ERR_HQ(ERR_GameMode mode) { m_Mode = mode; m_Equipment = new ERR_EnemyEquipment(mode); m_ConvoyPool = new ERR_ConvoyPool(mode, 1); m_Convoys = new ERR_ConvoyService(mode, m_ConvoyPool); m_Mortars = new ERR_MortarSystem(this); m_Logistics = new ERR_MortarLogistics(this, mode); m_Resupply = new ERR_InfantryResupply(this, mode); }
void ERR_HQ(ERR_GameMode mode) { m_Mode = mode; m_Equipment = new ERR_EnemyEquipment(mode); m_ConvoyPool = new ERR_ConvoyPool(mode, 1); m_Convoys = new ERR_ConvoyService(mode, m_ConvoyPool); m_Mortars = new ERR_MortarSystem(this); m_Logistics = new ERR_MortarLogistics(this, mode); m_Resupply = new ERR_InfantryResupply(this, mode); m_ConvoyStartup = new ERR_ConvoyStartup(mode.Settings().Get("automaticConvoyEnabled") == 1); }
static ERR_HQ Get()
{
ERR_GameMode mode = ERR_GameMode.Get();
@@ -128,6 +129,7 @@ class ERR_HQ : ERR_CommandService
ERR_HQ hq = Get();
if (hq) hq.Journal().Write(kind, message, messageId);
}
ERR_ConvoyStartup ConvoyStartup() { return m_ConvoyStartup; }
ERR_ConvoyPool ConvoyPool() { return m_ConvoyPool; }
ERR_ConvoyService Convoys() { return m_Convoys; }
ERR_ConvoyTask ConvoyTask() { return m_ConvoyTask; }
@@ -172,6 +174,26 @@ class ERR_HQ : ERR_CommandService
m_ConvoyFailure = "";
return !m_ConvoyTask.Stopped;
}
protected bool ConvoyAdmissionReady()
{
if (m_Units.IsEmpty() || !m_Mode.Forces()) return false;
foreach (ERR_HQUnit unit : m_Units)
if (unit.Group && !m_Mode.Forces().FindGroup(unit.Group)) return false;
array<ref ERR_MortarBattery> batteries = {}; m_Mortars.Batteries(batteries);
foreach (ERR_MortarBattery battery : batteries)
if (battery && !battery.Stopped() && !battery.StartupActivated) return false;
return true;
}
protected void AutomaticConvoy(float now)
{
if (!Replication.IsServer() || !m_Mode || m_Mode != ERR_GameMode.Get() || !m_Mode.Active()) return;
if (!m_ConvoyStartup || m_ConvoyStartup.Finished()) return;
string previous = m_ConvoyStartup.Status();
if (m_ConvoyStartup.Decide(now, m_ConvoyTask != null, ConvoyAdmissionReady()))
m_ConvoyStartup.Complete(StartScenarioConvoy());
if (previous != m_ConvoyStartup.Status())
m_Journal.Write("CONVOY STARTUP", m_ConvoyStartup.Status() + "; " + m_ConvoyFailure);
}
bool StartScenarioConvoy()
{
if (!m_Mode || !m_Mode.Sites()) return false;
@@ -182,6 +204,7 @@ class ERR_HQ : ERR_CommandService
string ConvoyStatus()
{
string detail = m_Convoys.Status();
if (m_ConvoyStartup) detail += "; automatic startup: " + m_ConvoyStartup.Status();
if (!m_ConvoyFailure.IsEmpty()) detail += "; " + m_ConvoyFailure;
return detail;
}
@@ -979,6 +1002,7 @@ class ERR_HQ : ERR_CommandService
m_Memory.Tick(now);
m_Equipment.Tick(now);
m_Convoys.Tick(now);
AutomaticConvoy(now);
m_Bodies.TickBudget(now);
if (now >= m_NextNetwork) { IndexRadios(); m_NextNetwork = now + 5000; }
for (int i = m_Contacts.Count() - 1; i >= 0; i--)
@@ -1022,6 +1046,7 @@ class ERR_HQ : ERR_CommandService
override void Stop()
{
m_ConvoyStartup.Stop();
m_Resupply.Stop();
m_Convoys.Stop();
m_Equipment.Stop();