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

Fixes shooting in adventure mode #1217

Merged
merged 7 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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,9 +1,11 @@
--@ module=true

local convo = reqscript('internal/advtools/convo')
local shooting = reqscript('internal/advtools/shooting')

OVERLAY_WIDGETS = {
conversation=convo.AdvRumorsOverlay,
shooting=shooting.FixShootingOverlay,
Copy link
Member

Choose a reason for hiding this comment

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

I'd use fix_shooting for the key so people know it's a fix

}

if dfhack_flags.module then
Expand Down
28 changes: 28 additions & 0 deletions internal/advtools/shooting.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Fixes shooting/throwing options stacking on each other, causing null pointers and crashes
--@ module = true

local aim_projectile = df.global.game.main_interface.adventure.aim_projectile

local overlay = require('plugins.overlay')

FixShootingOverlay = defclass(FixShootingOverlay, overlay.OverlayWidget)
FixShootingOverlay.ATTRS{
desc='Fixes Shooting your weapon breaking your Throw action.',
default_enabled=true,
viewscreens={
'dungeonmode/Inventory',
'dungeonmode/AimProjectile'
},
frame={w=0, h=0},
}

function FixShootingOverlay:onInput()
myk002 marked this conversation as resolved.
Show resolved Hide resolved
if aim_projectile.open == false then
aim_projectile.shooter_it = nil
aim_projectile.ammo_it = nil
aim_projectile.thrown_it = nil
aim_projectile.shooting = false
elseif aim_projectile.shooting then
aim_projectile.thrown_it = nil
end
end