Weapon Creation/Prefab Configuration – Arma Reforger

From Bohemia Interactive Community
< Arma Reforger:Weapon Creation
Revision as of 11:44, 27 March 2023 by Lou Montana (talk | contribs) (Page creation (from Arma Reforger:Weapon Creation))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

armareforger-new-weapon-adjusting-magazine-xob.gif

In this chapter we will learn how fuel is simulated in game and we will change following things:
  • Creating new rifle prefab
  • Configuring basic weapon parameters


Basic Weapon Configuration

Basic Weapon Prefab Setup

When making prefabs of weapons it is recommended to inherit from one of the already existing prefabs located in Prefabs\Weapons\Core - those prefabs should have most of the necessary configuration for various kinds of weapons.

In this case we will use Rifle_Base.et as parent prefab. To do so, navigate in Resource Browser attached to World Editor to Prefabs\Weapons\Core & locate Rifle_Base.et prefab. Once you are there, click with right mouse button on that prefab and select Inherit Prefab in Addon from context menu. When asked about new name of prefab, consider calling this new prefab WeaponName_base - this might be especially useful when you plan to have multiple variants of weapon, since it will help you to keep your structure nice and clean. After new inherited prefab is created, relocate it to some more fitting location like the Prefabs/Weapons/Rifles directory.

armareforger-new-weapon-creating-inherited-prefab.gif

Other method involves duplicating some already existing prefab - this might be handy if you are creating something similar to already existing weapons. For instance if you are making some new M16 variant, you could use Duplicate to "addon name" function on Rifle_M16A2_base.et and then modify parameters of such new prefab.

After new prefab is created, it is possible to start modifying it. It can be done by either by opening prefab in Prefab Edit Mode button or by placing prefab manually in World Editor. In this tutorial Prefab Edit Mode was used to edit the SampleWeapon_01_base.et prefab.

Once prefab is loaded, first step would be assigning correct model - in this case it is SampleWeapon_01.xob - to MeshObject component.

MeshObject component with assigned weapon model

If you inherited from core weapon type like Rifle_Base.et then you will need to add few components listed below. In case of duplication of existing prefab, it might be still worth to adjust data in those components before moving to next section of this tutorial, since some of the values might need to be adjusted, like for example damage in SCR_MeleeWeaponProperties.

  • RigidBody - this component is responsible for all kind of collisions and without it will be impossible to pick up weapon.
    • Once component is created it will be necessary to check Model Geometry parameter so its enabled
  • SCR_MeleeWeaponProperties - this component defines how much damage does this weapon when its used in melee fight
    • For rifles Damage value of 45 is a good starting point - for smaller weapon feel free to use lower value

armareforger-new-weapon-adding-components.gif

Additional, it might be also worth adding another CaseEjectingEffectComponent to Muzzle Component, which is going to emit muzzle smoke. To do so, click with Right Mouse Button on MuzzleComponent and select from context menu option Add child component and select CaseEjectingEffectComponent from the list.

Configuration of CaseEjectingEffectComponent

armareforger-new-weapon-adding-child-components.gif

In component itself, following changes will be required:

  • Assign fitting particle effect to Particle Effect field - i.e. Smoke_M16A2.ptc
  • In Effect Position parameter click on set class button and pick EntitySlotInfo class and call it for instance Muzzle
    • Inside Effect Position, change Pivot ID to barrel_muzzle
  • Change Has Sound parameter to disabled state

Additionally, you might also want to adjust:

  • What kind of cartridges are ejected by the weapon - this is defined in CaseEjectingEffectComponent - over here you can select from many particle effects like for instance Casing_556x45.ptc and assign them to Particle Effect property
  • Muzzle effect of the weapon - this is controlled by Particle Effect parameter in SCR_MuzzleEffectComponent - again, you can pick from some existing effects like Muzzle_AK74.ptc or create your own effects like mentioned in Weapon Modding documentation

Inventory Configuration

SCR_WeaponAttachmentsStorageComponent

In SCR_WeaponAttachmentsStorageComponent it is possible to adjust some of the basic item properties related to inventory but there is also one section which is used for defining weapon IK pose (RV veterans might find it similar to handAnims parameter). Animation IK pose is not going to be described in this paragraph though so let's move to inventory configuration.

Using vanilla animation graph will most likely result in malformed weapon, if you are not EXACTLY SAME bone positions as vanilla weapon.

It is still possible to use vanilla character animations and create custom weapon animations.

More about animations can be found on Weapon Animation page although it is strongly recommended to finish this part of the tutorial first!

When looking at SCR_WeaponAttachmentsStorageComponent, multiple Attributes can be observed:

  • Item Display Name - as name suggest, here it is possible to change Name and Description (on-hover tool tip visible in in-game inventory)
  • Item Phys Attributes - various physical attributes of the item like mass, volume, etc
  • Item Animation Attributes - here are defined item IK poses defined

Besides these attributes, there are also Custom Attributes where it is possible to change e.g. Item Inspection Anim or the character's maximum speed when a given item is equipped, or PreviewRenderAttributes, which controls the weapon preview in the inventory menu - if your weapon has an odd size, it might be necessary to adjust the camera parameters there.

In Reforger, inventory system is no longer using pictures' to for model thumbnails but instead, 3D models are rendered inside inventory menu. How this item is rendered inside inventory is controlled by PreviewRenderAttributes, where you have bunch of camera controls', and In case of SampleWeapon_01_base.et, some tweaks to will be required to the camera distance. Since this bullpup weapon is smaller than regular rifles, it looks quite small in inventory menu. To fix this, navigate to PreviewRenderAttributes class in Custom Attributes and change Camera Distance To Item parameter from 1 to 0.8.

PreviewRenderAttributes inside SCR_WeaponAttachmentsStorageComponent
To refresh preview renders in play mode, it might be necessary to reload all data with ⇧ Shift + R) shortcut in World Editor. If its not working, try to restart Workbench.

This will put camera closer to the weapon so in inventory menu, weapon should fill whole tile it has available.

In Rifle_Base prefab, Item Phys Attributes is not configured and it is necessary to use "set class" button next to that property. Pressing this button will show additional section where you can freely change parameters.

For this Sample Weapon, the following changes were done:

  • In Item Display Name section, Name property was changed to name of the weapon - in this case it is just "Sample Weapon"
    Tip: If you already want to configure your display name in a way, where it can be translated, consider looking at the Mod Localisation page.
  • In Item Phys Attributes:
    • Weight parameter was adjusted to somehow match the weight of real weapon without any accessories (including magazine). This parameter is using kilograms and in this example it was set to 4kg
    • Size Setup Strategy was setup to Volume. This means that size of that object will be calculated using Item Volume.
    • Item Volume [in cm3] defines how much space in inventory takes that object. In this example it is set to 2500 just to showcase how it works, normally, 3000 is used for machine guns, while rifle like AK74 has this value set to 1500

Additionally, it will be also necessary to add one entry to Custom Attributes. This can be done by clicking on arrow icon (1) to the right of it and then selecting ItemOneHandAnimAttributes class. This class controls the behavior of the weapon when it is held with one hand only - i.e. when the gadget is equipped - and in most cases the default values are good enough for rifles.

Actions

Add New Action Context

Adding new Action Contexts

Interactions with weapon in game world, like being able to take weapon from ground or performing some actions in inspect menu, are controlled by ActionsManagerComponent. Rifle_Base.et prefab should already have most of the Action Contexts and Additional Actions configured although if your weapon is capable of mounting some optic - like Sample Weapon - it might be necessary to add another context for handling optic-related actions it.

To do add new Action Context, simply click on plus icon next to it and then inside of it (by default it should be called UserActionContext), locate Context Name property and type in optic. After that click on set class button next to Position property and select PointInfo class - this will be used to adjust position where the action is located.

ActionsManagerComponent Debug

Once all contexts are in place, it will be most likely to do some adjustments to the context properties like tweaking position or radius where action is available. Typing in seemingly magic values and then checking it in play mode might be bit time consuming so that is why it is recommended to use some of the existing debugs to speed up configuration process.

ActionsManagerComponent custom debugs

After clicking on ActionManagerComponent with Right Mouse Button in Object Properties window, you should see multiple debugs listed in Custom section like:

  • Draw context(s) diagnostics for selected entity only - toggle if debug should be available only for selected entity - mutual exclusive with below debug
  • Draw context(s) diagnostics for all entities - toggle if debug should be available only for all entities in the world - mutual exclusive with above debug
  • Toggle context(s) transform gizmo visualization - show little gizmos next to context action
  • Toggle context(s) radius visualization - show radius of all action contexts
  • Toggle context(s) visibility angle visualization - toggle angle visibility of actions. Only active for non Omnidirectional action contexts (can be used to have actions which are i.e. available from side of the weapon)
  • Create user action context(s) from bones - small tool for creating multiple action contexts (see Car Creation documentation for more details)

In this case, it will be enough to enable contexts transform visualization. At later stage, it will be also handy to enable radius visualization when adjusting Radius parameter. Once it is enabled, World Editor viewport should look like this:

armareforger-new-weapon-default-action-debugs.png

As you can notice, most of the actions are located at center of the model and need to be moved to more logical places.

If you have some issue with actions visibility, you might also try to check in game debugs for User Actions.
Remember that user actions are only going to only if you have proper colliders with Weapon layer present and RigidBody has Model Geometry enabled

Location Setup

It might seem that adjusting of action contexts position is a tedious job but thankfully it is possible to adjust their position directly in viewport using gizmos. To do so, go to selected Action Context - in this case it will be firemode - and click once on one of the fields in Offset parameter. After that, you should see a gizmo snapped to this action context, which can be freely adjusted.

armareforger-new-weapon-action-contexts-viewport-tweaking.gif

Additionally it is also possible to use Pivot ID to snap action to one of the bones or snap points. Even after Pivot ID is selected, it is still possible to do some tweaks manually using Offset parameter (including tweaking it in viewport).

armareforger-new-weapon-action-contexts-viewport-tweaking-pivot.gif

After all Action Contexts are set, weapon in viewport should look like this:

armareforger-new-weapon-actions-final.png

Radius Setup

Last step will be adjusting radius of actions. Default action context is used for instance for picking up weapon from the ground so preferable it should cover the whole gun. Most of the actions which are inherited from Rifle_Base.et prefab have already reduced radius but since optic was created action context was created from scratch, it might still need some tweaking. Default value of Radius parameter on optic action context will cause that this action will fight for attention with all other actions and might also appear to early. To fix this, simply reducing Radius from 0.3 to 0.1 should effectively fix this issue.

Weapon Characteristics

Adjusting Fire Modes in MuzzleComponent

Most of the weapon firing characteristic can be changed in MuzzleComponent which is child of WeaponComponent. Over there, it is possible to Fire Modes, Dispersion, Bullet Init Speed Coef, Magazines and others. In this segment, focus would be but on getting fire modes set correctly, which were already partially covered in the Weapon Modding tutorial.

Starting with Fire Modes, Rifle_Base prefab has by default fire modes - Safe & Single fire mode, therefore it is assumed that any rifle has a safe mode. If it is not the case for the asset that you are preparing, then it might be necessary to create new base prefab based of Weapon_Base prefab - this scenario is not going to be described here though.

For purpose of this tutorial, Sample Weapon is equipped with three fire modes - safe, single & full auto. Since parent prefab has only two fire modes, a new one has to be added through ➕ sign (1) on the right side of the Fire Modes property. Once it is there, it can be filled with proper data.

'BaseFireMode with Max Burst set to 1 will work as single fire mode'. On newly added BaseFireMode, Max Burst should be set to -1 - this fire mode will work as full auto mode.

Burst fire weapons can be configured by setting Max Burst property to something above 1. In this case, new property will appear - Burst Type. Over there it is possible to select 3 types of burst fire:

  • Uninterruptible - once player presses fire button, weapon will fire exactly the amount of shots defined in Max Burst (unless weapon runs out of ammo)
  • Interruptible - burst fire will be interrupted once player release fire button. Burst memory is present (Burst Mode (weapons))
  • InterruptibleAndReseting - same as above but without burst memory

Weapon Behaviour Configuration

Weapon recoil is in configured on of the sub classes of Weapon Aim Modifiers. Rifle_Base prefab is missing RecoilWeaponAimModifier & ZeroingWeaponAimModifier subclasses in Weapon Aim Modifiers, therefore those have to be added to it. While ZeroingWeaponAimModifier doesn't need any tweaks, RecoilWeaponAimModifier class will have to be set from scratch by hand. As reference, either pictures below or AK74 prefab can be used as reference.

Combined recoil effect

When tweaking recoil values, following table might be useful to get general concept of what Linear, Angular & Turn Offset Data does. Tooltips above parameters should provide enough information on how to set data.

Recoil X Y Z
Linear

(1u=1m)

armareforger-new-weapon-recoil-linear-x2.gif armareforger-new-weapon-recoil-linear-y.gif armareforger-new-weapon-recoil-linear-z.gif
Angular

(1u = 1°)

armareforger-new-weapon-recoil-angular-x.gif armareforger-new-weapon-recoil-angular-y.gif armareforger-new-weapon-recoil-angular-z.gif
Offset

(1u = 1rad)

armareforger-new-weapon-recoil-offset-x.gif armareforger-new-weapon-recoil-offset-y.gif not used, should be left to 0

Zeroing

First, you need to setup SightsComponent and fill in Sights Ranges with desired zeroings of your weapon. The position of the camera when you aim down sights is controlled by Sights Position and if you have the eye snap point placed in the correct spot, then no further adjustments to it should be necessary.

Sample weapon setup is bit special since iron sights are mounted on RIS rail and are not integrated part of the weapon. They also have only one zeroing mod set to 300 meters so its not a good example to show how iron sights should be set.

Because of that, here is more general explanation how zeroing works using the game's AK74 as an example. Unlike in Arma 3, weapons in Arma Reforger are not using magic ballistic computer which is automatically adjusting angle of bullet which leaves the barrel but zeroing is working just like in real life. Bullets are affected by gravity and air friction, so if the target is a little farther away, it is necessary to aim higher if you still want to hit your target, and that's basically how mechanical iron sights work. In principle, iron sights are forcing you to look at certain angle which corresponds to ballistic curve of bullet.

armareforger-new-weapon-zeroing-ak.png

Setting points for the proper rotation of iron sights would be a tedious process, but fortunately there is an automated way built into Workbench to assist you in this process.

Remember - iron sights will be zeroed to just one particular bullet time, which is assigned in Magazine. If your iron sights are misbehaving, make sure that you are using correct ballistic data for your ammunition.

To use it, following things has to be done:

  • Click with Right Mouse Buttonon SightsComponent and select Toggle sight point diag from context menu - this will show position of sights point which zeroing generator will use
  • In SightsComponent, set class PointInfo (via set class) on Sights Point Front & Sights Point Rear parameters
  • Adjust position of Sights Point Front so it sits on tip of front iron sight. You can use view port gizmo to do so after clicking on Offset parameter inside Sights Point Front. You can also use snap points and assign them in Pivot ID if you prefer to do so
  • Adjust position of Sights Point Rear so it sits on tip of rear iron sight
  • Make sure that both front & rear points are in one line
  • In Zeroing Generator property in Sights Component, set class to BaseZeroingGenerator

armareforger-new-weapon-sights-debug.png

AK74 tangent sight

Next on the list preparing a list of all available zeroing modes. AK74 iron sights can be zeroed between 100 & 1000 meters and first zeroing mode is a 'battle zero' — a fixed preset configured for a likely combat distance. By aiming at an enemy's center of mass, one may be certain that the trajectory of the projectile will make contact, neither overflying or falling short. This means that in total there are 11 zeroing modes.

Zeroing modes are listed inside of Sights Ranges array in SightsComponent. Using the ➕ button next to that parameter, add 11 entries in that array which will represent all available zeroing modes.

Each SightRangeInfo has Range parameter which need to be filled manually - and the Weapon Position class - which is generated by zeroing generator. In Range, X value represents animation source value & Y represents desired zeroing range in meters (note that this value is also shared by UI).

Zeroing animation (which is not going to be created yet) goes from 0 to 1, where first entry in Sights Range array is 0 and last one is 1. Since there are 11 zeroing modes, interval between each zeroing mode can be set to 0.1 - this was calculated by using following equation 1/(number of frames - 1).

This means that you should have following zeroing modes:

Zeroing Modes Table
Animation Source Value Range [m]
0 440
0.1 100
0.2 200
0.3 300
0.4 400
0.5 500
0.6 600
0.7 700
0.8 800
0.9 900
1.0 1000
Zeroing generator does not work in Prefab Edit Mode! Place your weapon in World Editor in regular mode instead!

Once you have filled Sights Ranges you can click with right mouse button on Sights Component & then select from context menu "Process zeroing data". Generator will ask which muzzle you want to process and in most cases first muzzle will be the only choice. After confirming selection, generator will automatically calculate necessary offsets for Weapon Positions and store those generated values the currently selected weapon entity. Therefore, it will be necessary to use Apply to prefab button and save current world afterwards.

At this stage we won't bother with animating iron sights and we will get back to it once there is animation graph set in.

Ammunition Creation

Ammo Configuration

Projectile configuration
Projectile configuration

Depending on the type of ammo are you preparing, there are few core prefabs for various types of ammunition located in Prefabs/Weapons/Core folder. In general, there are three suggested approaches:

  • Creating new prefab inheriting from Ammo_Bullet_Base.et via Inherit Prefab in Addon functionality
  • Duplicating one of existing ammo prefabs via Duplicate in option - this might be useful for instance on rockets, if i.e. you don't want to use some of the components but still want to keep some of the configuration from it
  • Inheriting from one of existing prefabs - this can be used if you are trying to do some variant of existing ammo. This method could be for example used when you 5.45x39 7N6 vanilla bullet if you would like to do newer variant of that bullet (for instance 7N10) with slightly changed characteristics

In this tutorial, Sample Weapon is supposed to use a variant of 6.5 Grendel ammo but unlike in A3, this round won't be caseless to show how to configure spent cartridge ejection. Because of that, inheriting from Ammo_Bullet_Base.et was selected for configuration of this new bullet.

When trying to configure a bullet that exists in real life, it is good to gather as much reference material as possible. The Arma 3 variant of the 6.5x39mm is a fictional bullet, so as an inspiration, Lapua FMJ BT 144gr round with 6.5x39mm dimensions (instead of 6.5x38mm) was used, since there is a decent amount of information available for it.

After creating new inherited prefab called Ammo_65x39_FMJBT.et, first step will be creating Ammo folder in Prefabs/Weapons folder and then moving Ammo_65x39_FMJBT.et prefab from Prefabs/Weapons/Core to the Ammo folder.

Once prefab is in correct place, you can start editing it in World Editor by for example entering into Prefab Edit mode.

In Prefab itself, there are two things you will want to adjust before moving on to more complex topics. First one will be adjusting things in Projectile itself like changing following parameters:

  • In Projectile Model assign model of the bullet itself - this model is visible after it is being fired
  • In Cartridge Model assign model of the cartridge (bullet+case). Right now it is not being rendered in game though, unless loose bullet is placed in World Editor.

If you don't have models for neither Projectile or Cartridge Model , then you can use of the existing ones. In this case Bullet_762x51_M62.xob and Cartridge_762x51_M62.xob were used since they are closest thing which matches Lapua FMJ BT round.

Next, go to InventoryItemComponent and click on set class button next to Item Phys Attributes. Over there you will set inventory values which could be useful when i.e. taking single rounds (which normally in the game doesn't happen) try to tweak following parameters:

  • Weight - weight of the cartridge in kilograms - in this case it was set to 22 grams - influences weight of the magazine
  • Size Setup Strategy - change it to Volume
  • Item Volume - set it up to your linking. 7 is a good starting point
  • Size - change it to SLOT_1x1

armareforger-new-weapon-ammo-inventory.png

Ballistic Properties

Damage

AI Properties

-unknown feature ("wiki") defined-

Magazine Well

Magazine wells are classes which help to establish multi weapon (and mods) magazine compatibility. Any magazine which is using the selected class will be usable in any other weapon, which is using exactly the same magazine well.

In Arma Reforger, there are already plenty of magazine wells available but since this sample weapon is using rather unique magazine well, a new one has to be created.

📖
Recommended read: Script Editor documentation.

A new magazine well can be added to the list by creating a new script file in one of the game script folders (f.e. Scripts/Game/Weapon folder can be used - if you don't have such folder, then you need to create it manually). There are no requirements to the name of the script file but it is suggested to use the TAG_MagazineWell_ prefix naming convention. Such setup is sort of necessary since unlike models or prefabs, scripts don't use metafiles, and they can be replaced by placing file with exact name and relative location as original one. Once the script file is created and opened in Script Editor, the only remaining thing is to create a new class which inherits from BaseMagazineWell.

// Script File class MagazineWell65x39C_SampleWeaponClass {}; MagazineWell65x39C_SampleWeaponClass MagazineWell65x39C_SampleWeaponSource; class MagazineWell65x39C_SampleWeapon : BaseMagazineWell { };

In example above, new magazine well is called MagazineWell65x39C_SampleWeapon.

After magazine well is created, it will be necessary to recompile all game scripts via either Compile and Reload Scripts (⇧ Shift + F7) option in Script Editor or Reload Game Scripts (Ctrl + R) in World Editor.

Once scripts are compiled it should be possible to assign that class in Magazine Well property found both in MagazineComponent of magazine and MuzzleComponent of weapon. If there is already some class assigned in the Magazine Well property, then you can still change it by a right-click on it and selecting change class option from the context menu.

Magazine Prefab Setup

New magazine prefab can be easily created by inheriting from Magazine_Base.et prefab. Once new prefab inheriting from Magazine_Base.et is prepared, it is possible to assign magazine model in MeshObject.

Next step will be modification of magazine related properties in MagazineComponent. Over there, it is possible to set things like ammo which is used or capacity of magazine.

In InventoryItemComponent, similar to main weapon, it is possible to change inventory related properties like name or weight. In this example, values were set as on picture below.

Crates Filling

Once weapon and magazine are ready, it is possible to add those to crates, so they can be picked up either in Conflict armory or during Game Master sessions. In principle, there are two types of crates available in game:

  • Arsenal crates - those can be either unlimited or be single use. Closely tied to playable Factions. It is impossible to precisely specify the amount of available items.
  • Regular storage crates - using standard storage system, where creator defines exact amount of items, which are available inside of the crate.

Arsenal Crates

Adding new items to existing Faction Arsenals crates involves the following steps:

  • Creating override of existing Arsenal config - either ArsenalConfig_BLUFOR.conf (used by US Army), ArsenalConfig_INDFOR.conf (used by FIA) or ArsenalConfig_OPFOR.conf (used by the USSR faction) - by using Override in "addon name" functionality
  • Open overridden file and adding of new entry to Arsenal Items array by clicking on plus icon
  • Assigning prefab of item, which is supposed to be visible in Arsenal crate, to Item Resource Name property. This can be done either by clicking on button with two dots or by dragging and dropping prefab on this field
  • Selecting proper Item Type & Item Mode from the drop down menu
    • For rifles, Item Type can be set to RIFLE and Item Mode to WEAPON
    • For rifle magazines, Item Type can be set to RIFLE and Item Mode to AMMUNITION

Once those changes are performed, it might be necessary to Reload Game Scripts or even restart the Workbench; after that, those new items should be visible in existing crates in both Game Master and Conflict game mode

Regular Crates

If it is desired to have some specific amount of items, then it is possible to use UniversalInventoryStorageComponent (or its SCR_ equivalent) which can be added to basically to any entity with physics enabled.

Process of adding such custom create to in-game editor is not covered here and this subject is pretty well covered in the Asset Browser Mod Integration page.

First step is to locate the prefab where the new item should be stored. In this tutorial AmmoBox_545x39_2160rnd.et was duplicated to addon as AmmoBox_SampleWeaponMagazines.et and then used as an example on how to add new magazines to it. Once that duplicated prefab is present in target addon, following things have to be done:

  • Navigate to SCR_UniversalInventoryStorageComponent
  • Add new entry to Multi Slots array
  • Set Slot Template to InventoryStorageSlot and assign to it some unique name, i.e. Magazines
  • Assign magazine prefab to Prefab slot in this newly created Slot Template
  • Change number of items present in this slot by modifying Num Slots value (f.e. it can be set to 25)

After that, this crate should have 25 magazines of your choice inside.