Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 195 196 [197] 198 199 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1457348 times)

WillowLuman

  • Bay Watcher
  • They/Them Life is weird
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2940 on: February 04, 2013, 01:29:36 am »

Perhaps true. I don't think I've ever seen it use genetic data, always just "creating pregnancy ptr"
Logged
Dwarf Souls: Prepare to Mine
Keep Me Safe - A Girl and Her Computer (Illustrated Game)
Darkest Garden - Illustrated game. - What mysteries lie in the abandoned dark?

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2941 on: February 04, 2013, 02:12:50 am »

Interesting.  I would have expected DF to only care if the mother had a spouse id set at the time of birth, and would set up the history entries as needed.  If that's the case, then DFusion shouldn't be at fault.

I don't think it's the lover id though.  I'm pretty sure DF clears that once two dwarves marry.  It could be the links Quietust mentioned though.  I'd find it pretty strange if DF needed that to set up the future history entries.

It may be that my script isn't setting the spouse ids correctly.  What you see in the relationships screen doesn't depend on that at all, it actually uses the historical figure links.  The spouse id is what's needed for DF to generate 'talked with the spouse lately' thoughts, to start pregnancies, and to prevent a dwarf from getting another lover or spouse.

I'll take another look at it when I get a chance.
Logged
Through pain, I find wisdom.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2942 on: February 04, 2013, 02:27:50 am »

Interesting.  I would have expected DF to only care if the mother had a spouse id set at the time of birth, and would set up the history entries as needed.  If that's the case, then DFusion shouldn't be at fault.

I don't think it's the lover id though.  I'm pretty sure DF clears that once two dwarves marry.  It could be the links Quietust mentioned though.  I'd find it pretty strange if DF needed that to set up the future history entries.

It may be that my script isn't setting the spouse ids correctly.  What you see in the relationships screen doesn't depend on that at all, it actually uses the historical figure links.  The spouse id is what's needed for DF to generate 'talked with the spouse lately' thoughts, to start pregnancies, and to prevent a dwarf from getting another lover or spouse.

I'll take another look at it when I get a chance.
Having hist. events for marriage would make sense as it might check for them when creating new unit.

WillowLuman

  • Bay Watcher
  • They/Them Life is weird
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2943 on: February 04, 2013, 03:07:47 am »

Have yet to check whether the pregnancy can occur naturally in fort mode. Though, in legends, it does not list "in year X, A married B." Could be part of it, or could be an adv-mode specific problem.
Logged
Dwarf Souls: Prepare to Mine
Keep Me Safe - A Girl and Her Computer (Illustrated Game)
Darkest Garden - Illustrated game. - What mysteries lie in the abandoned dark?

Lord_Phoenix

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2944 on: February 04, 2013, 07:56:50 am »

Logged

danaris

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2945 on: February 04, 2013, 09:23:25 am »

I am having difficulty getting DFHack to run on OSX.

I extracted the files into my DF folder. When I double-click on "dfhack", it opens terminal and dwarffort.exe but does not start the game.

Double-clicking "dfhack-run" opens another terminal window that displays "Segmentation fault", then logs out and declares the process completed.

The readme has not been updated to include the new OSX version, can anyone help me? I have no idea what I'm doing.

First: what version of OS X are you running? Some changes need to be made to the dfhack script before it is possible to run it on versions prior to 10.7 (and even then I don't guarantee that they'll work).

Second: If you're running 10.7 or newer, please open up the Terminal, type "cd " (that's a space after cd), then drag the folder containing the dfhack script into the Terminal window and press Enter. Then type "./dfhack" and press Enter. What, exactly, does it say?
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2946 on: February 04, 2013, 01:31:35 pm »

Have yet to check whether the pregnancy can occur naturally in fort mode. Though, in legends, it does not list "in year X, A married B." Could be part of it, or could be an adv-mode specific problem.

I haven't tested it with this tool yet, but it should work.  When I did this the hard way with a memory editor it worked.

The lack of the Legends mode mentions of them marrying is becuase of the problem Quietust pointed out.  The script doesn't add the legends mode entries, which might be responsible for it not understanding who the father is in Legends mode.  I'll try fixing it eventually, but it's going to probably be a little while before I do.
Logged
Through pain, I find wisdom.

TigerHunter

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2947 on: February 04, 2013, 03:20:28 pm »

I am having difficulty getting DFHack to run on OSX.

I extracted the files into my DF folder. When I double-click on "dfhack", it opens terminal and dwarffort.exe but does not start the game.

Double-clicking "dfhack-run" opens another terminal window that displays "Segmentation fault", then logs out and declares the process completed.

The readme has not been updated to include the new OSX version, can anyone help me? I have no idea what I'm doing.

First: what version of OS X are you running? Some changes need to be made to the dfhack script before it is possible to run it on versions prior to 10.7 (and even then I don't guarantee that they'll work).

Second: If you're running 10.7 or newer, please open up the Terminal, type "cd " (that's a space after cd), then drag the folder containing the dfhack script into the Terminal window and press Enter. Then type "./dfhack" and press Enter. What, exactly, does it say?
I am running 10.6.8. What changes do I need to make?

Thank you for your help!
Logged

danaris

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2948 on: February 04, 2013, 05:51:34 pm »

I am running 10.6.8. What changes do I need to make?

Thank you for your help!

You need to comment out the line
Quote
export DYLD_FORCE_FLAT_NAMESPACE=1
(in other words, put a # in front of it).

(Or you can just delete the line.)
Logged

WillowLuman

  • Bay Watcher
  • They/Them Life is weird
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2949 on: February 04, 2013, 07:31:36 pm »

Comment out the line in which file?
Logged
Dwarf Souls: Prepare to Mine
Keep Me Safe - A Girl and Her Computer (Illustrated Game)
Darkest Garden - Illustrated game. - What mysteries lie in the abandoned dark?

danaris

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2950 on: February 04, 2013, 09:21:53 pm »

Comment out the line in which file?

In the dfhack script you run to launch DF with DFHack attached.
Logged

WillowLuman

  • Bay Watcher
  • They/Them Life is weird
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2951 on: February 04, 2013, 09:35:03 pm »

I've got a unix executable file called dfhack-run, looks like. Is the script in hack/scripts?
Logged
Dwarf Souls: Prepare to Mine
Keep Me Safe - A Girl and Her Computer (Illustrated Game)
Darkest Garden - Illustrated game. - What mysteries lie in the abandoned dark?

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2952 on: February 04, 2013, 09:48:34 pm »

hack/scripts is for lua scripts; that shouldn't be it.

WillowLuman

  • Bay Watcher
  • They/Them Life is weird
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2953 on: February 04, 2013, 10:29:59 pm »

Is it in the hack, though?
Logged
Dwarf Souls: Prepare to Mine
Keep Me Safe - A Girl and Her Computer (Illustrated Game)
Darkest Garden - Illustrated game. - What mysteries lie in the abandoned dark?

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: DFHack 0.34.11 r2
« Reply #2954 on: February 05, 2013, 01:13:33 am »

And one more script for those who are interested.  It's kind of a niche thing I threw together for an upcoming community fort, but I think it might be useful to anyone inundated with too many babies being born, as a supplement or instead of the init child cap.  I call it Family Planning, but that's probably not the best name for it since it's also simulating infertility due to age.  Just drop this into a file called familyplanning.lua in your scripts folder:

Code: [Select]
-- Simulates menopause and gives a limit on the number of living kids per mother

local args = {...}

function count_children(unit_id)
local children = 0

for key, value in pairs(df.global.world.units.all) do
if value.relations.mother_id == unit_id then
children = children + 1
end
end

return children
end

function terminate_pregnancy(unit)
if unit.relations.pregnancy_timer > 0 then
unit.relations.pregnancy_ptr:delete()
unit.relations.pregnancy_ptr = nil
unit.relations.pregnancy_timer = 0
unit.relations.pregnancy_mystery = -1
return 1 -- Terminated a pregnancy
end

-- Wasn't pregnant
return 0
end

function family_planning(menopause_min, menopause_max, children_min, children_max)
local terminated_pregnancies = 0

for key, value in pairs(df.global.world.units.all) do
local children = 0

-- Only married females matter
if (value.sex == 0 and value.relations.spouse_id ~= -1) then
children = count_children(value.id)
end

math.randomseed(value.id)
local maximum_children = math.random(children_min, children_max)
local menopause_age = math.random(menopause_min, menopause_max)
local age = df.global.cur_year - value.relations.birth_year

if age > menopause_age or children > maximum_children then
-- This is awkward syntax, but I have no idea how to pass local values by reference in Lua
terminated_pregnancies = terminated_pregnancies + terminate_pregnancy(value)
end
end

print("Terminated " .. terminated_pregnancies .. " pregnancies.")
end

if df.isnull(args[4]) then
print('You did not specify four parameters, so the following are assumed: menopause at 40-60, maximum children from 2-4.')
args[1] = 40
args[2] = 60
args[3] = 2
args[4] = 4
end

dfhack.with_suspend(family_planning, tonumber(args[1]), tonumber(args[2]), tonumber(args[3]), tonumber(args[4]))

The syntax is either

Code: [Select]
familyplanning or
Code: [Select]
familyplanning menopause_min menopause_max children_min children_max
If you don't provide all four of those arguments, it uses these defaults:  Menopause sets in at some age between 40 and 60.  A mother will be limited to somewhere between 2 and 4 children.

The actual menopause age and child cap are randomly decided per mother, with the RNG seeded based on her unit id.  This has the effect of being consistent between runs of the tool, but giving different values per mother.  If a mother is found who is too old or has more kids than she's supposed, and she's pregnant, it will remove her pregnancy.  I think this currently counts deceased children too, if they have migrated.  I'm not positive what it will do for those who haven't migrated: it only checks the global units list, so if things that haven't migrated aren't populated in that list they won't get counted.

These are roughly human values.  Ideally this would check the max age of the creature in question, but I don't know how to do that yet if it's possible.  Instead, if you really care about more dwarfy values you can just enter something like 100 for the menopause ages.  If you don't want that to be simulated, just enter like 1000.

This script will need to be run manually periodically.  It should arrive at the same random age and child caps even between runs of DF.  I don't know if it's possible to configure DFHack to run Lua scripts automatically, but I don't think so.  I can't code it in C++ right now either due to a lack of a compatible compiler being available right now.

I tested this one on a 20 year old fort, but it is unfortunately modded and running a species of egg layers.  It found and terminated 8 pregnancies as a result, and while they're egg layers, I assume it will work properly for dwarves and other creatures.
« Last Edit: February 05, 2013, 01:21:12 am by Telgin »
Logged
Through pain, I find wisdom.
Pages: 1 ... 195 196 [197] 198 199 ... 373