Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
21 lines
2.2 KiB
Python
21 lines
2.2 KiB
Python
from pathlib import Path
|
|
P=Path('/tmp/erri-launcher-resupply-1140');R=Path('/home/jakub/devel/escapistsrereintroduced');d=P/'addons/core/Scripts/Game/ERR/10_AI'
|
|
p=d/'ERR_InfantryAmmoTransfer.c';s=p.read_text().replace('if (muzzle.IsDisposable()) continue;', '''if (muzzle.IsDisposable()) continue;
|
|
SCR_MuzzleInMagComponent reloadable = SCR_MuzzleInMagComponent.Cast(muzzle);
|
|
if (reloadable && !reloadable.CanBeReloaded()) continue;''');p.write_text(s)
|
|
p=d/'ERR_HQAmmoSampler.c';s=p.read_text().replace('if (muzzle.GetMagazineWell() && !muzzle.IsDisposable()) result.LauncherMuzzles++;', '''SCR_MuzzleInMagComponent reloadable = SCR_MuzzleInMagComponent.Cast(muzzle);
|
|
bool supported = muzzle.GetMagazineWell() && !muzzle.IsDisposable();
|
|
if (reloadable && !reloadable.CanBeReloaded()) supported = false;
|
|
if (supported) result.LauncherMuzzles++;''');p.write_text(s)
|
|
for n in ['test_infantry_ammo_transfer.py','test_hq_ammo_sampler.py']:
|
|
p=P/'tests'/n;s=p.read_text().replace("'magazine','loaded','loadedItem'", "'magazine','reloadable','loaded','loadedItem'").replace("'weapon','muzzle','magazine','actor'", "'weapon','muzzle','reloadable','magazine','actor'")
|
|
# Translate only the native cast boundary.
|
|
marker="code=code.replace('array<'" if n=='test_hq_ammo_sampler.py' else "code=code.replace('ref ERR_InfantryAmmoCallback'"
|
|
pos=s.index(marker);s=s[:pos]+"code=code.replace('SCR_MuzzleInMagComponent.Cast(muzzle)', '(muzzle->inMag ? muzzle : nullptr)')\n"+s[pos:]
|
|
s=s.replace('using BaseMuzzleComponent=Muzzle*;', 'using BaseMuzzleComponent=Muzzle*;using SCR_MuzzleInMagComponent=Muzzle*;')
|
|
s=s.replace('bool disposable=false;bool IsDisposable()', 'bool inMag=false,canReload=true;bool CanBeReloaded(){return canReload;}bool disposable=false;bool IsDisposable()')
|
|
if n=='test_infantry_ammo_transfer.py':
|
|
s=s.replace('bad<7;', 'bad<8;').replace('if(bad==6)f.empty.capacity=0;', 'if(bad==6)f.empty.capacity=0;if(bad==7){f.muzzle.inMag=true;f.muzzle.canReload=false;}')
|
|
p.write_text(s)
|
|
n='test_hq_ammo_reporting.py';s=(R/'tests'/n).read_text();(P/'baseline/tests'/n).write_text(s);s=s.replace('LauncherRounds=', 'LauncherMuzzles=0,LauncherRounds=',1);(P/'tests'/n).write_text(s)
|