18 lines
1.1 KiB
Python
18 lines
1.1 KiB
Python
from policy_harness import ROOT, body, run
|
|
p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_PlayerMedical.c'
|
|
rule=body(p,'static float AllowedDamage(').replace('Math.Clamp','std::clamp').replace('Math.Min','std::min').replace('Math.Max','std::max').replace('0.01','0.01f').replace(', 1)',', 1.0f)').replace('std::max(0,','std::max(0.0f,')
|
|
run('''#include <algorithm>
|
|
#include <cassert>
|
|
'''+rule+'''
|
|
int main(){
|
|
assert(AllowedDamage(-40,10,100,0)==-40); // medical treatment must pass unchanged
|
|
assert(AllowedDamage(0,10,100,0)==0);
|
|
assert(AllowedDamage(5,100,100,0)==5); // ordinary damage still wounds
|
|
assert(AllowedDamage(100000,100,100,0)==99); // lethal blow stops above destruction
|
|
assert(AllowedDamage(100000,30,100,0.2f)>8.99f&&AllowedDamage(100000,30,100,0.2f)<9.01f);
|
|
assert(AllowedDamage(50,1,100,0)==0); // repeated damage cannot finish casualty
|
|
assert(AllowedDamage(50,0,100,0)==0); // never turn positive damage into free healing
|
|
}
|
|
''')
|
|
print('PASS: lethal and repeated damage clamp above configured destruction thresholds; ordinary wounds and healing retain their values')
|