Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rooftop shooting #52386

Merged
merged 4 commits into from
Oct 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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