aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/scripts/vscripts/lobby
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.CustomServers/scripts/vscripts/lobby')
-rw-r--r--Northstar.CustomServers/scripts/vscripts/lobby/_lobby.gnut37
-rw-r--r--Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut181
-rw-r--r--Northstar.CustomServers/scripts/vscripts/lobby/sh_lobby.gnut356
-rw-r--r--Northstar.CustomServers/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut21
4 files changed, 0 insertions, 595 deletions
diff --git a/Northstar.CustomServers/scripts/vscripts/lobby/_lobby.gnut b/Northstar.CustomServers/scripts/vscripts/lobby/_lobby.gnut
deleted file mode 100644
index fd877f8c..00000000
--- a/Northstar.CustomServers/scripts/vscripts/lobby/_lobby.gnut
+++ /dev/null
@@ -1,37 +0,0 @@
-untyped
-global function Lobby_Init
-global function Lobby_OnClientConnectionStarted
-global function Lobby_OnClientConnectionCompleted
-
-void function Lobby_Init()
-{
- // need to prevent a crash
- Music_Init()
-
- if ( IsPrivateMatch() || GetCurrentPlaylistName() == "private_match" ) // IsPrivateMatch() doesn't seem to be reliable on local server start
- PrivateLobby_Init()
- else
- {
- // non-private lobby clientcommands
- AddClientCommandCallback( "StartPrivateMatchSearch", ClientCommandCallback_StartPrivateMatchSearch )
- }
-}
-
-void function Lobby_OnClientConnectionStarted( entity player )
-{
-
-}
-
-void function Lobby_OnClientConnectionCompleted( entity player )
-{
- FinishClientScriptInitialization( player )
-}
-
-bool function ClientCommandCallback_StartPrivateMatchSearch( entity player, array<string> args )
-{
- // open lobby in private match mode
- SetCurrentPlaylist( "private_match" ) // required for private match lobby to start properly
- ServerCommand( "changelevel mp_lobby" )
-
- return true
-} \ No newline at end of file
diff --git a/Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut b/Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut
deleted file mode 100644
index 896ab207..00000000
--- a/Northstar.CustomServers/scripts/vscripts/lobby/_private_lobby.gnut
+++ /dev/null
@@ -1,181 +0,0 @@
-// TODO: could probably add some checks for whether player setting stuff is player 0 to check for host, might fail in dedicated tho
-
-global function PrivateLobby_Init
-
-struct {
- int startState
- string map = "mp_forwardbase_kodai"
- string mode = "aitdm"
-} file
-
-void function PrivateLobby_Init()
-{
- print( "PrivateLobby_Init()" )
- ClearPlaylistVarOverrides()
-
- AddClientCommandCallback( "PrivateMatchLaunch", ClientCommandCallback_PrivateMatchLaunch )
- AddClientCommandCallback( "PrivateMatchSetMode", ClientCommandCallback_PrivateMatchSetMode )
- AddClientCommandCallback( "SetCustomMap", ClientCommandCallback_SetCustomMap )
- AddClientCommandCallback( "PrivateMatchSwitchTeams", ClientCommandCallback_PrivateMatchSwitchTeams )
-
- AddClientCommandCallback( "PrivateMatchSetPlaylistVarOverride", ClientCommandCallback_PrivateMatchSetPlaylistVarOverride )
- AddClientCommandCallback( "ResetMatchSettingsToDefault", ClientCommandCallback_ResetMatchSettingsToDefault )
-}
-
-bool function ClientCommandCallback_PrivateMatchLaunch( entity player, array<string> args )
-{
- if ( file.startState == ePrivateMatchStartState.STARTING )
- {
- // cancel start if we're already mid-countdown
- file.startState = ePrivateMatchStartState.READY
- SetUIVar( level, "privatematch_starting", ePrivateMatchStartState.READY )
- SetUIVar( level, "gameStartTime", null )
- }
- else
- {
- // start match
- file.startState = ePrivateMatchStartState.STARTING
- thread StartMatch()
- }
-
- return true
-}
-
-bool function ClientCommandCallback_PrivateMatchSetMode( entity player, array<string> args )
-{
- if ( file.startState == ePrivateMatchStartState.STARTING )
- return true
-
- if ( args.len() != 1 )
- return true
-
- // todo: need to verify this value
- file.mode = args[0]
- //GameRules_SetGameMode( args[0] ) // can't do this here due to out of sync errors with new clients
-
- RefreshPlayerTeams()
-
- SetUIVar( level, "privatematch_mode", GetPrivateMatchModeIndex( args[0] ) )
- return true
-}
-
-bool function ClientCommandCallback_SetCustomMap( entity player, array<string> args )
-{
- if ( file.startState == ePrivateMatchStartState.STARTING )
- return true
-
- if ( args.len() != 1 )
- return true
-
- // todo: need to verify this value
- file.map = args[0]
-
- // todo: this should NOT be necessary, private matches should use an api to register maps in the future rather than hardcoded ids
- // should be removed whenever possible really
- SetUIVar( level, "privatematch_map", GetPrivateMatchMapIndex( args[0] ) )
- return true
-}
-
-bool function ClientCommandCallback_PrivateMatchSwitchTeams( entity player, array<string> args )
-{
- if ( file.startState == ePrivateMatchStartState.STARTING )
- return true
-
- // currently only support 2 teams in private matches
- SetTeam( player, player.GetTeam() == 2 ? 3 : 2 )
- return true
-}
-
-void function StartMatch()
-{
- // set starting uivar
- SetUIVar( level, "privatematch_starting", ePrivateMatchStartState.STARTING )
-
- // start countdown
- SetUIVar( level, "gameStartTime", Time() + 15 )
- float countdownEndTime = Time() + 15.0
-
- // can't use start here because we need to check stuff
- while ( Time() < countdownEndTime )
- {
- // stop if the countdown's been cancelled
- if ( file.startState != ePrivateMatchStartState.STARTING)
- return
-
- WaitFrame()
- }
-
- if ( file.mode in GAMETYPE_TEXT )
- GameRules_SetGameMode( file.mode )
- else
- GameRules_SetGameMode( GetPlaylistGamemodeByIndex( file.mode, 0 ) )
-
- try
- {
- // todo: not every gamemode uses the same playlist as their name! need some code to resolve these manually
- // would be nice if the gamemode api got some tweaks to allow for registering private match gamemodes maybe
- SetCurrentPlaylist( file.mode )
- }
- catch ( exception )
- {
- // temp
- if ( file.mode == "speedball" )
- SetCurrentPlaylist( "lf" )
-
- print( "couldn't find playlist for gamemode " + file.mode )
- }
-
- RefreshPlayerTeams()
-
- SetPlaylistVarOverride( "return_to_private_lobby", "1" )
- // TEMP for now: start game
- ServerCommand( "changelevel " + file.map )
-}
-
-void function RefreshPlayerTeams()
-{
- int maxTeams = GetGamemodeVarOrUseValue( file.mode, "max_teams", "2" ).tointeger()
- int maxPlayers = GetGamemodeVarOrUseValue( file.mode, "max_players", "12" ).tointeger()
-
- // special case for situations where we wrongly assume ffa teams because there's 2 teams/2 players
- if ( maxPlayers == maxTeams && maxTeams > 2 )
- {
- array<entity> players = GetPlayerArray()
- for ( int i = 0; i < players.len(); i++ )
- SetTeam( players[ i ], i + 7 ) // 7 is the lowest ffa team
- }
- else
- {
- bool lastSetMilitia = false
- foreach ( entity player in GetPlayerArray() )
- {
- if ( player.GetTeam() == TEAM_MILITIA || player.GetTeam() == TEAM_IMC )
- continue
-
- if ( lastSetMilitia ) // ensure roughly evenish distribution
- SetTeam( player, TEAM_IMC )
- else
- SetTeam( player, TEAM_MILITIA )
-
- lastSetMilitia = !lastSetMilitia
- }
- }
-}
-
-bool function ClientCommandCallback_PrivateMatchSetPlaylistVarOverride( entity player, array<string> 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<string> args )
-{
- ClearPlaylistVarOverrides()
- return true
-} \ No newline at end of file
diff --git a/Northstar.CustomServers/scripts/vscripts/lobby/sh_lobby.gnut b/Northstar.CustomServers/scripts/vscripts/lobby/sh_lobby.gnut
deleted file mode 100644
index fda0e5ff..00000000
--- a/Northstar.CustomServers/scripts/vscripts/lobby/sh_lobby.gnut
+++ /dev/null
@@ -1,356 +0,0 @@
-globalize_all_functions
-
-const string PRIVATE_MATCH_PLAYLIST = "private_match"
-
-struct {
- array<string> modes = [ // default modes in vanilla
- "aitdm",
- "tdm",
- "cp",
- "at",
- "ctf",
- "lts",
- "ps",
- "speedball",
- "mfd",
- "ttdm",
- "fd_easy",
- "fd_normal",
- "fd_hard",
- "fd_master",
- "fd_insane"
- ]
-
- array<string> maps = [ // default maps in vanilla
- "mp_forwardbase_kodai",
- "mp_grave",
- "mp_homestead",
- "mp_thaw",
- "mp_black_water_canal",
- "mp_eden",
- "mp_drydock",
- "mp_crashsite3",
- "mp_complex3",
- "mp_angel_city",
- "mp_colony02",
- "mp_glitch",
- "mp_relic02",
- "mp_wargames",
- "mp_rise",
- "mp_lf_stacks",
- "mp_lf_deck",
- "mp_lf_meadow",
- "mp_lf_traffic",
- "mp_lf_township",
- "mp_lf_uma"
- ]
-} file
-
-void function AddPrivateMatchMode( string mode )
-{
- if ( !file.modes.contains( mode ) )
- file.modes.append( mode )
-
- #if CLIENT
- // call this on ui too so the client and ui states are the same
- RunUIScript( "AddPrivateMatchMode", mode )
- #endif
-}
-
-void function AddPrivateMatchMap( string map )
-{
- if ( !file.maps.contains( map ) )
- file.maps.append( map )
-
- #if CLIENT
- // call this on ui too so the client and ui states are the same
- RunUIScript( "AddPrivateMatchMap", map )
- #endif
-}
-
-array<string> function GetPrivateMatchModes()
-{
- //array<string> modesArray
- //
- //int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST )
- //for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ )
- //{
- // modesArray.append( GetPlaylistGamemodeByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex ) )
- //}
-
- //return modesArray
-
- return file.modes
-}
-
-int function GetPrivateMatchModeIndex( string modeName )
-{
- //int indexForName = 0
- //
- //int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST )
- //for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ )
- //{
- // if ( GetPlaylistGamemodeByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex ) != modeName )
- // continue
- //
- // indexForName = modeIndex;
- // break
- //}
- //
- //return indexForName
-
- return file.modes.find( modeName )
-}
-
-
-array<string> function GetPrivateMatchMapsForMode( string modeName )
-{
- //array<string> mapsArray
- //
- //int modeIndex = GetPrivateMatchModeIndex( modeName )
- //int numMaps = GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, modeIndex )
- //for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ )
- //{
- // mapsArray.append( GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex, mapIndex ) )
- //}
- //
- //return mapsArray
-
- array<string> maps
-
- // use the private match playlist for this if the gamemode is in it already
- int privatePlaylistModeIndex = GetPrivateMatchModeIndex( modeName )
- if ( privatePlaylistModeIndex < GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST ) )
- {
- for ( int i = 0; i < GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, privatePlaylistModeIndex ); i++ )
- maps.append( GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, privatePlaylistModeIndex, i ) )
- }
- else
- {
- int numMaps = GetPlaylistGamemodeByIndexMapsCount( modeName, 0 )
- for ( int i = 0; i < numMaps; i++ )
- maps.append( GetPlaylistGamemodeByIndexMapByIndex( modeName, 0, i ) )
- }
-
- return maps
-}
-
-// never called
-/*array<string> function GetPrivateMatchModesForMap( string mapName )
-{
- array<string> modesArray
-
- int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST )
- for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ )
- {
- int numMaps = GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, modeIndex )
- for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ )
- {
- if ( GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex, mapIndex ) != mapName )
- continue
-
- modesArray.append( GetPlaylistGamemodeByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex ) )
- }
- }
-
- return modesArray
-}*/
-
-
-string function GetPrivateMatchMapForIndex( int index )
-{
- array<string> mapsArray = GetPrivateMatchMaps()
-
- if ( index >= mapsArray.len() || index < 0 )
- return ""
-
- return mapsArray[index]
-}
-
-string function GetPrivateMatchModeForIndex( int index )
-{
- array<string> modesArray = GetPrivateMatchModes()
-
- if ( index >= modesArray.len() || index < 0 )
- return ""
-
- return modesArray[index]
-}
-
-int function GetPrivateMatchMapIndex( string mapName )
-{
- array<string> mapsArray = GetPrivateMatchMaps()
- for ( int index = 0; index < mapsArray.len(); index++ )
- {
- if ( mapsArray[index] == mapName )
- return index
- }
-
- return 0
-}
-/*
-int function GetPrivateMatchModeIndex( string modeName )
-{
- array<string> modesArray = GetPrivateMatchModes()
- for ( int index = 0; index < modesArray.len(); index++ )
- {
- if ( modesArray[index] == modeName )
- return index
- }
-
- return 0
-}
-*/
-
-array<string> function GetPrivateMatchMaps()
-{
- //array<string> mapsArray
- //
- //int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST )
- //for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ )
- //{
- // int numMaps = GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, modeIndex )
- // for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ )
- // {
- // string mapName = GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex, mapIndex )
- // if ( mapsArray.contains( mapName ) )
- // continue
- //
- // mapsArray.append( mapName )
- // }
- //}
- //
- //return mapsArray
-
- return file.maps
-}
-
-
-
-array<string> function GetPlaylistMaps( string playlistName )
-{
- array<string> mapsArray
-
- int numModes = GetPlaylistGamemodesCount( playlistName )
- for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ )
- {
- int numMaps = GetPlaylistGamemodeByIndexMapsCount( playlistName, modeIndex )
- for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ )
- {
- string mapName = GetPlaylistGamemodeByIndexMapByIndex( playlistName, modeIndex, mapIndex )
- if ( mapsArray.contains( mapName ) )
- continue
-
- mapsArray.append( mapName )
- }
- }
-
- return mapsArray
-}
-
-
-bool function MapSettings_SupportsTitans( string mapName )
-{
- if ( mapName.find( "mp_lf_") != null )
- return false
-
- if ( mapName.find( "coliseum" ) != null )
- return false;
-
- return true
-}
-
-bool function MapSettings_SupportsAI( string mapName )
-{
- if ( mapName.find( "mp_lf_") != null )
- return false
-
- if ( mapName.find( "coliseum" ) != null )
- return false;
-
- return true
-}
-
-
-bool function ModeSettings_RequiresTitans( string modeName )
-{
- switch ( modeName )
- {
- case "lts":
- return true
- }
-
- return false
-}
-
-bool function ModeSettings_RequiresAI( string modeName )
-{
- switch ( modeName )
- {
- case "aitdm":
- case "at":
- return true
- }
-
- return false
-}
-
-#if !CLIENT
-string function PrivateMatch_GetSelectedMap()
-{
- var mapIndex = level.ui.privatematch_map
- string mapName = GetPrivateMatchMapForIndex( expect int(mapIndex) )
-
- return mapName
-}
-
-
-string function PrivateMatch_GetSelectedMode()
-{
- var modeIndex = level.ui.privatematch_mode
- string modeName = GetPrivateMatchModeForIndex( expect int(modeIndex) )
-
- return modeName
-}
-#endif
-
-bool function PrivateMatch_IsValidMapModeCombo( string mapName, string modeName )
-{
- array<string> mapsForMode = GetPrivateMatchMapsForMode( modeName )
-
- return mapsForMode.contains( mapName )
-}
-
-// end private match stuff
-
-int function Player_GetMaxMatchmakingDelay( entity player )
-{
- // return GetCurrentPlaylistVarInt( "matchmaking_delay", 0 )
- return 300
-}
-
-int function Player_GetRemainingMatchmakingDelay( entity player )
-{
- int lastLeaveTime = player.GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME )
-
- return Player_GetMaxMatchmakingDelay( player ) - (GetCurrentTimeForPersistence() - lastLeaveTime)
-}
-
-int function Player_NextAvailableMatchmakingTime( entity player )
-{
- #if MP
- int lastLeaveTime = player.GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME )
- if ( GetCurrentTimeForPersistence() - lastLeaveTime < Player_GetMaxMatchmakingDelay( player ) )
- {
- return Player_GetRemainingMatchmakingDelay( player )
- }
- #endif
-
- return 0
-}
-
-int function GetCurrentTimeForPersistence()
-{
- // Returns the unix timestap offset to the timezone we want to use
- return GetUnixTimestamp() + DAILY_RESET_TIME_ZONE_OFFSET * SECONDS_PER_HOUR
-}
diff --git a/Northstar.CustomServers/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut b/Northstar.CustomServers/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut
deleted file mode 100644
index b1474a15..00000000
--- a/Northstar.CustomServers/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut
+++ /dev/null
@@ -1,21 +0,0 @@
-global function PrivateMatchModesInit
-
-void function PrivateMatchModesInit()
-{
- // modes
- AddPrivateMatchMode( "ffa" )
- AddPrivateMatchMode( "fra" )
- AddPrivateMatchMode( "coliseum" )
-
- // playlists
- AddPrivateMatchMode( "attdm" )
- AddPrivateMatchMode( "turbo_ttdm" )
- AddPrivateMatchMode( "alts" )
- AddPrivateMatchMode( "turbo_lts" )
- AddPrivateMatchMode( "rocket_lf" )
- AddPrivateMatchMode( "holopilot_lf" )
-
- // maps
- AddPrivateMatchMap( "mp_coliseum" )
- AddPrivateMatchMap( "mp_coliseum_column" )
-} \ No newline at end of file