M3: Eliminations, spectating and results
The simulation now names what ended each player: weapon, fall, drown or tide, from the cause of the blow that took the last health. Hits carry the weapon's item code. Match keeps a kill feed (eliminator, cause, weapon, tick), per-player stats (damage dealt and taken between opponents, eliminations, never teammates), and a summary() with place, eliminations, damage and survival time. Players who fall on the same tick share the better place and are marked tied. When the last players fall together, the tie-break raises one team to first and the rest share the next place. Eliminated players spectate: first whoever knocked them out, then a living teammate, then the next living player in join order. When a target falls or leaves, the view follows its eliminator or moves on, on the same step. Spectators can cycle forwards and back. In results everyone watches the winner. The headless server logs every placement and the match summary. Closes #26 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+6
-4
@@ -216,7 +216,7 @@ static func _apply_hit(sim: Simulation, attacker: int, def: ItemDef, tier: int,
|
||||
HIT_PLAYER:
|
||||
if hit.headshot:
|
||||
amount *= def.headshot_multiplier
|
||||
damage_player(sim, sim.entities.find(hit.target), roundi(amount), attacker, hit.headshot)
|
||||
damage_player(sim, sim.entities.find(hit.target), roundi(amount), attacker, hit.headshot, def.code)
|
||||
HIT_PIECE:
|
||||
sim.damage_piece(hit.target, roundi(amount * def.structure_factor), "weapon")
|
||||
HIT_PROP:
|
||||
@@ -241,19 +241,21 @@ static func _pull(sim: Simulation, player: SimEntity, point: Vector3, speed: flo
|
||||
sim.events.append({"type": "line_pull", "player": player.id, "point": point})
|
||||
|
||||
|
||||
## Takes `amount` from armor, then health. Returns the damage actually done.
|
||||
static func damage_player(sim: Simulation, victim: SimEntity, amount: int, attacker: int, headshot: bool = false) -> int:
|
||||
## Takes `amount` from armor, then health. Returns the damage actually done. `item` is
|
||||
## the weapon's item code, or -1, for the kill feed.
|
||||
static func damage_player(sim: Simulation, victim: SimEntity, amount: int, attacker: int, headshot: bool = false, item: int = -1) -> int:
|
||||
if victim == null or victim.eliminated or amount <= 0:
|
||||
return 0
|
||||
var to_armor: int = mini(victim.armor, amount)
|
||||
victim.armor -= to_armor
|
||||
var to_health: int = mini(victim.health, amount - to_armor)
|
||||
victim.health -= to_health
|
||||
victim.last_cause = SimEntity.CAUSE_WEAPON
|
||||
if attacker != 0 and attacker != victim.id:
|
||||
victim.last_attacker = attacker
|
||||
sim.events.append({
|
||||
"type": "player_hit", "player": attacker, "victim": victim.id,
|
||||
"armor": to_armor, "health": to_health, "headshot": headshot,
|
||||
"armor": to_armor, "health": to_health, "headshot": headshot, "item": item,
|
||||
})
|
||||
return to_armor + to_health
|
||||
|
||||
|
||||
Reference in New Issue
Block a user