Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to extermiante all wild creatures #999

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/exterminate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Examples
Kill the ravens flying around the map (but only the male ones).
``exterminate GOBLIN --method magma --only-visible``
Kill all visible, hostile goblins on the map by boiling them in magma.
``exterminate all``
Kill all wild creatures.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Kill all wild creatures.
Kill all non-friendly creatures.

``exterminate all:FEMALE``
Kill all wild female creatures.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Kill all wild female creatures.
Kill all non-friendly female creatures.


Options
-------
Expand Down
27 changes: 27 additions & 0 deletions exterminate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,33 @@ if positionals[1]:lower() == 'undead' then
count = count + 1
end
end
elseif positionals[1]:split(':')[1] == "all" then
local selected_caste = nil

if string.find(positionals[1], ':') then
local tokens = positionals[1]:split(':')
selected_caste = tokens[2]
end
Comment on lines +185 to +190
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local selected_caste = nil
if string.find(positionals[1], ':') then
local tokens = positionals[1]:split(':')
selected_caste = tokens[2]
end
local selected_caste = positionals[1]:split(':')[2]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this was copied from the section below, but since you don't care about the "race" (all) here, it can be simplified


for _, unit in pairs(df.global.world.units.active) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for _, unit in pairs(df.global.world.units.active) do
for _, unit in ipairs(df.global.world.units.active) do


if not checkUnit(unit) then
goto skipunit
end
if options.only_visible and not dfhack.units.isVisible(unit) then
goto skipunit
end
if not options.include_friendly and isUnitFriendly(unit) then
goto skipunit
end
if selected_caste and selected_caste ~= df.creature_raw.find(unit.race).caste[unit.caste].caste_id then
goto skipunit
end

killUnit(unit, options.method)
count = count + 1
:: skipunit ::
end
else
local selected_race, selected_caste = positionals[1], nil

Expand Down