I've made a script for my tests today, related to the problem. May be useful. It's LUA script.
-- shows size of unit or all units in the same position, optionally lists them
local help = [====[
unit-size
=============
Shows size of an unit or all units at the same position. Unit can be selected by 'v', 'k' or from any list.
Optional arguments:
``unit-size -all`` shows total size of all units at that position
``unit-size -list`` like 'all' but also lists all the units
Units who died or were caged at the same position are counted separately.
]====]
local total_size_cur_live_uncaged = 0
local total_size_base_live_uncaged = 0
local total_size_cur_caged = 0
local total_size_base_caged = 0
local total_size_cur_dead = 0
local total_size_base_dead = 0
local position_x = nil
local position_y = nil
local position_z = nil
local str_sel = ""
local args = {...}
local unit = dfhack.gui.getSelectedUnit()
if unit then
if #args >0 then
args[1]=string.lower(args[1])
position_x = unit.pos.x
position_y = unit.pos.y
position_z = unit.pos.z
if args[1] == "-help" or args[1] == "help" then
print(help)
return
elseif args[1] == "-list" or args[1] == "list" or args[1] == "-all" or args[1] == "all" then
for k,v in ipairs(df.global.world.units.active) do
if v.id == unit.id then str_sel = " *" else str_sel = "" end
if v.pos.x == position_x and v.pos.y == position_y and v.pos.z == position_z then
if not v.flags1.caged and not v.flags1.dead then
total_size_cur_live_uncaged = total_size_cur_live_uncaged + v.body.size_info.size_cur
total_size_base_live_uncaged = total_size_base_live_uncaged + v.body.size_info.size_base
if args[1] == "-list" or args[1] == "list" then
print(string.format("Unit %s [ID %s] has size %s (%s)%s",v.name.first_name,v.id,v.body.size_info.size_cur,v.body.size_info.size_base,str_sel))
end
end
if v.flags1.caged then
total_size_cur_caged = total_size_cur_caged + v.body.size_info.size_cur
total_size_base_caged = total_size_base_caged + v.body.size_info.size_base
if args[1] == "-list" or args[1] == "list" then
print(string.format("Unit %s [ID %s, caged] has size %s (%s)%s",v.name.first_name,v.id,v.body.size_info.size_cur,v.body.size_info.size_base,str_sel))
end
end
if v.flags1.dead then
total_size_cur_dead = total_size_cur_dead + v.body.size_info.size_cur
total_size_base_dead = total_size_base_dead + v.body.size_info.size_base
if args[1] == "-list" or args[1] == "list" then
print(string.format("Unit %s [ID %s, DEAD] has size %s (%s)%s",v.name.first_name,v.id,v.body.size_info.size_cur,v.body.size_info.size_base,str_sel))
end
end
end
end
print(string.format("Total size of uncaged, living units here: %s (%s)",total_size_cur_live_uncaged,total_size_base_live_uncaged))
if total_size_cur_caged>0 then
print(string.format("Total size of units caged at this position: %s (%s)",total_size_cur_caged,total_size_base_caged))
end
if total_size_cur_dead>0 then
print(string.format("Total size of dead units who died or were caged here: %s (%s)",total_size_cur_dead,total_size_base_dead))
end
else
print(string.format("Unknown argument: %s",args[1]))
print(help)
return
end
else
print(string.format("Unit %s [ID %s] has size current (base): %s (%s)",unit.name.first_name,unit.id,unit.body.size_info.size_cur,unit.body.size_info.size_base))
if unit.flags1.caged then
print(string.format("Unit %s is caged.",unit.name.first_name))
end
if unit.flags1.dead then
print(string.format("Unit %s is dead.",unit.name.first_name))
end
end
else
print("You need to select an unit.")
print(help)
return
end
It needs an unit selected (may be from any lists or from "v" option or from "k" option, the last useful for guys in a cage). When no option is given, it shows size of an unit. With "
all" it shows size of all units from the same position, and with "
list" option it shows all and also lists them.
When "
list " option is used, unit with asterisk is the one selected.
There are caveats: position of caged units is the same as the position of cage trap they were trapped, while dead units (from Dead/Missing list most likely) retain position of their death. Therefore these two categories are listed separately. Also it's good for units, not their corpses (or any other items).
A side functionality is ability to get cage trap's efficiency: if you list a unit which is caged, you also get all units caged at the same position. So you know how good this trapping position is, at least from size perspective.
Interestingly, living units usually have bigger actual (current) size than base size, while zombies have it opposite. I suppose missing limbs and organs have something to do with it...