diff --git a/crates/sim/src/script_player.rs b/crates/sim/src/script_player.rs index 0b1e01b..547b750 100644 --- a/crates/sim/src/script_player.rs +++ b/crates/sim/src/script_player.rs @@ -49,6 +49,7 @@ pub(crate) fn spawn( }; world.unlink_player_area(id); world.client_meta_mut(id).shield = None; + let prev_health = world.player(id).map(|p| p.health); let mut ps = spawn_player_state(origin, angles); if let Some(max) = world .client_meta(id) @@ -56,8 +57,12 @@ pub(crate) fn spawn( .filter(|&n| n > 0) { ps.max_health = max; - ps.health = max; } + ps.health = match sessionstate { + "playing" => ps.max_health, + "dead" | "intermission" => prev_health.unwrap_or(0), + _ => 0, + }; let cmd = spawn_command_angles(world, id); ps.delta_angles = std::array::from_fn(|axis| angles[axis] - cmd[axis] as f32 * SHORT2ANGLE); let prev_teleport = world