From f16af287534fceeb466bbd474d1ab3d94c19d1a3 Mon Sep 17 00:00:00 2001 From: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Sat, 2 Sep 2023 17:49:26 +0100 Subject: Force player respawn to match vanilla (#554) Automatically respawns dead players after 5 seconds unless set otherwise --- .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index ec426754..3bd0cd69 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -274,6 +274,9 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga ClearRespawnAvailable( player ) + // reset this so that we default to pilot spawn + player.SetPersistentVar( "spawnAsTitan", false ) + OnThreadEnd( function() : ( player ) { if ( !IsValid( player ) ) @@ -379,6 +382,13 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga SetRespawnAvailable( player ) wait respawnDelay + + int forceRespawn = GetCurrentPlaylistVarInt( "player_force_respawn", -1 ) + + // -1 is disabled, anything over is the time we wait in seconds + // before respawning the player + if( forceRespawn >= 0 ) + thread ForceRespawnMeSignalAfterDelay( player, forceRespawn ) player.WaitSignal( "RespawnMe" ) // set in base_gametype: ClientCommand_RespawnPlayer @@ -398,6 +408,21 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga } } +// idk if this is a good delay or if it matches vanilla +void function ForceRespawnMeSignalAfterDelay( entity player, int delay = 5 ) +{ + player.EndSignal( "RespawnMe" ) + player.EndSignal( "OnDestroy" ) + + if( player.IsWatchingKillReplay() ) + player.WaitSignal( "KillCamOver" ) + + wait delay + + printt( format( "Forcing player respawn for player %s (took >%d seconds to respawn)", player.GetPlayerName(), delay ) ) + player.Signal( "RespawnMe" ) +} + void function PlayerWatchesKillReplayWrapper( entity player, entity attacker, float timeSinceAttackerSpawned, float timeOfDeath, float beforeTime, table replayTracker ) { player.EndSignal( "RespawnMe" ) -- cgit v1.2.3