feat(modes): matches now end, and something is at stake when they do
There was a string — `current_gamemode`, always "Deathmatch" — an OptionButton
with one entry in it, and a five-minute timer that counted to zero, set
`match_active = false`, and did nothing else. No winner was declared, no summary
appeared, the clock froze at 00:00, and players carried on shooting each other
in a match that had stopped counting. Nothing was tracked beyond a running kill
count. A match did not end so much as stop mattering, and everything a player
does in the last minute only matters if there is a last minute.
globals/game_mode.gd answers the three questions a mode has to answer — how you
score, when it ends, who won — for three modes:
Deathmatch 25 frags or 10 minutes.
Team Deathmatch two squads to 50, teams balanced by COUNT on join (a 4v4
that loses three from one side must refill the short side;
round-robin on join order leaves it 4v1 forever), friendly
fire off and enforced on the server before damage is even
broadcast — a mode where the damage lands but the kill does
not count is worse than either.
Gun Game every kill promotes you a rung and swaps your weapon. The
score IS the rung and the limit IS the ladder's length, so
finishing the ladder and reaching the score limit are the
same event and only one win condition exists.
`check_win` is a pure function of the stats and the clock, deliberately, because
a win condition that can only be exercised by playing a whole match is one
nobody tests — and the previous one never was. debug/game_mode_check.gd runs 30
cases over it: a tie is a DRAW rather than a win for whoever came first out of
the dictionary; a team match is decided on the TEAM's total, which a per-player
check never reaches; every ladder rung names a weapon that exists, or that rung
softlocks the mode; and promoting past the top clamps, because the winning kill
promotes before the match-end RPC lands.
Tracking now covers score, team, current streak, best streak and ladder rung.
Score and kills are separate numbers because in Gun Game they coincide and in
anything with an objective they would not. The scoreboard ranks by score, shows
the mode's own noun for it, and puts the limit on the top line — a win condition
players cannot see is one they cannot play toward.
ui/match_summary.gd gives the ending somewhere to happen: who won, WHY (time and
frag limit are different stories about the same scoreline), team totals, full
standings, and a way out that is not alt-F4. Play Again is host-only on a server.
Three bugs found on the way, all of which only became bugs once matches could
actually end: loading a level reset the clock but not the scores, so the second
match on a server would have ended on its first kill; `.rpc()` on an offline
peer does not call locally, so singleplayer had no killfeed and no stat sync at
all; and a rocket already in the air at the whistle could change the result
after the summary was on screen.
spawn smoke 0, game modes 30/30, movement 11/11.
Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f1a4f7df52
commit
986179854d
@@ -16,11 +16,26 @@ func _ready() -> void:
|
||||
set_process(true)
|
||||
|
||||
_setup_viewmodel_viewport()
|
||||
|
||||
|
||||
# Gun Game promotions arrive as a signal from the server.
|
||||
var nm = get_node_or_null("/root/NetworkManager")
|
||||
if nm and nm.has_signal("ladder_promoted"):
|
||||
nm.ladder_promoted.connect(_on_ladder_promoted)
|
||||
|
||||
# Wait one frame for LoadoutManager to be fully ready if needed
|
||||
await get_tree().process_frame
|
||||
_build_loadout()
|
||||
|
||||
|
||||
func _on_ladder_promoted(peer_id: int, _rung: int, weapon_id: String) -> void:
|
||||
# Only the promoted player's own manager acts; every peer receives the
|
||||
# signal because the killfeed uses it too.
|
||||
if player == null or not player.is_multiplayer_authority():
|
||||
return
|
||||
if multiplayer.has_multiplayer_peer() and peer_id != multiplayer.get_unique_id():
|
||||
return
|
||||
equip_ladder_weapon(weapon_id)
|
||||
|
||||
func _setup_viewmodel_viewport() -> void:
|
||||
if not camera: return
|
||||
|
||||
@@ -200,12 +215,49 @@ func _build_loadout() -> void:
|
||||
player.synced_loadout_melee = ""
|
||||
player.synced_loadout_ready = true
|
||||
|
||||
# Gun Game hands out the weapon, so the player's own loadout is ignored —
|
||||
# the whole mode is "you get what your rung gives you". Checked here rather
|
||||
# than in the mode so there is one place a loadout is built.
|
||||
if _ladder_mode():
|
||||
var nm = get_node_or_null("/root/NetworkManager")
|
||||
var rung: int = int(nm.player_stats.get(multiplayer.get_unique_id(), {})
|
||||
.get("rung", 0)) if nm else 0
|
||||
equip_ladder_weapon(GameMode.ladder_weapon(rung))
|
||||
return
|
||||
|
||||
_spawn_weapon(1, l["primary_1"])
|
||||
_spawn_weapon(2, l["primary_2"])
|
||||
_spawn_weapon(3, l["special"])
|
||||
if l.has("melee"):
|
||||
_spawn_weapon(4, l["melee"])
|
||||
|
||||
|
||||
_equip_slot(1)
|
||||
|
||||
|
||||
## Whether the current match issues weapons instead of letting players pick.
|
||||
func _ladder_mode() -> bool:
|
||||
var nm = get_node_or_null("/root/NetworkManager")
|
||||
return nm != null and nm.current_gamemode == GameMode.GUN_GAME
|
||||
|
||||
|
||||
## Replace everything in hand with one issued weapon. Gun Game's promotion.
|
||||
func equip_ladder_weapon(weapon_id: String) -> void:
|
||||
if weapon_id == "":
|
||||
return
|
||||
for w in weapons.values():
|
||||
if is_instance_valid(w):
|
||||
w.queue_free()
|
||||
weapons.clear()
|
||||
_spawn_weapon(1, weapon_id)
|
||||
if player:
|
||||
# Remote peers build their view of this player from the synced loadout,
|
||||
# so a promotion has to move that too or everyone else keeps seeing the
|
||||
# gun from the previous rung in their hands.
|
||||
player.synced_loadout_p1 = weapon_id
|
||||
player.synced_loadout_p2 = ""
|
||||
player.synced_loadout_sp = ""
|
||||
player.synced_loadout_melee = ""
|
||||
player.synced_loadout_ready = true
|
||||
_equip_slot(1)
|
||||
|
||||
func _build_remote_loadout(p1: String, p2: String, sp: String, melee: String) -> void:
|
||||
|
||||
Reference in New Issue
Block a user