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 


LUA code issue
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
mrhartsclube
Newbie cheater
Reputation: 0

Joined: 03 Feb 2013
Posts: 15

PostPosted: Wed Nov 11, 2020 2:21 am    Post subject: LUA code issue Reply with quote

Hello dear friends
Well since I still into old games I'm doing a hack for Peggle Nights game again!

How The Game works?

- you have number of limited balls (10 for start) and a cannon
- you shoot the ball and it hits some pegs in the way down
- there's a bucket that goes sideways back and forth
- if your ball lands inside the bucket you have a free ball

What I Did?

- I figured the ball have vertical (Y Axis) and horizontal (X Axis) values and I find the horizontal one.
- I find a number that just increases and because its using a trigonometric function sine, by increasing the number (angle) it gives the bucket back and forth movement between -1 and 1. but there is no such -1 and 1 number found so I'll go with the increasing one

What The Hack Looks Like?

The hack called "catch me bucket ©" Very Happy will move the bucket as the X Axis of the ball changes and relatively, so it catches the ball on any circumstances.

What LUA Code I Wrote?

this is the code I wrote after stopped the bucket from moving (and even while its moving) as script:


Code:

-- Most left position of bucket
MinBuck = 160
-- Most right position of bucket
MaxBuck = 450
-- Most left position of ball
MinBall = 1085312056
-- Most right position of ball
MaxBall = 1143179023
-- Two range Ratio
Ratio = (MaxBall-MinBall)/(MaxBuck-MinBuck)
-- There is a form with a button to show
CETrainer.show()
-- Also there is a timer (10Ms Interval)
function CETrainer_CETimer1Timer(sender)
    -- Read current X location of the ball from a pointer
    XBall = readInteger("[[[[PeggleNights.exe+002CBDD8]+30]+2C]+0]+EC")
    -- Calculating the ball x axis range into bucket movement range and where the bucket should be
    XBuck = ((XBall-MinBall)/Ratio)+MinBuck
    -- Write the result to bucket's Pointer
    writeInteger("[[[PeggleNights.exe+002CBDD8]+18]+F0C]+4C",XBuck)
end

function CETrainer_CEButton1Click(sender)
   -- And the button should destroy the timer and stop the script
   object_destroy(CETimer1)
end


So What's Wrong?

- Well the code seems to partially works, I mean before I shoot the balls it moves the bucket Realtime with the ball x-value, but after I shoot the ball it freezes until the ball falls and when the ball is gone it moves to it's location for a very short time.
- The second issue is it doesn't matter how much I manipulate the MinBuck and MaxBuck, the bucket won't move full screen width.
- The value of the variable contains bucket movement seems to change fine, but the bucket won't move or catch the ball at the time!
- Also the button doesn't work

what should I do, Please help Sad



Screenshot (6).png
 Description:
 Filesize:  682.22 KB
 Viewed:  5785 Time(s)

Screenshot (6).png



_________________
iMЯH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Wed Nov 11, 2020 11:58 am    Post subject: Reply with quote

MinBall / MaxBall are floats (5.517117 / 654.110291 respectively). Do the arithmetic using floating point numbers; don't convert them to integers immediately (especially not through reinterpretation of bits).

mrhartsclube wrote:
I find a number that just increases and because its using a trigonometric function sine, by increasing the number (angle) it gives the bucket back and forth movement between -1 and 1. but there is no such -1 and 1 number found so I'll go with the increasing one
I see no mention of this in your code.

Sounds to me like one of your pointer paths gets messed up when the ball is fired. Check if the addresses they're pointing to are consistent, and do proper error handling for read* / write*. read* won't return anything on error (vars are nil); write* will return true/false depending on whether or not the call to WPM succeeded (on some exception, it returns nothing).
If the pointer paths are fine, perhaps one of the addresses they're pointing to isn't used after the ball is fired. Look at what instructions access the addresses being pointed to. If nothing is reading from them after the ball is fired, it's not the right address.

_________________
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
mrhartsclube
Newbie cheater
Reputation: 0

Joined: 03 Feb 2013
Posts: 15

PostPosted: Wed Nov 11, 2020 9:35 pm    Post subject: Reply with quote

ParkourPenguin wrote:
MinBall / MaxBall are floats (5.517117 / 654.110291 respectively). Do the arithmetic using floating point numbers; don't convert them to integers immediately (especially not through reinterpretation of bits).


Hey there, well it seems logical what you say, so I will change them but the first lets check last part of your words...

ParkourPenguin wrote:
I see no mention of this in your code.


That's the part I wrote Integer into memory, the second pointer in my LUA code.

ParkourPenguin wrote:
Sounds to me like one of your pointer paths gets messed up when the ball is fired. Check if the addresses they're pointing to are consistent, and do proper error handling for read* / write*. read* won't return anything on error (vars are nil); write* will return true/false depending on whether or not the call to WPM succeeded (on some exception, it returns nothing).
If the pointer paths are fine, perhaps one of the addresses they're pointing to isn't used after the ball is fired. Look at what instructions access the addresses being pointed to. If nothing is reading from them after the ball is fired, it's not the right address.


But this part was revolutionary! I got the wrong pointer if what you said is what it should be! I don't know why this is happening but the address is being accessed by some op codes for a limited time! But anyhow the address I found is accessed by the number of times the ball hits anything, after the ball shoots.
I don't know what it means but I'll keep digging.
Thanks a lot for responding to me Wink Wink

_________________
iMЯH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Wed Nov 11, 2020 11:25 pm    Post subject: Reply with quote

mrhartsclube wrote:
That's the part I wrote Integer into memory...
If the actual x coordinate is the sine of that value, you should be using the inverse sine function somewhere. Graph the points and come up with a sinusoid that's a good fit (e.g. desmos; type "table" to get a table); then, find the inverse of that function.
But this might not be that pragmatic. If it works, it works, and you can forget about this; if it's slightly off between the middle and the ends, this is likely the problem.

I'm glad you discovered what's wrong and I hope you can find a solution for it. As an alternative to pointers, code injection can be used to get an address (search for "injection copy").

_________________
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
mrhartsclube
Newbie cheater
Reputation: 0

Joined: 03 Feb 2013
Posts: 15

PostPosted: Fri Nov 13, 2020 6:45 am    Post subject: Reply with quote

OK I faced what I feared!
I'm so bad in working with float numbers in assembly!
I found a float value between 66 & 586 which it seems to be what I want! I can't test it because it can't be frozen (game is faster than CE) except for the time that game is paused, I also can't work with floats in assembly to test it.
I tried nixing it with nop and the result was catastrophic Mr. Green first it ignored circle pegs, then it didn't recognized the bucket at all Very Happy

So watch this:

PeggleNights.exe+9A3C3 - fld dword ptr [ebp+08]
PeggleNights.exe+9A3C6 - fld st(0)
PeggleNights.exe+9A3C8 - fadd dword ptr [ecx+000000F4]
PeggleNights.exe+9A3CE - fstp dword ptr [ecx+000000F4]
PeggleNights.exe+9A3D4 - fld dword ptr [ecx+000000F8]
PeggleNights.exe+9A3DA - fld dword ptr [ebp+0C]

The value loads from stack[0] and I guess if I was able to change st(0) to what I get from the range calculation It should do the trick.

Any suggestions?

ParkourPenguin wrote:
If the actual x coordinate is the sine of that value, you should be using the inverse sine function somewhere.


Oh and thanks for the advice, I tried searching for some other things related to sine function but it seems the value I found now is the right one. and the good thing is it slows down in the screen edges and speeds up in the middle, so the number range is totally linear (I mean if you write numbers that this value give on the position axis of the bucket, you'll get same distance between (e.g.) 66 and 67 as you'll get between any two other number with exactly 1 unit distance)

_________________
iMЯH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Fri Nov 13, 2020 1:26 pm    Post subject: Reply with quote

Code:
fld dword ptr [ebp+08]          - push an argument on the fpu stack
fld st(0)                       - duplicate that value (new top value)
fadd dword ptr [ecx+000000F4]   - add the float at this address to the top value
fstp dword ptr [ecx+000000F4]   - store the top value at that address and pop it from the fpu stack
fld dword ptr [ecx+000000F8]    - push something else
fld dword ptr [ebp+0C]          - push another argument to this function


I'm assuming the fstp instruction writes the value of the bucket's x-coordinate. Make sure it doesn't write to anything else (right click -> "Find out what addresses this instruction accesses").

Then just write a code injection and do whatever you want with it. e.g.:
Code:
[ENABLE]
aobscan(bucketXInject, D9 C0 D8 81 F4 00 00 00 D9 99 F4 00 00 00) // make sure this is unique
alloc(newmem,2048)
alloc(bucketXval,4)
label(return)
registersymbol(bucketXInject)
registersymbol(bucketXval)


newmem:
  fld dword ptr [bucketXval]
  jmp return


bucketXval:
  dd (float)300.0

bucketXInject:
  jmp newmem
  nop
  nop
  nop
return:

[DISABLE]
bucketXInject:
  db D9 C0 D8 81 F4 00 00 00

dealloc(newmem)
dealloc(bucketXval)
unregistersymbol(bucketXInject)
unregistersymbol(bucketXval)

{

d9 45 08                fld    dword ptr [ebp+8]
// injecting here
d9 c0                   fld    st(0)
d8 81 f4 00 00 00       fadd   dword ptr [ecx+f4]
// done injecting
d9 99 f4 00 00 00       fstp   dword ptr [ecx+f4]
d9 81 f8 00 00 00       fld    dword ptr [ecx+f8]
d9 45 0c                fld    dword ptr [ebp+c]

}
If you can find a good way of getting the ball's x-coordinate in this context that would be ideal to copy right into the bucket's x-coordinate. e.g. perhaps if you're really lucky [ecx+ec] is the ball's x-coordinate?
_________________
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
mrhartsclube
Newbie cheater
Reputation: 0

Joined: 03 Feb 2013
Posts: 15

PostPosted: Fri Nov 13, 2020 2:52 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
fld dword ptr [ebp+08]          - push an argument on the fpu stack
fld st(0)                       - duplicate that value (new top value)
fadd dword ptr [ecx+000000F4]   - add the float at this address to the top value
fstp dword ptr [ecx+000000F4]   - store the top value at that address and pop it from the fpu stack
fld dword ptr [ecx+000000F8]    - push something else
fld dword ptr [ebp+0C]          - push another argument to this function


I'm assuming the fstp instruction writes the value of the bucket's x-coordinate. Make sure it doesn't write to anything else (right click -> "Find out what addresses this instruction accesses").


Thanks for the explanation, and yes its only writing on the bucket.

ParkourPenguin wrote:
If you can find a good way of getting the ball's x-coordinate in this context that would be ideal to copy right into the bucket's x-coordinate. e.g. perhaps if you're really lucky [ecx+ec] is the ball's x-coordinate?


Thanks again for the script, however I have some questions, and I have the X-Ball coordinates pointer, that was the first pointer in my original LUA.
So this is how far I could go with your code and my incomplete knowledge Mr. Green :

Code:

define(address,"PeggleNights.exe"+9A3C6)
define(bytes,D9 C0 D8 81 F4 00 00 00)

[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
alloc(bucketXval,4)
label(return)
registersymbol(bucketXval)
newmem:
fld dword ptr [bucketXval]
  jmp return
bucketXval:
{$LUA}
    MinBuck = 66.00
    MaxBuck = 586.0
    MinBall = 5.500
    MaxBall = 643.3
    Ratio = (MaxBall-MinBall)/(MaxBuck-MinBuck)
    XBall = readFloat("[[[[PeggleNights.exe+002CBDD8]+30]+2C]+0]+EC")
    XBuck = ((XBall-MinBall)/Ratio)+MinBuck
    writeFloat(bucketXval,XBuck)  <====
{$ASM}
address:
  jmp newmem
  nop 3
return:
[DISABLE]
address:
  db bytes
dealloc(newmem)
dealloc(bucketXval)
unregistersymbol(bucketXval)


Well it seems registered symbol in assembly part cannot be used inside LUA, and I'm pretty confused with this code already!
Either I should use the code I pointed at, or I use something like "dd XBuck" after {$ASM}!
And I know for sure they both won't work! so is current code!

So how can I write XBuck into bucketXval? Sad

Oh I was about to forget; when I used dd (float)300.0, the bucket frozen in a place and its like nothing is there, the ball just goes over the bucket and a coin flip for free ball/no ball! funny thing is the screenshot I attached shows that the score backgrounds are also works with this address and I got no points even when the ball goes through the one with all backgrounds!!! I guess the code is only on screen bucket and also makes the real bucket disappear! because I shot balls to entire game width and I got no freeball for catching by the bucket! Rolling Eyes
I'm most likely certain that something is wrong again!! Mr. Green



Screenshot 2020-11-14 003531.png
 Description:
 Filesize:  199.23 KB
 Viewed:  5665 Time(s)

Screenshot 2020-11-14 003531.png



_________________
iMЯH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Fri Nov 13, 2020 5:18 pm    Post subject: Reply with quote

mrhartsclube wrote:
So this is how far I could go with your code and my incomplete knowledge:
code...

{$lua} blocks in the auto assembler are analogous to a preprocessor directive. They're run before most other stuff is run (including registersymbol, I presume).

The easiest thing you can do is create a timer that writes the x coordinate to the symbol bucketXval - i.e. writeFloat("bucketXval", ...)

If you want to do it in assembly:
Code:
define(address,"PeggleNights.exe"+9A3C6)
define(bytes,D9 C0 D8 81 F4 00 00 00)

[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
label(minBuck)
label(maxBuck)
label(minBall)
label(maxBall)

newmem:
  push eax
  mov eax,[PeggleNights.exe+002CBDD8]
  mov eax,[eax+30]
  mov eax,[eax+2c]
  mov eax,[eax]

  fld dword ptr [maxBall]
  fld dword ptr [minBall]
  fld dword ptr [maxBuck]
  fld dword ptr [minBuck]
  fld dword ptr [eax+EC]
  fld dword ptr [minBall]
  fld dword ptr [minBuck]
  fxch st(1)
  fsubp st(2),st(0)
  fxch st(5)
  fsubrp st(4),st(0)
  fxch st(1)
  fsubp st(2),st(0)
  fxch st(1)
  fdivp st(2),st(0)
  fdivrp st(1),st(0)
  faddp st(1),st(0)

  pop eax
  jmp return

newmem+800:
minBuck:
  dd (float)66.0
maxBuck:
  dd (float)586.0
minBall:
  dd (float)5.5
maxBall:
  dd (float)643.3


address:
  jmp newmem
  nop 3
return:

[DISABLE]
address:
  db bytes
dealloc(newmem)

{

  d9 45 08                fld    dword ptr [ebp+8]
  // injecting here
  d9 c0                   fld    st(0)
  d8 81 f4 00 00 00       fadd   dword ptr [ecx+f4]
  // done injecting
  d9 99 f4 00 00 00       fstp   dword ptr [ecx+f4]
  d9 81 f8 00 00 00       fld    dword ptr [ecx+f8]
  d9 45 0c                fld    dword ptr [ebp+c]

}
I copied the x87 instructions from the output of a compiler- haven't tested it. You might overflow the x87 stack by pushing 7 values on it. Optimizing the code by hand should work, or you can probably use SSE instead:

Code:
...
newmem:
  push eax
  mov eax,[PeggleNights.exe+002CBDD8]
  mov eax,[eax+30]
  mov eax,[eax+2c]
  mov eax,[eax]

  movss xmm2,[maxBall]
  movss xmm5,[minBall]
  movss xmm0,[maxBuck]
  movss xmm4,[minBuck]
  movss xmm1,[eax+EC]
  movss xmm6,[minBall]
  subss xmm2,xmm5
  movss xmm3,[minBuck]
  subss xmm0,xmm4
  subss xmm1,xmm6
  divss xmm1,xmm2
  mulss xmm0,xmm1
  addss xmm0,xmm3
  sub esp,4
  movss [esp],xmm0
  fld dword ptr[esp]
  add esp,4

  pop eax
  jmp return
...
(again, copied from a compiler, not tested)
mrhartsclube wrote:
I guess the code is only on screen bucket and also makes the real bucket disappear!
Sounds like you found the wrong value. Keep searching and find one that actually works. If changing/freezing it normally in the address list doesn't work, changing it in Lua or assembly won't work either. You can still take what I wrote as an example to learn from if you want.
_________________
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
mrhartsclube
Newbie cheater
Reputation: 0

Joined: 03 Feb 2013
Posts: 15

PostPosted: Sun Feb 20, 2022 8:53 pm    Post subject: Reply with quote

So I'm back again! I appear every two years Very Happy
I am old enough to raise so many expectation, so I can't cheat games all the time and it happens to happen every two years Razz
Anyhow, I used registersymbol to define both addresses as variable and I tried to use it in LUA in between my ASM code but it gives me "This instruction can't be compiled" while the code works correctly in LUA editor!

Also if it runs before everything, things gets complicated!
Here's my code:

BUCKET POSITION AND CALCULATIONS:


Code:
define(address,"Peggle.exe"+79A8C)
define(bytes,8B 46 4C 51 D9 1C 24)
[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
alloc(xbucket,4)
label(pegsnui)
label(bucket)
label(return)
xbucket:
  dd 0
newmem:
  cmp [esi+10],3  // 3 is used for pegs but 5 and 2 used for UI and bucket
  je pegsnui
  mov [xbucket],eax  // eax is the increasing value for the bucket
  jmp bucket
pegsnui:
  mov eax,[esi+4C]
bucket:
{$lua}
    MinBuck = 150.0
    MaxBuck = 450.0
    MinBall = 5.500
    MaxBall = 643.3
    Ratio = (MaxBall-MinBall)/(MaxBuck-MinBuck)
    XBall = readFloat '[xball]+EC'
    XBucket = getAddressSafe '[xbucket]+4C'
    XBuck = ((XBall-MinBall)/Ratio)+MinBuck
    writeInteger(XBucket,math.floor(XBuck))
  {$asm}
  push ecx
  fstp dword ptr [esp]
  jmp return
address:
  jmp newmem
  nop 2
return:
registersymbol(xbucket)
[DISABLE]
address:
  db bytes
dealloc(*)
unregistersymbol(*)


BALL X POSITION

Code:

define(address,"Peggle.exe"+673E7)
define(bytes,D9 87 EC 00 00 00)
[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
alloc(xball,4)
label(code)
label(return)
xball:
  dd 0
newmem:
  mov [xball], edi
code:
  fld dword ptr [edi+000000EC]
  jmp return
address:
  jmp newmem
  nop
return:
registersymbol(xball)
[DISABLE]
address:
  db bytes
dealloc(*)
unregistersymbol(*)


Now I expect the xball and xbucket can be calculated by the LUA code but I messed it up and I don't even know if the rest of the code works or not Confused

_________________
iMЯH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Mon Feb 21, 2022 4:13 am    Post subject: Reply with quote

Code:

define(address,"Peggle.exe"+79A8C)
define(bytes,8B 46 4C 51 D9 1C 24)
[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
alloc(xbucket,4)

label(pegsnui)
label(bucket)
label(return)

xbucket:
   dd 0
newmem:
   cmp [esi+10],3       // 3 is used for pegs but 5 and 2 used for UI and bucket
   je pegsnui
   mov [xbucket],eax    // eax is the increasing value for the bucket
   jmp bucket

pegsnui:
   mov eax,[esi+4C]

bucket:
{$lua}
   MinBuck = 150.0
   MaxBuck = 450.0
   MinBall = 5.500
   MaxBall = 643.3
   Ratio = (MaxBall-MinBall)/(MaxBuck-MinBuck)
   XBall = readFloat '[xball]+EC'
   XBucket = getAddressSafe '[xbucket]+4C'
   XBuck = ((XBall-MinBall)/Ratio)+MinBuck
   writeInteger(XBucket,math.floor(XBuck))
{$asm}                      // These directives must not have whitespace preceding them otherwise they count as a comment
   push ecx
   fstp dword ptr [esp]
   jmp return

address:
   jmp newmem
   nop 2

return:
   registersymbol(xbucket)

[DISABLE]

address:
   db bytes

dealloc(*)                  // Using * in dealloc/unregistersymbol will deallocate all allocated memory/registered symbols
unregistersymbol(*)         // Including those in other scripts


Perhaps that is the cause of your issue.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Feb 21, 2022 4:54 am    Post subject: Reply with quote

keep in mind that {$lua} only runs one time when the script is assembled

it won't execute again

_________________
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
mrhartsclube
Newbie cheater
Reputation: 0

Joined: 03 Feb 2013
Posts: 15

PostPosted: Mon Feb 21, 2022 10:41 am    Post subject: Reply with quote

LeFiXER wrote:

Code:

... These directives must not have whitespace preceding them otherwise they count as a comment ...


Perhaps that is the cause of your issue.


Aaa Thank you, this was the cause of the error! I'm so obsessed with indentation that I forgot there are rules for different programs Very Happy

Dark Byte wrote:

keep in mind that {$lua} only runs one time when the script is assembled

it won't execute again


thank you, I see, so should I calculate this:

Code:
XBuck = ((XBall-MinBall)/Ratio)+MinBuck


in ASM?

If I should, I'm gonna need some help with that Very Happy I'm terrible with floating point instructions in ASM.

_________________
iMЯH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Mon Feb 21, 2022 1:20 pm    Post subject: Reply with quote

LeFiXER wrote:
Code:
dealloc(*)                  // Using * in dealloc/unregistersymbol will deallocate all allocated memory/registered symbols
unregistersymbol(*)         // Including those in other scripts
What?
These scripts don't interfere with each other:
Code:
[ENABLE]
alloc(foo,4096)
registersymbol(foo)
 
[DISABLE]
dealloc(*)
unregistersymbol(*)
Code:
[ENABLE]
alloc(bar,4096)
registersymbol(bar)
 
[DISABLE]
dealloc(*)
unregistersymbol(*)


xball script looks ok, but I'd use globalalloc for xball:
Code:
define(address,"Peggle.exe"+673E7)
define(bytes,D9 87 EC 00 00 00)

[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
globalalloc(xball,4)

xball:
  dd 0

newmem:
  mov [xball], edi
  fld dword ptr [edi+000000EC]
  jmp return

address:
  jmp newmem
  nop
return:

[DISABLE]
address:
  db bytes

dealloc(*)
This way, the other script won't have to worry about what happens if xball gets deallocated.

bucket position and calculations could use some work.
First of all, what's with the cmp instruction? The code under the bucket label gets executed regardless, so I don't understand why it's even there. If 2 is used for the bucket, shouldn't you compare it against 2 and skip everything if it's not 2?
I guess esi+4C is the actual address of the bucket's x position since 4C is the offset used in the Lua code. If so, the comment "eax is the increasing value for the bucket" might not apply where it is since the instruction `mov eax,[esi+4C]` hasn't been executed yet. You're also storing the value instead of the address.

Maybe something like this:
Code:
define(address,"Peggle.exe"+79A8C)
define(bytes,8B 46 4C 51 D9 1C 24)

[ENABLE]
assert(address,bytes)
alloc(newmem,$1000)
label(originalcode)
label(minBall)
label(minBuck)
label(ratio)
label(return)

newmem+800:
minBall:
  dd (float)5.5
minBuck:
  dd (float)150.0
// maxBall = 643.3, maxBuck = 450.0
// ratio = (maxBall - minBall) / (maxBuck - minBuck)
ratio:
  dd (float)2.126

newmem:
  cmp [esi+10],2
  jne originalcode
// bucket
  mov eax,[xball]
  test eax,eax    // if xball is null (hasn't been initialized yet)
  jz originalcode
  movss xmm0,[eax+EC]
  subss xmm0,[minBall]
  divss xmm0,[ratio]
  addss xmm0,[minBuck]
  cvttss2si eax,xmm0
  mov [esi+4C],eax
originalcode:
  mov eax,[esi+4C]
  push ecx
  fstp dword ptr [esp]
  jmp return

address:
  jmp newmem
  nop 2
return:

[DISABLE]
address:
  db bytes

dealloc(*)

Even still, you're just performing a linear interpretation between the extremes of both objects. If the bucket moves along a sinusoid it might not be good enough.

{$ccode} was a recent addition you might be able to use. The sin function should be available.
https://forum.cheatengine.org/viewtopic.php?t=618134
I can't play around with it right now to figure out how it works.

_________________
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
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Mon Feb 21, 2022 1:59 pm    Post subject: Reply with quote

ParkourPenguin wrote:

...


Ah, it must have been something else that caused my issue of memory being deallocated and symbols being unregistered at that time which led me to believe it was the cause of
Code:

dealloc(*)
unregistersymbol(*)


Good to know it wasn't that. I have been avoiding using it since because of that. From now on that will save me some time, thanks for clearing that up and apologies for the misinformation.
Back to top
View user's profile Send private message
mrhartsclube
Newbie cheater
Reputation: 0

Joined: 03 Feb 2013
Posts: 15

PostPosted: Mon Feb 21, 2022 4:19 pm    Post subject: Reply with quote

First of all I want to thank everybody who helped me and specially to ParkourPenguin who supported me with his information from the begining.

ParkourPenguin wrote:
If 2 is used for the bucket, shouldn't you compare it against 2 and skip everything if it's not 2?


Actually 3 is pegs animations but 2 and 5 had to be changed all together because there are some parts of the bucket that marked as 5 in the code, so:

ParkourPenguin wrote:

Code:

newmem:
  cmp [esi+10],2
  jne originalcode



I had to make it je originalcode and change 2 to 3.
It's very amazing how you guys are not playing this game but you can help me to achieve this! wow!! Surprised

ParkourPenguin wrote:

Even still, you're just performing a linear interpretation between the extremes of both objects. If the bucket moves along a sinusoid it might not be good enough.


actually as I mentioned it before, the movement is linear even if it looks like its sinusoid, so its totally working Very Happy Very Happy

I'm very excited and thankful for all the helps! there is a small bug to make it perfect that I'll be addressing it later.

Here's a GIF file to compare the result with original game.
Sorry about the quality & size (you can zoom though Laughing ) and thanks for helps Wink
the bucket can't keep the ball on its center because of the physical range difference but its doing a good job Very Happy



EDIT:
that globalaloc and test eax,eax was genius! it fixed so many upcoming errors Very Happy

_________________
iMЯH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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