Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TimedBlock
- -- If you want to change settings please open TimedBlock.ini
- -- If you want to change settings please open TimedBlock.ini
- -- If you want to change settings please open TimedBlock.ini
- -- DO NOT EDIT BELOW !
- local UEHelpers = require("UEHelpers")
- local ConfigHelper = require("ConfigHelper")
- local Mod = "TimedBlock"
- local ConfigName = "TimedBlock.ini"
- local config = {}
- local blockWindow = 0.0
- --Config = ConfigHelper.GetConfig("TimedBlock", "TimedBlock.ini")
- local inTimedBlock = false
- local isBlockPressed = false
- local blockTimeStamp = 0.0
- local coolDownTimeStamp = 0.0
- local timeLerp = 1.0
- local isInSlomo = false
- local hasBlocked = false
- local TimeSinceSlowSpeed = 0.0
- local VOblivionInitialSettings = nil
- local playerController = nil
- local worldSettings = nil
- local function PlayHitEffect()
- -- Doesn't work yet :(
- --local BP_BloodImpact_C = StaticFindObject('/Game/Art/FX/_Shared/Blueprints/BP_BloodImpact.Default__BP_BloodImpact_C')
- end
- local function SetBlockWindow()
- local player = FindFirstOf("BP_OblivionPlayerCharacter_C")
- if player and player:IsValid() then
- local playerstats = player.ActorValuesPairingComponent
- local playerBlockSkill = playerstats:GetUIntBaseActorValue(15)
- print(playerBlockSkill)
- if playerBlockSkill >= 100 then
- blockWindow = Config.TimedWindowMaster
- elseif playerBlockSkill >= 75 then
- blockWindow = Config.TimedWindowExpert
- elseif playerBlockSkill >= 50 then
- blockWindow = Config.TimedWindowJourneyman
- elseif playerBlockSkill >= 25 then
- blockWindow = Config.TimedWindowApprentice
- else
- blockWindow = Config.TimedWindowNovice
- end
- print(blockWindow)
- end
- end
- local function PlayTimedBlockSound()
- local actor = playerController.pawn
- local IntProperty = StaticFindObject('/Script/CoreUObject.Default__IntProperty')
- --AkAudioEvent /Game/WwiseAudio/Interface/Global/Redesign/ui_glb_hover.ui_glb_hover
- --local event = FindObject("/Game/WwiseEvents/MyEvent.MyEvent") -- UAkAudioEvent*
- local event1 = StaticFindObject('/Game/WwiseAudio/Magic/Alteration/magic_spl_alteration_fail.magic_spl_alteration_fail')
- local event2 = StaticFindObject('/Game/WwiseAudio/Interface/HUD/Redesign/ui_hud_weap_broken.ui_hud_weap_broken')
- local event5 = StaticFindObject('/Game/WwiseAudio/Events/NWSWeapon/nws_weap_impact.nws_weap_impact')
- local event6 = StaticFindObject('/Game/WwiseAudio/Events/NWSWeapon/Foley/nws_weap_bow_shoot.nws_weap_bow_shoot')
- local event8 = StaticFindObject('/Game/WwiseAudio/Game_Object/Door/obj_drs_alteration_cast.obj_drs_alteration_cast')
- local event9 = StaticFindObject('/Game/WwiseAudio/Interface/HUD/Redesign/ui_hud_weap_damaged.ui_hud_weap_damaged')
- local liveEvent = event5
- --print(string.format("liveEvent %s", liveEvent:GetFullName()))
- event9:PostOnActorAndWait(actor, true, {})
- if true then
- --event8:PostOnActorAndWait(actor, true, {})
- event2:PostOnActorAndWait(actor, true, {})
- liveEvent:PostOnActorAndWait(actor, true, {})
- --liveEvent:PostOnActorAndWait(actor, true, {})
- --liveEvent:PostOnActorAndWait(actor, true, {})
- ExecuteWithDelay(10, function()
- event1:PostOnActorAndWait(actor, true, {})
- end)
- ExecuteWithDelay(20, function()
- liveEvent:PostOnActorAndWait(actor, true, {})
- end)
- ExecuteWithDelay(30, function()
- event6:PostOnActorAndWait(actor, true, {})
- end)
- end
- --print("Played sound")
- end
- local function lerp(aFrom, aTo, aTime)
- return aFrom + (aTo - aFrom) * aTime
- end
- local function getCurrentTime()
- local timeSTMP = os.clock()
- return timeSTMP
- end
- local function setMaxBlock()
- --print("setMaxBlock")
- if Config.NoHealthDamageOnTimedBlock == true then
- VOblivionInitialSettings.MinimumShieldBlockValue = Config.DamageMultBlockedShield
- VOblivionInitialSettings.MinimumWeaponBlockValue = Config.DamageMultBlockedWeapon
- VOblivionInitialSettings.MinimumHandToHandBlockValue = Config.DamageMultBlockedHandToHand
- end
- if Config.NoFatigueDamageOnTimedBlock == true then
- VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = 0.0
- VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = 0.0
- VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = 0.0
- VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = 0.0
- end
- if Config.ModdedFatigueDamageOnTimedBlock == true then
- VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = Config.DefaultNoviceBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
- VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = Config.DefaultJourneymanBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
- VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = Config.DefaultExpertBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
- VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = Config.DefaultMasterBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
- end
- end
- local function restoreMaxBlock()
- --print("ReSetMaxBlock")
- if not VOblivionInitialSettings or not VOblivionInitialSettings:IsValid() then
- return
- end
- if Config.NoHealthDamageOnTimedBlock == true then
- VOblivionInitialSettings.MinimumShieldBlockValue = Config.DefaultDamageMultBlockedShield
- VOblivionInitialSettings.MinimumWeaponBlockValue = Config.DefaultDamageMultBlockedWeapon
- VOblivionInitialSettings.MinimumHandToHandBlockValue = Config.DefaultDamageMultBlockedHandToHand
- end
- if Config.NoFatigueDamageOnTimedBlock == true then
- VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = Config.DefaultNoviceBlockPerkFatigueDamageMod
- VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = Config.DefaultJourneymanBlockPerkFatigueDamageMod
- VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = Config.DefaultExpertBlockPerkFatigueDamageMod
- VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = Config.DefaultMasterBlockPerkFatigueDamageMod
- end
- if Config.ModdedFatigueDamageOnTimedBlock == true then
- VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = Config.DefaultNoviceBlockPerkFatigueDamageMod
- VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = Config.DefaultJourneymanBlockPerkFatigueDamageMod
- VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = Config.DefaultExpertBlockPerkFatigueDamageMod
- VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = Config.DefaultMasterBlockPerkFatigueDamageMod
- end
- --VOblivionInitialSettings.CombatHitConeAngle = 20.0
- end
- local function ReturnSlomoSpeed()
- local succ = false
- if playerController:IsValid() then
- --print(string.format("playerController %s", playerController:GetFullName()))
- if worldSettings:IsValid() then
- worldSettings.TimeDilation = 1.0
- if worldSettings.TimeDilation == 1.0 then
- isInSlomo = false
- succ = true
- --TimeDilation = worldSettings.TimeDilation
- end
- end
- end
- return succ
- end
- local function sendStagger()
- -- blivionPlayerCharacter_C_2147482298.CharacterMesh0.TABP_BlockShield_C_2147472083
- -- ObjectProperty /Script/Altar.VMeleeAttackComboAnimInstance:CurrentAttackAnimSequence
- -- TABP_MeleeAttack_MediumCombo_C /Game/Maps/World/L_Tamriel.L_Tamriel:PersistentLevel.BP_OblivionPlayerCharacter_C_2147482298.CharacterMesh0.TABP_MeleeAttack_MediumCombo_C_2147472753
- --VCharacterStatePairingComponent /Game/Maps/World/L_Tamriel.L_Tamriel:PersistentLevel.BP_OblivionPlayerCharacter_C_2147482298.Oblivion Actor State Pairing Component
- --ObjectProperty /Script/Altar.VPairedPawn:OblivionActorStatePairingComponent
- local attacker = playerController.pawn.OblivionActorStatePairingComponent.LatestHitTaken.Attacker
- --print(string.format("OblivionActorStatePairingComponent %s", playerController.pawn.OblivionActorStatePairingComponent:GetFullName()))
- --print(string.format("attacker %s", attacker:GetFullName()))
- --print(string.format("attacker.pawn %s", attacker.pawn:GetFullName()))
- --print(string.format("attacker.OblivionActorStatePairingComponent %s", attacker.OblivionActorStatePairingComponent:GetFullName()))
- ExecuteInGameThread(function()
- --attacker:CancelAnimatedAction()
- --attacker:SendStagger()
- end)
- --TABP_HitReact_C /Game/Maps/World/L_Tamriel.L_Tamriel:PersistentLevel.BP_OblivionPlayerCharacter_C_2147482298.First Person Skeletal Mesh.TABP_HitReact_C_2147475189
- --print(" S T A G G E R ")
- --attacker.pawn:AddGameplayTag({TagName=FName("Actor.Action.Combat.Dodge")})
- end
- local function SlomoLerp(aLerpMult)
- if playerController:IsValid() then
- --print(string.format("playerController %s", playerController:GetFullName()))
- if worldSettings:IsValid() then
- worldSettings.TimeDilation = lerp(1.0, Config.slowSpeed , aLerpMult)
- --print(string.format("TimeDilation %.2f", worldSettings.TimeDilation))
- if worldSettings.TimeDilation ~= 1.0 then
- isInSlomo = true
- --TimeDilation = worldSettings.TimeDilation
- end
- end
- end
- end
- local function ScheduleForReset()
- LoopAsync(1, function()
- --print("timed inslomo")
- local difference = getCurrentTime() - TimeSinceSlowSpeed
- if Config.RevertSlowMoSmooth == true then
- local aLrp = 1.0 - ((math.min(difference, Config.SlowDuration) / Config.SlowDuration) ^ Config.SlowMoSmoothEasingPow)
- --print(string.format("difference %s", difference))
- --print(string.format("aLrp %s", aLrp))
- if isInSlomo == true and aLrp < 1.0 and aLrp > 0.0 then
- SlomoLerp(aLrp)
- return false
- end
- end
- if isInSlomo == true and difference > Config.SlowDuration then
- restoreMaxBlock()
- ReturnSlomoSpeed()
- end
- if isInSlomo == true then
- return false
- end
- --print("done")
- return true
- end)
- end
- local function SlomoSpeed(aLerpMult)
- if playerController:IsValid() then
- if worldSettings:IsValid() then
- worldSettings.TimeDilation = Config.slowSpeed * aLerpMult
- if worldSettings.TimeDilation ~= 1.0 then
- isInSlomo = true
- TimeSinceSlowSpeed = getCurrentTime()
- ScheduleForReset()
- end
- end
- end
- end
- local function Hook()
- print("hooked timeblocked")
- RegisterHook("/Script/Altar.VEnhancedAltarPlayerController:BlockInput_Pressed", function(Context)
- if isBlockPressed == false then
- --SetCameraSettings()
- --PlayHitEffect()
- isBlockPressed = true
- if getCurrentTime() - coolDownTimeStamp > Config.CoolDownBeforeNextAttempt then
- inTimedBlock = true
- setMaxBlock()
- blockTimeStamp = getCurrentTime()
- --print(string.format("playerController %s", playerController:GetFullName()))
- end
- end
- local difference = getCurrentTime() - blockTimeStamp
- if difference >= blockWindow and inTimedBlock == true then
- inTimedBlock = false
- restoreMaxBlock()
- --print(string.format("difference is bigger than TimedWindow %s", difference))
- end
- end)
- RegisterHook("/Script/Altar.VEnhancedAltarPlayerController:BlockInput_Released", function(Context)
- coolDownTimeStamp = getCurrentTime()
- isBlockPressed = false
- inTimedBlock = false
- restoreMaxBlock()
- -- print("block released")
- end)
- RegisterHook("/Script/Altar.VPairedPawn:OnCombatHitDealt", function(Context, HitEvent)
- world = playerController:GetLevel().WorldSettings -- possible to change, requires rescan, might be replaced by an event, on level change?
- if HitEvent then
- local hEvent = HitEvent:get()
- if hEvent:IsValid() then
- local attacker = hEvent.Attacker
- local target = hEvent.Target
- local blockHit = hEvent.bDoesTargetBlockHit
- if attacker:IsValid() then
- if playerController.pawn:GetFullName() == target:GetFullName() and blockHit == true then
- --print("PLAYER HAS BLOCKED")
- worldSettings = playerController:GetLevel().worldSettings
- if inTimedBlock == true then
- --print("SendBlockHit")
- hasBlocked = true
- if isBlockPressed == true and getCurrentTime() - blockTimeStamp < blockWindow then
- hasBlocked = false
- --sendStagger() allows enemy to perform invisible hits DISABLED
- if Config.PlaySoundQueue == true then
- PlayTimedBlockSound()
- end
- setMaxBlock()
- -- TimeSinceSlowSpeed = getCurrentTime()
- SlomoSpeed(1.0)
- end
- end
- end
- end
- end
- end
- end)
- RegisterHook("/Game/Dev/Controllers/BP_AltarPlayerController.BP_AltarPlayerController_C:InpActEvt_AnyKey_K2Node_InputKeyEvent_1", function(Context, Key)
- if Key:get().KeyName:ToString() == Config.ReloadKey then
- --print("relaoding ini")
- Config = ConfigHelper.GetConfig(Mod, ConfigName)
- SetBlockWindow()
- end
- end)
- print("hook success!")
- end
- LoopAsync(100, function()
- playerController = UEHelpers.GetPlayerController()
- VOblivionInitialSettings = StaticFindObject('/Script/UE5AltarPairing.Default__VOblivionInitialSettings')
- if playerController:IsValid() then
- if playerController:GetLevel():IsValid() then
- worldSettings = playerController:GetLevel().worldSettings
- end
- end
- if not playerController:IsValid() or not VOblivionInitialSettings:IsValid() or not worldSettings:IsValid() then
- return false
- end
- local inputC = StaticFindObject('/Game/Dev/Controllers/BP_AltarPlayerController.BP_AltarPlayerController_C:InpActEvt_AnyKey_K2Node_InputKeyEvent_1')
- if inputC:IsValid() and inputC then
- print("Hooking . . .")
- Config = ConfigHelper.GetConfig(Mod, ConfigName)
- SetBlockWindow()
- Hook()
- else
- return false
- end
- return true
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement