Advertisement
em00se

Untitled

Apr 1st, 2024
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. -- DragonsDogma 2 DisableMouseAcceleration script by emoose
  2. -- https://www.nexusmods.com/dragonsdogma2/mods/342
  3.  
  4. local app_WorkRate_getRateDeltaTime = sdk.find_type_definition("app.WorkRate"):get_method("getRateDeltaTime")
  5.  
  6. local app_CameraManager = sdk.get_managed_singleton("app.CameraManager")
  7.  
  8. local yaw_speed_rate = 0
  9. local pitch_speed_rate = 0
  10. local IsMouseMovedInFrame = nil
  11. local getInputAxisR = nil
  12.  
  13. local input_speed_base = 0
  14. local cam_controller = nil
  15.  
  16. sdk.hook(
  17. sdk.find_type_definition("app.RotateCameraControllerBase"):get_method("getInputRotationSpeedRate"),
  18. function(args)
  19. cam_controller = sdk.to_managed_object(args[2])
  20.  
  21. yaw_speed_rate = app_CameraManager:getYawSpeedRate(cam_controller)
  22. pitch_speed_rate = app_CameraManager:getPitchSpeedRate(cam_controller)
  23.  
  24. getInputAxisR = cam_controller:getInputAxisR()
  25. IsMouseMovedInFrame = cam_controller:get_IsMouseMovedInFrame()
  26.  
  27. input_speed_base = sdk.to_float(args[3])
  28. return sdk.PreHookResult.SKIP_ORIGINAL
  29. end,
  30. function(retval)
  31. return sdk.float_to_ptr(input_speed_base / (cam_controller:get_ElapsedSecond() * 100))
  32. end
  33. )
  34.  
  35. sdk.hook(
  36. sdk.find_type_definition("app.RotateCameraControllerBase"):get_method("updateRotationDampingParam"),
  37. function(args)
  38. args[3] = sdk.float_to_ptr(0)
  39. args[4] = sdk.float_to_ptr(0)
  40. return sdk.PreHookResult.CALL_ORIGINAL
  41. end,
  42. function(retval)
  43. return retval
  44. end
  45. )
  46.  
  47. -- Make sure IsMouseInputSpeedAccel always returns false
  48. sdk.hook(
  49. sdk.find_type_definition("app.RotateCameraControllerBase"):get_method("get_IsMouseInputSpeedAccel"),
  50. function(args)
  51. return sdk.PreHookResult.SKIP_ORIGINAL
  52. end,
  53. function(retval)
  54. return sdk.to_ptr(false)
  55. end
  56. )
  57.  
  58. re.on_draw_ui(function()
  59. if imgui.tree_node("MouseAccelDebug") then
  60. if cam_controller then
  61.  
  62. imgui.text(" ")
  63. imgui.text("input_speed_base = " .. tostring(input_speed_base))
  64. imgui.text("yaw_speed_rate = " .. tostring(yaw_speed_rate))
  65. imgui.text("pitch_speed_rate = " .. tostring(pitch_speed_rate))
  66. imgui.text("IsMouseMovedInFrame = " .. tostring(IsMouseMovedInFrame))
  67. imgui.text("InputAxisR.x = " .. tostring(getInputAxisR.x))
  68. imgui.text("InputAxisR.y = " .. tostring(getInputAxisR.y))
  69.  
  70. local useOptionnal = cam_controller["<UseOptionnalSpeedRate>k__BackingField"]
  71. local yawInputRate = cam_controller["<YawInputRate>k__BackingField"]
  72. local pitchInputRate = cam_controller["<PitchInputRate>k__BackingField"]
  73. local angle = cam_controller["_Angle"]
  74. local rotationSettings = cam_controller._RotationCameraSettings
  75. imgui.text("UseOptionnalSpeedRate: " .. tostring(useOptionnal))
  76. imgui.text("YawInputRate: " .. tostring(yawInputRate))
  77. imgui.text("PitchInputRate: " .. tostring(pitchInputRate))
  78. imgui.text("Angle.X: " .. tostring(angle.x))
  79. imgui.text("Angle.Y: " .. tostring(angle.y))
  80. imgui.text("Angle.Z: " .. tostring(angle.Z))
  81. imgui.text("rotationSettings._YawRotationSpeed " .. tostring(rotationSettings._YawRotationSpeed))
  82. imgui.text("rotationSettings._PitchRotationSpeed " .. tostring(rotationSettings._PitchRotationSpeed))
  83. imgui.text("rotationSettings._MouseInputYawRotationSpeedRate " .. tostring(rotationSettings._MouseInputYawRotationSpeedRate))
  84. imgui.text("rotationSettings._MouseInputPitchRotationSpeedRate " .. tostring(rotationSettings._MouseInputPitchRotationSpeedRate))
  85. imgui.text("rotationSettings._EnableMouseInputSpeedAccel " .. tostring(rotationSettings._EnableMouseInputSpeedAccel))
  86. imgui.text("rotationSettings._MouseMoveSpeedMax " .. tostring(rotationSettings._MouseMoveSpeedMax))
  87. end
  88. imgui.tree_pop()
  89. end
  90. end)
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement