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 "NPC running off fix"
Purpose of change
sometimes your follower NPC just decided to randomly run away at max speed into the distance.
Fixes #31872
Split off from #31696
Describe the solution
There were two things happening as best I can tell :
When an activity was set to null, but the NPCs mission or attitude was still set to do an activity... when it came time for the NPC AI to choose an action, it didnt choose follow player, cos the NPCs attitude was not NPCATT_FOLLOW, and it didnt choose to do the activity, because the activitiy was null, so it reverte to what dynamic NPCs do and chose a long_term_goal to travel to.
I've fixed this by catching cases where the activitiy is null, but the MISSION/ATTITUDE needs to be reverted, and reverting them.
A seperate issue was that the NPCs path to destination to complte the activitiy, used player-centric code, which meant that if the player moved while the NPC was travelling to their activitiy, their path points got shifted, and that meant they were constantly travelling in one direction.
Ive fixed this by using an absolute co-ord to set their target point, to path to.
Describe alternatives you've considered
N/A
Additional context
N/A