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 


Q: Creating a table address based on other address.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Zaladine
Expert Cheater
Ban
Reputation: 3

Joined: 14 Oct 2012
Posts: 129
Location: Djokdja, Indonesia

PostPosted: Sat Feb 01, 2014 9:01 pm    Post subject: Q: Creating a table address based on other address. Reply with quote

I'm making a table for this specific game, which UI uses a non-digit-gauge
(a pointing arrow) for its wind bearing. I've managed to obtain this bearing
address, and turns out that it is in Radian system.

However, since some popular walk-throughs for certain calculation involving
this wind bearing is in degree, i need (want) to create a new table address
which reads my previous Radian address, convert it, and shown in degree.

According to Wiki, the formula is:
Quote:
Angle of Degrees = ( Angle of Radians * 180 ) / π

... where π (phi) = 3.1415926535897932384626433832795
... further reading: http://en.wikipedia.org/wiki/Radian

This new table address needs to be updated in real-time (once every second
is actually acceptable), as the aforementioned address is.

So, please teach me how to do this (preferably in a step-by-step manner for
beginners). Thank you very much in advance for kind replies...

_________________
... to boldly go where no eagle has gone before ...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat Feb 01, 2014 9:30 pm    Post subject: Reply with quote

Is the angle in radians stored as a float ?

If so, try this custom type (Not suitable for scanning, but usable for working with)

Just execute this script and you'll have a RadToDegree type
Code:

function RadToDegree_bytestovalue(b1,b2,b3,b4)
--Add extra byte parameters as required
  bt={}
  bt[1]=b1
  bt[2]=b2
  bt[3]=b3
  bt[4]=b4
  return (byteTableToFloat(bt)*180) / math.pi
end

function RadToDegree_valuetobytes(i)
  --return the bytes to write (usually only used when you change the value)
  bt=floatToByteTable((i * math.pi) / 180)

  return bt[1],bt[2],bt[3],bt[4]
end

registerCustomTypeLua("RadToDegree", 4, RadToDegree_bytestovalue, RadToDegree_valuetobytes)


One downside is that it currently only handles full integers

(You can also do an auto assembler script for this which CAN add support for floating points. But I don't feel like delving too deep into the floating point instruction set)

_________________
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
Zaladine
Expert Cheater
Ban
Reputation: 3

Joined: 14 Oct 2012
Posts: 129
Location: Djokdja, Indonesia

PostPosted: Sat Feb 01, 2014 10:22 pm    Post subject: Reply with quote

@ Dark Byte: Thanks for your reply...

1. Yes the Radian Angle address is a float data-type.
2. I have zero experience regards LUA scripting in CE. So, how should i do that appropriately ?

This is what i've tried, however:
- At main CE Window, i pressed Ctrl+Alt+L to bring out the Lua Script window.
- Copy your script and paste in it.
- Press 'Execute Script'
- ... then what? Was something happened? Cause i don't see any actions/changes at all.

Sorry for being dumb. I really hope that, if this is involves LUA Scripting, this would be a good start for getting used to it.


EDIT:
Have just noticed that a new data type available: "RadToDegree"...
Copied the previous address and changed the data type into the new one.
It works perfect, and will suffice for now...

Smile

_________________
... to boldly go where no eagle has gone before ...
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Feb 05, 2014 1:00 pm    Post subject: RadToDegree (Custom Type AA) Reply with quote

Custom Type Lua: Not suitable for scanning, but usable for working with.
Custom Type AA: Suitable for scanning and working with.


If you need for fast scanning (searching) - use "Custom Type AA" below:
Code:

alloc(ConvertRoutine,128)
alloc(ConvertBackRoutine,128)
alloc(TypeName,64)
alloc(ByteSize,4)
alloc(UsesFloat,1)

TypeName:
db 'RadToDeg (single-fp)',0
// single-precision floating-point value

ByteSize:
dd 4

UsesFloat:
db 1

ConvertRoutine:
[64-bit]
cvtss2sd xmm0,dword ptr[rcx]
[/64-bit]
[32-bit]
mov eax,[esp+04]
cvtss2sd xmm0,dword ptr[eax]
[/32-bit]

mov eax,#180
cvtsi2sd  xmm1,eax
mulsd xmm0,xmm1
fldpi
sub esp,8
db DD 1C 24 // fstp qword ptr [esp], fstp qword ptr [rsp]
divsd xmm0,[esp]
add esp,8
cvtsd2ss xmm0,xmm0
movd eax,xmm0

[64-bit]
ret
[/64-bit]
[32-bit]
ret 0004
[/32-bit]

ConvertBackRoutine:
[64-bit]
movd xmm0,ecx
[/64-bit]
[32-bit]
push ecx
mov ecx,[esp+08]
movd xmm0,ecx
[/32-bit]

cvtss2sd xmm0,xmm0
mov ecx,#180
cvtsi2sd  xmm1,ecx
divsd xmm0,xmm1
fldpi
sub esp,8
db DD 1C 24 // fstp qword ptr [esp], fstp qword ptr [rsp]
mulsd xmm0,[esp]
add esp,8
cvtsd2ss xmm0,xmm0

[64-bit]
movd [rdx],xmm0
ret
[/64-bit]
[32-bit]
mov ecx,[esp+0C]
movd [ecx],xmm0
pop ecx
ret 0008
[/32-bit]



Choose define new custom type AA, remove all auto-generated code, and paste the above code.




@Dark Byte, because of bug (reported here id=309):

I have to use "db DD 1C 24"



keywords (for easy "google searching"):
radians degrees pi Custom Type AA xmm0 xmm1 SSE



customType.png
 Description:
 Filesize:  8.7 KB
 Viewed:  4156 Time(s)

customType.png



_________________
Back to top
View user's profile Send private message MSN Messenger
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