Weapon Creation – Arma Reforger

From Bohemia Interactive Community
Jump to navigation Jump to search
(→‎Arsenal crates: - added links)
Line 519: Line 519:


===Adding weapon & magazines to crates===
===Adding weapon & magazines to crates===
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:
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 amount of available items.
*'''Arsenal crates''' - those can be either unlimited or be single use. Closely tied to '''playable Factions.''' It is impossible to precisely specify amount of available items.
Line 527: Line 527:
Adding new items to existing '''Faction Arsenals''' crates involves following steps:
Adding new items to existing '''Faction Arsenals''' crates involves 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 USSR faction'') - by using '''Override in "addon name"''' functionality
*Creating override of '''existing Arsenal config''' - either '''[https://enfusionengine.com/api/redirect?to=enfusion://ResourceManager/~ArmaReforger:Configs/Arsenal/ArsenalConfig_BLUFOR.conf ArsenalConfig_BLUFOR.conf]''' (''used by US Army''), '''[https://enfusionengine.com/api/redirect?to=enfusion://ResourceManager/~ArmaReforger:Configs/Arsenal/ArsenalConfig_INDFOR.conf ArsenalConfig_INDFOR.conf]''' (''used by FIA'') or '''[https://enfusionengine.com/api/redirect?to=enfusion://ResourceManager/~ArmaReforger:Configs/Arsenal/ArsenalConfig_OPFOR.conf ArsenalConfig_OPFOR.conf]''' (''used by USSR faction'') - by using '''[[Arma Reforger:Data Modding Basics#Using .22Override in....22 function|Override in "addon name"]]''' functionality
*Open overridden file and adding of new entry to '''Arsenal Items''' array by clicking on plus icon
*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
*'''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
Line 540: Line 540:
{{Feature|informative|Process of adding such custom create to in-game editor is not covered here and this subject is pretty well covered on [[Arma_Reforger:Asset_Browser_Mod_Integration|'''Asset Browser Mod Integration''']] page.}}
{{Feature|informative|Process of adding such custom create to in-game editor is not covered here and this subject is pretty well covered on [[Arma_Reforger:Asset_Browser_Mod_Integration|'''Asset Browser Mod Integration''']] page.}}


First step, would be locating prefab where 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:
First step, would be locating prefab where new item should be stored. In this tutorial '''[https://enfusionengine.com/api/redirect?to=enfusion://ResourceManager/~ArmaReforger:Prefabs/Props/Military/AmmoBoxes/AmmoBox_545x39_2160rnd.et AmmoBox_545x39_2160rnd.et]''' was [[Arma Reforger:Data Modding Basics#Using .22Duplicate to....22 function|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'''
*Navigate to '''SCR_UniversalInventoryStorageComponent'''

Revision as of 10:12, 6 March 2023

Goals of this tutorial

In this tutorial you will learn about:

  • Importing your first FBX file
  • Adding sockets & skeleton
  • How to configure new weapon
If you don't have any experience with Workbench yet, it is recommended to go through modded weapon tutorial to familiarize with some of the concepts present in the Workbench
📥
Sources files for this tutorial can be found on Arma Reforger Samples Github repository

Adding new weapon

Preparation phase consist of things like:
  • Preparing basic structure
  • Preparing mesh
  • Exporting mesh

Preparing structure

While keeping to official structure is not mandatory and there are no engine restrictions asset wise about it, it's recommended to follow guidelines listed here - Data (file) structure - to ensure that all automation plugins are parsing your assets correctly and make it later easy to navigate.

Therefore, your first task will be preparing following file structure

armareforger-new-weapon-file-structure.png

Preparing mesh

This tutorial will try to cover procedure for plugging in new weapon into Enfusion Workbench. While tutorial might be more focused on Blender users, other software users shouldn't be worried since most of the things are working very similar in other programs.

Object orientation

One of the most important thing to begin with is making sure that your model is properly orientated. As per Arma Reforger:FBX Import page:

Everything must be oriented as pointing along/towards the Y+ axis in Blender and 3dsMax and along Z+ axis in Maya

That means, when you are importing A3 weapon you need to rotate it by 90 degrees to the left.

Cutting object to parts

Most likely model that you might already have few bits already present in the mesh. Since Enfusion allows you to assemble weapon from multiple parts, we will split our mesh into multiple separate objects to achieve much higher customization of weapon.

armareforger-new-weapon-cutting-parts.gif

In this case, sample contains two parts which could be potentially moved to separate files, letting you to have 3 variants in total quite easily. As marked on above video, grip & iron sights were moved to separate FBX files. Magazine was already separated for that particular mesh so only remaining thing to do is adding slot points for those accessories.

Naming of objects

When it comes to naming, there are few important rules to keep in mind.

  1. _LODx suffix is used to indicate Level of Details
  2. UBX_, UCX_, USP_, UCS_, UCL_, UTM_ prefixes are used to mark Colliders
  3. OCC_ prefix is used for Geometry Occluders

Beside that, there are also some additional guidelines regarding naming of the objects - slot/snap points naming convention - itself which don't have effect on how mesh is processed by engine (like those mentioned above) but are there to have consistency. It's also worth to note that some of base weapon prefabs are using some of those names by default (they can be of course changed but it's strongly advised to follow those rules nevertheless).

Adding slots/snap points

If you had experience with Arma 3 modding, then whole concept of having slots & snap points should be fairly familiar to you. Those dummy objects are serving as memory points - there is one major difference though - you no longer have to place two points to make an axis. Instead, rotation of dummy object is used.

In Blender, you can use one of the empty objects like Plain Axis to create those helper points.

armareforger-new-weapon-empty-snap.jpg

armareforger-new-weapon-empty-create.png

Please notice Plain Axis gizmo - this is the orientation of the model. Make sure that your empty object is properly aligned

armareforger-new-weapon-empty-rotate.png

One easy method to have slot & snap points correctly aligned is to create first slot points, when the mesh is still in one piece, and then copy paste mesh & empty socket to new empty scene. After that only thing left is to rename slot_XX to snap_XX .

On Sample Weapon, following slots were created:

  • slot_ironsight_front & slot_ironsight_rear - slots for picattinny mounted ironsights
  • slot_magazine - slot for magazine well
  • slot_optics - slot for top mounted optics
  • slot_underbarrel - slot for bottom mounted accessories like bipod

Additional, following empty objects were created for various components:

  • snap_hand_right - helper point for weapon deployment
  • barrel_chamber & barrel_muzzle - those points are used in MuzzleComponent to determine location & direction where bullet is spawned
  • eye - point for aiming down sight view. Used in SightsComponent

Colliders & material names

Colliders are special type of objects which are used to calculate various kinds of collisions - be it physic simulation or tracing of bullet penetration. There are few rules regarding those colliders and most of them listed FBX Import - Colliders usage page.

Weapon requires at least one collider with Weapon layer preset - if you don't have it, then weapon actions like equip will be missing from it. If your geometry is simple enough, it is possible to just use one collider for both weapon & fire geometry collision. Otherwise it might be necessary to have two colliders:

  • One for Weapon collision - should be very simple collider (i.e. convex)
  • Another for FireGeo collision - can be more detailed, trimesh can be used to provide best experience available.

When importing asset from previous Arma game - like in this example - you are most likely going to have already convex components ready from Geometry, Fire Geometry, View Geometry or Geometry Physx LODs and in this case automatically Fire Geometry LOD from Arma 3 were used as FireGeo and mesh from Geometry LOD was used for Weapon layer.

Now you might ask how to assign Layer Presets. If you are using Blender, there is small handy tool - Objects Tool - which is part of Enfusion Blender Tools to assist you with assigning correct game materials & layer presets on colliders.Otherwise, take a look at FBX Import page where there are instructions how to set that parameter in 3DS Max or Maya.

You can use Model Quality Assurance to verify if your colliders are convex by checking UCX Collider option.

Setting skeleton & rigging mesh

Creating skeleton

Whether it's new model or mesh imported from P3D, most likely it will be necessary to prepare skeleton. In Blender skeletons are called Armatures and their creation process is quite straightforward. Starting with creation of Armature itself, this can be done by selecting Armature option from Add menu in top section of the viewport while being in Object mode.

armareforger-new-weapon-adding-armature.gif

It is recommended to keep your armature called Armature since in such scenario, you will avoid artificial bone in skeleton hierarchy when mesh is imported in Workbench. While it might be not causing any issue on rifles, it is basically a necessary thing when importing character related gear.

Once its created, you might notice that root bone is quite large and might wish to resize it - to do so, switch to Edit Mode and select that Bone and then reduce its size to some reasonable level. armareforger-new-weapon-scale-bone.gif

Armature should be located at 0,0,0 point and use 1.0 scale. Otherwise you might encounter some problems when trying to animate it in Blender at later stage.

Next step will be rotation of this bone towards the front of the weapon and then renaming it to w_root - this bone will serve us a root bone of this mesh.

armareforger-new-weapon-rotating-naming-bone.gif

Creating bones

After basics of armature are done, it is time to add bones for all animated parts on the weapon. While in Edit Mode and with Armature selected, it is possible to add new bones through either:

  • Add→Single Bone option in top bar of viewport
  • By duplicating bone already present in the armature - like w_root

If you choose the first option, then it will be necessary to resize & rotate the new bone to the desired size. Duplication doesn't have this problem, so it was chosen to create the fire mode switch bone - w_fire_mode. It is also important to keep the hierarchy of bones in order, and in this case it means that all bones responsible for moving parts of the weapon - like w_fire_mode - should be parented to w_root. This can be done selecting bone in Edit Mode and then changing Parent property in Relations section of Bone properties tab.

armareforger-new-weapon-duplicating-bones.gif

Consider setting bones visibility to In Front - this will help with placement of the bones.
armareforger-new-weapon-set-bone-in-front.png

There are also few thing to keep in mind when creating bones and below is list of those things:

  • Bones will serve as axis for any further motion so try to place them in spots which would result in reasonable motion, like center of fire selector pivot point or center of bolt.
  • Keep Y+ orientation of the bones - this might be especially handy is some action is using center of bone for actions
  • While it's not necessary, it is recommended to use vanilla naming convention for bones - this will be especially useful when dealing with animation export, since vanilla animation export profiles expects such bone names.
    • It is still possible to use custom names but this might require custom export profiles - more about it will mentioned in chapter covering animation of weapon

With this knowledge in mind, it should be possible to create rest of the bones like w_trigger, w_charging_handle and w_bolt.

armareforger-new-weapon-bones-end-result.png

Skinning mesh

Skinning of the mesh depends on the software that you are using and if you don't know how to do it in software of your choice, it is recommended to search for some tutorials on the web what skinning of bones is.

If you imported model from P3D via Enfusion Blender Tools then most likely you will have some vertex groups already - in this case you can try to rename those so they match skeleton bone names.
📖
Recommended read: Official Blender documentation - Assigning a Vertex Group

If you are using Blender, here you can find short instruction how to quickly setup skinning on object. In example below, w_bolt bone will be set

  1. Switch to Object Mode
  2. Select object which you want to skin - in this it is body_02_LOD0
  3. In Modifiers Properties tab, add Armature modifier via Add Modifier button
  4. In Object Data Properties expand Vertex Group panel
  5. Switch to Edit Mode and then activate face selection mode
  6. Select faces which should belong to bolt
  7. In Vertex Group section, click on plus button to Add Vertex Group
  8. Double click with Left Mouse Button on it and change name of that new vertex group from Group to w_bolt
  9. Click on Assign button in Vertex Groups section (assuming you still have selected bolt faces in viewport) - this will assign your current selection in viewport to w_bolt vertex group with full influence (influence is controlled by Weight property)any log

armareforger-new-weapon-set-skinning.gif

At this stage w_bolt bone should be successfully rigged but that is not the end of the process!

Below section applies to any 3D software!

When creating skinned objects, Enfusion Workbench expects that the whole object is skinned to some bone. WarningOtherwise importer will try to "fix" it by skinning remaining faces to some root bone and in console log you will see below message:Warning

RESOURCES (W): Missing some mesh skinning weights (Object_LOD0). Weighting them to root


In Blender realms, this means that any object which Armature modifier, must be fully skinned to some existing bone through vertex groups. In this case it means that all faces, beside those which belongs to w_bolt vertex group, on body_02_LOD0 object has to be skinned to w_root bone. In this case it was done by selecting faces belonging to w_bolt and then inverting the selection via CTRL+I shortcut. After that, new vertex group called w_root was created and current selection was assigned to it via Assign button.

armareforger-new-weapon-set-skinning-root.gif

Rigging colliders

If you have some animated collider please keep in mind that only trimesh colliders can be skinned. In all other cases you have to use 100% weight.

In Blender it gets even bit more tricky and Object Relations (in Object tab) have to be used if you want connect non trimesh collider to some skeleton bone.

armareforger-new-weapon-relations.png

It is also recommended to parent slots on the weapon to the Armature - it is not necessary to parent it to w_root bone though. This should make it easier to snap magazine in reload sequence for instance

FBX export settings

Most of the general rules can be found on FBX Import page . In principle, when exporting from i.e. 3DS Max, you have to make sure that you are exporting in binary format in version 2014/2015. Furthermore, Triangulation & Preserve Edge Orientation should be turned off.

Blender wise, there are 3 most important things to keep in mind when exporting FBX

1. Object Types:

For animated object like weapon you need to have checked on at least:

Empty - which handles all snap points

Armature - exports skeleton of your weapon

Mesh - self explanatory

armareforger-new-weapon-export-blender2.png
2. Custom Properties:

Without this option all custom properties like LayerPresets would be lost!

3. Leaf bones:

Leaf bones are completely unnecessary in Enfusion and it's better to have that option turned off

Preparing textures

When importing textures of weapon from previous Real Virtuality games like Arma 3 there is no real automated or simple method of conversion spec-gloss textures to PBR (Physicial Based Rendering) Metal Rough ones - current industry standard. Therefore in most cases it's much easier to do textures from scratch in i.e. Substance Painter.

There are tons of materials on the internet how to create proper PBR texture and it's highly recommend to search for it via some popular search engines.


Importing Mesh

In this chapter following topics will be explained
  • Importing new model
  • Importing textures

Importing & registering new model

Once mesh was successfully prepared and all selections, sockets & snap points are in place, it's time to try our asset in game. Majority of the process is already pretty well described on FBX import - Import process in the Workbench page.

In principle, all you have to do is click with right mouse button on your FBX files and select Register and Import option from the context menu

Checking colliders & materials

After initial import was done it's time to make sure that materials & colliders are using proper materials & colliders. By default, Enfusion will try to assign material based on the name of the assigned texture in mesh. If it fails to find such texture, new dummy material (see area marked in orange on screen below) will be created next to the FBX model.

There are 2 typical errors when it comes to collider configuration:

Colliders errors example
Make sure that you have "usage" property defined in collider object properties.

armareforger-fbx-layers-blender-1.png

More info about it can be found on Arma_Reforger:FBX_Import
Make sure that correct material is assigned to all colliders

armareforger-new-weapon-colliders-material.png

More info about it can be found on Arma_Reforger:FBX_Import

Skeleton & hierarchy

Import Settings tab

Next we will take care of bones - in this case, magazine object has only empty objects (snap point) and to import them, checking of Export Scene Hierarchy in Miscellaneous section of Import Settings tab should be enough.

In case of skinned assets like rifles, Export Skinning option should be used instead. It might be also good to know that Export Scene Hierarchy is not necessary when Export Skinning option is selected.

Below process of setting Export Scene Scene Hierarchy on magazine is showcased and then analogical process of using of Export Skinning on SampleWeapon_01.xob is presented.

If for some reason you don't see bones icon on SampleWeapon_01.xob even after checking Export Skinning and reimporting resource, make sure that you have properly skinned your model in 3D software of your choice.

Importing hierarchy on magazine
Importing skinning on weapon
Changes made in Import Settings tab are only applied to model after manually reimporting model via Reimport resource (PC) button.

Importing textures

In principle, you can use same procedures as the ones described on Weapon Modding page.

📖
Recommended read: Textures

By default, Workbench should already create some of the materials based on their material name in FBX, so in case of SampleWeapon_01.xob, there should be already some emats which needs to be properly configured.

  • SampleWeapon_01_Camo1.emat material with two textures
    • SampleWeapon_01_Camo1_BCR - Base color + Roughness
    • SampleWeapon_01_Camo1_NMO - Normal map
  • SampleWeapon_01_Camo2.emat also with two textures
    • SampleWeapon_01_Camo2_BCR - Base color + Roughness
    • SampleWeapon_01_Camo2_NMO - Normal map

armareforger-new-weapon-materials.png

Since in this example, magazine is sharing textures with rifle itself, it is necessary to adjust textures over there. To do so, double click on XOB file of magazine to open it in new Resource Manager tab. After that, it is possible to set up materials which were previously created for the weapon itself.

Materials can be assigned in 2 ways:

  • Drag and dropping desired material on material icon in Materials tab
    • This action will automatically reimport model with selected material
  • Changing Material Assign in Visual section of Import Settings
    • It will be necessary to click on Reimport resource (PC) button after applying changes

Below is showcase of first method:

Weapon configuration

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's 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 nameofweapon_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 Prefabs/Weapons/Rifles folder.

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

Changing inventory parameters

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 recommend to finish this part of the tutorial first!

When looking at SCR_WeaponAttachmentsStorageComponent, multiple Attributes can be observed like:

  • 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, 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 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.

Configuring actions

Adding new 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.

Adjusting action contexts

Using ActionsManagerComponent debugs

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

Changing location of action contexts

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

Adjusting radius of action contexts

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.

Configuring 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 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's 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's 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 ( https://en.wikipedia.org/wiki/Burst_mode_(weapons) )
  • InterruptibleAndReseting - same as above but without burst memory

Configuring weapon behavior

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

Setting zeroing adjustments

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 AK74 as an example. Unlike in Arma 3, weapons in 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's 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 11 zeroing modes.

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

Each SightRangeInfo has Range parameter - which need to be filled manually - and 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:

  • 0.0 animation source, 440m
  • 0.1 animation source, 100m
  • 0.2 animation source, 200m
  • 0.3 animation source, 300m
  • 0.4 animation source, 400m
  • 0.5 animation source, 500m
  • 0.6 animation source, 600m
  • 0.7 animation source, 700m
  • 0.8 animation source, 800m
  • 0.9 animation source, 900m
  • 1.0 animation source, 1000m
Zeroing generator doesn't 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. Therefor, 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.

Creating new ammo

Creating new Magazine Well

Magazine wells are classes, which help to establish multi weapon (& mods) magazine compatibility. Any magazine which is using selected class will be usable in any other weapon, which is using exactly 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

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 MagazineWell_ prefix naming convention where prefix is name of your addon. 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 script 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 Magazine Well property, then you can still change it by clicking on it with Right Mouse Buttonand selecting change class option from the context menu.

Basic 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.

Adding weapon & magazines to crates

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 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 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 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 storage crates

If it is desired to have some specific amount of items, then it is possible to utilize 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 on Asset Browser Mod Integration page.

First step, would be locating prefab where 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

Continuation

Next part - Weapon animations