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

Fix sleeping army controllers in Adventure Mode not responding to intruders #1177

Merged
merged 8 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions adv-fix-sleepers.lua

This file was deleted.

1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved

## New Features
- `buildingplan`: dimension tooltip is now displayed for constructions and buildings that are designated over an area
Expand Down
18 changes: 18 additions & 0 deletions docs/fix/sleepers.rst
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions fix/sleepers.lua
Original file line number Diff line number Diff line change
@@ -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 k, unit in pairs(df.global.world.units.active) do
Copy link
Member

Choose a reason for hiding this comment

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

is a camp a site? does that mean that the fix is only relevant in sites? can we trigger this script to run when a site is loaded? that is, can we make this script enableable and watch for state change events, automatically running when the SC_MAP_LOADED event fires and there is an active site (and we're 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.

There are camps that are created for travelling armies as well (for example, a unit stopped in the middle of nowhere to create a cloth block tent and is sleeping)
Yes, good idea! We can make this trigger either A) instantly react to adventurer, B) react to adventurer who isn't sneaking and present in close vicinity to the target, or C) React to receiving Pain (not bloodloss/painless attacks tho, so you can still rob someone by wrestling their items off)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should keep this manual for now until we decide on when the "fix" should apply, let's study the general sleeping behavior in adv mode and how people react to being attacked when asleep.

Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
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 .. " bugged army_controller(s).")
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
end