awakenmymasters How do I cheat?
Reputation: 0
Joined: 30 Mar 2020 Posts: 1
|
Posted: Mon Mar 30, 2020 7:34 pm Post subject: editing camera values using lua script |
|
|
Hi, I have a issue with my code which when the script is activated it moves the camera in the game but very stop and start rather than a smooth value change.
so I need the camera to pan across smoothy via a value change over time rather than a constant adding of numbers every interveral.
my explanation is pretty poor with me doing my best to explain using my limited knowledge, any help is appreciated thank you.
DoneState = false
local addr1 = 0x7133EAF0
local val = 10
local function timer_tick(timer)
local v = readFloat(addr1)
if v < 100 then
writeFloat(addr1, val + v)
else
DoneState = true
end
if DoneState == true then
timer.destroy()
end
end
if syntaxcheck then return end
local someTimer = createTimer(MainForm)
someTimer.Interval = 10
someTimer.OnTimer = timer_tick
|
|
mg_01 Cheater
Reputation: 0
Joined: 28 Jan 2018 Posts: 41
|
Posted: Thu Apr 02, 2020 12:19 pm Post subject: |
|
|
hi. i recently figured out how to do just this using linear interpolation and a whileloop.
it's a really long script, but you need a few things (the way I did it anyway):
The pointers/addresses that are going to change. A linear interpolation function to process the variables, and a while-do loop to do it.
It's a lot to explain, but take a look at the script first:
Code: | -- Initial Variables
fovPointer = ("[pcsx2.exe+026983F4]+FAC") -- FOV pointer
xPosPointer = ("[pcsx2.exe+026983F4]+F4C") -- X_POS pointer
xRotPointer = ("[pcsx2.exe+026983F4]+F94") -- X_ROT pointer
yPosPointer = ("[pcsx2.exe+026983F4]+F50") -- Y_POS pointer
yRotPointer = ("[pcsx2.exe+026983F4]+F98") -- Y_ROT pointer
yNOPPointer = ("[pcsx2.exe+026983F4]+FF0") -- Y NOP pointer
zNOPPointer = ("[pcsx2.exe+026983F4]+FF4") -- Z_NOP pointer
fovCurr = readFloat(fovPointer) -- readFloat for FOV
xPosCurr = readFloat(xPosPointer) -- readFloat for X_POS
xRotCurr = readFloat(xRotPointer) -- readFloat for X_ROT
yPosCurr = readFloat(yPosPointer) -- readFloat for Y_POS
yRotCurr = readFloat(yRotPointer) -- readFloat for Y_ROT
yNOPCurr = readFloat(yNOPPointer) -- readFloat for Y_NOP
zNOPCurr = readFloat(zNOPPointer) -- readFloat for Z_NOP
currentTime = 0 -- end when time = 1
contScript = true -- used to break with VK_HOME
-- Functions
function lerp(v0, v1, t) -- Linear Interpolation Function
return (1 - t) * v0 + t * v1
end
function readTF() -- Get Total Frames value
tfPointer = ("pcsx2.exe+271A324") -- Total Frames Pointer
readITF = readInteger(tfPointer) -- Read Total Frames Integer value
return(readITF)
end
-- End Points
fovEnd = 43 -- 43 is default Field of View value
xPosEnd = 0 -- 1280 & 1280 are default X-limits
xRotEnd = 0 -- 1280 & 1280 are default X-limits
yPosEnd = 340 -- 95 is ground, 900 is max
yRotEnd = 340 -- 95 is ground, 900 is max
yNOPEnd = 400 -- for both; need to NOP Y-min/max addresses
zNOPEnd = 1790 -- for both Z_Scale & Z_POS
timeSpeed = (1/50) -- Steps until current time is equal to 1
-- Main Script -- comment unused dimensions
oldFrame = readTF() -- gets Total Frames value for the checks
while currentTime < 1.0 and contScript do -- Unwritten axes will be commented-out.
--writeFloat(xPosPointer, lerp(xPosCurr, xPosEnd, currentTime))
--writeFloat(xRotPointer, lerp(xRotCurr, xRotEnd, currentTime))
writeFloat(yPosPointer, lerp(yPosCurr, yPosEnd, currentTime))
writeFloat(yRotPointer, lerp(yRotCurr, yRotEnd, currentTime))
writeFloat(yNOPPointer, lerp(yNOPCurr, yNOPEnd, currentTime))
writeFloat(zNOPPointer, lerp(zNOPCurr, zNOPEnd, currentTime))
writeFloat(fovPointer, lerp(fovCurr, fovEnd, currentTime))
currentTime = currentTime + timeSpeed -- break loop by pressing HOME key
if isKeyPressed(VK_HOME) then
contScript = false
break
end
currentFrame = readTF() -- gets current total-frame value.
while currentFrame == oldFrame do
if isKeyPressed(VK_HOME) then -- break loop by pressing HOME key
contScript = false
break
end
currentFrame = readTF()
end
oldFrame = currentFrame -- updates frame counter to new number
end
-- Write the end-values to fix the float point imprecision
writeFloat(fovPointer, fovEnd)
--writeFloat(xPosPointer, xPosEnd)
--writeFloat(xRotPointer, xRotEnd)
writeFloat(yPosPointer, yPosEnd)
writeFloat(yRotPointer, yRotEnd)
writeFloat(yNOPPointer, yNOPEnd)
writeFloat(zNOPPointer, zNOPEnd) |
|
|