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 


Writing a value if statement is met

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
tysman
Cheater
Reputation: 0

Joined: 06 Jan 2020
Posts: 28

PostPosted: Sat Sep 17, 2022 10:57 am    Post subject: Writing a value if statement is met Reply with quote

Hello I have a lua script inside of my assembly script for writing a health value if the value is equal. it seems to be writting but not using the timer or writing constantly

Code:

[ENABLE]

aobscanmodule(health,ROTTR.exe,66 0F 6E 40 28 0F 5B C0 0F 2F C1) // should be unique
alloc(newmem,$100,"ROTTR.exe"+231CEA)

label(code)
label(return)

newmem:
push rbx
mov rbx,["ROTTR.exe"+018DDE90]
cmp rbx,0
je code
mov rbx,[rbx+2A8]
cmp rbx,0
je code
lea rbx,[rbx+2C]
cmp rbx,0
je code
movss [rbx],xmm2
pop rbx

code:
  movd xmm0,[rax+28]
  jmp return

health:
  jmp newmem
return:
registersymbol(health)

{$lua}

health_display = readInteger('[["ROTTR.exe"+018DDE90]+2A8]+28')

h_timer = createTimer()
h_timer.setInterval(10)
h_timer.onTimer = function()
end

if(health_display >= 300)
then
writeInteger('[["ROTTR.exe"+018DDE90]+2A8]+28',300)
end

if(health_display >= 375)
then
writeInteger('[["ROTTR.exe"+018DDE90]+2A8]+28',375)
end

{$asm}

[DISABLE]

{$lua}

h_timer.destroy()

{$asm}

health:
  db 66 0F 6E 40 28

unregistersymbol(health)
dealloc(newmem)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sat Sep 17, 2022 11:24 am    Post subject: Reply with quote

I don't know why you have that code injection (xmm2 gets put into the value after display health. xmm2 contains max health or something ?)
Can't you do the writing of the value there ?


anyhow
Code:

[ENABLE]

aobscanmodule(health,ROTTR.exe,66 0F 6E 40 28 0F 5B C0 0F 2F C1) // should be unique
alloc(newmem,$100,"ROTTR.exe"+231CEA)

label(code)
label(return)

newmem:
push rbx
mov rbx,["ROTTR.exe"+018DDE90]
cmp rbx,0
je code
mov rbx,[rbx+2A8]
cmp rbx,0
je code
lea rbx,[rbx+2C]
cmp rbx,0
je code
movss [rbx],xmm2
pop rbx

code:
  movd xmm0,[rax+28]
  jmp return

health:
  jmp newmem
return:
registersymbol(health)

{$lua}
if syntaxcheck then return end
h_timer = createTimer()
h_timer.setInterval(10)
h_timer.onTimer = function()
  health_display = readInteger('[["ROTTR.exe"+018DDE90]+2A8]+28')

  if(health_display >= 300)
  then
    writeInteger('[["ROTTR.exe"+018DDE90]+2A8]+28',300)
  end

  if(health_display >= 375)
  then
    writeInteger('[["ROTTR.exe"+018DDE90]+2A8]+28',375)
  end
end


{$asm}

[DISABLE]

{$lua}
if syntaxcheck then return end
h_timer.destroy()

{$asm}

health:
  db 66 0F 6E 40 28

unregistersymbol(health)
dealloc(newmem)

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

Joined: 06 Jan 2020
Posts: 28

PostPosted: Sat Sep 17, 2022 12:01 pm    Post subject: Reply with quote

thanks that worked it seems to not be writing the 300 value when loading up an earlier save game. The assembly code above is for writing to current health which is a float and lua script is for writing to the display address which is an integer and the game isnt writing the xmm2 back to the display address fast enough. I ended up doing it this way instead
Code:

aobscanmodule(health,ROTTR.exe,66 0F 6E 40 28 0F 5B C0 0F 2F C1) // should be unique
alloc(newmem,$100,"ROTTR.exe"+231CEA)

label(code)
label(return)

newmem:
push rbx
mov rbx,["ROTTR.exe"+018DDE90]
cmp rbx,0
je code
mov rbx,[rbx+2A8]
cmp rbx,0
je code
lea rbx,[rbx+2C]
cmp rbx,0
je code
movss [rbx],xmm2
pop rbx

code:
  movd xmm0,[rax+28]
  jmp return

health:
  jmp newmem
return:
registersymbol(health)

{$lua}

h_timer = createTimer()
h_timer.setInterval(10)
h_timer.onTimer = function()
current_health = readFloat('[["ROTTR.exe"+018DDE90]+2A8]+2C')
writeInteger('[["ROTTR.exe"+018DDE90]+2A8]+28',current_health)
end

{$asm}

[DISABLE]

{$lua}

h_timer.destroy()

{$asm}

health:
  db 66 0F 6E 40 28

unregistersymbol(health)
dealloc(newmem)
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