Опрос на сайте
Как вам движок Vice Lua?

Популярные новости

Magic - TXD Builder 0.9.1

Magic - TXD Builder 0.9.1
Полезная программа для сборки TXD файлов, которая важные параметры, такие как mip map, DXT сжатие... Кроме того, программа

Vertex Alpha в Vice City

Vertex Alpha в Vice City
То, что некогда было доступно лишь в GTA: San Andreas и выше: Vertex Alpha, а потенциально - и физический бленд текстур в

Компактное меню

Компактное меню
Компактное меню для глобальных модов. Исключено все лишнее.

Main Menu Scene

Main Menu Scene
"Main Menu Scene" дает вам возможность создавать собственные сцены в "Главном Меню" игры с кастомными картой и скриптом, при

Rollerskates Mod

Rollerskates Mod
Модификация позволяет кататься на роликах, прямо как пляжные девушки.

31 январь 2025

Adding new weapons in GTA 4


Russian version (link)

Introduction
In this article I will show you how to add new weapons and sounds for it in standard GTA IV (not episodes) without plugins. I will only add one weapon, using the name “w_revolver” and “revolver”. Let's assume you already have the necessary assets in game format.

What you will need
- Weapon model, textures and collision
- Weapon sounds
- A program to open IMG archives and create RPF archives
- Text editor
- Game hash generator
- RAGEAT + IVAudioConv
- GTAAudioMetadataTool
Download link for GTAAudioMetadataTool:
GTAAudioMetadataTool.zip [1,78 Mb] (cкачиваний: 1)

What files are added and used
- w_revolver.wdr (model)
- w_revlover.wtd (textures)
- w_revolver.wbd (collision)
- common/data/default.ide
- common/data/WeaponInfo.xml
- pc/audio/sfx/revolver.rpf (weapon sounds)
- pc/audio/config/game.dat16
- pc/audio/config/sounds.dat15
- pc/audio/config/rpf.xml
- pc/audio/config/waveslots.xml
- gun@revolver.wad (player animations)
- common/data/animgrp.dat

Weapon model, weapon textures and weapon collision
You need to add the weapon model (wdr), weapon textures (wtd) and weapon collision (wbd) to the img-archive that will be loaded by the game.

Weapon definition
Open the following file: common/data/default.ide
Find the “weap” section in this file and add the following line to it:
w_revolver,	w_revolver,	gun@revolver,	1,	30,	0

The “weap” section is responsible for defining weapons.
w_revolver, w_revolver - name of wdr and wtd respectively
gun@revolver - name of animation file

Then, find the “amat” section and add the following line there:
w_revolver,	0,	CM_WEAPONS_PISTOL

The “amat” section is responsible for the sound collisions of weapons.
CM_WEAPONS_PISTOL - metadata name from game.dat16


Customizing weapon parameters
Open the following file: common/data/WeaponInfo.xml
Following the structure of the file, we need to add information about the new weapon there. Take a look at this example:
	<weapon type="EPISODIC_1">
		<data slot="HANDGUN" firetype="INSTANT_HIT" damagetype="BULLET" group="PISTOL_LARGE" targetrange="45.0" weaponrange="50.0" clipsize="6" ammomax="1500" timebetweenshots="333">
			<damage base="40" networkplayermod="4.0" networkpedmod="1.0"/>
			<physics force="75.0"/>
			<reload time="2000" fasttime="2000" crouchtime="2000"/>

			<aiming accuracy="0.5">
				<offset         x="0.15" y="1.0" z="0.55"/>
				<crouchedoffset x="0.2"  y="1.0" z="0.05"/>
				<reticule standing="0.6" ducked="0.5" scale="0.3"/>
			</aiming>

			<pickup regentime="240000" ammoonstreet="30"/>

			<controller>
				<rumble duration="150" intensity="0.1"/>
			</controller>

			<flags>
				<flag>GUN</flag>
				<flag>CAN_AIM</flag>
				<flag>CAN_FREE_AIM</flag>
				<flag>ANIM_RELOAD</flag>
				<flag>ANIM_CROUCH_FIRE</flag>
			</flags>
		</data>

		<assets model="w_revolver">
			<anim group="gun@revolver" meleegroup1="firearm_core"/>

			<effects>
				<muzzle fx="muz_pistol_large"/>
				<shell fx="weap_ejected_pistol"/>
			</effects>
		</assets>
	</weapon>

EPISODIC_1 is the weapon type that is specified in the first line. You can use another type, for example EPISODIC_2 or EPISODIC_3. The most recent free such type is EPISODIC_24. So, using “EPISODIC_”, you can add 24 types of new weapons to the standard game.

New sounds for weapons
In the folder with the game, open the following folder: pc/audio/sfx. Create an archive in rpf format (for example, using OpenIV). In this archive, create a folder with the same name as the archive (but without the extension). In this article, I will use the name MYWEAPONS.
After that, navigate to the folder with the RAGEAT utility. In this folder, create a text file with the following name and extension: MYWEAPONS_REVOLVER.oaf. After that, create a folder called MYWEAPONS_files.
Place your weapon sounds in the MYWEAPONS_files folder. Keep in mind that each gunshot sound in the game is divided into two audio files that refer to the left and right channel. I will use the following audio file names for the gunshot sound: REVOLVER_SHOT1_L.wav and REVOLVER_SHOT1_R.wav.
Now open the MYWEAPONS_REVOLVER.oaf file in a text editor and add the following lines to it:
{
    "isStream": false,
    "audioCount": 2,
    "animCount": 0,
    "entries": [
		{
            "name": "PISTOL_SHOT1_L",
            "file": "MYWEAPONS_files\\REVOLVER_SHOT1_L.wav",
            "compression": "PCM",
            "headroom": -191
        },
		{
            "name": "PISTOL_SHOT1_R",
            "file": "MYWEAPONS_files\\REVOLVER_SHOT1_R.wav",
            "compression": "PCM",
            "headroom": -191
        },
    ]
}

Note that the path to the sound file is specified in the “file” value, and the “name” value specifies the game name of the sound, which will be used by the game as a hash. If you will be adding more sounds, be sure to change the “audioCount” value.
Save this file and close it.
Drag and drop the MYWEAPONS_REVOLVER.oaf file onto the IVAudioConv.exe file. If all goes well, a file called MYWEAPONS_REVOLVER will be created, with no extension. This is the sound bank. Place it in the .rpf archive, namely in the folder we created earlier. You should get the following path: MYWEAPONS.rpf/MYWEAPONS/MYWEAPONS_REVOLVER.
We are done with the archive.

Now we need to make the game load the created archive and the sounds in it. In the folder with the game, open the following folder: pc/audio/config.
Open the file rpf.xml in this folder
Following the structure of the file, add the following lines there:
  <Rpf>
    <Name>MYWEAPONS</Name>
    <Type>rpf</Type>
    <Alias>MYWEAPONS</Alias>
  </Rpf>

Note that the name of the archive is specified in the "Name" and "Alias" values.
Save the file and close it.

Now open the waveslots.xml file in the same folder (not waveslot_.xml!)
Following the structure of the file, add the following lines there:
  <Slot>
    <Name content="ascii">MYWEAPONS_REVOLVER</Name>
    <MaxHeaderSize value="1024" />
    <LoadType content="ascii">BANK</LoadType>
    <StaticBank content="ascii">MYWEAPONS\MYWEAPONS_REVOLVER</StaticBank>
    <Size value="238592" />
  </Slot>

Note that here we need to specify the size of the MYWEAPONS sound bank in bytes in the "Size value". To find out the size of this sound bank in bytes, go back to the RAGEAT folder, right-click on the MYWEAPONS file and go to file properties. Copy the value of the size NOT used on the disk. In my case this value will be 238,592 bytes. You need to remove the commas and add your value to waveslots.xml, in the "Size value".

Go to the RAGEAT folder again. Open the following file: data/iv_eflc.ini
Here are the strings and their hashes that are used in the sound configs. All strings have the following form: [game hash]=[name]. You can generate game hashes using a name-based game hash generator (using OpenIV or through other generators on the internet).
I will use the following line in this article:
3184660097=XFADE_GUN_TEST_REVOLVER

After you have added the necessary lines, start RAGEAT. On the Metadata tab, in the list of working files, select the file game.dat16.
Use the search to find “W_GLOCK” in the loaded list. Scroll a little lower, you will see the rest of the metadata related to weapon sounds.
Select one of these metadata, then right click and select Duplicate. A duplicate of this metadata will be created. Select this duplicate.
Move to the right window of the program. Rename the name of this metadata to match the model name of your weapon. Here it will be W_REVOLVER
Next, let's go to the Hex view. Hover over the pink cells, then find those cells that have the following prefix: XFADE_GUN_TEST_.
Click once on the very first cell that refers to that name. After that, at the very bottom of the program, you will see the “Hash” field, which will have the prefix XFADE_GUN_TEST_. Replace it with the name you put in iv_eflc.ini.
There are other useful cells besides the ones mentioned above, but in this article we will only deal with this one.
Click the Save button in the lower-right corner of the program to save this metadata. Then, in the upper-left corner of the program, click File->Save to save the changes to game.dat16.
We are done with RAGEAT.

Download the GTAAudioMetadataTool from this link if you haven't already done so:
GTAAudioMetadataTool.zip [1,78 Mb] (cкачиваний: 1)

Go to the folder with the GTAAudioMetadataTool tool. Move the following file from the game folder into this folder: pc/audio/config/SOUNDS.DAT15
Run to_json.bat in the GTAAudioMetadataTool folder. A text file named SOUNDS.DAT15.json will be created. Open it with a text editor.
Now, following the structure of the file, we need to add the necessary metadata. You can use the metadata from this article as a template when adding sounds for weapons.
Let's add the metadata that relates to game.dat16:
    "XFADE_GUN_TEST_REVOLVER": {
        "Type": "audCrossfadeSound",
        "Flags": 174762,
        "__unk09": 0,
        "Header": {
            " __field16": 0
        },
        "Metadata": {
            "NearSound": "REVOLVER_FIRE",
            "FarSound": "DISTANT_DESERT_EAGLE",
            "__field08": 0,
            "__field09": 1106247680,
            "__field0d": 1119092736,
            "__field11": 0,
            "VariableHash1": "0x00000000",
            "VariableHash2": "0x00000000",
            "__field1d": 0,
            "VariableHash3": "0x00000000",
            "UnkCurvesHash": "0x94ae4add"
        }
    },

Thus, we specified the string XFADE_GUN_TEST_REVOLVER in game.dat16, and initialized the metadata with its name in sounds.dat15.

Now we need to add metadata for the “NearSound” value - REVOLVER_FIRE:
    "REVOLVER_FIRE": {
        "Type": "audMultitrackSound",
        "Flags": 174762,
        "__unk09": 0,
        "Header": {
            "__field0": 65436,
            "__field12": 0,
            "CategoryHash": "0x49d789a4",
            " __field16": 0
        },
        "Metadata": {
            "Tracks": [
                {
                    "TrackHash": "GENERAL_GUNS_EAGLE_DRY",
                    "__field04": 0
                },
                {
                    "TrackHash": "GENERAL_GUNS_EAGLE_LOWS",
                    "__field04": 0
                },
                {
                    "TrackHash": "REVOLVER_SHOT_1",
                    "__field04": 0
                },
                {
                    "TrackHash": "GENERAL_GUNS_EAGLE_SHOT2",
                    "__field04": 0
                },
                {
                    "TrackHash": "EAGLE_TAIL",
                    "__field04": 0
                },
                {
                    "TrackHash": "GUN_SWEETNERS_SINES_EAGLE",
                    "__field04": 0
                },
                {
                    "TrackHash": "EAGLE_SMACK_SOUND",
                    "__field04": 0
                }
            ]
        }
    },


Add metadata for “REVOLVER_SHOT_1”:
    "REVOLVER_SHOT_1": {
        "Type": "audCollapsingStereoSound",
        "Flags": 170662,
        "__unk09": 0,
        "Header": {
            "CategoryHash": "0xb9948cea",
            " __field16": 0
        },
        "Metadata": {
            "SoundHash1": "GENERAL_GUNS_REVOLVER_SHOT1_L",
            "SoundHash2": "GENERAL_GUNS_REVOLVER_SHOT1_R",
            "__field08": 3.0,
            "__field0c": 5.0,
            "VariableHash1": "0x00000000",
            "VariableHash2": "0x00000000",
            "VariableHash3": "0x00000000",
            "VariableHash4": "0x00000000",
            "VariableHash5": "0x00000000",
            "__field24": 0
        }
    },


Finally, we add metadata for the value of “SoundHash1” and “SoundHash2”:
    "GENERAL_GUNS_REVOLVER_SHOT1_L": {
        "Type": "audSimpleSound",
        "Flags": 174762,
        "__unk09": 0,
        "Header": {
            " __field16": 0
        },
        "Metadata": {
            "__field00": 0,
            "ArchiveHash": "MYWEAPONS.SFX/MYWEAPONS_REVOLVER",
            "SoundHash": "0x5f830a0a"
        }
    },
    "GENERAL_GUNS_REVOLVER_SHOT1_R": {
        "Type": "audSimpleSound",
        "Flags": 174762,
        "__unk09": 0,
        "Header": {
            " __field16": 0
        },
        "Metadata": {
            "__field00": 0,
            "ArchiveHash": "MYWEAPONS.SFX/MYWEAPONS_REVOLVER",
            "SoundHash": "0x7fc24a88"
        }
    },

Here, in the “SoundHash” values, we need to specify the sound hashes for the left channel and right channel of the audio. Recall that each gunshot sound in the game is divided into two audio files that belong to the left and right channel.
In this example, I use the following audio hashes for the left and right channel respectively:
0x5f830a0a - PISTOL_SHOT1_L
0x7fc24a88 - PISTOL_SHOT1_R
These hashes already exist in the game and are used for the W_GLOCK gun. Unfortunately, for some reason, custom hashes didn't work in my game, so I used the existing ones for all new sounds. However, this won't be a problem if you use these sounds in different sound banks for each gun.
We're done with SOUNDS.DAT15.json, save the changes.

In the same folder, run to_binary.bat. A binary file named SOUNDS.DAT15.GEN will be created. Rename the file by removing the “.GEN” at the end. The file is ready, move it back to the game folder.
We are done with the GTAAudioMetadataTool.

Player animations
If you are using an existing group of animations for the player, then skip this step.

You will need to add the animation group in wad format to the img-archive that will be loaded by the game. I will use the following name: gun@revolver.wad

Now we need to tell the game that gun@revolver is the weapon animation group.
Open the following file: common/data/animgrp.dat
Find the “WeaponGroups” section in this file, where the animation groups for existing weapons are added.
Add the following line there as well:
WeaponGroup( Streaming, gun@revolver )

Save the file and close it.

Посетители, находящиеся в группе Гости, не могут оставлять комментарии к данной публикации.

Добавить свой комментарий

Полужирный Наклонный текст Подчёркнутый текст Зачёркнутый текст | Выравнивание по левому краю По центру Выравнивание по правому краю | Вставка смайликов Выбор цвета | Скрытый текст Вставка цитаты Преобразовать выбранный текст из транслитерации в кириллицу Вставка спойлера
Вопрос: Введите первые 3 (Русские) буквы сайта (заглавные).
Ответ:*
Другие материалы

Добавление нового оружия в GTA 4

Добавление нового оружия в GTA 4
[RU] В этой статье я покажу как добавлять новое оружие и звуки для него в GTA IV без использования плагинов.

Adding a new interior to GTA 4

Adding a new interior to GTA 4
[EN] In this article we will try to understand how the interior of the player's first safehouse was added. This will help

Adding street names for the game map in GTA 4

Adding street names for the game map in GTA 4
[EN] Street names have been added to GTA IV with names that are displayed on the screen. In this article we will understand

Нативные функции в GTA 5

Нативные функции в GTA 5
В данной статье мы расскажем, как вызывать нативные функции из C++ напрямую в вашем скрипте, применять их в качестве
Ads

Группа GTA Builder