aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.CustomServers')
-rw-r--r--Northstar.CustomServers/mod.json5
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut49
2 files changed, 54 insertions, 0 deletions
diff --git a/Northstar.CustomServers/mod.json b/Northstar.CustomServers/mod.json
index fa51f4d4..6735306e 100644
--- a/Northstar.CustomServers/mod.json
+++ b/Northstar.CustomServers/mod.json
@@ -49,6 +49,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/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 )