Page 1 of 1

script/code writing help

Posted: Wed Aug 24, 2022 11:18 pm
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 ...


Re: script/code writing help

Posted: Thu Aug 25, 2022 1:10 am
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

Re: script/code writing help

Posted: Thu Aug 25, 2022 2:44 pm
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.

Re: script/code writing help

Posted: Thu Aug 25, 2022 5:28 pm
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


Re: script/code writing help

Posted: Thu Aug 25, 2022 5:36 pm
by pepePP
nvm it didnt work how I wanted it to. Ill just try the first code you sent. thx again

Re: script/code writing help

Posted: Sat Aug 27, 2022 4:58 am
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 :)

Re: script/code writing help

Posted: Fri Nov 18, 2022 11:47 pm
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

Re: script/code writing help

Posted: Sat Nov 19, 2022 12:39 am
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