Integrate owned Intel rerolls, discovery feedback and fair HQ reports
This commit is contained in:
@@ -7,6 +7,7 @@ class ERR_HQUnit
|
||||
float NextReport;
|
||||
ref ERR_HQRoute Uplink;
|
||||
ref ERR_HQReport PendingReport;
|
||||
ref ERR_HQReportSelection ReportSelection = new ERR_HQReportSelection();
|
||||
ref ERR_HQRoute Downlink;
|
||||
ref ERR_HQReport PendingOrder;
|
||||
ref ERR_HQReport Assignment;
|
||||
@@ -244,7 +245,8 @@ class ERR_HQ : ERR_CommandService
|
||||
array<ref ERR_HQVisualContact> samples = {};
|
||||
ERR_HQObservation.Gather(unit.Utility, now, samples);
|
||||
if (samples.IsEmpty()) return;
|
||||
ERR_HQVisualContact seen = samples[0];
|
||||
ERR_HQVisualContact seen = unit.ReportSelection.Select(samples);
|
||||
if (!seen) return;
|
||||
ERR_HQRoute route = m_Network.Route(unit.Radio);
|
||||
if (!route) return;
|
||||
ERR_HQReport report = new ERR_HQReport();
|
||||
@@ -258,6 +260,7 @@ class ERR_HQ : ERR_CommandService
|
||||
route.Payload = report.Description(now);
|
||||
unit.PendingReport = report;
|
||||
unit.Uplink = route;
|
||||
unit.ReportSelection.Queued(seen.Entity);
|
||||
m_Journal.Write("REPORT", route.Payload, report.MessageId);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,3 +197,39 @@ modded class SCR_AIGroupUtilityComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Owned AI adaptation: report distinct visible contacts fairly instead of
|
||||
// repeatedly choosing the first native perception entry. This is scheduling
|
||||
// history only; no positions, equipment or delivered HQ knowledge are retained.
|
||||
class ERR_HQReportSelection
|
||||
{
|
||||
protected ref array<IEntity> m_Recent = {};
|
||||
|
||||
ERR_HQVisualContact Select(array<ref ERR_HQVisualContact> samples)
|
||||
{
|
||||
ERR_HQVisualContact selected;
|
||||
int oldest = 64;
|
||||
foreach (ERR_HQVisualContact sample : samples)
|
||||
{
|
||||
if (!sample || !sample.Entity) continue;
|
||||
int index = m_Recent.Find(sample.Entity);
|
||||
if (!selected || index < oldest)
|
||||
{
|
||||
selected = sample;
|
||||
oldest = index;
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
// Call only once an uplink is actually queued. Failed delivery still counts
|
||||
// as an attempt, so an interrupted caller cannot starve other sightings.
|
||||
void Queued(IEntity target)
|
||||
{
|
||||
if (!target) return;
|
||||
for (int i = m_Recent.Count() - 1; i >= 0; i--)
|
||||
if (!m_Recent[i] || m_Recent[i] == target) m_Recent.Remove(i);
|
||||
if (m_Recent.Count() >= 64) m_Recent.Remove(0);
|
||||
m_Recent.Insert(target);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user