Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 100 101 [102] 103 104 ... 244

Author Topic: DFHack 50.14-r1.1  (Read 892974 times)

taleden

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1515 on: October 18, 2018, 03:39:07 pm »

Has anyone experimented with manually creating social activities to coax a dwarf into, for example, praying or socializing to satisfy an unmet need? Or does anyone know what structure flags or values cause a dwarf's social activity to be urgent (shown in purple)?

I've tried a few times to replicate the structures that I can see when a dwarf is engaged in a particular activity (i.e. praying), but I can't seem to make them stick; the dwarf just cancels the activity and finds something else to do, as if it were invalid or something. So I'm not sure if I've missed something or if the game just decides to cancel it and override with a higher priority activity (which could also be why the dwarf never meets that need on their own in the first place).

Does anyone have any knowledge to share about manipulating social activities or is this uncharted territory?
Logged

Saiko Kila

  • Bay Watcher
  • Dwarven alchemist
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1516 on: October 19, 2018, 01:58:23 am »

Is there a way for a Lua script to tell if a female egglayer is currently busy sitting on eggs in a nestbox? "unit.job.currentjob" and "unit.actions" don't seem to show it. I can use dfhack.buildings.findAtTile(), :getType() and .claimed_by to check that the bird is standing on her own claimed nest box which is probably close enough, but I wondered if someone knows a more direct way to test for egg-sitting.

You probably solved that on you own, but this is a function I use in my script to tell the birth time for pregnant females, it also checks for egglayers:
Spoiler (click to show/hide)

It takes unit as input, and returns a string which shows how many months, days or hours of pregnancy (or incubation) are left. "round" is a rounding function defined elsewhere.

I'd like to add, that the hen can be repeatedly imprisoned or even killed and the chicks would still hatch successfully, at least if the time left is small (like couple of days).
Logged

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1517 on: October 19, 2018, 03:12:58 am »

Has anyone experimented with manually creating social activities to coax a dwarf into, for example, praying or socializing to satisfy an unmet need? Or does anyone know what structure flags or values cause a dwarf's social activity to be urgent (shown in purple)?

I've tried a few times to replicate the structures that I can see when a dwarf is engaged in a particular activity (i.e. praying), but I can't seem to make them stick; the dwarf just cancels the activity and finds something else to do, as if it were invalid or something. So I'm not sure if I've missed something or if the game just decides to cancel it and override with a higher priority activity (which could also be why the dwarf never meets that need on their own in the first place).

Does anyone have any knowledge to share about manipulating social activities or is this uncharted territory?
I've not ever really gone much into social stuff, but I know some things I could point you to that might help:
  • Syndromes have some special triggers that allow their effects to activate based on the value of special counters, with the ones that might be relevant to social/break-related things being "TIME_SINCE_BREAK" and "ON_BREAK". In lua, these counters (and a lot more) can be found in the unit's status.misc_traits (provided they're active/whatever). You may have to manipulate these to encourage them to take breaks and stay on said breaks. It looks like there's also some counters that haven't been mapped(?) - I noticed that one of my units had a misc_trait of ID 63 (I think), which according to gm-editor is nil. As a side note, I may have now found a hacky way using this to stop all my civs that don't even have access to clothing from complaining about not having any clothes to wear!
  • The strength of a need can be modified in the unit's status.personality.current_soul.personality.needs, by changing its focus level. I know that a value of 400 is what it's set to when the need is met, and I believe that the value lowers as they get less focused, into the negatives. The numbers listed on the wiki are probably right for reference. You might be able to get dwarves having purple needs by just setting the focus value super low. Bear in mind, also, that what needs units have varies from unit to unit. Apparently, I made a modtool for setting a unit's needs, don't know if I ever shared it anywhere :P

xzaxza

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1518 on: October 19, 2018, 09:45:59 am »

Hi,

I'm new. DFHack's pretty neat. Some of the documentation is bit poor though. :P

Anything specifically? Feel free to suggest improvements - I can't guarantee that I can improve docs for tools I'm unfamiliar with, but other people might.

"embark-skills points" and "points" are separate, but I think they work on the same screen, so it's possible that DFHack's layout for that screen is wrong (I don't remember checking that one). I'll investigate.

I'm pretty sure preferences are just stored in a vector, so I can't think of an obvious reason why adding "too many" would crash, or why "too many" would even be a possible state. Maybe the preferences it makes are malformed sometimes? In any case, that script is garbage (many hardcoded options for arbitrary preference combinations, lots of duplicated code, etc.), so it'd probably have to be rewritten some anyway.

Edit: you need to run "points" on the embark site-choosing screen (before the screen where you select items). That works in 0.44.12 for me. I can probably add support for the item-choosing screen too, but I can't support anything before a world is loaded, since the relevant field (df.global.world.worldgen.worldgen_parms.embark_points) is reset to the world-specific value when a world is loaded.

Edit: fixed "embark-skills points" as well. Its other options appeared to work fine.
Hi, I'm slow.

Well, mainly I think there could be more details about the arguments of many functions, and perhaps examples. Some of the functions took a while to figure out, even with the documentation. I could of course try to contribute myself too.

Yeah, it might be that I was trying some of the embark thingies at wrong screen, but good to know you fixed the ones that were affected!

I'm not sure what exactly was the problem with the preferences, but it seemed so, when adding new values would cause a crash, but if you also removed some values it wouldn't crash. But eh, could be the script added wrong values or corrupted something somehow. Especially considering it sometimes stored the same preference multiple times.
Logged
Known issues
You may get a dwarf that likes bugged stockpiles.

taleden

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1519 on: October 19, 2018, 10:20:16 am »

the ones that might be relevant to social/break-related things being "TIME_SINCE_BREAK" and "ON_BREAK". In lua, these counters (and a lot more) can be found in the unit's status.misc_traits (provided they're active/whatever)
Hm, I can try those, although I'm not sure they're used any more in the current game version; in my fort of 112 citizens, not a single one has a misc_trait with id 16 (TimeSinceBreak) or 17 (OnBreak). Also, the problem I'm having isn't just with dwarves aborting my forced social activity for an actual job (teal text); they'll take a few steps pathing toward my activity and then stop and switch to a different idle activity (i.e. stop walking to the temple and instead go to Individual Combat Drill or to the library to read). That's why I was hoping to figure out the criteria for Purple! idle activities, to maybe get them to stick with what I assigned and not switch to something else.

The strength of a need can be modified in the unit's status.personality.current_soul.personality.needs, by changing its focus level. I know that a value of 400 is what it's set to when the need is met, and I believe that the value lowers as they get less focused, into the negatives. The numbers listed on the wiki are probably right for reference. You might be able to get dwarves having purple needs by just setting the focus value super low.
Yes, those are the focus level values that I'm scanning for dwarves with severely unmet needs (for example I had a military dwarf with -200000 PrayOrMedidate, which I think is the lower limit, because he would always drill in his idle time and never pray).

After some experimentation though, I'm pretty sure the Purple! indicator isn't really very meaningful. I just compared the need data for a bunch of dwarves currently engaged in purple "Socialize!"/"Pray!" and green "Socialize"/"Pray" activities, and the determining factor seems to be whether the dwarf has Socialize, PrayOrMedidate, BeCreative, Excitement or AdmireArt focus levels of -10000 or lower, but there was no link between the activity and the actual urgent need -- a dwarf with -10k Socialize and +10k PrayOrMedidate would still show "Pray!", a dwarf with -10k BeCreative and +10k everything else would still "Socialize!", etc.
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.44.12-r1
« Reply #1520 on: October 19, 2018, 09:01:09 pm »

Syndromes have some special triggers that allow their effects to activate based on the value of special counters, with the ones that might be relevant to social/break-related things being "TIME_SINCE_BREAK" and "ON_BREAK".
Funny you should mention those ones in particular - I just checked a disassembly of version 0.44.12, and those two actually don't exist anymore. "MOUNTAIN" is also no longer a Counter, but instead has its own distinct field in unit_soul.personality.
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.

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1521 on: October 20, 2018, 02:36:10 am »

Syndromes have some special triggers that allow their effects to activate based on the value of special counters, with the ones that might be relevant to social/break-related things being "TIME_SINCE_BREAK" and "ON_BREAK".
Funny you should mention those ones in particular - I just checked a disassembly of version 0.44.12, and those two actually don't exist anymore. "MOUNTAIN" is also no longer a Counter, but instead has its own distinct field in unit_soul.personality.
Aw, that's a shame - I was getting some dumb ideas for syndromes I could make that use them :b

Clément

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1522 on: October 20, 2018, 03:13:52 am »

When I run DFHack with valgrind, I get a lot of libruby.so errors. Is that expected and is there a way to suppress them?
Logged

Pvt. Pirate

  • Bay Watcher
  • Dabbling Linux User
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1523 on: October 20, 2018, 05:45:05 am »

Has anyone experimented with manually creating social activities to coax a dwarf into, for example, praying or socializing to satisfy an unmet need? Or does anyone know what structure flags or values cause a dwarf's social activity to be urgent (shown in purple)?

I've tried a few times to replicate the structures that I can see when a dwarf is engaged in a particular activity (i.e. praying), but I can't seem to make them stick; the dwarf just cancels the activity and finds something else to do, as if it were invalid or something. So I'm not sure if I've missed something or if the game just decides to cancel it and override with a higher priority activity (which could also be why the dwarf never meets that need on their own in the first place).

Does anyone have any knowledge to share about manipulating social activities or is this uncharted territory?
I've not ever really gone much into social stuff, but I know some things I could point you to that might help:
  • Syndromes have some special triggers that allow their effects to activate based on the value of special counters, with the ones that might be relevant to social/break-related things being "TIME_SINCE_BREAK" and "ON_BREAK". In lua, these counters (and a lot more) can be found in the unit's status.misc_traits (provided they're active/whatever). You may have to manipulate these to encourage them to take breaks and stay on said breaks. It looks like there's also some counters that haven't been mapped(?) - I noticed that one of my units had a misc_trait of ID 63 (I think), which according to gm-editor is nil. As a side note, I may have now found a hacky way using this to stop all my civs that don't even have access to clothing from complaining about not having any clothes to wear!
  • The strength of a need can be modified in the unit's status.personality.current_soul.personality.needs, by changing its focus level. I know that a value of 400 is what it's set to when the need is met, and I believe that the value lowers as they get less focused, into the negatives. The numbers listed on the wiki are probably right for reference. You might be able to get dwarves having purple needs by just setting the focus value super low. Bear in mind, also, that what needs units have varies from unit to unit. Apparently, I made a modtool for setting a unit's needs, don't know if I ever shared it anywhere :P
this calls for a special case of a dwarven mood that gets triggered by being unable to worship their deity for too long - "craft religios symbol":
the dorf claims a workshop and crafts a symbol of their deity - then goes to either their own room, a temple or the meeting hall and prays for an extended time.
Logged
"dwarves are by definition alcohol powered parasitic beards, which will cling to small caveadapt humanoids." (Chaia)

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1524 on: October 20, 2018, 06:16:17 am »

I've been running into a problem with the following code, which I know used to be how you went about spawning creatures via reactions a while ago:
Code: [Select]
modtools/reaction-trigger -reactionName FOE_SPAWN_SPRITE -command [ modtools/create-unit -race FOE_ICE_SPRITE -setUnitToFort -name FOE_TUNDRA -location [ \\LOCATION ] -age 0 ]
I get the error
Code: [Select]
0.44.12\hack\lua\utils.lua:598: error: invalid arg: 5: race Looking into it, it seems like it's treating the commands for modtools/create-unit as commands for modtools/reaction-trigger (-race happens to be in the position where a fifth arg would be) when checking for valid args. If I add "race" to reaction-trigger's valid args list, I then get an error for setUnitToFort not being valid.

Have I simply screwed up the formatting for this, or is the script busted? Either way, I guess I can hack create-unit's args into reaction-trigger's valid args and see where that gets me for now :P

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1525 on: October 20, 2018, 02:26:57 pm »

When I run DFHack with valgrind, I get a lot of libruby.so errors. Is that expected and is there a way to suppress them?
libruby.so isn't something we wrote (it's from Ruby), and we don't control what it does. Valgrind probably has a way to disable warnings for a specific library.

I get the error
Code: [Select]
0.44.12\hack\lua\utils.lua:598: error: invalid arg: 5: race
I think your syntax is ok, and the bracket looks like a normal bracket, not some funky Unicode one. Please post the full traceback, not just the one line - that will help identify whether this is originating from create-unit or reaction-trigger.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1526 on: October 21, 2018, 01:55:59 am »

I think your syntax is ok, and the bracket looks like a normal bracket, not some funky Unicode one. Please post the full traceback, not just the one line - that will help identify whether this is originating from create-unit or reaction-trigger.
Haha, yeah sorry - I originally intended to post it all but couldn't figure out how to copy from the command prompt. I've got it now (unless there's a file everything's logged to and this is just a bit of it?)
Code: [Select]
...1\PERIDE~1.12-\Dwarf Fortress 0.44.12\hack\lua\utils.lua:598: error: invalid arg: 5: race
stack traceback:
        [C]: in function 'error'
        ...1\PERIDE~1.12-\Dwarf Fortress 0.44.12\hack\lua\utils.lua:598: in function 'utils.processArgs'
        ...tress 0.44.12/hack/scripts/modtools/reaction-trigger.lua:226: in local 'script_code'
        ...\PERIDE~1.12-\Dwarf Fortress 0.44.12\hack\lua\dfhack.lua:680: in function 'dfhack.run_script_with_env'
        (...tail calls...)
The exact line for reaction-trigger might be off by 8 because I just commented out my additions to the valid args table to get it erroring again :P The line that's mentioned in the error (line 226 for my commented-out-additions version) is the line local args = utils.processArgs({...}, validArgs)

Clément

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1527 on: October 21, 2018, 04:03:50 am »

libruby.so isn't something we wrote (it's from Ruby), and we don't control what it does. Valgrind probably has a way to disable warnings for a specific library.

It's just to be sure. You could have uninitialized data passed into the library and only used later.

Here are the suppressions, I came up with:
Code: [Select]
{
ignore_rb_newobj_cond
Memcheck:Cond
...
fun:rb_newobj
}
{
ignore_rb_newobj_read8
Memcheck:Value8
...
fun:rb_newobj
}
{
ignore_ruby_xmalloc_cond
Memcheck:Cond
...
fun:ruby_xmalloc
}
{
ignore_ruby_xmalloc_read8
Memcheck:Value8
...
fun:ruby_xmalloc
}

I saw new errors, not related to ruby:
Code: [Select]
==4507== Conditional jump or move depends on uninitialised value(s)
==4507==    at 0x3E696CF3: mousequery_hook::interpose_fn_render() (mousequery.cpp:580)
==4507==    by 0x3D31DC8C: autochop_hook::interpose_fn_render() (autochop.cpp:822)
==4507==    by 0x6008A06: render_things() (graphics.cpp:537)
==4507==    by 0x5FD6E64: enablerst::async_loop() (enabler.cpp:319)
==4507==    by 0x5FD825E: call_loop(void*) (enabler.cpp:708)
==4507==    by 0x5C872EB: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==4507==    by 0x5CCA73E: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==4507==    by 0x7B96593: start_thread (pthread_create.c:463)
==4507==    by 0x7027E6E: clone (clone.S:95)
==4507==
==4507== Mismatched free() / delete / delete []
==4507==    at 0x4C3078C: operator delete[](void*) (vg_replace_malloc.c:621)
==4507==    by 0xB59DB3: ??? (in /home/clement/games/df/df_44_12_linux/libs/Dwarf_Fortress)
==4507==    by 0xB5A060: ??? (in /home/clement/games/df/df_44_12_linux/libs/Dwarf_Fortress)
==4507==    by 0x10AD3A1: ??? (in /home/clement/games/df/df_44_12_linux/libs/Dwarf_Fortress)
==4507==    by 0x8CACAA: ??? (in /home/clement/games/df/df_44_12_linux/libs/Dwarf_Fortress)
==4507==    by 0x9A3756: ??? (in /home/clement/games/df/df_44_12_linux/libs/Dwarf_Fortress)
==4507==    by 0x600DCDF: interfacest::loop() (interface.cpp:863)
==4507==    by 0x9CCDED: mainloop() (in /home/clement/games/df/df_44_12_linux/libs/Dwarf_Fortress)
==4507==    by 0x5FD6F59: enablerst::async_loop() (enabler.cpp:337)
==4507==    by 0x5FD825E: call_loop(void*) (enabler.cpp:708)
==4507==    by 0x5C872EB: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==4507==    by 0x5CCA73E: ??? (in /usr/lib64/libSDL-1.2.so.0.11.4)
==4507==  Address 0x5f331440 is 0 bytes inside a block of size 2 alloc'd
==4507==    at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
==4507==    by 0x543FD22: df::historical_figure::historical_figure() (in /home/clement/games/df/df_44_12_linux/hack/libdfhack-debug.so)
==4507==    by 0x5678200: DFHack::World::AddPersistentData(std::string const&) (World.cpp:270)
==4507==    by 0x3D319294: initialize() (autochop.cpp:227)
==4507==    by 0x3D319E00: plugin_onstatechange (autochop.cpp:919)
==4507==    by 0x548B179: DFHack::Plugin::on_state_change(DFHack::color_ostream&, DFHack::state_change_event) (PluginManager.cpp:566)
==4507==    by 0x548D393: DFHack::PluginManager::OnStateChange(DFHack::color_ostream&, DFHack::state_change_event) (PluginManager.cpp:981)
==4507==    by 0x53A8F7C: DFHack::Core::onStateChange(DFHack::color_ostream&, DFHack::state_change_event) (Core.cpp:2283)
==4507==    by 0x53A7940: DFHack::Core::doUpdate(DFHack::color_ostream&, bool) (Core.cpp:2015)
==4507==    by 0x53A7B7D: DFHack::Core::Update() (Core.cpp:2071)
==4507==    by 0x568318D: SDL_NumJoysticks (Hooks-linux.cpp:53)
==4507==    by 0x5FD6FF2: enablerst::async_loop() (enabler.cpp:348)
Using my own debug build of "DFHack version 0.44.12-r1 (development build 0.44.12-r1-53-ge56cb2a2) on x86_64"
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1528 on: October 21, 2018, 07:43:28 pm »

libruby.so isn't something we wrote (it's from Ruby), and we don't control what it does. Valgrind probably has a way to disable warnings for a specific library.

It's just to be sure. You could have uninitialized data passed into the library and only used later.

Here are the suppressions, I came up with:
(snip)
Fair. The first one looks like a mousequery bug. It sounds a little familiar, although I can't find an open PR fixing it, so maybe I'm mistaken. The second one looks like a mismatch between our historical_figure constructor and DF's destructor - maybe DF is dynamically allocating memory in the constructor? I've run into a likely-related issue where overriding operator new and operator delete crashes when freeing something allocated (I think?) in df::historical_figure::historical_figure(). Not really sure how to fix that one, so let me know if you uncover anything.

I think your syntax is ok, and the bracket looks like a normal bracket, not some funky Unicode one. Please post the full traceback, not just the one line - that will help identify whether this is originating from create-unit or reaction-trigger.
Haha, yeah sorry - I originally intended to post it all but couldn't figure out how to copy from the command prompt. I've got it now (unless there's a file everything's logged to and this is just a bit of it?)
Code: [Select]
...1\PERIDE~1.12-\Dwarf Fortress 0.44.12\hack\lua\utils.lua:598: error: invalid arg: 5: race
stack traceback:
        [C]: in function 'error'
        ...1\PERIDE~1.12-\Dwarf Fortress 0.44.12\hack\lua\utils.lua:598: in function 'utils.processArgs'
        ...tress 0.44.12/hack/scripts/modtools/reaction-trigger.lua:226: in local 'script_code'
        ...\PERIDE~1.12-\Dwarf Fortress 0.44.12\hack\lua\dfhack.lua:680: in function 'dfhack.run_script_with_env'
        (...tail calls...)
The exact line for reaction-trigger might be off by 8 because I just commented out my additions to the valid args table to get it erroring again :P The line that's mentioned in the error (line 226 for my commented-out-additions version) is the line local args = utils.processArgs({...}, validArgs)
Just to confirm, you haven't modified hack/lua/utils.lua at all, right?
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1529 on: October 22, 2018, 01:18:32 am »

Just to confirm, you haven't modified hack/lua/utils.lua at all, right?
Not to my knowledge, no. I've only opened it before to check the place it was erroring.
Pages: 1 ... 100 101 [102] 103 104 ... 244