Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Improving/decorating an item via dfhack, I.E giving it a gold trim?  (Read 1680 times)

ethanwdp

  • Escaped Lunatic
    • View Profile

Is it possible? It'd be nice to spice up my adventurers gear, especially for my current high-ranking paladin. I've been looking into this on and off for a few days now, both with dfhack scripting and Google and I haven't been able to find anything.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Improving/decorating an item via dfhack, I.E giving it a gold trim?
« Reply #1 on: December 13, 2016, 01:24:36 pm »

It should be. Look at an improved item with "gui/gm-editor", that should get you started.

If you want some actual code I think I do some improving with Lua code in the "User/Powered/Decorator" Rubble addon and in the Underhive Settlement mod.
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

ethanwdp

  • Escaped Lunatic
    • View Profile
Re: Improving/decorating an item via dfhack, I.E giving it a gold trim?
« Reply #2 on: December 14, 2016, 10:22:57 am »

It should be. Look at an improved item with "gui/gm-editor", that should get you started.

If you want some actual code I think I do some improving with Lua code in the "User/Powered/Decorator" Rubble addon and in the Underhive Settlement mod.

I use gm-editor a ton, the problem is finding an improved item. Most towns don't even have an armor shop, and it's a gamble to whether or not they have trimmed armor.


As for the lua, thanks! I'll take a look and report back if I have any luck with it.
« Last Edit: December 14, 2016, 10:26:15 am by ethanwdp »
Logged

ethanwdp

  • Escaped Lunatic
    • View Profile
Re: Improving/decorating an item via dfhack, I.E giving it a gold trim?
« Reply #3 on: December 14, 2016, 01:03:42 pm »

It should be. Look at an improved item with "gui/gm-editor", that should get you started.

If you want some actual code I think I do some improving with Lua code in the "User/Powered/Decorator" Rubble addon and in the Underhive Settlement mod.

I use gm-editor a ton, the problem is finding an improved item. Most towns don't even have an armor shop, and it's a gamble to whether or not they have trimmed armor.


As for the lua, thanks! I'll take a look and report back if I have any luck with it.

I've figured it out. Item modifications are userdata tables stored in df (the table, not the game). Searching through there, I could easily find what I had to do in order to add a modification. Calling df.new() generates a table of that type for me, and all I had to do was assign the values. Here's the script I've made, it's a little rough around the edges and doesn't apply the table to the item yet (as it's not finished) but it's a good proof of concept.


Spoiler (click to show/hide)

« Last Edit: December 14, 2016, 02:57:37 pm by ethanwdp »
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Improving/decorating an item via dfhack, I.E giving it a gold trim?
« Reply #4 on: December 16, 2016, 02:35:29 pm »

That looks about right. I haven't tested it, but you are certainly on the right road.

One thing to keep in mind: For some reason dyeing an item is more complicated than most improvements. I don't remember what all needs to be set, but there are extra fields that need to be set with the dye material (in addition to (maybe instead of?) the basic improvment material fields).
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

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Improving/decorating an item via dfhack, I.E giving it a gold trim?
« Reply #5 on: December 16, 2016, 04:54:00 pm »

Yeah, itemimprovement_threadst has a field for the thread (so you could put rope reed or elf hair or whatever) and that has a dye field for the actual colors where you can put the different dye materials for emerald/red/blue/grey.

Fun fact: assigning default improvement types lets them be used elsewhere. I tried putting a default handle improvement for stone axes and found I could add them to weapons and such as well. There's no reason you couldn't add strap or padding improvements, trim improvements, etc. [DEFAULT_IMPROVEMENT:TRIM:METAL] or something, if you use one of the ANY_HARD_MAT tags it will add extra nonsensical versions like "the trim is frozen gecko demon extract" so you gotta work around that but they work fine when added later.

You could write a script to alter an existing reaction so it adds art images btw, tweaking them through df.global.world.raw.reactions works properly, just gets ignored if you add the tag before loading the save.
Logged