Is There Any Way to Add Walking Cops to the Downtown District?

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
Gui7814
Jaywalker
Jaywalker
Posts: 5
Joined: 05 Aug 2024, 17:45

Is There Any Way to Add Walking Cops to the Downtown District?

Post by Gui7814 »

I wanted to add walking cops to the downtown district but I don't know how to do that since wil.scr doesn't have its source code released.
Rick
Car Jacker
Car Jacker
Posts: 34
Joined: 29 Jan 2012, 18:56
GH nick: Sequential

Re: Is There Any Way to Add Walking Cops to the Downtown District?

Post by Rick »

Hi and welcome to the forum :)

Don't exactly understand your problem, but isn't it sufficient to turn on police and cop peds do spawn in ped zones automatically?
These are the randomly spawned dummy cops you see in the game. Or do you want specific scripted cop peds?
Gui7814
Jaywalker
Jaywalker
Posts: 5
Joined: 05 Aug 2024, 17:45

Re: Is There Any Way to Add Walking Cops to the Downtown District?

Post by Gui7814 »

Rick wrote: 28 Aug 2024, 19:49 Hi and welcome to the forum :)
thanks!
Rick wrote: 28 Aug 2024, 19:49 Don't exactly understand your problem, but isn't it sufficient to turn on police and cop peds do spawn in ped zones automatically?
These are the randomly spawned dummy cops you see in the game. Or do you want specific scripted cop peds?
I wanted to add dummy cops just like in the industrial and residential district, but since the density of vehicles and pedestrians of zones including cops are defined by script and wil.scr still doesn't have its source code released, I don't know how to do this without needing the source code.
User avatar
B-$hep
Immortal
Posts: 574
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Is There Any Way to Add Walking Cops to the Downtown District?

Post by B-$hep »

Hello.
I havent scripted for a while.
If you figure / find out what command is responsible for cop "density" on map then I can figure out something.
Its not hard to edit SCR files.

Done this in the past successfully.


[offtopic]Btw Im still interested in GTA2 stuff but Im busy with working on my YT channels and I want to earn income from them.
I dont even have time to work on my cars (another hobby).
I havent lost interest in GTA2. I even have lots of ideas for map editor. Then I have also new script compiler (I have shelved this project for some time)[/offtopic]
Always wear safety glasses while programming.
Gui7814
Jaywalker
Jaywalker
Posts: 5
Joined: 05 Aug 2024, 17:45

Re: Is There Any Way to Add Walking Cops to the Downtown District?

Post by Gui7814 »

B-$hep wrote: 30 Aug 2024, 14:55 If you figure / find out what command is responsible for cop "density" on map then I can figure out something.
There is the MAP_ZONE command, which defines not only the density of police pedestrians, and there is the SET_POLICEPED_RATIO function, which obviously only changes the density of police pedestrians.

If you want more information, click on one of these links below:
MAP_ZONE
SET_POLICEPED_RATIO
User avatar
valps
Car Jacker
Car Jacker
Posts: 25
Joined: 31 Dec 2020, 15:03
GH nick: Valps
Location: Brazil
Contact:

Re: Is There Any Way to Add Walking Cops to the Downtown District?

Post by valps »

Despite the fact that we don't have the source code, always there is a "hard way" to change the GTA2 script file. You might use a binary editor (like the free program HxD) to change directly the array data of some MAP_ZONE's of the downtown district.

I did it, and I annexed the modified wil.scr to you. But if you want to know how I did or if you want to change another parameter, you may find useful this guide:

First, you can have a partially decompiled source code from .scr. Just open the Epic Map Editor, go to "tools" tab, and then "decompile SCR to MIS". For downtown district you choose "wil.scr", and then choose a folder to export the (partially) decompiled code. We unfortunately cannot recompile this code since all IFs and GOTOs are broken. Now you can view all the MAP_ZONE's arrays of data.

The zones of interest is those ones named "mXX", "w01" and "w03".

Second, note that some MAP_ZONE has 10 parameters, another has 11 parameters. The 11° parameter is always the "gangcar_ratio", and the 10° the "police_ped_ratio".

I decompiled the three districts and I noted that the overall ped density of the districts are different:

downtown: 200
residential: 500
industrial: 600

So you have to consider which value of "police_ped_ratio" you will use. I tested for police_ped_ratio = 50 and their spawn seems fair.

Thirdly, before editing any data, make a backup of the "wil.scr".

Fourthly, the order of all zone declarations in the source code is preserved in the compiled .scr. The first relevant map zone is

MAP_ZONE w03 = (600, 110, 0, 0, 400, 0, 0, 0, 500, 0, 200)

These parameters in 2 bytes hexadecimal are

600 = 0258 = 02 58
110 = 006E = 00 6E
0 = 0000 = 00 00
400 = 0190 = 01 90
500 = 01F4 = 01 F4
200 = 00C8 = 00 C8
etc.

However, the bytes order in .scr are reversed, so in the binary editor you will see

600 = 58 02
110 = 6E 00
0 = 00 00
400 = 90 01
500 = F4 01
200 = C8 00

Then the array (600, 110, 0, 0, 400, 0, 0, 0, 500, 0, 200) will show in binary editor as

58 02 6E 00 00 00 00 00 90 01 00 00 00 00 00 00 F4 01 00 00 C8 00

Search for this array of numbers in binary editor to find the address of this map_zone in wil.scr.

To change the "police_ped_ratio", we have to change the zero between 500 and 200, the penultimate parameter. So for example if you want to set police_ped_ratio = 50, that is "32 00" in two bytes hex, you have to change the penultimate pair of bytes (that is 00 00) to 32 00. So you will have

58 02 6E 00 00 00 00 00 90 01 00 00 00 00 00 00 F4 01 32 00 C8 00

To apply the change, just press ctrl+s to save the binary change.

Now you just need to repeat this process to other zones (always taking care with the number of parameters of each MAP_ZONE).
Attachments
walking_cops_downtown_district.zip
(15.33 KiB) Downloaded 20 times
Gui7814
Jaywalker
Jaywalker
Posts: 5
Joined: 05 Aug 2024, 17:45

Re: Is There Any Way to Add Walking Cops to the Downtown District?

Post by Gui7814 »

valps wrote: 03 Sep 2024, 19:57 Despite the fact that we don't have the source code, always there is a "hard way" to change the GTA2 script file. You might use a binary editor (like the free program HxD) to change directly the array data of some MAP_ZONE's of the downtown district.

I did it, and I annexed the modified wil.scr to you. But if you want to know how I did or if you want to change another parameter, you may find useful this guide:

First, you can have a partially decompiled source code from .scr. Just open the Epic Map Editor, go to "tools" tab, and then "decompile SCR to MIS". For downtown district you choose "wil.scr", and then choose a folder to export the (partially) decompiled code. We unfortunately cannot recompile this code since all IFs and GOTOs are broken. Now you can view all the MAP_ZONE's arrays of data.

The zones of interest is those ones named "mXX", "w01" and "w03".

Second, note that some MAP_ZONE has 10 parameters, another has 11 parameters. The 11° parameter is always the "gangcar_ratio", and the 10° the "police_ped_ratio".

I decompiled the three districts and I noted that the overall ped density of the districts are different:

downtown: 200
residential: 500
industrial: 600

So you have to consider which value of "police_ped_ratio" you will use. I tested for police_ped_ratio = 50 and their spawn seems fair.

Thirdly, before editing any data, make a backup of the "wil.scr".

Fourthly, the order of all zone declarations in the source code is preserved in the compiled .scr. The first relevant map zone is

MAP_ZONE w03 = (600, 110, 0, 0, 400, 0, 0, 0, 500, 0, 200)

These parameters in 2 bytes hexadecimal are

600 = 0258 = 02 58
110 = 006E = 00 6E
0 = 0000 = 00 00
400 = 0190 = 01 90
500 = 01F4 = 01 F4
200 = 00C8 = 00 C8
etc.

However, the bytes order in .scr are reversed, so in the binary editor you will see

600 = 58 02
110 = 6E 00
0 = 00 00
400 = 90 01
500 = F4 01
200 = C8 00

Then the array (600, 110, 0, 0, 400, 0, 0, 0, 500, 0, 200) will show in binary editor as

58 02 6E 00 00 00 00 00 90 01 00 00 00 00 00 00 F4 01 00 00 C8 00

Search for this array of numbers in binary editor to find the address of this map_zone in wil.scr.

To change the "police_ped_ratio", we have to change the zero between 500 and 200, the penultimate parameter. So for example if you want to set police_ped_ratio = 50, that is "32 00" in two bytes hex, you have to change the penultimate pair of bytes (that is 00 00) to 32 00. So you will have

58 02 6E 00 00 00 00 00 90 01 00 00 00 00 00 00 F4 01 32 00 C8 00

To apply the change, just press ctrl+s to save the binary change.

Now you just need to repeat this process to other zones (always taking care with the number of parameters of each MAP_ZONE).
thanks!
Post Reply