Integrate faction and random settings menus, generated objectives, scouts, convoys, air support, mortar stations and body-intel recovery. Add identified-body aggression, finite hunter UAZ deployment, dedicated objective defence and maximum AI skill with separate reduced aim accuracy. Include policy tests, native probes, evidence and documentation.
42 lines
2.4 KiB
Python
42 lines
2.4 KiB
Python
"""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 <cassert>
|
|
enum class EAISkill{REGULAR,CYLON};
|
|
struct SCR_AIThreatSystem{};
|
|
struct PerceptionComponent{float factor=0;void SetPerceptionFactor(float f){factor=f;}};
|
|
struct Native{
|
|
int calls=0;EAISkill sampled=EAISkill::CYLON;
|
|
float GetRandomFactor(EAISkill s,float mu){calls++;sampled=s;return mu+1;}
|
|
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;
|
|
aim.GetRandomFactor(EAISkill::CYLON,0);assert(aim.sampled==EAISkill::CYLON);
|
|
aim.m_CombatComponent=&combat;aim.GetRandomFactor(EAISkill::CYLON,0);assert(aim.sampled==EAISkill::CYLON);
|
|
combat.bound=true;aim.GetRandomFactor(EAISkill::CYLON,0);assert(aim.sampled==EAISkill::REGULAR);
|
|
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);
|
|
aim.GetRandomFactor(EAISkill::CYLON,0);assert(aim.sampled==EAISkill::CYLON);
|
|
}
|
|
''')
|
|
print('PASS: actual scoped REGULAR aim error and alert perception; preserves equipment multiplier and restores vanilla behavior when unbound')
|