So, I want to modify DFHack's fix/dead-units script to leave notable dead invaders (historical figures, ones with actual kills, legendaries, nobility, forgotten beasts, etc) alone, while removing the "axe fodder" and such. However, I don't know the structure of the data files, so I'm having a bit of trouble working out the right flags and such. Here's what I've got at the moment, basically only removing slaughtered unnamed animals and the three most common war animals I've had visit in my current fort.
Main questions:
1. Do race ID numbers (unit.race below) stay constant between worlds? If yes, is there a list somewhere?
2. Is there someplace I can see the file structure of the unit info? Of most interest are things relating to, say, kills, or legendary status, or titles/noble positions for my current purposes.
3. For that matter, is there a wiki or guide for DFHack scripting somewhere?
fix/dead-units
==============
Removes uninteresting dead units from the unit list. Doesn't seem to give any
noticeable performance gain, but migrants normally stop if the unit list grows
to around 3000 units, and this script reduces it back.
=end]]
local units = df.global.world.units.active
local dwarf_race = df.global.ui.race_id
local dwarf_civ = df.global.ui.civ_id
local count = 0
for i=#units-1,0,-1 do
local unit = units[i]
local flags1 = unit.flags1
local flags2 = unit.flags2
if flags1.dead and unit.race ~= dwarf_race then
local remove = false
if flags2.slaughter then
remove = true
elseif not unit.name.has_name then
remove = true
end
-- Should remove horses (174), trolls (593), beak dogs (609), even if named.
if unit.race == 174 then
remove = true
elseif unit.race == 593 then
remove = true
elseif unit.race == 609 then
remove = true
end
if remove then
count = count + 1
units:erase(i)
end
end
end
print('Units removed from active: '..count)