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 


How to handle slowing down time with speedhack?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Kahenraz
Newbie cheater
Reputation: 0

Joined: 29 Jun 2015
Posts: 16

PostPosted: Tue Oct 22, 2019 2:13 am    Post subject: How to handle slowing down time with speedhack? Reply with quote

I've re-implemented CheatEngine's hook of GetTickCount() and QueryPerformanceCounter() to adjust game speed like this:

Code:
tick=((currentRealTickCount-lastRealTick)*speedFactor+lastFakeTick)


This allows me to adjust the returned tick count by the change in the actual tick count which I then multiply by an adjustable factor.

This works fine for positive speed adjustments but when I try to slow the game down by adjusting the speed by say "0.5", then the game just freezes as if time isn't moving; until I adjust it back to at least "1" for normal time.

I don't see anything wrong with my approach and I can verify with little test programs that time is adjusting (slowing down) at the appropriate rate. But it doesn't seem to work in-game. In this case, it's FF7.

If I use CheatEngine's built-in speedhack then adjusting the speed by a factor of 0.5 does in fact slow the game down as expected. So it seems like a problem with my implementation.

Why might this be failing for me? Why does the game hang with my approach?

Note that in FF7, game speed seems to be controlled by QueryPerformanceCounter() exclusively, if that helps.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25284
Location: The netherlands

PostPosted: Tue Oct 22, 2019 3:33 am    Post subject: Reply with quote

Do you update lastFakeTick at the time that you change speed ? And do you get it before or after you have changed speedfactor? (if after that's why)


Also, what is your QueryPerformanceCounter() hook?
Do you take care that is is a 64-bit value?

You have to use separate variables for gettickcount and QueryPerformanceCounter

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Kahenraz
Newbie cheater
Reputation: 0

Joined: 29 Jun 2015
Posts: 16

PostPosted: Tue Oct 22, 2019 4:13 am    Post subject: Reply with quote

All of the above; yes.

Dark Byte wrote:
Also, what is your QueryPerformanceCounter() hook


It hooks Kernel32.dll QueryPerformanceCounter(). I call the original function to get the current tick and adjust my fake tick by an offset at each call.

The logic seems sound. As both currentRealTickCount and lastRealTick are sampled from the original function and (new-old) is always >= 0 then any result added to lastFakeTick will always be positive. The rate of increase is adjusted by speedFactor.

I can imagine that time can "stop" if for some reason speedFactor remains at 0 for the result of QueryPerformanceCounter(). But this isn't the case.

As I mentioned before, I ran some tests and time slows as expected with my little sample programs.

In this case I an hooking ONLY QueryPerformanceCounter() as GetTickCount() doesn't have any noticeable affect in FF7. There is no change in behavior when I hook both functions and hooking only GetTickCount() does nothing.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Tue Oct 22, 2019 3:45 pm    Post subject: Reply with quote

Try hooking timeGetTime as well and see if that has any effect.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming 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