Return to always treating hostile NPCs as being dangerous for 0.H #75781
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
Bugfixes "Treat hostile NPCs as unsafe even if your safe mode rules don't match."
Purpose of change
Fixes #65513
After several people digging into this, it looks like the real issue is that if you even as much as initialize a safe mode manager instance by e.g. adding a single empty rule, safe mode will no longer trigger on hostile NPCs.
Describe the solution
This adjusts the logic so that the fallback logic of "NPCs are unsafe if they're trying to kill us" is still evaluated even if we have safe mode rules set.
Describe alternatives you've considered
There might be some more sophisticated option based on making safe mode more directly aware of NPC hostility, but I'm aiming for a clean bugfix to get 0.H unblocked.
Testing
I reproduced the issue by spawning a NPC who was kinda angry to start with and then provoking them so they became hostile.
Once they were hostile, safe mode triggered.
I moved away from them and added an empty safe mode rule. (just Add -> Enter)
Once I did this, safe mode no longer triggered.
After my change, I repeated this process and safe mode triggered whether there was a rule in safe mode manager or not.
Additional context
Looks like this happened in #43095 attempting to avoid translation overhead. This restores the previous logic without regressing on that perf change.
Both options are arguably correct, but it seems unlikely that "ignore NPCs that are actively trying to kill me" is ever what you want.