I'm currently having a problem when assigning syndromes via script. I have a syndrome that's supposed to immediately grant the ability to perform an interaction, however the way
syndrome-util applies syndromes means that any syndrome effects added won't come into effect until the next syndrome tick (which can be quite a while in adventure mode), meaning the ability won't become available until then. Is there an alternative way to apply syndromes, or maybe some way to forcibly trigger the game to re-check a creature's syndromes without having to wait for the next syndrome tick?
Heyo, question about scripts here. I know hardly anything about how to write DFhack scripts, but how would I go about modifying the cannibalism script to apply to all sentient corpses as soon as they die? Note that I have written literally 0 dfhack scripts or plugins, but if someone could let me know, that'd be neat.
Here's something I just quickly threw together - it might need a little testing. It should automatically do the cannibalism thing whenever an item is created (except ones created due to traders, migrants, invaders and spider webs - some limitation on the event used), and yeah, a creature dying counts as creating a corpse :b.
-- Makes any creature that dies cannibal-able
local eventful = require "plugins.eventful"
function on_item_created(item_id)
local item = df.item.find(item_id)
item.flags.dead_dwarf = false
end
--------------------
initialized = initialized or false
function init()
-- Set up everything to default values here
initialized = true
eventful.enableEvent(eventful.eventType.ITEM_CREATED, 1)
eventful.onItemCreated["auto-cannabalism"] = on_item_created
end
function reset()
-- Set things to nil/default here
initialized = false
eventful.onItemCreated["auto-cannabalism"] = nil
end
dfhack.onStateChange["auto-cannabalism"] = function(code)
-- Wipe / reset data whenever loaded state changes
if code == SC_WORLD_UNLOADED then
reset()
elseif code == SC_WORLD_LOADED then
if ( not initialized ) then
init()
end
end
end
if ( not initialised ) then
init()
end
I think I may have used the wrong template, meaning that the script will always be running for the whole game session rather than per-world, but I'm too lazy at the moment to check/fix it :p
edit: I've released a more improved version on my
github. Still waiting to find out about a workaround for my syndrome-assigning problem, though :c