From 7c77cd5a0293a89ce35e89f13aa58ed30489e217 Mon Sep 17 00:00:00 2001 From: k9er Date: Thu, 2 Jan 2025 23:24:44 +0000 Subject: [PATCH] Allow selecting a random nade --- mutators.cfg | 6 ++--- qcsrc/common/mutators/mutator/nades/nades.qc | 26 ++++++++++++++------ qcsrc/common/mutators/mutator/nades/nades.qh | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/mutators.cfg b/mutators.cfg index f2d477a16..f0094c2cf 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -205,10 +205,10 @@ set g_nades_nade_edgedamage 90 set g_nades_nade_radius 300 set g_nades_nade_force 650 set g_nades_nade_newton_style 0 "nade velocity: 0 is absolute, 1 is relative (takes into account player velocity), 2 is something in between" -set g_nades_nade_type 1 "Type of the off-hand grenade. 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil, 10:ammo, 11:darkness" +set g_nades_nade_type 1 "Type of the off-hand grenade. 0:random 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil, 10:ammo, 11:darkness" seta cl_nade_timer 1 "show a visual timer for nades, 1 = only circle, 2 = circle with text" -seta cl_nade_type 3 "selected type of the off-hand grenade. 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil 10:ammo 11:darkness" +seta cl_nade_type 3 "selected type of the off-hand grenade. 0:random 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil 10:ammo 11:darkness" seta cl_pokenade_type "zombie" "monster to spawn" // ------------ @@ -223,7 +223,7 @@ seta cl_pokenade_type "zombie" "monster to spawn" // set g_nades_bonus 0 "Enable bonus grenades" set g_nades_bonus_client_select 0 "Allow client side selection of bonus nade type" -set g_nades_bonus_type 2 "Type of the bonus grenade. 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil 10:ammo 11:darkness" +set g_nades_bonus_type 2 "Type of the bonus grenade. 0:random 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil 10:ammo 11:darkness" set g_nades_bonus_onstrength 1 "Always give bonus grenades to players that have the strength powerup" set g_nades_bonus_max 3 "Maximum number of bonus grenades" set g_nades_bonus_only 0 "Disallow regular nades, only bonus nades can be used" diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 323c14d98..298079f53 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -149,9 +149,18 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan float bonusNades = STAT(NADE_BONUS); float bonusProgress = STAT(NADE_BONUS_SCORE); float bonusType = STAT(NADE_BONUS_TYPE); - Nade def = REGISTRY_GET(Nades, bonusType); - vector nadeColor = def.m_color; - string nadeIcon = def.m_icon; + Nade def = REGISTRY_GET(Nades, max(1, bonusType)); + string nadeIcon = def.m_icon; // use the Normal Nade icon for the random nade, and draw it as rainbow + vector nadeColor; + if(bonusType) + nadeColor = def.m_color; + else + { + nadeColor.x = time % (M_PI * 2); + nadeColor.y = 1; + nadeColor.z = 1; + nadeColor = hsv_to_rgb(nadeColor); + } vector iconPos, textPos; @@ -174,9 +183,9 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); if(draw_expanding) - drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time); + drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, (bonusType ? '1 1 1' : nadeColor), panel_fg_alpha, DRAWFLAG_NORMAL, expand_time); - drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, (bonusType ? '1 1 1' : nadeColor), panel_fg_alpha, DRAWFLAG_NORMAL); } } #endif @@ -1267,7 +1276,9 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin n.pokenade_type = pntype; - Nade def = REGISTRY_GET(Nades, max(1, ntype)); + if(ntype == 0) // random nade + ntype = floor(random() * (REGISTRY_COUNT(Nades) - 1)) + 1; + Nade def = REGISTRY_GET(Nades, ntype); if(def == NADE_TYPE_Null) def = NADE_TYPE_NORMAL; @@ -1399,6 +1410,7 @@ int nades_CheckTypes(entity player, int cl_ntype) switch (cl_ntype) { + case 0: return 0; // random nade CL_NADE_TYPE_CHECK(NADE_TYPE_NAPALM, autocvar_g_nades_napalm); CL_NADE_TYPE_CHECK(NADE_TYPE_ICE, autocvar_g_nades_ice); CL_NADE_TYPE_CHECK(NADE_TYPE_TRANSLOCATE, autocvar_g_nades_translocate); @@ -1530,7 +1542,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) player.pokenade_type = autocvar_g_nades_pokenade_monster_type; } - STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT); + STAT(NADE_BONUS_TYPE, player) = bound(0, STAT(NADE_BONUS_TYPE, player), REGISTRY_COUNT(Nades)); if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max) nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max); diff --git a/qcsrc/common/mutators/mutator/nades/nades.qh b/qcsrc/common/mutators/mutator/nades/nades.qh index e5fa0da89..94088c5d6 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qh +++ b/qcsrc/common/mutators/mutator/nades/nades.qh @@ -163,7 +163,7 @@ REPLICATE_INIT(string, cvar_cl_pokenade_type); .float nade_special_time; .string pokenade_type; .entity nade_damage_target; -.float cvar_cl_nade_type; +.int cvar_cl_nade_type; .string cvar_cl_pokenade_type; .float toss_time; .float nade_show_particles; -- 2.39.5