GTA2 memory addresses

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

ped ID is ped+512. There's a show ped/car ID option in gta2manager. I wrote a script that reads the health value of each ped and writes it to the ped ID.

Image

Instant gang has 50 health
Dummy peds have 50 health
Dummy drivers have 100
National guards have 50
Jeep blokes that chase you have 250 health. Most jeeps just have normal defenseless dummy peds in them with 100 health.
Police have 100
Roadblock FBI have 200
FBI has 250
SWAT has 400
User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: GTA2 memory addresses

Post by Pyro »

Impressive, nice work!

Maybe with this we can make 'proper' strength SWAT guys of our own.

One thing - on the second picture, all the peds, gang members and player show '666', what's that about?
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

Yes we can create peds as strong or stronger than swat.
Pyro wrote:One thing - on the second picture, all the peds, gang members and player show '666', what's that about?
[sm-evil] Ignore that! [sm-evil]
User avatar
Cuban-Pete
Immortal
Posts: 909
Joined: 29 Jan 2010, 15:03
GH nick: Cuban-Pete

Re: GTA2 memory addresses

Post by Cuban-Pete »

Nice work. I like (little) hacks like that. What is the code that you used? I perhaps want to try it myself.
"Mmmm, your eyes are so beautiful."
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

Image

The screenshot is just for fun. The attached code displays ped's real health but you must tick show PED IDs in gta2manager debug tab. Cars will just show their normal ID since I haven't added car health/ID changing yet.

The player needs to have a unique ID or the game will treat every ped as if friendly fire is disabled. You can still kill them with electrogun or explosions just like instant gang. I don't update the player ID in this example but I could set it to 1000+actual player health, if you wanted to display it but still keep a unique ID.
healthtest.7z
(3.54 KiB) Downloaded 1713 times
[mis]//Sektor GTAMP.com 2014
//Do whatever you want with this code
//healthtest.scr
//ste.gmp
//ste.sty

PLAYER_PED p = ( 149.0 , 195.0 , 255.0 ) 10 270
PLAYER_PED p2 = ( 150.0 , 195.0 , 255.0 ) 10 180
PLAYER_PED p3 = ( 151.0 , 195.0 , 255.0 ) 10 180
PLAYER_PED p4 = ( 152.0 , 195.0 , 255.0 ) 10 180
PLAYER_PED p5 = ( 153.0 , 195.0 , 255.0 ) 10 180
PLAYER_PED p6 = ( 154.0 , 195.0 , 255.0 ) 10 180

COUNTER idaddress
COUNTER healthaddress
COUNTER healthvalue
COUNTER true = 1
COUNTER charpointer = 660 // if you want to ignore player 2-6, set to 3960 ( 6 x 660 )
COUNTER cars = 0
CHAR_DATA c
CAR_DATA p1car

GENERATOR instantgang = ( 149.0 , 194.0 ) 0 COLLECT_40 0 0
CAR_DATA parked = ( 149.0 , 196.0 ) 0 0 BUG

MAP_ZONE cityinfo = (600, 300, 200, 100, 200, 100, 100, 50, 200, 300, 100)
MAP_ZONE s08 = (100, 500, 200, 100, 250, 0, 0, 0, 999, 100, 100)
MAP_ZONE m16 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m17 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m23 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m24 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m25 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m26 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m20 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m21 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m22 = (600, 400, 100, 0, 500, 0, 0, 100, 900, 0, 200)
MAP_ZONE m19 = (100, 0, 0, 0, 500, 0, 0, 100, 1000, 0, 1000)
MAP_ZONE s07 = (100, 500, 200, 100, 500, 0, 0, 100, 900, 0, 100)
MAP_ZONE s06 = (100, 500, 200, 100, 500, 0, 0, 0, 1000, 0, 100)
MAP_ZONE m18 = (100, 300, 0, 0, 500, 0, 0, 100, 900, 0, 300)
MAP_ZONE s04 = (100, 500, 200, 100, 500, 0, 0, 0, 1000, 0, 100)
SET_GANG_INFO (redngang, 5, PISTOL, MACHINE_GUN, MOLOTOV, 4, 47.50, 49.50, 255.00, 1, PICKUP, 3)
SET_GANG_INFO (sciegang, 7, PISTOL, MACHINE_GUN, FLAME_THROWER, 5, 211.50, 219.50, 255.00, 1, STRATOSB, 10)
SET_GANG_INFO (zaibgang, 8, PISTOL, DUAL_PISTOL, MACHINE_GUN, 3, 199.00, 25.50, 255.00, 1, VTYPE, 2)
SET_GANG_INFO (almagang, 22, NO_WEAPON, NO_WEAPON, NO_WEAPON, 3, 224.50, 20.50, 255.00, 0, VTYPE, 2)
SET_GANG_INFO (poligang, 0, PISTOL, PISTOL, PISTOL, 3, 224.50, 20.50, 255.00, 0, VTYPE, 2)

LEVELSTART

//show ped and car ID
COUNTER showpedid = 6204833
COUNTER one = 1
CHANGE_GANG_CHAR_RESPECT (showpedid, one, 111)

SWITCH_GENERATOR ( instantgang, on )

DECLARE_POLICELEVEL (6)
SET_STATION_INFO (trak01, 4, 0, 0)
SET_AMBIENT_LEVEL ( 0.3 , 0 )
SET_SHADING_LEVEL ( 27 )

WHILE_EXEC ( true = 1 )

GIVE_WEAPON (p,ROCKET_LAUNCHER)
GIVE_WEAPON (p,ELECTRO_GUN)
GIVE_WEAPON (p,FLAME_THROWER)
GIVE_WEAPON (p,MOLOTOV)
GIVE_WEAPON (p,SILENCED_MACHINE_GUN)

SET c = ( p + charpointer )

SET healthaddress=(c+534) //health
CHANGE_GANG_CHAR_RESPECT (healthaddress, healthvalue, 102)
SET idaddress=(c+512) //ID
CHANGE_GANG_CHAR_RESPECT (idaddress, healthvalue, 112)

SET charpointer = ( charpointer + 660 )

IF ( charpointer > 32340 ) // 49 x 660 (each character has a struct of 660 bytes)
SET charpointer = 660 // If you want to ignore player 2-6, set to 3960 ( 6 x 660 )
ENDIF

ENDWHILE

LEVELEND[/mis]
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

byte cardamage=carstruct+75h (0 = 0% damage, 125 = 100% damage). You can make wrecks drivable by changing this.
word carid=carstruct+6Ch

This will change the car ID to the car damage
[mis]
COUNTER cardamageaddress
COUNTER cardamagevalue
COUNTER caridaddress
SET cardamageaddress=(p1car+117)
CHANGE_GANG_CHAR_RESPECT (cardamageaddress, cardamagevalue, 104)
SET caridaddress=(p1car+108)
CHANGE_GANG_CHAR_RESPECT (caridaddress, cardamagevalue, 112)[/mis]
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: GTA2 memory addresses

Post by elypter »

does anyone know the address for the player x y and z?
yur sa'nok ngeyä
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

It's in the first post if you can decipher it.

http://gtamp.com/maps/superman.7z probably has script example
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: GTA2 memory addresses

Post by elypter »

ah its right there. i overread it somehow becasue of "angle".
now i just need fast reload. i'll check if its ar p1+21Ch.

btw: the superman script is fun and you can even fly out of the map
yur sa'nok ngeyä
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: GTA2 memory addresses

Post by elypter »

additional info for the player coordinates: they have to be divided by 16384 in order to match the gta2 coordinate grid.
yur sa'nok ngeyä
robotanarchy
Car Jacker
Car Jacker
Posts: 48
Joined: 22 Apr 2013, 22:48
GH nick: robotanarchy
Contact:

Re: GTA2 memory addresses

Post by robotanarchy »

Here are the addresses I'm using in my mod: https://github.com/Bytewerk/gta2-hacker ... ddresses.h

This includes a rumble byte, which I have documented here.

If someone could find good pointers to the displayed text (WASTED!, Shotgun!, Player xy left the game!), it would be really helpful. I've started looking for these, see the comments in the file.

EDIT: I've managed to permanently show the ESC text and modify that, it's all documented here: http://git.io/g2hr-esc-text
Last edited by robotanarchy on 07 Aug 2015, 09:46, edited 1 time in total.
GTA2 Hacker's Remix ...also check out my blog!
User avatar
Cuban-Pete
Immortal
Posts: 909
Joined: 29 Jan 2010, 15:03
GH nick: Cuban-Pete

Re: GTA2 memory addresses

Post by Cuban-Pete »

Do we also got the memory addresses for the head lights, alarm, dents etc. for the car you are driving at the moment (in the game)?
"Mmmm, your eyes are so beautiful."
Jones
Psycho
Psycho
Posts: 51
Joined: 08 Aug 2012, 21:25

Re: GTA2 memory addresses

Post by Jones »

After some digging with IDA Disassembler in the "source code" :geek: :
coplevel
coplevel = peek dword [p1 + 20Ah] 522
600 = level 1
1600
3000
5000
8000
12000 = level 6

threat reaction
reaction= peek dword [p1 + 28Ch ] 652
0 NO_REACTION
1 POLICE maybe? or same as 2
2 REACT_AS_NORMAL
3 RUN_AWAY

occupation
occupation= peek dword [p1 + 240h] 576
22 elvis?
51 no_occupation
3 dummy
8 walking cop
35 instant gang
23 medic

camera
camera x=peek dword [p1 + 1ACh] 428
camera y=peek dword [p1 + 1B0h] 432
camera z=peek dword [p1 + 1B4h] 436

char remap value
char remap value=peek byte [p1 + 244h] 580
0 police
10 red
11 green
Last edited by Jones on 05 May 2015, 20:20, edited 1 time in total.
robotanarchy
Car Jacker
Car Jacker
Posts: 48
Joined: 22 Apr 2013, 22:48
GH nick: robotanarchy
Contact:

Re: GTA2 memory addresses

Post by robotanarchy »

Good findings Jones, I'll definatelly try out the camera x,y,z addresses for my splitscreen mod!
GTA2 Hacker's Remix ...also check out my blog!
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

Thanks Jones. I might as well complete the occupation list.

The occupations listed in the compiler:

00 PLAYER
01 EMPTY
03 DUMMY
05 DRIVER
14 PSYCHO
15 MUGGER
16 CARTHIEF
17 BANK_ROBBER
18 CRIMINAL
22 ELVIS
24 POLICE
25 SWAT
26 FBI
27 ARMY
28 GUARD
32 GUARD_AGAINST_PLAYER
33 CRIMINAL_TYPE1
34 CRIMINAL_TYPE2
35 SPECIAL_GROUP_MEMBER
36 TANK_DRIVER
38 FIREMAN
39 ROAD_BLOCK_TANK_MAN
41 DRONE
43 STAND_STILL_BLOKE
44 ELVIS_LEADER
45 REFUGEES
46 ANY_LAW_ENFORCEMENT
47 ANY_EMERGENCY_SERVICE_MAN
48 ANY_GANG_MEMBER
49 ANY_ELVIS
51 NO_OCCUPATION

This list below isn't in the official compiler, so can't be set using SET_CHAR_OCCUPATION command. You might be able to set them by changing the memory or patching the SCR files or making your own compiler. I made the names up based on some quick observations. I knew which peds had which occupation number because I put the number on their heads instead of their ID number.
04 wait for bus ped?
07 walk anticlockwise dummy?
08 walking cop and sometimes wait for bus dummy?
09 some peds that get off the train. Most train peds just use DUMMY 3.
10 driving ped, 10 when I throw them out of car and then 11 when they run away.
19 seems to be a walking gang member, if they have a gun they walk around with it. Prison gang doesn't have guns but they still have some 19 occupation.
23 medic
29 maybe walking cops that start off walking anticlockwise.
42 gang car driver, will attack you if you steal their car
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: GTA2 memory addresses

Post by BenMillard »

That list is now linked in my Character AI tutorial.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

pedstruct + 364 (0x16C) = pointer to the ped's current car. It will be 0 if they are on foot.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

0x5E8108 = frame count address = frame count value since the game started

[mis]
// example script to show how many frames WHILE takes compared to WHILE_EXEC. Add more DO_NOWT and the frame count will increase.
COUNTER framepointer = 6193416
COUNTER frameaddress
COUNTER frame
ONSCREEN_COUNTER time

LEVELSTART

WHILE (true=1)
ADD_ONSCREEN_COUNTER (time,frame)
DO_NOWT
DO_NOWT
DO_NOWT
DO_NOWT
DO_NOWT
CHANGE_GANG_CHAR_RESPECT (framepointer, frameaddress, 104)
CHANGE_GANG_CHAR_RESPECT (frameaddress, frame, 102)
SET true=0
ENDWHILE

LEVELEND
[/mis]
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: GTA2 memory addresses

Post by T.M. »

Sektor, Is there some hidden meaning for those 5x DO_NOWT commands?

Does the first post have all the known hacks? Would be nice if there was a single paper for all the knowledge we have so far!

I would want so much to wrap those messy hacks into one function call, such as: frame = get_framecount(). I thought this could be done in JavaScript, so you write the new style code there and "compile" it into MIS file which contains all those ugly hacks and temporary variables etc. When it is made in JS, anyone could tamper with the code and develop further easily without needing to dl any tools, also insta cross-platform.

Is there something against implementing this? I havent been around for long time so maybe things changed or i simply forgot something :)
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor »

The only reason for the 5x DO_NOWT is because I copied it from an example that compares the speed/frames of WHILE and WHILE_EXEC.

It's not the best example or best practical use for reading the framecount. I used it for a pseudo random number example too but even that wasn't needed.

I don't think I added everything to the first post yet. Your idea could be useful. I've only seen a few other people even attempt to use these memory addresses but making it easier might attract some more scripters.
Post Reply