aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-03-03 20:54:59 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-03-03 20:54:59 +0000
commit81809dfba9a8329f07d68d1fd66133161234effa (patch)
tree94c6571b4be52dbd03435ffee478a41e8c062922 /Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut
parentfd0c66f5c84b7b6c349c3362c3e6df555c393aa5 (diff)
downloadNorthstarMods-81809dfba9a8329f07d68d1fd66133161234effa.tar.gz
NorthstarMods-81809dfba9a8329f07d68d1fd66133161234effa.zip
spectator refactor and private match spectator support
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut')
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut146
1 files changed, 146 insertions, 0 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut b/Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut
new file mode 100644
index 000000000..2e6e04f42
--- /dev/null
+++ b/Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut
@@ -0,0 +1,146 @@
+untyped
+
+globalize_all_functions
+
+struct
+{
+ table<string,table<string,int> > mapModeScoreLimits
+} file
+
+int function GetRoundScoreLimit_FromPlaylist()
+{
+ if ( !GameMode_IsDefined( GAMETYPE ) )
+ return GetCurrentPlaylistVarInt( "roundscorelimit", 10 )
+
+ return GameMode_GetRoundScoreLimit( GAMETYPE )
+}
+
+int function GetScoreLimit_FromPlaylist()
+{
+ if ( GameMode_HasMapSpecificScoreLimits( GAMETYPE ) )
+ return GameMode_GetMapSpecificScoreLimit( GAMETYPE )
+
+ if ( !GameMode_IsDefined( GAMETYPE ) )
+ return GetCurrentPlaylistVarInt( "scorelimit", 10 )
+
+ return GameMode_GetScoreLimit( GAMETYPE )
+}
+
+bool function GameMode_HasMapSpecificScoreLimits( string gameType )
+{
+ if ( gameType in file.mapModeScoreLimits )
+ {
+ if ( GetMapName() in file.mapModeScoreLimits[gameType] )
+ return true
+ }
+ return false
+}
+
+int function GameMode_GetMapSpecificScoreLimit( string gameType )
+{
+ return file.mapModeScoreLimits[gameType][GetMapName()]
+}
+
+void function GameMode_SetMapSpecificScoreLimit( table<string,int> mapModeScoreTable, string gameType )
+{
+ Assert( !( gameType in file.mapModeScoreLimits ), "GAMETYPE has already been added to mapModeScoreLimits" )
+ file.mapModeScoreLimits[gameType] <- mapModeScoreTable
+}
+
+bool function IsSuddenDeathGameMode()
+{
+ return GameMode_GetSuddenDeathEnabled( GameRules_GetGameMode() )
+}
+
+bool function IsCaptureMode()
+{
+ return GameRules_GetGameMode() == CAPTURE_POINT
+}
+
+bool function GameModeWantsToSkipBoostsAndTitanEarning()
+{
+ if ( Riff_TitanAvailability() == eTitanAvailability.Never )
+ return true
+ if ( Riff_BoostAvailability() == eBoostAvailability.Disabled )
+ return true
+
+ return false
+}
+
+IntFromEntityCompare function GetScoreboardCompareFunc()
+{
+ return ScoreboardCompareFuncForGamemode( GameRules_GetGameMode() )
+}
+
+IntFromEntityCompare function ScoreboardCompareFuncForGamemode( string gamemode )
+{
+ IntFromEntityCompare func = GameMode_GetScoreCompareFunc( gamemode )
+ if ( func != null )
+ return func
+
+ return CompareScore
+}
+
+
+bool function IsRoundWinningKillReplayEnabled()
+{
+ return expect bool ( level.nv.roundWinningKillReplayEnabled )
+}
+
+bool function IsRoundWinningKillReplayPlaying()
+{
+ return expect bool ( level.nv.roundWinningKillReplayPlaying )
+}
+
+bool function HasRoundScoreLimitBeenReached() //Different from RoundScoreLimit_Complete in that it only checks to see if the score required has been reached. Allows us to use it on the client to cover 90% of the cases we want
+{
+ if ( !IsRoundBased() )
+ return false
+
+ int roundLimit = GetRoundScoreLimit_FromPlaylist()
+
+ if ( !roundLimit )
+ return false
+
+ int militiaScore = GameRules_GetTeamScore2( TEAM_MILITIA )
+ int imcScore = GameRules_GetTeamScore2( TEAM_IMC )
+
+ if ( ( militiaScore >= roundLimit ) || ( imcScore >= roundLimit ) )
+ return true
+
+ return false
+}
+
+
+bool function IsTitanAvailable( entity player )
+{
+ var shiftIndex = player.GetEntIndex() - 1
+ var elimMask = (1 << shiftIndex)
+
+ return (level.nv.titanAvailableBits & elimMask) != 0
+}
+
+
+
+bool function IsRespawnAvailable( entity player )
+{
+ var shiftIndex = player.GetEntIndex() - 1
+ var elimMask = (1 << shiftIndex)
+
+ return (level.nv.respawnAvailableBits & elimMask) != 0
+}
+
+bool function IsPrivateMatchSpectator( entity player )
+{
+ // JFS
+ #if SERVER
+ if ( !player.p.clientScriptInitialized )
+ return false
+ #endif
+
+ // NS: allow spectators on non-private_match playlists
+ if ( ( IsPrivateMatch() || GetConVarBool( "ns_allow_spectators" ) ) && player.GetPersistentVarAsInt( "privateMatchState" ) == 1 )
+ return true
+
+ return false
+} \ No newline at end of file