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

Fix NPC head explodey when they leave / reenter reality bubble with an activity #35649

Merged
merged 2 commits into from Dec 9, 2019
Merged

Conversation

ghost
Copy link

@ghost ghost commented Nov 22, 2019

Summary

SUMMARY: Bugfixes "Fix NPC head explodey when they leave / reenter reality bubble with an activity"

Purpose of change

Fixes #35586

Describe the solution

There are two bugs ive fixed.

  1. from the attached issue - a discrepancy in the light level when NPC starts assessing tiles, and when they travel there, caused by the headlights of the car in the linked issue save - added some handling for differing light levels to stop NPCs constantly looping.
  2. also fixed the long-standing bug where if you walk away so the NPC leaves the reality bubble while NPCs are doing an activity, then come back, sometimes the target of the activity will not be loaded, so the NPC tries to perform the activity on an out of bounds target, causing an infinite loop. to fix this ive stashed the activity when the target tile leaves bubble, and restore it when the target tile re-enters bubble.

Describe alternatives you've considered

N/A

Testing

I tested on a tree chopping activity, walked away ( in the specific direction that would cause the tree to unload before the NPC does ) then walked back, there was one turn where the NPC was loaded and the tree was not, for that turn they paused, the next turn, the tree was loaded, and they resumed the activity properly.

I tested the attached issue savegame, and that is now fixed properly.

I did not test further on the leaving-bubble fix, for other activity types, or other permutations, as I need to sleep now, I will test further tomorrow, hence WIP for now, but code ready for review essentially.

Additional context

N/A

@Funguss
Copy link
Contributor

Funguss commented Nov 22, 2019

Brilliant! This might have an impact on NPCs deciding that they've completed all construction they can due to light levels, too. I'll have a play when it gets merged and see.

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [JSON] Changes (can be) made in JSON NPC / Factions NPCs, AI, Speech, Factions, Ownership labels Nov 22, 2019
@ghost
Copy link
Author

ghost commented Nov 23, 2019

Tested with other activities now - vehicle deconstruction/repair, butchering, constructing etc.
In all cases, walking away so the NPCs activity target unloads before it does, or walking back towards the NPC so they load before their activity target does - results in no more head exploding or infinite loops or errors. Consider this ok now.

@ghost ghost changed the title [WIP]Fix NPC head explodey when they leave / reenter reality bubble with an activity Fix NPC head explodey when they leave / reenter reality bubble with an activity Nov 23, 2019
@Funguss
Copy link
Contributor

Funguss commented Nov 24, 2019

Nice! Is it possible to have them "catch up" by simulating the time they've been unloaded? Or would that cause a bit too much lag?

@ghost
Copy link
Author

ghost commented Nov 24, 2019

Nice! Is it possible to have them "catch up" by simulating the time they've been unloaded? Or would that cause a bit too much lag?

This should happen automatically - NPCs get moves given to them in one go when they are re-loaded, so they should have a backlog of moves to work through which would do more activity turns for them.

Except in the case where they are re-loaded but the activity target isnt there, they would then use up all their extra moves in that one turn where they pause until the target is loaded too.

I'll think on a way to catch that up intelligently in another PR

@Funguss
Copy link
Contributor

Funguss commented Nov 24, 2019

This should happen automatically - NPCs get moves given to them in one go when they are re-loaded, so they should have a backlog of moves to work through which would do more activity turns for them.

Ah... I don't think they get much of a chance to display this, really. Most of the tasks I set them they 'finish' when they're nearly out of the reality bubble, just before they're unloaded. Maybe reading and such are fine, but any interaction with the world generally ends as soon as they're some distance away, or if they're on a different Z level. I don't know enough about what's going on and how extensive it is to do a report about it yet. I have a feeling the way they see things is skewed, but I don't know for sure. I haven't come up with a good way of testing this yet.

davidpwbrown added 2 commits December 8, 2019 21:09
commit to store credentials

commit to trigger rebuild

commit to trigger rebuild
@kevingranade kevingranade merged commit 4b3d7cc into CleverRaven:master Dec 9, 2019
@ghost ghost mentioned this pull request Dec 18, 2019
@ghost ghost deleted the resume_activity_fix branch December 19, 2019 14:15
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) [JSON] Changes (can be) made in JSON NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPCs deconstructing vehicles explode from infinite loop
3 participants