Advertisement
Guest User

Bloodborne WIP Mouse Injection LUA Script for CE7.4

a guest
Sep 8th, 2024
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.15 KB | None | 0 0
  1. -- Define the AOB pattern and memory range
  2. local aobPatternY = "?? ?? ?? ?? 00 00 00 00 00 00 00 00 00 ?? ?? ?? 00 00 00 00 8F C2 B5 3F 00 00 00 00 00 00 80 3F 9A 99 99 3E CD CC CC 3D A4 70 7D 3F 00 00 00 3F ?? ?? ?? ?? 00 00 80 40 00 00 80 40 CD CC 4C 3D CD CC CC 3D 9A 99 99 3E CD CC CC 3D CD CC CC 3D 00 00 80 3E 9A 99 99 3E 9A 99 99 3E CD CC CC 3D CD CC CC 3D 00 00 80 3E 8F C2 F5 3C C2 B8 32 3E C2 B8 B2 3E CD CC CC 3E CD CC CC 3E 9A 99 99 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 3F 00 00 00 40 00 00 80 3F 9A 99 19 3F AA 61 9C 3F C2 B8 32 BF C2 B8 32 3F C2 B8 32 BF 00 00 00 3F 00 00 00 40 92 0A ?? 40 92 0A ?? 40 C2 B8 B2 3F C2 B8 B2 3F 92 0A 86 40 92 0A 86 40 ?? ?? ?? ?? ?? ?? ?? ?? DB 0F 49 40 DB 0F 49 40 58 A0 0B 41"
  3. local startAddress = 0x000000000
  4. local endAddress = 0x200000000
  5.  
  6. -- Function to perform the AOB scan and get the camera addresses
  7. function getCameraAddresses()
  8. print("Starting AOB scan...")
  9. local startTime = os.clock()
  10. local ms = createMemScan()
  11. ms.firstScan(soExactValue, vtByteArray, rtRounded, aobPatternY, "", startAddress, endAddress, "", fsmAligned, "4", true, false, false, false)
  12. ms.waitTillDone()
  13. local fl = createFoundList(ms)
  14. fl.initialize()
  15. local addresses = {}
  16. for i = 0, fl.Count - 1 do
  17. local address = fl.Address[i]
  18. local numericAddress = tonumber(address, 16)
  19. table.insert(addresses, numericAddress)
  20. end
  21. fl.destroy()
  22. ms.destroy()
  23. print(string.format("Scan complete. Found %d addresses.", #addresses))
  24. print(string.format("Total time: %.2f seconds", os.clock() - startTime))
  25. return addresses
  26. end
  27.  
  28. -- Function to validate the camera addresses
  29. function validateCameraAddresses(addresses)
  30. for _, address in ipairs(addresses) do
  31. local cameraYAddress = address
  32. local cameraXAddress = cameraYAddress - 0xC
  33. local cameraY = readFloat(cameraYAddress)
  34. local cameraX = readFloat(cameraXAddress)
  35. if cameraY and cameraX then
  36. return cameraXAddress, cameraYAddress
  37. end
  38. end
  39. return nil, nil
  40. end
  41.  
  42. -- Function to get the mouse's horizontal position
  43. function getMouseX()
  44. local x, y = getMousePos()
  45. return x
  46. end
  47.  
  48. -- Function to get the mouse's vertical position
  49. function getMouseY()
  50. local x, y = getMousePos()
  51. return y
  52. end
  53.  
  54. -- Function to set the mouse position to the center of the screen
  55. function centerMouse()
  56. local screenWidth = getScreenWidth()
  57. local screenHeight = getScreenHeight()
  58. setMousePos(screenWidth / 2, screenHeight / 2)
  59. end
  60.  
  61. -- Function to update the camera's x value based on mouse movement
  62. function updateCameraX(cameraXAddress)
  63. local screenWidth = getScreenWidth()
  64. local centerX = screenWidth / 2
  65.  
  66. local mouseX = getMouseX()
  67. local deltaX = mouseX - centerX
  68.  
  69. if deltaX ~= 0 then
  70. local cameraX = readFloat(cameraXAddress)
  71. if cameraX == nil then
  72. print(string.format("Error: Unable to read cameraX value at address %X.", cameraXAddress))
  73. return
  74. end
  75.  
  76. -- Update cameraX based on deltaX movement (adjusted sensitivity)
  77. cameraX = cameraX + (deltaX * 0.005) -- Inverted and slightly reduced sensitivity
  78.  
  79. -- Ensure cameraX wraps around within -π to π using modulo operation
  80. cameraX = (cameraX + math.pi) % (2 * math.pi) - math.pi
  81.  
  82. -- Write the updated value back to the address
  83. writeFloat(cameraXAddress, cameraX)
  84. end
  85. end
  86.  
  87. -- Function to update the camera's y value based on mouse movement
  88. function updateCameraY(cameraYAddress)
  89. local screenHeight = getScreenHeight()
  90. local centerY = screenHeight / 2
  91.  
  92. local mouseY = getMouseY()
  93. local deltaY = mouseY - centerY
  94.  
  95. if deltaY ~= 0 then
  96. local cameraY = readFloat(cameraYAddress)
  97. if cameraY == nil then
  98. print(string.format("Error: Unable to read cameraY value at address %X.", cameraYAddress))
  99. return
  100. end
  101.  
  102. -- Update cameraY based on deltaY movement (adjusted sensitivity)
  103. cameraY = cameraY + (deltaY * 0.005) -- Inverted and slightly reduced sensitivity
  104.  
  105. -- Clamp cameraY to the min and max values
  106. cameraY = math.max(-0.6981316805, math.min(1.221730471, cameraY))
  107.  
  108. -- Write the updated value back to the address
  109. writeFloat(cameraYAddress, cameraY)
  110. end
  111. end
  112.  
  113. -- Function to update both camera x and y values
  114. function updateCamera(cameraXAddress, cameraYAddress)
  115. updateCameraX(cameraXAddress)
  116. updateCameraY(cameraYAddress)
  117. centerMouse()
  118. end
  119.  
  120. -- Function to NOP the specific instruction
  121. function nopInstruction()
  122. local aobPattern = "C4 C1 7A 11 85 44 01 00 00 4D 8D BD 63 02 00 00 41 8A 85 63 02 00 00 84 C0 C5 78 28 95 B0 FD FF FF 75 2B"
  123. autoAssemble([[
  124. aobscan(INJECT, ]] .. aobPattern .. [[)
  125. label(code)
  126. registersymbol(INJECT)
  127.  
  128. INJECT:
  129. db 90 90 90 90 90 90 90 90 90
  130.  
  131. code:
  132. ]])
  133. print("Instruction NOPed")
  134. end
  135.  
  136. -- Main function to perform the AOB scan and update the camera
  137. function main()
  138. nopInstruction()
  139. local addresses = getCameraAddresses()
  140. local cameraXAddress, cameraYAddress = validateCameraAddresses(addresses)
  141. if cameraXAddress and cameraYAddress then
  142. print(string.format("Camera Y Address: %X", cameraYAddress))
  143. print(string.format("Camera X Address: %X", cameraXAddress))
  144.  
  145. -- Set a timer to continuously update the camera's x and y values
  146. timer = createTimer(nil, false)
  147. timer.Interval = 6.94 -- Update approximately every 6.94 milliseconds for 144Hz
  148. timer.OnTimer = function() updateCamera(cameraXAddress, cameraYAddress) end
  149. timer.Enabled = false -- Start with the timer toggled off
  150.  
  151. -- Function to toggle the timer
  152. function toggleTimer()
  153. timer.Enabled = not timer.Enabled
  154. print("Timer Enabled: " .. tostring(timer.Enabled))
  155. end
  156.  
  157. -- Create a hotkey to toggle the timer (F10 key)
  158. createHotkey(toggleTimer, VK_F10)
  159. else
  160. print("No valid addresses found.")
  161. end
  162. end
  163.  
  164. -- Run the main function
  165. main()
  166.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement