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 


Multiply a value upon increase

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

Joined: 20 Dec 2018
Posts: 2
Location: Chicago, IL

PostPosted: Thu Dec 20, 2018 2:04 pm    Post subject: Multiply a value upon increase Reply with quote

Hey guys. I did an hour of googling before coming here so sorry if this has been asked before.

I'd like to set up a script that will increase the rate of experience gained in a game. Experience is stored as a 4 Byte variable.

Is there a way to compare the previous value with the new one, then multiply the difference, and add that to the new value? In this case, I would like to double the amount of experience gained, so I suppose simply being able to find the difference and adding it to the new value again would do the trick.

Thanks in advance.

P.S. I am not positive whether or not experience increments until it reaches the new value, or if the change in the variable is instantaneous. I would imagine this could cause complications if it did increment until the "gained" experience is depleted, especially if the script applies every time the experience value is changed. The change appears instant, but I'd have to play further into the game to see bigger experience values before I could really tell a difference.

---

I've used Cheat Engine for years now to do simple variable edits, but nothing too much more complicated than finding and editing values like money and experience. I haven't touched any scripting.

If there's a tutorial out there that will handle what I'm trying to accomplish, I'd be glad to take a look at that as well!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 67

Joined: 06 Jul 2014
Posts: 2143

PostPosted: Thu Dec 20, 2018 3:02 pm    Post subject: Reply with quote

Using AA to inject code would likely be best (see step 7 "Code Injection" of the CE tutorial), but Lua can do what you're asking.
Code:
local oldv = tonumber(AddressList.getMemoryRecordByDescription'My Experience'.Value)
local t = createTimer()

t.Interval = 200
t.OnTimer = function(t)
  local mr = AddressList.getMemoryRecordByDescription'My Experience'
  if not mr then t.destroy(); return end

  local v = tonumber(mr.Value)

  if v - oldv > 0 then  -- increased
    oldv = 2*v - oldv
    mr.Value = tostring(oldv)
  elseif v - oldv < 0 then -- decreased
    oldv = v
  end
end
edit: removed print
_________________
I don't know where I'm going, but I'll figure it out when I get there.


Last edited by ParkourPenguin on Thu Dec 20, 2018 5:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
eXistensial Warlock
How do I cheat?
Reputation: 0

Joined: 20 Dec 2018
Posts: 2
Location: Chicago, IL

PostPosted: Thu Dec 20, 2018 4:56 pm    Post subject: Reply with quote

Hey, this looks like what I'm looking for. Thanks a bunch!
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