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

Prevent monsters from leaping to their death in water #38150

Merged
merged 3 commits into from
Feb 20, 2020

Conversation

jkraybill
Copy link
Contributor

@jkraybill jkraybill commented Feb 19, 2020

Summary

SUMMARY: Bugfixes "Prevent monsters from leaping to their death in water"

Purpose of change

Fixes #38038 by preventing monsters that could drown from leaping into drownable terrain.

Describe the solution

I refactored the die_if_drowning method to separate out a method (is_aquatic_danger) that defines terrain that would drown a drownable monster. In the leaping code, I consider a square unleapable if it would drown the leaper, and prevent leaping.

This refactor removed some redundant code checking for TFLAG_DEEP_WATER before doing the die_if_drowning checks and encapsulated it in hopefully a better way.

Describe alternatives you've considered

Should leaping animals always know that they would drown? I decided yes, because they won't willingly walk to their death, but the alternative of allowing some version of the existing behaviour was considered. It didn't seem appropriate, unless there is some case where monsters do this that I'm not aware of.

Testing

I couldn't figure out how to make cougars reliably hostile while on the shoreline! My testing was with evolved mutants, who also have the Leap attack and are hostile.

I tested before and after, and before, an entire group of evolved mutants leaped to their death when I was on a motorboat just off the shore.

Afterwards, I verified that they did not leap directly into the water. I tested that they would leap if their target was on my boat, which they did occasionally:

sc001344

(Note the dead monsters in deep water are almost exclusively from the "before" save.)

Additional context

When I did have a boarded mutant on my boat, the mutant behaviour was a bit strange but I am quite certain it was not related to this change -- I just think that boarded walkers on boats don't navigate as expected. The mutant was shaking the boat but wasn't charging me. It looks like there is a navigation issue with walkers on boats over deep water? I think there's a separate issue here if someone wants to improve the behaviour of walkers on boarded boats.

@Funguss
Copy link
Contributor

Funguss commented Feb 19, 2020

Hell yeah, nice one! Regarding boat pathing it seems to be a symptom for all creatures in vehicles over deep water. I could leave my horse untied if I positioned the boat so the horse was surrounded by deep water tiles. Taking a horse for a boat ride is pretty weird anyway, but that's beside the point. I imagine dogs would behave the same, too.

@Sumguy62
Copy link
Contributor

But cougars can swim really well...

@ifreund ifreund added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. labels Feb 19, 2020
@ZhilkinSerg
Copy link
Contributor

You've changed filemode for some files:

image

@jkraybill
Copy link
Contributor Author

@ZhilkinSerg sorry no idea how that happened, definitely wasn't intentional :( Reverted.

@jkraybill
Copy link
Contributor Author

@Sumguy62 that's actually a good point, there is definitely room for improving aquatic behaviors but it's not the scope of this PR, I'd encourage opening an issue if you want to see more realistic cougar/other animal behavior!

@ZhilkinSerg ZhilkinSerg merged commit f3fbeb8 into CleverRaven:master Feb 20, 2020
@jkraybill jkraybill deleted the 38038 branch March 8, 2020 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cougars leap into deep water and drown
5 participants