From 7a69c2b42fac3253109e14c73792acc179e3acf6 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Sat, 9 Sep 2023 08:46:19 +0300 Subject: [PATCH] Add bound and descriptions for CVars (#39) - Add all CVars descriptions to `.json` --- .../configs/redm/gamemode_deathmatch.json | 78 +++++++++++++- .../scripting/ReDeathmatch/Modes/Vote.inc | 19 ++-- .../ReDeathmatch/ReDM_equip_manager.inc | 22 +++- .../scripting/ReDeathmatch/ReDM_features.inc | 102 ++++++++++++++++-- .../ReDeathmatch/ReDM_round_modes.inc | 8 +- .../addons/amxmodx/scripting/redm_spawns.sma | 50 ++++++--- 6 files changed, 239 insertions(+), 40 deletions(-) diff --git a/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json b/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json index f541706..302e544 100644 --- a/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json +++ b/cstrike/addons/amxmodx/configs/redm/gamemode_deathmatch.json @@ -30,6 +30,81 @@ ] }, "cvars": { + // ReDM: Spawns + /* Enables the system of selecting spawns. + 0 - disable + 1 - for all + 2 - only for T + 3 - only for CT */ + "mp_randomspawn": "1", + + /* Check the spawn point for visibility by enemies (line of sight). + 0 - disable + 1 - enable */ + "mp_randomspawn_los": "1", + + // Minimum distance to the enemy to enable spawn checks. + "mp_randomspawn_dist": "1500", + + // Name of the spawn manager + "redm_spawn_preset": "preset", + + // ReDM: Features + // Restore weapon slot on respawn. + "redm_keep_weapon_slot": "1", + + // Open weapon equip menu on spawn. + "redm_open_equip_menu": "0", + + // How much to restore HP when killing an enemy. + "redm_healer": "10", + + // How much to restore HP when killing with HS an enemy. + "redm_healer_hs": "15", + + // Mute the sounds of other players at a distance. + "redm_sounds_distance": "1500", + + // Highlight the display when you kill someone. + "redm_fade": "1", + + // Kill highlights color [RGBA] + "redm_fade_colors": "0 200 0 50", + + // Refill ammo on kills. + "redm_refill_ammo": "1", + + // Play a sound when an enemy is hit. + "redm_hitsound": "1", + + // Enable hits only in HS. + "mp_damage_headshot_only": "0", + + // Hide other players' killfeed. + "redm_hide_other_deathnotice": "1", + + // On spawn protection colors [RGBA] + "redm_protection_color_t": "200 0 0 15", + "redm_protection_color_ct": "0 0 200 15", + + // ReDM: Modes + /* Game mode change mode. + `0`, `disable` - disable modes + `random` - random change + `sequentially` - sequential mode change + */ + "redm_modes_switch": "sequentially", + + // Enable voting for the next game mode. + "redm_mode_vote_enable": "1", + + // Time to vote for the next mode (sec). + "redm_mode_vote_time": "15", + + // How many times can the game mode be extended. + "redm_mode_vote_extend_times": "1", + + // ReGameDLL Settings "mp_freeforall": "1", "bot_deathmatch": "1", "bot_defer_to_human": "0", @@ -61,8 +136,7 @@ "mp_scoreboard_showmoney": "0", "mp_show_radioicon": "0", "mp_timelimit": "30", - "mp_weapons_allow_map_placed": "0", - "mp_damage_headshot_only": "0" + "mp_weapons_allow_map_placed": "0" }, "modes": [ { diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/Modes/Vote.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/Modes/Vote.inc index 753a34d..3ab21b4 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/Modes/Vote.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/Modes/Vote.inc @@ -29,25 +29,26 @@ ModeVote_Init() { bind_pcvar_num( create_cvar( - "redm_mode_vote_enable", - "1", - .has_min = true, .min_val = 0.0 + "redm_mode_vote_enable", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Enable voting for the next game mode." ), redm_mode_vote_enable ) bind_pcvar_num( create_cvar( - "redm_mode_vote_time", - "15", - .has_min = true, .min_val = 0.0 + "redm_mode_vote_time", "15", + .has_min = true, .min_val = 0.0, + .description = "Time to vote for the next mode (sec)." ), redm_mode_vote_time ) bind_pcvar_num( create_cvar( - "redm_mode_vote_extend_times", - "1", - .has_min = true, .min_val = 0.0 + "redm_mode_vote_extend_times", "1", + .has_min = true, .min_val = 0.0, + .description = "How many times can the game mode be extended." ), redm_mode_vote_extend_times ) diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_equip_manager.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_equip_manager.inc index 33ef6ed..807746a 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_equip_manager.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_equip_manager.inc @@ -27,10 +27,26 @@ EquipManager_Init() { // RegisterHookChain(RG_CBasePlayer_GiveNamedItem, "CBasePlayer_GiveNamedItem", .post = false) RegisterHookChain(RG_CBasePlayer_AddPlayerItem, "CBasePlayer_AddPlayerItem", .post = false) - bind_pcvar_num(create_cvar("redm_keep_weapon_slot", "1"), redm_keep_weapon_slot) - bind_pcvar_num(create_cvar("redm_open_equip_menu", "0"), redm_open_equip_menu) + bind_pcvar_num( + create_cvar( + "redm_keep_weapon_slot", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Restore weapon slot on respawn." + ), + redm_keep_weapon_slot + ) + bind_pcvar_num( + create_cvar( + "redm_open_equip_menu", "0", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Open weapon equip menu on spawn." + ), + redm_open_equip_menu + ) - register_concmd("redm_dump_equip", "ConCmd_redm_dump_equip", ADMIN_MAP, "Dump loaded equipset from config to table.") + register_concmd("redm_dump_equip", "ConCmd_redm_dump_equip", ADMIN_MAP, "Dump loaded equipset from config to table in console.") register_clcmd("drop", "ClCmd_Drop") register_clcmd("say /guns", "ClCmd_Drop") diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc index 2d3960d..f64138b 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc @@ -38,17 +38,97 @@ Features_Init() { RegisterHookChain(RG_CBasePlayer_SetSpawnProtection, "CBasePlayer_SetSpawnProtection_Post", .post = true) RegisterHookChain(RG_CBasePlayer_RemoveSpawnProtection, "CBasePlayer_RemoveSpawnProtection", .post = true) - bind_pcvar_float(create_cvar("redm_healer", "10.0"), redm_healer) - bind_pcvar_float(create_cvar("redm_healer_hs", "20.0"), redm_healer_hs) - bind_pcvar_float(create_cvar("redm_sounds_distance", "1500.0"), redm_sounds_distance) - bind_pcvar_num(create_cvar("redm_fade", "1"), redm_fade) - bind_pcvar_string(create_cvar("redm_fade_colors", "0 200 0 50"), redm_fade_colors, charsmax(redm_fade_colors)) - bind_pcvar_num(create_cvar("redm_refill_ammo", "1"), redm_refill_ammo) - bind_pcvar_num(create_cvar("redm_hitsound", "1"), redm_hitsound) - bind_pcvar_num(create_cvar("mp_damage_headshot_only", "0"), mp_damage_headshot_only) - bind_pcvar_num(create_cvar("redm_hide_other_deathnotice", "1"), redm_hide_other_deathnotice) - bind_pcvar_string(create_cvar("redm_protection_color_t", "200 0 0 15"), redm_protection_color_t, charsmax(redm_protection_color_t)) - bind_pcvar_string(create_cvar("redm_protection_color_ct", "0 0 200 15"), redm_protection_color_ct, charsmax(redm_protection_color_ct)) + bind_pcvar_float( + create_cvar( + "redm_healer", "10.0", + .has_min = true, .min_val = 0.0, + .description = "How much to restore HP when killing an enemy." + ), + redm_healer + ) + bind_pcvar_float( + create_cvar( + "redm_healer_hs", "20.0", + .has_min = true, .min_val = 0.0, + .description = "How much to restore HP when killing with HS an enemy." + ), + redm_healer_hs + ) + bind_pcvar_float( + create_cvar( + "redm_sounds_distance", "1500.0", + .has_min = true, .min_val = 0.0, + .description = "Mute the sounds of other players at a distance." + ), + redm_sounds_distance + ) + bind_pcvar_num( + create_cvar( + "redm_fade", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Highlight the display when you kill someone." + ), + redm_fade + ) + bind_pcvar_string( + create_cvar( + "redm_fade_colors", "0 200 0 50", + .description = "Kill highlights color [RGBA]" + ), + redm_fade_colors, charsmax(redm_fade_colors) + ) + bind_pcvar_num( + create_cvar( + "redm_refill_ammo", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Refill ammo on kills." + ), + redm_refill_ammo + ) + bind_pcvar_num( + create_cvar( + "redm_hitsound", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Play a sound when an enemy is hit." + ), + redm_hitsound + ) + bind_pcvar_num( + create_cvar( + "mp_damage_headshot_only", "0", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Enable hits only in HS." + ), + mp_damage_headshot_only + ) + bind_pcvar_num( + create_cvar( + "redm_hide_other_deathnotice", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Hide other players' killfeed." + ), + redm_hide_other_deathnotice + ) + bind_pcvar_string( + create_cvar( + "redm_protection_color_t", "200 0 0 15", + .description = "On spawn T protection colors [RGBA]" + ), + redm_protection_color_t, charsmax(redm_protection_color_t) + ) + bind_pcvar_string( + create_cvar( + "redm_protection_color_ct", "0 0 200 15", + .description = "On spawn CT protection colors [RGBA]" + ), + redm_protection_color_ct, charsmax(redm_protection_color_ct) + ) + bind_pcvar_num(get_cvar_pointer("mp_respawn_immunity_effects"), mp_respawn_immunity_effects) } diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_round_modes.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_round_modes.inc index 1754df5..0fd5508 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_round_modes.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_round_modes.inc @@ -13,7 +13,13 @@ RoundModes_Init() { RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip", .post = false) bind_pcvar_string( - create_cvar("redm_modes_switch", "sequentially"), + create_cvar( + "redm_modes_switch", "sequentially", + .description = "Game mode change mode. \ + `0`, `disable` - disable modes, \ + `random` - random change, \ + `sequentially` - sequential mode change." + ), redm_modes_switch, charsmax(redm_modes_switch) ) diff --git a/cstrike/addons/amxmodx/scripting/redm_spawns.sma b/cstrike/addons/amxmodx/scripting/redm_spawns.sma index 5ffbe2c..5f4589b 100644 --- a/cstrike/addons/amxmodx/scripting/redm_spawns.sma +++ b/cstrike/addons/amxmodx/scripting/redm_spawns.sma @@ -29,7 +29,7 @@ enum EditorProps_s { static g_editorProps[MAX_PLAYERS + 1][EditorProps_s] -new JSON: g_arrSpawns = Invalid_JSON +static JSON: g_arrSpawns = Invalid_JSON static const g_spawnViewModels[_: TeamName - 1][] = { "models/player/vip/vip.mdl", @@ -47,16 +47,11 @@ static Float: g_gravityValues[] = { 1.0, 0.5, 0.25, 0.05 } -// Determines whether players are to spawn. 0 = default; 1 = both teams; 2 = Terrorists; 3 = CTs. -new mp_randomspawn = 1 +static mp_randomspawn +static mp_randomspawn_los +static Float: mp_randomspawn_dist -// If non-zero, a randomly spawning player will, if possible, not be spawned at a spawn point with direct line of sight to another player. (2 = check viewcone) -new mp_randomspawn_los = 2 - -// If greater than 0, a randomly spawning player will, if possible, not be spawned at a spawn point where the smallest distance to another player is smaller than the value of this ConVar. -new Float: mp_randomspawn_dist = 1500.0 - -new bool: mp_freeforall +static bool: mp_freeforall public plugin_precache() { @@ -66,7 +61,7 @@ public plugin_precache() { } public plugin_init() { - register_plugin("Spawns manager", REDM_VERSION, "Sergey Shorokhov") + register_plugin("ReDM: Spawns manager", REDM_VERSION, "Sergey Shorokhov") register_dictionary("common.txt") rh_get_mapname(g_mapName, charsmax(g_mapName)) @@ -81,9 +76,36 @@ public plugin_cfg() { bind_pcvar_num(get_cvar_pointer("mp_freeforall"), mp_freeforall) // set_pcvar_bounds(get_cvar_pointer("mp_forcerespawn"), CvarBound_Lower, true, 0.1) // TODO - bind_pcvar_num(create_cvar("mp_randomspawn", "1"), mp_randomspawn) - bind_pcvar_num(create_cvar("mp_randomspawn_los", "2"), mp_randomspawn_los) - bind_pcvar_float(create_cvar("mp_randomspawn_dist", "1500.0"), mp_randomspawn_dist) + bind_pcvar_num( + create_cvar( + "mp_randomspawn", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 3.0, + .description = "Enables the system of selecting spawns. \ + `0` - disable, \ + `1` - for all, \ + `2` - only for T, \ + `3` - only for CT" + ), + mp_randomspawn + ) + bind_pcvar_num( + create_cvar( + "mp_randomspawn_los", "1", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .description = "Check the spawn point for visibility by enemies (line of sight)." + ), + mp_randomspawn_los + ) + bind_pcvar_float( + create_cvar( + "mp_randomspawn_dist", "1500.0", + .has_min = true, .min_val = 0.0, + .description = "Minimum distance to the enemy to enable spawn checks." + ), + mp_randomspawn_dist + ) RegisterHookChain(RG_CBasePlayer_UseEmpty, "CBasePlayer_UseEmpty", .post = false)