Skip to content

Commit

Permalink
Merge pull request #3 from pinguluk/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pinguluk authored Mar 6, 2023
2 parents e5c8da2 + 623752a commit 4a801d0
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions Scripts/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ local is_bind_registered = false
local is_shadowblink_start_hook_registered = false
local is_shadowblink_end_hook_registered = false

-- Change the speed of the ShadowBlink function
function SetShadowBlinkSpeed()
local shadowBlinkAbilityRootMotion = StaticFindObject(
"/Game/Pawn/Student/Abilities/Locomotion/ABL_ShadowBlink.Default__ABL_ShadowBlink_C:ablRootMotionModifiersTask_1.RootMotionModifierProperties_DodgeRoll_0")
if shadowBlinkAbilityRootMotion:IsValid() then
print('Setting ShadowBlink speed to ' .. shadowBlinkSpeed)
shadowBlinkAbilityRootMotion:SetPropertyValue("BlinkSpeed", shadowBlinkSpeed)
end

end

-- Change the offset of the ShadowBlink animation end
-- Change the offset of the ShadowBlink animation end function
function SetShadowBlinkAnimationEnd(offset)
print('Setting ShadowBlinkAnimationEnd to ' .. offset)
shadowBlinkAbility:SetPropertyValue("m_EndTime", {
["Offset"] = offset
})
end

-- Initialise the script
-- Initialise the script function
function Init()
print('is_bind_registered: ' .. tostring(is_bind_registered))
print('is_shadowblink_start_hook_registered: ' .. tostring(is_shadowblink_start_hook_registered))
Expand All @@ -40,7 +40,8 @@ function Init()

-- Prevent the key bind from being initialised multiple times
if is_bind_registered == false then
-- Bind left control key
print('Registering STOP key hook')
-- Register the STOP key bind to stop the ShadowBlink
RegisterKeyBind(stopShadowBlinkKey, {}, function()
print('Pressed STOP key while ShadowBlinking? ' .. tostring(isShadowBlinking))
print('Stopping shadow blink')
Expand All @@ -53,6 +54,7 @@ function Init()

-- Prevent the hook from being initialised multiple times
if is_shadowblink_start_hook_registered == false then
print('Registering ShadowBlink start hook')
-- On ShadowBlink start
RegisterHook("/Game/Pawn/Shared/StateTree/BTT_Biped_ShadowBlink_2.BTT_Biped_ShadowBlink_2_C:ReceiveExecute",
function()
Expand All @@ -66,6 +68,7 @@ function Init()

-- Prevent the hook from being initialised multiple times
if is_shadowblink_end_hook_registered == false then
print('Registering ShadowBlink end hook')
-- On ShadowBlink end
RegisterHook("/Game/Pawn/Shared/StateTree/BTT_Biped_ShadowBlink_2.BTT_Biped_ShadowBlink_2_C:ExitTask",
function()
Expand All @@ -78,6 +81,14 @@ function Init()
end
end

-- This will be used to prevent the mod's script from being initialised earlier than it should
-- as the ShadowBlink start & end animations hooks are not registered correctly when launching the game
local shouldInitTheMod = false

NotifyOnNewObject("/Script/Phoenix.Loadingcreen", function(self)
shouldInitTheMod = true
end)

-- Hook on load / reload
RegisterHook("/Script/Engine.PlayerController:ClientRestart", function(Context)
print("Hooked on load / reload succesfully")
Expand All @@ -86,10 +97,11 @@ RegisterHook("/Script/Engine.PlayerController:ClientRestart", function(Context)
shadowBlinkAbility = StaticFindObject(
"/Game/Pawn/Student/Abilities/Locomotion/ABL_ShadowBlink.Default__ABL_ShadowBlink_C:ablRootMotionModifiersTask_1")

-- If the ability is found, initialise the script
if shadowBlinkAbility:IsValid() then
print('Initialising')
-- If the ability is valid/exists and shouldInitTheMod is true, initialise the mod's scripts
if shadowBlinkAbility:IsValid() and shouldInitTheMod then
shouldInitTheMod = false
print('Initialising InfiniteSwift mod')
Init()
print('Finished initialising')
print('Finished initialising InfiniteSwift mod')
end
end)

0 comments on commit 4a801d0

Please sign in to comment.