Implement Baseball aiming, pooled projectiles and VR07 targets
This commit is contained in:
1 parent
50fcb87d90
commit
d6ca417e9e
50 files changed
+3149
-32
No files matched your search
@@ -0,0 +1,187 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Identity-guarded Baseball evidence and bounded arithmetic projections.
|
||||
|
||||
No original code executes. The yaw-only launch projection uses continuous host
|
||||
trig; source full-Euler table quantization remains a separate precision boundary.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
BODIES = (
|
||||
('constructor', 0x40fc50, 0x40fe67, 'f539ae6099b61f9f1f7007cd185f211b3165dc484cf502c80eb4b5dfc1c2ef0b'),
|
||||
('pool', 0x422609, 0x4226a3, '8324ec8b6bd8d9ce6c65782611781d2a5e990e8f73359fd0403e6795ba1a9771'),
|
||||
('primary', 0x426566, 0x4268b4, 'be39a4022aaaf35b9e629597bd04a50e957dcdbe8c8e64fd6ca91e7060b66565'),
|
||||
('equip', 0x4296f8, 0x4297dd, '2c530179e91a377e31e9bc169c25332bf3821cec614e927d3d5bc51871d69d10'),
|
||||
('cleanup', 0x42871d, 0x4287ac, '7fdcf6718f6a53a5136240894dbd8c9f840968afbf7c5e10f2d2f766da48a3dd'),
|
||||
('launch', 0x429a30, 0x429c03, 'fb35366b25c4a6b1503a8028aeb354d8bbfc8d32f60a850a2fde109913e34a53'),
|
||||
('ball_callbacks', 0x40fee0, 0x410020, '0b0a8ca521c8f92583a57586af945860bb21042240b72b8bc57ff13e061ac45c'),
|
||||
('jimmy_contact', 0x423014, 0x423080, '997533ba4cd830f11af35b19aa926ebc52a5fce2ee394a7da2c0b82410d9b4d3'),
|
||||
('aim_input', 0x438bc0, 0x438cd0, '329acdc727d4d68fcc7d2cc85dcfe408f6e18700574af891d889673a780ec7d5'),
|
||||
('support_order', 0x47bb10, 0x47bba7, '7f34edef3fad0a511d8af4ff8add816d9169b8407b05f1093683969ee4a21669'),
|
||||
('wall_reflection', 0x472750, 0x472970, 'cae4ae6987680cb97264a918efc33e5bdd25f3b419096d201fc948130bc52315'),
|
||||
('defaults', 0x46fd90, 0x46fe49, 'c04ff2c68b8b2ce5cbee48675a54e73f85dcf3014c9b9efd93a42213c75792ab'),
|
||||
('aim_art', 0x402084, 0x402107, '4a839c828fe971f0629796f8dfe5523e695a448bd5812768a74f3976071b561e'),
|
||||
('stop_sound', 0x429a00, 0x429a25, '09501f7e7ec80126459cd211ad9520f65c66d1ca4c6e644781a05137d620c3fd'),
|
||||
('energy_gate', 0x4269d0, 0x426a69, '0a97a24b016fa6743b518cd6ebadce5966a717b84e4ca0bdfa583bcdc65d16b5'),
|
||||
)
|
||||
VTABLES = (
|
||||
(0x4a3bdc, 0x174, 0x428d50), (0x4a3bdc, 0x178, 0x427ff0),
|
||||
(0x4a3bdc, 0x180, 0x429a30), (0x4a3bdc, 0x148, 0x429a00),
|
||||
(0x4a3bdc, 0x170, 0x437740), (0x49141c, 0x370, 0x40ff50),
|
||||
(0x49141c, 0x374, 0x40fee0), (0x49141c, 0x378, 0x472750),
|
||||
(0x49141c, 0x37c, 0x40ff80), (0x49141c, 0x3c4, 0x40ff40),
|
||||
(0x49141c, 0x40c, 0x410000), (0x49141c, 0x288, 0x471cc0),
|
||||
(0x49141c, 0x2c4, 0x471f40),
|
||||
)
|
||||
CONSTANTS = ((0x49195c, 'f', -0.6499999761581421),
|
||||
(0x49fabc, 'f', 0.02222222276031971),
|
||||
(0x4a311c, 'f', 1800.), (0x49d5c8, 'f', 45.),
|
||||
(0x48d404, 'f', 30.), (0x4a3e40, 'd', 4.3),
|
||||
(0x4a3130, 'd', 100.), (0x495324, 'f', 20.))
|
||||
|
||||
|
||||
def collect(original: Path | str):
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
if digest != EXE_SHA256:
|
||||
raise ValueError('Unexpected original EXE identity')
|
||||
bodies = []
|
||||
for name, start, end, expected in BODIES:
|
||||
actual = hashlib.sha256(read_va(pe, start, end-start)).hexdigest()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed source span {name}')
|
||||
bodies.append(dict(name=name, va=hex(start), file_offset=hex(pe.offset(start-pe.base)),
|
||||
length=end-start, sha256=actual))
|
||||
for table, slot, target in VTABLES:
|
||||
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != target:
|
||||
raise ValueError(f'Changed virtual {table:x}+{slot:x}')
|
||||
for va, fmt, value in CONSTANTS:
|
||||
if struct.unpack('<'+fmt, read_va(pe, va, struct.calcsize(fmt)))[0] != value:
|
||||
raise ValueError(f'Changed constant {va:x}')
|
||||
# These are dispatcher table entries, not guessed gadget enumeration labels.
|
||||
if struct.unpack('<I', read_va(pe, 0x4298e8+7*4, 4))[0] != 0x4296f8:
|
||||
raise ValueError('Changed item6 equip target')
|
||||
if struct.unpack('<I', read_va(pe, 0x428844+6*4, 4))[0] != 0x42871d:
|
||||
raise ValueError('Changed raw6 cleanup target')
|
||||
font_table = read_va(pe, 0x4f4ed8, 768)
|
||||
if hashlib.sha256(font_table).hexdigest() != '910bef1d7aca6f1aa328ba9f671831bdbbda19b419fb0c693117cb096d542226':
|
||||
raise ValueError('Changed source gameplay font table')
|
||||
digits = [struct.unpack_from('<h', font_table, 5*128+(ord(c)-32)*2)[0] for c in '0123456789']
|
||||
if digits != [118,127,120,121,122,123,124,125,126,119] or struct.unpack_from('<h', font_table, 5*128)[0] != -1:
|
||||
raise ValueError('Changed TIME digit/null-space binding')
|
||||
return dict(sha256=digest, bodies=bodies,
|
||||
vtables=[dict(table=hex(t), slot=hex(s), target=hex(v)) for t,s,v in VTABLES],
|
||||
constants=[dict(va=hex(a), value=v) for a,_,v in CONSTANTS],
|
||||
pool_size=20, ball_canvas=2, ball_size=25, radius=15,
|
||||
factor=1, wall_damping=f32(.46), floor_friction=f32(.46),
|
||||
authored_property24=f32(3.2),
|
||||
landing_impulse_scale=f32(-.65), throw_energy=-1, throw_sound=10,
|
||||
aim_font=dict(table_va='0x4f4ed8', table_file_offset=hex(pe.offset(0x4f4ed8-pe.base)),
|
||||
set=5, digits=digits, null_space=True, digit_dimensions=[16,16]),
|
||||
aim_canvas=253, aim_position=[315,100], practice='vr07.gam')
|
||||
|
||||
|
||||
def f32(value):
|
||||
return struct.unpack('<f', struct.pack('<f', value))[0]
|
||||
|
||||
|
||||
def finite(*values):
|
||||
if not all(math.isfinite(v) for v in values):
|
||||
raise ValueError('Finite inputs required')
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Aim:
|
||||
pending: bool = False
|
||||
saved_pitch: float = 0.
|
||||
|
||||
|
||||
def aim_hold(state: Aim, current_pitch: float, *, mode=6, supported=True,
|
||||
energy=1., exempt=False, busy=False, modal=False):
|
||||
"""42668F..4268AF after outer input/primary gates; no timing integration.
|
||||
|
||||
First hold arms without capturing a new pitch. Existing pending state is
|
||||
preserved by rejects. Airborne raw6 follows other primary behavior.
|
||||
"""
|
||||
finite(current_pitch, energy, state.saved_pitch)
|
||||
if busy or modal or mode == 0 or (energy <= 0 and not exempt):
|
||||
return state
|
||||
if mode != 6 or not supported:
|
||||
return state
|
||||
if not state.pending:
|
||||
return replace(state, pending=True)
|
||||
return replace(state, saved_pitch=f32(max(0., min(45., current_pitch))))
|
||||
|
||||
|
||||
def release(state: Aim, *, primary=False):
|
||||
"""426585..4265F9; intentionally no mode/energy test after pending check."""
|
||||
if primary or not state.pending:
|
||||
return state, None
|
||||
return replace(state, pending=False), dict(pitch=state.saved_pitch, sound=10, energy=-1.)
|
||||
|
||||
|
||||
def cleanup(state: Aim):
|
||||
"""Raw6 cleanup does not write pending1E26 or savedPitch1E28."""
|
||||
return state
|
||||
|
||||
|
||||
def aim_label(saved_pitch):
|
||||
"""426754..426792 screen text arguments, computed BEFORE new pitch capture."""
|
||||
finite(saved_pitch)
|
||||
return 286, int((45.-saved_pitch)*4.3+100.), int(saved_pitch)
|
||||
|
||||
|
||||
def next_slot(index: int, *, exists=True):
|
||||
if not 0 <= index < 20:
|
||||
raise ValueError('Pool index must be0..19')
|
||||
return (index+1) % 20 if exists else index
|
||||
|
||||
|
||||
def launch_yaw_only(root, yaw, saved_pitch):
|
||||
"""429A30 upright actor subset, no original trig-table precision claim.
|
||||
|
||||
Full source uses local-point384(0,80,50), then local-vector38C(0,
|
||||
float32(pitch*float32(1/45)),1), quick-normalize, multiply1800.
|
||||
"""
|
||||
finite(*root, yaw, saved_pitch)
|
||||
if len(root) != 3 or not 0 <= saved_pitch <= 45:
|
||||
raise ValueError('Three-vector root and bounded pitch required')
|
||||
angle = math.radians(yaw)
|
||||
s, c = math.sin(angle), math.cos(angle)
|
||||
slope = f32(saved_pitch*f32(1/45))
|
||||
scale = 1800/math.sqrt(1+slope*slope)
|
||||
return ((root[0]-50*s, root[1]+80, root[2]+50*c),
|
||||
(-s*scale, slope*scale, c*scale))
|
||||
|
||||
|
||||
def landing_impulse(velocity):
|
||||
"""40FF80 writes impulse288, BEFORE support47BB74 clears velocityY."""
|
||||
finite(*velocity)
|
||||
x,y,z = velocity
|
||||
return f32(x), f32(y*f32(-.65)), f32(z)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
cli.add_argument('--output', type=Path)
|
||||
args=cli.parse_args()
|
||||
result=json.dumps(collect(args.original), indent=2)+'\n'
|
||||
if args.output:
|
||||
original=args.original.resolve()
|
||||
if args.output.resolve().is_relative_to(original):
|
||||
cli.error('Write generated evidence outside the original directory')
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(result)
|
||||
else:
|
||||
print(result, end='')
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only source guards for VR07 moving targets; projections are not execution."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'levels'))
|
||||
from gam import parse
|
||||
|
||||
BODIES = (
|
||||
('target_constructor', 0x430220, 0x4304F6, '17b53c1d4a2196a52bfc43bb7a96216874d7d8923474a2062513312bbe783ae2'),
|
||||
('target_contact', 0x430570, 0x4306A2, 'c5aeee5d71caba224d24159edbfc9a9d835cb4524ae13eee063e69e3187a76c4'),
|
||||
('target_frame', 0x4306B0, 0x430860, '85fd36a64db4876ffabe0f66d3897ef0ee95ed1401646591afcff2ebdb55093f'),
|
||||
('sprite_postload', 0x441AC0, 0x441B20, '10dcae6c03a8cf9f54aade2062a315179a4de9546f1c36380083edfb3d344062'),
|
||||
('vr07_constructor', 0x4573F0, 0x4574D8, '5a4772c281584d37184d99a7b995fa806ff653bc8ed680c75227560663110523'),
|
||||
('parent_activation', 0x40E1F0, 0x40E270, '515567cf4a702fa8864c3b714759585e83f34bddb047e8eb762dede3ef480951'),
|
||||
)
|
||||
TABLES = ((0x4A8A10, 0x40, 0x430570), (0x4A8A10, 0x3C4, 0x4306B0),
|
||||
(0x4A8A10, 0x40C, 0x441AC0), (0x4CFAE0, 0x134, 0x475CD0),
|
||||
(0x4BE404, 0x428, 0x40E1F0))
|
||||
|
||||
|
||||
def collect(original: Path):
|
||||
pe = PE(find_case(original, 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unexpected original executable identity')
|
||||
bodies = []
|
||||
for name, start, end, expected in BODIES:
|
||||
if hashlib.sha256(read_va(pe, start, end-start)).hexdigest() != expected:
|
||||
raise ValueError(f'Changed original span {name}')
|
||||
bodies.append(dict(name=name, va=hex(start), fileOffset=hex(pe.offset(start-pe.base)),
|
||||
length=end-start, sha256=expected))
|
||||
for table, slot, target in TABLES:
|
||||
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != target:
|
||||
raise ValueError('Changed original virtual target')
|
||||
if read_va(pe, 0x45CA06, 5) != bytes.fromhex('e81538fdff'):
|
||||
raise ValueError('Changed 3TAR factory constructor')
|
||||
if read_va(pe, 0x475CD0, 5) != bytes.fromhex('32c0c21800'):
|
||||
raise ValueError('Changed false game registration filter')
|
||||
level = parse(find_case(original, 'gam/VR07.gam').read_bytes())
|
||||
targets = [dict(offset=hex(e.offset), properties=e.values()) for e in level.entities if e.kind == '3TAR']
|
||||
return dict(sha256=EXE_SHA256, bodies=bodies, targets=targets,
|
||||
vtables=[dict(table=hex(t), slot=hex(s), target=hex(f)) for t,s,f in TABLES],
|
||||
evidenceType='Static source guards and serialized data, not original runtime')
|
||||
|
||||
|
||||
def hit_target(timer: float, points: int, respawn: float):
|
||||
"""430592..4305D1: caller already proved a C3DBASEBALL contact."""
|
||||
if timer > 0:
|
||||
return dict(accepted=False, hidden=False, timer=timer, points=0)
|
||||
return dict(accepted=True, hidden=True, timer=respawn, points=points)
|
||||
|
||||
|
||||
def step_respawn(timer: float, seconds: float):
|
||||
"""4306FA..43074F: expiry is <=0 after the stored float subtraction."""
|
||||
if timer <= 0:
|
||||
return timer, False
|
||||
value = struct.unpack('<f', struct.pack('<f', timer-seconds))[0]
|
||||
return (0, True) if value <= 0 else (value, False)
|
||||
|
||||
|
||||
def parent_hits(count: int, required: int):
|
||||
"""4305FB..430631: strict >, not >=; only after a matching parent lookup."""
|
||||
count += 1
|
||||
return (0, True) if count > required else (count, False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
print(json.dumps(collect(cli.parse_args().original), indent=2))
|
||||
@@ -0,0 +1,199 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only Scooter identity guards and bounded static projections.
|
||||
|
||||
No target execution. Input projection is keyboard-only; drive gate deliberately
|
||||
requires child support observations instead of fabricating wheel contacts.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
BODIES = (
|
||||
('equip', 0x4290b7, 0x429375, '4e65ee2007a20cd3a78a4529c8177fb6245c539041b82417095a267c193d9ec1'),
|
||||
('cleanup', 0x4281b3, 0x4284fb, '8ac21a2f27a6703058d18965e86759a878e7d31da86fa827015394164e1a06ec'),
|
||||
('spawn', 0x423ce8, 0x423dc1, 'dbfa1a7b5609eef20a3ef3d9bd86320d79ee616b06220bedce71bb014d04c5a6'),
|
||||
('mount', 0x422f13, 0x422fb9, '4d51aa5e2324e3af45632eeae417e976d4cbee9e421a10b1b47ca0a5758811d5'),
|
||||
('constructor', 0x4211a0, 0x4212f7, 'dd15bf6a55325da3247fe6fe9d9986b2a718ee5945dc10f5dfcbd1ed23a7c741'),
|
||||
('frame', 0x421580, 0x4217ca, '0d05dda2520f9063d66b256098ad4e63f42eeb1139620d458c86d9a9b6d4b458'),
|
||||
('input', 0x421880, 0x4218be, 'e46056df24b730111fbaa9a02878ad954762e4b23ac2cec602bbf875677ce14c'),
|
||||
('predicates', 0x421c10, 0x421cf7, '7461aaff87634a270874304ad4a4618fdc020c3643cc21d605d5cf3b4581820e'),
|
||||
('vehicle_frame', 0x465220, 0x46582d, '22a766ca5ccd38bcb524d75b1620dfd4718b2ddef2997dedae3f6f84d0984ec8'),
|
||||
('vehicle_input', 0x465830, 0x465dfe, '62cb4e87ab784d45a13fc763cb79b00d23942a95776568209cbd2b0b625f191f'),
|
||||
('vehicle_constructor', 0x464b90, 0x464de2, 'af460774f65ffa90dde8407145ffee72643f3e81586a033162b5b22985067017'),
|
||||
('parameters', 0x464f60, 0x464fcb, 'd32e32495b39a261b6f778d5a24da9a70309c4766dc0994cc2a4973253f57aa9'),
|
||||
('wheel_setup', 0x412a90, 0x412c77, '2f44692c4545b8088711168dff16269461a862c400b591e091a20ce89c9576ff'),
|
||||
('sound', 0x412ed0, 0x412f8b, '93ae7fb944aaeff732fa99bcc89db5546bdf8a379a3922575d79b693c03f4408'),
|
||||
('camera', 0x4130a0, 0x413a60, '9614e6e4ae80f576c060706bd6da453e8f29d8568330c60293570f57c3f4dcc2'),
|
||||
('collision_callback', 0x421910, 0x421ba4, 'a5a0cd543bf833aa87a896c33144c4d374bb55aae7d7726619011ce6b3611ebc'),
|
||||
('base_factor', 0x412940, 0x41294c, '5bd12b37bcf408ee68ea761709182ba1781a4b7debbf0bae4a236ac1aa0ae238'),
|
||||
)
|
||||
VTABLES = (
|
||||
(0x4a2f8c, 0x168, 0x412a90), (0x4a2f8c, 0x174, 0x421800),
|
||||
(0x4a2f8c, 0xec, 0x4130a0), (0x4a2f8c, 0x120, 0x421c10),
|
||||
(0x4a2f8c, 0x124, 0x421c40), (0x4a2f8c, 0x128, 0x421c70),
|
||||
(0x4a2f8c, 0x12c, 0x421cb0), (0x4a2f8c, 0x130, 0x413a60),
|
||||
(0x4a2aec, 0x110, 0x471240), (0x4a2aec, 0x100, 0x4711e0),
|
||||
(0x4a2aec, 0x214, 0x471a00), (0x4a2aec, 0x28c, 0x471c90),
|
||||
(0x4a2aec, 0x438, 0x4218c0),
|
||||
)
|
||||
CONSTANTS = ((0x4a3110, 'd', .3), (0x48e5dc, 'f', 200.),
|
||||
(0x49d5cc, 'f', -45.), (0x49d5c8, 'f', 45.),
|
||||
(0x4a3118, 'f', 0.6600000262260437),
|
||||
(0x4afce0, 'f', 0.4000000059604645),
|
||||
(0x4a311c, 'f', 1800.), (0x4a3120, 'f', 4.5),
|
||||
(0x4a3124, 'f', 600.), (0x48e5ec, 'f', 10.))
|
||||
|
||||
|
||||
def collect(original: Path | str):
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
if digest != EXE_SHA256:
|
||||
raise ValueError('Unexpected original EXE identity')
|
||||
bodies = []
|
||||
for name, start, end, expected in BODIES:
|
||||
actual = hashlib.sha256(read_va(pe, start, end-start)).hexdigest()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed source span {name}')
|
||||
bodies.append(dict(name=name, va=hex(start), file_offset=hex(pe.offset(start-pe.base)),
|
||||
length=end-start, sha256=actual))
|
||||
for base, slot, expected in VTABLES:
|
||||
if struct.unpack('<I', read_va(pe, base+slot, 4))[0] != expected:
|
||||
raise ValueError(f'Changed virtual {base:x}+{slot:x}')
|
||||
for va, kind, expected in CONSTANTS:
|
||||
if struct.unpack('<'+kind, read_va(pe, va, struct.calcsize(kind)))[0] != expected:
|
||||
raise ValueError(f'Changed constant {va:x}')
|
||||
for va, value in [(0x4eef2c, b'omt\\scooter.omt\0'), (0x4eef4c, b'SCOOT\0'),
|
||||
(0x4eef54, b'SCOOTSTOP\0'), (0x4ecc80, b'C3DJEEP\0')]:
|
||||
if read_va(pe, va, len(value)) != value:
|
||||
raise ValueError(f'Changed source string {va:x}')
|
||||
if read_va(pe, 0x413a60, 3) != b'\x32\xc0\xc3':
|
||||
raise ValueError('Changed always-false sprint predicate')
|
||||
return dict(sha256=digest, bodies=bodies,
|
||||
vtables=[dict(table=hex(b), slot=hex(s), target=hex(t)) for b,s,t in VTABLES],
|
||||
constants=[dict(va=hex(a), value=v) for a,k,v in CONSTANTS],
|
||||
raw_mode=4, actor_class='C3DJEEP', radius=150, factor=f32(.2),
|
||||
wheel_slots=6, wheel_construction_count=4, drive_support_minimum=2,
|
||||
normal_maximum=f32(2250*f32(.66)), jump_pending_y=700,
|
||||
original_runtime_verified=False, runtime_implemented=False)
|
||||
|
||||
|
||||
def f32(value):
|
||||
return struct.unpack('<f', struct.pack('<f', value))[0]
|
||||
|
||||
|
||||
def finite(*values):
|
||||
if not all(math.isfinite(v) for v in values):
|
||||
raise ValueError('Finite source inputs required')
|
||||
|
||||
|
||||
def timestep(seconds):
|
||||
finite(seconds)
|
||||
if not 0 <= seconds < 1:
|
||||
raise ValueError('Bounded timestep required')
|
||||
|
||||
|
||||
def equip_result(*, companion_exists=True, companion_enabled=True, practice=False):
|
||||
"""4290B7 leaf. Spawning/showing does not itself mount or change control."""
|
||||
if practice:
|
||||
return 'practice_VR05'
|
||||
return 'raw4_vehicle_visible_unmounted' if companion_exists and companion_enabled else 'unchanged'
|
||||
|
||||
|
||||
def drive_eligible(grounded: bool, wheel_supports: tuple[bool | None, ...]):
|
||||
"""465594..4655AE. None is a missing child, not an invented supported child."""
|
||||
if len(wheel_supports) != 6 or any(v is not None and type(v) is not bool for v in wheel_supports):
|
||||
raise ValueError('Six source wheel slots required')
|
||||
front = sum(v is True for v in wheel_supports[:2])
|
||||
rear = sum(v is True for v in wheel_supports[2:])
|
||||
return dict(front=front, rear=rear, total=front+rear,
|
||||
drive=bool(grounded and front+rear >= 2))
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Steering:
|
||||
speed: float = 0.
|
||||
turn: float = 0.
|
||||
keyboard_turn: bool = False
|
||||
reverse_latch: bool = False
|
||||
braking: bool = False
|
||||
|
||||
|
||||
def keyboard_input(state: Steering, seconds: float, *, left=False, right=False,
|
||||
forward=False, backward=False, rear_supports=0):
|
||||
"""465830 keyboard subset, no AI/sprint/mouse/analog/camera/contact phase.
|
||||
|
||||
413A60 sprint predicate always returns false for this vehicle. Values round
|
||||
at source storage boundaries, without claiming x87 bit parity.
|
||||
"""
|
||||
timestep(seconds)
|
||||
finite(state.speed, state.turn)
|
||||
if type(rear_supports) is not int or not 0 <= rear_supports <= 4:
|
||||
raise ValueError('Rear source support count0..4 required')
|
||||
dt = f32(seconds)
|
||||
turn = state.turn
|
||||
key_turn = state.keyboard_turn
|
||||
if left:
|
||||
turn += dt*200
|
||||
key_turn = True
|
||||
elif right:
|
||||
turn -= dt*200
|
||||
key_turn = True
|
||||
elif key_turn:
|
||||
turn = max(0., turn-dt*200) if turn > 0 else min(0., turn+dt*200)
|
||||
turn = f32(min(45., max(-45., turn)))
|
||||
speed = state.speed
|
||||
reverse_latch, braking = state.reverse_latch, state.braking
|
||||
maximum = f32(2250*f32(.66))
|
||||
throttle = forward and rear_supports > 0
|
||||
if throttle:
|
||||
if speed < maximum:
|
||||
speed = f32(min(maximum, speed+dt*700))
|
||||
reverse_latch = False
|
||||
if backward and rear_supports > 0:
|
||||
if not reverse_latch:
|
||||
reverse_latch = True
|
||||
if speed > 0:
|
||||
speed = f32(max(0., speed-dt*1200))
|
||||
braking = True
|
||||
elif speed < 0:
|
||||
speed = f32(min(0., speed+dt*1200))
|
||||
braking = True
|
||||
else:
|
||||
speed = f32(max(-maximum*f32(.4), speed-dt*1200))
|
||||
else:
|
||||
braking = False
|
||||
reverse_latch = False
|
||||
return Steering(speed, turn, key_turn, reverse_latch, braking)
|
||||
|
||||
|
||||
def jump_pending(*, mounted: bool, grounded: bool, held: bool, latched: bool):
|
||||
"""4215BA..421618: source pending vector write, not direct live velocity."""
|
||||
if not mounted:
|
||||
return latched, None
|
||||
if not held:
|
||||
return False, None
|
||||
if not latched and grounded:
|
||||
return True, (0., 700., 0.)
|
||||
return latched, None
|
||||
|
||||
|
||||
def animation_step(timer: float, seconds: float, speed: float):
|
||||
"""42171A: strict double.3 comparison after float timer store."""
|
||||
finite(timer, speed)
|
||||
timestep(seconds)
|
||||
timer = f32(timer+f32(seconds))
|
||||
return (0., 'SCOOTSTOP' if speed < 10 else 'SCOOT') if timer > .3 else (timer, None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
print(json.dumps(collect(cli.parse_args().original), indent=2))
|
||||
Reference in new issue
Block a user