aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut')
-rw-r--r--Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut49
1 files changed, 49 insertions, 0 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut
new file mode 100644
index 000000000..27581aeac
--- /dev/null
+++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut
@@ -0,0 +1,49 @@
+untyped
+global function GamemodeSbox_Init
+
+struct {
+ array<entity> spawnpoints
+} file
+
+void function GamemodeSbox_Init()
+{
+ SetConVarInt( "sv_cheats", 1 ) // cheats on by default
+
+ // cache spawnpoints
+ //file.spawnpoints = GetEntArrayByClass_Expensive( "info_spawnpoint_human" )
+ // todo just use a spawn callback for this rather than weird late cache in spawn
+
+ AddCallback_OnClientConnected( SboxSpawnPlayer )
+ AddDeathCallback( "player", SboxRespawnPlayer )
+}
+
+void function SboxSpawnPlayer( entity player )
+{
+ if ( player.GetPlayerSettings() == "spectator" ) // if they haven't spawned yet
+ player.SetPlayerSettings( "pilot_grapple_male" )
+
+ if ( file.spawnpoints.len() == 0 ) // have to cache late rather than on init due to spawnpoints not existing in init
+ file.spawnpoints = GetEntArrayByClass_Expensive( "info_spawnpoint_human" )
+
+ if ( GetGameState() != eGameState.Playing ) // hacky but can't set this in init either
+ SetGameState( eGameState.Playing )
+
+ entity spawnpoint = file.spawnpoints[ RandomInt( file.spawnpoints.len() ) ]
+
+ ScreenFadeFromBlack( player, 0.0, 0.0 ) // HACK before non-classicmp intros are ready, remove the blackscreen we get from waitingforplayers
+ player.RespawnPlayer( spawnpoint )
+ player.GiveWeapon( "mp_weapon_toolgun" )
+}
+
+void function SboxRespawnPlayer( entity player, var damageInfo )
+{
+ thread SboxRespawnPlayerThreaded( player )
+}
+
+void function SboxRespawnPlayerThreaded( entity player )
+{
+ // todo: replace this with real respawn logic when that's ready
+
+ wait 2.5
+ SboxSpawnPlayer( player )
+} \ No newline at end of file