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

Sane-ify in-vehicle movement size checks #74004

Merged
merged 6 commits into from
May 23, 2024

Conversation

RenechCDDA
Copy link
Member

@RenechCDDA RenechCDDA commented May 22, 2024

Summary

None

Purpose of change

image
(in multiple places)

NPC magically acquires cramped space effect because of vehicle 3 tiles away
image

Wall of trunks with cargo is invincible to the zombie hordes (waited one hour)
image

Describe the solution

De-duplicate code

Concentrate all checks in one creature function instead of repeating it all over the place

Use tripoint_abs_ms instead of raw tripoints

Don't apply cramped space effects when evaluating places to move to (that's why the function is const...)

FUNCTIONAL CHANGES:

Removed the flying bypass for open top vehicle tiles, since it did not check the actual z-level above or anything. I'm not interested in writing a bunch of checks for this and it's just plain incorrect.

Make monsters bash the vehicle if they can't move through it, they're trying to bash the terrain right now by checking creature::can_move_to_vehicle_tile again... I don't like this but it doesn't seem to explode anything in testing

Because the calculation changed to sane-ify volume, some vehicle parts which previously were free to traverse might now give the cramped space effect.

Describe alternatives you've considered

Lots of reverting.

Testing

image

Additional context

There should be no functional changes aside from that which is noted

@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels May 22, 2024
@RenechCDDA
Copy link
Member Author

RenechCDDA commented May 22, 2024

OK I have no good suggestions to solve the bashing. It's not that they're bashing terrain, they just aren't bashing except 1 in 50 times.

Cataclysm-DDA/src/monmove.cpp

Lines 1703 to 1711 in 5b4b49b

map &here = get_map();
if( !( here.is_bashable_furn( p ) || here.veh_at( p ).obstacle_at_part() ) ) {
// if the only thing here is road or flat, rarely bash it
bool flat_ground = here.has_flag( ter_furn_flag::TFLAG_ROAD, p ) ||
here.has_flag( ter_furn_flag::TFLAG_FLAT, p );
if( !here.is_bashable_ter( p ) || ( flat_ground && !one_in( 50 ) ) ) {
return false;
}
}

Profiling suggests it is not gamebreaking to just check creature::can_move_to_vehicle_tile again, so that was the solution I went with.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 22, 2024
@IdleSol
Copy link

IdleSol commented May 22, 2024

If the volume of a tile is smaller than yours, break it up instead of moving to it

@RenechCDDA RenechCDDA marked this pull request as ready for review May 22, 2024 18:18
@worm-girl
Copy link
Contributor

This looks like a huge improvement. The flying thing seems reasonable to cut, too. I wanted to make it so that removing your roof would expose you to wasp attacks, but I think they can just fly to z+1 and sting you from above if you're in a convertible.

@dseguin dseguin merged commit 61addf8 into CleverRaven:master May 23, 2024
37 of 45 checks passed
@meelock
Copy link
Contributor

meelock commented May 24, 2024

Seems this may be causing lingering cramped effect if this was changed by 2129.

@meelock
Copy link
Contributor

meelock commented May 24, 2024

cataclysm-tiles_avenGnnu6K

@meelock
Copy link
Contributor

meelock commented May 24, 2024

Seems it occurs when walking into tiles with (broken?) large guns.

@DeciusBrutus
Copy link

This looks like a huge improvement. The flying thing seems reasonable to cut, too. I wanted to make it so that removing your roof would expose you to wasp attacks, but I think they can just fly to z+1 and sting you from above if you're in a convertible.

Do vehicle roofs protect against wasp stings from Z+1?

@rselias
Copy link
Contributor

rselias commented May 25, 2024

There's still something wrong. I'm getting the cramped effect from entering any interior tile of any car. Character is normal sized and naked, inventory is empty, no items on the seat. At least the effect isn't permanent now, but it shouldn't be happening to begin with.

Edit: Check out a Luxury RV. The front section of the camper causes the cramped effect, but part of the back doesn't. Might be useful. The tiles that don't cause the effect have a frame, roof, aisle lights, and a floor trunk. There are tiles in the front of the camper that are the same except for having an aisle instead of a floor trunk, and do cause the cramped effect.

@RenechCDDA RenechCDDA deleted the aisle_size_checks_wtf branch May 25, 2024 00:34
@SaltGin
Copy link

SaltGin commented May 25, 2024

There's still something wrong. I'm getting the cramped effect from entering any interior tile of any car. Character is normal sized and naked, inventory is empty, no items on the seat. At least the effect isn't permanent now, but it shouldn't be happening to begin with.

Can confirm this.

@IdleSol
Copy link

IdleSol commented May 25, 2024

return false;
}

if( critter_volume < free_cargo * 1.33 ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I reading this right? If the creature's volume is less than a third over the free cargo space and isn't a monster, snake, blob or fish-type then it's cramped? Shouldn't the check be for if the creature's volume greater than a third over free cargo space?

Copy link
Member Author

Choose a reason for hiding this comment

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

Reading it right, interpreting it wrong. If the critter is greater than the free cargo size, it can't move into this tile in the first place - we return false earlier in the function. https://github.com/CleverRaven/Cataclysm-DDA/pull/74004/files#diff-5a026da090b6664f91c5f3bc4a9d0844cff966ef6fa5785d258b3aa47b370a2cR253

But yeah this logic is confusing, and part of the reason why I wanted to get rid of the huge block of volume comparisons shown.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yeah, point. I was so focused on chasing down what was setting cramped to true I failed to remember what the whole function was about.

That said, I'm reasonably sure this particular check is the culprit when it comes to #74068 since commenting out cramped = true; and recompiling prevents the behavior reported there from occurring.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the equation should be free_cargo * 0.75 < critter_volume instead,
thus we set cramped when free_cargo * 0.75 < critter_volume && critter_volume <= free_cargo

I'm already working on it tonight, this whole thing is still a mess.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just tested critter_volume * 0.75 < free_cargo && critter_volume <= free_cargo and it's still setting cramped to true.

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 [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions Monsters Monsters both friendly and unfriendly. NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants