Fix convoy coordination, AI combat and spectator recovery

This commit is contained in:
2026-09-27 22:28:07 +02:00
parent 2551d171b3
commit c5629f7f4f
108 changed files with 4337 additions and 282 deletions
+10 -7
View File
@@ -7,12 +7,13 @@ def native(signature):
return s.replace('perceptionComp.', 'perceptionComp->').replace('m_CombatComponent.', 'm_CombatComponent->')
run(r'''
#include <cassert>
#include <cmath>
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;}
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{
@@ -27,15 +28,17 @@ struct Aim:Native{
};
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);
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);
aim.GetRandomFactor(EAISkill::CYLON,0);assert(aim.sampled==EAISkill::CYLON);
assert(aim.GetRandomFactor(EAISkill::CYLON,0)==1);assert(aim.sampled==EAISkill::CYLON);
}
''')
print('PASS: actual scoped REGULAR aim error and alert perception; preserves equipment multiplier and restores vanilla behavior when unbound')
print('PASS: actual scoped 10% tighter REGULAR aim error and alert perception; preserves equipment multiplier and restores vanilla behavior when unbound')