diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-08-31 23:14:58 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-08-31 23:14:58 +0100 |
commit | 9a96d0bff56f1969c68bb52a2f33296095bdc67d (patch) | |
tree | 4175928e488632705692e3cccafa1a38dd854615 /Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut | |
parent | 27bd240871b7c0f2f49fef137718b2e3c208e3b4 (diff) | |
download | NorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.tar.gz NorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.zip |
move to new mod format
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut')
-rw-r--r-- | Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_sbox.gnut | 49 |
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 |