From f3e146dd30f80d8e8ba870f9451879b30238fea6 Mon Sep 17 00:00:00 2001 From: Bejofo <32919220+Bejofo@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:03:10 +0800 Subject: [PATCH 1/4] Fix rooftop shooting --- src/ballistics.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ballistics.cpp b/src/ballistics.cpp index c5c2321ff4c88..9c1551f5ef121 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -337,14 +337,24 @@ 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 ) { From 3714548ef052a09a9283c63f0c75dc2e86deb027 Mon Sep 17 00:00:00 2001 From: Bejofo <32919220+Bejofo@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:29:55 +0800 Subject: [PATCH 2/4] fix whitespace --- src/ballistics.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ballistics.cpp b/src/ballistics.cpp index 9c1551f5ef121..f81c6d1d6d392 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -338,23 +338,23 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri tp = trajectory[i]; if (tp.z != prev_point.z){ - tripoint floor1 = prev_point; - tripoint floor2 = tp; - if (floor1.z < floor2.z){ - floor1.z++; - } else { - floor2.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; - } - } + 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 ) { From 6e1424aae13cbd29041536e99cdb019238b83736 Mon Sep 17 00:00:00 2001 From: Bejofo <32919220+Bejofo@users.noreply.github.com> Date: Fri, 22 Oct 2021 17:42:39 +0800 Subject: [PATCH 3/4] try astyling --- src/ballistics.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ballistics.cpp b/src/ballistics.cpp index f81c6d1d6d392..bd0a3c604fe7f 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -336,18 +336,19 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri for( size_t i = 1; i < traj_len && ( has_momentum || stream ); ++i ) { prev_point = tp; tp = trajectory[i]; - - if (tp.z != prev_point.z){ + + if( tp.z != prev_point.z ) { tripoint floor1 = prev_point; tripoint floor2 = tp; - if (floor1.z < floor2.z){ + + 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)){ + if( here.has_floor( floor1 ) && here.has_floor( floor2 ) ) { // Currently strictly no shooting through floor // TODO: Bash the floor tp = prev_point; @@ -355,6 +356,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri 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 ) { From bde03080a9eae4c0c32fa41e0f733b464756b7a6 Mon Sep 17 00:00:00 2001 From: Bejofo <32919220+Bejofo@users.noreply.github.com> Date: Sat, 23 Oct 2021 15:30:19 +0800 Subject: [PATCH 4/4] try astying again --- src/ballistics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ballistics.cpp b/src/ballistics.cpp index bd0a3c604fe7f..5e06efe0966af 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -336,7 +336,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri for( size_t i = 1; i < traj_len && ( has_momentum || stream ); ++i ) { prev_point = tp; tp = trajectory[i]; - + if( tp.z != prev_point.z ) { tripoint floor1 = prev_point; tripoint floor2 = tp; @@ -347,7 +347,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri 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. + // 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 @@ -356,7 +356,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri 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 ) {