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 


Interpreting/converting double float used in-game as a %

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

Joined: 12 Dec 2022
Posts: 3

PostPosted: Mon Dec 12, 2022 6:25 am    Post subject: Interpreting/converting double float used in-game as a % Reply with quote

Currently playing a single player, non-online game where there is a weapon proficiency meter. In-game this is represented as a a percentage with 2 decimal places (e.g 1.27%).

I have found the address that controls this proficiency using cheat engine but it's stored as a double floating point value and I cannot figure out how the game takes this value and converts it into the percentage shown.

I know that:
1.8514715696817E-312 = 2.95%
1.85147160206277E-312 = 3.00%

Is there any way to figure this out? (apologies if this is a stupid question, I am a novice in this area)

Edit: I should probably mention that obviously the goal is to change the value and instantly make the proficiency 100% (or close to it)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Mon Dec 12, 2022 12:33 pm    Post subject: Reply with quote

Change the value type from double to float and see if that helps.

If it still isn't obvious, right click the memory record and select "Find out what instructions access this address". Post the instructions that come up

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
whatizlove
How do I cheat?
Reputation: 0

Joined: 12 Dec 2022
Posts: 3

PostPosted: Mon Dec 12, 2022 1:56 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Change the value type from double to float and see if that helps.

If it still isn't obvious, right click the memory record and select "Find out what instructions access this address". Post the instructions that come up


Ok, so converting to float shows this:

Double: 2.12733224481571E-312
In-game Proficiency: 15.82%
Float: 3.518359184

I'm not sure if I did the next part right:

FFFFF8004C80E64F - 4C 8B 1A - mov r11,[rdx]
FFFFF8004C80E652 - 4A 8B 54 02 F8 - mov rdx,[rdx+r8-08]
FFFFF8004C80E6A3 - 44 8A 5C 11 FF - mov r11l,[rcx+rdx-01]
7FF7C9F26BE8 - 39 41 18 - cmp [rcx+18],eax
7FF7C9F26B96 - 41 39 44 93 18 - cmp [r11+rdx*4+18],eax
7FF7C9F26AC1 - 42 39 44 81 18 - cmp [rcx+r8*4+18],eax
7FF7C9F268D7 - 43 FF 44 81 18 - inc [r9+r8*4+18]
7FF7C9F268EC - 43 8B 44 81 18 - mov eax,[r9+r8*4+18]
7FF7C9F268F6 - 43 89 44 81 18 - mov [r9+r8*4+18],eax
7FF7C9F26C75 - 8B 53 18 - mov edx,[rbx+18]

The 3 relevant ones seem to be:
7FF7C9F268D7 - 43 FF 44 81 18 - inc [r9+r8*4+18]
7FF7C9F268EC - 43 8B 44 81 18 - mov eax,[r9+r8*4+18]
7FF7C9F268F6 - 43 89 44 81 18 - mov [r9+r8*4+18],eax

They each only accessed 4 times, once for each time the proficiency increased.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Tue Dec 13, 2022 3:30 am    Post subject: Reply with quote

It's not a floating point value. It looks like some integer.

Change it to a 4-byte value and see if you can make some sense of it. e.g. maybe the minimum proficiency is 0, the maximum proficiency is some large 4-byte integer, and the game only ever displays this info as a percentage of `current / max` proficiency.

It's an odd coincidence the last 3 hex digits are the same in all 3 values you've posted so far (when interpreted as 4-byte int). Maybe it's some weird fixed-point arithmetic value? I may look into this later...

If you have nothing else to go on, maybe the code around those 3 relevant instructions has some more information. If you don't know how to read assembly, post a hundred or so instructions around that area (those 3 instructions are all near each other).

PS: does changing that value also change the weapon's proficiency? If not, ignore all of this- it's not the right value

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
whatizlove
How do I cheat?
Reputation: 0

Joined: 12 Dec 2022
Posts: 3

PostPosted: Tue Dec 13, 2022 6:32 am    Post subject: Reply with quote

ParkourPenguin wrote:


PS: does changing that value also change the weapon's proficiency? If not, ignore all of this- it's not the right value


I'll be able to check out the other stuff a little later but I can answer this right now.

Changing the value does change the proficiency but because it is such an insane value that I cannot make sense of, any change to it often results in very weird changes to the proficiency. Changing just the first digit before the decimal place from 1 to 2 and nothing else resulted in a proficiency in-game of something like "-46777.77%".

Changing the value at random is like a hope and pray at this point, I've yet to get anything actually usable from manually changing the value. It seems the value, which is shown in cheat engine as a "Double", needs to be VERY specific for the game to interpret it correctly. Using one of the older values, like the ones I've posted in the thread before now, does work fine but obviously that means I can only reduce the proficiency with any kind of accuracy.

It's really strange because almost everything else in this game is so simple, in terms of finding and changing the values in Cheat Engine anyway. Money, health, etc are all simple values with regular integers. Even limited-time mechanics like the kill meter for this 1 specific area in the game is stored as the exact simple value that's displayed in-game.

But just finding this weapon proficiency value was a mission in-and-of-itself, and I've not yet been able to find anything else that relates to it. It's very odd.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Tue Dec 13, 2022 3:08 pm    Post subject: Reply with quote

whatizlove wrote:
It seems the value, which is shown in cheat engine as a "Double", needs to be VERY specific for the game to interpret it correctly.
The game is not treating it as a double. You should stop treating it as a double.
All values are just sequences of bytes. You're free to interpret this sequence of bytes however you want. In this case, the game is treating these particular bytes as a 4-byte value. You should follow what the game is doing and treat it as such.

Having the second highest bit set makes me think this might be some weird floating point value. If so, the mantissa could be 17 bits and the exponent 14 bits, but I've never heard of such a value type before.

Could you provide more examples while you're at it? Something like this:
Code:
4-byte hex = proficiency%
405D6666 = 2.95%
405D8000 = 3.00%
40612CCC = 15.82%
...

In addition to recording valid proficiency values, setting these custom values and recording the proficiency might be interesting:
Code:
C05D8000 =
405DC000 =
405DE000 =
405DF000 =
405C8000 =
405E8000 =
405F8000 =
40608000 =


Maybe also try subtracting 4 from the address (e.g. 027C451C - 4 = 027C4518) and setting the type as double. I don't think this will help as there should've been some SSE or x87 instructions accessing the value.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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 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