Use an address specific value as a trigger to activate another (Joker Commands)

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

Is there a way to create a code that uses an address as a trigger using LUA script? I mean every time the address reaches a specific value it constantly set a value of 100 to another one. It's like a Gameshark joker command, but using an address value as a hotkey or trigger to activate another one and a timer of 10ms to repeat the process if the trigger value is always the same. If there's already a thread about that could anyone share? 'cause I didn't find it.



eg.



if address 005513F000 = 0063 then set a value of 100 to 005510F244

repeat after 10ms

else if address 005513F000 [B]≠[/B] 0063 then do nothing



Sorry my bad english.

Kickyoace
Novice Cheater
Novice Cheater
Posts: 21
Joined: Sun Jun 18, 2017 1:41 am
Reputation: 15

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Kickyoace »

if you wanna venture into the ASM side of things this can be done by using [URL]https://wiki.cheatengine.org/index.php?title=Assembler:Commands:CMP[/URL] or you can do an if statment in lua might be easier to just break and trace the code to tell you what to filter out when you need to set the last mem address or what is really going on in the code or just find a better spot to overwrite that value where its not being memcopy'ed around the place

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

[QUOTE="Kickyoace, post: 135727, member: 6619"]

if you wanna venture into the ASM side of things this can be done by using [URL]https://wiki.cheatengine.org/index.php?title=Assembler:Commands:CMP[/URL] or you can do an if statment in lua might be easier to just break and trace the code to tell you what to filter out when you need to set the last mem address or what is really going on in the code or just find a better spot to overwrite that value where its not being memcopy'ed around the place

[/QUOTE]



Is there any templates using compare operand parameters? I've tried to use CMP, no luck, 'cause I'm using pointers and it's a lot more easier to create it by LUA script than AOB injection. I've tried to find a template with a structure like that, but looks like no one ever tried to make a joker command like code using CE. I know CE allows hotkeys to freeze, increase, decrease and set a specific value to any code, but to use an address to activate other is only possible through script.

TimFun13
Expert Cheater
Expert Cheater
Posts: 1354
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 6

Use an address specific value as a trigger to activate another (Joker Commands)

Post by TimFun13 »

Try a[URL='https://fearlessrevolution.com/threads/6493/'][U] thread[/U][/URL] or a [U][URL='https://fearlessrevolution.com/threads/6492/']timer[/URL][/U].



[CODE=lua]{$lua}

------------------------------ ENABLE ------------------------------

[ENABLE]

local aTimer = nil

local aTimerInterval = 100

local address = 0xdeadbeef

local address2 = 0xbeef0000

local function aTimer_tick(timer)

if readInteger(address) == 100 then

writeInteger(address2, 100)

end

end

----------------------------------

if syntaxcheck then return end

aTimer = createTimer(MainForm)

aTimer.Interval = aTimerInterval

aTimer.OnTimer = aTimer_tick

------------------------------ DISABLE ------------------------------

[DISABLE]

if syntaxcheck then return end

aTimer.destroy()[/CODE]
Last edited by TimFun13 on Thu Jan 01, 1970 12:00 am, edited 1 time in total.

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

[QUOTE="ShyTwig16, post: 135767, member: 91"]

Try a[URL='https://fearlessrevolution.com/threads/6493/'][U] thread[/U][/URL] or a [U][URL='https://fearlessrevolution.com/threads/6492/']timer[/URL][/U].



[CODE=lua]{$lua}

------------------------------ ENABLE ------------------------------

[ENABLE]

local aTimer = nil

local aTimerInterval = 100

local address = 0xdeadbeef

local address2 = 0xbeef0000

local function aTimer_tick(timer)

if readInteger(address) == 100 then

writeInteger(address2, 100)

end

end

----------------------------------

if syntaxcheck then return end

aTimer = createTimer(MainForm)

aTimer.Interval = aTimerInterval

aTimer.OnTimer = aTimer_tick

------------------------------ DISABLE ------------------------------

[DISABLE]

if syntaxcheck then return end

aTimer.destroy()[/CODE]

[/QUOTE]



[QUOTE]

if readInteger(address) == 100 then

writeInteger(address2, 100)

[/QUOTE]



These values here are in HEX or DEC form?

Is there a way to use dd , dw , db and dq to establish the byte limits (4, 2, 1 and 8 bytes) and # to id the values as decimal?



And I tried to use pointers as addresses with no success



Here's how I write them:

[QUOTE]

local address = ["Tutorial-i386.exe"+000000]+1C2

local address2 = ["Tutorial-i386.exe"+000001]+2A1

[/QUOTE]
Last edited by Marconeto on Thu Jan 01, 1970 12:00 am, edited 1 time in total.

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

Sorry. I was really dumb here tsk tsk



I use this to write a specific integer to the address and they are already decimal. 0x should be used for HEX

[QUOTE]

[B]readSmallInteger[/B](address) == 4 then

[B]writeSmallInteger[/B](address2, 100)

end

[/QUOTE]



That part is ok so far, but I had no luck and with the effects and the script wouldn't turn off when using a timer, but It stay enabled even when I click the box.



Thread would be like this?



[CODE=lua]

{$lua}

------------------------------ ENABLE ------------------------------

local addr = "octoshock.dll+1E600B" //BizHawk: (PSX)Resident Evil - Hand gun bullets

local addr2 = "octoshock.dll+1E600B" //same

[ENABLE]

local function luaThread(thread)

while RunLuaThread do

if readSmallInteger(address) == 0x000F then //Every time the bullets reach 15 it will automatically write 100

writeSmallInteger(address2, 0x0064)

end

sleep(0)

end

thread.terminate()

end

----------------------------------

if syntaxcheck then return end

RunLuaThread = true

createThread(luaThread)

------------------------------ DISABLE ------------------------------

[DISABLE]

if syntaxcheck then return end

RunLuaThread = false

[/CODE]
Last edited by Marconeto on Thu Jan 01, 1970 12:00 am, edited 2 times in total.

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

GOTCHA! The thread worked perfectly!

Thank you so much, [B][USER=91]ShyTwig16[/USER][/B]!



I'm going to post the correct thread here for those interested.



[CODE=lua]



{$lua}

------------------------------ ENABLE ------------------------------

local addr = "octoshock.dll+1E600B"

local addr2 = "octoshock.dll+1E600B"

[ENABLE]

local function luaThread(thread)

while RunLuaThread do

if readBytes(addr) == 0x0F then

writeBytes(addr2, 0x64)

end

sleep(0)

end

thread.terminate()

end

----------------------------------

if syntaxcheck then return end

RunLuaThread = true

createThread(luaThread)

------------------------------ DISABLE ------------------------------

[DISABLE]

if syntaxcheck then return end

RunLuaThread = false

[/CODE]
Last edited by TimFun13 on Thu Jan 01, 1970 12:00 am, edited 2 times in total.

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

Hi [B][USER=91]ShyTwig16[/USER][/B], here I am annoying you again rsrs.



Is there any template that shows how this thread logic would look like but using AOB injection instead?



I've looked into the Cheat Engine's Wiki but I didn't find any articles describing how the logic behind AOB works except the basics. I mean is there a way to use[B] "If, then, else, and, or"[/B] and other logic operations without relying on LUA script? The major problem with LUA is the CPU consumption when there are too many threads and I'm not familiar with AOB injection. By using CMP I should achieve something similar, but the structure doesn't work.



[URL]https://wiki.cheatengine.org/index.php?title=Assembler:Commands[/URL] (The article that I used to find the commands, but since I'm no good with the structure I couldn't make it work)



I've found this on a article that shows how to create pointer addresses using AOB, but I had no luck and no results when trying to create a logic like the one you showed me, but using AOB.

[URL unfurl="true"]https://forum.cheatengine.org/viewtopic.php?p=5730610[/URL]

TimFun13
Expert Cheater
Expert Cheater
Posts: 1354
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 6

Use an address specific value as a trigger to activate another (Joker Commands)

Post by TimFun13 »

Find where the address is written to and change it there. If you don't know how to find that start with the CE tutorial in the CE help menu. Once you have the injection point you can just add the logic there.

Something like this:

[CODE=cea]//...

cmp byte ptr [octoshock.dll+1E600B],0F

jne @f

mov byte ptr [octoshock.dll+1E600B],64

@@:

//...

[/CODE]



Here's a few link that might help as well.

[URL='https://fearlessrevolution.com/threads/6637/'][B][U]AOB signatures[/U][/B][/URL]

[URL='https://fearlessrevolution.com/threads/6544/'][B][U]Code Injection - Editable Values[/U][/B][/URL]

[URL='https://fearlessrevolution.com/threads/6539/'][B][U]Code Injection - Full[/U][/B][/URL]



EDIT: That or use one thread enabled as a "main script" and toggle options with global variables in other scripts. As using comparative logic you are limited to JE, JNE, JG, JL, CMOVE, CMOVG, and others like that. No real OR, AND, or ELSE; just a lot of jumps back and forth that can get a bit messy.
Last edited by TimFun13 on Thu May 21, 2020 5:11 am, edited 2 times in total.

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

[B][USER=91]ShyTwig16[/USER][/B]



Got it!

It needed a [B]jne[/B] to work.

The easy way to find where the address is written is by watching the accesses and that part is ok. I screwed everything because I didn't know that a [B]jne[/B] function was needed.

But it wont change much as you said, because this injection also needs a lot of jumps but in different places since the injection point is allocated near the end of the memory. The number of addresses that I used in this process will always result in high CPU consumption and this makes it useless. As you said the only way to reduce CPU consumption is by using one thread as the base.

Thank you, man!

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Re: Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

Although this thread is old I'm here to show a way to create Joker like commands through code injection.
As an example I'm using the following emulator and ROM/Game:
BizHawk 1.13.2
Libretro Core: Genplus-gx
ROM: Revenge of Shinobi, The (W) (REV 03) [!].bin
Since joker like codes based on lua scripting demand lots of CPU, I feel like it would help those interested in creating these types of codes for consoles like Sega Genesis, SNES, PC Engine and any other that unfortunately doesn't have those type of codes (Game Genie and Action Replay works only with constant freeze type codes when dealing with 8 and 16-bit consoles).
First of all you will need a memory that has constant access to a specific address. Try looking for a memory at the disassembler that access only one address. I'm using ""libgenplusgx.dll"+11FA" for the following code and if you find out what addresses this instruction access at the disassembler you find out that it's only one. After that you'll enter the Auto Assembler (Ctrl+A), create a table framework (Ctrl+Alt+T) and inject the template (Ctrl+I). The rest follows:
E.g
[ENABLE]
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(Turbo)
label(Moreshurikens)
label(Superjump)
label(exit)

newmem:
cmp byte ptr [libgenplusgx.dll+50AFEA],#1 //Turbo is active when "Up" is pressed
je Turbo
cmp byte ptr [libgenplusgx.dll+50AFEA],#2 //Turbo is active when "Down" is pressed
je Turbo
cmp byte ptr [libgenplusgx.dll+50AFEA],#58 //More Shuriken when "Down+Right+B+C" is pressed
je Moreshurikens
cmp byte ptr [libgenplusgx.dll+50AFEA],#32 //Super Jump when "C" is pressed
je Superjump
cmp byte ptr [libgenplusgx.dll+50AFEA],#36 //Super Jump when "C+Left" is pressed
je Superjump
cmp byte ptr [libgenplusgx.dll+50AFEA],#40 //Super Jump when "C+Right" is pressed
je Superjump
jne originalcode
movups xmm0,[libgenplusgx.dll+50AFF0] //This Opcode belongs to the original memory and it can't be removed, else the game will crash

Turbo:
mov byte ptr [libgenplusgx.dll+517043],00 //This code set the shooting animation speed to a higher level
movups xmm0,[libgenplusgx.dll+50AFF0] //This Opcode belongs to the original memory
jmp originalcode

Moreshurikens:
mov word ptr [libgenplusgx.dll+51917E],#9999 //Give the player 9999 shurikens (game rounds it to 899)
movups xmm0,[libgenplusgx.dll+50AFF0] //This Opcode belongs to the original memory
jmp originalcode

Superjump:
mov word ptr [libgenplusgx.dll+51705C],#65532 //Super Jump or Moon Jump like code. If you hold down "C" the ninja will fly.
movups xmm0,[libgenplusgx.dll+50AFF0] //This Opcode belongs to the original memory
jmp originalcode

originalcode:
movups xmm0,[libgenplusgx.dll+50AFF0] //This Opcode belongs to the original memory. The originalcode is active when none of the commands are active

exit:
jmp returnhere

"libgenplusgx.dll"+11FA:
jmp newmem
nop 2
returnhere:

[DISABLE]
dealloc(newmem)
"libgenplusgx.dll"+11FA:
movups xmm0,[libgenplusgx.dll+50AFF0]
These kind of codes needs a memory that is always active and has access to a specific address. Their original opcode need to be at the end of line to avoid crash. Always avoid using memories that has access and control to many addresses since emulator/consoles memory instructions are volatile (meaning the opcode may change during the gameplay). I know it may be hard, but if you get this to work you'll never use Game Genie, Action Replay, Code Breaker or Game Shark ever again.
Last edited by Marconeto on Thu Feb 18, 2021 5:34 pm, edited 1 time in total.

User avatar
SunBeam
RCE Fanatics
RCE Fanatics
Posts: 4665
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4186

Re: Use an address specific value as a trigger to activate another (Joker Commands)

Post by SunBeam »

Good thing you posted it in the Lua section. *claps* There are a lot of ways to do what you did above even without code injection. I would appreciate it if you explained what you did without emphasizing it can't be done with Lua "cuz it eats a lot of CPU". This only shows you don't know, probably haven't tried or don't want to learn Lua.

And what the hell are "joker like commands"? What you actually mean is mimic the effect of a joker command. Which is the same thing happening on PCs with game engines and consoles. See Unreal Engine 4. You open the console, you type in "god" command and hit Enter key. Something happens in memory which tells the Engine god is active. Same as your joker commands which either trigger some value to switch or enable some timer which depletes a value.

Marconeto
Noobzor
Noobzor
Posts: 10
Joined: Tue May 19, 2020 4:38 am
Reputation: 0

Re: Use an address specific value as a trigger to activate another (Joker Commands)

Post by Marconeto »

SunBeam wrote:
Wed Feb 17, 2021 3:55 am
Good thing you posted it in the Lua section. *claps* There are a lot of ways to do what you did above even without code injection. I would appreciate it if you explained what you did without emphasizing it can't be done with Lua "cuz it eats a lot of CPU". This only shows you don't know, probably haven't tried or don't want to learn Lua.

And what the hell are "joker like commands"? What you actually mean is mimic the effect of a joker command. Which is the same thing happening on PCs with game engines and consoles. See Unreal Engine 4. You open the console, you type in "god" command and hit Enter key. Something happens in memory which tells the Engine god is active. Same as your joker commands which either trigger some value to switch or enable some timer which depletes a value.
Wtf lol. There are lots of ways to do that, yeah, but when dealing with old consoles or emulation, in that case, the thing is a lot different. Yes I have tried lua and for these type of codes it's not a good option. I know Unreal Engine has a console, but that's not what I meant. Binding hotkeys doesn't help either, it works but the time of response has some gaps and the game engine is just a software interpreter and wrapper (using layman's terms).
The lua is available for everyone in the thread, but I just posted this as a sort of addendum (even though is a code injection within a Lua Scripting section). And I learn what's necessary, little by little 'cause unfortunately I don't have enough time to read the entire lua programming book or what's available at Cheat Engine wiki.
[Link]
Joker Commands:[Link]
No need to be rude, man. If the post annoys anyone you just have to say and I will remove it. I'm just letting people, who might be interested, know that there are alternatives to lua when dealing with these types of codes and they don't demand a complex script. The only answers I found in both Cheat Engine forums to the same type of question doesn't satisfy the question.

TimFun13
Expert Cheater
Expert Cheater
Posts: 1354
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 6

Re: Use an address specific value as a trigger to activate another (Joker Commands)

Post by TimFun13 »

Marconeto wrote:
Wed Feb 17, 2021 1:36 pm
...
You could even try to setup a Lua Module that has a table of read addresses, write addresses, and values to write. Then use a single thread or timer to check them all and act accordingly.

But yeah, if speed is a real concern then ASM will most likely be the best way to go.

And if you need it to work every time the value is set, code injection is your best bet in my opinion.

User avatar
SunBeam
RCE Fanatics
RCE Fanatics
Posts: 4665
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4186

Re: Use an address specific value as a trigger to activate another (Joker Commands)

Post by SunBeam »

Marconeto wrote:
Wed Feb 17, 2021 1:36 pm
...
Kindly post or PM me a link to both the emulator you're using and the game in question, so we're "talking the same language" (so I work with the same ones you do). I'll check it out and post my thoughts.

Post Reply

Who is online

Users browsing this forum: No registered users