Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Anyone know how to tally up how many dwarves are on either side in the arena?  (Read 734 times)

Pancakes

  • Bay Watcher
  • Cancels drink: Too insane
    • View Profile

I'm doing some research in the arena and need to be able to quickly tally up how many dwarves are on either team, team 1 or team 2. There are too many dwarves to accurately count by hand, so I was wondering if there was a way that I could use Notepad++ or something else to see how many on either side of the conflict survived. Thanks!
« Last Edit: February 12, 2020, 07:45:53 pm by Scarlet_Avenger »
Logged

Atomic Chicken

  • Bay Watcher
    • View Profile

I wrote a script which should perform the described function:

Code: [Select]
local teams = {}

for _, unit in ipairs(df.global.world.units.active) do
  if not unit.flags2.killed then -- don't count dead units
    local side = unit.enemy.enemy_status_slot
    if teams[side] then
      teams[side] = teams[side] + 1
    else
      teams[side] = 1
    end
  end
end

for side, count in pairs(teams) do
  if count > 0 then
    local name
    if side == 0 then
      name = 'Independent'
    else
      name = 'Side ' .. side
    end
    print(name .. ': ' .. count)
  end
end


This works using DFHack. Copy-paste the above code into a text editor like Notepad++ and save it as a .lua file with a name of your choosing (arena-team-count.lua is an example) in the \hack\scripts folder (which should be present in your main DF folder after extracting DFHack there). To run, simply enter the file name in the DFHack console during play (taking the above example, this would just be arena-team-count). A list of teams and their unit count (not counting dead units) should be printed to the console.

Note: I might have seen this sooner if it had been posted in the Utilities and 3rd Party Applications section of the forums.

Logged
As mentioned in the previous turn, the most exciting field of battle this year will be in the Arstotzkan capitol, with plenty of close-quarter fighting and siege warfare.  Arstotzka, accordingly, spent their design phase developing a high-altitude tactical bomber.