#!/usr/bin/env python3 """Guarded Grappler follow-camera/lifetime projection; never executes originals. Only the ordinary walking/air follow branches are modeled. Camera flags828/851, Bubble movement2, scene-entry snap and whole frame scheduling remain separate. """ from __future__ import annotations import argparse from dataclasses import dataclass, replace import hashlib import json from pathlib import Path import struct from checkpoint_script_state import EXE_SHA256, find_case, read_va from pe_inspect import PE from rocketship_motion_camera import add_axis, f32, rotate SPANS = ( ('equip',0x4297dd,0x429857,'8d8c915150a29692734293b0048429f77f8467e50ab4e5449e7110f9d3a060eb'), ('attach-camera',0x426d53,0x426da0,'8858a5eec86ee75575aafdfc6eadabc707432821a0db34cd3e6c663d21c423bf'), ('detach',0x429c10,0x429cf7,'aad9706ec19de0d162827fe957e91fb4a513423d6e6901de9a29e4c780f7df97'), ('cleanup',0x4287ac,0x42883b,'7f1a0574e1a04b1893e2599749616af049854408e1296a2f50e0510b6847d1e5'), ('ground-follow',0x439625,0x4398f2,'43ae070dd7f5b3de39cef33e9af25c2847a5e35bfa172dc479292e896ef14a88'), ('air-follow',0x439900,0x43a111,'895f27be2ad03f49230fe34e98753095285a61f52b4adbbb15f1dd7c868b2901'), ('air-eye-transform',0x43a5d0,0x43a750,'d903035a775b5f2436ea203bfa40a812335c7c75d038592ec766a374d78e47a0'), ('camera-ray',0x43b820,0x43b90f,'da79aee91ec334b7cba52edb6b3e0a016e6c553cace3a77a908f13c55af949ad'), ('camera-defaults',0x437740,0x43778e,'8a03dc8f9289f76b96be53a678e54729e345624fe98b6045e93236a303d3cb12'), ('action-guard',0x43aff0,0x43b0b6,'f439e7317ada3ffb0bc2a9dbfad19539e0faf6e97de463ebaa5b9825d27f7d82'), ('constructor-globals',0x422761,0x4227d9,'76d9d28d1a7d655cc48a435af2c77017e86c610a586356859a13e53ea33235df'), ) VTABLES = ((0x120, 0x43a5d0), (0x124, 0x438bc0), (0x128, 0x439900), (0x16c, 0x43b820), (0x170, 0x437740), (0x150, 0x43aff0), (0x204, 0x429c10)) CONSTANTS = ((0x4afce8, 'd', 1.9), (0x4a2ad0, 'd', .2), (0x4a0ce0, 'd', 1.2), (0x49d5ac, 'f', .75), (0x4a3138, 'f', 1.5), (0x48e5e8, 'f', 45.511112213134766)) def collect(original): pe = PE(find_case(Path(original), 'Neutron.exe')) if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256: raise ValueError('Unexpected original EXE identity') spans = [] for name, start, end, expected in SPANS: digest = hashlib.sha256(read_va(pe, start, end-start)).hexdigest() if digest != expected: raise ValueError('Changed source span '+name) spans.append(dict(name=name, va=hex(start), end=hex(end), file_offset=hex(pe.offset(start-pe.base)), sha256=digest)) for slot, expected in VTABLES: if struct.unpack('