Lock-on and targeting (executable)
Decoded from the Store build 1.3.25854.2
executable (our reading of the machine code; no
game data involved apart from the camera record
fields named below). Godot side:
godot/scripts/combat/lock_on.gd
(PdLockOn), used by player.gd.
Units 0.1 m, ticks 1/30 s, angles 15-bit (0x8000
= 360°). “C” is the character object (position
at C + 0x12e40, facing C + 0x12e68, camera yaw /
pitch C + 0x12e5c / + 0x12e60, pad held /
previous / pressed bits at C + 0x1425c / +
0x14260 / + 0x14264); “P” = C + 0x40 is its
combat part (health P + 0xc, four body records
from P + 0x40).
- Where the lock lives: the per-player camera object at C + 0x13f10 (init 0x1402529a0, tick 0x140252a20 called from the character tick at 0x14024f120). Fields: +0x4 lock button state, +0x8 “just switched on”, +0xc lock state (0 not tracking, 1/2/3 distance grades), +0x10 target index, +0x14 tracked this tick, +0x300 back pointer to C. It starts unlocked with index −1.
- The target table (global 0x1404bcb50, 32 pointers): every targetable body record of every character (and of bosses’ parts). The lock stores an index into it. A record’s +0x60 is its position, +0xb8 its owner (P), +0x14 / +0x1c must be non-zero to be targetable. Fill order (docs 11-10): the registration 0x14024d440, run at character set-up (0x14024f4b7; also 0x14015d0e0 and the boss set-up 0x140147fa8), gives each of the character’s four body records (P + 0x40 + k × 0xC0, those in use) the lowest free index, stores it in the record (+0x20, the id the network fire message carries) and sets the entry count 0x1404bc5d0 to the highest used index + 1. The table is cleared at battle set-up (0x14012823c). Characters are set up in slot order, so with one body record each the order is player slot 0, 1, 2, 3 (M: the set-up order was not stepped through; a character with several body records takes consecutive indices).
- Valid target (0x1402543e0): the entry exists and is flagged targetable; its owner is active (P + 0 ≠ 0), is not the locking player, has health > 0, does not have status slot 8 active, and is on another team unless option byte 0x14052dfb9 is set. While the locking player has status slot 9 active, only the entry that status names is valid. There is no range, angle or line-of-sight test.
- Picking (0x140252f70): the first valid index at or after a start index, wrapping around the 32 entries. Option byte 0x14052dfb8 = 0 (the default) uses it for everything: with no index held the lock picks from 0 every tick, locked or not; a release moves the held index on to a valid one (so a KO’d target is dropped there); the switch press (pad bit 0x400, edge: held now, not held the tick before) picks from index + 1. That is the next body in table order, not the next-nearest. With 0x14052dfb8 ≠ 0 the switch instead sorts the valid entries by a float key per entry (camera object + 0x90 + i·0x14: the distance from the player’s body record to the entry, written each tick by the target projection, “Play camera” tick step 9) and takes the one after the current target, the first on a fresh lock (0x140252ff0; the sort direction was not read).
- Lock button (pad bit 0x800), by option byte 0x14052dfb7: 0 (the default) toggles on the pressed edge: when the lock tracked something last tick it releases, else it switches on and re-picks from the held index; 1 locks while held; 2 locks while held and stays on while the target is valid. All three option bytes are 0 on a fresh save (reset at 0x1401cb070). Bit 0x800 is the right trigger and 0x400 the left trigger (docs 11-10, “Pad input: buttons to pad bits”).
- Tick (0x1402531d0), only
while the match phase global 0x1404bc950 is 6
(the fight): if the lock is on and the held
index is valid, the state is graded by the 3-D
distance from the player’s body record to the
target’s: 1 within 80 units (8 m), 2
within 300 units (30 m), 3 beyond, and
the camera turns toward the target (yaw and
pitch steps from the
setup/configdata.datcamera record: at most +0x8 degrees of yaw and +0xc of pitch per tick, pitch clamped by +0x20 / +0x24 after adding the rest-pitch offset +0x2c; the camera run’s “Play camera” notes cover the framing). If the held target is not valid the lock stays on but tracks nothing (state 0) until a press: it does not move on by itself. When the lock is off the state is 0 and the camera pitch returns to the record’s rest pitch. - What a cast gets (0x140258180, at cast start): the target pointer (C + 0x70, the skill objects’ +0x48) = table[index] when the state is not 0. A lunge skill (0x140167910: skill set 0x52 = 0 and behavior 0x7A = 3, 12, 13 or 14, the melee kinds) gets it only at state 1 (within 80 units), else none. The network fire message carries the target as the record’s id byte (+0x20), 0xff for none (0x1402632b0).
- Aim of a cast (0x140258382..0x1402585a4; cast state S, yaw at S + 0x88, pitch at S + 0x8c, “aimed at a target” flag S + 0x84). With a target, for a set-0 skill other than behavior 8, 16, or 4 with its first parameter (0x7C) = 2: yaw = the direction to the target, pitch from the height difference (caster y + C + 0x12e98 against the target’s y), flag 1. Otherwise the flag is 0 and, for a character with a camera (C + 0x30 ≠ 0) and a skill of set 0 or 2 outside those behaviors: yaw = the camera yaw (C + 0x12e5c) and pitch = the camera’s aim pitch C + 0x12e64 (0 for set 2); every other case takes the body’s facing and pitch 0. During the cast the facing turns toward the cast yaw by the character’s turn step per tick (0x14025bd53, 0x14025c0a9), so a player without a target turns to where the camera looks and fires there. The aim pitch is written by the camera tick (0x140252e07..0x140252f0c): unlocked, the camera pitch minus the camera record’s rest pitch (level when the camera is at rest); locked, the pitch from the caster to the target, clamped by the record’s first two angles. The cast pitch (S + 0x8c) reaches the shot through the caster’s body matrix: see “Vertical aim of a cast” (docs 11-10 vaim; this said “not followed”). The cast-start message (0x14025ca20) carries the yaw only; the fire message carries the whole spawn matrix.
- Homing: a skill object keeps that pointer (+0x48) and drops it for good when the target’s owner has health ≤ 0, at spawn (0x140263a47) and every tick (0x1402639d3). The shots’ steering (“Straight behavior” and the other kinds) aims at the pointed record.
- Locked movement (0x14025b6fc, the run start; per-tick turn at 0x14025ba2c): while the lock tracks, the move direction is the camera yaw plus the stick angle, and its angle relative to the facing picks the run: within 45° forward, 45°–135° a sideways run with the facing set 90° back toward the camera, beyond 135° a back-run with the facing reversed (exactly 180°: one of the two back-runs at random). Each tick the facing then turns onto the camera yaw by at most the character’s turn step (a per-character table at 0x1404c0240, row 0xa0 bytes). So the body keeps facing along the camera, and the camera faces the target.
- The CPU’s lock is driven by
its AI instead of the buttons: the AI controller
(0x14017b220, running the scripts under
com/ai) writes the same state and index (C + 0x13f1c / + 0x13f20) from the player slot its script chose (script built-in 0x14020e650), index −1 when that player is gone or KO’d, with the same 80 / 300 grades.