Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [DfHack] how to make job use a specific item  (Read 1938 times)

Bogus

  • Bay Watcher
    • View Profile
[DfHack] how to make job use a specific item
« on: April 04, 2016, 09:53:51 am »

there seems to be no direct way to manipulate the selection of actual items a job makes, after you have defined the specifics of the item you want.

currently im using a script to forbid items that i dont want in a job (like, a bag of material that doesnt have enough of that material). bascially i forbid and remove job items after the selection was made, but this is somewhat complicated and needs a lot of checking, and releasing of the items afterwards.

so basically, to just get me a suitable item, i would have to browse through all items in existance, and then write it into the job fields, or is there an easier way?
« Last Edit: April 10, 2016, 06:36:49 pm by Bogus »
Logged

Hesperid

  • Bay Watcher
    • View Profile
Re: [DfHack] how to make jobs look for (specific) items?
« Reply #1 on: April 05, 2016, 12:39:29 pm »

Since you're already doing scripting, why don't you write a script that assigns the specific item to the job that you want?
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [DfHack] how to make jobs look for (specific) items?
« Reply #2 on: April 06, 2016, 04:04:25 am »

there seems to be no direct way to manipulate the selection of actual items a job makes, after you have defined the specifics of the item you want.

currently im using a script to forbid items that i dont want in a job (like, a bag of material that doesnt have enough of that material). bascially i forbid and remove job items after the selection was made, but this is somewhat complicated and needs a lot of checking, and releasing of the items afterwards.

so basically, to just get me a suitable item, i would have to browse through all items in existance, and then write it into the job fields, or is there an easier way?
Short answer: yes you need to fillout The fields yourself.
Long answer: maybe GUI/advfort_items.lua would help?

Bogus

  • Bay Watcher
    • View Profile
Re: [DfHack] how to make jobs look for (specific) items?
« Reply #3 on: April 06, 2016, 04:14:34 am »

alright, thx. i kind of have it figured out how ill do it, but how strictly does the game check if items are suitable for job items? and do job items have to match the reaction reagents? i will be using both the onJobInitiated & onReactionComplete events.

what i want to do is cooking reactions/jobs that take very specific stuff, some of which cant be defined as a reaction reagent in raws (like an either FISH or MEAT item). also i would like to find bagged reagents myself, so the game wont bring half-full ones.

so  i was wondering how much information i need to have in the reaction raw, if any. can i just add items to my job as i please?

« Last Edit: April 06, 2016, 04:26:58 am by Bogus »
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [DfHack] how to make jobs look for (specific) items?
« Reply #4 on: April 06, 2016, 04:43:00 am »

alright, thx. i kind of have it figured out how ill do it, but how strictly does the game check if items are suitable for job items? and do job items have to match the reaction reagents? i will be using both the onJobInitiated & onReactionComplete events.

what i want to do is cooking reactions/jobs that take very specific stuff, some of which cant be defined as a reaction reagent in raws (like an either FISH or MEAT item). also i would like to find bagged reagents myself, so the game wont bring half-full ones.

so  i was wondering how much information i need to have in the reaction raw, if any. can i just add items to my job as i please?
If I remember correctly game does not check items at all. You need to perform your own "checking" (can be none). Be warned: some job types might crash df if items received are not what it expected.

For the meat/fish i think you could define them... But i'm no raw expert. And you can have as little information as you want. But having more information would help for df to do some of the job. E.g. if you change the job "onJobInitiated" state, you might force df do the tracking of the item itself, as you can fill out the "job-items" which are like requirements for the job item. You can fill it out as detailed as you wish (e.g. only dwarf-flesh meat allowed - although no-canibalism rule would not find any valid items for this job).

also this is some part of df-logic that sees if item is suitable for the job: advfort because in adventure mode it fails to fill out items automatically...

Bogus

  • Bay Watcher
    • View Profile
Re: [DfHack] how to make jobs look for (specific) items?
« Reply #5 on: April 10, 2016, 12:21:44 pm »

the problem seems to be that df just ignores the items i directly insert into the items vectors and instead finds own items matching the job_items, and using these for the job instead.

for example, my reaction has 2 reagents/job_items which are entirely undefined (basically, [REAGENT:xyz:1:NONE:NONE:NONE:NONE]). in my script i then find a bag of flour and another containing salt, and write these 2 items into the items vector. the idea here was to force df to use these exact items, instead of using the info from job_items at all. what df does instead is to grab 2 random items (say, a lungfish remains and a bucket) and use these in the job, because they fit the requirements of the 2 reagents/job_items - even tho there are already 2 entries in the items vector, which also fit the requirements.

there seems to be no way to stop this from occuring. the job_item_idx from the items i picked match the 2 corresponding job_items, they have a specific_ref with a job field that points to the job, and i tried setting different flags on the job/items(fetching, bringing). i also tried manually removing the items that df picks, which is possible, but doesnt make df use my items either.
Logged