Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
44 lines
2.9 KiB
Diff
44 lines
2.9 KiB
Diff
--- a/addons/core/Scripts/Game/ERR/10_AI/ERR_GroundDepotLoading.c
|
|
+++ b/addons/core/Scripts/Game/ERR/10_AI/ERR_GroundDepotLoading.c
|
|
@@ -174,18 +174,19 @@
|
|
array<IEntity> items = {}; ERR_Inventory.Items(inventory, items);
|
|
return items.Count() <= 128 && items.Contains(item);
|
|
}
|
|
- protected bool SelectWorker(ERR_HQUnit crew)
|
|
- {
|
|
- if (!Quiet(crew) || crew.HomeGuard || crew.ReservedForSupport || crew.LogisticsReservation > 0) return false;
|
|
+ protected bool SelectWorker(ERR_HQUnit crew, IEntity item)
|
|
+ {
|
|
+ if (!item || !Quiet(crew) || crew.HomeGuard || crew.ReservedForSupport || crew.LogisticsReservation > 0) return false;
|
|
if (crew.Assignment || crew.Task || crew.PendingTask || crew.PendingOrder || crew.Downlink || crew.Waypoint) return false;
|
|
int count = crew.StatusSampler.InitialStrength();
|
|
if (count < 1 || count > 32 || !crew.StatusSampler.OwnsRoster(crew.Group)) return false;
|
|
for (int slot = 0; slot < count; slot++)
|
|
{
|
|
IEntity actor = crew.StatusSampler.InitialMember(slot);
|
|
- if (!actor || !crew.StatusSampler.CanAttribute(slot, actor, false) || !ERR_Actors.CanFight(actor) || CompartmentAccessComponent.GetVehicleIn(actor)) continue;
|
|
+ if (!actor || !crew.StatusSampler.CanAttribute(slot, actor, false) || !ERR_EnemyEquipmentRules.Eligible(m_Mode, crew.Group, actor) || CompartmentAccessComponent.GetVehicleIn(actor)) continue;
|
|
SCR_ChimeraAIAgent agent = SCR_ChimeraAIAgent.Cast(SCR_AIUtils.GetAIAgent(actor));
|
|
if (!agent || !agent.m_UtilityComponent || !agent.m_UtilityComponent.m_AIInfo) continue;
|
|
+ if (!ERR_InfantryAmmoTransfer.Compatible(actor, item)) continue;
|
|
m_Worker = actor; m_WorkerSlot = slot; m_Utility = agent.m_UtilityComponent; return true;
|
|
}
|
|
return false;
|
|
@@ -211,13 +212,13 @@
|
|
// The camp is an authored own location; only the truck position is reported.
|
|
if (vector.DistanceXZ(site.Definition.Position, report.Position) > 150) continue;
|
|
ERR_HQUnit crew = m_HQ.GroundUnit(site.Responders.Group);
|
|
- if (!SelectWorker(crew)) continue;
|
|
for (int itemIndex = 0; itemIndex < m_Mode.Sites().DepotMagazineCount(site) && itemIndex < 96; itemIndex++)
|
|
{
|
|
IEntity item = m_Mode.Sites().DepotMagazine(site, itemIndex);
|
|
if (!m_Original.Contains(item) || m_Spent.Contains(item) || !ERR_GroundDepotTransfer.Magazine(item) || !Stored(item, site.Container)) continue;
|
|
- // Match a real carried rifle; source camp stock cannot become arbitrary cargo.
|
|
- if (!ERR_InfantryAmmoTransfer.Compatible(m_Worker, item)) continue;
|
|
+ // Select an original worker for this exact item; an incompatible first
|
|
+ // member must not hide a later eligible carrier of finite camp stock.
|
|
+ if (!SelectWorker(crew, item)) continue;
|
|
int token = 300000 + m_Attempts + 1;
|
|
if (!m_HQ.ReserveGroundDepot(crew, donor, service, token)) continue;
|
|
m_Reservation = new ERR_FiniteMagazineReservation(m_Original, m_Spent, item);
|