 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
NastyKhan How do I cheat?
Reputation: 0
Joined: 05 Apr 2026 Posts: 2
|
Posted: Sun Apr 05, 2026 8:39 am Post subject: Resident Evil 2 - script crash |
|
|
Hello good people,
I'm learning to script in Cheat Engine and I decided to use Resident Evil 2 Remake (Steam) as an example. My goal is to make character's health to be set to 1200 whenever they're hit.
Health is applied by this instruction:
present in "re2.exe"+A8BF90.
As far as I understand "r9" is an actor. Could be player, but can also be an enemy.
+58 is current health.
My assumption is that +54 is max health, since for the player it's always 1200, while for zombies is something around 700-800.
My plan is to make the following script: whenever "re2.exe"+A8BF90 is executed, check if r9+54 is 1200. If so, change eax to 1200.
Unfortunately I keep failing. My code either doesn't work at all (all takes damage) or works to all (everybody are immortal, even zombies with their heads blown open) or crashes the game.
What am I doing wrong here?
| Code: | [ENABLE]
alloc(newmem,2048,"re2.exe"+A8BF90)
label(originalcode)
label(return)
newmem:
cmp dword ptr [r9+54],1200
jne originalcode
mov eax, 1200
mov [r9+58],eax
jmp return
originalcode:
mov [r9+58],eax
jmp return
"re2.exe"+A8BF90:
jmp newmem
nop
return:
[DISABLE]
"re2.exe"+A8BF90:
db 41 89 41 58
dealloc(newmem) |
Best regards
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 154
Joined: 06 Jul 2014 Posts: 4753
|
Posted: Sun Apr 05, 2026 3:18 pm Post subject: |
|
|
Most literals in AA scripts are parsed as hexadecimal by default. The only parameter I can think of off the top of my head that's parsed as decimal by default is the amount of memory to allocate (i.e. 2048 in that script).
So 1200 is actually 0x1200, or 4608.
People usually specify decimal numbers with a `#` prefix. i.e. `cmp dword ptr [r9+54],#1200` and `mov eax,#1200`
Also, I'd suggest using either the "AOBScan" template or the "Full Injection" template if you don't want to do an aobscan. If the game updates and the location of the original code changes, your script as it is now will still enable and arbitrarily modify some other memory location. With the aobscan template, it might still find the new injection point; with the full injection template, it'll just fail to enable in the first place. (don't delete the comment at the bottom of the script showing the code around the original injection point- that can be used to find the new location of the injection point if the game updates)
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
NastyKhan How do I cheat?
Reputation: 0
Joined: 05 Apr 2026 Posts: 2
|
Posted: Sun Apr 05, 2026 3:44 pm Post subject: |
|
|
I see, thanks.
Meanhwile I did some more research.
I learnt that player's R9 is always
| Code: | | [[[[[["re2.exe"+095D7700]+0]+298]+50]+28]+18]+20 |
and obviously
| Code: | | [[[[[["re2.exe"+095D7700]+0]+298]+50]+28]+18]+20+58 |
is always their health.
I tried figure this out with YouTube and chatGPT but it either crashes or simply doesn't work. I'm out of ideas.
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 154
Joined: 06 Jul 2014 Posts: 4753
|
Posted: Sun Apr 05, 2026 9:10 pm Post subject: |
|
|
You should probably dereference that last node in the pointer.
| Code: | | [[[[[[["re2.exe"+095D7700]+0]+298]+50]+28]+18]+20]+58 |
Also, don't put that big address specifier directly in an instruction. CE will evaluate that pointer path when the script is assembled- not when the game executes the injected code. You'd have to manually traverse the pointer path yourself.
| Code: | push rcx
mov rcx,"re2.exe"+095D7700
mov rcx,[rcx]
mov rcx,[rcx]
mov rcx,[rcx+298]
mov rcx,[rcx+50]
mov rcx,[rcx+28]
mov rcx,[rcx+18]
mov rcx,[rcx+20]
test rcx,r9
pop rcx
jne originalcode
... | If that doesn't work all the time, I'd blame the pointer path.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| 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
|
|