From 27bd240871b7c0f2f49fef137718b2e3c208e3b4 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sat, 17 Jul 2021 23:46:52 +0100 Subject: ctf switchsides spawn fix (untested) --- .../scripts/vscripts/_loadouts_mp.gnut | 2 +- Northstar.CustomServers/scripts/vscripts/_misc.gnut | 16 +--------------- .../scripts/vscripts/gamemodes/_gamemode_ctf.nut | 8 ++++++-- .../scripts/vscripts/lobby/_private_lobby.gnut | 14 ++++++++++++++ .../scripts/vscripts/mp/_base_gametype_mp.gnut | 17 +++++++++++++---- .../scripts/vscripts/mp/_classic_mp_dropship_intro.gnut | 13 ++++++++++--- .../scripts/vscripts/mp/_gamestate_mp.nut | 4 +++- 7 files changed, 48 insertions(+), 26 deletions(-) (limited to 'Northstar.CustomServers/scripts') diff --git a/Northstar.CustomServers/scripts/vscripts/_loadouts_mp.gnut b/Northstar.CustomServers/scripts/vscripts/_loadouts_mp.gnut index 2a6eb5a8c..2b7b90b3b 100644 --- a/Northstar.CustomServers/scripts/vscripts/_loadouts_mp.gnut +++ b/Northstar.CustomServers/scripts/vscripts/_loadouts_mp.gnut @@ -54,7 +54,7 @@ void function SetWeaponDropsEnabled( bool enabled ) void function DestroyDroppedWeapon( entity victim, entity attacker, var damageInfo ) { - if ( !file.weaponDropsEnabled ) + if ( !file.weaponDropsEnabled && IsValid( victim.GetActiveWeapon() ) ) victim.GetActiveWeapon().Destroy() } diff --git a/Northstar.CustomServers/scripts/vscripts/_misc.gnut b/Northstar.CustomServers/scripts/vscripts/_misc.gnut index 4384f8dfe..ef7e629fa 100644 --- a/Northstar.CustomServers/scripts/vscripts/_misc.gnut +++ b/Northstar.CustomServers/scripts/vscripts/_misc.gnut @@ -12,21 +12,7 @@ void function Spotting_Init() void function FW_Border_GlobalInit() { - AddCallback_EntitiesDidLoad( FW_Border_EntitiesDidLoad ) -} - -void function FW_Border_EntitiesDidLoad() -{ - if ( GetConVarString( "mp_gamemode" ) != "fw" ) - { - // remove fw borders if we're not playing fw - array brushes = GetEntArrayByClass_Expensive( "func_brush" ) - foreach ( entity brush in brushes ) - if ( GetEditorClass( brush ) == "func_brush_fw_territory_border" && GameModeRemove( brush ) ) - brush.Destroy() - - return - } + AddSpawnCallbackEditorClass( "func_brush", "func_brush_fw_territory_border", void function( entity e ) { GameModeRemove( e ) } ) } bool function IsVDUTitan(entity titan) diff --git a/Northstar.CustomServers/scripts/vscripts/gamemodes/_gamemode_ctf.nut b/Northstar.CustomServers/scripts/vscripts/gamemodes/_gamemode_ctf.nut index 728d742df..704f55d3b 100644 --- a/Northstar.CustomServers/scripts/vscripts/gamemodes/_gamemode_ctf.nut +++ b/Northstar.CustomServers/scripts/vscripts/gamemodes/_gamemode_ctf.nut @@ -69,8 +69,12 @@ void function RateSpawnpoints_CTF( int checkClass, array spawnpoints, in // if there are, spawn them outside of it ( but ideally still close ) // max distance away should be like, angel city markets - array startSpawns = SpawnPoints_GetPilotStart( team ) - array enemyPlayers = GetPlayerArrayOfTeam_Alive( GetOtherTeam( team ) ) + int spawnTeam = team + if ( HasSwitchedSides() ) + spawnTeam = GetOtherTeam( team ) + + array startSpawns = SpawnPoints_GetPilotStart( spawnTeam ) + array enemyPlayers = GetPlayerArrayOfTeam_Alive( GetOtherTeam( spawnTeam ) ) vector startSpawnAverage bool enemyInBase = false diff --git a/Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut b/Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut index 1b4e5dbd9..896ab207b 100644 --- a/Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut +++ b/Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut @@ -17,6 +17,8 @@ void function PrivateLobby_Init() AddClientCommandCallback( "PrivateMatchSetMode", ClientCommandCallback_PrivateMatchSetMode ) AddClientCommandCallback( "SetCustomMap", ClientCommandCallback_SetCustomMap ) AddClientCommandCallback( "PrivateMatchSwitchTeams", ClientCommandCallback_PrivateMatchSwitchTeams ) + + AddClientCommandCallback( "PrivateMatchSetPlaylistVarOverride", ClientCommandCallback_PrivateMatchSetPlaylistVarOverride ) AddClientCommandCallback( "ResetMatchSettingsToDefault", ClientCommandCallback_ResetMatchSettingsToDefault ) } @@ -160,6 +162,18 @@ void function RefreshPlayerTeams() } } +bool function ClientCommandCallback_PrivateMatchSetPlaylistVarOverride( entity player, array args ) +{ + // note: atm this doesn't actually check for the number of overrides, since there's no way to do this on server yet + // need to expose this to script soon + + if ( args.len() < 2 ) + return true + + SetPlaylistVarOverride( args[0], args[1] ) + return true +} + bool function ClientCommandCallback_ResetMatchSettingsToDefault( entity player, array args ) { ClearPlaylistVarOverrides() diff --git a/Northstar.CustomServers/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/scripts/vscripts/mp/_base_gametype_mp.gnut index 9d2ccc919..9274854a2 100644 --- a/Northstar.CustomServers/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -339,8 +339,7 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga if ( "respawnTime" in attacker.s ) respawnTime = Time() - expect float ( attacker.s.respawnTime ) - thread PlayerWatchesKillReplay( player, attacker.GetEncodedEHandle(), attacker.GetIndexForEntity(), respawnTime, timeOfDeath, beforeTime, replayTracker ) - thread EndReplayOnTime( player, replayLength ) + thread PlayerWatchesKillReplayWrapper( player, attacker, respawnTime, timeOfDeath, beforeTime, replayTracker ) } player.SetPlayerSettings( "spectator" ) // prevent a crash with going from titan => pilot on respawn @@ -356,10 +355,10 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga SetRespawnAvailable( player ) wait respawnDelay + + player.WaitSignal( "RespawnMe" ) // set in base_gametype: ClientCommand_RespawnPlayer player.SetPredictionEnabled( true ) - - player.WaitSignal( "RespawnMe" ) // set in base_gametype: ClientCommand_RespawnPlayer ClearRespawnAvailable( player ) // need so the respawn icon doesn't show for like a frame on next death if ( ( expect bool( player.GetPersistentVar( "spawnAsTitan" ) ) && IsTitanAvailable( player ) ) || ( Riff_SpawnAsTitan() > 0 && Riff_ShouldSpawnAsTitan( player ) ) ) // spawn as titan @@ -373,6 +372,14 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga } } +void function PlayerWatchesKillReplayWrapper( entity player, entity attacker, float timeSinceAttackerSpawned, float timeOfDeath, float beforeTime, table replayTracker ) +{ + PlayerWatchesKillReplay( player, attacker.GetEncodedEHandle(), attacker.GetIndexForEntity(), timeSinceAttackerSpawned, timeOfDeath, beforeTime, replayTracker ) + player.ClearReplayDelay() + player.ClearViewEntity() + player.SetPredictionEnabled( true ) +} + void function EndReplayOnTime( entity player, float replayLength ) { player.EndSignal( "RespawnMe" ) @@ -381,6 +388,8 @@ void function EndReplayOnTime( entity player, float replayLength ) wait replayLength if ( IsValid( player ) && KillcamsEnabled() ) { + print( "fucking how" ) + player.ClearReplayDelay() player.ClearViewEntity() player.SetPredictionEnabled( true ) diff --git a/Northstar.CustomServers/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut b/Northstar.CustomServers/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut index 7d5fb9f0d..02c312be3 100644 --- a/Northstar.CustomServers/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut +++ b/Northstar.CustomServers/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut @@ -72,9 +72,6 @@ void function DropshipIntro_OnClientConnected( entity player ) return } - - // if we're at this point, we have more players than we do dropships, oh dear - RespawnAsPilot( player ) } void function DropshipIntro_OnClientDisconnected( entity player ) @@ -159,6 +156,16 @@ void function SpawnPlayerIntoDropship( entity player ) break } + + if ( playerDropship.dropship == null ) + { + // if we're at this point, we have more players than we do dropships, oh dear + ScreenFadeFromBlack( player, 0.0 ) + RespawnAsPilot( player ) + + file.numPlayersInIntro-- + return + } // figure out what anims we're using for idle string idleAnim = DROPSHIP_IDLE_ANIMS[ playerDropshipIndex ] diff --git a/Northstar.CustomServers/scripts/vscripts/mp/_gamestate_mp.nut b/Northstar.CustomServers/scripts/vscripts/mp/_gamestate_mp.nut index bbeb72fbb..96a61b69f 100644 --- a/Northstar.CustomServers/scripts/vscripts/mp/_gamestate_mp.nut +++ b/Northstar.CustomServers/scripts/vscripts/mp/_gamestate_mp.nut @@ -51,7 +51,7 @@ struct { void function PIN_GameStart() { - // todo: using the pin telemetry function here is weird and was done veeery early on before i knew how this all worked, should use a different one + // todo: using the pin telemetry function here, weird and was done veeery early on before i knew how this all worked, should use a different one // called from InitGameState //FlagInit( "ReadyToStartMatch" ) @@ -596,6 +596,8 @@ void function CleanUpEntitiesForRoundEnd() foreach ( entity player in GetPlayerArray() ) { + ClearTitanAvailable( player ) + if ( IsAlive( player ) ) player.Die() -- cgit v1.2.3