Skip to content

Commit 6936ce8

Browse files
Crystalwarriorpre-commit-ci[bot]myk002
authored
Add new overlay advtools fastcombat - skip combat anims and announcements (#1385)
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! --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Myk <myk.taylor@gmail.com>
1 parent 0420f9b commit 6936ce8

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

advtools.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
--@ module=true
22

33
local convo = reqscript('internal/advtools/convo')
4+
local fastcombat = reqscript('internal/advtools/fastcombat')
45
local party = reqscript('internal/advtools/party')
56

67
OVERLAY_WIDGETS = {
78
conversation=convo.AdvRumorsOverlay,
9+
fastcombat=fastcombat.AdvCombatOverlay,
810
}
911

1012
if dfhack_flags.module then

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Template for new versions:
3030
- `autocheese`: automatically make cheese using barrels that have accumulated sufficient milk
3131

3232
## New Features
33+
- `advtools`: new overlay ``advtools.fastcombat``; allows you to skip combat animations and the announcement "More" button
3334

3435
## Fixes
3536
- `advtools`: fix dfhack-added conversation options not appearing in the ask whereabouts conversation tree

docs/advtools.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,16 @@ enemies will gain the ``slay`` and ``kill`` keywords. It will also add
3535
additional conversation options for asking whereabouts of your relationships --
3636
in vanilla, you can only ask whereabouts of historical figures involved in
3737
rumors you personally witnessed or heard about.
38+
39+
``advtools.fastcombat``
40+
~~~~~~~~~~~~~~~~~~~~~~~
41+
42+
When enabled, this overlay will allow you to skip most combat animations,
43+
including the whooshes and projectiles travelling through the screen. It will
44+
also let you skip the announcements window when the "More" button is active,
45+
scrolling you to the very bottom with the first press, and skipping the window
46+
entirely with the second press. This drastically speeds up combat while still
47+
giving you the option not to skip the announcements. Skip keys are left mouse click,
48+
the SELECT button, the movement keys and combat-related keys that don't bring up a
49+
menu (such as bump attack). If clicking to skip past combat, it will only skip the
50+
announcements if you're clicking outside the announcements panel.

internal/advtools/fastcombat.lua

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
--@ module=true
2+
local overlay = require('plugins.overlay')
3+
local gui = require('gui')
4+
local widgets = require('gui.widgets')
5+
6+
-- Overlay
7+
AdvCombatOverlay = defclass(AdvCombatOverlay, overlay.OverlayWidget)
8+
AdvCombatOverlay.ATTRS{
9+
desc='Skip combat animations and announcements with a click or key press.',
10+
default_enabled=true,
11+
viewscreens='dungeonmode',
12+
fullscreen=true,
13+
default_pos={x=1, y=7},
14+
frame={h=15},
15+
}
16+
17+
function AdvCombatOverlay:init()
18+
self.skip_combat = false
19+
20+
self:addviews{
21+
widgets.Panel{
22+
frame={w=113},
23+
view_id='announcement_panel_mask'
24+
}
25+
}
26+
end
27+
28+
function AdvCombatOverlay:preUpdateLayout(parent_rect)
29+
self.frame.w = parent_rect.width
30+
end
31+
32+
function AdvCombatOverlay:render(dc)
33+
if df.global.adventure.player_control_state == df.adventurest.T_player_control_state.TAKING_INPUT then
34+
self.skip_combat = false
35+
return
36+
end
37+
if self.skip_combat then
38+
-- Instantly process the projectile travelling
39+
df.global.adventure.projsubloop_visible_projectile = false
40+
-- Skip the combat swing animations
41+
df.global.adventure.game_loop_animation_timer_start = df.global.adventure.game_loop_animation_timer_start + 1000
42+
end
43+
end
44+
45+
46+
local COMBAT_MOVE_KEYS = {
47+
_MOUSE_L=true,
48+
SELECT=true,
49+
A_MOVE_N=true,
50+
A_MOVE_S=true,
51+
A_MOVE_E=true,
52+
A_MOVE_W=true,
53+
A_MOVE_NW=true,
54+
A_MOVE_NE=true,
55+
A_MOVE_SW=true,
56+
A_MOVE_SE=true,
57+
A_MOVE_SAME_SQUARE=true,
58+
A_ATTACK=true,
59+
A_COMBAT_ATTACK=true,
60+
}
61+
62+
function AdvCombatOverlay:onInput(keys)
63+
for code,_ in pairs(keys) do
64+
if not COMBAT_MOVE_KEYS[code] then goto continue end
65+
if df.global.adventure.player_control_state ~= df.adventurest.T_player_control_state.TAKING_INPUT then
66+
-- Instantly speed up the combat
67+
self.skip_combat = true
68+
elseif df.global.world.status.temp_flag.adv_showing_announcements then
69+
-- Don't let mouse skipping work when you click within the adventure mode announcement panel
70+
if keys._MOUSE_L and self.subviews.announcement_panel_mask:getMousePos() then
71+
return
72+
end
73+
-- Instantly process the projectile travelling
74+
-- (for some reason, projsubloop is still active during "TAKING INPUT" phase)
75+
df.global.adventure.projsubloop_visible_projectile = false
76+
77+
-- If there is more to be seen in this box...
78+
if df.global.world.status.temp_flag.adv_have_more then
79+
-- Scroll down to the very bottom
80+
df.global.world.status.adv_scroll_position = #df.global.world.status.adv_announcement - 10
81+
-- Nothing new left to see, get us OUT OF HERE!!
82+
else
83+
-- Allow us to quit out of showing announcements by clicking anywhere OUTSIDE the box
84+
df.global.world.status.temp_flag.adv_showing_announcements = false
85+
end
86+
end
87+
::continue::
88+
end
89+
end

0 commit comments

Comments
 (0)