Repository navigation
119 worked example the flying wreckage
Update (document 170): an
FWallpiece has priority 0, no callbacks and a descriptor with no shape, so nothing meets it and it changes nothing in the game. Since stage S5.6 the port's pieces rollFxRandand are out of the deterministic simulation.
Question: document 118 found that a wreck that lands hard (or is shot to below -40 hit points) calls FUN_0042b4e0, which makes FWall objects (class 3, table 0x44abb0) from the body's parts. What are they, which parts make them, and what do they do? (Issue #81, a vertical-slice item.)
FUN_0042b4e0(pos, team, row, descriptor, heading, pitch, callback) walks the body descriptor's parts. For each part:
cls = (part.flags & 0x300) >> 8; // 0, 1, 2 or 3
if (cls != 0) {
record = row[cls - 1]; // 0 = no piece
if (record) { piece = FUN_0042c290(0x44abb0, team, x, y, z, record); ... }
}row is 0x44aa90 when the wreck is more than 10 units up and 0x44aad0 below. Both rows are { record, record, 0 }: class 1 and 2 make a piece, class 3 makes none (so those parts stay in the decal). Reading the flags of every body descriptor:
| Body | Parts with flags & 0x300
|
|---|---|
| Tank (14), Jeep (11), MSV (14) | none (all 0x8 or 0x0) |
| Heli (12) | class 1 (0x108): cels 564, 544, 534, 569; class 2 (0x208): cels 539, 574, 549; class 3 (0x308, no piece): 524 (fuselage), 529 x2 (canopy), 554, 559 |
So only the Heli shatters: seven of its twelve body parts fly off; the fuselage, the canopy panes and the tail boom stay on the ground. That is the "shatters apart" of document 87's footage note.
The records (0x44a850 class 1 and 0x44a864 class 2 above 10 units; 0x44a890, 0x44a8a4 below) differ only in speed: rate 0x2888 = 0.158 progress units a tick above, 0x5111 = 0.316 below; every record is 19 units long (about 115 ticks above, 58 ticks below), fades from unit 14, and class 1 ends with a burn-out animation that class 2 lacks.
FUN_0042a610 builds the piece from the part: the part's four corners (turned by the wreck's heading when it is not 0), their centroid, the corners moved to be about the centroid, and the centroid's normalised direction (FUN_0042a570) stored as the piece's flight direction. The piece is created at the part's centroid. The tick FUN_0042b290 adds the record's rate to the piece's progress (the first tick sets it to 1.0 instead; the creation flag 0x40), ends the piece at the record's duration, and runs each op of the record's list (+0x10, 8 dwords each: op, start, end, ..., four parameters) whose start <= floor(progress) <= end, through the table 0x44ab50:
| Index | Function | Op | Parameters |
|---|---|---|---|
| 0 | 0x42a920 |
end | destroy when progress reaches the duration |
| 1 | 0x42a950 |
tint | shade the piece's palette toward entry [5] of cel -[4] over the op's range |
| 2 | 0x42aad0 |
speed | ease the outward speed to a target at a rate, optionally from an initial value; moves along the direction (height too until gravity runs) |
| 3, 4 |
0x42abc0, 0x42aca0
|
yaw and roll spin | a random target spin (the sum of two draws, either sign), the spin easing to it; angles in 22-bit units |
| 5 | 0x42ad80 |
frames | swap the piece's sprite to cel + progress - start
|
| 6 | 0x42aeb0 |
gravity | on its first run ([4] = 1) start the fall from direction.z * speed; then 0x51e a tick down to the fall limit |
| 7 | 0x42af60 |
sink | end below a given height (not used by these records) |
| 8 | 0x42afa0 |
drag | slow drift words that nothing ever sets (a no-op) |
| 9 | 0x42b030 |
bounce | not used by these records |
| 10 | 0x42b0e0 |
land | at or below the ground: play the surface's effect record and end |
Record 0x44a850 (tools/data/debris.json): land (1-100), speed to 0.2 a tick (1-3, then again 4-100), gravity (2-100, launching), yaw and roll spin (3-100), tint (3-10), drag (1-100), frames (11-18: cels 1917-1924). So a piece drifts outward at 0.2 units a tick, starts to fall at unit 2, tumbles on both axes at up to about 14 degrees a tick, darkens, and if it has not landed by unit 11 shows eight burn-out frames (cels 1917-1924, which the registry still calls pickup.gem_yellow.* and prop.debris_faint.*: issue #49). On landing the effect depends on the surface: the water test of document 62 picks a splash record, tile art 0x49-0x53 the pavement puffs 0x444968, anything else the land puff 0x444740; each plays its sound.
The draw callback FUN_0042a7b0 rotates the centred corners by the piece's heading (+0x4c, the yaw spin) and its roll (+0x68, through the table 0x481710) and fades the piece from the record's fade unit.
DebrisPiece (game/debris_piece.gd) runs a record's script; the ops are data (world/debris.json, from tools/data/debris.json by both importers). One op:
"gravity":
if _slots[i] == null:
_slots[i] = 0.0
if bool(op.get("launch", false)):
vz = dir.z * speed
airborne = true
vz = maxf(vz - GRAVITY, -FALL_LIMIT)
d.z += vz
moved = trueMatchController._on_wreck_debris is FUN_0042b4e0's loop: it takes the wreck's Wreck.debris signal, the vehicle definition's render parts and their flags, and makes a piece per marked part.
var cls := (int(part.get("flags", 0)) >> 8) & 3
var addr := String(row.get(str(cls), ""))
...
p.position = w.position + Vector2(centre.x, centre.z)
p.z = w.z + centre.y
p.dir = centre.normalized()
p.sprite_id = pack.team_variant(part["sprite_ids"], colour)DebrisPieceView3D draws the quad (yaw about the vertical, roll about the lateral axis, the burn-out frames, a darkening tint, the fade in 16 levels). tests/debris_check.gd runs a piece through its script and a wreck's landing through a match; tools/tests/wreck_fall_check.gd checks the real pack's records and that exactly seven Heli parts are marked.
Port choices, marked in the code and the data: the tint shades toward a fixed dark colour (the palette entry is not read); the roll axis; the water record is the small splash (the choice depends on a length the decompiler hides).
- The piece's collision test while it moves (
FUN_0042c830) and the 60-tick removal of a piece that is not on screen. -
Who callsanswered in document 121: the Drone's end handler, a destroyed turret tile, and op 17 of a tile's collapse script (buildings, bushes, crates, the crushed bush). The Heli is the only vehicle whose body breaks.FUN_0042b4e0with the other rows of the piece tables: - Cels 527/528 and 532/533 of issue #27 are not these pieces' art (the pieces use the body part's own cel and the burn-out cels).
Return Fire, rebuilt
Elsewhere