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 


Increase one value whenever a different value increases

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

Joined: 28 Nov 2021
Posts: 2

PostPosted: Sun Nov 28, 2021 3:32 pm    Post subject: Increase one value whenever a different value increases Reply with quote

Hi there,
Here's what I'm trying to do: I want to make it, so scoring points increases your current health. I already know how to find the static addresses for health and score, and have some experience scripting.

Basically: Save current score, check regularly if score has increased, and if so, raise health by 10% of the points scored.

I'm trying to see if I can "Doomify" Bulletstorm by making it faster (works great) and having Skillshots heal you, so you don't have to wait for your health to regen passively.

Any help would be much appreciated!
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater
Reputation: 5

Joined: 02 Sep 2011
Posts: 537
Location: 0x90

PostPosted: Sun Nov 28, 2021 4:12 pm    Post subject: Reply with quote

What do you know of Lua? You could use that to implement the logic. You will want to read the score value and the health value. Store the score in a variable to check for increases and if so then increase the health by 10% of the score.

Code:

[ENABLE]
-- Assuming it's a 4-byte value, if it's float use readFloat() instead
local old_score = readInteger('address_of_score')

-- Create a timer to consistently check for changes to score
local t = createTimer(getMainForm())
t.Interval = 20 -- 20 ms
t.OnTimer = function ()
            -- so the timer only runs once, but will require re-activating
            if t then t.destroy(); t = nil end
               local current_score = readInteger('address_of_score')

              if current_score > old_score then
              -- We use readInteger, or readFloat whichever is suitable, to get the value of HP
              local hp = readInteger('address_of_health')
              -- We calculate 10% of the score so we know how much to increase the HP by
              local health_to_increase = ((10 / current_score) * 100)
              -- We add the two values together and store the new value in hp
              hp = hp + health_to_increase
              -- Write the new value to the address of hp
              writeInteger('address_of_hp', hp)
              end
            end
[DISABLE]
if t then t.destroy(); t = nil end


Something like this. You will have to insert the addresses of score and HP but this should work as intended.

More documentation about which Lua functions are available can be viewed here
Back to top
View user's profile Send private message
mingoyreb
How do I cheat?
Reputation: 0

Joined: 28 Nov 2021
Posts: 2

PostPosted: Mon Nov 29, 2021 4:13 pm    Post subject: Reply with quote

Wow, that was quick. Yeah, the code makes sense to me. Thank you so much! I'll start tinkering with it tonight.
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