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..437417c7a9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -30,6 +30,7 @@ Template for new versions: - `autocheese`: automatically make cheese using barrels that have accumulated sufficient milk ## New Features +- `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 diff --git a/docs/advtools.rst b/docs/advtools.rst index c62cdb1f83..113d6c969a 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -35,3 +35,16 @@ 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.fastcombat`` +~~~~~~~~~~~~~~~~~~~~~~~ + +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 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. diff --git a/internal/advtools/fastcombat.lua b/internal/advtools/fastcombat.lua new file mode 100644 index 0000000000..2b9cd184f0 --- /dev/null +++ b/internal/advtools/fastcombat.lua @@ -0,0 +1,89 @@ +--@ module=true +local overlay = require('plugins.overlay') +local gui = require('gui') +local widgets = require('gui.widgets') + +-- Overlay +AdvCombatOverlay = defclass(AdvCombatOverlay, overlay.OverlayWidget) +AdvCombatOverlay.ATTRS{ + desc='Skip combat animations and announcements with a click or key press.', + default_enabled=true, + viewscreens='dungeonmode', + fullscreen=true, + default_pos={x=1, y=7}, + frame={h=15}, +} + +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) + if df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then + self.skip_combat = false + return + end + if self.skip_combat then + -- Instantly process the projectile travelling + df.global.adventure.projsubloop_visible_projectile = false + -- Skip the combat swing animations + df.global.adventure.game_loop_animation_timer_start = df.global.adventure.game_loop_animation_timer_start + 1000 + end +end + + +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) + for code,_ in pairs(keys) do + 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 to the very bottom + 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 + df.global.world.status.temp_flag.adv_showing_announcements = false + end + end + ::continue:: + end +end