Skip to content

Commit

Permalink
Expose more game state information to DiscordRPC (#869)
Browse files Browse the repository at this point in the history
When playing Frontier Defense it will show when the player is in a Wave Break or which Wave they are currently through
Whenever the server is NOT at the Playing gamestate, the plugin will report the respective states instead such as Selecting Titan screen, Prematch, Epilogue, Postmatch, etc...
  • Loading branch information
Zanieon authored Sep 7, 2024
1 parent 6b839de commit 62b9215
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ global struct GameStateStruct {
int otherHighestScore
int maxScore
float timeEnd
int serverGameState
int fd_waveNumber
int fd_totalWaves
}

global struct UIPresenceStruct {
Expand Down
13 changes: 13 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ GameStateStruct function DiscordRPC_GenerateGameState( GameStateStruct gs )
if ( IsValid( GetLocalClientPlayer() ) )
gs.ownScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() )

if ( GameRules_GetGameMode() == FD )
{
gs.playlist = "fd" // So it returns only one thing to the plugin side instead of the 5 separate difficulties FD have
if ( GetGlobalNetInt( "FD_waveState" ) == WAVE_STATE_INCOMING || GetGlobalNetInt( "FD_waveState" ) == WAVE_STATE_IN_PROGRESS )
{
gs.fd_waveNumber = GetGlobalNetInt( "FD_currentWave" ) + 1
gs.fd_totalWaves = GetGlobalNetInt( "FD_totalWaves" )
}
else
gs.fd_waveNumber = -1 // Tells plugin it's on Wave Break
}

gs.serverGameState = GetGameState() == -1 ? 0 : GetGameState()
gs.otherHighestScore = gs.ownScore == highestScore ? secondHighest : highestScore

gs.maxScore = IsRoundBased() ? GetCurrentPlaylistVarInt( "roundscorelimit", 0 ) : GetCurrentPlaylistVarInt( "scorelimit", 0 )
Expand Down

0 comments on commit 62b9215

Please sign in to comment.