Bay 12 Games Forum

Please login or register.

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

Author Topic: Help with healing a dwarf. Dfhack etc...  (Read 10891 times)

Bates

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #15 on: January 15, 2013, 05:48:02 pm »

Ah, so the death time of a creature from old age is decided at birth?
And here I was believing, that the game checked dwarves age at each new year and rolling randomly wheter they die or not.  :)

I had a feeling, that the old_year is the correct flag, I just wasn't sure how to modify it.

In any case, your script worked perfectly Warmist, thanks a bunch!

Oh, and if anyone wants to check their dwarves death years, you can print it with print (unit.relations.old_year)
« Last Edit: January 15, 2013, 05:55:29 pm by Bates »
Logged

crossmr

  • Bay Watcher
    • View Profile
    • Jeonsa
Re: Help with healing a dwarf. Dfhack etc...
« Reply #16 on: May 30, 2013, 07:46:14 am »

oh yeah that's because that's bit is bugged.
Code: [Select]
function tools.heal2(unit)
if unit==nil then
unit=getCreatureAtPos(getxyz())
end
unit.body.wounds:resize(0) -- memory leak here :/
unit.body.blood_count=unit.body.blood_max
--set flags for standing and grasping...
unit.status2.able_stand=4
unit.status2.able_stand_impair=4
unit.status2.able_grasp=4
unit.status2.able_grasp_impair=4
--should also set temperatures, and flags for breath etc...
unit.flags1.dead=false
unit.flags2.calculated_bodyparts=false
unit.flags2.calculated_nerves=false
unit.flags2.circulatory_spray=false
unit.flags2.vision_good=true
unit.flags2.vision_damaged=false
unit.flags2.vision_missing=false
unit.flags2.breathing_good=true
unit.counters.winded=0
unit.counters.unconscious=0
for k,v in pairs(unit.body.components) do
for kk,vv in pairs(v) do
if k == 'body_part_status' then v[kk].whole = 0  else v[kk] = 0 end
end
end
end
tools.menu:add("heal2",tools.heal2)
this will work.

Working version of this for current? When I tried to modify this for my current game, I get this:

Code: [Select]
..._34_11v00\DF_Phoebus_34_11v00\hack\scripts/healunit2.lua:6: Cannot write fiel
d unit.T_status2.able_stand: not found.
stack traceback:
        [C]: in function '__newindex'
        ..._34_11v00\DF_Phoebus_34_11v00\hack\scripts/healunit2.lua:6: in main c
hunk
        (...tail calls...)
it doesn'tlike the able_stand field..

I just made a quick and dirty edit to the code because it was complaining about variables:
Code: [Select]
local unit=dfhack.gui.getSelectedUnit()
unit.body.wounds:resize(0) -- memory leak here :/
unit.body.blood_count=unit.body.blood_max
--set flags for standing and grasping...
unit.status2.able_stand=4
unit.status2.able_stand_impair=4
unit.status2.able_grasp=4
unit.status2.able_grasp_impair=4
--should also set temperatures, and flags for breath etc...
unit.flags1.dead=false
unit.flags2.calculated_bodyparts=false
unit.flags2.calculated_nerves=false
unit.flags2.circulatory_spray=false
unit.flags2.vision_good=true
unit.flags2.vision_damaged=false
unit.flags2.vision_missing=false
unit.flags2.breathing_good=true
unit.counters.winded=0
unit.counters.unconscious=0
for k,v in pairs(unit.body.components) do
for kk,vv in pairs(v) do
if k == 'body_part_status' then v[kk].whole = 0  else v[kk] = 0 end
end
end
Logged
Pages: 1 [2]