From 95550dcd868bf018c4141eb5ea34158c480b1ca3 Mon Sep 17 00:00:00 2001 From: s1lent Date: Tue, 13 Aug 2019 20:11:27 +0700 Subject: [PATCH] Added cvar respawn_immunity_effects for turn off spawn protection effects also removes spawn protection at player move. Closes #318 --- README.md | 1 + dist/game.cfg | 25 +++++++++++++++---------- regamedll/common/in_buttons.h | 2 ++ regamedll/dlls/game.cpp | 24 +++++++++++++----------- regamedll/dlls/game.h | 1 + regamedll/dlls/player.cpp | 27 ++++++++++++++++++++++----- 6 files changed, 54 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 6d785431..c264b9d0 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure' | mp_item_staytime | 300 | - | - | Time to remove item that have been dropped from the players. | | mp_legacy_bombtarget_touch | 1 | 0 | 1 | Legacy func_bomb_target touch. New one is more strict.
`0` New behavior
`1` Legacy behavior| | mp_respawn_immunitytime | 0 | 0 | - | Specifies the players defense time after respawn. (in seconds).
`0` disabled
`>0.00001` time delay to remove protection | +| mp_respawn_immunity_effects | 1 | 0 | 1 | Enable effects on player spawn protection.
`0` disabled
`1` enable (Use in conjunction with the cvar mp_respawn_immunitytime) | | mp_kill_filled_spawn | 1 | 0 | 1 | Kill the player in filled spawn before spawning some one else (Prevents players stucking in each other).
Only disable this if you have semiclip or other plugins that prevents stucking.
`0` disabled
`1` enabled | | mp_allow_point_servercommand | 0 | 0 | 1 | Allow use of point_servercommand entities in map.
`0` disallow
`1` allow
`NOTE`: Potentially dangerous for untrusted maps.| | mp_hullbounds_sets | 1 | 0 | 1 | Sets mins/maxs hull bounds for the player.
`0` disabled
`1` enabled | diff --git a/dist/game.cfg b/dist/game.cfg index a384ac5f..fb8f3e4e 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -83,7 +83,7 @@ mp_roundrespawn_time 20 // 1 - enabled // // Default value: "0" -mp_auto_reload_weapons "0" +mp_auto_reload_weapons 0 // Refill amount of backpack ammo up to the max // 0 - disabled (default behaviour) @@ -206,7 +206,7 @@ mp_item_staytime 300 // 1 - Legacy behavior // // Default value: "1" -mp_legacy_bombtarget_touch "1" +mp_legacy_bombtarget_touch 1 // Specifies the players defense time after respawn. (in seconds). // 0 - disabled @@ -215,13 +215,20 @@ mp_legacy_bombtarget_touch "1" // Default value: "0" mp_respawn_immunitytime "0" +// Enable effects on player spawn protection +// 0 - disabled +// 1 - enabled (Use in conjunction with the cvar mp_respawn_immunitytime) +// +// Default value: "1" +mp_respawn_immunity_effects 1 + // Kill the player in filled spawn before spawning some one else (Prevents players stucking in each other). // Only disable this if you have semiclip or other plugins that prevents stucking // 0 - disabled // 1 - enabled // // Default value: "1" -mp_kill_filled_spawn "1" +mp_kill_filled_spawn 1 // Allow use of point_servercommand entities in map. // NOTE: Potentially dangerous for untrusted maps. @@ -229,7 +236,7 @@ mp_kill_filled_spawn "1" // 1 - allow // // Default value: "0" -mp_allow_point_servercommand "0" +mp_allow_point_servercommand 0 // Show 'HP' field into a scoreboard // 0 - don't send any update for 'HP' field to any clients @@ -240,7 +247,7 @@ mp_allow_point_servercommand "0" // 5 - show 'HP' field to teammates and spectators // // Default value: "3" -mp_scoreboard_showhealth "3" +mp_scoreboard_showhealth 3 // Show 'Money' field into a scoreboard // 0 - don't send any update for 'Money' field to any clients @@ -251,7 +258,7 @@ mp_scoreboard_showhealth "3" // 5 - show 'Money' field to teammates and spectators // // Default value: "3" -mp_scoreboard_showmoney "3" +mp_scoreboard_showmoney 3 // How much to reduce damage done to teammates when shot. // Range is from 0 - 1 (with 1 being damage equal to what is done to an enemy) @@ -295,7 +302,7 @@ mp_radio_timeout "1.5" // 0 - disable radio messages // // Default value: "60" -mp_radio_maxinround "60" +mp_radio_maxinround 60 // When set, players can buy anywhere, not only in buyzones. // 0 - disabled @@ -304,6 +311,4 @@ mp_radio_maxinround "60" // 3 - only CT team // // Default value: "0" -mp_buy_anywhere "0" - - +mp_buy_anywhere 0 diff --git a/regamedll/common/in_buttons.h b/regamedll/common/in_buttons.h index 0b8cfa51..3b08dd46 100644 --- a/regamedll/common/in_buttons.h +++ b/regamedll/common/in_buttons.h @@ -49,4 +49,6 @@ #define IN_ALT1 (1<<14) #define IN_SCORE (1<<15) // Used by client.dll for when scoreboard is held down +#define IN_ACTIVE (IN_ATTACK | IN_ATTACK2 | IN_JUMP | IN_DUCK | IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT) + #endif // IN_BUTTONS_H diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index c1416ba0..f2c5e8ec 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -110,17 +110,18 @@ cvar_t fraglimit = { "mp_fraglimit", "0", FCVAR_SERVER, 0.0f, nullpt cvar_t round_restart_delay = { "mp_round_restart_delay", "5", FCVAR_SERVER, 0.0f, nullptr }; cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers // TODO: Maybe it's better to register in the engine? -cvar_t hostagehurtable = { "mp_hostage_hurtable", "1", FCVAR_SERVER, 1.0f, nullptr }; -cvar_t roundover = { "mp_roundover", "0", FCVAR_SERVER, 0.0f, nullptr }; -cvar_t forcerespawn = { "mp_forcerespawn", "0", FCVAR_SERVER, 0.0f, nullptr }; -cvar_t show_radioicon = { "mp_show_radioicon", "1", 0, 1.0f, nullptr }; -cvar_t old_bomb_defused_sound = { "mp_old_bomb_defused_sound", "1", 0, 1.0f, nullptr }; -cvar_t item_staytime = { "mp_item_staytime", "300", FCVAR_SERVER, 300.0f, nullptr }; -cvar_t legacy_bombtarget_touch = { "mp_legacy_bombtarget_touch", "1", 0, 1.0f, nullptr }; -cvar_t respawn_immunitytime = { "mp_respawn_immunitytime", "0", FCVAR_SERVER, 0.0f, nullptr }; -cvar_t kill_filled_spawn = { "mp_kill_filled_spawn", "1", 0, 0.0f, nullptr }; -cvar_t afk_bomb_drop_time = { "mp_afk_bomb_drop_time", "0", FCVAR_SERVER, 0.0f, nullptr }; -cvar_t buy_anywhere = { "mp_buy_anywhere", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t hostagehurtable = { "mp_hostage_hurtable", "1", FCVAR_SERVER, 1.0f, nullptr }; +cvar_t roundover = { "mp_roundover", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t forcerespawn = { "mp_forcerespawn", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t show_radioicon = { "mp_show_radioicon", "1", 0, 1.0f, nullptr }; +cvar_t old_bomb_defused_sound = { "mp_old_bomb_defused_sound", "1", 0, 1.0f, nullptr }; +cvar_t item_staytime = { "mp_item_staytime", "300", FCVAR_SERVER, 300.0f, nullptr }; +cvar_t legacy_bombtarget_touch = { "mp_legacy_bombtarget_touch", "1", 0, 1.0f, nullptr }; +cvar_t respawn_immunitytime = { "mp_respawn_immunitytime", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t respawn_immunity_effects = { "mp_respawn_immunity_effects", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t kill_filled_spawn = { "mp_kill_filled_spawn", "1", 0, 0.0f, nullptr }; +cvar_t afk_bomb_drop_time = { "mp_afk_bomb_drop_time", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t buy_anywhere = { "mp_buy_anywhere", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t allow_point_servercommand = { "mp_allow_point_servercommand", "0", 0, 0.0f, nullptr }; cvar_t hullbounds_sets = { "mp_hullbounds_sets", "1", 0, 0.0f, nullptr }; @@ -314,6 +315,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&item_staytime); CVAR_REGISTER(&legacy_bombtarget_touch); CVAR_REGISTER(&respawn_immunitytime); + CVAR_REGISTER(&respawn_immunity_effects); CVAR_REGISTER(&kill_filled_spawn); CVAR_REGISTER(&afk_bomb_drop_time); CVAR_REGISTER(&buy_anywhere); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 71e2a133..54015bfa 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -155,6 +155,7 @@ extern cvar_t old_bomb_defused_sound; extern cvar_t item_staytime; extern cvar_t legacy_bombtarget_touch; extern cvar_t respawn_immunitytime; +extern cvar_t respawn_immunity_effects; extern cvar_t kill_filled_spawn; extern cvar_t afk_bomb_drop_time; extern cvar_t buy_anywhere; diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 1960b630..c17062ec 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -4179,7 +4179,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)() // Debounced button codes for pressed/released // UNDONE: Do we need auto-repeat? - m_afButtonPressed = (buttonsChanged & pev->button); // The changed ones still down are "pressed" + m_afButtonPressed = (buttonsChanged & pev->button); // The changed ones still down are "pressed" m_afButtonReleased = (buttonsChanged & (~pev->button)); // The ones not down are "released" // Hint messages should be updated even if the game is over @@ -4448,7 +4448,9 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)() UpdateLocation(); #ifdef REGAMEDLL_ADD - if (CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Expired) + auto protectStateCurrent = CSPlayer()->GetProtectionState(); + if (protectStateCurrent == CCSPlayer::ProtectionSt_Expired || + (protectStateCurrent == CCSPlayer::ProtectionSt_Active && (m_afButtonPressed & IN_ACTIVE))) { RemoveSpawnProtection(); } @@ -9733,8 +9735,13 @@ LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, SetSpawnProtection, (float flProtectionT void EXT_FUNC CBasePlayer::__API_HOOK(SetSpawnProtection)(float flProtectionTime) { - pev->rendermode = kRenderTransAdd; - pev->renderamt = 100.0; +#ifdef REGAMEDLL_ADD + if (respawn_immunity_effects.value > 0) +#endif + { + pev->rendermode = kRenderTransAdd; + pev->renderamt = 100.0f; + } CSPlayer()->m_flSpawnProtectionEndTime = gpGlobals->time + flProtectionTime; } @@ -9743,7 +9750,17 @@ LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, RemoveSpawnProtection) void CBasePlayer::__API_HOOK(RemoveSpawnProtection)() { - pev->rendermode = kRenderNormal; +#ifdef REGAMEDLL_ADD + if (respawn_immunity_effects.value > 0) +#endif + { + if (pev->rendermode == kRenderTransAdd && + pev->renderamt == 100.0f) + { + pev->renderamt = 255.0f; + pev->rendermode = kRenderNormal; + } + } CSPlayer()->m_flSpawnProtectionEndTime = 0.0f; }