 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
mordax Expert Cheater
Reputation: 1
Joined: 16 Apr 2010 Posts: 138
|
Posted: Sat Sep 21, 2024 8:10 am Post subject: how can i modify all except 1 using shared opcode? |
|
|
Hiya, can someone please help with lua. i have tried chatGPT, but it can't seem to get it to work. it's rather simple thing, but i don't know how to write lua from head.
i understand the code once i see it, but i can't figure out where issue is.
i basically want to do 1 hit kills, but it doesn't seem to be working.
so there is shared opcode that changes health for player + npcs
i already have asm script to filter out player. my method is to set a flag for first found address as that's always player, then rest are NPCs. its been working consistently so far.
without exposing too much about the game, here is part of my asm script that works for filtering out player.
| Code: |
newmem:
cmp byte [capture_flag], 1
je check_if_player
mov byte [capture_flag], 1
mov rax, _health1
mov [rax], rcx
check_if_player:
mov rax, _health1
cmp rcx, [rax]
je skip_npc_update
skip_npc_update:
mov eax, [rcx+000000AA]
jmp return
findphealthcmp:
jmp newmem
nop
return: |
i then add custom address into cheat list which is "_health1" and this is player health. it displays it fine and i can modify it.
but i'm having hard time writing lua that would modify all NPC healths to randomly low numbers, not just 1 or 0, but something like between 1 and 10.
i can easily modify this to set all NPC health to 0 or 1, but i want to be more creative and set it to randomly low value. i have consulted with chatGPT and it confirmed it can only be done via lua, but it fails to give me working script.
can someone please give me working example on how to do such thing via lua?
my opcode is "breakpoint on read", it doesn't write values, just reads.
by using that opcode, i can set all NPC health to specific value via assembly script, but for randomly generated values i need to use lua and i can't get it to work.
can someone please help with this part? working sample would be enough. part that would use the opcode to modify all other addresses except the player.
i hope this is clear enough on what i'm trying to do. Thanks.
|
|
| Back to top |
|
 |
Bloodybone Newbie cheater
Reputation: 0
Joined: 07 Dec 2016 Posts: 21 Location: Germany
|
Posted: Sat Sep 21, 2024 9:49 am Post subject: |
|
|
I would actually use assembly instead of lua because if you want to use lua you would either have to cache all of the npcs addresses or call lua from assembly with for example a {$luacode} block. I would do something like this instead:
| Code: | //...
label(minValue)
label(maxValue)
label(randomSeed)
label(npcend)
newmem:
cmp byte [capture_flag], 1
je check_if_player
mov byte [capture_flag], 1
mov rax, _health1
mov [rax], rcx
check_if_player:
mov rax, _health1
cmp rcx, [rax]
je skip_npc_update
// Save Registers, align Stack ...
push rbx
push rcx
push rdx
push r8
push r9
push r10
push r11
push rbp
mov rbp,rsp
and spl,F0
sub rsp,20
mov rbx,rcx
mov eax, [rbx+000000AA]
cmp eax,[maxValue] // Check if npc health is already below max
jle npcend
// Create Random Number
cmp dword ptr [randomSeed],0
jne short @f
// Create Seed
call ntdll.NtGetTickCount
mov [randomSeed],eax
@@:
lea rcx,[randomSeed]
call ntdll.RtlRandomEx
xor rdx,rdx
mov ecx,[maxValue]
inc ecx // make maxValue inclusive
sub ecx,[minValue]
div ecx
add edx,[minValue]
mov [rbx+000000AA],edx
npcend:
mov rsp,rbp
pop rbp
pop r11
pop r10
pop r9
pop r8
pop rdx
pop rcx
pop rbx
skip_npc_update:
mov eax, [rcx+000000AA]
jmp return
minValue:
dd 0
maxValue:
dd #10
randomSeed:
dd 0
findphealthcmp:
jmp newmem
nop
return: |
This code is assuming that health is an integer not float
If you want to add minValue and maxValue to the table, register them with registersymbol()
|
|
| Back to top |
|
 |
mordax Expert Cheater
Reputation: 1
Joined: 16 Apr 2010 Posts: 138
|
Posted: Sat Sep 21, 2024 10:06 am Post subject: |
|
|
| Bloodybone wrote: | I would actually use assembly instead of lua because if you want to use lua you would either have to cache all of the npcs addresses or call lua from assembly with for example a {$luacode} block. I would do something like this instead:
| Code: | //...
label(minValue)
label(maxValue)
label(randomSeed)
label(npcend)
newmem:
cmp byte [capture_flag], 1
je check_if_player
mov byte [capture_flag], 1
mov rax, _health1
mov [rax], rcx
check_if_player:
mov rax, _health1
cmp rcx, [rax]
je skip_npc_update
// Save Registers, align Stack ...
push rbx
push rcx
push rdx
push r8
push r9
push r10
push r11
push rbp
mov rbp,rsp
and spl,F0
sub rsp,20
mov rbx,rcx
mov eax, [rbx+000000AA]
cmp eax,[maxValue] // Check if npc health is already below max
jle npcend
// Create Random Number
cmp dword ptr [randomSeed],0
jne short @f
// Create Seed
call ntdll.NtGetTickCount
mov [randomSeed],eax
@@:
lea rcx,[randomSeed]
call ntdll.RtlRandomEx
xor rdx,rdx
mov ecx,[maxValue]
inc ecx // make maxValue inclusive
sub ecx,[minValue]
div ecx
add edx,[minValue]
mov [rbx+000000AA],edx
npcend:
mov rsp,rbp
pop rbp
pop r11
pop r10
pop r9
pop r8
pop rdx
pop rcx
pop rbx
skip_npc_update:
mov eax, [rcx+000000AA]
jmp return
minValue:
dd 0
maxValue:
dd #10
randomSeed:
dd 0
findphealthcmp:
jmp newmem
nop
return: |
This code is assuming that health is a integer not float
If you want to add minValue and maxValue to the table, register them with registersymbol() |
thanks, but i think i got it working via lua. problem with asm is that it kept crashing my game and my lua isn't that good. i don't know every syntax and chatgpt sometimes just gets stuck in loop and don't know how to fix it. if i just say "this crashed game" it can't seem to realize what part crashes the game.
now i just have issues that lua needs to execute AFTER asm is enabled, which is bit of an issue as it keeps spamming in the output field that something is invalid (since asm is not enabled). trying to solve that part right now with custom trigger to make lua inactive.
i will try the asm method at some point, since it seems easier and i can toggle it off.
|
|
| 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
|
|