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))
|
||||
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Export exact Baseball canvases and authored VR07 data without timing guesses."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import asdict
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from entities import resolve_asset
|
||||
from gam import parse
|
||||
from omt import Database, FormatError, read_canvas, write_png
|
||||
|
||||
ARCHIVE_SHA256 = 'b584ffa4a38f4bc809b3ea8f4321e0c08f2719e22df41a3fb4cd143ed89b3bef'
|
||||
VR07_SHA256 = '1260b75d82ec794f9375ada30e186424746bc1dd4e4b0540c9b69bb7ad12d0b1'
|
||||
# Identity, source name, offset, bytes, width, height, decoded RGBA SHA256.
|
||||
CANVASES = (
|
||||
(2, 'ball0000', 72372, 3786, 32, 32, '68904b758e69139de0b01329b2a9844ecd2a466f31598c24324affaccfa2cab9'),
|
||||
(3, 'ball0001', 68582, 3790, 32, 32, '005def070e18111fbdb067e75285dad8ec677c1608020f55c3db7a4b9745205c'),
|
||||
(4, 'ball0002', 64788, 3794, 32, 32, 'c368a59d5d7a57824c1c6b56b617cf058f5d5d53e18e5e48989710413490c536'),
|
||||
(5, 'ball0003', 58830, 3794, 32, 32, 'e5da21c359d3215759e5c3c238107f526f7109203c0ff9fa391a3c8bc40c17ed'),
|
||||
(8, 'target', 48796, 10034, 64, 64, '8d31014cb9b9661ebed902c864bf740f562460e74da3f6b86ed3d2be4d10f0ec'),
|
||||
)
|
||||
AIM_ARCHIVES = {
|
||||
'omt/screens.omt': 'e8e95231f5d302b41f4fbf33df1c5a08ce4645370f9f519527ff1727b73b7a5e',
|
||||
'alpha.omt': '53cb9f47a588b1f19eb0adc4d43c8066a8b78aedd764b9e9314c81e287991126',
|
||||
}
|
||||
AIM_CANVASES = (
|
||||
('omt/screens.omt', 253, 15, 210, '2e16e11b151c8474ba68fd5017d1a3a6304a594a7f34c3b423f3417c7edfb453'),
|
||||
('alpha.omt', 118, 16, 16, 'edc60e65dcf7320813a80d4312e3c45951ccfc566ea79dfabf7a22ebc4b96049'),
|
||||
('alpha.omt', 127, 16, 16, '1fd058ad5bdc0f8a064ef7d2d52b2b036df3f35515691a366799d7e8aab5297f'),
|
||||
('alpha.omt', 120, 16, 16, '62aaeaaf107300a6f4f7ff52e98106c1520a9edbe2137626ee41091cf243e5c5'),
|
||||
('alpha.omt', 121, 16, 16, 'd78bf1895f5838b9eb8c6a22565a9588dae4fc8f7106697df373f4408aae634c'),
|
||||
('alpha.omt', 122, 16, 16, 'f6d628639de4e40005f62f63a49308ff9ee0656a36bb6eb7787230b4830a5ed9'),
|
||||
('alpha.omt', 123, 16, 16, '9f58cad5621d89b7a7012036daa8532b2397b0d9d267ab7d1aa5a7cd10d7ae87'),
|
||||
('alpha.omt', 124, 16, 16, '49cdc9ec812f4ef3826011d542c30afbb10229c4b4ce549e7820233bbaa53dd9'),
|
||||
('alpha.omt', 125, 16, 16, 'aaef2d59c2636c059b446bed643985ca55d15b2d070b0582b2d8994b3bf74f1e'),
|
||||
('alpha.omt', 126, 16, 16, 'bade574a4624a3f763ddd9c87fa2f102562b00d8d604e9faf32a43b372de64e0'),
|
||||
('alpha.omt', 119, 16, 16, '0a663ddf2df9f1065f5e4ffe27b4d1fa96edd5f19b6323217bad4148f8d2f3d7'),
|
||||
)
|
||||
TIME_DIGITS = (118, 127, 120, 121, 122, 123, 124, 125, 126, 119)
|
||||
|
||||
|
||||
def digest(data: bytes) -> str:
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def export_baseball(original: Path, output: Path) -> dict:
|
||||
original, output = original.resolve(), output.resolve()
|
||||
if output.is_relative_to(original) or original.is_relative_to(output):
|
||||
raise ValueError('Output must be separate from the original installation')
|
||||
if output.exists() and any(p.is_symlink() for p in output.rglob('*')):
|
||||
raise ValueError('Generated Baseball paths must not contain symlinks')
|
||||
database = Database(resolve_asset(original, 'omt/RetainedSprites.omt'))
|
||||
if digest(database.data) != ARCHIVE_SHA256:
|
||||
raise FormatError('Unexpected original Baseball archive identity')
|
||||
textures, pixels = [], []
|
||||
for identity, name, offset, size, width, height, rgba_sha in CANVASES:
|
||||
matches = [e for e in database.entries if e.type == 'Canv' and e.id == identity]
|
||||
if len(matches) != 1:
|
||||
raise FormatError('Missing original Baseball canvas')
|
||||
entry = matches[0]
|
||||
if (entry.name, entry.offset, entry.size) != (name, offset, size):
|
||||
raise FormatError('Unexpected original Baseball canvas metadata')
|
||||
payload = database.payload(entry)
|
||||
canvas = read_canvas(payload)
|
||||
rgba = canvas['rgba']
|
||||
if (canvas['width'], canvas['height'], len(rgba), digest(rgba)) != (width, height, width*height*4, rgba_sha):
|
||||
raise FormatError('Unexpected original Baseball decoded pixels')
|
||||
textures.append(dict(id=identity, name=name, width=width, height=height,
|
||||
path=f'canvas_{identity}.rgba', png=f'canvas_{identity}.png',
|
||||
sourceOffset=offset, sourceBytes=size, sourceSha256=digest(payload), rgbaSha256=rgba_sha))
|
||||
pixels.append(rgba)
|
||||
aim_databases = {name: Database(resolve_asset(original, name)) for name in AIM_ARCHIVES}
|
||||
for name, expected in AIM_ARCHIVES.items():
|
||||
if digest(aim_databases[name].data) != expected:
|
||||
raise FormatError('Unexpected Baseball aim archive identity')
|
||||
aim_textures, aim_pixels = [], []
|
||||
for archive, identity, width, height, rgba_sha in AIM_CANVASES:
|
||||
aim_database = aim_databases[archive]
|
||||
entry = next(e for e in aim_database.entries if e.type == 'Canv' and e.id == identity)
|
||||
payload = aim_database.payload(entry)
|
||||
canvas = read_canvas(payload)
|
||||
rgba = canvas['rgba']
|
||||
if (canvas['width'], canvas['height'], len(rgba), digest(rgba)) != (width, height, width*height*4, rgba_sha):
|
||||
raise FormatError('Unexpected Baseball aim decoded pixels')
|
||||
aim_textures.append(dict(id=identity, name=entry.name, database=archive,
|
||||
width=width, height=height, path=f'aim_{identity}.rgba', png=f'aim_{identity}.png',
|
||||
sourceOffset=entry.offset, sourceBytes=entry.size, sourceSha256=digest(payload), rgbaSha256=rgba_sha))
|
||||
aim_pixels.append(rgba)
|
||||
source = resolve_asset(original, 'gam/VR07.gam')
|
||||
source_data = source.read_bytes()
|
||||
if digest(source_data) != VR07_SHA256:
|
||||
raise FormatError('Unexpected original Baseball tutorial identity')
|
||||
level = parse(source_data)
|
||||
records = [dict(ordinal=index, **asdict(entity)) for index, entity in enumerate(level.entities)
|
||||
if entity.kind in ('STRT', '3TAR', '3MCA')]
|
||||
targets = [r for r in records if r['kind'] == '3TAR']
|
||||
if len(targets) != 6:
|
||||
raise FormatError('Unexpected original Baseball tutorial target count')
|
||||
manifest = dict(schema=1, source=database.path.name, sourceSha256=ARCHIVE_SHA256,
|
||||
textures=textures, ballCanvasIds=[2, 3, 4, 5], retainedTargetCanvasId=8,
|
||||
aimTextures=aim_textures, aimArchiveSha256=AIM_ARCHIVES.copy(),
|
||||
aimFontPolicy='Original TIME set5; null space has zero advance;16-unit digits',
|
||||
aimDigitIds=list(TIME_DIGITS),
|
||||
tutorial=dict(source=source.name, sha256=VR07_SHA256, entities=records),
|
||||
bindingPolicy='Exact resource identities; caller owns source timing, dimensions, billboarding and attachments')
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
for entry, rgba in zip(textures+aim_textures, pixels+aim_pixels):
|
||||
(output/entry['path']).write_bytes(rgba)
|
||||
write_png(output/entry['png'], entry['width'], entry['height'], rgba)
|
||||
(output/'baseball.json').write_text(json.dumps(manifest, indent=2)+'\n', encoding='utf-8')
|
||||
return manifest
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
export_baseball(args.original, args.output)
|
||||
print(f'Original Baseball resources exported: {args.output}/baseball.json')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -13,6 +13,7 @@ from ui import export_ui
|
||||
from gadget_resources import export_gadget_resources
|
||||
from gadget_followup_assets import export_meter
|
||||
from bubble_resources import export_bubble
|
||||
from baseball_resources import export_baseball
|
||||
from sound_bank import export_sound_bank
|
||||
|
||||
|
||||
@@ -84,6 +85,7 @@ def main():
|
||||
export_gadget_resources(Database(find_archive(args.original, 'screens')), args.output / 'gadgets')
|
||||
export_meter(args.original, args.output / 'invisible-meter')
|
||||
export_bubble(args.original,args.output/'bubble')
|
||||
export_baseball(args.original,args.output/'baseball')
|
||||
effects = export_sound_bank(args.original, args.output / 'effects')
|
||||
print(f"SoundEffects.omt: {len(effects['resources'])} original sound identities")
|
||||
for name in args.audio:
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Export original Scooter resource data; do not assign attachments or playback.
|
||||
|
||||
The two Scooter ASE morphs have 195 indexed positions, whereas scooter.omt's
|
||||
body has 98. Keep these samples unbound rather than inventing UVs or a base.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from ase import export_ase, read_ase
|
||||
from entities import resolve_asset
|
||||
from models import export_omt_model
|
||||
from omt import Database, FormatError, read_shape
|
||||
from png import read_png
|
||||
|
||||
SOURCES = {
|
||||
'omt/scooter.omt': '8d4ffdafee5fd819c5220ee4f608c901a5988fe6b8b13316e15618f5eec75e81',
|
||||
'ASE/jimstop.ASE': 'b294d090ac5c4ec449d845db6d837f2cbedf5f7b812f5b6ed2bb70f85246f1d0',
|
||||
'ASE/jimscooter.ASE': 'b27c8cb80811eb70e391fc061dab99c7d5f0b4d884c109b34c673a1815508299',
|
||||
'ASE/jimscooterstop.ASE': 'edcdcc879a28757994525f815c88cd6dd46dc788b69ba2f902323d6de48cb873',
|
||||
'ASE/godscooter.ASE': 'c18f1414ec2b397e0c8f8320f63830ab88630ea05a354bb99af34ce7fea79bd1',
|
||||
'ASE/godscooter2.ASE': 'fcf9ca5e8298efa7b4d551d9d09878c04f1f2647b6a30edfa2297617a7d63189',
|
||||
'png/jimycarl.png': '55ed165aaffe177cb62558a08d13fc3b2210da6e353065b108849d46df9dacb6',
|
||||
}
|
||||
|
||||
|
||||
def _json(path: Path, value):
|
||||
path.write_text(json.dumps(value, separators=(',', ':'), allow_nan=False)+'\n', encoding='utf-8')
|
||||
|
||||
|
||||
def export_scooter(original: Path, output: Path) -> dict:
|
||||
original, output = original.resolve(), output.resolve()
|
||||
if output.is_relative_to(original) or original.is_relative_to(output):
|
||||
raise ValueError('Output must be separate from the original installation')
|
||||
# Existing descendants are checked before any helper writes into them.
|
||||
if output.exists() and any(p.is_symlink() for p in output.rglob('*')):
|
||||
raise ValueError('Generated Scooter paths must not contain symlinks')
|
||||
paths = {name: resolve_asset(original, name) for name in SOURCES}
|
||||
for name, path in paths.items():
|
||||
if hashlib.sha256(path.read_bytes()).hexdigest() != SOURCES[name]:
|
||||
raise FormatError(f'Unexpected original Scooter source identity: {name}')
|
||||
database = Database(paths['omt/scooter.omt'])
|
||||
shapes = {}
|
||||
for identity, expected in ((0, ('goddard01', 98, 176)), (1, ('wheel', 32, 56))):
|
||||
entry = next(e for e in database.entries if e.type == '3DSh' and e.id == identity)
|
||||
shape = read_shape(database.payload(entry))
|
||||
if (entry.name, len(shape['vertices']), len(shape['polygons'])) != expected:
|
||||
raise FormatError('Unexpected original Scooter shape metadata')
|
||||
shapes[identity] = shape
|
||||
animations = {name: read_ase(path) for name, path in paths.items() if name.startswith('ASE/')}
|
||||
for name, animation in animations.items():
|
||||
expected_count = 195 if 'godscooter' in name else 426
|
||||
if len(animation['objects']) != 1 or len(animation['objects'][0]['samples']) != 2:
|
||||
raise FormatError('Unexpected original Scooter animation objects/samples')
|
||||
if any(len(s['vertices']) != expected_count for s in animation['objects'][0]['samples']):
|
||||
raise FormatError('Unexpected original Scooter morph vertex count')
|
||||
texture_path = resolve_asset(original, 'png/jimycarl.png')
|
||||
texture = read_png(texture_path)
|
||||
rgba = texture.pop('rgba')
|
||||
texture.update(source=texture_path.name, sourceSha256=hashlib.sha256(texture_path.read_bytes()).hexdigest(),
|
||||
rgbaSha256=hashlib.sha256(rgba).hexdigest(), path='../jimycarl.rgba')
|
||||
manifest = dict(schema=1, sources=SOURCES.copy(), shapes=[], animations=[], unboundMorphs=[],
|
||||
bindingPolicy='Resource-only export; caller owns original attachment, transforms and timing')
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
for identity in shapes:
|
||||
folder = f'shape_{identity}'
|
||||
details = export_omt_model(database, identity, output/folder)
|
||||
manifest['shapes'].append(dict(id=identity, path=folder+'/scene.json', **details))
|
||||
(output/'jimycarl.rgba').write_bytes(rgba)
|
||||
for stem in ('jimscooter', 'jimscooterstop'):
|
||||
animation = export_ase(paths[f'ASE/{stem}.ASE'], output/stem, paths['ASE/jimstop.ASE'])
|
||||
animation['texture'] = texture
|
||||
_json(output/stem/'animation.json', animation)
|
||||
manifest['animations'].append(dict(source=stem+'.ASE', path=stem+'/animation.json'))
|
||||
for stem in ('godscooter', 'godscooter2'):
|
||||
animation = animations[f'ASE/{stem}.ASE']
|
||||
filename = stem+'-unbound.json'
|
||||
_json(output/filename, animation)
|
||||
manifest['unboundMorphs'].append(dict(source=stem+'.ASE', path=filename,
|
||||
vertices=195, sourceTimes=[s['time'] for s in animation['objects'][0]['samples']],
|
||||
reason='No matching textured base recovered; OMT body 98 and existing Goddard base 222 differ'))
|
||||
_json(output/'scooter.json', manifest)
|
||||
return manifest
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
export_scooter(args.original, args.output)
|
||||
print(f'Original Scooter resources exported: {args.output}/scooter.json')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user