diff options
Diffstat (limited to 'Northstar.CustomServers')
8 files changed, 107 insertions, 58 deletions
diff --git a/Northstar.CustomServers/mod.json b/Northstar.CustomServers/mod.json index d3740a12..1c08f9ba 100644 --- a/Northstar.CustomServers/mod.json +++ b/Northstar.CustomServers/mod.json @@ -53,6 +53,11 @@ "Name": "ns_progression_enabled", "DefaultValue": "0", "Flags": "ARCHIVE_PLAYERPROFILE" + }, + { + "Name": "ns_allow_team_change", + "DefaultValue": "1", + "Flags": "REPLICATED" } ], "Scripts": [ diff --git a/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut index a20e7aa0..21723ab5 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut @@ -91,6 +91,8 @@ void function EarnMeterMP_PlayerLifeThink( entity player ) EarnObject pilotReward = PlayerEarnMeter_GetReward( player ) float pilotRewardFrac = PlayerEarnMeter_GetRewardFrac( player ) int lastEarnMeterMode = PlayerEarnMeter_GetMode( player ) + bool saidTitanSoon = false + bool titanReadyMsg = false float lastPassiveGainTime = Time() OnThreadEnd( @@ -148,8 +150,22 @@ void function EarnMeterMP_PlayerLifeThink( entity player ) if ( lastEarnMeterMode == eEarnMeterMode.DEFAULT ) { + if ( Riff_TitanAvailability() != eTitanAvailability.Never ) + { + if ( PlayerEarnMeter_GetOwnedFrac( player ) >= 0.75 && PlayerEarnMeter_GetOwnedFrac( player ) < 0.95 && !saidTitanSoon ) + { + PlayFactionDialogueToPlayer( "mp_titanSoon", player ) + saidTitanSoon = true + } + else if( PlayerEarnMeter_GetOwnedFrac( player ) < 0.75 ) + saidTitanSoon = false + } + if ( PlayerEarnMeter_GetOwnedFrac( player ) < 1.0 ) + { PlayerEarnMeter_DisableGoal( player ) + titanReadyMsg = false + } else if ( player.GetPlayerNetInt( "goalState" ) != eRewardState.UNAVAILABLE ) { // if goal is enabled then the client will show "titan ready" alerts even if it isn't @@ -157,6 +173,11 @@ void function EarnMeterMP_PlayerLifeThink( entity player ) // so unfortunately we have to do this manually player.SetPlayerNetInt( "goalState", eRewardState.AVAILABLE ) PlayerEarnMeter_RefreshGoal( player ) + if( !titanReadyMsg ) + { + Remote_CallFunction_NonReplay( player, "ServerCallback_TitanReadyMessage" ) + titanReadyMsg = true + } } if ( Time() - lastPassiveGainTime > 4.0 && file.passiveMeterGainEnabled ) // this might be 5.0 diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_spawnpoints.gnut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_spawnpoints.gnut deleted file mode 100644 index e69de29b..00000000 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_spawnpoints.gnut +++ /dev/null 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 b77a37b2..6b4e82d6 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -18,6 +18,7 @@ global function TrackTitanDamageInPlayerGameStat global function ShouldEntTakeDamage_SPMP global function GetTitanBuildTime global function TitanPlayerHotDropsIntoLevel +global function SetGamemodeAllowsTeamSwitch global function SetRecalculateRespawnAsTitanStartPointCallback @@ -30,10 +31,13 @@ struct { array<entity> specCams entity functionref( entity player, entity basePoint ) recalculateRespawnAsTitanStartPointCallback + table<entity, float> playerChangeTeamTimeBuffer + bool gamemodeTeamSwitchEnabled = true } file void function BaseGametype_Init_MPSP() { + AddClientCommandCallback( "changeteam", ClientCommandCallbackChangeTeam ) AddSpawnCallback( "info_intermission", SetIntermissionCamera ) AddPostDamageCallback( "player", AddToTitanDamageStat ) @@ -630,6 +634,51 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref file.recalculateRespawnAsTitanStartPointCallback = callbackFunc } +void function SetGamemodeAllowsTeamSwitch( bool enabled ) +{ + file.gamemodeTeamSwitchEnabled = enabled +} + +bool function ClientCommandCallbackChangeTeam( entity player, array<string> args ) +{ + if ( !GetConVarBool( "ns_allow_team_change" ) || IsPrivateMatchSpectator( player ) ) + return true + + if ( !file.gamemodeTeamSwitchEnabled ) + { + SendHudMessage( player, "#TEAMSWITCH_GAMEMODE", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + return true + } + + if ( !( player in file.playerChangeTeamTimeBuffer ) ) + { + file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5.0 + } + else + { + if ( file.playerChangeTeamTimeBuffer[ player ] > Time() ) + { + SendHudMessage( player, "#TEAMSWITCH_BUFFER", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + return true + } + } + + if ( player in file.playerChangeTeamTimeBuffer && file.playerChangeTeamTimeBuffer[ player ] < Time() ) + file.playerChangeTeamTimeBuffer[ player ] = Time() + 5.0 + + if ( !GamePlaying() ) + { + SendHudMessage( player, "#TEAMSWITCH_GAMEPLAY", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + return true + } + if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() ) + SetTeam( player, GetOtherTeam( player.GetTeam() ) ) + else + SendHudMessage( player, "#TEAMSWITCH_DISABLED", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + + return true +} + // stuff to change later bool function ShouldEntTakeDamage_SPMP( entity ent, var damageInfo ) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut index 0c66f5a9..17323c38 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut @@ -226,37 +226,7 @@ void function SetWinner( int team, string winningReason = "", string losingReaso SetGameState( eGameState.WinnerDetermined ) ScoreEvent_MatchComplete( team ) - array<entity> players = GetPlayerArray() - int functionref( entity, entity ) compareFunc = GameMode_GetScoreCompareFunc( GAMETYPE ) - if ( compareFunc != null ) - { - players.sort( compareFunc ) - int playerCount = players.len() - int currentPlace = 1 - for ( int i = 0; i < 3; i++ ) - { - if ( i >= playerCount ) - continue - - if ( i > 0 && compareFunc( players[i - 1], players[i] ) != 0 ) - currentPlace += 1 - - switch( currentPlace ) - { - case 1: - UpdatePlayerStat( players[i], "game_stats", "mvp" ) - UpdatePlayerStat( players[i], "game_stats", "mvp_total" ) - UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" ) - break - case 2: - UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" ) - break - case 3: - UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" ) - break - } - } - } + RegisterMatchStats_OnMatchComplete() } } } diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut index 74a9088b..84b09ec8 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut @@ -13,6 +13,7 @@ global function UpdateTitanCoreEarnedStat global function PreScoreEventUpdateStats global function PostScoreEventUpdateStats global function Stats_OnPlayerDidDamage +global function RegisterMatchStats_OnMatchComplete struct { table< string, array<string> > refs @@ -36,7 +37,6 @@ void function Stats_Init() AddCallback_OnPlayerRespawned( OnPlayerRespawned ) AddCallback_OnClientConnected( OnClientConnected ) AddCallback_OnClientDisconnected( OnClientDisconnected ) - AddCallback_GameStateEnter( eGameState.WinnerDetermined, OnWinnerDetermined ) thread HandleDistanceAndTimeStats_Threaded() thread SaveStatsPeriodically_Threaded() @@ -813,7 +813,7 @@ void function OnPlayerRespawned( entity player ) thread SetLastPosForDistanceStatValid_Threaded( player, true ) } -void function OnWinnerDetermined() +void function RegisterMatchStats_OnMatchComplete() { // award players for match completed, wins, and losses foreach ( entity player in GetPlayerArray() ) @@ -888,30 +888,28 @@ void function OnWinnerDetermined() player.SetPersistentVar( "kdratio_lifetime_pvp", kdratio_lifetimepvp ) } - // award mvp and top 3 in each team - if ( !IsFFAGame() ) + array<entity> players = GetPlayerArray() + players.sort( GetScoreboardCompareFunc() ) + int playerCount = players.len() + int currentPlace = 1 + for ( int i = 0; i < 3; i++ ) { - string gamemode = GameRules_GetGameMode() - int functionref( entity, entity ) compareFunc = GameMode_GetScoreCompareFunc( gamemode ) - - for( int team = 0; team < MAX_TEAMS; team++ ) + if ( i >= playerCount ) + continue + + int functionref( entity, entity ) compareFunc = GetScoreboardCompareFunc() + if ( i > 0 && compareFunc( players[i - 1], players[i] ) != 0 ) + currentPlace += 1 + switch( currentPlace ) { - array<entity> players = GetPlayerArrayOfTeam( team ) - if ( compareFunc == null ) - { - printt( "gamemode doesn't have a compare func to get the top 3" ) - return - } - players.sort( compareFunc ) - int maxAwards = int( min( players.len(), 3 ) ) - for ( int i = 0; i < maxAwards; i++ ) - { - if ( i == 0 ) - Stats_IncrementStat( players[ i ], "game_stats", "mvp", "", 1.0 ) - Stats_IncrementStat( players[ i ], "game_stats", "top3OnTeam", "", 1.0 ) - } + case 1: // MVP have two parallel stats which one registers MVP for the map played and the other goes to the player's stats menu as a total MVP times + UpdatePlayerStat( players[i], "game_stats", "mvp" ) + UpdatePlayerStat( players[i], "game_stats", "mvp_total" ) + case 2: + case 3: + UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" ) // Ingame this is the "Times Top 3" for the whole match, not per team + break } - } } diff --git a/Northstar.CustomServers/mod/scripts/vscripts/sh_loadouts.nut b/Northstar.CustomServers/mod/scripts/vscripts/sh_loadouts.nut index 7a7498b8..4bf195b6 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/sh_loadouts.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/sh_loadouts.nut @@ -1509,7 +1509,7 @@ string function GetValidatedPersistentLoadoutValue( entity player, string loadou {
printt( "Invalid Loadout Property: ", loadoutType, loadoutIndex, loadoutProperty, value )
value = ResetLoadoutPropertyToDefault( player, loadoutType, loadoutIndex, loadoutProperty ) //TODO: This will call player.SetPersistentVar() directly. Awkward to do this in a getter function
- ClientCommand( player, "disconnect #RESETTING_LOADOUT", 0 ) //Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence
+ NSDisconnectPlayer( player, "#RESETTING_LOADOUT" ) // Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence
}
}
@@ -1519,7 +1519,8 @@ string function GetValidatedPersistentLoadoutValue( entity player, string loadou {
printt( "Invalid Loadout Property: ", loadoutType, loadoutIndex, loadoutProperty, value )
value = ResetLoadoutPropertyToDefault( player, loadoutType, loadoutIndex, loadoutProperty ) //TODO: This will call player.SetPersistentVar() directly. Awkward to do this in a getter function
- ClientCommand( player, "disconnect #RESETTING_LOADOUT", 0 ) //Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence
+ NSDisconnectPlayer( player, "#RESETTING_LOADOUT" ) // Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence
+
}
ValidateSkinAndCamoIndexesAsAPair( player, loadoutType, loadoutIndex, loadoutProperty, value ) //TODO: This is awkward, has the potential to call a SetPersistentLoadoutValue() if skinIndex and camoIndex are not correct as a pair
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut b/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut index 3297643e..307548d7 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut @@ -169,8 +169,13 @@ void function UpdateCachedLoadouts_Threaded() // below here is just making all the menu models update properly and such #if UI - uiGlobal.pilotSpawnLoadoutIndex = GetPersistentSpawnLoadoutIndex( GetUIPlayer(), "pilot" ) - uiGlobal.titanSpawnLoadoutIndex = GetPersistentSpawnLoadoutIndex( GetUIPlayer(), "titan" ) + entity UIPlayer = GetUIPlayer() + + if ( !IsValid( UIPlayer ) ) + return + + uiGlobal.pilotSpawnLoadoutIndex = GetPersistentSpawnLoadoutIndex( UIPlayer, "pilot" ) + uiGlobal.titanSpawnLoadoutIndex = GetPersistentSpawnLoadoutIndex( UIPlayer, "titan" ) #endif #if CLIENT |