diff options
author | Zanieon <william-millennium@hotmail.com> | 2024-08-30 15:08:38 +0200 |
---|---|---|
committer | Zanieon <william-millennium@hotmail.com> | 2024-08-30 15:08:38 +0200 |
commit | dafc1d1e9729093b00fd27bc3083133f6af4d4b7 (patch) | |
tree | 612b91da2567c753dbe6e18adeb79ec6f8a1e7e8 /Northstar.CustomServers | |
parent | c674e3c0583c5c8eca136a5ebeb5ed2ac6cae6c4 (diff) | |
download | NorthstarMods-dafc1d1e9729093b00fd27bc3083133f6af4d4b7.tar.gz NorthstarMods-dafc1d1e9729093b00fd27bc3083133f6af4d4b7.zip |
Move `CaptureFlag` function
as part of the refactoring effort in #830
Diffstat (limited to 'Northstar.CustomServers')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut | 123 |
1 files changed, 62 insertions, 61 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut index 72f43e18..7375d199 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut @@ -287,6 +287,68 @@ void function GiveFlag( entity player, entity flag ) SetFlagStateForTeam( flag.GetTeam(), eFlagState.Away ) // used for held } +void function CaptureFlag( entity player, entity flag ) +{ + // can only capture flags during normal play or sudden death + if (GetGameState() != eGameState.Playing && GetGameState() != eGameState.SuddenDeath) + { + printt( player + " tried to capture the flag, but the game state was " + GetGameState() + " not " + eGameState.Playing + " or " + eGameState.SuddenDeath) + return + } + // reset flag + ResetFlag( flag ) + + print( player + " captured the flag!" ) + + // score + int team = player.GetTeam() + AddTeamScore( team, 1 ) + AddPlayerScore( player, "FlagCapture", player ) + player.AddToPlayerGameStat( PGS_ASSAULT_SCORE, 1 ) // add 1 to captures on scoreboard + SetRoundWinningKillReplayAttacker( player ) // set attacker for last cap replay + + array<entity> assistList + if ( player.GetTeam() == TEAM_IMC ) + assistList = file.imcCaptureAssistList + else + assistList = file.militiaCaptureAssistList + + foreach( entity assistPlayer in assistList ) + { + if ( player != assistPlayer ) + AddPlayerScore( assistPlayer, "FlagCaptureAssist", player ) + if( !HasPlayerCompletedMeritScore( assistPlayer ) ) + { + AddPlayerScore( assistPlayer, "ChallengeCTFCapAssist" ) + SetPlayerChallengeMeritScore( assistPlayer ) + } + } + + assistList.clear() + + // notifs + MessageToPlayer( player, eEventNotifications.YouCapturedTheEnemyFlag ) + EmitSoundOnEntityOnlyToPlayer( player, player, "UI_CTF_1P_PlayerScore" ) + + if( !HasPlayerCompletedMeritScore( player ) ) + { + AddPlayerScore( player, "ChallengeCTFRetAssist" ) + SetPlayerChallengeMeritScore( player ) + } + + MessageToTeam( team, eEventNotifications.PlayerCapturedEnemyFlag, player, player ) + EmitSoundOnEntityToTeamExceptPlayer( flag, "UI_CTF_3P_TeamScore", player.GetTeam(), player ) + + MessageToTeam( GetOtherTeam( team ), eEventNotifications.PlayerCapturedFriendlyFlag, player, player ) + EmitSoundOnEntityToTeam( flag, "UI_CTF_3P_EnemyScores", flag.GetTeam() ) + + if ( GameRules_GetTeamScore( team ) == GameMode_GetRoundScoreLimit( GAMETYPE ) - 1 ) + { + PlayFactionDialogueToTeam( "ctf_notifyWin1more", team ) + PlayFactionDialogueToTeam( "ctf_notifyLose1more", GetOtherTeam( team ) ) + } +} + void function DropFlag( entity player, bool realDrop = true ) { entity flag = GetFlagForTeam( GetOtherTeam( player.GetTeam() ) ) @@ -351,67 +413,6 @@ void function ResetFlag( entity flag ) flag.Signal( "ResetDropTimeout" ) } -void function CaptureFlag( entity player, entity flag ) -{ - // can only capture flags during normal play or sudden death - if (GetGameState() != eGameState.Playing && GetGameState() != eGameState.SuddenDeath) - { - printt( player + " tried to capture the flag, but the game state was " + GetGameState() + " not " + eGameState.Playing + " or " + eGameState.SuddenDeath) - return - } - // reset flag - ResetFlag( flag ) - - print( player + " captured the flag!" ) - - // score - int team = player.GetTeam() - AddTeamScore( team, 1 ) - AddPlayerScore( player, "FlagCapture", player ) - player.AddToPlayerGameStat( PGS_ASSAULT_SCORE, 1 ) // add 1 to captures on scoreboard - SetRoundWinningKillReplayAttacker( player ) // set attacker for last cap replay - - array<entity> assistList - if ( player.GetTeam() == TEAM_IMC ) - assistList = file.imcCaptureAssistList - else - assistList = file.militiaCaptureAssistList - - foreach( entity assistPlayer in assistList ) - { - if ( player != assistPlayer ) - AddPlayerScore( assistPlayer, "FlagCaptureAssist", player ) - if( !HasPlayerCompletedMeritScore( assistPlayer ) ) - { - AddPlayerScore( assistPlayer, "ChallengeCTFCapAssist" ) - SetPlayerChallengeMeritScore( assistPlayer ) - } - } - - assistList.clear() - - // notifs - MessageToPlayer( player, eEventNotifications.YouCapturedTheEnemyFlag ) - EmitSoundOnEntityOnlyToPlayer( player, player, "UI_CTF_1P_PlayerScore" ) - - if( !HasPlayerCompletedMeritScore( player ) ) - { - AddPlayerScore( player, "ChallengeCTFRetAssist" ) - SetPlayerChallengeMeritScore( player ) - } - - MessageToTeam( team, eEventNotifications.PlayerCapturedEnemyFlag, player, player ) - EmitSoundOnEntityToTeamExceptPlayer( flag, "UI_CTF_3P_TeamScore", player.GetTeam(), player ) - - MessageToTeam( GetOtherTeam( team ), eEventNotifications.PlayerCapturedFriendlyFlag, player, player ) - EmitSoundOnEntityToTeam( flag, "UI_CTF_3P_EnemyScores", flag.GetTeam() ) - - if ( GameRules_GetTeamScore( team ) == GameMode_GetRoundScoreLimit( GAMETYPE ) - 1 ) - { - PlayFactionDialogueToTeam( "ctf_notifyWin1more", team ) - PlayFactionDialogueToTeam( "ctf_notifyLose1more", GetOtherTeam( team ) ) - } -} void function OnPlayerEntersFlagReturnTrigger( entity trigger, entity player ) { |