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 


Execute code on value change

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

Joined: 27 Feb 2019
Posts: 3

PostPosted: Wed Feb 27, 2019 10:50 am    Post subject: Execute code on value change Reply with quote

Hello all!

I'm trying to modify Kingdoms of Amalur: Reckoning XP gain speed.

In this game, it's extremely easy to over level to remedy this I wanted to nerf the amount of XP the player is getting every time he gets any XP.

I found the memory address which stores the overall XP for the player. My idea was to trigger a function each time this value changes and nerf the XP.

For example, if the player currently has 100 XP and then he gets 10xp for killing a monster, the new value would be 110. What I would do is store the old value, subtract the new from the old (thus getting the amount XP gained) and multiply it by the nerf value. In other words:
Code:
110 - 100 = 10


Then:
Code:
10 * 0.5[Nerf factor] = 5[New gain value]


So, in the end, the new value would be 100 + 5 = 105.

This is all a good, however, I wasn't able to find how to do something that triggers code or functions on value change. Is this sort of thing at all possible?

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

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Wed Feb 27, 2019 2:19 pm    Post subject: Reply with quote

That's what code injection is for.

If you must use Lua, look into debug_setBreakpoint. Note that break-on-write breakpoints must use a debug register.
You could also just use a timer and simulate it, but that might cause strange behaviour.

_________________
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
curtwagner1984
How do I cheat?
Reputation: 0

Joined: 27 Feb 2019
Posts: 3

PostPosted: Thu Feb 28, 2019 6:35 am    Post subject: Reply with quote

ParkourPenguin wrote:
That's what code injection is for.

If you must use Lua, look into debug_setBreakpoint. Note that break-on-write breakpoints must use a debug register.
You could also just use a timer and simulate it, but that might cause strange behaviour.


Thank you for your reply. I'm fairly new to CE. Are there some tutorials about how to use code injection, debug register and the timer?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Thu Feb 28, 2019 9:32 am    Post subject: Reply with quote

Go through the CE tutorial located in the "Help" menu of CE. You'll find plenty of videos and other kinds of tutorials showing the basics of code injection if you search for it.

You can also search for information on debug registers. One good way to learn is to start going down a wiki rabbit hole.

For Lua-specific help, there's documentation that can be accessed through CE's "Help" menu.
The CE Wiki has more information than it used to, but it's also sometimes misleading or wrong.
Using a search engine is always an option to look for examples and problems other people have had.

_________________
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
curtwagner1984
How do I cheat?
Reputation: 0

Joined: 27 Feb 2019
Posts: 3

PostPosted: Sat Mar 02, 2019 10:55 am    Post subject: Reply with quote

Thank You!
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