script/code writing help

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
pepePP
Noobzor
Noobzor
Posts: 6
Joined: Sun Aug 21, 2022 6:27 pm
Reputation: 0

script/code writing help

Post by pepePP »

So ive been making a few simple cheattables for myself, but I came across a problem, or should I say that im just too lazy:)
So in the game there are a lot of enemy types, meaning tons of enemy hp values.(its a 4v4 turnbased game) I always use the same 4 characters so its easier to put in the script and not change everytime.but now every game I play theres different enemy hp values so I wanted to ask if theres a way to write the code a little simpler and not add a label and cmp for every value.

I thought about putting all under one label:

ohk:
cmp DWORD PTR [rcx+1C],(float)99
cmp DWORD PTR [rcx+1C],(float)172
cmp ...


DrummerIX
Expert Cheater
Expert Cheater
Posts: 2885
Joined: Wed Mar 22, 2017 6:15 pm
Reputation: 0

Re: script/code writing help

Post by DrummerIX »

You have 2 options:

code for the least amount of options by trying to do the opposite (code for allies instead of enemies)

use a loop with some local variables with all the values you need to check for

panraven
Table Makers
Table Makers
Posts: 121
Joined: Fri Mar 03, 2017 12:03 am
Reputation: 108

Re: script/code writing help

Post by panraven »

It can be slightly simplify like this, note the last j* before ohk:

Code: Select all

cmp   dword ptr[rcx+10],(float)105
je    ohk
cmp   dword ptr[rcx+10],(float)104
je    ohk
cmp   dword ptr[rcx+10],(float)103
je    ohk
... 
cmp   dword ptr[rcx+10],(float)102
jne   nochange
ohk:
mov   dword ptr[rcx+10],0 /// or mov dword ptr[rcx+10],(float)1
jmp   return
nochange:
movss  [rcx+10],xmm1
jmp   return
...
You can also use a 'loop' as suggested by DrummerIX ; but using lua loop to generate aa code instead may save some aa management works:

Code: Select all

{$lua}
local codes = {}
for numf in ('105.1/105.2/105.3/105.4/105.5/105.6/105.7/105.8/105.9'):gmatch'[.%d]+'do
  codes[1+#codes] = string.format([[
cmp   dword ptr[rcx+10],(float)%s
je    ohk
  ]],numf)
end
return table.concat(codes,'\n')
{$asm}
cmp   dword ptr[rcx+10],(float)102
jne   nochange
ohk:
mov   dword ptr[rcx+10],0 /// or mov dword ptr[rcx+10],(float)1
jmp   return
nochange:
movss  [rcx+10],xmm1
jmp   return
...
There may be typo, and check the code if it compile, especial check if the jmps are ok.
Hope you get the idea.

pepePP
Noobzor
Noobzor
Posts: 6
Joined: Sun Aug 21, 2022 6:27 pm
Reputation: 0

Re: script/code writing help

Post by pepePP »

Im still a noob, so I have no idea what is going on in your second script xD. thx for the first code tho, now I know how to simplify it when there are tons of enemy HP's. but now I tried to do what Drummer said and I dont know if its right cos it doesnt set enemy hp to 0. I get the idea behind it tho.
-set my HP values to "1000" and everything else in that instruction(enemies) to 0

here is what I came up with but setting the enemies to 0 didnt seem to work. help


pepePP
Noobzor
Noobzor
Posts: 6
Joined: Sun Aug 21, 2022 6:27 pm
Reputation: 0

Re: script/code writing help

Post by pepePP »

nvm it didnt work how I wanted it to. Ill just try the first code you sent. thx again

User avatar
SunBeam
Administration
Administration
Posts: 4702
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4285

Re: script/code writing help

Post by SunBeam »

I would suggest thinking outside the box. You will eventually need to upgrade your thinking, remove those horse goggles and set out your goals. I'd think it like this: "rather than wasting time to do it for each type -- if I even know what that means -- I would find a common denominator and pick on that". So I'd compare the structure of a character of mine's health against that of an enemy's health. Find out a bool or dword that is used by the Engine to say "hey, this is a player character == 0; this is an enemy character == 1". Instead of looping through tens of types, I'd do a "cmp [rcx+offset],0/1" to determine player vs. enemy. But that's just me :)

pepePP
Noobzor
Noobzor
Posts: 6
Joined: Sun Aug 21, 2022 6:27 pm
Reputation: 0

Re: script/code writing help

Post by pepePP »

SunBeam wrote:
Sat Aug 27, 2022 4:58 am
I would suggest thinking outside the box. You will eventually need to upgrade your thinking, remove those horse goggles and set out your goals. I'd think it like this: "rather than wasting time to do it for each type -- if I even know what that means -- I would find a common denominator and pick on that". So I'd compare the structure of a character of mine's health against that of an enemy's health. Find out a bool or dword that is used by the Engine to say "hey, this is a player character == 0; this is an enemy character == 1". Instead of looping through tens of types, I'd do a "cmp [rcx+offset],0/1" to determine player vs. enemy. But that's just me :)
sadly im not as skilled as you are when it comes to scripting. Im noob

User avatar
RTX_XXXX
Expert Cheater
Expert Cheater
Posts: 124
Joined: Thu Sep 24, 2020 6:02 pm
Reputation: 172

Re: script/code writing help

Post by RTX_XXXX »

Who has the fking 0 damage in this game? :shock: you just say the machine : ( dude only jump to HP ), this mean dmg part is completely useless! other parts r also a mess, try to use dissect data/structure to find some diff offset's values

Post Reply

Who is online

Users browsing this forum: No registered users