modded class SCR_ChimeraAIAgent
{
 void ProbeReleasePrison() { ERR_PrisonPhaseChanged(ERR_Phase.PRISON, ERR_Phase.RADIO_SEARCH); SetPermanentLOD(0); ActivateAI(); }
}
modded class ERR_HunterService
{
 ERR_HunterVehicle ProbeUnit()
 {
  vector position, angles;
  if (!ERR_SupplyConvoySystem.ApproachDirected("6870 0 3500", position, angles, 500)) return null;
  ERR_HunterVehicle unit = new ERR_HunterVehicle(); unit.Source = "native-gun-team";
  unit.Entity = Vehicle.Cast(ERR_Actors.Spawn(ERR_HunterFleetRules.VehiclePrefab(0), position, angles));
  unit.Group = SCR_AIGroup.Cast(ERR_Actors.Spawn(ERR_ConvoyResources.GroupPrefab(), position));
  if (!FillCrew(unit)) return null;
  unit.Group.SetPermanentLOD(0); unit.Group.ActivateAI();
  array<AIAgent> agents = {}; unit.Group.GetAgents(agents);
  foreach (AIAgent agent : agents) { agent.SetPermanentLOD(0); agent.ActivateAI(); }
  return unit;
 }
}
modded class ERR_HunterTactics
{
 void ProbeBegin()
 {
  Unit.Group.SetPermanentLOD(0); Unit.Group.ActivateAI();
  foreach (IEntity member : Unit.Members)
  {
   AIControlComponent control = AIControlComponent.Cast(member.FindComponent(AIControlComponent));
   SCR_ChimeraAIAgent agent = SCR_ChimeraAIAgent.Cast(control.GetControlAIAgent()); if (agent) agent.ProbeReleasePrison();
  }
  Delivered = true; State = 2; Deadline = GetGame().GetWorld().GetWorldTime() + 45000; NextRetry = Deadline;
  Stage = Unit.Entity.GetOrigin(); Approach = ERR_Actors.Ground(Stage + "40 0 0"); Sector = ERR_Actors.Ground(Stage + "65 0 20");
  Attack.ReportPosition = Stage + "200 0 0"; Attack.Forward = "1 0 0"; Attack.Teams.Insert(this);
  bool issued = Board(false);
  PrintFormat("ERR GUN TEAM START: board=%1 loaded=%2 split=%3", issued, ERR_HunterGunTeam.LoadedGunner(Unit) != null, m_GunTeam != null);
 }
 bool ProbeSplit() { return m_GunTeam != null; }
}
modded class ArmaReforgerScripted
{
 protected ref ERR_HunterService m_ProbeService;
 protected ref ERR_HunterVehicle m_ProbeUnit;
 protected ref ERR_HunterAttack m_ProbeAttack;
 protected ref ERR_HunterTactics m_ProbeTactics;
 protected float m_ProbeAge;
 protected float m_ProbeNext;
 protected bool m_ProbeDone;
 override void OnUpdate(BaseWorld world, float timeslice)
 {
  super.OnUpdate(world, timeslice);
  if (m_ProbeDone || !ERR_GameMode.Get() || !ERR_GameMode.Get().EnemyFaction()) return;
  m_ProbeAge += timeslice;
  if (m_ProbeAge < 5) return;
  if (!m_ProbeService)
  {
   m_ProbeService = new ERR_HunterService(ERR_GameMode.Get(), null); m_ProbeUnit = m_ProbeService.ProbeUnit();
   if (!m_ProbeUnit) { Print("ERR GUN TEAM FAILED creation"); m_ProbeDone = true; }
   return;
  }
  if (m_ProbeAge < 10) return;
  if (!m_ProbeTactics)
  {
   m_ProbeAttack = new ERR_HunterAttack(); m_ProbeAttack.Started = world.GetWorldTime();
   m_ProbeTactics = new ERR_HunterTactics(ERR_GameMode.Get(), m_ProbeUnit, m_ProbeAttack, 1); m_ProbeTactics.ProbeBegin();
  }
  m_ProbeTactics.Tick(ERR_HQ.Get(), world.GetWorldTime());
  // End only the fixture's search dwell once both men reached the sector;
  // exercise production regroup immediately instead of waiting out the timer.
  if (m_ProbeTactics.State == 5 && vector.DistanceXZ(m_ProbeUnit.Driver.GetOrigin(), m_ProbeUnit.Entity.GetOrigin()) > 50 && vector.DistanceXZ(m_ProbeUnit.Members[2].GetOrigin(), m_ProbeUnit.Entity.GetOrigin()) > 50) m_ProbeTactics.Deadline = world.GetWorldTime();
  if (m_ProbeAge >= m_ProbeNext)
  {
   m_ProbeNext = m_ProbeAge + 5;
   PrintFormat("ERR GUN TEAM PROGRESS: state=%1 driverDistance=%2 passengerDistance=%3 gunnerSeated=%4 split=%5 footReady=%6", m_ProbeTactics.State, vector.DistanceXZ(m_ProbeUnit.Driver.GetOrigin(), m_ProbeUnit.Entity.GetOrigin()), vector.DistanceXZ(m_ProbeUnit.Members[2].GetOrigin(), m_ProbeUnit.Entity.GetOrigin()), m_ProbeUnit.Seats[1].GetOccupant() == m_ProbeUnit.Members[1], m_ProbeTactics.ProbeSplit(), m_ProbeTactics.Aboard(false));
  }
  if (m_ProbeAge > 110 || (m_ProbeTactics.Stopped && m_ProbeTactics.Aboard(true)))
  {
   m_ProbeTactics.Stop();
   PrintFormat("ERR GUN TEAM COMPLETE: holdReleased=%1 allOriginalCrewSeated=%2", !ERR_ConvoyMountedCrew.Retain(m_ProbeUnit.Members[1], m_ProbeUnit.Entity), m_ProbeTactics.Aboard(true));
   m_ProbeDone = true;
  }
 }
}
