diff --git a/changelog.txt b/changelog.txt index 7444ef3d3..cd5d2baba 100644 --- a/changelog.txt +++ b/changelog.txt @@ -58,6 +58,7 @@ Template for new versions: - `assign-minecarts`: reassign vehicles to routes where the vehicle has been destroyed (or has otherwise gone missing) - `fix/dry-buckets`: prompt DF to recheck requests for aid (e.g. "bring water" jobs) when a bucket is unclogged and becomes available for use - `exterminate`: show descriptive names for the listed races in addition to their IDs +- `exterminate`: show actual names for unique creatures such as forgotten beasts and titans - `fix/ownership`: now also checks and fixes room ownership links ## Documentation diff --git a/exterminate.lua b/exterminate.lua index 0043febb9..0263fbe48 100644 --- a/exterminate.lua +++ b/exterminate.lua @@ -134,12 +134,23 @@ local function getMapRaces(opts) local map_races = {} for _, unit in pairs(df.global.world.units.active) do if not checkUnit(opts, unit) then goto continue end - local craw = df.creature_raw.find(unit.race) - local unit_race_name = dfhack.units.isUndead(unit) and 'UNDEAD' or craw.creature_id - local race = ensure_key(map_races, unit_race_name) + local race_name, display_name + if dfhack.units.isUndead(unit) then + race_name = 'UNDEAD' + display_name = 'UNDEAD' + else + local craw = df.creature_raw.find(unit.race) + race_name = craw.creature_id + if race_name:match('^FORGOTTEN_BEAST_[0-9]+$') or race_name:match('^TITAN_[0-9]+$') then + display_name = dfhack.units.getReadableName(unit) + else + display_name = craw.name[0] + end + end + local race = ensure_key(map_races, race_name) race.id = unit.race - race.name = unit_race_name - race.display_name = unit_race_name == 'UNDEAD' and '' or craw.name[0] + race.name = race_name + race.display_name = display_name race.count = (race.count or 0) + 1 ::continue:: end @@ -195,6 +206,17 @@ if not positionals[1] or positionals[1] == 'list' then table.insert(sorted_races, v) end table.sort(sorted_races, function(a, b) + if a.count == b.count then + local asuffix, bsuffix = a.name:match('([0-9]+)$'), b.name:match('([0-9]+)$') + if asuffix and bsuffix then + local aname, bname = a.name:match('(.*)_[0-9]+$'), b.name:match('(.*)_[0-9]+$') + local anum, bnum = tonumber(asuffix), tonumber(bsuffix) + if aname == bname and anum and bnum then + return anum < bnum + end + end + return a.name < b.name + end return a.count > b.count end) for _,v in ipairs(sorted_races) do