-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Fix reach attacks through ceiling #81772
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10643,11 +10643,21 @@ | |
return g->get_creatures_if( [this, range, melee, &here]( const Creature & critter ) -> bool { | ||
//the call to map.sees is to make sure that even if we can see it through walls | ||
//via a mutation or cbm we only attack targets with a line of sight | ||
bool can_see = ( ( sees( here, critter ) || sees_with_specials( critter ) ) && here.sees( pos_bub( here ), critter.pos_bub( here ), 100 ) ); | ||
tripoint_bub_ms you_pos = pos_bub( here ); | ||
tripoint_bub_ms critter_pos = critter.pos_bub( here ); | ||
bool can_see = ( ( sees( here, critter ) || sees_with_specials( critter ) ) && here.sees( you_pos, critter_pos, 100 ) ); | ||
if( can_see && melee ) //handles the case where we can see something with glass in the way for melee attacks | ||
{ | ||
std::vector<tripoint_bub_ms> path = here.find_clear_path( pos_bub( here ), | ||
critter.pos_bub( here ) ); | ||
if( you_pos.z() > critter_pos.z() && ( !here.has_floor( you_pos ) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting aside the thing that clang-tidy is complaining about (which is that doing the same thing (returning false) in two different branches of an if/else is considered bug-prone), I'm not sure the logic is correct. BTW I think you can make clang happy by just breaking the "else" relation and have it be two separate if clauses, I don't think trying to refactor it into a single clause is a good idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. handling it this way seems to make blind shots in the dark impossible which they physically are not, so maybe just check for obstacles? |
||
!here.has_flag( ter_furn_flag::TFLAG_GOES_UP, you_pos ) && | ||
!here.has_flag( ter_furn_flag::TFLAG_GOES_DOWN, you_pos ) ) ) { | ||
return false; | ||
} else if( you_pos.z() < critter_pos.z() && ( !here.has_floor( critter_pos ) && | ||
!here.has_flag( ter_furn_flag::TFLAG_GOES_UP, critter_pos ) && | ||
!here.has_flag( ter_furn_flag::TFLAG_GOES_DOWN, critter_pos ) ) ) { | ||
return false; | ||
} | ||
std::vector<tripoint_bub_ms> path = here.find_clear_path( you_pos, critter_pos ); | ||
for( const tripoint_bub_ms &point : path ) { | ||
if( here.impassable( point ) && | ||
!( weapon.has_flag( flag_SPEAR ) && // Fences etc. Spears can stab through those | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.