diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-08 03:19:49 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-08 03:19:49 +0000 |
commit | d888352dc05c2b5ba89ff2e40c4a4d1acc1e4e0a (patch) | |
tree | c4e6aa9276d109ec7c7728dc8a8f2ebe38564acc /Northstar.CustomServers/mod/scripts/vscripts/mp | |
parent | 42f66d01d16b0d562fa08e3f5a1bc66e97ef5c43 (diff) | |
download | NorthstarMods-d888352dc05c2b5ba89ff2e40c4a4d1acc1e4e0a.tar.gz NorthstarMods-d888352dc05c2b5ba89ff2e40c4a4d1acc1e4e0a.zip |
add GetWinningTeamWithFFASupport for timeout winning checks
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut index 598b4522..2d39cf2d 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut @@ -15,6 +15,7 @@ global function SetRoundWinningKillReplayAttacker global function SetWinner global function SetTimeoutWinnerDecisionFunc global function AddTeamScore +global function GetWinningTeamWithFFASupport global function GameState_GetTimeLimitOverride global function IsRoundBasedGameOver @@ -231,10 +232,7 @@ void function GameStateEnter_Playing_Threaded() if ( file.timeoutWinnerDecisionFunc != null ) winningTeam = file.timeoutWinnerDecisionFunc() else - winningTeam = GetWinningTeam() - - if ( winningTeam == -1 ) - winningTeam = TEAM_UNASSIGNED + winningTeam = GetWinningTeamWithFFASupport() if ( file.switchSidesBased && !file.hasSwitchedSides && !IsRoundBased() ) // in roundbased modes, we handle this in setwinner SetGameState( eGameState.SwitchingSides ) @@ -264,9 +262,7 @@ void function GameStateEnter_WinnerDetermined() void function GameStateEnter_WinnerDetermined_Threaded() { // do win announcement - int winningTeam = GetWinningTeam() - if ( winningTeam == -1 ) - winningTeam = TEAM_UNASSIGNED + int winningTeam = GetWinningTeamWithFFASupport() foreach ( entity player in GetPlayerArray() ) { @@ -334,9 +330,7 @@ void function GameStateEnter_WinnerDetermined_Threaded() int roundsPlayed = expect int ( GetServerVar( "roundsPlayed" ) ) SetServerVar( "roundsPlayed", roundsPlayed + 1 ) - int winningTeam = GetWinningTeam() - if ( winningTeam == -1 ) - winningTeam = TEAM_UNASSIGNED + int winningTeam = GetWinningTeamWithFFASupport() int highestScore = GameRules_GetTeamScore( winningTeam ) int roundScoreLimit = GameMode_GetRoundScoreLimit( GAMETYPE ) @@ -801,6 +795,35 @@ void function SetTimeoutWinnerDecisionFunc( int functionref() callback ) file.timeoutWinnerDecisionFunc = callback } +int function GetWinningTeamWithFFASupport() +{ + if ( !IsFFAGame() ) + return GameScore_GetWinningTeam() + else + { + // custom logic for calculating ffa winner as GameScore_GetWinningTeam doesn't handle this + int winningTeam = TEAM_UNASSIGNED + int winningScore = 0 + + foreach ( entity player in GetPlayerArray() ) + { + int currentScore = GameRules_GetTeamScore( player.GetTeam() ) + + if ( currentScore == winningScore ) + winningTeam = TEAM_UNASSIGNED // if 2 teams are equal, return TEAM_UNASSIGNED + else if ( currentScore > winningScore ) + { + winningTeam = player.GetTeam() + winningScore = currentScore + } + } + + return winningTeam + } + + unreachable +} + // idk float function GameState_GetTimeLimitOverride() |