6. Combat and collisions
Lasers, missiles and ramming: how a hit is detected, what it costs, and the surprising shapes of the "hit zones" that come from simple box tests. Distances are in world units, speeds in units per frame (chapter 3).
Your laser
Firing
- Press Space or the mouse button: the first frame fires; holding fires every third frame. Releasing resets this, so fast tapping fires faster than holding.
- No shot when all 8 slots are in flight, when you are dead, spectating, or cloaked (the press is then used up, but no shot appears).
- A shot starts 64 units from your ship along its "up" axis (which points down the screen, chapter 3), so it appears a little below the centre of the view, with your ship's orientation, and flies at your velocity + 1024 units per frame forward. It lives 24 frames: about 24,600 units of range beyond your own drift.
- With extra fire power (a pick-up) each shot uses one unit of the stock and becomes powered; powered shots are drawn yellow instead of white.
The hit test: a box around the shot
Each frame, after the shot moves, it is tested against possible targets. The test is a box in the shot's own frame (its forward, right and "up" axes, copied from your ship when it was fired): the target's centre must be within ±512 units along the shot's flight, and within a sideways half-width of ±192 units (big targets: aliens, pods, ships) or ±96 (small ones: missiles, satellites) along the other two axes. A first rough check against a ±512 cube in world axes saves time and slightly trims the box's corners.
What a shot can hit, in order
| Mode | Targets, tested in this order | Effect |
|---|---|---|
| single player | 1. aliens | −1 hit point, −2 while you have extra fire power left; at 0 the alien explodes and you get its points (100–400) |
| 2. enemy missiles | destroyed, 25 points | |
| 3. pods | destroyed (friendly fire, no points, no message) | |
| 4. your satellite | destroyed, no points | |
| multiplayer | 1. other players' ships (cloaked ones too) | reported to the victim (below); +50 points for you per hit |
| 2. other players' satellites | reported to the owner, who explodes it; no points | |
| 3. your satellite | destroyed |
The first hit ends the shot (in single player); the shot then shows a small expanding red ring for 7 frames at the hit point. Objects that are already exploding (dying aliens, missiles, pods) cannot be hit, cannot ram and cannot be locked onto.
- Damage is decided by your stock, not by the shot. Against aliens a hit does double damage if you have extra fire power at the moment of the hit; a plain shot fired just before a fire-power pick-up hits hard, the last powered shot (stock now 0) hits soft.
- Point-blank blind spot. A shot is first tested after its first move, about 1024 units ahead; with its box reaching 512 back, anything closer than about 512 units straight ahead is never hit D (the 512-unit edge itself was observed, runtime #26). Ramming starts only below about 256 units, so an alien between 256 and 512 units right in front of you can neither be shot nor rammed.
- Tunnelling. The box is ±512 units along the flight (1025 units counting both ends); the shot moves 1024 plus your speed per frame. At full throttle about 1 in 8 shots at a target at rest exactly on the line of fire skips over it; with extra thrust about 1 in 5 D. A target coming toward the shot is skipped more often, one moving away less.
- Order of the frame. Your shots are tested before the aliens move, so they hit where the aliens were at the end of the previous frame.
Alien lasers
- Fired by Fighters (every 4th frame), Guardians at rest (every other frame) and mutants (every frame), each only while aimed at you, i.e. you are within about 1° of their nose (chapter 7).
- 8 shared slots. A shot starts at the alien's centre and flies 1024 units per frame along the alien's nose, without the alien's own speed, for 24 frames. It does not explode, it just vanishes.
- It can only hit you, and only while you are alive. The test: first a rough ±1024 cube in world axes, then the vector from the shot to you, in the shot's own frame, must be within ±1024 units along its right axis, but only ±256 along its flight and its "up" axis (a flat slab, see the figure).
- A hit costs 1 shield and flashes the screen light red. No bump, and the bump immunity after a collision does not protect you.
The slab is only 512 units deep, but the shot moves 1024 units per frame. A shot aimed straight at you therefore passes through without a hit about half the time D (a pass-through was observed, runtime #27). And like yours, an alien shot moves before its first test: if you are less than about 768 units in front of the alien that fires, its shot never hits you D.
Missiles
Locking on
Your missiles (single player only, Enter or Caps Lock) need a target. After the aliens move each frame, every live alien is checked against a "lock window": it must be in front of you and within ±384 units of your line of sight, both sideways and up/down. Every alien that passes is marked, and the sight turns into the four-triangle bracket.
This window is a square beam of fixed width along your view direction, not a cone: at 16,000 units it reaches only about 1.4° off your line of sight (2.7° across), at 1000 units about 21° (42° across), and very close it covers almost everything in front of you, even outside the screen (an alien never drawn, 70° to the side, was locked and killed in a test run, runtime #34) D.
- A missile homes on the first marked alien in the alien table, not the nearest.
- The marks are made after the aliens move, and your ship is updated first in the next frame, so a missile uses the previous frame's lock.
- An alien closer than about 128 units can never be locked (a number overflows in the original's 16-bit arithmetic).
- Without a target: "No Target", nothing else. With no missiles left, or 4 already flying: nothing.
Your missile
- Starts 64 units from your ship along its "up" axis, at its top speed of 400 units per frame. While its target is behind it, it brakes by 25 per frame (down to 0); once the target is ahead it speeds up again by 25 per frame. It turns up to 128 steps (22.5°, with 2048 steps per full turn) per frame: very agile.
- Homes on its target with the "to object" steering helper (it turns toward the target in proportion to how far off the nose it is; chapter 7). When it is within about 256 units of it (every coordinate difference), the target loses 16 hit points: a missile hit always kills, and you get the alien's points.
- It can only hit its own target; it flies through everything else. If the target is destroyed first, the missile flies straight on and disappears once it is about 16,000 units away from you.
Enemy missiles
| Pirate's missile | Commander's missile | |
|---|---|---|
| speed | 400, constant | 400; brakes by 12.5 per frame down to 50 while you are behind it, speeds up again when aimed |
| turn | 8 steps (1.4°) per frame | 32 steps (5.6°) per frame |
| gives up | when about 16,000 units from you | never |
- "WARNING: MISSILE LAUNCH DETECTED". Both home on you with the "chase" helper (turn toward you in proportion to how far off the nose you are; chapter 7).
- They hit when within about 256 units of you on every axis (the same 256-unit cube as ramming an alien, but bump immunity does not apply): 1 shield, light-red flash, the missile explodes. No bump.
- At 400 units per frame they are faster than your ship (at most 144, or 288 with extra thrust): you cannot outrun one, but you can shoot it down for 25 points.
Ramming and other contacts
"Touching" means every coordinate difference is below about 256 units (ships, aliens and pods; 128 for satellites), i.e. the renderer's display exponent is 7 or more, and you are not in the 8 frames of bump immunity after the last collision (chapter 5).
| Contact | Effect |
|---|---|
| you and an alien (while you have shields) | you lose 1 shield, light-green flash, bump (chapter 4; no bump if it was your last shield); the alien loses 1 hit point and may explode, but a ram kill gives no points |
| you and another player's ship (cloaked or not) | you lose 1 shield, light-green flash and bump (none of these if it kills you); each machine decides this for itself and tells nobody |
| you and a satellite | you collect it (chapter 7) |
| you and a pod | nothing |
| alien and alien, alien and pod | nothing (except an alien reaching the pod it is after, chapter 7) |
Shields, damage and death
- Shields start at 32 and never exceed 32. Every hit or collision costs 1; a powered hit from another player costs 2.
- The background flashes for exactly one frame: light green for a collision, light red for a hit, yellow for a powered hit (if two happen in one frame, the last one wins).
- When the shields reach 0, a 64-frame death countdown starts and the death screen follows (chapter 2). A dead ship drifts no more and cannot fire, but the world keeps running; aliens' shots, missiles and rams no longer hurt it.
Multiplayer: the shooter decides
In multiplayer no machine simulates anybody else's weapons for real. The rules (the network side is chapter 8):
- The shooter's machine decides every hit. Its own laser shots are tested against its local copies of the other ships (as last received). A hit is written into the shooter's next packet as a hit report: "slot n was hit", with a flag for powered shots. The shooter scores 50 points per hit, at once; there is no extra reward for a kill.
- The victim's machine applies it when the packet arrives, at the end of its frame: −1 shield (−2 if powered), flash, and any stored cloak time is lost ("Cloak Destroyed!"), even if the cloak was switched off. At 0 shields the victim records the shooter as its killer.
- The shot copies you see from other players are only pictures; they never hit you (chapter 5).
- Ship-to-ship collisions are judged by each machine on its own; a collision kill names the other player as killer but gives nobody points.
- A cloaked ship is invisible in the others' views but still on their radars, can still be hit, and cannot fire.
- A packet carries one hit report per victim, so two of your shots hitting the same player in the same frame count once.
The victim's machine reads the last packet received from each player every frame, whether or not a new one arrived. If a shooter's packets stop right after a hit (it crashed or its network dropped), that one hit is applied again in every frame: in a test, one hit took 20 shields in about 20 frames and the death countdown restarted every frame for as long as the shooter stayed silent (100 seconds in the test; runtime #24 in docs/runtime-baseline.md). Hit reports also still land on a player who is already dead.
Keep the box tests with their sizes and orientations; they are the feel of aiming in NetWars (a laser that needs to be on target sideways but forgives a lot along the flight, alien shots that are hard to dodge sideways but sometimes pass through). If you want to remove the tunnelling and the point-blank blind spots (yours and the aliens'), test the shot's whole path segment for the frame instead of its end point; that is a deliberate change of feel, so make it a choice. Keep the frame order (your shots, then the aliens, then their shots), which decides who sees whose old position.
For multiplayer keep "the shooter decides", but send each hit report once with an id and have the victim acknowledge it, instead of re-reading the last packet: that removes the repeated-hit bug (chapter 8 and 13).
All box tests work on whole units: the difference between target and shot is taken per axis in whole world units, rounded down, first checked against the rough cube, then dotted with the shot's axes (rounded down, chapter 3) and compared with the limits. Every limit is inclusive: "within ±512" means −512 ≤ value ≤ 512 (513 misses). Results can therefore differ from an exact floating-point test by a unit or so at the faces of the box.