M7: Duos and revive

Two-player teams, enforced by the simulation:
- Match puts every player on a team (SimEntity.team); Weapons.damage_player
  refuses damage between teammates from every weapon, the boathook and blasts.
- A player whose health runs out with a teammate standing goes down instead of
  out: 60 health to bleed (one point every half second), crawling at 1 m/s, no
  firing, building, looting or items. Hits still take it; drowning too.
- A standing teammate within 2 m holding interact for 6 s revives them with 30
  health. Letting go or moving away starts it over.
- Downed players are out when their health runs out again or when no teammate
  is left standing, credited to whoever downed them. A team falls together and
  shares its place; the tie-break puts standing ahead of downed.
- Downs and revives go through Match events and the kill feed ("X knocked Y
  down"); the HUD says what to do while down.

Wire: FLAG_DOWNED in the player record and the own block (flags now u16),
so prediction crawls too. Protocol version 5.

Bots: never target a teammate, land with their teammate, regroup when they
stray past 30 m, crawl toward a standing teammate when down, go to revive a
downed teammate within 60 m when not in a fight, and turn from a downed target
to its standing teammate when it's in view.

Options: --team-size=2 on the server, --duos offline, and Solo/Duos under
Crew in the Practice menu. The figure has a downed crawl pose.

Tests: test_duos (downing, crawl, revive, interrupted revive, bleed-out,
finishing, team out, falling together, no friendly damage including kegs,
drowning while down, hash, match placement and tie-break), bots as teammates,
the downed flag on the wire, the feed, server and menu options. make
duo-matches plays 10 bot duos matches.

Closes #30

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 03:01:09 -05:00
co-authored by Claude Opus 5.5
parent 324bf84dd5
commit 2167900e45
53 changed files with 1105 additions and 61 deletions
+12 -1
View File
@@ -1,7 +1,7 @@
## Command-line configuration for a headless server.
##
## tools/godot.sh -- --server [--listen] [--port=N] [--seed=N] [--players=N] [--bots=N]
## [--bot-difficulty=mixed|easy|normal|hard] [--ticks=N]
## [--bot-difficulty=mixed|easy|normal|hard] [--team-size=1|2] [--ticks=N]
## [--unthrottled] [--log-every=N] [--matches=N] [--world-hash-every=N]
## [--name=NAME] [--list=HOST[:PORT]]... [--no-lan]
## [--health-port=N] [--health-bind=ADDRESS] [--stop-file=PATH]
@@ -24,6 +24,9 @@
## A listening server answers LAN discovery on its port plus one unless `--no-lan`,
## and registers with each `--list` server (see ListServer) under `--name`.
##
## `--team-size=2` plays duos (M7): pairs in join order, who can't hurt each other and
## go down instead of out while their teammate stands. 1, solo, is the default.
##
## Unknown or malformed arguments are errors, so a typo can't silently run the wrong
## match. See `parse()`.
class_name ServerConfig
@@ -46,6 +49,8 @@ var port: int = DEFAULT_PORT
## Idle player slots, for a server that isn't listening.
var players: int = 0
var bots: int = 0
## Players on a team: 1 for solo, Tuning.DUO_TEAM_SIZE for duos.
var team_size: int = 1
## Every bot's difficulty, as an index into Tuning.BOT_DIFFICULTIES, or -1 to mix them.
var bot_difficulty: int = -1
## Ticks to run before exiting. 0 runs until the process is stopped.
@@ -107,6 +112,7 @@ func to_dictionary() -> Dictionary:
"port": port,
"players": players,
"bots": bots,
"team_size": team_size,
"bot_difficulty": "mixed" if bot_difficulty < 0 else String(Tuning.BOT_DIFFICULTIES[bot_difficulty]["name"]),
"ticks": ticks,
"matches": matches,
@@ -147,6 +153,9 @@ func _parse_one(arg: String) -> void:
"--bots":
if _check_int(key, value):
bots = value.to_int()
"--team-size":
if _check_int(key, value):
team_size = value.to_int()
"--ticks":
if _check_int(key, value):
ticks = value.to_int()
@@ -260,6 +269,8 @@ func _validate() -> void:
)
if listen and players > 0:
errors.append("--players is for a server that isn't listening; with --listen, people join over the network")
if team_size < 1 or team_size > Tuning.DUO_TEAM_SIZE:
errors.append("--team-size must be 1 (solo) or %d (duos), got %d" % [Tuning.DUO_TEAM_SIZE, team_size])
if ticks < 0:
errors.append("--ticks can't be negative")
if log_every < 0: