Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Quality control  (Read 2335 times)

Manzeenan

  • Bay Watcher
  • [SLOWLEARNER]
    • View Profile
Quality control
« on: December 28, 2014, 04:30:57 pm »

How would I go about creating a reaction that can take any weapon and raise its quality at least one level? Is this even possible?
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: Quality control
« Reply #1 on: December 28, 2014, 05:01:37 pm »

How would I go about creating a reaction that can take any weapon and raise its quality at least one level? Is this even possible?
Not with raw modding alone, and I'm not sure there's much of a roleplaying justification for such a reaction: it'd be easier to make a similar item of higher quality than to 'fix' an existing one.

That said, I know you can manipulate wear levels with DFHack, I'm pretty sure quality levels could be overwritten as well.  To invoke DFHack from a reaction, you make a Lua script to do what you want, then set up a reaction-trigger in the onload.init file.

Another way is to register an event in Lua, which would probably be easier to identify the item being upgraded:

Code: (improve-thing.lua) [Select]
local event = require "plugins.eventful"

function improveThing(reaction, unit, input_items, input_reagents, output_items, call_native)
-- code to increment the quality of the output_items
end

event.registerReaction("LUA_HOOK_IMPROVE_THING", improveThing)
« Last Edit: December 28, 2014, 05:07:21 pm by Dirst »
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Quality control
« Reply #2 on: December 28, 2014, 05:09:23 pm »

Like Dirst said, such a thing would be trivial with some DFHack Lua-fu. It would be hard to target the item if you did it via reaction-trigger, but I think it could be done trivially with Lua hooks (using eventful).

If I had my DF stuff on this computer I would even code it up for you (but I don't, and I won't be home until sometime after tuesday, and then I won't have internet *sigh*).
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Quality control
« Reply #3 on: December 28, 2014, 06:11:18 pm »

That would be a very nice script to have. Reaction accepts any weapon that is not masterwork, levels it up one quality level. I'd put that into MasterworkDF in a heartbeat.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Quality control
« Reply #4 on: December 28, 2014, 06:19:44 pm »

Lua hooks are the way to go in most cases, the number of things they can do that are difficult or impossible to do with reaction-trigger is just INSANE. If you can wait a week or two I'll see what I can do :)

(Don't get me wrong, reaction-trigger is really nice (way better than autoSyndrome anyway), but Lua hooks are more powerful in every possible way)
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: Quality control
« Reply #5 on: December 28, 2014, 06:29:57 pm »

That would be a very nice script to have. Reaction accepts any weapon that is not masterwork, levels it up one quality level. I'd put that into MasterworkDF in a heartbeat.
I know that reaction-trigger is 0.40-only (and it doesn't even pass a reference to the reaction's products).  I'm not sure about the eventful Lua hook, but I wouldn't be surprised if it was as well.

Items have a .item_quality characteristic which is a simple integer that can be manipulated.  Something like

Code: [Select]
local event = require "plugins.eventful"

function improveThing(reaction, unit, input_items, input_reagents, output_items, call_native)
    local upgradeItem
    upgradeItem = output_items[1]

    if upgradeItem.item_quality < 6 then
        upgradeItem.item_quality = upgradeItem.item_quality + 1
    end
end

event.registerReaction("LUA_HOOK_IMPROVE_THING", improveThing)

Can't actually run this right now, so be sure to check the output_items object before doing anything drastic.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Manzeenan

  • Bay Watcher
  • [SLOWLEARNER]
    • View Profile
Re: Quality control
« Reply #6 on: December 28, 2014, 07:09:42 pm »

Didn't expect this much actual feedback, this is awesome  :)
Logged

kiwiphoenix

  • Bay Watcher
    • View Profile
Re: Quality control
« Reply #7 on: December 28, 2014, 08:12:01 pm »

If you don't want to rely on DFHack, you could use the neat little trick given to us in this latest version, Toad be praised.

Spoiler (click to show/hide)

This will use up any stone or metal weapon and produce a copy, potentially with a different quality level.
Now, I personally use this for adventure mode, but you could pretty easily put it into Fortress mode.
It's not guaranteed to raise the quality level, but a low-qual weapon honed by an expert worker will almost certainly improve.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Quality control
« Reply #8 on: December 28, 2014, 09:30:50 pm »

Dirst's code was almost exactly what I would have used (and yes, it will work for 34.11).

Not 100% sure if it will work without testing it, but it should work just fine.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Manzeenan

  • Bay Watcher
  • [SLOWLEARNER]
    • View Profile
Re: Quality control
« Reply #9 on: December 28, 2014, 09:48:22 pm »

If you don't want to rely on DFHack, you could use the neat little trick given to us in this latest version, Toad be praised.

Spoiler (click to show/hide)

This will use up any stone or metal weapon and produce a copy, potentially with a different quality level.
Now, I personally use this for adventure mode, but you could pretty easily put it into Fortress mode.
It's not guaranteed to raise the quality level, but a low-qual weapon honed by an expert worker will almost certainly improve.
This mightve been what I was initially looking for, does this use a stone and does it work in fort mode? I might make a grindstone workshop that uses oil as a reagent.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Quality control
« Reply #10 on: December 28, 2014, 10:07:12 pm »

ROCK is little stone picked up off the ground in ADV mode, use BOULDER for fortress mode (assuming you want to use a hunk of stone), other than that you will want to replace ADVENTURE_MODE_ENABLED with a BUILDING tag (and unless you want to randomly want to lose your weapon change the "95" to "100").
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Raidau

  • Bay Watcher
    • View Profile
Re: Quality control
« Reply #11 on: December 28, 2014, 11:12:49 pm »

The script you are looking for already exists, see here
http://www.bay12forums.com/smf/index.php?topic=135597.0
Logged
Marital status manipulator
Custom item descriprions
Natural Balance Mod (2013-2015) development suspended...

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Quality control
« Reply #12 on: December 28, 2014, 11:21:42 pm »

That effects the currently equipped weapon, not really suitable for use in a fortress mode reaction.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Raidau

  • Bay Watcher
    • View Profile
Re: Quality control
« Reply #13 on: December 29, 2014, 05:53:23 am »

Quote
item-imbue - changes the material of an item with a reaction
Logged
Marital status manipulator
Custom item descriprions
Natural Balance Mod (2013-2015) development suspended...

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Quality control
« Reply #14 on: December 29, 2014, 06:53:44 am »

We are talking about changing the quality not the material.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS
Pages: [1] 2