diff --git a/adv-fix-sleepers.lua b/adv-fix-sleepers.lua deleted file mode 100644 index e92a01e0e7..0000000000 --- a/adv-fix-sleepers.lua +++ /dev/null @@ -1,45 +0,0 @@ ---Fixes all local bugged sleepers in adventure mode. ---[====[ - -adv-fix-sleepers -================ -Fixes :bug:`6798`. This bug is characterized by sleeping units who refuse to -awaken in adventure mode regardless of talking to them, hitting them, or waiting -so long you die of thirst. If you come accross one or more bugged sleepers in -adventure mode, simply run the script and all nearby sleepers will be cured. - -Usage:: - - adv-fix-sleepers - - -]====] - ---======================== --- Author: ArrowThunder on bay12 & reddit --- Version: 1.1 ---======================= - --- get the list of all the active units currently loaded -local active_units = df.global.world.units.active -- get all active units - --- check every active unit for the bug -local num_fixed = 0 -- this is the number of army controllers fixed, not units - -- I've found that often, multiple sleepers share a bugged army controller -for k, unit in pairs(active_units) do - if unit then - local army_controller = df.army_controller.find(unit.enemy.army_controller_id) - if army_controller and army_controller.type == 4 then -- sleeping code is possible - if army_controller.unk_64.t4.unk_2.not_sleeping == false then - army_controller.unk_64.t4.unk_2.not_sleeping = true -- fix bug - num_fixed = num_fixed + 1 - end - end - end -end - -if num_fixed == 0 then - print ("No sleepers with the fixable bug were found, sorry.") -else - print ("Fixed " .. num_fixed .. " bugged army_controller(s).") -end diff --git a/changelog.txt b/changelog.txt index a3dd724786..a56839cf24 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ Template for new versions: - `gui/tiletypes`: interface for modifying map tiles and tile properties - `fix/population-cap`: fixes the situation where you continue to get migrant waves even when you are above your configured population cap - `fix/occupancy`: fixes issues where you can't build somewhere because the game tells you an item/unit/building is in the way but there's nothing there +- `fix/sleepers`: (reinstated) fixes sleeping units belonging to a camp that never wake up. ## New Features - `buildingplan`: dimension tooltip is now displayed for constructions and buildings that are designated over an area, like bridges and farm plots @@ -87,6 +88,7 @@ Template for new versions: - `max-wave`: merged into `pop-control` - `devel/find-offsets`, `devel/find-twbt`, `devel/prepare-save`: remove development scripts that are no longer useful - `fix/item-occupancy`, `fix/tile-occupancy`: merged into `fix/occupancy` +- `adv-fix-sleepers`: renamed to `fix/sleepers` - `adv-rumors`: merged into `advtools` # 50.13-r2 diff --git a/docs/adv-fix-sleepers.rst b/docs/adv-fix-sleepers.rst deleted file mode 100644 index 111a743f43..0000000000 --- a/docs/adv-fix-sleepers.rst +++ /dev/null @@ -1,18 +0,0 @@ -adv-fix-sleepers -================ - -.. dfhack-tool:: - :summary: Fix units who refuse to awaken in adventure mode. - :tags: unavailable - -Use this tool if you encounter sleeping units who refuse to awaken regardless of -talking to them, hitting them, or waiting so long you die of thirst -(:bug:`6798`). If you come across one or more bugged sleepers in adventure -mode, simply run the script and all nearby sleepers will be cured. - -Usage ------ - -:: - - adv-fix-sleepers diff --git a/docs/fix/sleepers.rst b/docs/fix/sleepers.rst new file mode 100644 index 0000000000..1b3a0bc6ae --- /dev/null +++ b/docs/fix/sleepers.rst @@ -0,0 +1,18 @@ +fix/sleepers +============ + +.. dfhack-tool:: + :summary: Fixes sleeping units belonging to a camp that never wake up. + :tags: adventure bugfix + +Fixes :bug:`6798`. This bug is characterized by sleeping units who refuse to +awaken in adventure mode regardless of talking to them, hitting them, or waiting +so long you die of thirst. If you come accross one or more bugged sleepers in +adventure mode, simply run the script and all nearby sleepers will be cured. + +Usage +----- + +:: + + fix/sleepers diff --git a/fix/sleepers.lua b/fix/sleepers.lua new file mode 100644 index 0000000000..1b7ed75fa8 --- /dev/null +++ b/fix/sleepers.lua @@ -0,0 +1,21 @@ +-- Number of fixed army controller(s) that may be shared by multiple units +local num_fixed = 0 + +-- Loop through all the active units currently loaded +for _, unit in ipairs(df.global.world.units.active) do + local army_controller = unit.enemy.army_controller + -- Only Campers have been observed to sleep + if army_controller and army_controller.goal == df.army_controller_goal_type.CAMP then + if not army_controller.data.goal_camp.camp_flag.ALARM_INTRUDER then + -- Intruder alert! Bloodthirsty adventurer is in the camp! + army_controller.data.goal_camp.camp_flag.ALARM_INTRUDER = true + num_fixed = num_fixed + 1 + end + end +end + +if num_fixed == 0 then + print ("No sleepers with the fixable bug were found, sorry.") +else + print ("Fixed " .. num_fixed .. " group(s) of sleeping units.") +end