Created
May 6, 2025 23:01
-
-
Save Priler/f8546bf01f9e1fbef66c207c593890e6 to your computer and use it in GitHub Desktop.
Workaround for first bow shoot menu open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--BowReleaseAnimationCancel | |
-- CONFIG | |
--------------------------------------------------------------------------------------------------------------------------- | |
--if you dont like that the animation is canceled the moment the arrow is shot, you can change this value to something > 0: | |
local DelayInMillisecondsForAnimationCancel = 10 | |
-- set to true if you want to disable the insta draw feature. | |
local DisableInstaDraw = false | |
-- this is the custom starting duration, it will only be used if DisableInstaDraw is set to false | |
local starting_draw_duration = 10 | |
--------------------------------------------------------------------------------------------------------------------------- | |
-- END CONFIG | |
local UEHelpers = require("UEHelpers") | |
local shot_bow = false | |
local function logMessage(message) | |
print("BowReleaseAnimationCancel - ".. message) | |
end | |
---@param Context RemoteUnrealParam | |
local function PeformBowAttack(Context) | |
local base = Context:get() ---@type UAST_CharacterActionBowDrawShoot_C | |
if not base.bIsPlayer then | |
return | |
end | |
local ptr_pawn = base.PairedPawn | |
if not ptr_pawn then | |
logMessage("ptr_Pawn not found") | |
end | |
local pawn = base.PairedPawn:Get() ---@cast pawn AVPairedPawn | |
local playerController = UEHelpers.GetPlayerController() | |
if not playerController or not playerController:IsValid() then | |
logMessage("PlayerController not found or invalid") | |
return | |
end | |
--local pawn = playerController.Pawn ---@cast pawn AVPairedPawn | |
if not pawn or not pawn:IsValid() then | |
logMessage("Pawn not found or invalid") | |
return | |
end | |
shot_bow = true | |
if DelayInMillisecondsForAnimationCancel >0 then | |
ExecuteWithDelay(DelayInMillisecondsForAnimationCancel,function() | |
playerController:QuickMenuInput_Pressed() | |
end) | |
else | |
playerController:QuickMenuInput_Pressed() | |
end | |
end | |
local function OnEntered(Context) | |
local base = Context:get() ---@type UAST_CharacterActionBowDrawShoot_C | |
if not base.bIsPlayer then | |
return | |
end | |
if DisableInstaDraw then | |
return | |
end | |
base.BowDrawInputHeldTime = starting_draw_duration | |
base.DrawDuration = starting_draw_duration | |
end | |
local playerController = UEHelpers.GetPlayerController() | |
---@param Context RemoteUnrealParam | |
local function CloseShortcutOnOpen(Context) | |
if not playerController or not playerController:IsValid() then | |
logMessage("PlayerController not found or invalid") | |
return | |
end | |
if shot_bow then | |
playerController:QuickMenuInput_Released() | |
shot_bow = false | |
end | |
end | |
local mod_name = "BowReleaseAnimationCancel" | |
local function create_hook(name,hook,fn) | |
return{ | |
name= name, | |
hook= hook, | |
fn=fn, | |
maxAttempts = 50, | |
currentAttempt = 0, | |
run= function(self) | |
local success = pcall(RegisterHook, | |
self.hook, | |
self.fn) | |
if success then | |
print(mod_name.."["..self.name.."]: Initialized.") | |
else | |
print(mod_name.."["..self.name.."]: Failed to initialize.") | |
end | |
self.currentAttempt = self.currentAttempt + 1 | |
if self.currentAttempt >= self.maxAttempts then | |
return true | |
end | |
return success | |
end | |
} | |
end | |
local hooks = { | |
create_hook("PerformBowAttack","/Game/Dev/StateMachine/AST_CharacterActionBowDrawShoot.AST_CharacterActionBowDrawShoot_C:PerformBowAttack",PeformBowAttack), | |
create_hook("InstaDraw","/Game/Dev/StateMachine/AST_CharacterActionBowDrawShoot.AST_CharacterActionBowDrawShoot_C:OnEntered",OnEntered), | |
create_hook("CloseShortcutOnOpen","Function /Game/UI/Modern/GameMenuLayer/WBP_ModernMenu_QuickKeys.WBP_ModernMenu_QuickKeys_C:PlayOpenAnimation",CloseShortcutOnOpen) | |
} | |
RegisterHook("/Script/Altar.VEnhancedAltarPlayerController:OnLoadFinished", function(ctx) | |
playerController:QuickMenuInput_Pressed() | |
ExecuteWithDelay(50, function() | |
playerController:QuickMenuInput_Released() | |
end) | |
end) | |
for i,hook in ipairs(hooks) do | |
LoopAsync(1000, function() return hook:run() end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment