 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
512MB Cheater
Reputation: 0
Joined: 07 Apr 2015 Posts: 38
|
Posted: Tue Feb 06, 2024 6:09 am Post subject: cmp questions |
|
|
I'm currently attempting to grasp the concept of CMP and its application in defining conditional actions based on value comparisons.
I've wrote this code to check whether the armor value exceeds 100; if it does, the program skips, otherwise, it sets the armor value to 100 upon pickup:
Is there a simpler method to write a script for this purpose?
| Code: |
alloc(newmem,$1000)
alloc(SkipArmour,$1000)
alloc(GiveArmour,$1000)
label(code)
label(return)
newmem:
code:
//add [edx+08],eax
cmp eax,#100
Jg SkipArmour //IF EAX is bigger then 100
Jl GiveArmour //IF EAX is less then 100
// add [edx+08],#100
// mov eax,[ecx+08]
// jmp return
SkipArmour:
//add [edx+08],#100
//mov eax,[ecx+08]
jmp return
GiveArmour:
add [edx+08],#100
mov eax,[ecx+08]
jmp return
|
|
|
| Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue Feb 06, 2024 6:51 am Post subject: |
|
|
You are jumping if greater, and then jumping if less, so you are not jumping if equal. You can use JGE (jump if greater or equal) or JLE (jump if less or equal).
Something like this should work:
| Code: |
alloc(newmem,$1000)
label(code)
label(return)
newmem:
code:
//add [edx+08],eax
cmp eax,#100
jge return //return if greater than or equal to 100, else continue with code (you can also jump to original code, depending on what you are trying to do)
add [edx+08],#100
mov eax,[ecx+08]
jmp return //you may want to let original code execute before returning, depending on what you are trying to do |
|
|
| Back to top |
|
 |
512MB Cheater
Reputation: 0
Joined: 07 Apr 2015 Posts: 38
|
Posted: Tue Feb 06, 2024 9:17 am Post subject: |
|
|
Thank you!
Is there any documentation or guides that you would recommend regarding scripting?
|
|
| Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Tue Feb 06, 2024 10:37 am Post subject: |
|
|
You can (and should) learn the basics of assembly language, but you do not have to get too far with it in order to create cheats.
Best to learn by doing. Study other scripts. Ask questions. Give yourself time to learn etc..
|
|
| 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
|
|