 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Redouane Master Cheater
Reputation: 3
Joined: 05 Sep 2013 Posts: 363 Location: Algeria
|
Posted: Sun May 03, 2015 3:43 pm Post subject: |
|
|
| Fresco wrote: |
The above code works but it's not smooth.
It moves the player in the crosshair direction with the correct speed but it feels like it's teleporting instead of gradually flying.
The assembly version works well, very smooth, but is there a way to make the movements smooth in the Lua version ?
If you have any ideas please post.
Thank you. |
If I were you,I'd use assembly to make the 'fly' code,and Lua to detect the keypress and activate the asm code,for example,in the fly code,cmp [active],0 and activate if not equal,and from Lua,when the key is pressed,write 01 to active,write 0 to active to desactivate,just an idea.
(Tip:you can integrate Lua in the auto assembler using luacall,{$lua},{$asm} )
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Mon May 04, 2015 3:41 pm Post subject: |
|
|
| DaSpamer wrote: | | Code: | timer = createTimer(getMainForm());
timer.Interval = 1;
timer.onTimer = function () if (isKeyPressed(VK_Z)) then fly(); end |
|
It is an improvement but I'm afraid it still skips some positions whilst the assembly version does not.
My system (PC) is not very great either therefore a new thread totally slowed down the game's FPS from a good 70 to a 20 at most.
So the thread is not an option.
Any other ideas ?
Thank you.
[EDIT]
@rnib I used:
| Code: | push 0x58
call GetAsyncKeyState
shr ax,#15
cmp ax,1
jne exit |
_________________
... Fresco |
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Mon May 04, 2015 6:09 pm Post subject: |
|
|
You mentioned the AA version was smooth. Why are you trying to convert it to Lua?
Was there a problem with the AA? Maybe we can help with that.
@rnib, could you post an example of calling Lua from AA?
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Mon May 04, 2015 7:20 pm Post subject: |
|
|
Well the AA version works very well.
I just want to see if I can achieve the same thing with lua that's all.
However, since you asked, there is in fact just a micro problem with the AA version, and I think it's because of the calculations.
Let's say that when the crosshairs x value is 0 the player is looking north, and when it's 90 is looking east. If I now freeze the crosshairs x value to 45 I should be looking north-east. If I now activate the fly code the player should fly north-east (i.e. 45) however in my code the player flies more north than east but the difference is not much, it's about 0.5 degrees, tolerable of course, but annoying.
The asm algo looks currently like this:
| Code: | newmem:
pushfd
pushad
fsave [fsaveop]
/*
all variables are 4bytes single precision floating point numbers
Xcoord = the player current x position on the map
crosshairbaseaddy = the player current crosshair x position
crosshairbaseaddy+4 = crosshair y
*/
/*
esi = x - address of whatever object x position
esi+4 = y
esi+8 = z
adding a positive value to xPosition mooves the player east
adding a negative value to xPosition mooves the player west
adding a positive value to yPosition mooves the player up
adding a negative value to yPosition mooves the player down
adding a positive value to zPosition mooves the player south
adding a negative value to zPosition mooves the player north
the crosshair xValue (i.e. right / left) can go from -360 to +360
moving the crosshairs from left to right increases crosshair xValue
moving the crosshairs from right to left decreases crosshair xValue
once the crosshair xValue hah reached +360 or -360 it resets itself to 0
0, +360, -360 is looking north
+180, -180 is looking south
+90, -270 is looking east
+270, -90 is looking west
the crosshair yValue (i.e. up / down) can go from -80 to +80
moving the crosshairs from down to up decreases crosshair yValue
moving the crosshairs from up to down increases crosshair yValue
looking down crosshair yValue is 80
looking up crosshair yValue is -80
looking horizontally crosshair yValue is 0
*/
//checks if esi is player position
cmp esi, dword ptr [Xcoord]
jne exit
//checks if hotkey for fly code is activated
push 0x58 // VK_X
call GetAsyncKeyState
shr ax,#15
cmp ax,1
jne exit
//places in ebx the address of player crosshair x
mov ebx, crosshairbaseaddy
mov ebx, dword ptr [ebx]
/***********************/
/*** Start of Y algo ***/
// maxCrossY = (float)-80
// maxSpeed and speed means the same thing
// crossY : -80 = speedNeed : maxSpeed
// speedNeed = ( crossY * speed ) / -80
// current player y position += speedNeed
// ebx+4 = address of current player y crosshair
// esi+4 = address of current player y position
fld dword ptr [ebx+4]
fmul dword ptr [speed]
fdiv dword ptr [maxCrossY]
fadd dword ptr [esi+04]
fstp dword ptr [esi+04]
/***** End of Y algo ***/
/***********************/
// ebx = address of current player x crosshair
// compare current player x crosshair with zero
fld dword ptr [ebx]
fcom dword ptr [floatzeroval]
fstsw ax
fwait
sahf
jae crssyxoky
// if below zero add 360 to current player x crosshair
fadd dword ptr [rotationangle]
crssyxoky:
// compare current player x crosshair with 90
fcom dword ptr [float90]
fstsw ax
fwait
sahf
jae above90
/*
from now on I will be referring to current player x crosshair with corssX
speedNeeded is directly proportional to corssX for going east
if corssX is 0 then don't go east
if corssX is 90 then go east full speed
speedNeeded : maxSpeed = crossX : 90
speedNeeded = ( corossX * maxSpeed )/90
****************************************************
speedNeeded is inversly proportional to corssX for going north
this one i got from the forum, thank you guys
speedNeeded = (90-crossX)/180
*/
/*
as angle increases x speed increases
as angle increases z speed decreases
*/
fld st
fmul dword ptr [speed]
fdiv dword ptr [float90]
fadd dword ptr [esi]
fstp dword ptr [esi]
fld dword ptr [float90]
fsub st(0), st(1)
fdiv dword ptr [float180]
fchs
fadd dword ptr [esi+8]
fstp dword ptr [esi+8]
fstp st(0)
jmp exit
above90:
fcom dword ptr [float180]
fstsw ax
fwait
sahf
jae above180
/*
as angle increases x speed decreases
as angle increases z speed increases
*/
fsub dword ptr [float90]//simplifythings
fld dword ptr [float90]
fsub st(0), st(1)
fdiv dword ptr [float180]
fadd dword ptr [esi]
fstp dword ptr [esi]
fmul dword ptr [speed]
fdiv dword ptr [float90]
fadd dword ptr [esi+8]
fstp dword ptr [esi+8]
jmp exit
above180:
fcom dword ptr [float270]
fstsw ax
fwait
sahf
jae above270
/*
as angle increases x speed increases
as angle increases z speed decreases
*/
fsub dword ptr [float180]//simplifythings
fld st
fmul dword ptr [speed]
fdiv dword ptr [float90]
fchs
fadd dword ptr [esi]
fstp dword ptr [esi]
fld dword ptr [float90]
fsub st(0), st(1)
fdiv dword ptr [float180]
fadd dword ptr [esi+8]
fstp dword ptr [esi+8]
fstp st(0)
jmp exit
above270:
/*
as angle increases x speed decreases
as angle increases z speed increases
*/
fsub dword ptr [float270]//simplifythings
fld dword ptr [float90]
fsub st(0), st(1)
fdiv dword ptr [float180]
fchs
fadd dword ptr [esi]
fstp dword ptr [esi]
fmul dword ptr [speed]
fdiv dword ptr [float90]
fchs
fadd dword ptr [esi+8]
fstp dword ptr [esi+8]
exit:
frstor [fsaveop]
popad
popfd
fld dword ptr [esi]
fld dword ptr [esi+04]
jmp returnhere |
_________________
... Fresco |
|
| Back to top |
|
 |
Redouane Master Cheater
Reputation: 3
Joined: 05 Sep 2013 Posts: 363 Location: Algeria
|
Posted: Tue May 05, 2015 8:42 am Post subject: |
|
|
| Zanzer wrote: |
@rnib, could you post an example of calling Lua from AA? |
Its possible,but It requires knowledge about the C API of Lua,not something to use to achieve the fly hack (I mean,its unrelated to the main topic).
If you're interested:
forum.cheatengine.org/viewtopic.php?t=563962
If you mean 'to integrate Lua in AA scripts',then try with luacall(code),{$lua},{$asm}.
Also,I heard that the getASyncKeystate function can give wrong results if it's called from different locations (processes),is that true?
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Tue May 05, 2015 8:56 am Post subject: |
|
|
| rnib wrote: | | Also,I heard that the getASyncKeystate function can give wrong results if it's called from different locations (processes),is that true? |
Worked for me every time with absolutely no problems whatsoever.
Maybe the people who say that, say it because they have no idea how to call it, or misspell something.
A common error is to:
push 'a' instead of push 'A'
I personally just push 0x41 they VK_CODE
Others forget to:
shr ax,#15
cmp ax,1
jne exit
While others mess up with the stack by forgetting:
pushfd
pushad
popad
popfd
_________________
... Fresco |
|
| 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
|
|