diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-05-06 18:20:02 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-05-06 18:20:02 +0100 |
commit | fdc06d48b37147cc305d9563ef8c49c37f08fdc0 (patch) | |
tree | 4b51bf128f0978be529aa0d34465b5d9bc0a9962 /Northstar.CustomServers | |
parent | 2278a4e74642fa6b8f9f61508277ac23644366c2 (diff) | |
download | NorthstarMods-maybe-better-ctf-spawns-pr.tar.gz NorthstarMods-maybe-better-ctf-spawns-pr.zip |
properly swap flag teamsmaybe-better-ctf-spawns-pr
Diffstat (limited to 'Northstar.CustomServers')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut index 07c984be..567aebee 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut @@ -6,6 +6,7 @@ global function RateSpawnpoints_CTF const int CTF_TEAMCOUNT = 2 struct { + bool lastSwitchedSides = false table< int, array<entity> > captureAssists } file @@ -422,19 +423,28 @@ void function CTFStartGame() // setup stuff for the functions in shared gamemode scripts // have to do this here so GameHasFlags() works fine level.teamFlags <- {} + + bool switchedSides = HasSwitchedSides() == 1 + // if we switch sides, swap flag spawns + if ( switchedSides != file.lastSwitchedSides ) + { + entity tempSpawn = svGlobal.flagSpawnPoints[ TEAM_IMC ] + svGlobal.flagSpawnPoints[ TEAM_IMC ] = svGlobal.flagSpawnPoints[ TEAM_MILITIA ] + svGlobal.flagSpawnPoints[ TEAM_MILITIA ] = tempSpawn + + file.lastSwitchedSides = switchedSides + } int team = TEAM_IMC for ( int i = 0; i < CTF_TEAMCOUNT; i++, team++ ) - { - int spawnTeam = HasSwitchedSides() ? GetOtherTeam( team ) : team - + { // create flag base entity flagBase = CreatePropDynamic( CTF_FLAG_BASE_MODEL, svGlobal.flagSpawnPoints[ team ].GetOrigin(), svGlobal.flagSpawnPoints[ team ].GetAngles(), 0 ) - SetTeam( flagBase, spawnTeam ) + SetTeam( flagBase, team ) // create the flag's return trigger entity flagReturnTrigger = CreateEntity( "trigger_cylinder" ) - SetTeam( flagReturnTrigger, spawnTeam ) + SetTeam( flagReturnTrigger, team ) flagReturnTrigger.SetRadius( CTF_GetFlagReturnRadius() ) flagReturnTrigger.SetAboveHeight( CTF_GetFlagReturnRadius() ) @@ -449,13 +459,13 @@ void function CTFStartGame() entity flag = CreateEntity( "item_flag" ) flag.SetValueForModelKey( CTF_FLAG_MODEL ) flag.MarkAsNonMovingAttachment() - SetTeam( flag, spawnTeam ) + SetTeam( flag, team ) DispatchSpawn( flag ) flag.SetModel( CTF_FLAG_MODEL ) flag.s.base <- flagBase flag.s.returnTrigger <- flagReturnTrigger - level.teamFlags[ spawnTeam ] <- flag + level.teamFlags[ team ] <- flag Flag_Reset( flag, false ) thread FlagLifetime( flag ) @@ -463,7 +473,7 @@ void function CTFStartGame() file.captureAssists[ team ] <- [] SetGlobalNetEnt( team == TEAM_IMC ? "imcFlagHome" : "milFlagHome", flagBase ) - SetFlagStateForTeam( spawnTeam, eFlagState.None ) + SetFlagStateForTeam( team, eFlagState.None ) } // init all players |