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

Update Exterminate #1187

Merged
merged 11 commits into from
Jun 22, 2024
Merged

Update Exterminate #1187

merged 11 commits into from
Jun 22, 2024

Conversation

Crystalwarrior
Copy link
Contributor

  • Fix it crashing adventure mode due to outdated item deletion method
  • Add --x (--max) argument, letting you set an extermination cap
  • Teleport disintegrated units to the top of the world so they are not seen dying

…te" option

Swap to dfhack.items.remove(item) method of destroying an item
Add a --maximum options to set maximum number of units to exterminate
…to z-level 0 instead?)

Add a "maximum" option letting you exterminate up to a cap
Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

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

please add documentation to docs/exterminate.rst and changelog.txt

exterminate.lua Outdated Show resolved Hide resolved
exterminate.lua Outdated Show resolved Hide resolved
Crystalwarrior and others added 3 commits June 22, 2024 02:48
Don't teleport unit on DISINTEGRATE method
Add documentation for new features
changelog.txt Outdated Show resolved Hide resolved
changelog.txt Outdated Show resolved Hide resolved
@@ -48,6 +48,8 @@ Options
on the map.
``-f``, ``--include-friendly``
Specifies the tool should also kill units friendly to the player.
``-x``, ``--max <num>``
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
``-x``, ``--max <num>``
``-l``, ``--limit <num>``

@@ -64,6 +66,7 @@ Methods
:magma: Boil the unit in magma (not recommended for magma-safe creatures).
:butcher: Will mark the units for butchering instead of killing them. This is
more useful for pets than armed enemies.
:knockout: Will put units into an unconscious state for 30k ticks.
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
:knockout: Will put units into an unconscious state for 30k ticks.
:knockout: Will put units into an unconscious state for 30k ticks (about a month).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

more testing needed for this one, I dunno if adventure mode ticks align with fortress mode ticks

Copy link
Member

@myk002 myk002 Jun 22, 2024

Choose a reason for hiding this comment

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

they don't. the month estimate is for fort mode. you could define either define a time span that knockout will last and adjust different ticks based on the mode, or else document the different time spans that knockout will last in fort mode vs. adventure mode.

wiki article on time: https://dwarffortresswiki.org/index.php/Time#Basic_mechanics

exterminate.lua Outdated
Comment on lines 28 to 34
local isInAdvGroup = false
local isAdvPet = false
local adv = dfhack.world.getAdventurer()
if adv then
isInAdvGroup = unit.relationship_ids.GroupLeader == dfhack.world.getAdventurer().id
isAdvPet = unit.relationship_ids.PetOwner == dfhack.world.getAdventurer().id
end
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 isInAdvGroup = false
local isAdvPet = false
local adv = dfhack.world.getAdventurer()
if adv then
isInAdvGroup = unit.relationship_ids.GroupLeader == dfhack.world.getAdventurer().id
isAdvPet = unit.relationship_ids.PetOwner == dfhack.world.getAdventurer().id
end
local adv = dfhack.world.getAdventurer()
if adv then
if adv == unit or
unit.relationship_ids.GroupLeader == adv.id or
unit.relationship_ids.PetOwner == adv.id
then
return true
end
end

if adv then
isInAdvGroup = unit.relationship_ids.GroupLeader == dfhack.world.getAdventurer().id
isAdvPet = unit.relationship_ids.PetOwner == dfhack.world.getAdventurer().id
end
return dfhack.units.isOwnCiv(unit) or
dfhack.units.isOwnGroup(unit) or
Copy link
Member

Choose a reason for hiding this comment

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

how does isOwnGroup behave in adventure mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it doesn't. isOwnGroup only checks plotinfo which is irrelevant to adventure mode

Copy link
Member

Choose a reason for hiding this comment

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

does that mean it always returns false, or that it returns garbage data?

exterminate.lua Outdated
@@ -156,13 +161,15 @@ local options, args = {
method = killMethod.INSTANT,
only_visible = false,
include_friendly = false,
maximum = -1,
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
maximum = -1,
limit = -1,

exterminate.lua Outdated Show resolved Hide resolved
exterminate.lua Outdated
@@ -217,7 +224,9 @@ elseif positionals[1]:split(':')[1] == "all" then
local selected_caste = positionals[1]:split(':')[2]

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

if options.maximum > 0 and count >= options.maximum then
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
if options.maximum > 0 and count >= options.maximum then
if options.limit > 0 and count >= options.limit then

exterminate.lua Outdated
@@ -269,6 +278,9 @@ else
target = selected_race

for _, unit in pairs(df.global.world.units.active) do
if options.maximum > 0 and count >= options.maximum then
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
if options.maximum > 0 and count >= options.maximum then
if options.limit > 0 and count >= options.limit then

myk002 and others added 2 commits June 21, 2024 18:30
…tate with no pathfinding

maximum -> limit
Implement suggestions
@myk002
Copy link
Member

myk002 commented Jun 22, 2024

note that you can add the code change suggestions to a batch and commit them directly instead of reimplementing the suggestions yourself. That also has the benefit of resolving the suggestion.

changelog.txt Outdated Show resolved Hide resolved
@myk002
Copy link
Member

myk002 commented Jun 22, 2024

I determined that dfhack.units.isOwnGroup will return garbage data in adventure mode, but it's due to a DF bug. I'll take that up with Putnam.

@myk002 myk002 merged commit d95e812 into DFHack:master Jun 22, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants