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 


tyring to make a script disable itself

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

Joined: 10 Jan 2020
Posts: 5

PostPosted: Sat Jan 11, 2020 7:04 pm    Post subject: tyring to make a script disable itself Reply with quote

Hello. I am not new to CE or hacking for that matter, but i`ve just recently began to try scripting. The game is Saints Row IV and I`ve made a very simple instakill script, but on some entities it glitches out (if you instakill a warden, but fail to do a promt that appears soon after, he will stay in a state of 0 health but alive, with no way to kill him). I just made this script to change the health when you hit him to a fixed 10hp. the problem is, if more than one bullet hit him, meaning if his health turns to 0, he will enter the invincible state.
So i was wondering if there was a way to make the script disable iself, after checking if the enemy has the correct amout of health points (10 in this case).

If you know of a way to make it easier to do, please feel free to comment it and i will try it out.

TL;DR: need help ajusting the script to disable iself after it changes the enemies health


Code:
[ENABLE]

aobscanmodule(INJECT,SaintsRowIV.exe,F3 0F 11 86 20 1E 00 00 F3 0F 10 86) // should be unique
alloc(newmem,$1000)

label(code)
label(return)
label(kill)
newmem:

code:
  cmp [esi+00001C78],0 //check if its a bot or player
  je kill
  movss [esi+00001E20],xmm0 //remove health from player after taking damage
  jmp return

kill:
  mov [esi+00001E20],10 //make enemy health 10
  jmp return

INJECT:
  jmp newmem
  nop 3
return:
registersymbol(INJECT)

[DISABLE]

INJECT:
  db F3 0F 11 86 20 1E 00 00

unregistersymbol(INJECT)
dealloc(newmem)
[/code]
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Sat Jan 11, 2020 10:18 pm    Post subject: Reply with quote

You might be better off looking for some value that tells you what type of enemy you're looking at- similar to what you're doing for bot vs player.

Would it be fine to change it to 10 only if it's more than 10?
Code:
alloc(health_max,4)

newmem:
code:
  cmp [esi+00001C78],0
  jne short exit
  ucomiss xmm0,[health_max]
  jbe short exit
  movss xmm0,[health_max]
exit:
  movss [esi+00001E20],xmm0
  jmp return

health_max:
  dd (float)10.0

p.s.: that 10 in your code is an integer. As a float (what [esi+1e20] is), it would be some insignificantly small number.

_________________
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
YUU429
How do I cheat?
Reputation: 0

Joined: 10 Jan 2020
Posts: 5

PostPosted: Sun Jan 12, 2020 11:26 am    Post subject: Reply with quote

ParkourPenguin wrote:
You might be better off looking for some value that tells you what type of enemy you're looking at- similar to what you're doing for bot vs player.

Would it be fine to change it to 10 only if it's more than 10?

p.s.: that 10 in your code is an integer. As a float (what [esi+1e20] is), it would be some insignificantly small number.



Hi, thank you for the help, but where exactly should i add your code?
should i create a new script (with only that) or should i replace the 'aob injection code' part with what you made?
if i leave it to run in its own script it tells me the enable part and disable part are missing. Should i just copy this
Code:
[ENABLE]

aobscanmodule(INJECT,SaintsRowIV.exe,F3 0F 11 86 20 1E 00 00 F3 0F 10 86) // should be unique
alloc(newmem,$1000)

label(code)
label(return)
//------------------- Your code here as-is
[DISABLE]

INJECT:
  db F3 0F 11 86 20 1E 00 00

unregistersymbol(INJECT)
dealloc(newmem)

to be able to enable/disable it?
and lastly, for the type of enemy im looking at, from what i can tell, there where about 6 entities that can take damage (veicles, bosses, wardens, players, 'homies' which are allies, and the ai). the part where i found if they where the computer or the player (health values where there too) i couldnt find anything related to a specific type of entity. The veicles, for example, dont show as running the same 'damage' part of the code (movss [esi+00001E20],xmm0) and i could not find a health variable for them.

Ive atteched the dissected data structures plus a screen shot of the health variables.

Sorry for any inconvenience i may have caused.

thank you again!


edit: i cant post the attachment for the dissect table, sorry! If you want it, we can figure out a way for me to send the CSX file



Screenshot (120).png
 Description:
 Filesize:  207.77 KB
 Viewed:  2844 Time(s)

Screenshot (120).png


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Sun Jan 12, 2020 3:10 pm    Post subject: Reply with quote

Don't just copy/paste everything. Try to read the script and figure out a general idea of what each thing does.
  • Put the health_max alloc under the newmem alloc.
  • Delete label(kill) and replace it with label(exit)
  • Replace the code in newmem (includes code under both labels code and kill) with the code I posted.
  • The health_max code can be placed anywhere you want (I put it just under the code in newmem).
  • The four lines from INJECT: to return: make the game run the code in newmem, so leave those in.
  • I don't know why CE's template puts the registersymbol at the end of the enable section (I'd put it after allocs/labels), but leave it in regardless of where you decide to put it.
  • Also, since you're allocating more memory, you should deallocate it in the disable section.

I don't know how much I can help with the structure dissect window. Look for a difference between wardens and regular enemies that doesn't change. 1DD4, 1DF0, 1DF8, 1E00, and 1E0C are all possibilities.
It looks like 1E10 / 1E14 could be related to max health. Perhaps you could use that? Assuming no regular enemies have that much health, of course.

_________________
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
YUU429
How do I cheat?
Reputation: 0

Joined: 10 Jan 2020
Posts: 5

PostPosted: Sun Jan 12, 2020 5:42 pm    Post subject: Reply with quote

ok, thank you very much. It seems to work with the warden i've tried it on!
Do you know anywhere i could learn assembly/script writing? I dont fully understand it yet, and i still use the AOB Injection template for everything that i do.
Thanks again!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Sun Jan 12, 2020 10:34 pm    Post subject: Reply with quote

Not really. There's some information on the CE wiki as well as random tutorials scattered across YouTube and these forums.

If you're referring to x86/x64 specifically, search for something like "x86 tutorial" and you may find something worthwhile. Just be cautious of what you read- people that don't understand much can give bad information. Material from Intel / AMD is probably good but might be a little advanced for a beginner (e.g. their software developer's guides/manuals are great but intricate).

_________________
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
YUU429
How do I cheat?
Reputation: 0

Joined: 10 Jan 2020
Posts: 5

PostPosted: Mon Jan 13, 2020 2:13 pm    Post subject: Reply with quote

ok, thank you, i will try doing just that
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