Is There Any Way to Add Walking Cops to the Downtown District?
Posted: 27 Aug 2024, 03:28
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.
Grand Theft Auto Multiplayer
https://gtamp.com/forum/
thanks!
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.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?
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.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.
thanks!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).