Skip to content

Commit d1ed5b7

Browse files
committed
vanish the undead instead of marking them inactive
so undead sieges can end
1 parent 855f0f6 commit d1ed5b7

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Template for new versions:
3434
- `caravan`: Correct price adjustment values in trade agreement details screen
3535
- `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
3636
- `suspendmanager`: Improve the detection on "T" and "+" shaped high walls
37+
- `starvingdead`: ensure sieges end properly when undead siegers starve
3738

3839
## Misc Improvements
3940
- `devel/lsmem`: added support for filtering by memory addresses and filenames

starvingdead.lua

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,30 @@ end
4545
StarvingDead = defclass(StarvingDead)
4646
StarvingDead.ATTRS{
4747
decay_rate = 1,
48-
death_threshold = 6
48+
death_threshold = 6,
4949
}
5050

5151
function StarvingDead:init()
5252
self.timeout_id = nil
5353
-- Percentage goal each attribute should reach before death.
54-
self.attribute_goal = 10
55-
self.attribute_decay = (self.attribute_goal ^ (1 / ((self.death_threshold * 28 / self.decay_rate)))) / 100
56-
self.undead_count = 0
54+
local attribute_goal = 10
55+
self.attribute_decay = (attribute_goal ^ (1 / ((self.death_threshold * 28 / self.decay_rate)))) / 100
5756

5857
self:checkDecay()
5958
print(([[StarvingDead started, checking every %s days and killing off at %s months]]):format(self.decay_rate, self.death_threshold))
6059
end
6160

6261
function StarvingDead:checkDecay()
63-
self.undead_count = 0
6462
for _, unit in pairs(df.global.world.units.active) do
6563
if (unit.enemy.undead and not unit.flags1.inactive) then
66-
self.undead_count = self.undead_count + 1
67-
6864
-- time_on_site is measured in ticks, a month is 33600 ticks.
6965
-- @see https://dwarffortresswiki.org/index.php/Time
7066
for _, attribute in pairs(unit.body.physical_attrs) do
7167
attribute.value = math.floor(attribute.value - (attribute.value * self.attribute_decay))
7268
end
7369

7470
if unit.curse.time_on_site > (self.death_threshold * 33600) then
75-
unit.flags1.inactive = true
76-
unit.curse.rem_tags2.FIT_FOR_ANIMATION = true
71+
unit.animal.vanish_countdown = 1
7772
end
7873
end
7974
end

0 commit comments

Comments
 (0)