From 4a6fe77b38d781936d7e7d2543f041c8babcb089 Mon Sep 17 00:00:00 2001 From: Alaux <73968015+MrAlaux@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:31:46 -0300 Subject: [PATCH] Hitscan-trail interval setting, and more Also tweaked description of the `bobbing_style` CVAR. --- src/g_game.c | 7 ++++++- src/p_map.c | 21 +++++++++++++-------- src/p_map.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 9972a6d6f..360c36b72 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6231,7 +6231,7 @@ void G_BindWeapVariables(void) M_BindNum("bobbing_style", &bobbing_style, NULL, 0, 0, 6, ss_weap, wad_yes, - "Weapon Bobbing Style"); + "Weapon bobbing style"); M_BindBool("weapon_inertia", &weapon_inertia, NULL, false, ss_weap, wad_yes, "Weapon inertia"); @@ -6251,6 +6251,11 @@ void G_BindWeapVariables(void) M_BindBool("sx_fix", &sx_fix, NULL, false, ss_none, wad_yes, "Correct centering of first-person sprites"); + // (CFG-only) + M_BindNum("hitscan_trail_interval", &hitscan_trail_interval, NULL, + 8, 1, 16, ss_none, wad_yes, + "Distance between particles of hitscan trails, in units"); + // [Nugget] ---------------------------------------------------------------/ #define BIND_WEAP(num, v, help) \ diff --git a/src/p_map.c b/src/p_map.c index 38a72eba3..8f447994d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -48,6 +48,7 @@ #include "z_zone.h" // [Nugget] +#include #include "g_game.h" #include "p_tick.h" @@ -98,6 +99,8 @@ msecnode_t *sector_list = NULL; // phares 3/16/98 // [Nugget] Hitscan trails /-------------------------------------------------- +int hitscan_trail_interval; + static int show_hitscan_trails = 0; static fixed_t distance_travelled = 0; @@ -123,7 +126,7 @@ void P_SpawnHitscanTrail(fixed_t x, fixed_t y, fixed_t z, angle_t angle, fixed_t slope, fixed_t range, fixed_t distance) { - const int scaled_range = (range >> FRACBITS) / 8; + const int scaled_range = (range >> FRACBITS) / hitscan_trail_interval; if (!scaled_range) { return; } @@ -136,16 +139,18 @@ void P_SpawnHitscanTrail(fixed_t x, fixed_t y, fixed_t z, ystep = (y2 - y) / scaled_range, zstep = (slope * (range >> FRACBITS)) / scaled_range; - const int scaled_distance = (distance >> FRACBITS) / 8; + const int num_particles = (distance >> FRACBITS) / hitscan_trail_interval; - for (int i = 5; i < scaled_distance; i++) + // Don't spawn particles less than 40 units away + for (int i = ceil((float) 40 / hitscan_trail_interval); i < num_particles; i++) { - mobj_t *const puff = P_SpawnVisualMobj(x + xstep * i, - y + ystep * i, - z + zstep * i, - AS_TRAIL1); + const fixed_t xdist = xstep * i, ydist = ystep * i, zdist = zstep * i; + + mobj_t *const puff = P_SpawnVisualMobj(x + xdist, y + ydist, z + zdist, AS_TRAIL1); + + // One more tic every 128 units + puff->alttics += (P_AproxDistance(xdist, ydist) >> FRACBITS) / 128; - puff->alttics += i / 16; puff->flags |= MF_NOGRAVITY; puff->tranmap = trail_tranmap; } diff --git a/src/p_map.h b/src/p_map.h index d80459049..f457c93aa 100644 --- a/src/p_map.h +++ b/src/p_map.h @@ -30,6 +30,7 @@ struct player_s; struct sector_s; // [Nugget] CVARs +extern int hitscan_trail_interval; extern boolean comp_lscollision; extern boolean comp_lsamnesia;