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

Add new overlay advtools fastcombat - skip combat anims and announcements #1385

Merged
merged 17 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from 15 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
2 changes: 2 additions & 0 deletions advtools.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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``, 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
Expand Down
13 changes: 13 additions & 0 deletions docs/advtools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
89 changes: 89 additions & 0 deletions internal/advtools/fastcombat.lua
Original file line number Diff line number Diff line change
@@ -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
-- 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