Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Proper way to write a value from another address?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
wood5578
How do I cheat?
Reputation: 0

Joined: 13 May 2020
Posts: 2

PostPosted: Sat Oct 24, 2020 5:29 am    Post subject: Proper way to write a value from another address? Reply with quote

I'm trying to make an adjustable camera for a racing game. I have found the camera and the car's coordinates. The script reads the car's coordinates, then writes it onto the camera's coordinates.

It looks normal on a stand still, but once the car starts moving, the camera stutters. I have already NOP'd the opcodes that writes to the camera coordinates.

I tried reducing the stutters with the solutions from this thread :
forum.cheatengine.org/viewtopic.php?t=606924

Which reduces some of the stutter but still present.

Here is the lua script used, controls to adjust the camera is yet to be implemented :

Code:
globalalloc(cheaton,4)

cheaton:
dd 0

{$lua}

if syntaxcheck then return end

[ENABLE]

local node = getAddress("69EC9A50") // Get XYZ coordinates.

local calcX = readFloat(node + 0x40)
local calcY = readFloat(node + 0x48)
local calcZ = readFloat(node + 0x44)


--packwrite script by panraven
function packWrite(addr, fms, ...)
  local packed = addr and string.pack(fms,...)
  if packed then return writeBytes(addr,{packed:byte(1,-1)}) end
end

createNativeThread(function(timer)
sleep(200)
while readFloat("cheaton") == 0 do
sleep(6.65)

local node2 = getAddress("69E4BF10") // Get the car's XYZ coordinates.

local carx = readFloat(node2 + 0x00)
local cary = readFloat(node2 + 0x04)
local carz = readFloat(node2 + 0x08)

calcX = carx
calcY = cary + 12 //Offset camera height to hood
calcZ = carz

packWrite(node + 0x40, 'fff', calcX, calcY, calcZ) // Write the new values onto the camera's coordinates.

  end
  end)

[DISABLE]

{$asm}
cheaton:
dd 1


Here is the video showing how it looks, epilepsy warning btw : youtu.be/L_YIYLXWk8o


Looking for some help on this, thanks in advanced!
Back to top
View user's profile Send private message
ShaRose
Cheater
Reputation: 0

Joined: 12 Jan 2010
Posts: 26

PostPosted: Sat Oct 24, 2020 11:22 am    Post subject: Reply with quote

At a guess, it might be because the timer isn't synced to when you are rendering each frame: I'd see if you could find somewhere you can stick some instructions that run for each frame.

Maybe use the opcodes you NOPed out to set the camera position to jump somewhere and jump back?
Back to top
View user's profile Send private message
wood5578
How do I cheat?
Reputation: 0

Joined: 13 May 2020
Posts: 2

PostPosted: Sat Oct 24, 2020 11:38 pm    Post subject: Reply with quote

ShaRose wrote:
At a guess, it might be because the timer isn't synced to when you are rendering each frame: I'd see if you could find somewhere you can stick some instructions that run for each frame.

Maybe use the opcodes you NOPed out to set the camera position to jump somewhere and jump back?


Thanks for the advice! Matching the timer to the game's framerate does reduce the stutter a lot. Its still present but only when the game has a minor drop in framerate.

Oh and yeah, I forgot to mention, the game heavily relies on the framerate (60fps), as game speed is tied to it.

I will try the instructions method later
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites