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

[WIP]NPC and player auto-crafting from workbench bills #34246

Closed
wants to merge 4 commits into from
Closed

[WIP]NPC and player auto-crafting from workbench bills #34246

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 26, 2019

Summary

SUMMARY: Features "NPC and player auto-crafting from workbench bills"

Purpose of change

Allows players to set desired crafting bills on a workbench, then press a button to fetch tools and components and work through the bills automatically, or ask an NPC to do that for you.

Describe the solution

Similar to the other multi-zone activities, this time however, there is bit of data attached to the submap, that can be set/edited/removed via the workbench menu, this is similar to partial constructions and graffiti in the way its attached to submap.

So far the crafting_bill struct only contains a map of recipe and int( batch size ), but could, in future, contain more data.

You set the recipe you want via a modification of the crafting menu( you can only set bills for things you know how to craft ), set the batch size in the normal way, you can then edit the quantity or delete any of the bills youve set there. ( if the workbench is destroyed - the bills are too, if the workbench is dragged - the bills move with it too - a bit of a hack around the fact we cant store data in furniture ).

You can then ask an NPC to do any crafting that they can, and if they have the skills for it, they will go and fetch tools and components and work on the bill.

They will create the unfinished craft item, and then start working on that, for the menus that normally would pop during crafting for selection of components or when tools go missing etc, then the NPC will favour things on the map nearby and just use what they can.

This command can also be used by the player in the shift+O zone menu.

Any unfinished craft items on that workbench will be prioritised to be worked on first, before any bills, that way, unfinished stuff is done first before any new bills are started.

As with all these other multi-zone activities, the NPC ( or player ) will tidy up afterwards and move unused tools and the finished item to an unsorted loot spot.

Describe alternatives you've considered

N/A

Additional context

Current limitations:
No liquid crafts - sorry - the liquid handling is a step too far for me at the moment, it looks a right headache for NPCs to handle that cleanly, so - just for the moment - no liquid craft bills on workbenches, or NPCs working on unfinished liquid craft items.

No vehicle workbench bills - there is probably a fairly workable solution to this, but for the moment I didnt want to get into that whole thing of vehicle movement moving the crafting_bill data with it.

Marking as WIP, as I tweak it and try and shake out all the numerous bugs that will inevitably result, and that others will surely raise, that ive not considered yet.

Im gonna test this thoroughly as it changes a lot of the crafting code. consider this v0.1

also: I dont do UI. its awful - https://cdn.discordapp.com/attachments/598535827169083403/625792508885991424/unknown.png

any pointers in this area would be appreciated.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Crafting / Construction / Recipes Includes: Uncrafting / Disassembling NPC / Factions NPCs, AI, Speech, Factions, Ownership Info / User Interface Game - player communication, menus, etc. <Enhancement / Feature> New features, or enhancements on existing Mechanics: Character / Player Character / Player mechanics Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones labels Sep 26, 2019
src/crafting_gui.cpp Outdated Show resolved Hide resolved
src/handle_action.cpp Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Oct 2, 2019

Fixed some problems.

  1. the code to place item on workbench automatically needed a force override, when the bill is already on a workbench, to use that one instead of the next one in a radius. - this caused problems with the activity tripoints stored.
  2. fixed resuming after fetching - the check for "can do one craft" was before " can do the entire batch" so after fetching one component, they stopped fetching and built just one of th ebatch - now they will fetch the entire stack, then do the entire batch if they can, and only if they cant, do they check for being able to do just one at a time.
  3. fixed tidying up after craft was completed, by ensuring the backlog id was not a reference, when the backlog was cleared soon afterwards.

@ghost ghost changed the title [WIP] NPC and player auto-crafting from workbench bills NPC and player auto-crafting from workbench bills Oct 2, 2019
@ghost
Copy link
Author

ghost commented Oct 2, 2019

Been playing with it a fair bit, and cant detect any further problems.

src/crafting.cpp Outdated Show resolved Hide resolved
src/savegame_json.cpp Outdated Show resolved Hide resolved
src/map.cpp Outdated Show resolved Hide resolved
src/crafting_gui.h Outdated Show resolved Hide resolved
src/crafting_gui.cpp Outdated Show resolved Hide resolved
src/crafting.h Outdated Show resolved Hide resolved
src/crafting.cpp Outdated Show resolved Hide resolved
src/iexamine.cpp Outdated Show resolved Hide resolved
src/savegame_json.cpp Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Oct 18, 2019

Woops managed to merge in some stuff I was working on with NPC repairing activity into this one.
Reverted those unwanted changes now

@ghost
Copy link
Author

ghost commented Oct 21, 2019

Updated a bit of a messy merge to new generic_activity structure, will test tomorrow.

@ghost
Copy link
Author

ghost commented Oct 24, 2019

seems to still work ok , post-merge conflict resolutions, minus some shenanigans when NPCs are all pathing to adjacent spots to do their job at connected workbenches, and get in each others way, but thats normal for them.

src/activity_handlers.cpp Outdated Show resolved Hide resolved
src/activity_handlers.h Outdated Show resolved Hide resolved
src/activity_item_handling.cpp Outdated Show resolved Hide resolved
src/activity_item_handling.cpp Outdated Show resolved Hide resolved
src/activity_item_handling.cpp Outdated Show resolved Hide resolved
src/activity_item_handling.cpp Outdated Show resolved Hide resolved
src/activity_item_handling.cpp Outdated Show resolved Hide resolved
src/crafting.cpp Outdated Show resolved Hide resolved
src/crafting_gui.cpp Outdated Show resolved Hide resolved
src/crafting_gui.cpp Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Nov 23, 2019

Was playing with this merged locally, and need to change the inventory code a bit - will do so post 0.E

@ghost ghost changed the title NPC and player auto-crafting from workbench bills [WIP]NPC and player auto-crafting from workbench bills Nov 23, 2019
@ghost
Copy link
Author

ghost commented Dec 8, 2019

rebased. still think theres some performance problems , with the changes to the crafting code, but that can wait until its closer to merging time post 0.E anyway.

@Funguss
Copy link
Contributor

Funguss commented Feb 19, 2020

Just wanted to say I am stupendously thankful for this and I can't wait to see this happen! Even though it doesn't include liquid crafting (my dreams of an NPC slave compound producing biodiesel from rendered tainted fat to feed my zombie-powered death mobile still won't be realised!) this is game changing and will make NPCs much, much more useful.

If only they'd get back to work without being told to... 😉 👍

Seriously, this is absolutely brilliant, well done!

@ghost
Copy link
Author

ghost commented Feb 20, 2020

Just wanted to say I am stupendously thankful for this and I can't wait to see this happen! Even though it doesn't include liquid crafting (my dreams of an NPC slave compound producing biodiesel from rendered tainted fat to feed my zombie-powered death mobile still won't be realised!) this is game changing and will make NPCs much, much more useful.

If only they'd get back to work without being told to... 😉 👍

Seriously, this is absolutely brilliant, well done!

I think I can do liquid crafting post 0.E, just need to decouple the "what to do with this liquid" code from being avatar-centric. And thanks!

@Funguss
Copy link
Contributor

Funguss commented Feb 27, 2020

Regarding the recipes... Not sure if this might end up being a rabbithole or a nightmare in some way, but what about generating a new recipe list for individual NPCs and have those added to the workbench, too, with crafting limited to the ones who know how to do them?

One approach would be to have targeted bills that only the named NPCs (or PC) can craft, or workbenches dedicated to an individual. With workbench dedication the nice touch would be that the in progress item wouldn't need to be intrinsically tied to one person (death issues) and could be reassigned relatively easily. Also, the recipe list could be limited intuitively to the character in question.

Though I imagine these would all touch on a great many different areas of code, hence my disclaimer at the start. 😕 I'd love to see this kind of thing but I'm not sure how feasible it is.

@ghost
Copy link
Author

ghost commented Feb 29, 2020

Regarding the recipes... Not sure if this might end up being a rabbithole or a nightmare in some way, but what about generating a new recipe list for individual NPCs and have those added to the workbench, too, with crafting limited to the ones who know how to do them?

One approach would be to have targeted bills that only the named NPCs (or PC) can craft, or workbenches dedicated to an individual. With workbench dedication the nice touch would be that the in progress item wouldn't need to be intrinsically tied to one person (death issues) and could be reassigned relatively easily. Also, the recipe list could be limited intuitively to the character in question.

Though I imagine these would all touch on a great many different areas of code, hence my disclaimer at the start. 😕 I'd love to see this kind of thing but I'm not sure how feasible it is.

Currently, with this PR, unfinished items are not tied to any particular NPC.
when NPCs scan for a job to work on, they check for unfinished crafts on the workbench first, but discount it if someone else is working there.

If that person walks away from the workbench, another NPC can slot in and finish the task ( if they have the skill for it )

as for reserved recipes/workbenches, I think maybe that might be useful in the future for static NPC bases, but as this PR is focused on player follower NPCs and basecamps, its not something Im going to focus on immediately.

@Funguss
Copy link
Contributor

Funguss commented Feb 29, 2020

Well, I was suggesting those mostly as workarounds to allow the player to specify a recipe that they themselves can't craft. It's one of the lacking features that would allow me to set skill gain to 0.01x, and it's also something that's generally bugged me from functionality and RP perspectives.

The other thing that's missing is having NPCs build and modify vehicles from dynamic player made templates.

Still, I'm really excited to test all these out! 😁 Roll on 0.E!

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` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling <Enhancement / Feature> New features, or enhancements on existing Info / User Interface Game - player communication, menus, etc. Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones [JSON] Changes (can be) made in JSON Mechanics: Character / Player Character / Player mechanics NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
Status: Abandoned PRs with no one to pick them up
Development

Successfully merging this pull request may close these issues.

6 participants