Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 52 additions & 15 deletions specs/weapons.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,47 @@ For each cell, in *z* then *x* order, for the cell's `unit` and then its `unit2`

For the cell's features, when the weapon does not have bit 14 of `flags` set: a cell whose `feature`
is 0xfffe is first replaced by its origin cell, read with `los_radar.GetMapCell` at (*x* − its
`offsetX`, *z* − its `offsetY`); a `feature` of 0xfffb or above is skipped. The distance from the
`offsetX`, *z* − its `offsetY`); a `feature` of 0xfffb or above is skipped, tested on the cell that results
from that replacement (so an origin cell whose own `feature` is 0xfffb or above is skipped). A `feature`
below 0xfffb is an index below `Game.featureCount` in every valid block, and an origin cell that does
not exist is a case no valid block has: both are outside the contract, and no recording holds
either. The distance from the
centre to the feature is, when the visited cell's `flags` bit 0 is set, the length of the centre minus
`Game.spots[cell.spot].pos`; otherwise `features.GetFootprintCentre` of the visited cell's coordinates
and the feature, and the length of the gap to the centre it writes. A distance below the radius adds
the origin cell to the list (once) and publishes the features' DAMAGE (kind 34) with the origin cell's
*x* and *z* and the weapon's index in `Game.weapons`.

When the weapon has `interceptor` set, every projectile in the table that has its `dead` bit clear and
is not this weapon, and whose squared distance from its position to the centre (each difference taken in
signed 64 bits, squared, the high 32 bits summed) is below `areaOfEffect²`, is detonated with no unit,
and `network.SendProjectileDetonated` is called twice: with the attacker and that projectile, then with
the attacker and this weapon. The sweep has no limit on how deep it nests: a detonated interceptor
projectile whose own detonation reaches the area damage sweeps in turn, to any depth.
is not the projectile being detonated, and whose squared distance from its position to the centre (each
difference taken as a signed 32-bit value that wraps, squared in signed 64 bits, the high 32 bits of
each square summed as signed 32-bit numbers) is below `areaOfEffect²` (the 16-bit `areaOfEffect` squared as a signed 32-bit product, so a
value of 46341 or more squares to a negative number), is detonated with no unit, and
`network.SendProjectileDetonated` is called twice: with the attacker and that projectile, then with the
attacker and the projectile being detonated (the one whose sweep this is). A detonation that an
AREA_DAMAGE or DETONATE event starts has no projectile of the table to pass: the call's second
argument is the event's own record, which is no block address, so a module passes 0 there (the call
acts only in a network game, and no recording holds one). A detonated interceptor projectile whose own detonation reaches the area
damage sweeps in turn, inside the sweep that detonated it. The two
announcements of a projectile follow everything its detonation does, the sweeps nested in it included:
in `ai-antinuke-pair` at tick 5926, interceptor projectile 3 (attacker `Unit#252`) detonates projectile
4, whose own sweep detonates projectile 5, and the calls come in the order (`Unit#253`, 5), (`Unit#253`,
4), (`Unit#252`, 4), (`Unit#252`, 3).

A projectile whose weapon does not have `noExplode` set has its `dead` bit set by its detonation before
its area damage runs (step 2 of "A detonation"), so no later sweep detonates it again, and a chain of
such projectiles has at most as many levels as the table has projectiles (300). A projectile whose
weapon has `noExplode` set keeps its `dead` bit clear, unless step 3 of "A detonation" ends its
detonation (which sets the bit and runs no area damage), so each later sweep that reaches one whose
detonation ran the area damage detonates it again, and a chain through one can have more levels than
the table has entries. Two interceptor projectiles, of the same weapon or of two, that are both
`noExplode` and in each other's reach (directly, or through the sweeps of others) detonate each other without end:
the reference has no result for that cycle, and it is outside the contract. So is a chain of more
than 300 levels, which only a `noExplode` interceptor can make (no weapon of the game's data is both),
and no recording or vector holds one. The contract is every chain of up to 300 levels, which the
sweep detonates to its end, in the depth-first order above. The work a module keeps for the nested
sweeps outside its stack is empty when the outermost sweep starts (a sweep started while none runs)
and when it ends (`docs/module-abi.md`, section 12).

Finally, when the weapon's attacker is not null, HIT is published on it with the enemy and then the
friendly total.
Expand Down Expand Up @@ -458,10 +486,12 @@ Given a projectile *p* and its weapon, at its position:
7. Features: *cx* = the whole *x* ÷ 16 and *cz* = the whole *z* ÷ 16, both as signed 16-bit. The cell's
`feature` *f* is resolved: *f* below 0xfffb is `Game.features[f]` when *f* is below
`Game.featureCount`, else none; 0xfffe means the cell's origin (the cell at `offsetX` and `offsetY`
back, whose feature is used), and any other value of 0xfffb and above none. When a feature remains and
its `height` plus the cell's `low` is above the whole *y*: when the projectile's `cellX` and `cellZ`
already equal *cx* and *cz* the feature is dropped (the projectile already hit this cell), else they
become *cx* and *cz*. A surviving feature detonates *p* with no unit and the rule ends.
back, whose feature is used), and any other value of 0xfffb and above none. A feature whose `height`
plus the cell's `low` is not above the whole *y* is dropped, and a feature that is above it is dropped
too when the projectile's `cellX` and `cellZ` already equal *cx* and *cz* (the projectile already hit
this cell); otherwise `cellX` and `cellZ` become *cx* and *cz*, and that feature survives (`cellX` and
`cellZ` change only in this case). A surviving feature detonates *p* with no unit
and the rule ends.
8. When the cell's `low` is above the whole *y*: a weapon with `groundBounce` set gets
`direction.y = −(direction.y >> 2)` (arithmetic shift) and the rule ends without a detonation; any
other weapon detonates *p* with no unit and the rule ends.
Expand Down Expand Up @@ -497,6 +527,11 @@ weapon, and no scenario reaches one (#25).
| SET_STOCKPILES 267 | each slot that has a weapon gets the stockpile `stockpiles[w]` (its low 8 bits) | 1 |
| ADD_STOCKPILE 269 | the slot's stockpile rises by one (8 bits) | 1 |

**The `source` of DAMAGE and REMOTE_DAMAGE** is 0 (no attacker) or the block offset of a slot of
`Game.units` inside the pool (the first slot included), by the test the table above gives for `unit`.
The reference does no such test; any other value is outside the contract: the reference has no result for it, and no recording holds
one. The event is not refused for it.

**A unit's slots set up** (INIT_SLOTS): for each slot *w*: `reloadTimer` 0; `flags` keeps bits 5 to 7,
its bit 0 becomes 0, bits 2 and 3 become *w*, its bit 4 becomes 1 and its bit 1 becomes 1 when the
definition's `weapons[w]` is not weapon 0; `weapon` becomes `u.def.weapons[w]`; `stockpile` 0; `muzzleAimFromDeltaZ` becomes
Expand Down Expand Up @@ -759,7 +794,7 @@ For each slot *w* from 0 to 2, in order:
- With the slot's weapon `ballistic`: `scripts.GetAimFromPosition` gives the aim point; the differences
to *pos* give the heading (`heading(dx, dz) − u.heading`, 16 bits) and the pitch (the launch angle
rule of (dx, dy, dz, speed, pitch)); a pitch of 0x8000 means no aim. With `lineOfSight`: the heading
is `heading` of the differences, and the pitch is `heading` of minus *dy*'s whole part and of the
is `heading` of the differences minus `u.heading` (16 bits), and the pitch is `heading` of minus *dy*'s whole part and of the
truncated `distance(dx, dz)` cut to 16 bits; any other weapon has no aim.
- With no aim: the slot's bit 0 is cleared, OUT_OF_REACH is published and the handler returns 0. When
the aim tolerance test (below) fails: the slot's bit 0 is cleared and it returns 0.
Expand Down Expand Up @@ -1070,12 +1105,14 @@ Not recorded in the kit's recordings (`docs/replay-format.md`, "Not recorded"),
reason:

- An interceptor shot: the recorded interceptor is the anti-nuke of `orders-weapon-build`, which
searches and finds no projectile, so `FindTargetableProjectile`'s hit, a projectile's chase of its
`interceptedProjectile` and `SendProjectileDetonated` are unrecorded.
searches and finds no projectile, so `FindTargetableProjectile`'s hit and a projectile's chase of its
`interceptedProjectile` are unrecorded. `ai-antinuke-pair` (ticks 5920 to 5930) holds the
detonation of interceptor projectiles and its two `SendProjectileDetonated` calls each, in a chain of
two levels.
- `network.SendWeaponFire`, `network.SendUnitDamage`, `network.SendWeaponFireAt` and
`network.SendProjectileDetonated`: they act only in a network game. The kit's stated limits
(`docs/replay-format.md`, "Not recorded", weapons) also leave unjudged the two points' addresses,
interceptor chains deeper than four, a moved interceptor with a dead target, writes through a corrupt
interceptor chains deeper than two levels, a moved interceptor with a dead target, writes through a corrupt
pointer of the block and a damage table above 65536 entries.
- A hit of a paralyser weapon (a DAMAGE event of kind 2), PARALYZE's effect, damage of kind 11 and the
recorded kinds' other values: the recorded DAMAGE events are of kinds 3 and 10.
Expand Down Expand Up @@ -1122,5 +1159,5 @@ Questions the kit leaves open, which this spec does not answer:

## 8. Kit version

Kit `interfaces-v92` and `reference-traces-v60`, the versions the gate judges against. Interface
Kit `interfaces-v102` and `reference-traces-v64`, the versions the gate judges against. Interface
`weapons` 4.0.
Loading