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 


little bit of maths

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Fresco
Grandmaster Cheater
Reputation: 4

Joined: 07 Nov 2010
Posts: 600

PostPosted: Mon Mar 12, 2012 8:44 am    Post subject: little bit of maths Reply with quote

OK, so there's this double health address.
max hp val = 32 ____ db 00 00 00 00 00 00 40 40
min hp val = 32.0000076591969 ____ db 00 00 40 40 00 00 40 40

I'm trying to make a code that will show the % of health

so 100% would be 32
an 0% __ 32.0000076591969

with what algorithm i could calculate that ?
just need the maths, no assembly. thanks.

_________________
... Fresco
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

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

PostPosted: Mon Mar 12, 2012 9:07 am    Post subject: Reply with quote

again, are you sure it is stored as 32(double) and not as 3 (float/single)?

max hp val looks like 0 - 3
min hp val looks like 3 - 3

(I assume this game stores health as total damage taken and the value behind it is the max amount of damage it can take)

with my method the formula would be:
(maxdamage-damagetaken) / maxdamage * 100
(so: (3-hp) / 3 * 100)

but if you insist it is a double then
(32.0000076591969-hp)/0.0000076591969 * 100

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Fresco
Grandmaster Cheater
Reputation: 4

Joined: 07 Nov 2010
Posts: 600

PostPosted: Thu Mar 15, 2012 10:25 am    Post subject: Reply with quote

thank you
you were wright, about the address being a float, even thought i don't know why changing the next address value affects the players health ...
anyways i figured the right algorithm:

[(max_damade - min_damage) * user_%_input / 100] + min_damage

and the assembly would be:
Code:
fld dword ptr [max_damade]
fsub dword ptr [min_damage]
fmul dword ptr [user_%_input]
fdiv dword ptr [HP_100] // HP_100 = 100 (float)
fadd dword ptr [min_damage]
fstp dword ptr [pointer] // store the result into memory

_________________
... Fresco
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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