aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Coop/scripts/vscripts/client
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-06-22 14:30:49 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-06-22 14:30:49 +0100
commit207facbc402f5639cbcd31f079214351ef605cf2 (patch)
tree4710b2a88dd64f3dfea1609d31a5de9141640951 /Northstar.Coop/scripts/vscripts/client
parentc2d438568df6d98cf731807e30eaa7da31e5ea52 (diff)
downloadNorthstarMods-207facbc402f5639cbcd31f079214351ef605cf2.tar.gz
NorthstarMods-207facbc402f5639cbcd31f079214351ef605cf2.zip
initial commit after moving to new repo
Diffstat (limited to 'Northstar.Coop/scripts/vscripts/client')
-rw-r--r--Northstar.Coop/scripts/vscripts/client/cl_respawnselect_sp.gnut110
1 files changed, 110 insertions, 0 deletions
diff --git a/Northstar.Coop/scripts/vscripts/client/cl_respawnselect_sp.gnut b/Northstar.Coop/scripts/vscripts/client/cl_respawnselect_sp.gnut
new file mode 100644
index 00000000..eab80e98
--- /dev/null
+++ b/Northstar.Coop/scripts/vscripts/client/cl_respawnselect_sp.gnut
@@ -0,0 +1,110 @@
+global function ShowRespawnSelect_SP
+global function ClRespawnselect_SP_Init
+global function DisableDeathBlur
+global function DisplayRespawnPrompt
+
+struct
+{
+ bool deathBlur = false // death blur will stay after respawn if we don't remove it
+ bool canRespawn = false
+ var respawnHintRui
+} file
+
+
+void function ClRespawnselect_SP_Init()
+{
+ Assert( !IsMultiplayer() )
+
+ AddCallback_OnPlayerLifeStateChanged( Callback_PlayerLifestateChanged )
+ file.respawnHintRui = RuiCreate( $"ui/respawn_hint.rpak", clGlobal.topoFullScreen, RUI_DRAW_HUD, RUI_SORT_SCREENFADE + 100 )
+ RuiSetResolutionToScreenSize( file.respawnHintRui )
+
+ // register these early so we don't end up registering multiple times and crashing later
+ RegisterButtonPressedCallback( KEY_SPACE, PlayerPressed_RespawnPilotSP )
+ RegisterButtonPressedCallback( BUTTON_X, PlayerPressed_RespawnPilotSP )
+}
+
+void function Callback_PlayerLifestateChanged( entity player, int oldLifeState, int newLifeState )
+{
+ if ( player.GetPlayerSettings() == "spectator" )
+ {
+ if ( !IsTestMap() )
+ {
+ ScreenFade( GetLocalViewPlayer(), 0, 0, 0, 255, 0.5, 1.0, FFADE_IN )
+ //printt( "cl SCREENFADE: " + 0.5 + " " + 1.0 )
+ }
+ return
+ }
+
+ if ( oldLifeState == newLifeState )
+ return
+
+ if ( player != GetLocalViewPlayer() )
+ return
+
+ //if ( newLifeState == LIFE_DEAD )
+ // thread ShowRespawnSelect_SP()
+}
+
+void function DisableDeathBlur()
+{
+ file.deathBlur = false
+}
+
+void function ShowRespawnSelect_SP()
+{
+}
+
+void function PlayerPressed_RespawnPilotSP( entity player )
+{
+ if ( file.canRespawn )
+ {
+ player.ClientCommand( "RespawnNowSP" )
+ RuiSetBool( file.respawnHintRui, "isVisible", false )
+ file.canRespawn = false
+ }
+}
+
+void function DisplayRespawnPrompt()
+{
+ // move this out of here since otherwise the client will attempt to bind it multiple times which crashes
+ //RegisterButtonPressedCallback( KEY_SPACE, PlayerPressed_RespawnPilotSP )
+ //RegisterButtonPressedCallback( BUTTON_X, PlayerPressed_RespawnPilotSP )
+
+ // delay this so it coincides with serverside respawn delay
+ //RuiSetBool( file.respawnHintRui, "isVisible", true )
+
+ print( "DisplayRespawnPrompt()" )
+ if ( !AreAllPlayersDead() )
+ thread WaitToDisplayRespawnPrompt()
+ else
+ thread LevelFailedEffect()
+}
+
+void function WaitToDisplayRespawnPrompt()
+{
+ print( "waittodisplayrespawnprompt()" )
+ // display respawn ui
+ RuiSetBool( file.respawnHintRui, "isVisible", true )
+
+ entity player = GetLocalViewPlayer()
+ RuiSetGameTime( file.respawnHintRui, "nextSpawnTime", expect float( player.nv.nextRespawnTime ) )
+
+ // wait until we can respawn
+ wait expect float( player.nv.nextRespawnTime ) - Time()
+
+ // wait until server will allow a respawn to enable it
+ file.canRespawn = true
+}
+
+void function LevelFailedEffect()
+{
+ print( "levelfailedeffect()")
+ // display the fade that gets displayed in vanilla on death
+
+ wait 1.5
+ SetScreenBlur( 1.0, 1.0, EASING_LINEAR )
+
+ wait 0.25
+ ScreenFade( GetLocalViewPlayer(), 0, 0, 0, 255, 0.8, 5, FFADE_OUT )
+} \ No newline at end of file