Page 4 of 6

Re: GTA2 memory addresses

Posted: 14 Jan 2018, 13:33
by Logofero
Nobody not is found a method to create an object/car/character? Or call spawn like in GTA3/VC/SA

Re: GTA2 memory addresses

Posted: 11 Feb 2018, 14:04
by Sektor
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.

Re: GTA2 memory addresses

Posted: 22 Feb 2018, 00:12
by Logofero
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)

Re: GTA2 memory addresses

Posted: 23 Feb 2018, 00:44
by Logofero
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)?

Re: GTA2 memory addresses

Posted: 23 Feb 2018, 02:25
by Sektor

Re: GTA2 memory addresses

Posted: 23 Feb 2018, 02:47
by Logofero
Thank you. References are useful.

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

Re: GTA2 memory addresses

Posted: 23 Feb 2018, 02:53
by Sektor
No, I haven't found the arrows pointing location. I looked for it since it would be useful in GTA2 Radar but no luck.

Re: GTA2 memory addresses

Posted: 23 Feb 2018, 03:05
by Logofero
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)

Re: GTA2 memory addresses

Posted: 24 Feb 2018, 01:51
by Logofero
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.

Re: GTA2 memory addresses

Posted: 24 Feb 2018, 05:16
by BeepBoop
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.

Re: GTA2 memory addresses

Posted: 24 Feb 2018, 12:18
by Logofero
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

Re: GTA2 memory addresses

Posted: 24 Feb 2018, 15:18
by Logofero
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

Re: GTA2 memory addresses

Posted: 24 Feb 2018, 20:25
by BeepBoop
Can you use multiple offsets?


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

Re: GTA2 memory addresses

Posted: 25 Feb 2018, 02:49
by Logofero
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

Re: GTA2 memory addresses

Posted: 25 Feb 2018, 12:38
by Logofero
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.

Re: GTA2 memory addresses

Posted: 10 Mar 2018, 17:39
by Logofero
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.

Re: GTA2 memory addresses

Posted: 11 Mar 2018, 03:00
by BeepBoop
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.

Re: GTA2 memory addresses

Posted: 11 Mar 2018, 10:54
by Logofero
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.

Re: GTA2 memory addresses

Posted: 16 Mar 2018, 21:44
by Logofero
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

Re: GTA2 memory addresses

Posted: 16 Mar 2018, 22:00
by Sektor
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.