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) --- .../northstar_client_localisation_english.txt | 1 + .../northstar_client_localisation_tchinese.txt | 1 + Northstar.CustomServers/mod.json | 8 +++++ .../mod/scripts/vscripts/_respawn_protection.gnut | 39 ++++++++++++++++++++++ .../mod/scripts/vscripts/_utility.gnut | 2 +- .../lobby/sh_private_lobby_modes_init.gnut | 1 + 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Northstar.CustomServers/mod/scripts/vscripts/_respawn_protection.gnut diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt index 4f2e7a771..ae84e7c4f 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt @@ -55,6 +55,7 @@ Press Yes if you agree to this. This choice can be changed in the mods menu at a "roundscorelimit" "Score Limit (round-based)" "timelimit" "Time Limit" "roundtimelimit" "Time Limit (round-based)" + "respawnprotection" "Respawn Protection Time" "pilot_health_multiplier" "Health multiplier" "respawn_delay" "Respawn Delay" diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt b/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt index c00e73024..a8d6b811d 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt @@ -52,6 +52,7 @@ "roundscorelimit" "分數限制(回合制)" "timelimit" "時間限制" "roundtimelimit" "時間限制(回合制)" + "respawnprotection" "重生保護時間" "pilot_health_multiplier" "生命值加成" "respawn_delay" "重生延遲" diff --git a/Northstar.CustomServers/mod.json b/Northstar.CustomServers/mod.json index 9388b16f7..e7c00daa4 100644 --- a/Northstar.CustomServers/mod.json +++ b/Northstar.CustomServers/mod.json @@ -104,6 +104,14 @@ { "Path": "lobby/sh_private_lobby_modes_init.gnut", "RunOn": "( SERVER || CLIENT ) && MP" + }, + + { + "Path": "_respawn_protection.gnut", + "RunOn": "SERVER && MP", + "ServerCallback": { + "Before": "RespawnProtection_Init" + } } ] } \ No newline at end of file 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 000000000..2fb177677 --- /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 59bba002d..1644afd94 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 68d6a5d7f..719ea3361 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