From f8231fd3323d2ac5634825b632e9b67bb1a836c0 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Thu, 30 Jan 2025 05:39:58 +0300 Subject: [PATCH 01/17] Add a new fastcombat advtools overlay, allowing you to instantly process many combat actions to combat the tedium of combat. Also works for movement in general! --- advtools.lua | 2 + changelog.txt | 1 + docs/advtools.rst | 15 ++++++ internal/advtools/fastcombat.lua | 91 ++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 internal/advtools/fastcombat.lua diff --git a/advtools.lua b/advtools.lua index 6b2b0d09af..9f4d2ec3b3 100644 --- a/advtools.lua +++ b/advtools.lua @@ -1,10 +1,12 @@ --@ module=true local convo = reqscript('internal/advtools/convo') +local fastcombat = reqscript('internal/advtools/fastcombat') local party = reqscript('internal/advtools/party') OVERLAY_WIDGETS = { conversation=convo.AdvRumorsOverlay, + fastcombat=fastcombat.AdvCombatOverlay, } if dfhack_flags.module then diff --git a/changelog.txt b/changelog.txt index 6c8f0dd35e..7e823ca38c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -28,6 +28,7 @@ Template for new versions: ## New Tools - `autocheese`: automatically make cheese using barrels that have accumulated sufficient milk +- `advtools`: new overlay ``advtools fastcombat``, while active it allows you to instantly skip many combat actions ## New Features diff --git a/docs/advtools.rst b/docs/advtools.rst index c62cdb1f83..2d1d1db99c 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -35,3 +35,18 @@ enemies will gain the ``slay`` and ``kill`` keywords. It will also add additional conversation options for asking whereabouts of your relationships -- in vanilla, you can only ask whereabouts of historical figures involved in rumors you personally witnessed or heard about. + +``advtools.combat`` +~~~~~~~~~~~~~~~~~~~ + +When enabled, this overlay will allow you to skip most combat animations, +including the wooshes and projectiles travelling through the screen. It will +also let you skip the announcements window if "More" button is active, +scrolling you to the very bottom with the first press, and skipping the window +entirely with the second press. This drastically speeds up combat while still +being intuitive enough - you can still be slow and methodical if you choose +not to skip. Skip keys are left mouseclick, the SELECT button, the movement +keys and combat-related keys that don't bring up its own menu (such as bump +attack). If clicking to skip past combat, it will properly unerstand when +you're clicking within the announcements box and not activate the script - +only clicking OUTSIDE it will process the skipping. diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua new file mode 100644 index 0000000000..708ec6b56d --- /dev/null +++ b/internal/advtools/fastcombat.lua @@ -0,0 +1,91 @@ +--@ module=true +local overlay = require('plugins.overlay') + +-- Overlay +AdvCombatOverlay = defclass(AdvCombatOverlay, overlay.OverlayWidget) +AdvCombatOverlay.ATTRS{ + desc='Faster combat!', + default_enabled=true, + viewscreens='dungeonmode', + frame={w=0, h=0}, +} +local skip_combat = false +function AdvCombatOverlay:render() + local adv = df.global.adventure + if adv.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then + skip_combat = false + return + end + if skip_combat then + -- Instantly process the projectile travelling + adv.projsubloop_visible_projectile = false + -- Skip the combat swing animations + adv.game_loop_animation_timer_start = adv.game_loop_animation_timer_start + 1000 + end +end + + +COMBAT_MOVE_KEYS={ + _MOUSE_L = true, + SELECT = true, + A_MOVE_N = true, + A_MOVE_S = true, + A_MOVE_E = true, + A_MOVE_W = true, + A_MOVE_NW = true, + A_MOVE_NE = true, + A_MOVE_SW = true, + A_MOVE_SE = true, + A_MOVE_SAME_SQUARE = true, + A_ATTACK = true, + A_COMBAT_ATTACK = true, +} + +function AdvCombatOverlay:onInput(keys) + if AdvCombatOverlay.super.onInput(self, keys) then + return true + end + local adv = df.global.adventure + for code,_ in pairs(keys) do + if COMBAT_MOVE_KEYS[code] then + if adv.player_control_state ~= df.adventurest.T_player_control_state.TAKING_INPUT then + -- Instantly speed up the combat + skip_combat = true + elseif adv.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then + if COMBAT_MOVE_KEYS[code] and df.global.world.status.temp_flag.adv_showing_announcements then + -- We're using mouse to skip, more unique behavior to mouse clicking is handled here + if keys._MOUSE_L then + x,y = dfhack.screen.getMousePos() + local screen_width, _ = dfhack.screen.getWindowSize() + -- Calculate if we're clicking within the vanilla adv announcements box + adv_announce_width = 112 + adv_announce_x1 = screen_width/2 - adv_announce_width/2 - 1 + adv_announce_x2 = screen_width/2 + adv_announce_width/2 - 1 + -- The Y values for this box don't change + adv_announce_y1, adv_announce_y2 = 6, 20 + -- Check if we're clicking within the bounds of the adv announcements box that is being shown right now + if y >= adv_announce_y1 and y <= adv_announce_y2 and x >= adv_announce_x1 and x <= adv_announce_x2 then + -- Don't do anything on our end, the player is clicking within the adv announcements box. + -- We don't want to overtake vanilla behavior in this ui element. + return + end + end + -- Instantly process the projectile travelling + -- (for some reason, projsubloop is still active during "TAKING INPUT" phase) + adv.projsubloop_visible_projectile = false + + -- If there is more to be seen in this box... + if df.global.world.status.temp_flag.adv_have_more then + -- Instantly scroll to the very end when clicking, we want OUT of here, + -- but still leave a chance for the player to review the log! + df.global.world.status.adv_scroll_position = math.min(df.global.world.status.adv_scroll_position + 10, #df.global.world.status.adv_announcement) + -- Nothing new left to see, get us OUT OF HERE!! + else + -- Allow us to quit out of showing announcements by clicking anywhere OUTSIDE the box + df.global.world.status.temp_flag.adv_showing_announcements = false + end + end + end + end + end +end \ No newline at end of file From 7ce4003371a8976aa24b18a4d213ac1244eb3da8 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Thu, 30 Jan 2025 06:45:22 +0300 Subject: [PATCH 02/17] a --- docs/advtools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advtools.rst b/docs/advtools.rst index 2d1d1db99c..3c7d9352d2 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -36,7 +36,7 @@ additional conversation options for asking whereabouts of your relationships -- in vanilla, you can only ask whereabouts of historical figures involved in rumors you personally witnessed or heard about. -``advtools.combat`` +``advtools.fastcombat`` ~~~~~~~~~~~~~~~~~~~ When enabled, this overlay will allow you to skip most combat animations, From ee3fe2de68b09e5cff9fc3f94cb147e80169b8f3 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 06:14:14 +0300 Subject: [PATCH 03/17] fix docs --- docs/advtools.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/advtools.rst b/docs/advtools.rst index 3c7d9352d2..9fcfaa2fa6 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -37,10 +37,10 @@ in vanilla, you can only ask whereabouts of historical figures involved in rumors you personally witnessed or heard about. ``advtools.fastcombat`` -~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~ When enabled, this overlay will allow you to skip most combat animations, -including the wooshes and projectiles travelling through the screen. It will +including the whooshes and projectiles travelling through the screen. It will also let you skip the announcements window if "More" button is active, scrolling you to the very bottom with the first press, and skipping the window entirely with the second press. This drastically speeds up combat while still From 952543fdb20789a102b980f0dcd1b3379d0222a6 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 06:16:54 +0300 Subject: [PATCH 04/17] , --- docs/advtools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advtools.rst b/docs/advtools.rst index 9fcfaa2fa6..9eb4586f37 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -47,6 +47,6 @@ entirely with the second press. This drastically speeds up combat while still being intuitive enough - you can still be slow and methodical if you choose not to skip. Skip keys are left mouseclick, the SELECT button, the movement keys and combat-related keys that don't bring up its own menu (such as bump -attack). If clicking to skip past combat, it will properly unerstand when +attack). If clicking to skip past combat, it will properly understand when you're clicking within the announcements box and not activate the script - only clicking OUTSIDE it will process the skipping. From f929b1c4d6889ef6b91c8ed295ddf065a39a2ffc Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 06:36:11 +0300 Subject: [PATCH 05/17] Implement suggestions --- internal/advtools/fastcombat.lua | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 708ec6b56d..1ec5108019 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -7,51 +7,51 @@ AdvCombatOverlay.ATTRS{ desc='Faster combat!', default_enabled=true, viewscreens='dungeonmode', - frame={w=0, h=0}, + fullscreen=true, + default_pos={x=1,y=1}, + skip_combat = false } -local skip_combat = false + function AdvCombatOverlay:render() - local adv = df.global.adventure - if adv.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then - skip_combat = false + if df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then + self.skip_combat = false return end - if skip_combat then + if self.skip_combat then -- Instantly process the projectile travelling - adv.projsubloop_visible_projectile = false + df.global.adventure.projsubloop_visible_projectile = false -- Skip the combat swing animations - adv.game_loop_animation_timer_start = adv.game_loop_animation_timer_start + 1000 + df.global.adventure.game_loop_animation_timer_start = df.global.adventure.game_loop_animation_timer_start + 1000 end end -COMBAT_MOVE_KEYS={ - _MOUSE_L = true, - SELECT = true, - A_MOVE_N = true, - A_MOVE_S = true, - A_MOVE_E = true, - A_MOVE_W = true, - A_MOVE_NW = true, - A_MOVE_NE = true, - A_MOVE_SW = true, - A_MOVE_SE = true, - A_MOVE_SAME_SQUARE = true, - A_ATTACK = true, - A_COMBAT_ATTACK = true, +local COMBAT_MOVE_KEYS = { + _MOUSE_L=true, + SELECT=true, + A_MOVE_N=true, + A_MOVE_S=true, + A_MOVE_E=true, + A_MOVE_W=true, + A_MOVE_NW=true, + A_MOVE_NE=true, + A_MOVE_SW=true, + A_MOVE_SE=true, + A_MOVE_SAME_SQUARE=true, + A_ATTACK=true, + A_COMBAT_ATTACK=true, } function AdvCombatOverlay:onInput(keys) if AdvCombatOverlay.super.onInput(self, keys) then return true end - local adv = df.global.adventure for code,_ in pairs(keys) do if COMBAT_MOVE_KEYS[code] then - if adv.player_control_state ~= df.adventurest.T_player_control_state.TAKING_INPUT then + if df.global.adventure.player_control_state ~= df.adventurest.T_player_control_state.TAKING_INPUT then -- Instantly speed up the combat - skip_combat = true - elseif adv.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then + self.skip_combat = true + elseif df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then if COMBAT_MOVE_KEYS[code] and df.global.world.status.temp_flag.adv_showing_announcements then -- We're using mouse to skip, more unique behavior to mouse clicking is handled here if keys._MOUSE_L then @@ -72,7 +72,7 @@ function AdvCombatOverlay:onInput(keys) end -- Instantly process the projectile travelling -- (for some reason, projsubloop is still active during "TAKING INPUT" phase) - adv.projsubloop_visible_projectile = false + df.global.adventure.projsubloop_visible_projectile = false -- If there is more to be seen in this box... if df.global.world.status.temp_flag.adv_have_more then From 69d5c032c60a6c75ead7c88d917ab9ae6a7116cd Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 06:57:00 +0300 Subject: [PATCH 06/17] new tool not feature --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 7e823ca38c..2f3b243028 100644 --- a/changelog.txt +++ b/changelog.txt @@ -28,9 +28,9 @@ Template for new versions: ## New Tools - `autocheese`: automatically make cheese using barrels that have accumulated sufficient milk -- `advtools`: new overlay ``advtools fastcombat``, while active it allows you to instantly skip many combat actions ## New Features +- `advtools`: new overlay ``advtools.fastcombat``, while active it allows you to instantly skip many combat actions ## Fixes - `advtools`: fix dfhack-added conversation options not appearing in the ask whereabouts conversation tree From 7f87f2f14d8be5e4bd74c9817b097a4b0bf10e6d Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 06:58:09 +0300 Subject: [PATCH 07/17] Update comment to be correct and not lying to you --- internal/advtools/fastcombat.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 1ec5108019..63a84f5f4a 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -76,8 +76,7 @@ function AdvCombatOverlay:onInput(keys) -- If there is more to be seen in this box... if df.global.world.status.temp_flag.adv_have_more then - -- Instantly scroll to the very end when clicking, we want OUT of here, - -- but still leave a chance for the player to review the log! + -- Scroll down 10 paces aka the same way it'd happen if you pressed on "more" df.global.world.status.adv_scroll_position = math.min(df.global.world.status.adv_scroll_position + 10, #df.global.world.status.adv_announcement) -- Nothing new left to see, get us OUT OF HERE!! else From 148df9f48b09edf552d33fea6401cbbbaab13142 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 06:59:03 +0300 Subject: [PATCH 08/17] add end newline --- internal/advtools/fastcombat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 63a84f5f4a..c3a583c79e 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -87,4 +87,4 @@ function AdvCombatOverlay:onInput(keys) end end end -end \ No newline at end of file +end From aedeacd92f97d837a13445a26204e5ff3640aeb9 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 08:01:45 +0300 Subject: [PATCH 09/17] make it a fullscreen widget --- internal/advtools/fastcombat.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index c3a583c79e..714ef3a539 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -1,4 +1,6 @@ --@ module=true +local gui = require('gui') +local widgets = require('gui.widgets') local overlay = require('plugins.overlay') -- Overlay @@ -8,7 +10,6 @@ AdvCombatOverlay.ATTRS{ default_enabled=true, viewscreens='dungeonmode', fullscreen=true, - default_pos={x=1,y=1}, skip_combat = false } From 0ea6f1801763e235771dbffbd47b2d408fe518ff Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 31 Jan 2025 08:21:20 +0300 Subject: [PATCH 10/17] remove useless code --- internal/advtools/fastcombat.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 714ef3a539..40f7cf116b 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -1,6 +1,4 @@ --@ module=true -local gui = require('gui') -local widgets = require('gui.widgets') local overlay = require('plugins.overlay') -- Overlay From 78bd9488b4fa57a50e3675094a6209a196df9d84 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Sat, 1 Feb 2025 13:27:21 +0300 Subject: [PATCH 11/17] use widget to capture mouse clicks instead --- internal/advtools/fastcombat.lua | 42 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 40f7cf116b..ff1945f781 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -1,5 +1,7 @@ --@ module=true local overlay = require('plugins.overlay') +local gui = require('gui') +local widgets = require('gui.widgets') -- Overlay AdvCombatOverlay = defclass(AdvCombatOverlay, overlay.OverlayWidget) @@ -8,10 +10,27 @@ AdvCombatOverlay.ATTRS{ default_enabled=true, viewscreens='dungeonmode', fullscreen=true, - skip_combat = false + default_pos={x=1, y=7}, + frame={h=15}, } -function AdvCombatOverlay:render() +function AdvCombatOverlay:init() + self.skip_combat = false + + self:addviews{ + widgets.Panel{ + frame={w=113}, + view_id='announcement_panel_mask' + } + } +end + +function AdvCombatOverlay:preUpdateLayout(parent_rect) + self.frame.w = parent_rect.width +end + +function AdvCombatOverlay:render(dc) + AdvCombatOverlay.super.render(self, dc) if df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then self.skip_combat = false return @@ -52,22 +71,9 @@ function AdvCombatOverlay:onInput(keys) self.skip_combat = true elseif df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then if COMBAT_MOVE_KEYS[code] and df.global.world.status.temp_flag.adv_showing_announcements then - -- We're using mouse to skip, more unique behavior to mouse clicking is handled here - if keys._MOUSE_L then - x,y = dfhack.screen.getMousePos() - local screen_width, _ = dfhack.screen.getWindowSize() - -- Calculate if we're clicking within the vanilla adv announcements box - adv_announce_width = 112 - adv_announce_x1 = screen_width/2 - adv_announce_width/2 - 1 - adv_announce_x2 = screen_width/2 + adv_announce_width/2 - 1 - -- The Y values for this box don't change - adv_announce_y1, adv_announce_y2 = 6, 20 - -- Check if we're clicking within the bounds of the adv announcements box that is being shown right now - if y >= adv_announce_y1 and y <= adv_announce_y2 and x >= adv_announce_x1 and x <= adv_announce_x2 then - -- Don't do anything on our end, the player is clicking within the adv announcements box. - -- We don't want to overtake vanilla behavior in this ui element. - return - end + -- Don't let mouse skipping work when you click within the adventure mode announcement panel + if keys._MOUSE_L and self.subviews.announcement_panel_mask:getMousePos() then + return end -- Instantly process the projectile travelling -- (for some reason, projsubloop is still active during "TAKING INPUT" phase) From e107451a077d59be8d601002187a6839ba01ab60 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 1 Feb 2025 10:42:13 +0000 Subject: [PATCH 12/17] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/advtools.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advtools.rst b/docs/advtools.rst index 9eb4586f37..02d712c532 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -39,7 +39,7 @@ rumors you personally witnessed or heard about. ``advtools.fastcombat`` ~~~~~~~~~~~~~~~~~~~~~~~ -When enabled, this overlay will allow you to skip most combat animations, +When enabled, this overlay will allow you to skip most combat animations, including the whooshes and projectiles travelling through the screen. It will also let you skip the announcements window if "More" button is active, scrolling you to the very bottom with the first press, and skipping the window From df75299214a57b060b40316a8a3283abb24e48b9 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sat, 1 Feb 2025 14:53:42 +0300 Subject: [PATCH 13/17] Apply suggestions from code review Co-authored-by: Myk --- docs/advtools.rst | 13 ++++---- internal/advtools/fastcombat.lua | 52 ++++++++++++++------------------ 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/docs/advtools.rst b/docs/advtools.rst index 02d712c532..dd0a451424 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -41,12 +41,11 @@ rumors you personally witnessed or heard about. When enabled, this overlay will allow you to skip most combat animations, including the whooshes and projectiles travelling through the screen. It will -also let you skip the announcements window if "More" button is active, +also let you skip the announcements window when the "More" button is active, scrolling you to the very bottom with the first press, and skipping the window entirely with the second press. This drastically speeds up combat while still -being intuitive enough - you can still be slow and methodical if you choose -not to skip. Skip keys are left mouseclick, the SELECT button, the movement -keys and combat-related keys that don't bring up its own menu (such as bump -attack). If clicking to skip past combat, it will properly understand when -you're clicking within the announcements box and not activate the script - -only clicking OUTSIDE it will process the skipping. +giving you the option not to skip the announcements. Skip keys are left mouse click, +the SELECT button, the movement +keys and combat-related keys that don't bring up a menu (such as bump +attack). If clicking to skip past combat, it will only skip the announcements +if you're clicking outside the announcements panel. diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index ff1945f781..38faa9a011 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -6,7 +6,7 @@ local widgets = require('gui.widgets') -- Overlay AdvCombatOverlay = defclass(AdvCombatOverlay, overlay.OverlayWidget) AdvCombatOverlay.ATTRS{ - desc='Faster combat!', + desc='Skip combat animations and announcements with a click or key press.', default_enabled=true, viewscreens='dungeonmode', fullscreen=true, @@ -30,7 +30,6 @@ function AdvCombatOverlay:preUpdateLayout(parent_rect) end function AdvCombatOverlay:render(dc) - AdvCombatOverlay.super.render(self, dc) if df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then self.skip_combat = false return @@ -61,35 +60,30 @@ local COMBAT_MOVE_KEYS = { } function AdvCombatOverlay:onInput(keys) - if AdvCombatOverlay.super.onInput(self, keys) then - return true - end for code,_ in pairs(keys) do - if COMBAT_MOVE_KEYS[code] then - if df.global.adventure.player_control_state ~= df.adventurest.T_player_control_state.TAKING_INPUT then - -- Instantly speed up the combat - self.skip_combat = true - elseif df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then - if COMBAT_MOVE_KEYS[code] and df.global.world.status.temp_flag.adv_showing_announcements then - -- Don't let mouse skipping work when you click within the adventure mode announcement panel - if keys._MOUSE_L and self.subviews.announcement_panel_mask:getMousePos() then - return - end - -- Instantly process the projectile travelling - -- (for some reason, projsubloop is still active during "TAKING INPUT" phase) - df.global.adventure.projsubloop_visible_projectile = false + if not COMBAT_MOVE_KEYS[code] then goto continue end + if df.global.adventure.player_control_state ~= df.adventurest.T_player_control_state.TAKING_INPUT then + -- Instantly speed up the combat + self.skip_combat = true + elseif df.global.world.status.temp_flag.adv_showing_announcements then + -- Don't let mouse skipping work when you click within the adventure mode announcement panel + if keys._MOUSE_L and self.subviews.announcement_panel_mask:getMousePos() then + return + end + -- Instantly process the projectile travelling + -- (for some reason, projsubloop is still active during "TAKING INPUT" phase) + df.global.adventure.projsubloop_visible_projectile = false - -- If there is more to be seen in this box... - if df.global.world.status.temp_flag.adv_have_more then - -- Scroll down 10 paces aka the same way it'd happen if you pressed on "more" - df.global.world.status.adv_scroll_position = math.min(df.global.world.status.adv_scroll_position + 10, #df.global.world.status.adv_announcement) - -- Nothing new left to see, get us OUT OF HERE!! - else - -- Allow us to quit out of showing announcements by clicking anywhere OUTSIDE the box - df.global.world.status.temp_flag.adv_showing_announcements = false - end - end + -- If there is more to be seen in this box... + if df.global.world.status.temp_flag.adv_have_more then + -- Scroll down 10 paces aka the same way it'd happen if you pressed on "more" + df.global.world.status.adv_scroll_position = math.min(df.global.world.status.adv_scroll_position + 10, #df.global.world.status.adv_announcement) + -- Nothing new left to see, get us OUT OF HERE!! + else + -- Allow us to quit out of showing announcements by clicking anywhere OUTSIDE the box + df.global.world.status.temp_flag.adv_showing_announcements = false end end - end + ::continue:: + end end From 63f565878add85db047a31f922494384b390f92d Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Sat, 1 Feb 2025 14:56:40 +0300 Subject: [PATCH 14/17] Scroll down to the very bottom in a single click rather than the "shift-scroll"/more button behavior --- docs/advtools.rst | 7 +++---- internal/advtools/fastcombat.lua | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/advtools.rst b/docs/advtools.rst index dd0a451424..113d6c969a 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -45,7 +45,6 @@ also let you skip the announcements window when the "More" button is active, scrolling you to the very bottom with the first press, and skipping the window entirely with the second press. This drastically speeds up combat while still giving you the option not to skip the announcements. Skip keys are left mouse click, -the SELECT button, the movement -keys and combat-related keys that don't bring up a menu (such as bump -attack). If clicking to skip past combat, it will only skip the announcements -if you're clicking outside the announcements panel. +the SELECT button, the movement keys and combat-related keys that don't bring up a +menu (such as bump attack). If clicking to skip past combat, it will only skip the +announcements if you're clicking outside the announcements panel. diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 38faa9a011..919ae85ac5 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -76,8 +76,8 @@ function AdvCombatOverlay:onInput(keys) -- If there is more to be seen in this box... if df.global.world.status.temp_flag.adv_have_more then - -- Scroll down 10 paces aka the same way it'd happen if you pressed on "more" - df.global.world.status.adv_scroll_position = math.min(df.global.world.status.adv_scroll_position + 10, #df.global.world.status.adv_announcement) + -- Scroll down to the very bottom + df.global.world.status.adv_scroll_position = #df.global.world.status.adv_announcement -- Nothing new left to see, get us OUT OF HERE!! else -- Allow us to quit out of showing announcements by clicking anywhere OUTSIDE the box From 83929dc27e0509bb2b7b61def51fe022032ba7e3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 1 Feb 2025 12:00:21 +0000 Subject: [PATCH 15/17] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- internal/advtools/fastcombat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 919ae85ac5..657bd12b69 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -85,5 +85,5 @@ function AdvCombatOverlay:onInput(keys) end end ::continue:: - end + end end From 051b3fad8ce26d8362b29c55ae6f8c3e58ac74dd Mon Sep 17 00:00:00 2001 From: Myk Date: Sat, 1 Feb 2025 12:50:33 -0800 Subject: [PATCH 16/17] Update changelog.txt --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 2f3b243028..437417c7a9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -30,7 +30,7 @@ Template for new versions: - `autocheese`: automatically make cheese using barrels that have accumulated sufficient milk ## New Features -- `advtools`: new overlay ``advtools.fastcombat``, while active it allows you to instantly skip many combat actions +- `advtools`: new overlay ``advtools.fastcombat``; allows you to skip combat animations and the announcement "More" button ## Fixes - `advtools`: fix dfhack-added conversation options not appearing in the ask whereabouts conversation tree From 136cfbf7693174cbf2c6283d5d28808016de487d Mon Sep 17 00:00:00 2001 From: Myk Date: Sat, 1 Feb 2025 12:51:11 -0800 Subject: [PATCH 17/17] set scroll position properly --- internal/advtools/fastcombat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua index 657bd12b69..2b9cd184f0 100644 --- a/internal/advtools/fastcombat.lua +++ b/internal/advtools/fastcombat.lua @@ -77,7 +77,7 @@ function AdvCombatOverlay:onInput(keys) -- If there is more to be seen in this box... if df.global.world.status.temp_flag.adv_have_more then -- Scroll down to the very bottom - df.global.world.status.adv_scroll_position = #df.global.world.status.adv_announcement + df.global.world.status.adv_scroll_position = #df.global.world.status.adv_announcement - 10 -- Nothing new left to see, get us OUT OF HERE!! else -- Allow us to quit out of showing announcements by clicking anywhere OUTSIDE the box