From bca681c6e7b2b281a234d1ee9cbd671f97e45cb6 Mon Sep 17 00:00:00 2001 From: zxcPandora <81985226+zxcPandora@users.noreply.github.com> Date: Tue, 15 Feb 2022 12:14:36 +0800 Subject: Add respawn protection match setting (#167) --- .../mod/scripts/vscripts/_respawn_protection.gnut | 39 ++++++++++++++++++++++ .../mod/scripts/vscripts/_utility.gnut | 2 +- .../lobby/sh_private_lobby_modes_init.gnut | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Northstar.CustomServers/mod/scripts/vscripts/_respawn_protection.gnut (limited to 'Northstar.CustomServers/mod') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_respawn_protection.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_respawn_protection.gnut new file mode 100644 index 00000000..2fb17767 --- /dev/null +++ b/Northstar.CustomServers/mod/scripts/vscripts/_respawn_protection.gnut @@ -0,0 +1,39 @@ +global function RespawnProtection_Init + +void function RespawnProtection_Init(){ + AddCallback_OnPlayerRespawned( OnPlayerRespawned ) +} + +void function OnPlayerRespawned( entity player ) +{ + thread RespawnProtection(player,GetCurrentPlaylistVarFloat("respawnprotection",0.0)) +} + +void function RespawnProtection( entity player , float time ){ + OnThreadEnd( + function() : ( player ) + { + //cancel protect if player attack + if( IsDemigod( player ) ) + { + DisableDemigod( player ); + } + } + ) + + player.EndSignal( "OnDeath" ) + player.EndSignal( "OnDestroy" ) + player.EndSignal( "OnPrimaryAttack" ) + + if( IsDemigod( player ) ) + { + DisableDemigod( player ); + } + else{ + //start protect + EnableDemigod( player ) + wait time + //cancel protect + DisableDemigod( player ); + } +} diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut index 59bba002..1644afd9 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut @@ -4401,4 +4401,4 @@ bool function PlayerHasTitan( entity player ) return true return false -} +} \ No newline at end of file diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut index 68d6a5d7..719ea336 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_private_lobby_modes_init.gnut @@ -10,6 +10,7 @@ void function PrivateMatchModesInit() AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_MATCH", "roundscorelimit", "0" ) //, "Score Limit (round-based modes)" ) AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_MATCH", "timelimit", "12" ) //, "Time Limit" ) AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_MATCH", "roundtimelimit", "0" ) //, "Time Limit (round-based modes)" ) + AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_MATCH", "respawnprotection", "0.0" ) //, "Player Respawn Protection Time" ) AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_PILOT", "pilot_health_multiplier", "1.0" ) AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_PILOT", "respawn_delay", "0.0" ) -- cgit v1.2.3