Page 1 of 1

No delay for weapons - is this scriptable?

Posted: 05 May 2013, 10:33
by PacMani
Right after the 2-byte ammo value, there's the 1-byte delay in frames.
Removing the code setting this one up gives these results.


Can this be scripted :?: I just played around with CheatEngine for that video (to demonstrate what it can do for a presentation).

[sm-wink]<--dafuq

Re: No delay for weapons - is this scriptable?

Posted: 05 May 2013, 10:41
by Sektor
Nice. I've always wanted to do that. It might require vike to change one of the commands to support peak and poke. Hopefully this motivates him to do it sooner.

I asked him to change CHECK_RESPECT_GREATER ( playername , gangname , requiredlevel ) to change/read bytes if the requiredlevel is 1337 or 31337.

Re: No delay for weapons - is this scriptable?

Posted: 05 May 2013, 11:29
by PacMani
Cool thing! I have to get into scripting soon I think, doesn't look too hard, just too lazy to set up tools.

Btw, sometimes GTA2 crashes when shooting Rocket Launchers with 0 delay (appears to happen randomly, not according to the number of missiles flying or explosions seen), I changed the opcode to set a delay of 1 and it never crashed anymore.

Re: No delay for weapons - is this scriptable?

Posted: 05 May 2013, 23:36
by Cuban-Pete
OVERLORD READY! :)

Nice hacking!

Re: No delay for weapons - is this scriptable?

Posted: 06 May 2013, 15:46
by PacMani
BTW, a value of 65535 (-1 or 0xFFFF) gives K.F. ammo, can't that be set in scripts? I always saw ammos being "freezed" to 99(0)

Re: No delay for weapons - is this scriptable?

Posted: 06 May 2013, 16:00
by Sektor
If you give KF ammo the proper way then you can't switch weapon. I still haven't checked if this can be done just with script and the current exe.

Re: No delay for weapons - is this scriptable?

Posted: 08 May 2013, 15:42
by PacMani
Oh lol thats funny, it works flawlessy when just manipulating the ammo value with CheatEngine, you can switch between every weapon with K.F. ammo.

Re: No delay for weapons - is this scriptable?

Posted: 09 May 2013, 04:36
by Sektor
I'm surprised more people haven't commented on this. It's one of my all time favourite GTA2 videos.

Re: No delay for weapons - is this scriptable?

Posted: 09 May 2013, 07:55
by PacMani
Oh well, I don't think it's too special. It was fun combining this with indestructible cars, you could throw as many rocket launchers or whatever on them and they didn't explode :)

Re: No delay for weapons - is this scriptable?

Posted: 09 May 2013, 08:22
by T.M.
Sektor wrote:I asked him to change CHECK_RESPECT_GREATER ( playername , gangname , requiredlevel ) to change/read bytes if the requiredlevel is 1337 or 31337.
Will that change the scripts behaviour which use that function already?
Sektor wrote:I'm surprised more people haven't commented on this. It's one of my all time favourite GTA2 videos.
Its ok, i dont comment much on these anyways... here i am, as requested. though.

Re: No delay for weapons - is this scriptable?

Posted: 10 May 2013, 21:59
by BenMillard
Liked and added to my GTA Modding Tests playlist.

YouTube URLs just got way, way longer?

Re: No delay for weapons - is this scriptable?

Posted: 11 May 2013, 04:07
by Sektor
T.M. wrote:Will that change the scripts behaviour which use that function already?
Nothing uses that command but it won't matter if they do since it will act like normal if the respect value is 100 or under. Anything over 100 is not sensible, so Vike can add his own code there.

Re: No delay for weapons - is this scriptable?

Posted: 11 May 2013, 20:08
by T.M.
Sektor wrote:
T.M. wrote:Will that change the scripts behaviour which use that function already?
Nothing uses that command but it won't matter if they do since it will act like normal if the respect value is 100 or under. Anything over 100 is not sensible, so Vike can add his own code there.
Oh, but the function is still working in GTA2?

Why not use CHECK_RESPECT_EQUAL() instead? Somewhat more intuitive to me, than using "greater".

Re: No delay for weapons - is this scriptable?

Posted: 12 May 2013, 06:08
by Vike the Hube
PacMani what exact address did you use for this?

Re: No delay for weapons - is this scriptable?

Posted: 14 May 2013, 17:17
by PacMani
The delay is the unsigned byte after the ammo which is a short int in every weapon info structure. There's no fixed address for that or some kind of pointer I can give you right now (I always searched for ammo and added the byte after it).
E.g.
... 04 01 31 00 00 00 ...
Here I got 26 rocket launchers (0x0104 = 260 / 10) and a delay of 49 frames (0x31) until I can shoot it again. The delay may also be a short int but I never had a delay bigger than 255 frames, but stuff afterwards was also always 0x00.

E.g. like here, the weapon info structures are outlined in red, the ammo in green and the delay in blue.
The weapon info array is filled up in the order you got the weapons, e.g. if you got the rocket launcher first, he will be the first one in the array, and if you got a pistol afterwards, it will be the second entry in the array. The byte in the third row in each weapon info structure right after the yellow line also seems to be an order index or something (always counting up, 0x85E4, 0x85F4, 0x8604, 0x8614), don't ask me!^^ There's also a 0x00 and 0x01 flag for weapons which is set for weapons which are fired by tapping Ctrl and not holding it (like the Tank Rocket Launchers), freezing it to 0 or removing the code setting it has no effect though.
Image

Re: No delay for weapons - is this scriptable?

Posted: 18 May 2013, 11:18
by Sektor
p + 368 seems to contain the address of the player's 1st weapon ammo but I need a PEEK command to copy that address into a counter or some way to read a value rather than a pointer.

I think the code to remove the delay for the 1st weapon would look something like this once Vike adds PEEK and POKE.

COUNTER ammopointer
COUNTER ammoaddress
COUNTER reload

SET ammopointer = (p + 368)
CHECK_RESPECT_EQUAL (ammopointer, ammoaddress, 1337) // peek (for this example 4 bytes would need to be read into a counter, perhaps 104 for 4 bytes would make more sense than 1337).
SET reload = (ammoaddress + 2)
CHECK_RESPECT_EQUAL (reload, 0, 31337) // poke

Re: No delay for weapons - is this scriptable?

Posted: 18 May 2013, 18:17
by PacMani
Wow, you guys could really need a "preprocessor" e.g. translator program for converting new "high level GTA code" to those low level workaround commands :D

Re: No delay for weapons - is this scriptable?

Posted: 19 May 2013, 08:28
by T.M.
PacMani wrote:Wow, you guys could really need a "preprocessor" e.g. translator program for converting new "high level GTA code" to those low level workaround commands :D
You read my thoughts.

I think that could be done by the custom compiler (which is work in progress, ETA 2019), which would have special functions with intuitive naming, which would generate that code.

Basically it could just display specific patterns of code as those function names, but in reality, the .mis code would still look hacky (if you dont use the custom compiler/scriptpad).

Some of the hacks could never be compressed as simple function names, for example if you use it in a loop.

I think you guys should start listing these hacks in some list of new functions, where anyone could just take them in their scripts. For each function, you would write own function name, in the style of old function names.

For the new custom compiler, Sektor's function definition could look something like this:
[mis]
// function name and parameters:
REMOVE_DELAY_FOR_CURRENT_WEAPON [
PLAYER_PED player1 // one parameter for each line for clarity.
]
// function body:
COUNTER p1ammopointer
COUNTER p1ammoaddress
COUNTER p1reload
SET p1ammopointer = (player1 + 368)
CHECK_RESPECT_EQUAL (p1ammopointer, p1ammoaddress, 1337) // peek
SET p1reload = (p1ammoaddress + 2)
CHECK_RESPECT_EQUAL (p1reload, 0, 31337) // poke

// if the function returns something, we would just type in the end:
// RETURN something
[/mis]
Usage:

Code: Select all

REMOVE_DELAY_FOR_CURRENT_WEAPON (P1)

Re: No delay for weapons - is this scriptable?

Posted: 19 May 2013, 16:19
by Cuban-Pete
Just wanted to drop by and say that this CheatEngine program is rather nice. Thanks for sharing.

Re: No delay for weapons - is this scriptable?

Posted: 20 May 2013, 18:25
by PacMani
oh no problem, its making me happy since a decade almost;D