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 


Regenerating health

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

Joined: 31 Jul 2011
Posts: 9

PostPosted: Sun Jul 31, 2011 11:50 am    Post subject: Regenerating health Reply with quote

Hello everyone. As you can probably see I'm very new here. Despite that though I've been using cheat engine for a while and up until now I've been able to solve just about any problem I've come across just by searching on the forums but I've just hit something that I can't quite figure out and I'm hoping I can get some advice.

Okay so my question is this. Say i have a typical game where if you get hurt, your health doesn't regenerate. now I'm pretty sure that in most games where it DOES regen it's all just based on time as in every second your health increases by such and such amount. How though, would I go about doing THAT in a game that doesn't have regenerative health? it's just something I've been fooling around with in my head for a while lately. I would think you would just have to find the time in your game and somehow get it to add health to your health but what if it's a game like... Fall out, where you don't actually SEE the time in game.

If anyone could help me with this I'd greatly appreciate it. i was hoping I'd be able to say hi first in another area but I can't seem to locate a newcomer thread so having to do it here. Sorry if i am being rude by asking for something on my first post.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Sun Jul 31, 2011 11:56 am    Post subject: Reply with quote

In CE's scripting engine you can create a timer and inside the onTick callback just read your current health and add some too it.

Code:


local f = createForm( true );
local t = createTimer( f, true );
timer_setInterval( t, 1000 );

timer_onTimer( t, function( )
   -- read health here..
   -- add some value to it..
   -- write health back..
end );


You can create the timer without a form if you want as well, but then you are responsible for deleting it yourself.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Captanblue
How do I cheat?
Reputation: 0

Joined: 31 Jul 2011
Posts: 9

PostPosted: Sun Jul 31, 2011 1:13 pm    Post subject: Reply with quote

hooo boy this is a bit more complicated than I thought it would be. I only just figured out how to find static pointers manually (never could get pointer scanner to work). is there a tutorial that may shed some more light on this? I did the cheat engine tutorial but it didn't really help much Mad

Or maybe you might be able to help still. Say I found an address with my hp in it. How would I go about adding that to your code then?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Sun Jul 31, 2011 3:08 pm    Post subject: Reply with quote

If you have the address, you can use one of the functions to read from the games memory, then write back to it. Depending on what type of value you are dealing with. For example, if the health value is an integer (4 bytes) you can read it like this:

Code:
local health = readInteger( 0x12345678 );
health = health + 10;
writeInteger( 0x12345678, health );


Just add that chunk inside the timer stuff above. Change the address and look into main.lua for the other functions if you are unsure of anything.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Captanblue
How do I cheat?
Reputation: 0

Joined: 31 Jul 2011
Posts: 9

PostPosted: Mon Aug 01, 2011 4:42 pm    Post subject: Reply with quote

Okay, I've done the work and it works fine. However I have two more questions.. How would I make this work on a static address (like after I found the right pointers) AND how do I make it so it stop s adding to my health when it reaches max BUT still works even after I hit max. So like it doesn't actually shut down the program I made.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Mon Aug 01, 2011 6:58 pm    Post subject: Reply with quote

read- and writeInteger can also read addresses in string format
e.g: readInteger("[[baseaddress.exe+1234]+1234]+8");

as for the max, just first read the value and compare it to the current max health (max health is often stored near the current health)
If it's smaller, increase by 10, or to max if the difference is smaller

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Captanblue
How do I cheat?
Reputation: 0

Joined: 31 Jul 2011
Posts: 9

PostPosted: Wed Aug 10, 2011 4:54 pm    Post subject: Reply with quote

Hey, sorry it took me so long to get back to you on my progess. Let me just say that it worked like a charm... sort of. the only problem now is when my health goes to full it stops and then it wont regenerate after being hit. I'm using an "if than" statement so I figured it my just be reaching the end and stopping there. is there a way to make it so that it loops indefinitely?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Wed Aug 10, 2011 5:18 pm    Post subject: Reply with quote

with the timer you can do that.
Each time check if the current health is lower than the max health

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Captanblue
How do I cheat?
Reputation: 0

Joined: 31 Jul 2011
Posts: 9

PostPosted: Wed Aug 10, 2011 5:58 pm    Post subject: Reply with quote

well I've tried doing that but it stops once my health is full. I just use a simple if than statement too, not sure what I am doing wrong

This is the stuff I typed in

local f = createForm( true );
local t = createTimer( f, true );
timer_setInterval( t, 1000 );
local health = readFloat( 0x188395FC);

timer_onTimer( t, function()
if health < 6 then
health = health + 6*.01;
writeFloat( 0x188395FC, health );
else
health = 54356 -- added this in just because, had no real reason for it
end
end );



But anyway, I made it so it would see if my health was lower than what it should be, add health, and then that's it. But it stops after my health is full and doesn't regen anymore

EDIT:

I JUST figured out what I did wrong. I had to add in when the program read from the adress in order to get what I wanted. here's my new script that I found works

local f = createForm( true );
local t = createTimer( f, true );
timer_setInterval( t, 1000 );
local health = readFloat( 0x19482894);

timer_onTimer( t, function()
local health = readFloat( 0x19482894);
if health < 6 then
health = health + 6*.01;
writeFloat( 0x19482894, health );
else
health = 54356 --
end
end );

I feel kinda silly for messing that up for so long. Thanks again for the help!


Last edited by Captanblue on Wed Aug 10, 2011 6:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Wed Aug 10, 2011 6:14 pm    Post subject: Reply with quote

move the readFloat line where you get the current health to the start of the timer function (that is under the timer_ontimer line)

I'm currently not behind a real comp so I can't copy/paste a fixed version but i hope you get it)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Captanblue
How do I cheat?
Reputation: 0

Joined: 31 Jul 2011
Posts: 9

PostPosted: Wed Aug 10, 2011 6:29 pm    Post subject: Reply with quote

Yeah just figured it out. thanks again Smile
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