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 10890 times)

Bloodyharbinger

  • Bay Watcher
    • View Profile
Help with healing a dwarf. Dfhack etc...
« on: November 28, 2012, 02:38:23 pm »

Not sure if this is the right place but here goes.

So I had just started a new fort recently and in my haste pulled the wrong lever. I ended up breaking the spine of my legendary mason/engraver. This forced them to 'Ability to stand Lost'

I looked and I looked and found several lua scripts and even some dfusion tools scripts. I understand code a bit and everything should have worked as it has before in adventure mode, but it didn't. All the wounds have been healed, but the 'Ability to stand Lost' tag is still there.

Using the lua script did not return any errors but the dfusion returned 'Cannot write field vector<body_part_status>.0: complex object'. I will get the error to pop up again when I am home.

Any help would be awesome.

Edit: fixed error message.
« Last Edit: November 28, 2012, 09:32:26 pm by Bloodyharbinger »
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #1 on: November 28, 2012, 04:03:39 pm »

it would be helpful if you post the code you used.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Bloodyharbinger

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #2 on: November 28, 2012, 04:26:04 pm »

I tried code you posted actually :)

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.counters.winded=0
unit.counters.unconscious=0
for k,v in pairs(unit.body.components) do
for kk,vv in pairs(v) do
v[kk]=0
end
end
end
tools.menu:add("heal2",tools.heal2)

Also this as a stand alone lua

Code: [Select]
local unit=dfhack.gui.getSelectedUnit()
if unit then
print("Erasing wounds...")
while #unit.body.wounds > 0 do
unit.body.wounds:erase(#unit.body.wounds-1)
end
unit.body.wound_next_id=1

print("Refilling blood...")
unit.body.blood_count=unit.body.blood_max

print("Resetting status flags...")
unit.status2.able_stand_impair=unit.status2.able_stand
unit.status2.able_grasp_impair=unit.status2.able_grasp

unit.flags2.has_breaks=false
unit.flags2.gutted=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.flags2.breathing_problem=false

unit.flags2.calculated_nerves=false
unit.flags2.calculated_bodyparts=false

print("Resetting counters...")
unit.counters.winded=0
unit.counters.stunned=0
unit.counters.unconscious=0
unit.counters.webbed=0
unit.counters.pain=0
unit.counters.nausea=0
unit.counters.dizziness=0

unit.counters2.paralysis=0
unit.counters2.fever=0
unit.counters2.exhaustion=0
unit.counters2.hunger_timer=0
unit.counters2.thirst_timer=0
unit.counters2.sleepiness_timer=0
unit.counters2.vomit_timeout=0

I have also tried mixing both and changing it up but still no luck.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #3 on: November 28, 2012, 04:43:19 pm »

which version of dfhack are you using?
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Bloodyharbinger

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #4 on: November 28, 2012, 09:15:15 pm »

Just got home and recreated the error message so I could fix that mess I typed.

Cannot write field vector<body_part_status>.0: complex object

I am using the version downloaded from  https://github.com/peterix/dfhack/downloads for windows. 34.11-r2

I am going to try and reinstall on the random chance I messed up.

Edit: I reinstalled- same error. I did find that taking this section of code out stopped the error but did not heal the dwarf

Code: [Select]
for k,v in pairs(unit.body.components) do
for kk,vv in pairs(v) do
v[kk]=0
end
end
« Last Edit: November 28, 2012, 09:51:05 pm by Bloodyharbinger »
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #5 on: November 29, 2012, 12:01:14 pm »

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.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Bloodyharbinger

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #6 on: November 29, 2012, 07:26:40 pm »

You sir are awesome. Thanks for the help that did the trick. As a reward I have painted you a picture!
Logged

GreatWyrmGold

  • Bay Watcher
  • Sane, by the local standards.
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #7 on: November 29, 2012, 11:10:16 pm »

Just FYI, once they get out of the hospital they can probably crawl around and work that way.
Logged
Sig
Are you a GM with players who haven't posted? TheDelinquent Players Help will have Bay12 give you an action!
[GreatWyrmGold] gets a little crown. May it forever be his mark of Cain; let no one argue pointless subjects with him lest they receive the same.

Bates

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #8 on: January 12, 2013, 11:44:18 am »

I have a noble who is *NOT* useless, in fact she (my Duchess) is very useful usually being the first to mine, butcher, recovering wounded, etc.

The problem is, that my current save is on the last day of the year and she is 151 years old and the game has decided to kill her due to old age.
I used the heal script on her and she came back to life, but as soon as I unpause she again dies to old age.
So there is a flag on her that makes her status as "dead from old age", but I can't find it.

I just survived a BIG siege and my last save is from the beginning of the siege (some two weeks back), when one of my weaponsmiths got a mood.
And I tested this save and she is already marked to die from old age and the next newest save is 3 months back and I really don't want to play the last 3-4 months again.  :'(

Does anyone have any idea on how I could keep my all time favorite noble alive?
Logged

feelotraveller

  • Bay Watcher
  • (y-sqrt{|x|})^2+x^2=1
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #9 on: January 12, 2013, 07:03:39 pm »

This  http://dwarffortresswiki.org/index.php/User:Vjek#rejuvenate seems to be what you are looking for.  I haven't tried it myself but should make her 20 years old all over again.  Actually I've gotta figure a way to run that script on myself...   ;D
Logged

Bates

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #10 on: January 12, 2013, 08:10:10 pm »

I already tried it and it doesn't help.
I also tried rising my dwarves max age to 160:190 in the raws, but that also didn't help.

The game seems to have decided a while back, that my duchess will die of old age come new year and given her a "die from old age" flag.
So I need some way to remove that flag.
Logged

Bates

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #11 on: January 14, 2013, 01:50:22 pm »

So is there anyone, who can help me?
Anyone at all?
Please?
Pretty please with sugar on top?  :-\
Logged

smakemupagus

  • Bay Watcher
  • [CANOPENDOORS]
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #12 on: January 14, 2013, 05:18:53 pm »

The more specific you can be the more likely someone can help.

The rejuvenate script did nothing? 
did you get an error?  did you get the (unit.name.first_name.." is now 20 years old") message?

or she turned 20 and still died at the end of the year?

Bates

  • Bay Watcher
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #13 on: January 15, 2013, 03:34:34 am »

Oh sorry, didn't realize that my comment was so ambiguous.

So rejuvenate script didn't give any errors and she turned 20, even said so on her status screen, but at the end of the year she still died to old age.
I then resurrected her with the heal script and ran rejuvenate again for good measure, but as soon as I unpaused she again died to old age.

So the game must have put a dies_to_old_age flag on her, so she dies to old age even though she is only 20 years old.
« Last Edit: January 15, 2013, 03:48:27 am by Bates »
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Help with healing a dwarf. Dfhack etc...
« Reply #14 on: January 15, 2013, 02:59:06 pm »

Oh sorry, didn't realize that my comment was so ambiguous.

So rejuvenate script didn't give any errors and she turned 20, even said so on her status screen, but at the end of the year she still died to old age.
I then resurrected her with the heal script and ran rejuvenate again for good measure, but as soon as I unpaused she again died to old age.

So the game must have put a dies_to_old_age flag on her, so she dies to old age even though she is only 20 years old.
you are close. Game sets the time of death by old age to each unit upon it's birth. That script only changes the time of birth, not the time of death.
Code: [Select]
-- This script will make any dwarf live for 100 years more
-- usage is:  target a unit in DF, and execute this script in dfhack
-- via ' lua /path/to/script '


function makelivelong()
local current_year
unit=dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit under cursor!  Aborting with extreme prejudice.")
return
end

current_year=df.global.cur_year

if unit.relations.old_year < current_year+100 then
unit.relations.old_year=current_year+100
end
print (unit.name.first_name.." will die after 100 years from now")

end

makelivelong()
Try this.
« Last Edit: January 15, 2013, 03:05:22 pm by Warmist »
Logged
Pages: [1] 2