49 lines
2.3 KiB
C
49 lines
2.3 KiB
C
// Scoped skill specialization for original physical convoy turret occupants.
|
|
// Owned extension and inspected vanilla API provenance: docs/ai-equipment-migration.md.
|
|
class ERR_EnemyGunnerSkill
|
|
{
|
|
static bool CapturedGroup(ERR_GameMode mode, SCR_AIGroup group)
|
|
{
|
|
if (!mode || !group) return false;
|
|
ERR_HQ hq = ERR_HQ.Cast(mode.Command());
|
|
if (!hq) return false;
|
|
ERR_ConvoyTask task = hq.ConvoyTask();
|
|
if (!task || task.Vehicles.Count() > 6) return false;
|
|
foreach (ERR_ConvoyVehicle unit : task.Vehicles)
|
|
if (unit && unit.Group == group && ERR_ConvoyRules.Captured(unit.Entity, group)) return true;
|
|
return false;
|
|
}
|
|
static bool OriginalGunner(ERR_GameMode mode, SCR_AIGroup group, IEntity actor)
|
|
{
|
|
if (!ERR_EnemyEquipmentRules.Eligible(mode, group, actor)) return false;
|
|
ERR_HQ hq = ERR_HQ.Cast(mode.Command());
|
|
if (!hq) return false;
|
|
ERR_ConvoyTask task = hq.ConvoyTask();
|
|
if (!task || !task.Ready || task.Stopped || !task.Receipt || !task.Receipt.Consumed || task.Vehicles.Count() > 6 || !mode.Forces()) return false;
|
|
foreach (ERR_ConvoyVehicle unit : task.Vehicles)
|
|
{
|
|
if (!unit || unit.Group != group || !unit.Registered || unit.Released || !unit.Entity || !ERR_Actors.Alive(unit.Entity)) continue;
|
|
if (unit.Index < 0 || unit.Index >= task.Receipt.Records.Count() || unit.Members.Count() > 16 || unit.Members.Count() != unit.Seats.Count()) return false;
|
|
ERR_ForceRecord record = mode.Forces().FindGroup(group);
|
|
if (!record || !record.Physical || record.Eliminated || record.Kind != ERR_ForceKind.CONVOY || record.Id != task.Receipt.Records[unit.Index]) return false;
|
|
if (ERR_ConvoyRules.Captured(unit.Entity, group)) return false;
|
|
for (int i = 0; i < unit.Members.Count(); i++)
|
|
{
|
|
if (unit.Members[i] != actor) continue;
|
|
BaseCompartmentSlot slot = unit.Seats[i];
|
|
return slot && TurretCompartmentSlot.Cast(slot) && slot.GetType() == ECompartmentType.TURRET
|
|
&& slot.GetOccupant() == actor && slot.GetVehicle() == unit.Entity
|
|
&& ERR_ConvoyRules.PartOf(CompartmentAccessComponent.GetVehicleIn(actor), unit.Entity);
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
static EAISkill Profile(EAISkill requested, bool originalGunner)
|
|
{
|
|
EAISkill skill = ERR_EnemyEquipmentRules.Floor(requested);
|
|
if (originalGunner && skill < EAISkill.CYLON) return EAISkill.CYLON;
|
|
return skill;
|
|
}
|
|
}
|