Bay 12 Games Forum

Please login or register.

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

Author Topic: [title edited] semi-solution for starving/dehydrated prisoners and patients  (Read 17474 times)

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile

Do you have a 0.34.11 save with a starving/dehydrated prisoner (that you could upload) or at least a quick way of creating criminals that I could have put in jail?

I am trying to tackle an old bug, and this could save me some time.

I suppose having a wounded dwarf in the hospital who is or isn't being fed/watered would be useful too.

UPDATE: See new post below for solution: http://www.bay12forums.com/smf/index.php?topic=138609.msg5286137#msg5286137

UPDATE 2: The relevant bug report: http://www.bay12games.com/dwarves/mantisbt/view.php?id=2606
« Last Edit: May 16, 2014, 10:52:47 pm by Urist Da Vinci »
Logged

Argonnek

  • Bay Watcher
  • Surging Forward
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #1 on: May 15, 2014, 08:23:29 pm »

Have an animal trainer train a bunch of war dogs, then slaughter them all for their meat. The resulting tantrum might get him sent to jail.

FrankMcFuzz

  • Bay Watcher
  • Accomplished Cat Cooker
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #2 on: May 15, 2014, 08:59:24 pm »

Do you have a 0.34.11 save with a starving/dehydrated prisoner (that you could upload) or at least a quick way of creating criminals that I could have put in jail?

I am trying to tackle an old bug, and this could save me some time.

I suppose having a wounded dwarf in the hospital who is or isn't being fed/watered would be useful too.

Actually, this happens to me all the time, but I fixed the issue with a clever usage of garbage dumps and nobody else got thrown in jail. But please, fix it, it hurts my brain how often it happens.

Also, SOMEONE might get thrown in jail for a tantrum when they punch someone through the face, but the tantrum spiral may get too out of hand to be a decent replication of the starving prisoner problem.
Logged
Urist cancels rest injury: Too injured

BenLubar

  • Bay Watcher
  • [BODY:HUMANOID_LEGLESS_6ARMS]
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #3 on: May 15, 2014, 11:03:58 pm »

You could just ignore mandates and make sure none of your dwarves have "feed/water prisoners" enabled.
Logged

FrankMcFuzz

  • Bay Watcher
  • Accomplished Cat Cooker
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #4 on: May 15, 2014, 11:28:18 pm »

Is there a DFHack for "Incriminate" or "Create vampire"? Because that's two ways to make criminals.
Logged
Urist cancels rest injury: Too injured

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #5 on: May 16, 2014, 12:34:17 am »

You could just ignore mandates and make sure none of your dwarves have "feed/water prisoners" enabled.

The bug is that they will sometimes (all the time?) not do this even when that labor is enabled.

FrankMcFuzz

  • Bay Watcher
  • Accomplished Cat Cooker
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #6 on: May 16, 2014, 12:35:48 am »

You could just ignore mandates and make sure none of your dwarves have "feed/water prisoners" enabled.

The bug is that they will sometimes (all the time?) not do this even when that labor is enabled.

I'd agree with all the time.
Logged
Urist cancels rest injury: Too injured

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #7 on: May 16, 2014, 12:53:28 am »

I just embarked with a modded expedition leader who makes mandates - when those mandates expire, I should get some criminals.

FrankMcFuzz

  • Bay Watcher
  • Accomplished Cat Cooker
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #8 on: May 16, 2014, 12:57:33 am »

I just embarked with a modded expedition leader who makes mandates - when those mandates expire, I should get some criminals.

Have a jail built and sherriff appointed before it happens, otherwise it'll just say "no sentence pending"
Logged
Urist cancels rest injury: Too injured

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Anyone have a 0.34.11 save with a starving/dehydrated prisoner?
« Reply #9 on: May 16, 2014, 01:55:59 am »

Got my criminal, testing has commenced.

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile

This DFHack lua script appears to "debug" a unit that needs feeding/watering. Appears to work on prisoners (chained OR caged), patients, and loose babies.

Code: [Select]
unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

print(unit)
print(unit.counters2.thirst_timer)

for k,v in pairs(unit.status.misc_traits) do
print(k, v.id, v.value, df.misc_trait_type[v.id])
if v.id == 0 then v.value=0 end --GiveWater cooldown set to zero
if v.id == 1 then v.value=0 end --GiveFood cooldown set to zero
end


The game has cooldowns for how often a creature can be fed/watered, and sometimes these cooldowns get stuck or reset to a large number without the unit actually being fed/watered.

FrankMcFuzz

  • Bay Watcher
  • Accomplished Cat Cooker
    • View Profile

This DFHack lua script appears to "debug" a unit that needs feeding/watering. Appears to work on prisoners (chained OR caged), patients, and loose babies.

Code: [Select]
unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

print(unit)
print(unit.counters2.thirst_timer)

for k,v in pairs(unit.status.misc_traits) do
print(k, v.id, v.value, df.misc_trait_type[v.id])
if v.id == 0 then v.value=0 end --GiveWater cooldown set to zero
if v.id == 1 then v.value=0 end --GiveFood cooldown set to zero
end


The game has cooldowns for how often a creature can be fed/watered, and sometimes these cooldowns get stuck or reset to a large number without the unit actually being fed/watered.

Truly you are a !!SCIENTIST!! for the ages. <3

Seriously, this helps me a lot, most of my forts die to tantrum spirals due to underfed prisoners.
Logged
Urist cancels rest injury: Too injured

fricy

  • Bay Watcher
  • [DFHACK:ZEALOT]
    • View Profile

This DFHack lua script appears to "debug" a unit that needs feeding/watering. Appears to work on prisoners (chained OR caged), patients, and loose babies.
/snip
The game has cooldowns for how often a creature can be fed/watered, and sometimes these cooldowns get stuck or reset to a large number without the unit actually being fed/watered.

Brilliant. Will be included in MacNewbie. Since you didn't name the script, I took the liberty of saving it as feed-prisoner.lua. Any way to run it automatically when needed, or is that only possible if rewritten and complied as a plugin? 

Swonnrr

  • Bay Watcher
    • View Profile

I would name it fix-starving-prisoner, or something like that.
"feed prisoner" would imply that it feed the dwarf (reset the hunger-o-meter), although that's not what it does, it allow the prisoner to eat again.
Logged

tejón

  • Bay Watcher
    • View Profile

So hopefully this isn't completely and utterly wrong. I'm a lua noob and also spoiled on compiler errors.

feeding-timers.lua
Code: [Select]
-- feeding-timers :
--   Immediately fixes feeding timers for prisoners, patients and infants.
-- feeding-timers enable :
--   Repeats the fix once per month (but not immediately).
-- feeding-timers enable # :
--   Repeats the fix once per # months, minimum 1 (but not immediately).
-- feeding-timers disable :
--   Ceases automatic fixes.

local callback_id = nil
local frequency = 0

local function feeding_timer_fix()
    local fixcount = 0
    for _,unit in ipairs(df.global.world.units.active) do
        if dfhack.units.isCitizen(unit) then
            for _,v in pairs(unit.status.misc_traits) do
                local didfix = 0
                if v.id == 0 then -- I think this should have additional conditions...
                    v.value = 0 -- GiveWater cooldown set to zero
                    didfix = 1
                end
                if v.id == 1 then -- I think this should have additional conditions...
                    v.value = 0 -- GiveFood cooldown set to zero
                    didfix = 1
                end
                fixcount = fixcount + didfix
            end
        end
    end
    print("Fixed feeding timers for " .. fixcount .. " citizens.")
    if frequency > 0 then
        callback_id = dfhack.timeout(frequency, 'months', feeding_timer_fix)
    end
end

local args = {...}

if args[1] == 'disable' then
    if callback_id ~= nil then -- Is this required or will timeout_active fail gracefully?
        timeout_active(callback_id, nil) -- Does this return nil?
    end
    callback_id = nil
    frequency = 0
else if args[1] == 'enable' then
    if tonumber(args[2]) then
        frequency = args[2]
        if frequency < 2 then
            frequency = 1
        end
    else
        frequency = 1 -- What's the normal, non-broken food/water interval?
    end
    if callback_id ~= nil then
        timeout_active(callback_id, nil)
    end
    callback_id = dfhack.timeout(frequency, 'months', feeding_timer_fix)
    print('Feeding timers will be fixed at each ' .. frequency .. ' month interval.')
else
    feeding_timer_fix()
end
« Last Edit: May 17, 2014, 08:36:07 pm by tejón »
Logged
Pages: [1] 2