Skip to content

Commit

Permalink
Fix rooftop shooting (#52386)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bejofo authored Oct 28, 2021
1 parent d9c1c2e commit 25d9d00
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,26 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri
prev_point = tp;
tp = trajectory[i];

if( ( tp.z > prev_point.z && here.has_floor( tp ) ) ||
( tp.z < prev_point.z && here.has_floor( prev_point ) ) ) {
// Currently strictly no shooting through floor
// TODO: Bash the floor
tp = prev_point;
traj_len = --i;
break;
if( tp.z != prev_point.z ) {
tripoint floor1 = prev_point;
tripoint floor2 = tp;

if( floor1.z < floor2.z ) {
floor1.z++;
} else {
floor2.z++;
}
// We only stop the bullet if there are two floors in a row
// this allow the shooter to shoot adjacent enemies from rooftops.
if( here.has_floor( floor1 ) && here.has_floor( floor2 ) ) {
// Currently strictly no shooting through floor
// TODO: Bash the floor
tp = prev_point;
traj_len = --i;
break;
}
}

// Drawing the bullet uses player g->u, and not player p, because it's drawn
// relative to YOUR position, which may not be the gunman's position.
if( do_animation && !do_draw_line ) {
Expand Down

0 comments on commit 25d9d00

Please sign in to comment.