Hi everyone,
I'm back again with my pesky vermin. I can't seem to get a regional interaction or even a self-targeting interaction to fire reliably. The syndrome defined within the interaction shows up on the world syndrome list, so that's not the problem. I tried to capture the interaction, syndrome-trigger and eventful's onSyndrome (though I'm far from sure I did that last one right). For whatever reason, neither version of the interaction works (or at least works reliably).
Is there a way to fire a script whenever a creature spawns? Maybe an undocumented hack of Eventful (there was mention of an EventType table that I couldn't find anywhere)? I'll just check if it's one of my critters in civ -1, apply my Lua if it is, and do nothing if it isn't. It's perfectly okay if the event only works on naturally spawning critters, since I can always run additional code if I'm spawning one in a script.
Basically I want any of these that pop up on the map to be immediately friendly to the player's civ (ideally, this method wouldn't assume the player is playing dwarves). I know this code works when I run it manually:
--modifies a specific unit to make it domesticated (and available for pet adoption)
--[=[
argument
<UNIT_ID> The creature to be domesticated, mandatory
Made by Dirst for use in The Earth Strikes Back mod
Intended use is to automatically domesticate all new instances of specific species.
TO DO:
Find a method to apply this script to all new members of the target species.
--]=]
args = {...}
local critter = df.unit.find(tonumber(args[1]))
if critter.civ_id == -1 then
if df.global.gamemode == df.game_mode.ADVENTURE then
critter.civ_id = df.global.world.units.active[0].civ_id
else
critter.civ_id = df.global.ui.civ_id
critter.flags2.resident = false;
critter.flags3.body_temp_in_range = true;
critter.population_id = -1
critter.status.current_soul.unit_id = critter.id
critter.animal.population.region_x = -1
critter.animal.population.region_y = -1
critter.animal.population.unk_28 = -1
critter.animal.population.population_idx = -1
critter.animal.population.depth = -1
critter.counters.soldier_mood_countdown = -1
critter.counters.death_cause = -1
critter.enemy.anon_4 = -1
critter.enemy.anon_5 = -1
critter.enemy.anon_6 = -1
end
critter.flags1.tame = true
critter.training_level = 7
-- Verbose for troubleshooting purposes.
print("Critter (unit# "..args[1]..") has been domesticated.")
else
print("Critter (unit# "..args[1]..") is not wild.")
end
In fact the "k" screen updates immediately when I do this, no need to cursor off and come back like with spawn-unit. I just can't find a way to make it run automatically.
My dwarves still aren't carrying the little guys around either. I think the wiki might be outdated on that behavior. However, interaction stuff didn't work any better when these guys were normal animals.
My last resort is to use Putnam's way of cycling thru every unit every N ticks, and apply the changes to any applicable critters.