Vertical aim of a cast
Decoded from the Store build 1.3.25854.2 executable (our reading of the machine code). Completes “Aim of a cast” in “Lock-on and targeting”. Angles are the engine’s integer angle units (32768 per turn, 5215.19 per radian); a positive pitch points down. Confidence is M throughout unless marked (read in the code, not yet checked against footage).
Where the stored pitch goes. The cast state S is part of the character object (S = C + 0x12f00), so the cast pitch S + 0x8c is C + 0x12f8c and the cast yaw S + 0x88 is C + 0x12f88. The pitch has exactly one reader: the body matrix build (0x1402514c0, run from the character tick at 0x14024f130 and from 0x14024e4e8). Each tick it makes the matrix at C + 0x12dc0 as
position = (x, feet y + body centre height, z) (C + 0x12e40.., centre height C + 0x12e98,
character record field 0x12)
rotation = turn about the vertical by the facing (C + 0x12e68, routine 0x1402906e0),
then tilt about the body's side axis by the cast pitch (C + 0x12f8c, 0x1402905c0)
and that matrix is what the cast release hands to the skill-object spawn (0x14025c8f8 → 0x1402626d0 → 0x140263a00; also the instant release at 0x140258638). So:
- the shot’s launch frame is the caster’s facing tilted by the cast pitch; its forward axis is the launch direction of every kind that flies along its matrix;
- the horizontal part is the facing at the release tick, not the cast yaw itself: the facing turns onto the cast yaw by the turn step per tick during the cast, so a cast that releases before the turn is finished fires along the facing reached so far;
- the pitch is written only at cast start (and zeroed at set-up, 0x140256bc9), so the matrix keeps the last cast’s tilt until the next cast. Whether the drawn model uses this matrix (a visible lean) was not followed.
Start point. The spawn replaces the matrix position: when the cast carries a fire-node id (S + 0xc20, ≠ −1) it is the world position of that model node (lookup 0x14018a310; with several matching nodes the shot index modulo their count picks one, 0x140262b30..); else the matrix position stays (the body centre). The spawn copies the matrix to the object (+0x80, position also at +0x68) and stores its heading and pitch as integers (+0xc0 = atan2(forward x, forward z), +0xc4 = atan2(forward y, horizontal length), 0x140263aec..b70). The integer pitch +0xc4 has no reader in the skill code; +0xc0 is read by moving and kinesis.
The pitch value (cast start, 0x140258407..0x14025857d):
- Locked target (flag S + 0x84 = 1; set 0 other than mine, hole_all, and auto with first parameter 2): pitch = atan2((caster feet y + caster centre height) − target point y, horizontal distance caster → target point); yaw = atan2(Δx, Δz). The target point is the locked body record’s position (record + 0x60..0x68), the same point the shots steer at. No clamp, no lead, no gravity term: a straight line from the caster’s centre to that point at cast start. The record position is the torso root node’s world position (animated; about 11–12 u over the feet when standing), not the body centre: “Body point, sight point and aim point” (docs 11-12).
- No target, a character with a camera, set 0 outside those kinds: pitch = the camera’s aim pitch (C + 0x12e64) = camera pitch − the camera record’s rest pitch (unlocked), see “Play camera” tick step 8. The cast does not clamp it again, so its range is the camera’s own pitch limits shifted by the rest pitch (record 0: limits ±70°, rest 9° down). While a lock tracks, the aim pitch is the body-to-target angle clamped to the limits, but then the cast takes the locked branch above anyway. The aim pitch is frozen during the cast states.
- Set 2 (defenses) without a target, and every other case: pitch 0.
Per kind: what the launch frame does (inits in “Skill casting leftovers”):
| kind | vertical aim |
|---|---|
| straight (0) | copies the spawn matrix whole (0x140264576): flies along its forward axis, pitch included. With a target it then steers in 3-D toward the target point (the capped turn of “Straight behavior”, only inside the 60° cone), so a height difference is covered by the launch pitch plus homing; no lead |
| ricochet (17) | copies the spawn matrix, then applies its record’s spread angles (0x14026af73..b105): pitch included |
| multishot (6) | with a target the base direction is the 3-D direction from the start point to the target point; without one the spawn matrix’s forward axis (pitch included); then the record’s spread angles (0x14026676b..a18) |
| parabola (1) | with a target: aims at the target point and rebuilds its frame from that direction; the vertical speed comes from the arc solve (g = 8H / T², initial vertical speed g·T/2 − Δy / T, “Parabola”), so the pitch is not used. Without a target the landing point comes from a routine not followed (0x14026e410) and only the heading of the spawn matrix is kept (+0x1d0) |
| fall (2), fast_rain (7), rain (20), hole (15, 16) | positioned from the target / caster frame, not from the launch pitch (fall and rain build their own frame; rain copies the spawn matrix for its volley origin only) |
| crawl (5) | copies the spawn matrix, then drops to the floor (floor query 0x14013ef00 at init): floor-hugging; what remains of the pitch was not followed (L) |
| moving (10), kinesis (11) | read the integer heading +0xc0 only: pitch ignored |
| mine (8), burst (9) | position only (and mines never aim: pitch 0 by the cast rule) |
| melee (13), blade (12), pursuit (3, 14) | carried by the attack bone / the caster: no aim at all |
| auto (4) | no projectile |
Network. The fire message (type 3) carries the full spawn matrix (f32[16] at 0x10), so the remote shot gets the same tilted frame; nothing else about the pitch is sent.
Camera pitch while aiming (already in “Play camera”): the manual pitch, the lock-on turn and the aim pitch all clamp to the camera record’s two limits (±70° in record 0); while the lock tracks, the camera pitch itself is driven toward the target angle plus the record’s lock offset (0x2C) by at most the pitch step per tick. There is no separate “aiming” mode: the limits are the same with and without a lock.
Implementation notes for the rebuild
- Keep a per-character cast pitch (set at cast start by the rule above) and build the launch frame as yaw(facing at release) · pitch(cast pitch); spawn straight, ricochet and untargeted multishot shots along its forward axis from the fire node (or the body centre when the cast has no fire node).
- Locked: pitch = atan2(caster centre y − target point y, horizontal distance), unclamped; truncate to the 32768-per-turn integer as the game does (also the yaw).
- Unlocked player: pitch = camera pitch − rest pitch, as the camera tick already computes for C + 0x12e64; bots and defenses: 0.
- Do not snap the body to the cast yaw: the shot leaves along the facing reached at release.
- Parabola, moving, kinesis, mine, burst, melee kinds, rain kinds: do not apply the pitch.
- Send the launch frame with the fire event in netplay (the game sends the matrix).
- Built (vaim 11-10):
Player.cast_pitch/DataSkill.launch_dir(straight shots; our fire shot), the aim pitch in PlayerInput for a remote body; the target point is the body centre (INFERRED), the start point and the at-once body turn are still ours (PLACEHOLDERS.md). - To check against footage before calling it H: an unlocked straight shot with the camera pitched up/down should leave at the camera’s pitch minus 9°; a locked shot at a target on a higher floor should leave already tilted at it.