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 6 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 shooting = reqscript('internal/advtools/shooting')
local party = reqscript('internal/advtools/party')

OVERLAY_WIDGETS = {
conversation=convo.AdvRumorsOverlay,
fix_shooting=shooting.FixShootingOverlay,
}

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 @@ -28,6 +28,7 @@ Template for new versions:

## New Tools
- `advtools`: collection of useful commands and overlays for adventure mode
- `advtools`: added a fix for the shooting bug that corrupts throwing/shooting and can cause crashes between save loads
myk002 marked this conversation as resolved.
Show resolved Hide resolved
- `advtools`: advtools party - promotes one of your companions to become a controllable adventurer
- `pop-control`: (reinstated) limit the maximum size of migrant waves
- `bodyswap`: (reinstated) take control of another unit in adventure mode
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