Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How can I remove "forge (metal) weapon" in favor of a custom reaction?  (Read 837 times)

Lurksquatch

  • Bay Watcher
    • View Profile

I'm trying to make weapons (namely, early firearms) that require more than just a given amount of metal to build. While I already have a reaction put together that allows dwarves to make firearms out of metal, firing mechanisms and wood, there is still the option to simply forge rifles out of metal without the other ingredients. Is there a way to make it so a custom weapon can only be produced through a custom reaction?
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions

For weapons and armor, you could ensure that it's not included in the civilization's list of permitted equipment, but that might also prevent it from being available in other circumstances (e.g. embark, trade, sieger equipment, and various places in Adventurer mode).

If the above turns out to actually be a problem, the only other method I can think of would be to write a DFHack plugin which dynamically removes those jobs from the workshop's menus (which is only possible with certain workshops) and also from the job manager (which I only know how to do with the old-style job manager from 0.31 and earlier). A script might work, though I don't know if it's possible to register callbacks for opening the relevant menus.

Edit:

For workshops, you'd want to hook into building_workshopst::fillSidebarMenu() and/or building_furnacest::fillSidebarMenu() (and further check the building subtype) and modify the contents of df::global::ui_sidebar_menus->workshop_job appropriately (namely, removing from choices_all and choices_visible based on the value of category_id and possibly other fields too). Be aware that this does not work for all buldings - notably, it doesn't work with the Jeweler, Mechanic, Butcher, Fishery, Loom, Kennel, or Dyer workshops.

For the simple work order manager (u->m->q), you'd want to hook into viewscreen_jobmanagementst::feed(), watch for the MANAGER_NEW_ORDER keybinding, let it open viewscreen_createquotast, then filter its orders and all_orders lists.
« Last Edit: July 01, 2020, 10:53:22 am by Quietust »
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

Lurksquatch

  • Bay Watcher
    • View Profile

I'll try removing the weapons and ammo from their equipment list. I would prefer that traders etc. be able to bring firearms with them, but I have no clue how to use DFHack, so that might have to be the solution.

Thanks for the advice. I'll update this thread if it works or not. If anyone else has an idea, I'm all ears.
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions

For reference, I've done this exact sort of job availability manipulation in a version of DFHack I ported to DF v0.23.130.23a (yes, that's the old 2D version in which Boatmurdered took place), specifically in this plugin (for adding some extra jobs).

It doesn't do exactly what you're trying to do (it adds new jobs rather than removing existing ones), but if a plugin turns out to be necessary for what you're trying to do, it should provide an excellent starting point, only requiring minimal changes in order to get it to compile (like adjusting the viewscreen hooks to use feed/logic/render instead of the combined view, renaming the building vmethod hook to match what was used in 0.34+, and changing the material selectors from the old "material/matgloss" scheme to the "mat_type"/"mat_index" that was introduced in 0.31).
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

Lurksquatch

  • Bay Watcher
    • View Profile

So, after some testing and IRL interruptions, I have returned. Removing the firearms and bullets from the Dwarf Entity did remove the option to simply forge them out of bars of metal, instead of building them from various components. However, this did in fact remove the ability to buy them at embark, and it prevents dwarven traders from bringing them. After a bit of thought, I've decided this is an acceptable outcome.

Thanks for the advice!
Logged