-
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?
Conversation
Mind fixing clang errors? |
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 ) ); |
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.
bool can_see = ( ( sees( here, critter ) || sees_with_specials( critter ) ) && here.sees( you_pos, critter_pos, 100 ) ); | |
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 comment
The 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.
Assume the player is above the target, we need one of "has_floor() == false" or "has_flag( GOES_DOWN ) == true" for the target to be a valid candidate, but we're also checking for GOES_UP?
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 comment
The 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?
Summary
Bugfixes "Fix reach attacks through ceilings"
Purpose of change
Fix #80258
Describe the solution
Added checking to getting targetable creatures to make sure vertical attacks are only allowed if on stairs/ladders
Describe alternatives you've considered
Testing
Additional context