forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DFHack#1053 from terribleperson/master
zero-noexert-exhaustion bugfix script, doc, and control-panel registry entry
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
fix/noexert-exhaustion | ||
====================== | ||
|
||
.. dfhack-tool:: | ||
:summary: Prevents NOEXERT units from getting tired when training. | ||
:tags: fort bugfix units | ||
|
||
This tool zeroes the "exhaustion" counter of all NOEXERT units (e.g. Vampires, Necromancers, and Intelligent Undead), | ||
fixing any that are stuck 'Tired' from an activity that doesn't respect NOEXERT. This is not a permanent fix - | ||
the issue will reoccur next time they partake in an activity that does not respect the NOEXERT tag. | ||
|
||
Running this regularly works around :bug:`8389`, which permanently debuffs NOEXERT units and prevents them from | ||
properly partaking in military training. It should be run if you notice Vampires, Necromancers, or Intelligent | ||
Undead becoming 'Tired'. Enabling this script via `control-panel` or `gui/control-panel` will run it often enough to | ||
prevent NOEXERT units from becoming 'Tired'. | ||
|
||
Usage | ||
----- | ||
:: | ||
|
||
fix/noexert-exhaustion | ||
|
||
Technical details | ||
----------------- | ||
|
||
Units with the NOEXERT tag ignore most sources of physical exertion, and have no means to recover from it. | ||
Individual Combat Drill seems to add approximately 50 'Exhaustion' every 9 ticks, ignoring NOEXERT. | ||
Units become Tired at 2000 Exhaustion, and switch from Individual Combat Drill to Individual Combat Drill/Resting at 3000. | ||
Setting the Exhaustion counter of every NOEXERT-tagged unit to 0 every 350 ticks should prevent them from becoming Tired from Individual Combat Drill. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--checks all units for the NOEXERT tag, and sets their Exhaustion counter to zero | ||
--NOEXERT units (including Vampires, Necromancers, and Intelligent Undead) are unable to lower their Exhaustion, and are not supposed to gain Exhaustion. | ||
--at least one activity (Individual Combat Drill) doesn't respect NOEXERT, and will leave NOEXERT units permanently Tired. This script will fix 'Tired' NOEXERT units. | ||
--Individual Combat Drill seems to add 50 Exhaustion approximately every 9 ticks. 'Tired' appears at 2000 Exhaustion, and dwarves switch to Individual Combat Drill/Resting at 3000 Exhaustion. | ||
--Running this script on repeat approximately at least every 350 ticks should prevent NOEXERT units from becoming Tired as a result of Individual Combat Drill. | ||
|
||
function isNoExert(u) | ||
if(u.curse.rem_tags1.NOEXERT) then --tag removal overrides tag addition, so if the NOEXERT tag is removed the unit cannot be NOEXERT. | ||
return false | ||
end | ||
if(u.curse.add_tags1.NOEXERT) then--if the tag hasn't been removed, and the unit has a curse that adds it, they must be NOEXERT. | ||
return true | ||
end | ||
if(dfhack.units.casteFlagSet(u.race,u.caste, df.caste_raw_flags.NOEXERT)) then --if the tag hasn't been added or removed, but their race and caste has the tag, they're NOEXERT. | ||
return true | ||
end | ||
end | ||
|
||
function fixNoExertExhaustion() | ||
for _, unit in ipairs(dfhack.units.getCitizens()) do | ||
if(isNoExert(unit)) then | ||
unit.counters2.exhaustion = 0 -- 0 represents no Exhaustion. NOEXERT units should never have Exhaustion above 0. | ||
end | ||
end | ||
end | ||
|
||
fixNoExertExhaustion() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters