-
Notifications
You must be signed in to change notification settings - Fork 284
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
Fix eternal drowning when NPC is thrown into deep water. #3269
Merged
scarf005
merged 2 commits into
cataclysmbnteam:upload
from
cbnbugfix2:fix-eternal-drowning
Sep 27, 2023
Merged
Fix eternal drowning when NPC is thrown into deep water. #3269
scarf005
merged 2 commits into
cataclysmbnteam:upload
from
cbnbugfix2:fix-eternal-drowning
Sep 27, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An NPC that was thrown into water would eternally drown, even after getting back on land. This also fixes that NPCs take damage from drowning normally while being submerged in deep water after walking into it instead of being thrown into it, which may not be a desirable change, since NPC behaviour does not currently include a lot of deep water avoidance.
scarf005
approved these changes
Sep 27, 2023
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.
scarf005
approved these changes
Sep 27, 2023
wha- but how i think it's related to #3282 |
I just tried killing an NPC using "Kill NPCs" in the build I made with my fork, and that works fine. I also killed an NPC manually, and that also worked fine. |
Yep it's fine, looks like it was the cache dead NPCs thing instead. |
scarf005
pushed a commit
to scarf005/Cataclysm-BN
that referenced
this pull request
Sep 28, 2023
…team#3269) * fix: NPCs no longer drown eternally after being thrown. An NPC that was thrown into water would eternally drown, even after getting back on land. This also fixes that NPCs take damage from drowning normally while being submerged in deep water after walking into it instead of being thrown into it, which may not be a desirable change, since NPC behaviour does not currently include a lot of deep water avoidance. * fix: Disable NPCs taking damage from drowning.
This was referenced Oct 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Bugfixes "Fix NPCs eternally drowning after being thrown into deep water despite afterwards getting out of it"
Purpose of change
Prevent NPCs from drowning eternally if they are thrown into deep water, even after walking onto land again.
Describe the solution
The first commit fixes a bug where an NPC, after being thrown into water (for instance by a kevlar hulk), would eternally drown, even after getting onto land (unless debugging was used to constantly give them health, they would constantly take torso damage and quickly die). This fix also has the second effect that NPCs now will be treated as being submerged when walking into deep water, causing drowning after enough time. This second effect has drawbacks due to the behaviour of NPCs not currently having drowning avoidance programmed into it. The fix is inspired by similar code in
monmove.cpp
, atCataclysm-BN/src/monmove.cpp
Lines 1638 to 1664 in dc43e23
The second commit disables NPCs taking damage from drowning, which fixes the possible issue above where NPCs might unintentionally die from standing around in deep water without trying to get out of it.
The two commits together should have mostly the same effects as before, except:
Testing
I tested it using debug mode, with an NPC walking into deep water and observing that it did not drown after 30 minutes of waiting in deep water using the quick-wait function, and also tested that an NPC no longer drowns eternally by positioning deep water and a kevlar hulk such that the kevlar hulk would throw the NPC into deep water, and then observing that the NPC is still alive after 30 minutes of waiting once it got onto land using the quick-wait function.
Additional context
I talked about this bug and how to fix it best with some of the developers on Discord, and from what I understood, what I have implemented here might fit decently what we discussed. This way of fixing it should also mean that implementing NPCs drowning in the future should be easier, since only a few lines should be removed, and those lines have a Github issue attached to it in the code. The issue #3266 has been created as a suggestion on implementing drowning and to help explain in the code why drowning is currently disabled for NPCs .