Advertisement
Guest User

Untitled

a guest
May 9th, 2025
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.60 KB | None | 0 0
  1. -- TimedBlock
  2. -- If you want to change settings please open TimedBlock.ini
  3. -- If you want to change settings please open TimedBlock.ini
  4. -- If you want to change settings please open TimedBlock.ini
  5.  
  6. -- DO NOT EDIT BELOW !
  7.  
  8. local UEHelpers = require("UEHelpers")
  9. local ConfigHelper = require("ConfigHelper")
  10. local Mod = "TimedBlock"
  11. local ConfigName = "TimedBlock.ini"
  12. local config = {}
  13. local blockWindow = 0.0
  14.  
  15.  
  16. --Config = ConfigHelper.GetConfig("TimedBlock", "TimedBlock.ini")
  17. local inTimedBlock = false
  18. local isBlockPressed = false
  19. local blockTimeStamp = 0.0
  20. local coolDownTimeStamp = 0.0
  21. local timeLerp = 1.0
  22. local isInSlomo = false
  23. local hasBlocked = false
  24. local TimeSinceSlowSpeed = 0.0
  25. local VOblivionInitialSettings = nil
  26. local playerController = nil
  27. local worldSettings = nil
  28.  
  29.  
  30. local function PlayHitEffect()
  31.  
  32. -- Doesn't work yet :(
  33. --local BP_BloodImpact_C = StaticFindObject('/Game/Art/FX/_Shared/Blueprints/BP_BloodImpact.Default__BP_BloodImpact_C')
  34.  
  35.  
  36. end
  37.  
  38. local function SetBlockWindow()
  39. local player = FindFirstOf("BP_OblivionPlayerCharacter_C")
  40. if player and player:IsValid() then
  41. local playerstats = player.ActorValuesPairingComponent
  42. local playerBlockSkill = playerstats:GetUIntBaseActorValue(15)
  43. print(playerBlockSkill)
  44.  
  45. if playerBlockSkill >= 100 then
  46. blockWindow = Config.TimedWindowMaster
  47. elseif playerBlockSkill >= 75 then
  48. blockWindow = Config.TimedWindowExpert
  49. elseif playerBlockSkill >= 50 then
  50. blockWindow = Config.TimedWindowJourneyman
  51. elseif playerBlockSkill >= 25 then
  52. blockWindow = Config.TimedWindowApprentice
  53. else
  54. blockWindow = Config.TimedWindowNovice
  55. end
  56. print(blockWindow)
  57. end
  58. end
  59.  
  60.  
  61. local function PlayTimedBlockSound()
  62.  
  63. local actor = playerController.pawn
  64.  
  65.  
  66. local IntProperty = StaticFindObject('/Script/CoreUObject.Default__IntProperty')
  67. --AkAudioEvent /Game/WwiseAudio/Interface/Global/Redesign/ui_glb_hover.ui_glb_hover
  68. --local event = FindObject("/Game/WwiseEvents/MyEvent.MyEvent") -- UAkAudioEvent*
  69. local event1 = StaticFindObject('/Game/WwiseAudio/Magic/Alteration/magic_spl_alteration_fail.magic_spl_alteration_fail')
  70. local event2 = StaticFindObject('/Game/WwiseAudio/Interface/HUD/Redesign/ui_hud_weap_broken.ui_hud_weap_broken')
  71.  
  72. local event5 = StaticFindObject('/Game/WwiseAudio/Events/NWSWeapon/nws_weap_impact.nws_weap_impact')
  73. local event6 = StaticFindObject('/Game/WwiseAudio/Events/NWSWeapon/Foley/nws_weap_bow_shoot.nws_weap_bow_shoot')
  74.  
  75. local event8 = StaticFindObject('/Game/WwiseAudio/Game_Object/Door/obj_drs_alteration_cast.obj_drs_alteration_cast')
  76.  
  77. local event9 = StaticFindObject('/Game/WwiseAudio/Interface/HUD/Redesign/ui_hud_weap_damaged.ui_hud_weap_damaged')
  78.  
  79. local liveEvent = event5
  80. --print(string.format("liveEvent %s", liveEvent:GetFullName()))
  81.  
  82.  
  83. event9:PostOnActorAndWait(actor, true, {})
  84.  
  85. if true then
  86. --event8:PostOnActorAndWait(actor, true, {})
  87. event2:PostOnActorAndWait(actor, true, {})
  88.  
  89. liveEvent:PostOnActorAndWait(actor, true, {})
  90. --liveEvent:PostOnActorAndWait(actor, true, {})
  91. --liveEvent:PostOnActorAndWait(actor, true, {})
  92.  
  93. ExecuteWithDelay(10, function()
  94. event1:PostOnActorAndWait(actor, true, {})
  95. end)
  96.  
  97. ExecuteWithDelay(20, function()
  98. liveEvent:PostOnActorAndWait(actor, true, {})
  99. end)
  100.  
  101. ExecuteWithDelay(30, function()
  102. event6:PostOnActorAndWait(actor, true, {})
  103. end)
  104.  
  105.  
  106. end
  107. --print("Played sound")
  108.  
  109.  
  110.  
  111.  
  112.  
  113. end
  114.  
  115.  
  116.  
  117. local function lerp(aFrom, aTo, aTime)
  118. return aFrom + (aTo - aFrom) * aTime
  119. end
  120.  
  121. local function getCurrentTime()
  122. local timeSTMP = os.clock()
  123. return timeSTMP
  124. end
  125.  
  126. local function setMaxBlock()
  127. --print("setMaxBlock")
  128. if Config.NoHealthDamageOnTimedBlock == true then
  129. VOblivionInitialSettings.MinimumShieldBlockValue = Config.DamageMultBlockedShield
  130. VOblivionInitialSettings.MinimumWeaponBlockValue = Config.DamageMultBlockedWeapon
  131. VOblivionInitialSettings.MinimumHandToHandBlockValue = Config.DamageMultBlockedHandToHand
  132.  
  133. end
  134.  
  135.  
  136. if Config.NoFatigueDamageOnTimedBlock == true then
  137. VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = 0.0
  138. VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = 0.0
  139. VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = 0.0
  140. VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = 0.0
  141. end
  142.  
  143. if Config.ModdedFatigueDamageOnTimedBlock == true then
  144. VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = Config.DefaultNoviceBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
  145. VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = Config.DefaultJourneymanBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
  146. VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = Config.DefaultExpertBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
  147. VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = Config.DefaultMasterBlockPerkFatigueDamageMod * Config.ModdedFatigueDamageFactor
  148. end
  149.  
  150. end
  151.  
  152.  
  153.  
  154. local function restoreMaxBlock()
  155.  
  156. --print("ReSetMaxBlock")
  157. if not VOblivionInitialSettings or not VOblivionInitialSettings:IsValid() then
  158. return
  159. end
  160. if Config.NoHealthDamageOnTimedBlock == true then
  161. VOblivionInitialSettings.MinimumShieldBlockValue = Config.DefaultDamageMultBlockedShield
  162. VOblivionInitialSettings.MinimumWeaponBlockValue = Config.DefaultDamageMultBlockedWeapon
  163. VOblivionInitialSettings.MinimumHandToHandBlockValue = Config.DefaultDamageMultBlockedHandToHand
  164.  
  165. end
  166.  
  167. if Config.NoFatigueDamageOnTimedBlock == true then
  168. VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = Config.DefaultNoviceBlockPerkFatigueDamageMod
  169. VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = Config.DefaultJourneymanBlockPerkFatigueDamageMod
  170. VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = Config.DefaultExpertBlockPerkFatigueDamageMod
  171. VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = Config.DefaultMasterBlockPerkFatigueDamageMod
  172. end
  173.  
  174. if Config.ModdedFatigueDamageOnTimedBlock == true then
  175. VOblivionInitialSettings.NoviceBlockPerkFatigueDamageMod = Config.DefaultNoviceBlockPerkFatigueDamageMod
  176. VOblivionInitialSettings.JourneymanBlockPerkFatigueDamageMod = Config.DefaultJourneymanBlockPerkFatigueDamageMod
  177. VOblivionInitialSettings.ExpertBlockPerkFatigueDamageMod = Config.DefaultExpertBlockPerkFatigueDamageMod
  178. VOblivionInitialSettings.MasterBlockPerkFatigueDamageMod = Config.DefaultMasterBlockPerkFatigueDamageMod
  179. end
  180.  
  181. --VOblivionInitialSettings.CombatHitConeAngle = 20.0
  182.  
  183. end
  184.  
  185. local function ReturnSlomoSpeed()
  186. local succ = false
  187.  
  188. if playerController:IsValid() then
  189. --print(string.format("playerController %s", playerController:GetFullName()))
  190.  
  191. if worldSettings:IsValid() then
  192.  
  193. worldSettings.TimeDilation = 1.0
  194. if worldSettings.TimeDilation == 1.0 then
  195. isInSlomo = false
  196. succ = true
  197. --TimeDilation = worldSettings.TimeDilation
  198. end
  199. end
  200. end
  201. return succ
  202. end
  203.  
  204.  
  205.  
  206.  
  207. local function sendStagger()
  208. -- blivionPlayerCharacter_C_2147482298.CharacterMesh0.TABP_BlockShield_C_2147472083
  209. -- ObjectProperty /Script/Altar.VMeleeAttackComboAnimInstance:CurrentAttackAnimSequence
  210. -- TABP_MeleeAttack_MediumCombo_C /Game/Maps/World/L_Tamriel.L_Tamriel:PersistentLevel.BP_OblivionPlayerCharacter_C_2147482298.CharacterMesh0.TABP_MeleeAttack_MediumCombo_C_2147472753
  211. --VCharacterStatePairingComponent /Game/Maps/World/L_Tamriel.L_Tamriel:PersistentLevel.BP_OblivionPlayerCharacter_C_2147482298.Oblivion Actor State Pairing Component
  212. --ObjectProperty /Script/Altar.VPairedPawn:OblivionActorStatePairingComponent
  213.  
  214. local attacker = playerController.pawn.OblivionActorStatePairingComponent.LatestHitTaken.Attacker
  215. --print(string.format("OblivionActorStatePairingComponent %s", playerController.pawn.OblivionActorStatePairingComponent:GetFullName()))
  216.  
  217. --print(string.format("attacker %s", attacker:GetFullName()))
  218. --print(string.format("attacker.pawn %s", attacker.pawn:GetFullName()))
  219. --print(string.format("attacker.OblivionActorStatePairingComponent %s", attacker.OblivionActorStatePairingComponent:GetFullName()))
  220.  
  221. ExecuteInGameThread(function()
  222. --attacker:CancelAnimatedAction()
  223. --attacker:SendStagger()
  224. end)
  225. --TABP_HitReact_C /Game/Maps/World/L_Tamriel.L_Tamriel:PersistentLevel.BP_OblivionPlayerCharacter_C_2147482298.First Person Skeletal Mesh.TABP_HitReact_C_2147475189
  226.  
  227. --print(" S T A G G E R ")
  228. --attacker.pawn:AddGameplayTag({TagName=FName("Actor.Action.Combat.Dodge")})
  229.  
  230. end
  231.  
  232.  
  233. local function SlomoLerp(aLerpMult)
  234. if playerController:IsValid() then
  235. --print(string.format("playerController %s", playerController:GetFullName()))
  236. if worldSettings:IsValid() then
  237. worldSettings.TimeDilation = lerp(1.0, Config.slowSpeed , aLerpMult)
  238. --print(string.format("TimeDilation %.2f", worldSettings.TimeDilation))
  239.  
  240. if worldSettings.TimeDilation ~= 1.0 then
  241. isInSlomo = true
  242. --TimeDilation = worldSettings.TimeDilation
  243. end
  244. end
  245. end
  246. end
  247.  
  248.  
  249. local function ScheduleForReset()
  250. LoopAsync(1, function()
  251. --print("timed inslomo")
  252.  
  253.  
  254. local difference = getCurrentTime() - TimeSinceSlowSpeed
  255. if Config.RevertSlowMoSmooth == true then
  256.  
  257. local aLrp = 1.0 - ((math.min(difference, Config.SlowDuration) / Config.SlowDuration) ^ Config.SlowMoSmoothEasingPow)
  258. --print(string.format("difference %s", difference))
  259. --print(string.format("aLrp %s", aLrp))
  260. if isInSlomo == true and aLrp < 1.0 and aLrp > 0.0 then
  261. SlomoLerp(aLrp)
  262. return false
  263. end
  264.  
  265. end
  266.  
  267.  
  268.  
  269. if isInSlomo == true and difference > Config.SlowDuration then
  270. restoreMaxBlock()
  271. ReturnSlomoSpeed()
  272. end
  273.  
  274.  
  275.  
  276. if isInSlomo == true then
  277. return false
  278. end
  279. --print("done")
  280. return true
  281.  
  282.  
  283. end)
  284. end
  285.  
  286. local function SlomoSpeed(aLerpMult)
  287.  
  288. if playerController:IsValid() then
  289. if worldSettings:IsValid() then
  290. worldSettings.TimeDilation = Config.slowSpeed * aLerpMult
  291. if worldSettings.TimeDilation ~= 1.0 then
  292. isInSlomo = true
  293. TimeSinceSlowSpeed = getCurrentTime()
  294. ScheduleForReset()
  295.  
  296. end
  297. end
  298. end
  299. end
  300.  
  301.  
  302. local function Hook()
  303. print("hooked timeblocked")
  304. RegisterHook("/Script/Altar.VEnhancedAltarPlayerController:BlockInput_Pressed", function(Context)
  305. if isBlockPressed == false then
  306. --SetCameraSettings()
  307. --PlayHitEffect()
  308. isBlockPressed = true
  309. if getCurrentTime() - coolDownTimeStamp > Config.CoolDownBeforeNextAttempt then
  310. inTimedBlock = true
  311. setMaxBlock()
  312. blockTimeStamp = getCurrentTime()
  313. --print(string.format("playerController %s", playerController:GetFullName()))
  314. end
  315. end
  316.  
  317. local difference = getCurrentTime() - blockTimeStamp
  318.  
  319. if difference >= blockWindow and inTimedBlock == true then
  320. inTimedBlock = false
  321. restoreMaxBlock()
  322. --print(string.format("difference is bigger than TimedWindow %s", difference))
  323. end
  324.  
  325.  
  326. end)
  327.  
  328.  
  329. RegisterHook("/Script/Altar.VEnhancedAltarPlayerController:BlockInput_Released", function(Context)
  330. coolDownTimeStamp = getCurrentTime()
  331. isBlockPressed = false
  332. inTimedBlock = false
  333. restoreMaxBlock()
  334. -- print("block released")
  335.  
  336. end)
  337.  
  338. RegisterHook("/Script/Altar.VPairedPawn:OnCombatHitDealt", function(Context, HitEvent)
  339.  
  340. world = playerController:GetLevel().WorldSettings -- possible to change, requires rescan, might be replaced by an event, on level change?
  341.  
  342. if HitEvent then
  343. local hEvent = HitEvent:get()
  344. if hEvent:IsValid() then
  345. local attacker = hEvent.Attacker
  346. local target = hEvent.Target
  347. local blockHit = hEvent.bDoesTargetBlockHit
  348. if attacker:IsValid() then
  349. if playerController.pawn:GetFullName() == target:GetFullName() and blockHit == true then
  350. --print("PLAYER HAS BLOCKED")
  351. worldSettings = playerController:GetLevel().worldSettings
  352.  
  353. if inTimedBlock == true then
  354. --print("SendBlockHit")
  355. hasBlocked = true
  356. if isBlockPressed == true and getCurrentTime() - blockTimeStamp < blockWindow then
  357. hasBlocked = false
  358. --sendStagger() allows enemy to perform invisible hits DISABLED
  359. if Config.PlaySoundQueue == true then
  360. PlayTimedBlockSound()
  361. end
  362.  
  363.  
  364. setMaxBlock()
  365. -- TimeSinceSlowSpeed = getCurrentTime()
  366. SlomoSpeed(1.0)
  367. end
  368. end
  369. end
  370. end
  371. end
  372. end
  373. end)
  374.  
  375.  
  376. RegisterHook("/Game/Dev/Controllers/BP_AltarPlayerController.BP_AltarPlayerController_C:InpActEvt_AnyKey_K2Node_InputKeyEvent_1", function(Context, Key)
  377. if Key:get().KeyName:ToString() == Config.ReloadKey then
  378. --print("relaoding ini")
  379. Config = ConfigHelper.GetConfig(Mod, ConfigName)
  380. SetBlockWindow()
  381. end
  382. end)
  383. print("hook success!")
  384. end
  385.  
  386. LoopAsync(100, function()
  387.  
  388.  
  389. playerController = UEHelpers.GetPlayerController()
  390. VOblivionInitialSettings = StaticFindObject('/Script/UE5AltarPairing.Default__VOblivionInitialSettings')
  391.  
  392. if playerController:IsValid() then
  393. if playerController:GetLevel():IsValid() then
  394. worldSettings = playerController:GetLevel().worldSettings
  395. end
  396. end
  397.  
  398.  
  399. if not playerController:IsValid() or not VOblivionInitialSettings:IsValid() or not worldSettings:IsValid() then
  400. return false
  401. end
  402.  
  403. local inputC = StaticFindObject('/Game/Dev/Controllers/BP_AltarPlayerController.BP_AltarPlayerController_C:InpActEvt_AnyKey_K2Node_InputKeyEvent_1')
  404.  
  405. if inputC:IsValid() and inputC then
  406. print("Hooking . . .")
  407. Config = ConfigHelper.GetConfig(Mod, ConfigName)
  408. SetBlockWindow()
  409. Hook()
  410. else
  411. return false
  412. end
  413.  
  414.  
  415. return true
  416. end)
  417.  
  418.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement