]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow selecting a random nade
authork9er <k9wolf@pm.me>
Thu, 2 Jan 2025 23:24:44 +0000 (23:24 +0000)
committerterencehill <piuntn@gmail.com>
Thu, 2 Jan 2025 23:24:44 +0000 (23:24 +0000)
mutators.cfg
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nades/nades.qh

index f2d477a16c373260bff7c81405f250e14313a8ee..f0094c2cf86331281be6e5fb070c700384531996 100644 (file)
@@ -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"
index 323c14d987d4eefccb8c2ca9069cc2d395309475..298079f53efb27d157006521a746a40164625216 100644 (file)
@@ -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);
index e5fa0da8903379143b983852d03dab8b00335b35..94088c5d6bc010f6bd721a5cf7d66d4020d2a4ab 100644 (file)
@@ -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;