Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ramza13
Copy link
Contributor

@Ramza13 Ramza13 commented Jul 13, 2025

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

@GuardianDll GuardianDll added the target/0.I-branch Tag to trigger trop bot to port a PR to the 0.I branch. label Jul 13, 2025
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jul 13, 2025
@GuardianDll
Copy link
Member

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 ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) &&
Copy link
Member

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.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions target/0.I-branch Tag to trigger trop bot to port a PR to the 0.I branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Player can reach attack through floor
4 participants