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,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