Allow NPCs to use basecamp storage zone for activities/jobs #37325
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: Features "Allow NPCs to use basecamp storage zone for activities/jobs"
Purpose of change
Allow NPCs to use basecamp storage zone for activities/jobs
Describe the solution
So a b it of a rabbit hole.
I wanted them to use components for activities , in a basecamp storage zone, if they were assigned to the camp.
Turns out the usual checks for is_assigned_to_camp() failed when their mission was NPCMISSION_ACTIVITY, because the check was for NPCMISSION_ASSIGNED_CAMP.
So I needed to change how that worked, it made no sense to check for their mission, when the mission can change, but their assigned status should remain constnat until told to leave the camp.
This then meant I had to define assigned status by another way, which was to use the job system.
a new job of NPCJOB_NOJOB is default given to all npcs, this means they are not assigned to a camp, wheras NPCJOB_NULL is assigned to a camp, but no particular duties.
So the check became has_job() && position == camp position.
But the check for camp position was flawed too, because a camp can occupy 9 omts, but it only checked if the NPC was at the centre one, so I added a check to see if they were within 3 omts of the centre omt.
This then succesfully made the check for an NPC to define whether they were assigned to a camp a bit saner, I then changed some of the activity code, and discovered a bug where they werent tidying up after themselves, so fixed that.
( I also spent around an hour trying to debug why an NPC wasnt doing constructing, only to find out that they couldnt see far enough to move the components near the work spot, as they were short-sighted and had no glasses - so another thing to add to #37300
Describe alternatives you've considered
N/A
Testing
Made a camp, made some construction task zones nearby, added a basecamp storage zone, put the components there, assigned the NPC to the camp, gave them building job.
Waited minutes, NPC went and fetched from basecamp storage zone, and did the tasks.
No need for a seperate loot zone.
Additional context
N/A