GTA2 memory addresses

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sun Jan 14, 2018 1:33 pm

Nobody not is found a method to create an object/car/character? Or call spawn like in GTA3/VC/SA

User avatar
Sektor
Boss
Boss
Posts: 1366
Joined: Tue Mar 04, 2008 6:51 am
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor » Sun Feb 11, 2018 2:04 pm

I don't know how to create objects, I can only move them around.

Here are the stats shown at the end of the level:

vehicles_hijacked: 0x5E3CC4, 0x50C;
auto_damage_cost: 0x5E3CC4, 0x52C;
civilians_run_down: 0x5E3CC4, 0x510;
civilians_murdered: 0x5E3CC4, 0x514;
lawmen_killed: 0x5E3CC4, 0x518;
gang_members_killed: 0x5E3CC4, 0x51C;
fugitive_factor: 0x5E3CC4, 0x530;

I thought it would be interesting to display them in realtime. Useful if you wanted to try a pacifist speedrun.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Thu Feb 22, 2018 12:12 am

Does anyone know a pointer in the name car?

ped struct + 0x16C = car pointer = car struct + ? = name car

Added:

I found a way to turn on/off the lights and open/close the doors in the car.

Code: Select all

ped struct + 0x16C = car struct
car struct + 0x8 = [byte] front left light (set 64/0 on/off light, car struct + 0x8 = +4 left light crash decal)
car struct + 0xA = [byte] front right light (set 128/0 on/off light, car struct + 0x8 = +8 right light crash decal)
Last edited by Logofero on Fri Feb 23, 2018 12:59 am, edited 3 times in total.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Fri Feb 23, 2018 12:44 am

Sector, you have set an example in the subject http://gtamp.com/forum/viewtopic.php?f=4&t=815#p10212 you know the pointer on the arrows or offset (all arrow data)?

User avatar
Sektor
Boss
Boss
Posts: 1366
Joined: Tue Mar 04, 2008 6:51 am
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor » Fri Feb 23, 2018 2:25 am


Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Fri Feb 23, 2018 2:47 am

Thank you. References are useful.

And do you know the address objective type (folowing at point) for ped?

User avatar
Sektor
Boss
Boss
Posts: 1366
Joined: Tue Mar 04, 2008 6:51 am
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor » Fri Feb 23, 2018 2:53 am

No, I haven't found the arrows pointing location. I looked for it since it would be useful in GTA2 Radar but no luck.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Fri Feb 23, 2018 3:05 am

Sektor wrote:No, I haven't found the arrows pointing location. I looked for it since it would be useful in GTA2 Radar but no luck.
I meant it. http://projectcerbera.com/gta/2/tutorials/character-ai

Code: Select all

SET_CHAR_OBJECTIVE (name, OBJECTIVE_TYPE) 
SET_CHAR_OBJECTIVE (name, OBJECTIVE_TYPE, X, Y, Z)

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sat Feb 24, 2018 1:51 am

I found some useful addresses for cars. Changes the status of the engine, light, door locks and car acceleration.

Code: Select all

car struct + 0x9C = [byte] engine state: 0 disabled, 1 off (set 2 engine and light off), 3 on (set 4 on engine and light)
car struct + 0x98 = [byte] door lock: 1 locked, 2 unlocked
car struct + 0x84 = [byte] car model: 0-86, 77 no moved (load handling from nyc.gci)
Can anyone know the address for changing the color and speed of car?

Edited: found car model.
Last edited by Logofero on Sat Feb 24, 2018 3:13 pm, edited 1 time in total.

BeepBoop
Car Jacker
Car Jacker
Posts: 44
Joined: Fri Oct 14, 2016 1:32 am
GH nick: BeepBoop

Re: GTA2 memory addresses

Post by BeepBoop » Sat Feb 24, 2018 5:16 am

I know the color of the car address for cheat engine.

"GTA2.EXE"+0027C274 (2 bytes)
Offset #1 = 0x24
Offset #2 = 0x50

Tell me if it works or not.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sat Feb 24, 2018 12:18 pm

BeepBoop wrote:I know the color of the car address for cheat engine.

"GTA2.EXE"+0027C274 (2 bytes)
Offset #1 = 0x24
Offset #2 = 0x50

Tell me if it works or not.
Сrash game and color is not displayed.

I thought the color should be somewhere in the structure of the car or in the structure of its sprite, but I did not find it there. Maybe someone can find (full example get car, sprite struct):

Code: Select all

0x5EB4FC = ped offset = ped offset + 0x4 = array ped pointer + 0xC4 = ped pointer = ped struct
ped struct + 0x16C = car pointer = car struct
car struct + 0x58 = sprite pointer = car sprite struct

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sat Feb 24, 2018 3:18 pm

Found car emergy siren, simulation button horn and enable signalisation sound:

Code: Select all

car struct + 0xA4 = [byte] emergy siren: 4 on, 2 off (in emergy cars)
car struct + 0xA7 = [byte] simulation button horn: 248 press (set 255), 0 up
car struct + 0x8E = [byte] signalisation sound: 1 on, 0 off

BeepBoop
Car Jacker
Car Jacker
Posts: 44
Joined: Fri Oct 14, 2016 1:32 am
GH nick: BeepBoop

Re: GTA2 memory addresses

Post by BeepBoop » Sat Feb 24, 2018 8:25 pm

Can you use multiple offsets?


For Example: car struct + 0x24 + 0x50 = Current car color.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sun Feb 25, 2018 2:49 am

BeepBoop wrote:Can you use multiple offsets?


For Example: car struct + 0x24 + 0x50 = Current car color.
address + offset, but this is when the offset is needed. When do I need to get the pointer I'm using. method of

example get scripts/struct.txt

Code: Select all

while(true)
    if (IsKeyDown(13)) then -- For write in MISI.log ped_struct and car_struct down key ENTER.
        local address = tonumber("0x5EB4FC") -- Ped offset found by Sector
        local offset = 0x4
        local ped_ptr = ReadProcessMemory(address, 4)
        ped_ptr = ped_ptr + offset
        ped_ptr = ReadProcessMemory(ped_ptr, 4) 
        local ped_struct = ReadProcessMemory(ped_ptr + 0xC4, 4) -- Get struct ped ID 1 (it player 1)
        if (ped_struct ~= 0) then -- Check player 1 exists
            local car_struct = ReadProcessMemory(ped_struct + 0x16C, 4)
            WriteInLog(string.format("Get ped struct %X car struct %X\n", ped_struct, car_struct))
        end
    end
    wait(200)
end
The presented syntax example is used in MISI
Last edited by Logofero on Sun Feb 25, 2018 12:41 pm, edited 1 time in total.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sun Feb 25, 2018 12:38 pm

The car color works. Thanks BeepBoop http://gtamp.com/forum/viewtopic.php?f= ... =60#p10567

get car color scripts/carcolor.txt

Code: Select all

while(true)
    if (IsKeyDown(13)) then -- Get color down key ENTER.
        local address = tonumber("0x5EB4FC") -- Ped offset found by Sector
        local offset = 0x4
        local ped_ptr = ReadProcessMemory(address, 4)
        ped_ptr = ped_ptr + offset
        ped_ptr = ReadProcessMemory(ped_ptr, 4)
        local ped_struct = ReadProcessMemory(ped_ptr + 0xC4, 4) -- Get struct ped ID 1 (it player 1)
        if (ped_struct ~= 0) then -- Check player 1 exists
            local car_struct = ReadProcessMemory(ped_struct + 0x16C, 4)
            if (car_struct ~= 0) then -- Check car exists
                local car_ptr = ReadProcessMemory(car_struct + 0x50, 4) -- Car color found by BeepBoop
                local car_color = ReadProcessMemory(car_ptr + 0x24, 2)
                WriteInLog(string.format("Get ped struct %X car struct %X car color %d\n", ped_struct, car_struct, car_color))
            end
        end
    end
    wait(200)
end
Now need to get the name and speed of the car.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sat Mar 10, 2018 5:39 pm

Does anyone have addresses for setting the volume of effects and music? Or C/C++ interfaces to configure the sound device GTA2.

This is necessary to turn off the radio in the car.

BeepBoop
Car Jacker
Car Jacker
Posts: 44
Joined: Fri Oct 14, 2016 1:32 am
GH nick: BeepBoop

Re: GTA2 memory addresses

Post by BeepBoop » Sun Mar 11, 2018 3:00 am

I've found the music and effects volume addresses, but changing them doesn't do anything. You can change the radio/effects volume in the GTA 2 manager while in-game without having to restart.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Sun Mar 11, 2018 10:54 am

BeepBoop wrote:I've found the music and effects volume addresses, but changing them doesn't do anything. You can change the radio/effects volume in the GTA 2 manager while in-game without having to restart.
A pro manager can not be a speech that only works for manual tuning.

I just need a rewritable memory address. I found it but it was in a heap of other addresses and it was not possible to weed out. Need a pointer for device Music/SFX (in RegEdit it GTA2/Sound keys: CDVol and SFXVol). Or can anyone know the sound API for controlling the current sound device GTA2.

Logofero
Serial Killer
Serial Killer
Posts: 231
Joined: Wed Dec 09, 2015 2:18 pm
GH nick: Logofero

Re: GTA2 memory addresses

Post by Logofero » Fri Mar 16, 2018 9:44 pm

I tried to change the position/angle of the object only z changes. The x, y coordinates are read-only? Sector, do you have an address for changing x, y, z (to write) the object?

I used:

Code: Select all

-- Since: v0.2.1b
function SetObjPos(obj, x, y, z)
    local obj_ptr = ReadProcessMemory(obj + 0x4, 4)
    WriteProcessMemory(obj_ptr + 0x14, x * 16384, 4)
    WriteProcessMemory(obj_ptr + 0x18, y * 16384, 4)
    WriteProcessMemory(obj_ptr + 0x1C, z * 16384, 4)
end

while (true) do
    if (IsKeyDown(0x4)) then -- Down key middle mouse wheel
        -- Here code create object or get obj struct
        SetObjPos(obj, 10.0, 30.0, 5.0) -- Changed only z
    end
end

User avatar
Sektor
Boss
Boss
Posts: 1366
Joined: Tue Mar 04, 2008 6:51 am
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: GTA2 memory addresses

Post by Sektor » Fri Mar 16, 2018 10:00 pm

They're not read only but maybe something else has to change to trigger the game to redraw. If you try with an animated object like a rocket, it should update instantly.

Post Reply