Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 287 288 [289] 290 291 ... 360

Author Topic: DFHack 0.43.03-r1  (Read 1078886 times)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.42.06-r1
« Reply #4320 on: May 25, 2016, 02:10:18 pm »

Hey guys, I just read about forceequip:
Quote
forceequip
Forceequip moves local items into a unit’s inventory. It is typically used to equip specific clothing/armor items onto a dwarf, but can also be used to put armor onto a war animal or to add unusual items (such as crowns) to any unit.

For more information run forceequip help. See also modtools/equip-item.

How could I use this to target a pet pastured on a workshop? As in:
1. Pasture pet on custom workshop.
2. Dwarf runs a reaction; reagent in reaction is the armor that will be put on the pet.
3. Pet now wears said armor.

I knew the syntax in the older dfhack scripts, but I'm not sure how to do this with the Onload.init. Can it even target units in workshops?
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 :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4321 on: May 25, 2016, 03:11:47 pm »

Hey guys, I just read about forceequip:
Quote
forceequip
Forceequip moves local items into a unit’s inventory. It is typically used to equip specific clothing/armor items onto a dwarf, but can also be used to put armor onto a war animal or to add unusual items (such as crowns) to any unit.

For more information run forceequip help. See also modtools/equip-item.

How could I use this to target a pet pastured on a workshop? As in:
1. Pasture pet on custom workshop.
2. Dwarf runs a reaction; reagent in reaction is the armor that will be put on the pet.
3. Pet now wears said armor.

I knew the syntax in the older dfhack scripts, but I'm not sure how to do this with the Onload.init. Can it even target units in workshops?

Currently I think the best you can do is
Code: [Select]
modtools/reaction-trigger -reactionName X -allowNonworkerTargets -command [ script here but make sure you use \\TARGET_ID instead of \\WORKER_ID ]
Haven't tested it myself, but if I am reading the script right it should work. Also, unlike reaction-product-trigger reaction-trigger doesn't need to create a product.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.42.06-r1
« Reply #4322 on: May 25, 2016, 03:59:14 pm »

Haven't tested it myself, but if I am reading the script right it should work. Also, unlike reaction-product-trigger reaction-trigger doesn't need to create a product.
Thanks... I get as far as "no unit found at cursor", so the script does run, but as always the script is not optimized for use in a workshop. It requires a cursor for the location. :/ I used the plugin forceequip. I couldnt get modtools/equip-items to work this way.
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 :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4323 on: May 25, 2016, 05:49:43 pm »

Haven't tested it myself, but if I am reading the script right it should work. Also, unlike reaction-product-trigger reaction-trigger doesn't need to create a product.
Thanks... I get as far as "no unit found at cursor", so the script does run, but as always the script is not optimized for use in a workshop. It requires a cursor for the location. :/ I used the plugin forceequip. I couldnt get modtools/equip-items to work this way.

Yeah, just looked at forceequip, that plugin isn't set up for use in reactions. What about this

Code: [Select]
modtools/reaction-product-trigger -reactionName "Equip Animal Armor" -allowNonworkerTargets -command [ modtools/equip-item -unit \\TARGET_ID -item \\INPUT_ITEMS -bodyPart UB -mode Worn ]
For the reaction you will want the armor you want to equip as the only reagent, and you will need one product. Conversely you could change \\INPUT_ITEMS to \\OUTPUT_ITEMS, have the reagents be whatever you want the armor to be made out of and then the product to be the armor itself.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.42.06-r1
« Reply #4324 on: May 25, 2016, 07:01:11 pm »

I get the error message about "cannot write field: item.find: Number expected".

I tried  \\INPUT_ITEMS, \\OUTPUT_ITEMS, both with \\\ and both with []. I also tried an item ID, like ARMOR:ITEM_ARMOR_BREASTPLATE:INORGANIC:STEEL. None of those help, same error message.
« Last Edit: May 25, 2016, 07:04:02 pm by Meph »
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 :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4325 on: May 25, 2016, 07:13:06 pm »

I get the error message about "cannot write field: item.find: Number expected".

I tried  \\INPUT_ITEMS, \\OUTPUT_ITEMS, both with \\\ and both with []. I also tried an item ID, like ARMOR:ITEM_ARMOR_BREASTPLATE:INORGANIC:STEEL. None of those help, same error message.

It must be because \\INPUT_ITEMS and \\OUTPUT_ITEMS are given you a table of values instead of an individual one. My last suggestion would be, if you make the piece of armor in the reaction so that it is the product you can replace \\OUTPUT_ITEMS with \\\LAST and that should work.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.42.06-r1
« Reply #4326 on: May 25, 2016, 07:25:16 pm »

My last try was \\LAST and \\\LAST
Code: [Select]
modtools/reaction-trigger -reactionName TEST_PET_ARMOR1 -allowNonworkerTargets -command [ modtools/equip-item -unit \\TARGET_ID -item \\\LAST -bodyPart UB -mode Worn ]
Thats it for now... same thing with the item error. I did use reaction-trigger, not reaction-product-trigger, which yet again doesnt want to trigger, no idea why.

Could I not hardcode the item into the script? Change these lines:
Code: [Select]
local itemId = tonumber(args.item) or ((args.item == '\\LAST') and (df.global.item_next_id-1))
local item = df.item.find(itemId)
if not item then
  error('invalid item!', args.item)
end
to include something like ARMOR:ITEM_ARMOR_ANIMAL:INORGANIC:STEEL ?
« Last Edit: May 25, 2016, 07:28:05 pm by Meph »
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 :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4327 on: May 25, 2016, 07:52:35 pm »

Yes you could, you could replace
Code: [Select]
itemId = tonumber(args.item) or ((args.item == '\\LAST') and (df.global.item_next_id-1))with
Code: [Select]
item = 'ARMOR:ITEM_ARMOR_ANIMAL'
mat = 'INORGANIC:STEEL'
itemId = dfhack.items.createItem(dfhack.items.findType(item), dfhack.items.findSubtype(item), dfhack.matinfo.find(mat)['type'], dfhack.matinfo.find(material).index, unit)

After you brought it up I decided that I wanted to expand that system so that you could give units special jewelry, armor to pets, various tools like smoke bombs and grappling hooks, etc... So I am planning on making it more robust, including auto forbidding items so dwarfs won't just take the items off, possibly also including adding ownership of items.
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4328 on: May 25, 2016, 08:08:37 pm »

Yes you could, you could replace
Code: [Select]
itemId = tonumber(args.item) or ((args.item == '\\LAST') and (df.global.item_next_id-1))with
Code: [Select]
item = 'ARMOR:ITEM_ARMOR_ANIMAL'
mat = 'INORGANIC:STEEL'
itemId = dfhack.items.createItem(dfhack.items.findType(item), dfhack.items.findSubtype(item), dfhack.matinfo.find(mat)['type'], dfhack.matinfo.find(material).index, unit)

After you brought it up I decided that I wanted to expand that system so that you could give units special jewelry, armor to pets, various tools like smoke bombs and grappling hooks, etc... So I am planning on making it more robust, including auto forbidding items so dwarfs won't just take the items off, possibly also including adding ownership of items.
The only problem here is that you are creating a new item from whole cloth, so any quality level of the reagent is lost.  As long as it's going to be a custom script, it might be easier to customize the \\INPUT_ITEMS to refer specifically to the first item.  That will retain quality levels, name, artifact status, etc.
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

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4329 on: May 25, 2016, 10:09:58 pm »

Dirst: Thanks for all your work on create-unit. I can't really help with it now but I'll include that version next chance I get.

I'm having trouble getting interaction-trigger to trigger anything at all in both arena mode and adventure mode.

It doesn't seem to be reading the attack string or defense string that I put for the trigger to activate, because I also put -suppressAttack and
-suppressDefense and I am still able to see the attack string in my combat logs.

Quote
modtools/interaction-trigger -onAttackStr "ORC_ATTACK_A" -onDefenseStr "ORC_DEFEND_D" -suppressAttack -suppressDefend -command [ item/projectile -unit_source \\ATTACKER_ID -unit_target \\DEFENDER_ID -item AMMO:ITEM_AMMO_BOLTS -mat INORGANIC:IRON -number 5 -maxrange 500 -hitchance 100 ]

Would there be any problems if the creature that could do the interaction didn't learn it but was spawned with the ability to do it?

It works by reading announcement logs, and those are slightly different in adventure mode / arena so it only works in fortress mode. It's harder than it sounds to fix it. Currently it does a lot of tricky things to cut down on ambiguity but can occasionally get confused if two units with the same name (as it shows up in the combat log) are in the same tile. Those things would have to be different in different modes.

Meph: currently modtools/equip-item is only designed for equipping one item at a time, so if you pass a list of item ids it won't know how to handle it. You'd need a wrapper script to equip items in this way, even if there's just one, because it's a *list* of one item id instead of just one item id.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.42.06-r1
« Reply #4330 on: May 26, 2016, 03:19:02 am »

Yes you could, you could replace
Code: [Select]
itemId = tonumber(args.item) or ((args.item == '\\LAST') and (df.global.item_next_id-1))with
Code: [Select]
item = 'ARMOR:ITEM_ARMOR_ANIMAL'
mat = 'INORGANIC:STEEL'
itemId = dfhack.items.createItem(dfhack.items.findType(item), dfhack.items.findSubtype(item), dfhack.matinfo.find(mat)['type'], dfhack.matinfo.find(material).index, unit)

After you brought it up I decided that I wanted to expand that system so that you could give units special jewelry, armor to pets, various tools like smoke bombs and grappling hooks, etc... So I am planning on making it more robust, including auto forbidding items so dwarfs won't just take the items off, possibly also including adding ownership of items.
Did that. Bad Argument at #1 to 'find' (string expcted, go nil) at line 78, the one I changed.

I tried:
Code: [Select]
modtools/reaction-trigger -reactionName TEST_PET_ARMOR2 -allowNonworkerTargets -command [ modtools/equip-item-animal -unit \\TARGET_ID -item ARMOR:ITEM_ARMOR_ANIMAL:INORGANIC:STEEL -bodyPart UB -mode Worn ]
modtools/reaction-trigger -reactionName TEST_PET_ARMOR1 -allowNonworkerTargets -command [ modtools/equip-item-animal -unit \\TARGET_ID -item ARMOR:ITEM_ARMOR_ANIMAL -bodyPart UB -mode Worn ]
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 :::

jecowa

  • Bay Watcher
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4331 on: May 29, 2016, 10:20:51 am »

Is it accurate to call DFHack a modding API that comes with a few built-in mods?
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4332 on: May 29, 2016, 10:24:59 am »

Yes.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4333 on: May 29, 2016, 04:09:17 pm »

It's really more of a memory hacking API. Like cheat engine, but significantly more high-level due to most things already being mapped out.

kane_t

  • Bay Watcher
    • View Profile
Re: DFHack 0.42.06-r1
« Reply #4334 on: May 29, 2016, 10:29:49 pm »

I'm guessing the answer is "no," but does DFHack expose any hardcoded variables, like the happiness bonuses for different positive emotions?  I imagine most of them are elided by the compiler, but I know I've, in the past, used vectors full of constants in my own games.

I'm curious about making dwarven moods more difficult to handle.  I've always considered it too easy to make dwarves happy by giving them large rooms.  What I actually think should happen is that dwarves should become inured to specific luxuries after a while, but that would require new mechanics on Tarn's part (or a really obnoxiously complicated plugin that shadows the entire mood system).  But, just making them less ecstatic about having a nice dining room would be a start.
Logged
Pages: 1 ... 287 288 [289] 290 291 ... 360