Skip to content

Commit

Permalink
Hit ceiling / floor in PTR_ShootTraverse
Browse files Browse the repository at this point in the history
  • Loading branch information
kraflab committed Jan 4, 2024
1 parent 18e1125 commit 87259b3
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion prboom2/src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,45 @@ dboolean PTR_ShootTraverse (intercept_t* in)
// hit line
// position a bit closer

frac = in->frac - FixedDiv (4*FRACUNIT,attackrange);
if (map_format.zdoom)
{
int side = P_PointOnLineSide(trace.x, trace.y, li);
sector_t *sec = side ? li->backsector : li->frontsector;

z = shootz + FixedMul(aimslope, FixedMul(in->frac, attackrange));

if (sec && sec->floorheight > z)
{
fixed_t dist;

if (sec->floorpic == skyflatnum)
return false;

dist = FixedDiv(sec->floorheight - shootz, aimslope);
frac = FixedDiv(dist, attackrange);
}
else if (sec && sec->ceilingheight < z)
{
fixed_t dist;

if (sec->ceilingpic == skyflatnum)
return false;

// TODO: ceiling puffs get pushed down and look off
dist = FixedDiv(sec->ceilingheight - shootz, aimslope);
frac = FixedDiv(dist, attackrange);
}
else
{
frac = in->frac;
}
}
else
{
frac = in->frac;
}

frac -= FixedDiv(4 * FRACUNIT, attackrange);
x = trace.x + FixedMul (trace.dx, frac);
y = trace.y + FixedMul (trace.dy, frac);
z = shootz + FixedMul (aimslope, FixedMul(frac, attackrange));
Expand Down

0 comments on commit 87259b3

Please sign in to comment.