Skip to content

Commit

Permalink
Hitscan-trail interval setting, and more
Browse files Browse the repository at this point in the history
Also tweaked description of the `bobbing_style` CVAR.
  • Loading branch information
MrAlaux committed Dec 14, 2024
1 parent c7000be commit 4a6fe77
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) \
Expand Down
21 changes: 13 additions & 8 deletions src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "z_zone.h"

// [Nugget]
#include <math.h>
#include "g_game.h"
#include "p_tick.h"

Expand Down Expand Up @@ -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;
Expand All @@ -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; }

Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/p_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4a6fe77

Please sign in to comment.