Files
EscapistsReintroduced/docs/evidence/cessna-recon-2026-10-08/native-fixture.c
T
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

70 lines
4.0 KiB
C

modded class ArmaReforgerScripted
{
protected float m_ERRNextHQ, m_ERRNextPrint, m_ERRAirborneAt, m_ERRDestroyedAt;
protected bool m_ERRTargets, m_ERRKilled, m_ERRSeen, m_ERRDone;
protected Vehicle m_ERRFirst;
protected ref ERR_PlaneFlight m_ERRCaptured;
override void OnUpdate(BaseWorld world, float timeslice)
{
super.OnUpdate(world, timeslice);
ERR_HQ hq=ERR_HQ.Get(); ERR_GameMode mode=ERR_GameMode.Get();
if (!hq || !mode || !mode.Active() || m_ERRDone) return;
if (m_ERRCaptured && m_ERRCaptured.Captured)
{
PrintFormat("ERR PLANE CAPTURE restored=%1 alive=%2",m_ERRCaptured.ERR_RatesRestored(),ERR_Actors.Alive(m_ERRCaptured.Aircraft));
PrintFormat("ERR PLANE COMPLETE sighting=%1 capture=%2",m_ERRSeen,m_ERRCaptured.ERR_RatesRestored()); m_ERRDone=true; return;
}
float now=world.GetWorldTime();
if(now>=m_ERRNextHQ) { m_ERRNextHQ=now+1000; hq.Tick(now); hq.Journal().Flush(); }
if(now>=m_ERRNextPrint) { m_ERRNextPrint=now+5000; Print("ERR PLANE PROBE " + hq.PlaneRecon().Status()); }
ERR_PlaneFlight flight=hq.PlaneRecon().Current();
if(!flight || !flight.Aircraft) return;
if(!m_ERRTargets)
{
m_ERRTargets=true; m_ERRFirst=flight.Aircraft;
mode.Transition(ERR_Phase.RADIO_SEARCH);
SCR_AIGroup targetGroup=SCR_AIGroup.Cast(ERR_Actors.Spawn("{C31F210ABE078195}Prefabs/ERR/ReconCrew.et", ERR_Actors.Ground("4730 0 11650")));
mode.Own(targetGroup); targetGroup.SetFaction(mode.PlayerFaction()); targetGroup.SetPermanentLOD(0); targetGroup.ActivateAI();
targetGroup.GetGroupUtilityComponent().SetCombatMode(EAIGroupCombatMode.HOLD_FIRE);
for(int i=0;i<3;i++)
{
IEntity actor=ERR_Actors.Spawn("{C31F210ABE078199}Prefabs/ERR/ReconPilotWest.et", ERR_Actors.Ground(Vector(4730+i*15,0,11650)));
mode.Own(actor); ERR_Actors.SetFaction(actor,mode.PlayerFaction());
AIControlComponent control=AIControlComponent.Cast(actor.FindComponent(AIControlComponent)); control.ActivateAI();
AIAgent agent=control.GetControlAIAgent(); agent.SetPermanentLOD(0); agent.ActivateAI(); targetGroup.AddAgent(agent);
PrintFormat("ERR PLANE TARGET faction=%1 group=%2 alive=%3",SCR_FactionManager.SGetFaction(actor).GetFactionKey(),targetGroup,ERR_Actors.CanFight(actor));
DamageManagerComponent damage=DamageManagerComponent.Cast(actor.FindComponent(DamageManagerComponent)); damage.EnableDamageHandling(false);
}
}
if(flight.Crew)
{
array<ref ERR_HQVisualContact> visible={}; ERR_HQObservation.Gather(flight.Crew.GetGroupUtilityComponent(),now,visible);
if(!visible.IsEmpty() && !m_ERRSeen) PrintFormat("ERR PLANE NATIVE VISIBLE count=%1 target=%2",visible.Count(),visible[0].Entity);
array<ref ERR_HQReport> reports={}; hq.SupportContacts(reports,now);
foreach(ERR_HQReport report:reports) if(report.Source==flight.Crew && !m_ERRSeen)
{ m_ERRSeen=true; PrintFormat("ERR PLANE PASS native crew sighting delivered to HQ target=%1 position=%2",report.Target,report.Position); }
}
if(flight.Airborne() && m_ERRAirborneAt==0) { m_ERRAirborneAt=now; Print("ERR PLANE PASS native airport takeoff"); }
if(!m_ERRKilled && m_ERRAirborneAt>0 && now-m_ERRAirborneAt>=120000)
{
SCR_VehicleDamageManagerComponent damage=SCR_VehicleDamageManagerComponent.Cast(flight.Aircraft.FindComponent(SCR_VehicleDamageManagerComponent));
PrintFormat("ERR PLANE PASS 120s patrol alive=%1 position=%2 speed=%3",ERR_Actors.Alive(flight.Aircraft),flight.Aircraft.GetOrigin(),flight.Aircraft.GetPhysics().GetVelocity().Length());
damage.SetHealthScaled(0); m_ERRKilled=true; m_ERRDestroyedAt=now; Print("ERR PLANE TEST aircraft destroyed");
}
if(m_ERRKilled && !m_ERRCaptured && flight.Aircraft!=m_ERRFirst && flight.Airborne())
{
PrintFormat("ERR PLANE PASS replacement took off after destruction elapsed=%1",now-m_ERRDestroyedAt);
m_ERRCaptured=flight; ERR_Actors.SetFaction(flight.Aircraft,mode.PlayerFaction());
}
}
}
modded class ERR_PlaneFlight
{
bool ERR_RatesRestored()
{
vector actual;
return ERR_CessnaBridge.Rates(Aircraft,m_InputRates,actual) && actual==m_InputRates;
}
}