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 


cmp questions

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
512MB
Cheater
Reputation: 0

Joined: 07 Apr 2015
Posts: 38

PostPosted: Tue Feb 06, 2024 6:09 am    Post subject: cmp questions Reply with quote

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
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Tue Feb 06, 2024 6:51 am    Post subject: Reply with quote

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
View user's profile Send private message
512MB
Cheater
Reputation: 0

Joined: 07 Apr 2015
Posts: 38

PostPosted: Tue Feb 06, 2024 9:17 am    Post subject: Reply with quote

Thank you!
Is there any documentation or guides that you would recommend regarding scripting?
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Tue Feb 06, 2024 10:37 am    Post subject: Reply with quote

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