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:
@@ -12,7 +12,9 @@
|
||||
## hud and hud_build (issue A9): once landed, the server hands the player a carbine, a
|
||||
## fowling piece and bandages, wounds them a little and takes three bots out in
|
||||
## different ways, so every part of the HUD has something to show; hud_build then goes
|
||||
## into build mode. Every stage draws the HUD as the client's HudState has it.
|
||||
## into build mode. hud_downed (issue M7) plays duos, with the first bot as the player's
|
||||
## crewmate, and after the hud staging a bot's shot downs the player. Every stage draws
|
||||
## the HUD as the client's HudState has it.
|
||||
extends Node3D
|
||||
|
||||
const DT: float = 1.0 / Tuning.TICK_RATE_HZ
|
||||
@@ -34,6 +36,8 @@ func _ready() -> void:
|
||||
rules.max_players = bots + 1
|
||||
rules.lobby_ticks = 6
|
||||
rules.countdown_ticks = 6
|
||||
if stage == "hud_downed":
|
||||
rules.team_size = Tuning.DUO_TEAM_SIZE
|
||||
_loop = ServerLoop.new(match_seed, 0, bots, rules)
|
||||
_net = NetServer.new()
|
||||
if _net.listen(0, HOST) != OK:
|
||||
@@ -68,7 +72,7 @@ func _ready() -> void:
|
||||
reached = me.drop_state == Drop.ABOARD and _session.game.prediction.next_tick > 3 * Tuning.TICK_RATE_HZ
|
||||
"glide":
|
||||
reached = me.drop_state == Drop.GLIDING
|
||||
"landed", "basin", "build", "build_refused", "hud", "hud_build":
|
||||
"landed", "basin", "build", "build_refused", "hud", "hud_build", "hud_downed":
|
||||
reached = me.drop_state == Drop.NONE
|
||||
if reached and since < 0:
|
||||
since = 0
|
||||
@@ -94,6 +98,11 @@ func _ready() -> void:
|
||||
return
|
||||
if stage == "hud_build" and _build_mode(true).is_empty():
|
||||
return
|
||||
if stage == "hud_downed":
|
||||
var downed_text: String = _down_player()
|
||||
if downed_text.is_empty():
|
||||
return
|
||||
basin_text += downed_text
|
||||
_session.hud.fade_feed = false
|
||||
_session.hud.show_state(_session.hud_state())
|
||||
_session.view.settle()
|
||||
@@ -139,7 +148,7 @@ func _stage_hud() -> String:
|
||||
var taken: int = 0
|
||||
for bot: int in flow.bot_handles.keys():
|
||||
var player: SimEntity = sim.entities.find(int(flow.entity_of.get(bot, 0)))
|
||||
if player == null or player.eliminated:
|
||||
if player == null or player.eliminated or sim.are_teammates(mine, player):
|
||||
continue
|
||||
player.health = 0
|
||||
player.last_cause = causes[taken]
|
||||
@@ -164,6 +173,35 @@ func _stage_hud() -> String:
|
||||
return " · %d of %d standing, %d feed lines" % [hud.standing, hud.total, hud.feed.size()]
|
||||
|
||||
|
||||
## Duos: a bot's shot takes the player's last health with their crewmate still up, so
|
||||
## they go down. Returns a caption line, or "" after reporting an error.
|
||||
func _down_player() -> String:
|
||||
var flow: Match = _loop.match_flow
|
||||
var sim: Simulation = _loop.sim
|
||||
var mine: SimEntity = sim.entities.find(int(flow.entity_of.get(_session.link.handle, 0)))
|
||||
var foe: SimEntity = null
|
||||
for bot: int in flow.bot_handles.keys():
|
||||
var player: SimEntity = sim.entities.find(int(flow.entity_of.get(bot, 0)))
|
||||
if player != null and not player.eliminated and not sim.are_teammates(mine, player):
|
||||
foe = player
|
||||
break
|
||||
if mine == null or foe == null or not sim.has_standing_teammate(mine):
|
||||
push_error("client capture: no foe, or no crewmate standing, to down the player")
|
||||
return ""
|
||||
mine.armor = 0
|
||||
Weapons.damage_player(sim, mine, mine.health, foe.id, false, ItemCatalog.code_of("dock_carbine"))
|
||||
for _round: int in Tuning.TICK_RATE_HZ:
|
||||
_game.poll()
|
||||
_loop.run_tick()
|
||||
_game.after_tick()
|
||||
_session.pump(DT)
|
||||
var hud: HudState = _session.hud_state()
|
||||
if not mine.downed or not hud.downed:
|
||||
push_error("client capture: the player isn't down (server %s, HUD %s)" % [mine.downed, hud.downed])
|
||||
return ""
|
||||
return " · downed, %d health to bleed" % mine.health
|
||||
|
||||
|
||||
## Stops the autoplay where the player stands and goes into build mode for a driftwood
|
||||
## wall, after the server has given the player plenty of materials or taken them all.
|
||||
## Returns a caption line, or "" after reporting an error.
|
||||
|
||||
Reference in New Issue
Block a user