|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
canesugar42 How do I cheat? Reputation: 0
Joined: 10 Aug 2021 Posts: 1
|
Posted: Thu Aug 12, 2021 2:54 pm Post subject: [HELP] Make in game clock time available to trainer |
|
|
Hey guys, I'm trying to sus out how to make the in game clock time of a game accessible via Lua script to a trainer. Basically I want to eventually create a bunch of functions based off clock time.
What I've got so far is that there is a function that creates the h:m:s as a float for h:m...
So 8:29 would be 8.483... it's always to several more decimal places though.
The autoassembler code for the function always stays the same:
movss[rcx+78],xmm2
So I can search for that easily and then find the two time addresses by doing find out what addresses this code writes to in the code list (once I add the function to it)
So there are two addresses that this writes to, one h, and one for m. They're both floats, but one counts every second, and one only updates every minute (4 seconds in real life). The seconds aren't represented on the actual clock display, but they count up in the address behind the scenes in both floats.
There's some time formatting that goes on, and then the final result is pushed to another memory address which is, again, always different.
I can easily find all the values I need every time, but I'm having a brain fart trying to figure out how to actually get the m:s values out of cheat engine, and into a lua script that would pass the values to a trainer that would display the time, and later, a bunch of values based on the time, but for now, just the time.
If you save and reload, all the addresses become different too... and the rcx and xmm2 register & extended memory change to different register/extended memory locations too.
So yeah, all I want to do is have the time constantly displayed in the trainer whenever the game is running, having it zero out whenever the game is not running, and be able to pick up at any point no matter what the time actually is in game.
It's just kinda beyond me as to how to do this all in Lua.
To be a little more pointed, I guess I was wondering if there's something like AOBScan for functions. Like a lua function that did the same thing as Search > find assembly code. That'd make my life a lot easier, but I just can't seem to figure out how to get there.
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
|
Back to top |
|
|
Birdi Expert Cheater Reputation: 0
Joined: 08 Jun 2020 Posts: 122 Location: Migrating
|
Posted: Fri Aug 13, 2021 12:33 am Post subject: |
|
|
Code: |
time = 8.48355
minutes = math.floor(time)
seconds1 = math.fmod(time,1)
seconds2 = math.fmod(time,1)/2
seconds3 = (math.fmod(time,1)/2)*100
seconds4 = math.floor((math.fmod(time,1)/2)*100)
print("Time: "..time.."\n\nMinutes: "..minutes.."\nSeconds1: "..seconds1.."\nSeconds2: "..seconds2.."\nSeconds3: "..seconds3.."\nSeconds4: "..seconds4.."\n\nReal Time: "..minutes..":"..seconds4)
Returns:
Time: 8.48355
Minutes: 8
Seconds1: 0.48355
Seconds2: 0.241775
Seconds3: 24.1775
Seconds4: 24
Real Time: 8:24
|
Just fill in the blanks with your registers, etc. I left in each step so you could see how the decimals are converted. You really only need "seconds4" on top of the minutes.
If you're certain you can grab the value of the timer from that code, just create a symbol and store the value in that when it's run, then read memory from your symbol using Lua. Tim's suggestion will help with that.
If the opcodes are changing registers on restart, try moving up the callstack to see where it's being written from more directly.. at some point you'll find something more static.
Alternatively just use readmem and compare the opcode to figure out the registers to use.
|
|
Back to top |
|
|
|
|
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
|
|