Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 349 350 [351] 352 353 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1443723 times)

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5250 on: February 17, 2014, 01:52:23 am »

Yeah, those are missing for whatever reason, but here's a simple function that should do the same thing (weighted for syndromes as well):

Code: [Select]
function getAttrValue(unit,attr,mental)
    if unit.curse.attr_change then
        if mental then
            return (unit.status.current_soul.mental_attrs[attr].value+unit.curse.attr_change.ment_att_add[attr])*unit.curse.attr_change.ment_att_perc[attr]/100
        else
            return (unit.body.physical_attrs[attr].value+unit.curse.attr_change.phys_att_add[attr])*unit.curse.attr_change.phys_att_perc[attr]/100
        end
    else
        if mental then
            return unit.status.current_soul[attr].value
        else
            return unit.body.physical_attrs[attr].value
        end
    end
end

So if you want SPATIAL_SENSE:

Code: [Select]
print(getAttrValue(dfhack.gui.getSelectedUnit(),'SPATIAL_SENSE',true))
STRENGTH:

Code: [Select]
print(getAttrValue(dfhack.gui.getSelectedUnit(),'STRENGTH'))
« Last Edit: February 17, 2014, 01:57:52 am by Putnam »
Logged

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5251 on: February 17, 2014, 01:55:19 am »

Yeah, those are missing for whatever reason, but here's a simple function that should do the same thing (weighted for syndromes as well):

Oops, forgot to actually add those to the export list - will be fixed in the next release whenever that happens.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5252 on: February 17, 2014, 06:00:24 am »

Perfect, thanks Putnam!
Logged

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5253 on: February 17, 2014, 08:16:39 pm »

So, another question: is there a function that can return the main material of any item, including corpses and organics, in a way that can be copied onto another item?  Like what you would get if you run a reaction that uses the item's material.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5254 on: February 17, 2014, 08:22:29 pm »

To return the main material, just use dfhack.matinfo.decode(item).

To copy using that, use this function as an example:

Code: [Select]
function copyItemMat(item1,item2)
    local matInfo=dfhack.matinfo.decode(item1)
    item2:setMaterial(matInfo.type)
    item2:setMaterialIndex(matinfo.index)
end

When it comes to items, knowing the vmethods that items have available is very useful:

https://github.com/Putnam3145/df-structures/blob/master/df.items.xml

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5255 on: February 18, 2014, 04:35:40 pm »

Is there a simple way of causing a body part to fall off through a script?  I've tried using a modified version of Warmist's rip-heart script but that doesn't seem to give the severed part a material, a proper size or properties, etc... I can set the damage to 100% for each layer but is there a way to run the check?

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5256 on: February 19, 2014, 12:27:31 am »

Is there a simple way of causing a body part to fall off through a script?  I've tried using a modified version of Warmist's rip-heart script but that doesn't seem to give the severed part a material, a proper size or properties, etc... I can set the damage to 100% for each layer but is there a way to run the check?
I think you need to add a wound that marks e.g. connective tissue as destroyed (or other part that connects the two) and then mark a flag to recalculate wounds. Though not sure  if that will work. My rip heart was more of a "create bodypart" experiment and dwarves can live without a heart apparently if not for the bleeding wound.

Raidau

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5257 on: February 19, 2014, 02:48:01 am »

What  is the easiest way to find dfhack.matinfo record for a given organic material? dfhack.matinfo.find() function must be able to do that, but i dont understand how it handles several arguments.

I wrote a function that takes a pair of strings returns organic material object, for example funct('DWARF','BONE') will return dwarf bone material. But then i realized that will not speed up the process of finding type/index pair :-\
Logged
Marital status manipulator
Custom item descriprions
Natural Balance Mod (2013-2015) development suspended...

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.34.11 r3
« Reply #5258 on: February 19, 2014, 09:23:05 am »

What  is the easiest way to find dfhack.matinfo record for a given organic material? dfhack.matinfo.find() function must be able to do that, but i dont understand how it handles several arguments.

I wrote a function that takes a pair of strings returns organic material object, for example funct('DWARF','BONE') will return dwarf bone material. But then i realized that will not speed up the process of finding type/index pair :-\
What exactly did you try with dfhack.matinfo.find()?

I ask because find("DWARF", "BONE"), find("DWARF:BONE"), find("CREATURE", "DWARF", "BONE"), find("CREATURE:DWARF:BONE"), find("CREATURE_MAT", "DWARF", "BONE"), and find("CREATURE_MAT:DWARF:BONE") all properly return material info for dwarf bone.
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.

Raidau

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5259 on: February 19, 2014, 11:03:57 am »

What exactly did you try with dfhack.matinfo.find()?

I ask because find("DWARF", "BONE"), find("DWARF:BONE"), find("CREATURE", "DWARF", "BONE"), find("CREATURE:DWARF:BONE"), find("CREATURE_MAT", "DWARF", "BONE"), and find("CREATURE_MAT:DWARF:BONE") all properly return material info for dwarf bone.

I tried several srings as separate arguments, find("DWARF", "BONE") still returns nil,   find("DWARF:BONE") worked just fine! thanks
Logged
Marital status manipulator
Custom item descriprions
Natural Balance Mod (2013-2015) development suspended...

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5260 on: February 19, 2014, 12:43:45 pm »

Is there a simple way of causing a body part to fall off through a script?  I've tried using a modified version of Warmist's rip-heart script but that doesn't seem to give the severed part a material, a proper size or properties, etc... I can set the damage to 100% for each layer but is there a way to run the check?
I think you need to add a wound that marks e.g. connective tissue as destroyed (or other part that connects the two) and then mark a flag to recalculate wounds. Though not sure  if that will work. My rip heart was more of a "create bodypart" experiment and dwarves can live without a heart apparently if not for the bleeding wound.

Until they are hit by an attack, creatures can even live without a head or upper body.  They can also keep body parts that are attached to the missing part, like keeping a hand when their lower arm is missing... obviously this needs fixing.
Where is the flag to recalculate wounds?  (I've tried slamming them into the ground, but that doesn't work... possibly because it's blunt damage and therefore the game ignores it as long as the creature's parts are soft.  Even if that part is supposedly cut in half already.)

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5261 on: February 19, 2014, 01:23:30 pm »

try unit.flags2.calculated_bodyparts=false

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5262 on: February 19, 2014, 05:44:56 pm »

This is always causing me trouble.
What exactly is the nature of the functions on these pages?  https://github.com/DFHack/dfhack/blob/master/library/modules/Items.cpp
Some of them seem to work, others just don't.  For instance, I'm trying to find the string value for an item type (among other info) given it's type and subtype index.  Isn't that what ItemTypeInfo is supposed to do?
But dfhack.itemtypeinfo throws an error...

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5263 on: February 19, 2014, 06:13:31 pm »

That's because it's not exported to lua. The ones in the Lua API are the only ones that are, AFAIK. Those are C++ functions specifically.

Getting type+subtype string is pretty easy with this function:

Code: [Select]
function getRawStringItem(item)
    local type=item:getType()
    local attrs=df.item_type.attrs[type]
    if not attrs.is_rawable then return df.item_type[type]..":NO_SUBTYPE" end
    local subtype=item:getSubtype()
    return df.item_type[type]..":"..df['itemdef_'..df.item_type.attrs[type].caption..'st'].find(subtype).id
end

Okay that last line is way more complex than I expected it to be.
« Last Edit: February 19, 2014, 06:35:16 pm by Putnam »
Logged

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5264 on: February 19, 2014, 07:25:32 pm »

Ah, that would explain it.

Thanks for the help!
Pages: 1 ... 349 350 [351] 352 353 ... 373