Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define the AOB pattern and memory range
- 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"
- local startAddress = 0x000000000
- local endAddress = 0x200000000
- -- Function to perform the AOB scan and get the camera addresses
- function getCameraAddresses()
- print("Starting AOB scan...")
- local startTime = os.clock()
- local ms = createMemScan()
- ms.firstScan(soExactValue, vtByteArray, rtRounded, aobPatternY, "", startAddress, endAddress, "", fsmAligned, "4", true, false, false, false)
- ms.waitTillDone()
- local fl = createFoundList(ms)
- fl.initialize()
- local addresses = {}
- for i = 0, fl.Count - 1 do
- local address = fl.Address[i]
- local numericAddress = tonumber(address, 16)
- table.insert(addresses, numericAddress)
- end
- fl.destroy()
- ms.destroy()
- print(string.format("Scan complete. Found %d addresses.", #addresses))
- print(string.format("Total time: %.2f seconds", os.clock() - startTime))
- return addresses
- end
- -- Function to validate the camera addresses
- function validateCameraAddresses(addresses)
- for _, address in ipairs(addresses) do
- local cameraYAddress = address
- local cameraXAddress = cameraYAddress - 0xC
- local cameraY = readFloat(cameraYAddress)
- local cameraX = readFloat(cameraXAddress)
- if cameraY and cameraX then
- return cameraXAddress, cameraYAddress
- end
- end
- return nil, nil
- end
- -- Function to get the mouse's horizontal position
- function getMouseX()
- local x, y = getMousePos()
- return x
- end
- -- Function to get the mouse's vertical position
- function getMouseY()
- local x, y = getMousePos()
- return y
- end
- -- Function to set the mouse position to the center of the screen
- function centerMouse()
- local screenWidth = getScreenWidth()
- local screenHeight = getScreenHeight()
- setMousePos(screenWidth / 2, screenHeight / 2)
- end
- -- Function to update the camera's x value based on mouse movement
- function updateCameraX(cameraXAddress)
- local screenWidth = getScreenWidth()
- local centerX = screenWidth / 2
- local mouseX = getMouseX()
- local deltaX = mouseX - centerX
- if deltaX ~= 0 then
- local cameraX = readFloat(cameraXAddress)
- if cameraX == nil then
- print(string.format("Error: Unable to read cameraX value at address %X.", cameraXAddress))
- return
- end
- -- Update cameraX based on deltaX movement (adjusted sensitivity)
- cameraX = cameraX + (deltaX * 0.005) -- Inverted and slightly reduced sensitivity
- -- Ensure cameraX wraps around within -π to π using modulo operation
- cameraX = (cameraX + math.pi) % (2 * math.pi) - math.pi
- -- Write the updated value back to the address
- writeFloat(cameraXAddress, cameraX)
- end
- end
- -- Function to update the camera's y value based on mouse movement
- function updateCameraY(cameraYAddress)
- local screenHeight = getScreenHeight()
- local centerY = screenHeight / 2
- local mouseY = getMouseY()
- local deltaY = mouseY - centerY
- if deltaY ~= 0 then
- local cameraY = readFloat(cameraYAddress)
- if cameraY == nil then
- print(string.format("Error: Unable to read cameraY value at address %X.", cameraYAddress))
- return
- end
- -- Update cameraY based on deltaY movement (adjusted sensitivity)
- cameraY = cameraY + (deltaY * 0.005) -- Inverted and slightly reduced sensitivity
- -- Clamp cameraY to the min and max values
- cameraY = math.max(-0.6981316805, math.min(1.221730471, cameraY))
- -- Write the updated value back to the address
- writeFloat(cameraYAddress, cameraY)
- end
- end
- -- Function to update both camera x and y values
- function updateCamera(cameraXAddress, cameraYAddress)
- updateCameraX(cameraXAddress)
- updateCameraY(cameraYAddress)
- centerMouse()
- end
- -- Function to NOP the specific instruction
- function nopInstruction()
- 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"
- autoAssemble([[
- aobscan(INJECT, ]] .. aobPattern .. [[)
- label(code)
- registersymbol(INJECT)
- INJECT:
- db 90 90 90 90 90 90 90 90 90
- code:
- ]])
- print("Instruction NOPed")
- end
- -- Main function to perform the AOB scan and update the camera
- function main()
- nopInstruction()
- local addresses = getCameraAddresses()
- local cameraXAddress, cameraYAddress = validateCameraAddresses(addresses)
- if cameraXAddress and cameraYAddress then
- print(string.format("Camera Y Address: %X", cameraYAddress))
- print(string.format("Camera X Address: %X", cameraXAddress))
- -- Set a timer to continuously update the camera's x and y values
- timer = createTimer(nil, false)
- timer.Interval = 6.94 -- Update approximately every 6.94 milliseconds for 144Hz
- timer.OnTimer = function() updateCamera(cameraXAddress, cameraYAddress) end
- timer.Enabled = false -- Start with the timer toggled off
- -- Function to toggle the timer
- function toggleTimer()
- timer.Enabled = not timer.Enabled
- print("Timer Enabled: " .. tostring(timer.Enabled))
- end
- -- Create a hotkey to toggle the timer (F10 key)
- createHotkey(toggleTimer, VK_F10)
- else
- print("No valid addresses found.")
- end
- end
- -- Run the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement