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 


Help with fixing this script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Rubyelf
Newbie cheater
Reputation: 0

Joined: 08 Mar 2013
Posts: 20

PostPosted: Thu Mar 07, 2024 9:30 pm    Post subject: Help with fixing this script Reply with quote

So I am attempting to fix a broken script, which doesn't let items decrease if you were to split them/use them.

While I managed to do this, the issue I am having is when you split them, the item that splits off also does not decrease even when added back. I want that to happen.

The original script is shown below, and the new one where I found the current AOB after an update is where I am having issues. They look entirely different, and while I am sure this is part of my issue, the old AOB no longer exists (no amount of searching has managed to find it, I ended up having to use the debugger to get even remotely close).



halp.png
 Description:
Current with the issue
 Filesize:  183.6 KB
 Viewed:  572 Time(s)

halp.png



old.png
 Description:
Old Code
 Filesize:  71.5 KB
 Viewed:  572 Time(s)

old.png


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4307

PostPosted: Thu Mar 07, 2024 10:54 pm    Post subject: Reply with quote

Don't use `nop 3`. That's just for padding in the old script. In the old script, the original code at the injection point (`sub` & `mov`) takes up 8 bytes. The jump only needs 5 bytes. That leaves 3 bytes that need to be padded for the `return` label to be at the correct address.
The new script doesn't need that. The original code (`sub` & `je`) takes up 5 bytes exactly- no need for padding.

Rubyelf wrote:
when you split them, the item that splits off also does not decrease even when added back.
I'm not entirely sure what you mean by this.

Maybe don't do it if the result would be 0?
Code:
...
newmem:
  cmp [rbx+1C],edi
  jne return
  sub [rbx+1C],edi
  jmp INJECT+1B

INJECT+09:
  jmp newmem
return:

...
`jne return` - if they're equal (i.e. subtracting the value would set it to 0), skip it. The second instruction doesn't need to be executed since the result is obviously not equal and the branch won't be taken.
`jmp INJECT+1B` - due to the aobscan, the injected code needs to be correct regardless of where the injection point is located in memory. If the game updates and the injection point changes location, the jump destination will also change. As such, you can't just write the original instruction down and expect it to work if the original code changes its location in the exe.
The original instruction, `74 0D - je GameAssembly.dll+29AB68D`, just jumps 0xD bytes after the address of the next instruction. The offset from the aobscan symbol - i.e. 0x1B - can be calculated from this.
You could also use `reassemble(INJECT+C)`. Even though this is technically a jcc, it'll always be taken given the context around the previous `jne return`.

You could simply write the original instruction down if you forego the aobscan and use the "Full Injection" template instead. Of course, this means the injection point is expected to be at a certain address. If the game updates, the script is more likely to fail than if it used aobscan.

PS: use a more unique symbol name than "INJECT". If two or more scripts register the same symbol, bad things will happen.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Rubyelf
Newbie cheater
Reputation: 0

Joined: 08 Mar 2013
Posts: 20

PostPosted: Fri Mar 08, 2024 1:13 am    Post subject: Reply with quote

Quote:

Rubyelf wrote:
when you split them, the item that splits off also does not decrease even when added back.


What I mean by that is, you can drag things back to add them as a stack, but with this enabled, it didn't add it back and instead the one you dragged remained (eg 1 stack of ice cream, dragged onto a stack of 20 ice creams, it goes to 21, but that 1 stack stays in its spot).

I'll check your ideas out tomorrow, too late now, thank you for the help hopefully it works for me Smile I am still learning
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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