Implement original gadget panel and playable shrink ray

This commit is contained in:
UnixNight committed 2026-10-27 12:18:45 -04:00
1 parent 0272f7bef7
commit 7b5230ceb8
57 files changed
+3545 -48

No files matched your search

+184
View File
@@ -0,0 +1,184 @@
#!/usr/bin/env python3
"""Read-only, byte-guarded 3SOL visual/shrink source contract.
REA findings are recorded in docs/gameplay/shrink-targets.md. This utility
rechecks their byte/asset provenance; it neither executes the game nor recovers
the full soldier AI or collision system. Addresses use preferred image bases.
"""
from __future__ import annotations
import argparse
import hashlib
import json
from pathlib import Path
import struct
import sys
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
sys.path.insert(0, str(HERE.parent / 'extractors'))
sys.path.insert(0, str(HERE.parent / 'levels'))
from checkpoint_script_state import EXE_SHA256, find_case, read_va
from pe_inspect import PE
from ase import read_ase
import gam
DLL_SHA256 = '3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943'
BODIES = (
('Neutron.exe', 'enemy_mode_setter', 0x4089B0, 0x408B93, '0f8a8d6894ff1d246abbf5d8493330c4c9d5508bb5f027deaff0c38dcc969695'),
('Neutron.exe', 'shared_yokian_constructor', 0x44A730, 0x44A97C, '4654b058e18f96c88a081878d432cd11e94ba3165529be6486b5e79d0dd321ed'),
('Neutron.exe', 'soldier_constructor', 0x44BEE0, 0x44C028, 'e4ad6ea59b4d5f4e0c30b08f0161ec677da08b9f3a06efe28f4dd9009c472ddc'),
('Neutron.exe', 'soldier_model_loader', 0x44C0B0, 0x44C1BB, '538a3dbf346547fd7ddfea85a8348acd91ddcb2006f2d9ed1ede594f9b9a367d'),
('Neutron.exe', 'shared_yokian_update_range', 0x44AA00, 0x44AF9B, 'bcc710da864a6954cfa2f61ca39a50aff2244c0965ee28882a62dd942309f8c2'),
('Neutron.exe', 'game_animation_selector', 0x40DA30, 0x40DAAD, 'f5c8baa1dd35b9920da657dbefcdd7bf3e927fcc764ea395bb50269f49dd4738'),
('OMT2.dll', 'engine_sequence_selector', 0x100209F0, 0x10020A9A, 'c430ff3c7036e6415f167579cab749db5811eabc296fbcee5e91bbf43f72173c'),
('OMT2.dll', 'engine_next_frame', 0x10021000, 0x100210B8, '4d39ade2bd9cd9456301146096e493a0b9dcec49e00e4e8fd8d94ecbc86eff72'),
)
SITES = (
('Neutron.exe', 'mode_setter_previous_current_fields', 0x4089E5, '8b8ec80600008dbe60040000505768dccb4e00898ecc0600008986c8060000'),
('Neutron.exe', 'mode5_no_additional_dispatch', 0x408BA8, '8e8b4000'),
('Neutron.exe', 'authored_aistate_property', 0x407F67, '8d867c0800006a06506890ca4e008bceff92fc030000'),
('Neutron.exe', 'yokian_initial_mode_two', 0x44A7D3, 'b802000000'),
('Neutron.exe', 'yokian_current_and_authored_mode', 0x44A7F7, '8986c806000089863c090000'),
('Neutron.exe', 'postload_restores_authored_mode', 0x409503, '8b96080600008d8e40ffffff89967c0800008b96080600008b0152ff9024010000'),
('Neutron.exe', 'capture_authored_reset_mode', 0x409460, '8b817c0800008981080600008b11ffa20c040000'),
('Neutron.exe', 'soldier_calls_yokian_constructor', 0x44BF32, 'e8f9e7ffff'),
('Neutron.exe', 'soldier_class_fourcc', 0x44BFF5, '684c4f5333'),
('Neutron.exe', 'walk_asset', 0x44C0C3, '6884194f00'),
('Neutron.exe', 'walk_action', 0x44C0C8, '6808d84e00'),
('Neutron.exe', 'shrink_asset', 0x44C0DC, '6874194f00'),
('Neutron.exe', 'shrink_action', 0x44C0E1, '685ce14e00'),
('Neutron.exe', 'talk_asset', 0x44C0F0, '6864194f00'),
('Neutron.exe', 'talk_action', 0x44C0F5, '68f0d74e00'),
('Neutron.exe', 'stop_asset', 0x44C104, '6864194f00'),
('Neutron.exe', 'stop_action', 0x44C109, '68f4c94e00'),
('Neutron.exe', 'vr_range_low', 0x44C121, '3d31305256'),
('Neutron.exe', 'vr_range_high', 0x44C128, '3d38305256'),
('Neutron.exe', 'vr_texture_0', 0x44C133, '6850194f00'),
('Neutron.exe', 'vr_texture_1', 0x44C144, '6850194f00'),
('Neutron.exe', 'regular_texture_0', 0x44C14F, '6844194f00'),
('Neutron.exe', 'regular_texture_1', 0x44C160, '6834194f00'),
('Neutron.exe', 'initial_walk', 0x44C184, '6854ca4e00'),
('Neutron.exe', 'body_radius_90', 0x44C19D, '680000b442'),
('Neutron.exe', 'body_radius_setter', 0x44C1A4, 'ff9010010000'),
('Neutron.exe', 'body_factor_1', 0x44C1AC, '680000803f'),
('Neutron.exe', 'body_factor_setter', 0x44C1B3, 'ff9200010000'),
('Neutron.exe', 'soldier_calls_yokian_update', 0x44C1C9, 'e832e8ffff'),
('Neutron.exe', 'initial_shrunk_flag_false', 0x44A905, '889e70090000'),
('Neutron.exe', 'timer_skip_unless_positive', 0x44AE6F, '0f85a4000000'),
('Neutron.exe', 'timer_subtract_delta', 0x44AE75, 'd986b4080000d8642468d996b4080000'),
('Neutron.exe', 'expiry_skip_unless_negative', 0x44AE90, '0f8483000000'),
('Neutron.exe', 'expiry_zero_timer', 0x44AE96, '899eb4080000'),
('Neutron.exe', 'expiry_clear_shrunk', 0x44AE9C, '889eb0080000'),
('Neutron.exe', 'expiry_saved_mode', 0x44AEA8, '8b8e7c080000'),
('Neutron.exe', 'expiry_mode_callback', 0x44AEBD, 'ff9024010000'),
('Neutron.exe', 'expiry_walk', 0x44AEC6, '6854ca4e00'),
('Neutron.exe', 'engine_sequence_call', 0x40DA61, 'ff5210'),
('Neutron.exe', 'game_copy_loop_flag', 0x40DA64, '889fad000000'),
('OMT2.dll', 'engine_restart_or_preserve_ordinal', 0x10020A3A, '8a44241484c07536'),
('OMT2.dll', 'engine_loop_gate', 0x10021079, '8a591d84db7434'),
('OMT2.dll', 'engine_wrap_first_frame', 0x10021080, '8b12'),
('OMT2.dll', 'engine_hold_current_frame', 0x100210B4, '5f5e5bc3'),
)
VTABLES = (
('soldier_complete_mode_setter', 0x4C1E64, 0x124, 0x4089B0),
('soldier_complete_load', 0x4C1E64, 0x10C, 0x44C0B0),
('soldier_complete_select_action', 0x4C1E64, 0xE0, 0x40DD90),
('soldier_complete_select_sequence', 0x4C1E64, 0xE4, 0x40DA30),
('soldier_interface_radius_set', 0x4C19C4, 0x110, 0x471240),
('soldier_interface_factor_set', 0x4C19C4, 0x100, 0x4711E0),
('soldier_interface_update', 0x4C19C4, 0x3C4, 0x44C1C0),
)
STRINGS = {
0x4ECA90: 'AIState',
0x4F1984: 'soldwalk.ase', 0x4F1974: 'soldshrink.ASE',
0x4F1964: 'soldatak.ASE', 0x4ED808: 'HIWALK', 0x4EE15C: 'HISHRINK',
0x4ED7F0: 'HITALK', 0x4EC9F4: 'HISTOP', 0x4F1950: 'vryoksoldier.png',
0x4F1944: 'yoksold.png', 0x4F1934: 'yoksoldtalk.png', 0x4ECA54: 'WALK',
}
ASSETS = {
'soldwalk.ASE': '98b16d95899a9d6f201d48b8f46183314c9570def076c8a038e0f706eda55a19',
'soldshrink.ASE': 'bd79795a878557cd979a97719653aa669130ad778e922f0b78aa2160eddeb59f',
'soldatak.ASE': 'b759a087dc5ab6621e8b9745b5e62bf24b2f131b6bd0e509f2f5392d94d496a1',
}
def timer_step(timer: float, delta: float, shrunk: bool = True) -> tuple[float, bool, bool]:
"""Bounded control-flow projection, not original x87/runtime emulation.
Deliberately retains the source's equality edge case. The caller supplies
original nonnegative game time; this does not model unrelated AI updates.
"""
if timer > 0:
timer -= delta
if timer < 0:
return 0, False, True
return timer, shrunk, False
def collect(root: Path) -> dict:
modules = {name: PE(find_case(root, name)) for name in ('Neutron.exe', 'OMT2.dll')}
identities = {name: hashlib.sha256(pe.data).hexdigest() for name, pe in modules.items()}
bodies, sites, vtables = [], [], []
for module, name, start, end, expected in BODIES:
pe = modules[module]
actual = hashlib.sha256(read_va(pe, start, end-start)).hexdigest()
bodies.append(dict(module=module, name=name, va=hex(start), end_exclusive=hex(end),
file_offset=hex(pe.offset(start-pe.base)), sha256=actual, matches=actual == expected))
for module, name, va, expected in SITES:
pe = modules[module]
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
sites.append(dict(module=module, name=name, va=hex(va),
file_offset=hex(pe.offset(va-pe.base)), bytes=actual, matches=actual == expected))
pe = modules['Neutron.exe']
for name, table, slot, expected in VTABLES:
target = struct.unpack('<I', read_va(pe, table+slot, 4))[0]
vtables.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(target),
file_offset=hex(pe.offset(table+slot-pe.base)), matches=target == expected))
strings = []
for va, expected in STRINGS.items():
actual = pe.cstr(pe.offset(va-pe.base))
strings.append(dict(va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
value=actual, matches=actual == expected))
clips = []
for name, expected in ASSETS.items():
path = find_case(root, 'ASE/'+name)
asset = read_ase(path)
samples = [sample for obj in asset['objects'] for sample in obj['samples']]
clips.append(dict(name=path.name, sha256=asset['sha256'], matches=asset['sha256'] == expected,
frames_per_second=asset['framesPerSecond'], ticks_per_frame=asset['ticksPerFrame'],
sample_count=len(samples), vertex_counts=[len(s['vertices']) for s in samples],
face_counts=[len(s['faces']) for s in samples], times=[s['time'] for s in samples],
y_bounds=[[min(v[1] for v in s['vertices']), max(v[1] for v in s['vertices'])] for s in samples]))
textures = []
for name in ('vryoksoldier.png', 'yoksold.png', 'yoksoldtalk.png'):
path = find_case(root, 'png/'+name)
textures.append(dict(name=path.name, sha256=hashlib.sha256(path.read_bytes()).hexdigest()))
level_path = find_case(root, 'gam/VR04.gam')
level_data = level_path.read_bytes()
targets = [dict(kind=e.kind, file_offset=hex(e.offset), fields=e.values())
for e in gam.parse(level_data).entities if e.kind == '3SOL']
return dict(scope='Static source and original asset data only; no original runtime execution.',
modules=identities, known_binary=identities == {'Neutron.exe': EXE_SHA256, 'OMT2.dll': DLL_SHA256},
bodies=bodies, sites=sites, vtables=vtables, strings=strings, clips=clips, textures=textures,
radius=90, factor=1,
modes=dict(current_complete='0x6c8', previous_complete='0x6cc',
authored_complete='0x93c', authored_interface='0x87c',
authored_property='AIState', initial_authored=2,
shrink_snapshots_authored=False, expiry_restores='authored'),
vr04=dict(sha256=hashlib.sha256(level_data).hexdigest(), targets=targets))
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('original', type=Path)
args = parser.parse_args()
result = collect(args.original)
print(json.dumps(result, indent=2, allow_nan=False))
guards = result['bodies'] + result['sites'] + result['vtables'] + result['strings'] + result['clips']
if not result['known_binary'] or not all(item['matches'] for item in guards):
raise SystemExit(1)
if __name__ == '__main__':
main()