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 


[req]making script for select unit health.
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Thu Nov 12, 2015 9:51 pm    Post subject: [req]making script for select unit health. Reply with quote

Hi.
Making script for select unit health is hard.
how make script for stronghold crusader 2 to weak unit, heal unit,super unit and reset unit.
please help me in making this scripts.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Nov 14, 2015 5:36 pm    Post subject: Reply with quote

Find a unit's health. Find out what access that health only when the unit is selected.
Hook that instruction to save a pointer to the unit's structure.

Add to that hook a check for a custom 0/1 variable. When 0, execute code as normal.
When 1, set unit's health to 9999 before the instruction would normally read the value.
Of course, set the custom variable back to 0 when done.

Then you set a hotkey to change your custom variable to 1 when desired.
Back to top
View user's profile Send private message
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Sun Nov 15, 2015 1:22 pm    Post subject: Reply with quote

Do you can show me the script for Reset unit(health) and heal unit(set to max)?
please.
Back to top
View user's profile Send private message
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Tue Nov 17, 2015 6:44 pm    Post subject: Reply with quote

One can not help me?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Tue Nov 17, 2015 7:01 pm    Post subject: Reply with quote

How to make a script:
http://forum.cheatengine.org/viewtopic.php?t=570083

Find an instruction that accesses health often enough and inject code there. Then, just move whatever value you want into the address. If you want to set a unit's health to max, you'll have to find out where that's stored if it's not constant. It's usually around the current health value, so simply browsing for it in the memory viewer can lead you to it.

_________________
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
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Tue Nov 17, 2015 7:45 pm    Post subject: Reply with quote

I would script like cheat happens options unit's.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Tue Nov 17, 2015 7:51 pm    Post subject: Reply with quote

I'm not sure I'm understanding you correctly, but if you're saying you want to make a trainer, then there's also a tutorial for that here:
http://forum.cheatengine.org/viewtopic.php?p=5576412

_________________
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
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Tue Nov 17, 2015 8:00 pm    Post subject: Reply with quote

Now,if I want to from weak unit's and super unit's mode to normal To go back to what should I do?
I cant good write english.sorry
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Tue Nov 17, 2015 9:21 pm    Post subject: Reply with quote

You could make hotkeys for everything using Lua.
Code:
healthAddr = 0x0040AD38

function disableHacks()
  -- code to disable hacks
  -- example:
  writeDouble(healthAddr,100)
end

function weakUnitHack()
  -- code to make a unit weak
  -- example:
  writeDouble(healthAddr,1)
end

function strongUnitHack()
  -- code to make a unit strong
  -- example:
  writeDouble(healthAddr,999999999)
end

createHotkey(disableHacks,VK_NUMPAD0)
createHotkey(weakUnitHack,VK_NUMPAD1)
createHotkey(strongUnitHack,VK_NUMPAD2)

_________________
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
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Tue Nov 17, 2015 9:44 pm    Post subject: Reply with quote

This lua It works.very thank you
other my question?
what about make script and address So that the when with number1 enable then Automatically disable?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Tue Nov 17, 2015 10:04 pm    Post subject: Reply with quote

You could use a timer to disable it after a certain amount of time has passed (for example 10 seconds):
Code:
function strongUnitHack()
  if strongT then
    strongT.destroy()
    strongT = nil
    disableHacks()
    return
  else
    strongT = createTimer(nil,true)
    strongT.Interval = 10000 --10 seconds
    strongT.OnTimer = strongUnitHack
  end

  -- code to make a unit strong
  -- example:
  writeDouble(healthAddr,999999999)
end

Do a similar thing for the function weakUnitHack(). Just name the timer variable something different (e.g. "weakT").

A side effect is that if you press the hotkey for this function again, it'll disable the hack. You can get around this by setting that hotkey's DelayBetweenActivate property to the same as the interval on the timer.

_________________
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
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Wed Nov 18, 2015 4:56 am    Post subject: Reply with quote

Do,You write the lua code that gets the entire to auto assembly?(i mean is how this lua code in auto assemly)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Wed Nov 18, 2015 9:49 am    Post subject: Reply with quote

All of that code was meant to go into the cheat table Lua script (Ctrl+Alt+L).

If you want to put it into an AA script, do something like this:
Code:
[ENABLE]
// asm code here
{$lua}
  -- Lua code here
{$asm}
// asm code here
[DISABLE]
// asm code here
{$lua}
  -- Lua code here
{$asm}
// asm code here


If you want to auto assemble something using Lua, then use the autoAssemble(String) function:
Code:
autoAssemble([[
// asm code here
// example:
globalalloc(newmem,1024)]])

_________________
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
sjl002
Master Cheater
Reputation: 0

Joined: 31 Aug 2013
Posts: 305

PostPosted: Wed Nov 18, 2015 10:06 pm    Post subject: Reply with quote

Thanks again.
for example lua script super unit What the difference with heal unit.
is meaning super unit mov unit health to max and freeze to max for one unit?(To be show script for this options)**
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Thu Nov 19, 2015 12:41 pm    Post subject: Reply with quote

Create a timer and freeze it with that:
Code:
function freezeUnitHealth()
  if freezeT then
    freezeT.destroy()
    freezeT = nil
    return
  else
    freezeT = createTimer(nil,true)
    freezeT.Interval = 10000 --10 seconds
    freezeT.OnTimer = freezeUnitHealth
  end

  local f = function()
    writeDouble(healthAddr,100)
  end
  local fT = createTimer(freezeT,true)
  fT.Interval = 50
  fT.OnTimer = f
end

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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