From d1ed5b7401340286faa626ef3a26f16a7b80a6bb Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 11 Aug 2023 13:17:48 -0700 Subject: [PATCH] vanish the undead instead of marking them inactive so undead sieges can end --- changelog.txt | 1 + starvingdead.lua | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6c8eeed715..15bee9cdea 100644 --- a/changelog.txt +++ b/changelog.txt @@ -34,6 +34,7 @@ Template for new versions: - `caravan`: Correct price adjustment values in trade agreement details screen - `caravan`: Apply both import and export trade agreement price adjustments to items being both bought or sold to align with how vanilla DF calculates prices - `suspendmanager`: Improve the detection on "T" and "+" shaped high walls +- `starvingdead`: ensure sieges end properly when undead siegers starve ## Misc Improvements - `devel/lsmem`: added support for filtering by memory addresses and filenames diff --git a/starvingdead.lua b/starvingdead.lua index 72728bbff8..8bf523fa38 100644 --- a/starvingdead.lua +++ b/starvingdead.lua @@ -45,26 +45,22 @@ end StarvingDead = defclass(StarvingDead) StarvingDead.ATTRS{ decay_rate = 1, - death_threshold = 6 + death_threshold = 6, } function StarvingDead:init() self.timeout_id = nil -- Percentage goal each attribute should reach before death. - self.attribute_goal = 10 - self.attribute_decay = (self.attribute_goal ^ (1 / ((self.death_threshold * 28 / self.decay_rate)))) / 100 - self.undead_count = 0 + local attribute_goal = 10 + self.attribute_decay = (attribute_goal ^ (1 / ((self.death_threshold * 28 / self.decay_rate)))) / 100 self:checkDecay() print(([[StarvingDead started, checking every %s days and killing off at %s months]]):format(self.decay_rate, self.death_threshold)) end function StarvingDead:checkDecay() - self.undead_count = 0 for _, unit in pairs(df.global.world.units.active) do if (unit.enemy.undead and not unit.flags1.inactive) then - self.undead_count = self.undead_count + 1 - -- time_on_site is measured in ticks, a month is 33600 ticks. -- @see https://dwarffortresswiki.org/index.php/Time for _, attribute in pairs(unit.body.physical_attrs) do @@ -72,8 +68,7 @@ function StarvingDead:checkDecay() end if unit.curse.time_on_site > (self.death_threshold * 33600) then - unit.flags1.inactive = true - unit.curse.rem_tags2.FIT_FOR_ANIMATION = true + unit.animal.vanish_countdown = 1 end end end