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

Allow NPCs to use basecamp storage zone for activities/jobs #37325

Closed
wants to merge 4 commits into from
Closed

Allow NPCs to use basecamp storage zone for activities/jobs #37325

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 23, 2020

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

@curstwist curstwist added [C++] Changes (can be) made in C++. Previously named `Code` Player Faction Base / Camp All about the player faction base/camp/site labels Jan 24, 2020
@kevingranade
Copy link
Member

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/basecamp-what-do-i-need-to-make-butchering-job-actually-work/22565/5

@ZhilkinSerg ZhilkinSerg added 0.E Feature Freeze <Enhancement / Feature> New features, or enhancements on existing labels Jan 27, 2020
@ghost
Copy link
Author

ghost commented Feb 21, 2020

closing as im redoing jobs in a separate PR that will neaten it all up and make more sense with some future goals.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Player Faction Base / Camp All about the player faction base/camp/site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants