"""Execute production aim/perception overrides with native API doubles.""" from policy_harness import ROOT, body, run path=ROOT/'addons/core/Scripts/Game/ERR/10_AI/ERR_EnemySkillAwareness.c' def native(signature): s=body(path,signature).replace('override ','').replace('super.', 'Native::').replace('EAISkill.', 'EAISkill::') s=s.replace('PerceptionComponent perceptionComp','PerceptionComponent* perceptionComp').replace('SCR_AIThreatSystem threatSystem','SCR_AIThreatSystem* threatSystem') return s.replace('perceptionComp.', 'perceptionComp->').replace('m_CombatComponent.', 'm_CombatComponent->') run(r''' #include #include enum class EAISkill{REGULAR,CYLON}; struct SCR_AIThreatSystem{}; struct PerceptionComponent{float factor=0;void SetPerceptionFactor(float f){factor=f;}}; struct Native{ float error=1;int calls=0;EAISkill sampled=EAISkill::CYLON; float GetRandomFactor(EAISkill s,float mu){calls++;sampled=s;return mu+error;} void UpdatePerceptionFactor(PerceptionComponent* p,SCR_AIThreatSystem*){calls++;p->factor=.4f;} }; struct Combat:Native{ bool bound=false;float m_fEquipmentPerceptionFactor=1,m_fPerceptionFactor=1; static constexpr float PERCEPTION_FACTOR_ALERTED=2.5f; bool ERR_EnhancedEnemy(){return bound;} '''+native('override void UpdatePerceptionFactor(')+r''' }; struct Aim:Native{ Combat* m_CombatComponent=nullptr; '''+native('override float GetRandomFactor(')+r''' }; int main(){ Aim aim;Combat combat;PerceptionComponent perception;SCR_AIThreatSystem threat; assert(aim.GetRandomFactor(EAISkill::CYLON,0)==1);assert(aim.sampled==EAISkill::CYLON); aim.m_CombatComponent=&combat;assert(aim.GetRandomFactor(EAISkill::CYLON,0)==1);assert(aim.sampled==EAISkill::CYLON); combat.bound=true;assert(std::abs(aim.GetRandomFactor(EAISkill::CYLON,0)-.9f)<.00001f);assert(aim.sampled==EAISkill::REGULAR); assert(std::abs(aim.GetRandomFactor(EAISkill::CYLON,5)-5.9f)<.00001f); aim.error=-2;assert(std::abs(aim.GetRandomFactor(EAISkill::CYLON,0)+1.8f)<.00001f);aim.error=1; combat.UpdatePerceptionFactor(&perception,&threat);assert(perception.factor==2.5f&&combat.calls==0); combat.m_fEquipmentPerceptionFactor=3;combat.m_fPerceptionFactor=.5f; combat.UpdatePerceptionFactor(&perception,&threat);assert(perception.factor==3.75f); combat.UpdatePerceptionFactor(nullptr,&threat);assert(combat.calls==0); combat.bound=false;combat.UpdatePerceptionFactor(&perception,&threat);assert(perception.factor==.4f&&combat.calls==1); assert(aim.GetRandomFactor(EAISkill::CYLON,0)==1);assert(aim.sampled==EAISkill::CYLON); } ''') print('PASS: actual scoped 10% tighter REGULAR aim error and alert perception; preserves equipment multiplier and restores vanilla behavior when unbound')