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 


Set value only if value at specific address is zero

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
MichiS97
How do I cheat?
Reputation: 0

Joined: 21 Feb 2013
Posts: 9

PostPosted: Tue Mar 10, 2015 3:40 pm    Post subject: Set value only if value at specific address is zero Reply with quote

Hi and sorry, I couldn't come up with a better title for the thread.

I need somebody's help on a trainer I am working on. I can use CheatEngine well enough to create trainers for my personal use (nothing ASM based, just basic memory alterations) but I have come to a problem now.
I'd like to create a cheat for a trainer that sets the value at a specific address to 64 if the value currently is 00. It's probably better to tell you why I need it exactly so here is what I need this for:
I want to play Legend of Zelda: Oracle of Ages on the VBA-M emulator and I would like to use a cheat that fills my health after it reaches 0 and therefore prevents me from dying. Now, there's an item in the game that achieves exactly that called the Magic Potion but it disappears after using it once and Id like to have an infinite amount of it. Of course, there already is a Gameshark code that would give me this item infinitely but it is pretty buggy and messes up other items. From what I have experimented with the code it seems that one byte in the memory has control over two items.
So yeah, I pretty much want to simulate this reviving potion with a code that fills my health back to max as soon as it reaches 0. I already have the address to it and I can freeze and set the value to a different one without a problem but is there a way to wirte a lua script that only sets the value if I don't have any health left? I have a basic knowledge of programming in Java but Lua still is a very unfamiliar territory for me so I'd be glad if someone could help me out there by providing me with a working script or telling me how I could code this myself.
The address for health is: "VisualBoyAdvance-M.exe"+003169B0
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Tue Mar 10, 2015 3:48 pm    Post subject: Reply with quote

Well, if you have the address of your health it's quite simple:

Right click -> find out what writes to this address (alternatively you can choose the point above that one)

Optionally do a reverse-debugging to make sure that routine only access your health and not i.e. your enemy's too.

Since you cannot program in ASM (or did I misunderstood you?) just post the command which writes the health here and we can help you to create a script that'll set your health to 64 every time you losse some health points ...
Back to top
View user's profile Send private message
MichiS97
How do I cheat?
Reputation: 0

Joined: 21 Feb 2013
Posts: 9

PostPosted: Tue Mar 10, 2015 3:54 pm    Post subject: Reply with quote

The address is a pointer though. Do I choose "Find what writes this pointer" or "Find what writes the address pointed at"?

EDIT: Got it. The command is "VisualBoyAdvance-M.exe+14DD - 88 0C 10 - mov [eax+edx],cl"....you know....if it would be a simple sub or add I could do something about it Very Happy
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Tue Mar 10, 2015 4:04 pm    Post subject: Reply with quote

When you have this address in the disassembler:

Rightclick on it -> "Find out what addresses this instruction accesses"

Then loose some health and try to damage your enemies too ... If only your own health address shows up, then it's pretty simple, otherwise you would've to find a compare too, in order not to make your enemies godlike too
Back to top
View user's profile Send private message
MichiS97
How do I cheat?
Reputation: 0

Joined: 21 Feb 2013
Posts: 9

PostPosted: Tue Mar 10, 2015 4:08 pm    Post subject: Reply with quote

Doing this makes the game run in slow mo and returns about 10,000 adresses Very Happy
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Tue Mar 10, 2015 4:12 pm    Post subject: Reply with quote

Ouch ... Seems like one of those "One for all" addresses ...

Then go back to your health address once more, right click -> find out what access this address ... There you should get more than one address ... Do the reverse debugging (the point with "Find out what addresses this instruction accesses") on every one of them ... If one of them only access your own health address and nothing else, then post it's assembler code here
Back to top
View user's profile Send private message
MichiS97
How do I cheat?
Reputation: 0

Joined: 21 Feb 2013
Posts: 9

PostPosted: Tue Mar 10, 2015 4:15 pm    Post subject: Reply with quote

What the hell...it doesn't find a single address that accesses the health address
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Tue Mar 10, 2015 4:16 pm    Post subject: Reply with quote

Did you also loose some health? At least the one you just posted should show up (because writing is also a kind of accessing)

About the pointer-thing: make sure you click on the "Find what access the address pointed at by this pointer"
Back to top
View user's profile Send private message
MichiS97
How do I cheat?
Reputation: 0

Joined: 21 Feb 2013
Posts: 9

PostPosted: Tue Mar 10, 2015 4:19 pm    Post subject: Reply with quote

For some reason I got two results after restarting the emulator. Both addresses give me thousands of results and slow motion when I try reverse debugging them
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Tue Mar 10, 2015 4:30 pm    Post subject: Reply with quote

Why do you need an emulator anyways? Of course the emulator acceses more than just one address ... Can't you directly debug the legend of zelda EXE File?
Back to top
View user's profile Send private message
MichiS97
How do I cheat?
Reputation: 0

Joined: 21 Feb 2013
Posts: 9

PostPosted: Tue Mar 10, 2015 4:31 pm    Post subject: Reply with quote

It's a Gameboy Color game Razz
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Tue Mar 10, 2015 4:44 pm    Post subject: Reply with quote

Ahhh sure, sorry, I mistook it for a different game Smile

Well, when using an emulator it's almost impossible to make (good) cheats because there won't be an address that just access the disered game values (like this is normally the case when debugging the game's own EXE) ...
Back to top
View user's profile Send private message
MichiS97
How do I cheat?
Reputation: 0

Joined: 21 Feb 2013
Posts: 9

PostPosted: Tue Mar 10, 2015 4:47 pm    Post subject: Reply with quote

Yes I pretty much expected that...well it doesn't matter too much but was worth a shot, thanks for your help!
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 Lua Scripting 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