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 


Simple check HP and activate script function?

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

Joined: 14 Jan 2019
Posts: 1

PostPosted: Mon Jan 14, 2019 9:08 pm    Post subject: Simple check HP and activate script function? Reply with quote

Hi,

I have never really done any scripting in cheat engine before, but I have a game that I have an "Invinvibility" function setup in, however I only want to activate it as a "Safeguard" from dying. The game is Let It Die, kind of like a Dark Souls style game but much more harsh penalty for dying. I am just looking to do something like:

int mycurrenthp;
ReadProcessMemory(PlayerHpAddr, &mycurrenthp)

if mycurrenthp < 500
enable damage immunity script

Is this possible with the cheat engine scripting engine?
Back to top
View user's profile Send private message AIM Address
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Jan 15, 2019 6:21 am    Post subject: Reply with quote

sure, something like
Code:
local script = AddressList.getMemoryRecordByDescription("name of script")
local hp = AddressList.getMemoryRecordByDescription("name of hp memrec")
local t = createTimer()
t.Interval = 100 -- milliseconds
t.OnTimer = function()
  if tonumber(hp.Value) < 500) then script.Active=true
  elseif tonumber(hp.Value) > 1500 then script.Active = false end
end
alternatively you can use the hp address and the correct read<Type> function
Code:
copy paste from celua.txt
readSmallInteger(address) : Reads a 16-bit integer from the specified address
readInteger(address) : Reads a 32-bit integer from the specified address
readQword(address): Reads a 64-bit integer from the specified address
readPointer(address): In a 64-bit target this equals readQword, in a 32-bit target readInteger()
readFloat(address) : Reads a single precision floating point value from the specified address
readDouble(address) : Reads a double precision floating point value from the specified address
readString(address, maxlength, widechar OPTIONAL) : Reads a string till it encounters a 0-terminator. Maxlength is just so you won't freeze for too long, set to 6000 if you don't care too much. Set WideChar to true if it is encoded using a widechar formatting


Of course, depending on the godmode script you could just have it check the health and only do something different from the original code if it's under 500 and/or have a boolean that's toggled under 500 and above 1500 etc. so that it enables when you're nearly dead and autodisables when you've healed back up a bit.

_________________
https://github.com/FreeER/ has a few CE related repos
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