Arma 3 Scripting

Arma 3: Weapon Config Guidelines

  • Also known as Arma 3 Weapon Config Guidelines

Topic · Markdown · JSON · original wiki page

101 - How to set up a weapon for Arma 3

Please be aware of our Arma 3 modding license: http://community.bistudio.com/wiki/Arma_3_Modding_License

Additional functionality compared to A2/OA

Model requirements {p3d}

Model config changes {model.cfg}

{model.cfg}

class magazine_hide
{
    type = "hide";
    source = "reloadMagazine";
    selection = "magazine";
    minValue = 0.000000;
    maxValue = 1.00000;
    hideValue = 0.220;
    unhideValue = 0.550;
};

{model.cfg}

class magazine_reload_move_1
{
    type = "translation";
    source = "reloadMagazine";
    selection = "magazine";
    axis = "magazine_axis";
    minValue = 0.145;
    maxValue = 0.170;
    offset0 = 0.0;
    offset1 = 0.5;
};

{model.cfg}

class BackSight_optic
{
    type = "rotation";
    source = "hasOptics";
    selection = "BackSight";
    axis = "BackSight_axis";
    memory = 1;
    minValue = 0.0000000;
    maxValue = 1.0000000;
    angle0 = 0.000000;
    angle1 = (rad 90);
};

{model.cfg}

class OP_ROT
{
    type="rotation";
    source = "zeroing2";        // use second muzzle zeroing for rotation
    sourceAddress = "loop";        // loop when phase out of bounds
    selection = "OP";            // selection we want to rotate
    axis = "OP_axis";            // has its own axis
    minValue = 0;
    maxValue = 3;                // this weapon has array with 4 distances
    angle0 = "rad 0";
    angle1 = "rad 65";
};

{model.cfg}

class MuzzleFlashROT
{
    type = "rotationX";
    source = "ammoRandom";        // use ammo count as phase for animation
    sourceAddress = "loop";        // loop when phase out of bounds
    selection = "zasleh";        // selection we want to rotate
    axis = "";                    // no own axis - center of rotation is computed from selection
    centerFirstVertex = true;    // use first vertex of selection as center of rotation
    minValue = 0;
    maxValue = 4;                // rotation angle will be 360/4 = 90 degrees
    angle0 = "rad 0";
    angle1 = "rad 360";
};

New config parameters {config.cpp}

Slotable weapons

class SlotInfo;
class CowsSlot : SlotInfo
{
    // targetProxy
    linkProxy = "\A3\data_f\proxies\weapon_slots\TOP";

    // display name
    displayName = "$STR_A3_CowsSlot0";

    // class names with items supported by weapon
    compatibleItems[] = { "optic_Arco", "optic_aco", "optic_ACO_grn", "optic_hamr", "optic_Holosight" };
};
class PointerSlot : SlotInfo
{
    // targetProxy
    linkProxy = "\A3\data_f\proxies\weapon_slots\SIDE";

    // display name
    displayName = "$STR_A3_PointerSlot0";

    // class names with items supported by weapon
    compatibleItems[] = { "acc_flashlight", "acc_pointer_IR" };
};

class CfgWeapons
{
    class myWeapon
    {
        class WeaponSlotsInfo
        {
            mass = 4; // default mass of a weapon
            class MuzzleSlot : SlotInfo
            {
                // targetProxy
                linkProxy = "\A3\data_f\proxies\weapon_slots\MUZZLE";

                // display name
                displayName = "Muzzle Slot";

                // class names with items supported by weapon
                compatibleItems[] = {}; // moved to each weapon
            };
            class CowsSlot : CowsSlot {};
            class PointerSlot : PointerSlot {};
            allowedSlots[] = { 901 }; // you simply cannot put this into your pants
        };
    };
};

Muzzle accessories

class Mode_SemiAuto;
class CfgWeapons
{
    class ItemCore;
    class InventoryMuzzleItem_Base_F;
    class myMuzzleAccessory
    {
        scope = 2;
        displayName = "My Muzzle Accessory";

        picture = "\A3\weapons_F\Data\UI\myMuzzleAccessory_CA.paa";
        model = "\A3\weapons_f\acc\myMuzzleAccessory";

        class ItemInfo : InventoryMuzzleItem_Base_F
        {
            soundTypeIndex = 1; // index of sound in sounds[] in weapon modes (inherited 1 from parent class)

            class MagazineCoef
            {
                initSpeed = 0.8;
            };

            class AmmoCoef
            {
                hit = 0.8;
                visibleFire = 0.3;
                audibleFire = 0.8;
                visibleFireTime = 0.5;
                audibleFireTime = 1.0;
                cost = 1.0;
                typicalSpeed = 0.8;
                airFriction = 1.0;
            };

            muzzleEnd = "zaslehPoint";        // memory point in muzzle supressor's model
            alternativeFire = "Zasleh2";    // class in cfgWeapons with model of muzzle flash

            class MuzzleCoef
            {
                dispersionCoef = 1.0f;
                artilleryDispersionCoef = 1.0f;

                fireLightCoef = 0.1f;

                recoilCoef = 1.0f;
                recoilProneCoef = 1.0f;

                minRangeCoef = 1.0f; minRangeProbabCoef = 1.0f;
                midRangeCoef = 1.0f; midRangeProbabCoef = 1.0f;
                maxRangeCoef = 1.0f; maxRangeProbabCoef = 1.0f;
            };
        };
    };
};

Sound Values

class MyWeapon : Rifle_Base_F
{
    class Single : Mode_SemiAuto
    {
        sounds[] = { "StandardSound", "SilencedSound" };

        class BaseSoundModeType // this base class has base definitions that both standard and silenced sounds will inherit (sound of closure stays the same no matter what muzzle accessory is used)
        {
            weaponSoundEffect = "DefaultRifle";

            closure1[] = { "A3\sounds_f\weapons\closure\closure_rifle_2", db-12, 1, 10 };
            closure2[] = { "A3\sounds_f\weapons\closure\closure_rifle_3", db-12, 1, 10 };
            soundClosure[] = { closure1, 0.5, closure2, 0.5 };
        };

        class StandardSound : BaseSoundModeType // Sounds inside this class are used when soundTypeIndex = 0, according to sounds[]
        {
            begin1[] = { "A3\Sounds_F\weapons\SMG_02\SMG_02_st_1b", db0, 1, 500 };
            begin2[] = { "A3\Sounds_F\weapons\SMG_02\SMG_02_st_2b", db0, 1, 500 };
            begin3[] = { "A3\Sounds_F\weapons\SMG_02\SMG_02_st_3b", db0, 1, 500 };
            soundBegin[] = { begin1, 0.33, begin2, 0.33, begin3, 0.34 };
        };

        class SilencedSound : BaseSoundModeType // Sounds inside this class are used when soundTypeIndex = 1, according to sounds[]
        {
            begin1[] = { "A3\sounds_f\weapons\silenced\silent-07", db-1, 1, 200 };
            begin2[] = { "A3\sounds_f\weapons\silenced\silent-08", db-1, 1, 200 };
            soundBegin[] = { begin1, 0.5, begin2, 0.5 };
        };
        // various other fire mode parameters
    };
};

Optics

class cfgWeapons
{
    class ItemCore;
    class InventoryOpticsItem_Base_F;
    class myOpticsAccessory
    {
        scope = 2;
        displayName = "My Optics Accessory";

        picture = "\A3\weapons_F\Data\UI\myOpticsAccessory_CA.paa";
        model = "\A3\weapons_f\acc\myOpticsAccessory";
        weaponInfoType = "RscOptics_myOptics";

        class ItemInfo : InventoryOpticsItem_Base_F
        {
            mass = 7;
            modelOptics = "\A3\Weapons_f\acc\reticle_MyOptics_F";
            class OpticsModes
            {
                class MyOptics
                {
                    opticsID = 1;
                    useModelOptics = true;
                    opticsPPEffects[] = { "OpticsCHAbera1", "OpticsBlur1" };
                    opticsZoomMin = 0.0555;
                    opticsZoomMax = 0.1300;
                    opticsZoomInit= 0.1300;
                    discreteDistance[] = { 100, 300, 400, 500, 600, 700, 800, 900, 1000 };
                    discreteDistanceInitIndex = 1;
                    distanceZoomMin = 100;
                    distanceZoomMax = 1000;
                    nFovLimit = 0.07;
                    discreteFov[] = { 0.1300, 0.0555 };
                    discreteInitIndex = 0;
                    modelOptics[] = { "\A3\Weapons_f\acc\reticle_MyOptics_F", "\A3\Weapons_f\acc\reticle_MyOptics_z_F" };
                    memoryPointCamera = "opticView";
                    visionMode[] = { "Normal", "NVG" };
                    opticsFlare = true;
                    opticsDisablePeripherialVision = true;
                    cameraDir = "";
                };
                class IronOnTopOfMyOptics : MyOptics
                {
                    opticsID = 2;
                    useModelOptics = false;
                    opticsFlare = false;
                    opticsDisablePeripherialVision = false;
                    opticsZoomMin = 0.375;
                    opticsZoomMax = 1.1;
                    opticsZoomInit = 0.75;
                    memoryPointCamera = "eye";
                    visionMode[] = {};
                    discretefov[] = {};
                };
            };
        };
    };
};

Side Accessory

class cfgWeapons
{
    class ItemCore;
    class InventoryFlashLightItem_Base_F;
    class mySidesAccessory
    {
        scope = 2;
        displayName = "My Sides Accessory";

        picture = "\A3\weapons_F\Data\UI\mySidesAccessory_CA.paa";
        model = "\A3\weapons_f\acc\mySidesAccessory";

        class ItemInfo : InventoryFlashLightItem_Base_F
        {
            mass = 9;
            class Pointer
            {
                irLaserPos = "laser pos";
                irLaserEnd = "laser dir";
            };
            class FlashLight {};
        };
    };
};

Custom reload animations

class CfgMovesBasic
{
    class DefaultDie;
    class ManActions
    {
        reloadMyWeapon = "reloadMyWeapon";
    };
};

class CfgGesturesMale
{
    class Default;
    class States
    {
        class reloadMyWeapon : Default
        {
            file = "\A3\anims_f\Data\Anim\Sdr\wop\erc\stp\rld\rfl\reloadMyWeapon.rtm";
            looped = 0;
            speed = 0.400000;
            mask = "handsWeapon";
            headBobStrength = 0.200000;
            headBobMode = 2;
            rightHandIKBeg = 1;
            rightHandIKEnd = 1;
            leftHandIKCurve[] = { 0, 1, 0.050000, 0, 0.950000, 0, 1, 1 };
        };
    };
};

class cfgWeapons
{
    class myWeapon
    {
        reloadAction = "reloadMyWeapon";
    };
};

Underwater weapons

class Mode_SemiAuto;

class cfgWeapons
{
    class myWeapon
    {
        modes[] = { "Single" };    // this example weapon has just one fire mode
        canShootInWater = 1;    // allows to shoot under water
        class Single : Mode_SemiAuto
        {
            begin1[] = { "A3\sounds_f\weapons\myWeapon\myWeapon_st_1b.wav", db5, 1, 900 };
            begin2[] = { "A3\sounds_f\weapons\myWeapon\myWeapon_st_2b.wav", db5, 1, 900 };
            begin3[] = { "A3\sounds_f\weapons\myWeapon\myWeapon_st_3b.wav", db5, 1, 900 };
            soundBegin[] = { begin1, 0.33, begin2, 0.33, begin3, 0.34 }; // all three sounds have roughly the same probablity
            beginwater1[] = { "A3\sounds_f\weapons\myWeapon\underwater_myWeapon_st_1b.wav", db0, 1, 200 };
            beginwater2[] = { "A3\sounds_f\weapons\myWeapon\underwater_myWeapon_st_2b.wav", db5, 1, 200 };
            beginwater3[] = { "A3\sounds_f\weapons\myWeapon\underwater_myWeapon_st_3b.wav", db5, 1, 200 };
            soundBeginWater[] = { beginwater1, 0.33, beginwater2, 0.33, beginwater3, 0.34 }; // all three sounds have roughly the same probablity
        };
    };
};
class CfgAmmo
{
    class BulletBase;
    class myAmmo : BulletBase // for myWeapon
    {
        waterFriction = -0.00096;    // nearly direct line underwater
        timeToLive = 0.12;            // that's enough for 45 meters underwater
        effectFly = "AmmoUnderwater";
    };
};

Ammo changes on fly and on hit

submunitionConeType[] = { "random", 10 };
submunitionConeType[] = { "randomcenter", 10 };
submunitionConeType[] = { "randomupcone", 10 };
submunitionConeType[] = { "poissondisc", 10 };
submunitionConeType[] = { "poissondisccenter", 10 };
submunitionConeType[] = { "custom", { { 0, 0 }, { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } } };
class cfgAmmo
{
     class SubmunitionBase;
    class MyAmmo : SubmunitionBase
    {
        submunitionAmmo = "MySubmunitionAmmo";
        submunitionConeType[] = { "poissondisc", 10 };
        submunitionConeAngle = 10;
        triggerDistance = 100;
    };
};
class CfgAmmo
{
    class ShotDeployBase;
    class Mo_ClassicMineRange : ShotDeployBase
    {
        submunitionAmmo = "APERSMine_Range_Ammo";    // some random mine deployable by a mortar
        airFriction = 0;                            // artillery ammo works better without friction
        EffectFly = "ArtilleryTrails";                // some funky effect of smoke trails and stuff
    };
};

Explosion shielding

class cfgVehicles
{
    class myVehicle
    {
        class HitPoints
        {
            class HitLFWheel { armor = 0.12; explosionShielding = 0.8; };
        };
    };
};

Weapon inertia

class cfgWeapons
{
    class myWeapon
    {
        // inertia coefficient of the weapon
        inertia = 0.5;
    };
};

Inventory icons overlay method

class CfgWeapons
{
    class myWeapon
    {
        class WeaponSlotsInfo : WeaponSlotsInfo // default accessories for this slot, iconPicture and iconPinpoint is defined in the base class
        {
            class MuzzleSlot : MuzzleSlot
            {
                iconPosition[] = { 0.0, 0.45 };    // position of the slot icon inside of the weapon icon, relative to top-left corner in {right, down} format
                iconScale = 0.2;                // scale of icon described in iconPicture
                iconPicture = "\A3\Weapons_F\Data\UI\attachment_muzzle.paa"; // icon for selected slot
                iconPinpoint = "Center";        // top, bottom, left, right, center alignment of the icon on snap point
            };
            class CowsSlot : CowsSlot // default accessories for this slot, iconPicture and iconPinpoint is defined in the base class
            {
                iconPosition[] = { 0.5, 0.35 };
                iconScale = 0.2;
            };
            class PointerSlot : PointerSlot // default accessories for this slot, iconPicture and iconPinpoint is defined in the base class
            {
                iconPosition[] = { 0.20, 0.45 };
                iconScale = 0.25;
            };
        };
        icon = "\A3\MyAddon\Rifles\MyRifle\Data\MyRifle_X_CA.paa" // this stays the same as before and is used as a base layer
    };
};

Magazine compatibility groups

class cfgWeapons
{
    class arifle_MX_Base_F;
    class rhs_weap_m4_Base : arifle_MX_Base_F
    {
        // ...
        // first magazine in array is used as a default magazine in Virtual Arsenal
        // Eden editor ammo crates widget is also using that array to create list of compatible magazine which can be placed in crate
        magazines[] =
        {
            "rhs_mag_30Rnd_556x45_M855A1_Stanag"
        };
        // Link to magazine wells
        magazineWell[] = { "STANAG_556x45" };
    };
};

// Located in root config
class CfgMagazineWells
{
    class STANAG_556x45
    {
        // Magazines listed by mod
        // It is possible to add new arrays to class but for now inheritance (i.e. STANAG_556x45_New: STANAG_556x45 {};) is not supported
        RHS_Magazines[] =
        {
            "rhs_mag_30Rnd_556x45_M855_Stanag",
            "rhs_mag_30Rnd_556x45_M855_Stanag_Tracer_Red",
            "rhs_mag_30Rnd_556x45_M855_Stanag_Tracer_Green",
            "rhs_mag_30Rnd_556x45_M855_Stanag_Tracer_Yellow",
            "rhs_mag_30Rnd_556x45_M855_Stanag_Tracer_Orange",

            "rhs_mag_100Rnd_556x45_M855A1_cmag",
            "rhs_mag_100Rnd_556x45_M855A1_cmag_mixed",
            "rhs_mag_100Rnd_556x45_M855_cmag",
            "rhs_mag_100Rnd_556x45_M855_cmag_mixed",
            "rhs_mag_100Rnd_556x45_Mk318_cmag",
            "rhs_mag_100Rnd_556x45_Mk262_cmag"
        };
        // Magazines defined
        BI_Magazines[] =
        {
            "30Rnd_556x45_Stanag",
            "30Rnd_556x45_Stanag_Tracer_Red",
            "30Rnd_556x45_Stanag_Tracer_Green",
            "30Rnd_556x45_Stanag_Tracer_Yellow"
        };
    };
};

Bipods

class CfgWeapons
{
    class ItemCore;
    class InventoryUnderItem_Base_F;
    class test_bipod_01_F : ItemCore
    {
        scope        = 2;                                                            // available in Arsenal
        displayName    = "My Little Bipod";                                            // name of item in Inventory (and Arsenal)
        picture        = "\A3\Weapons_F_Mark\Data\UI\gear_accu_bipod_01_snd_CA.paa";    // icon in Inventory
        model        = "\Samples_f\Test_weapon_01\test_bipod_01_F.p3d";                // path to model

        class ItemInfo : InventoryUnderItem_Base_F
        {
            deployedPivot        = "bipod";    // what point should be used to be on surface while unfolded
            hasBipod            = true;        // bipod obviously has a bipod
            mass                = 10;        // what is the mass of the object
            soundBipodDown[]    = { "A3\Sounds_F_Mark\arsenal\sfx\bipods\Bipod_AAF_down", db-3, 1, 20 };    // sound of unfolding the bipod
            soundBipodUp[]        = { "A3\Sounds_F_Mark\arsenal\sfx\bipods\Bipod_AAF_up", db-3, 1, 20 };        // sound of folding the bipod
        };
        inertia = 0.2; // how much does the bipod add to inertia of the weapon
    };
};
class cfgWeapons
{
    class myWeapon
    {
        deployedPivot        = "bipod";    // what point should be used to be on surface while unfolded
        hasBipod            = true;        // a weapon with bipod obviously has a bipod
        soundBipodDown[]    = { "A3\Sounds_F_Mark\arsenal\sfx\bipods\Bipod_AAF_down", db-3, 1, 20 };    // sound of unfolding the bipod
        soundBipodUp[]        = { "A3\Sounds_F_Mark\arsenal\sfx\bipods\Bipod_AAF_up", db-3, 1, 20 };        // sound of folding the bipod
    };
};

{model.cfg}

class legs
{
    type            = rotation;
    source            = bipod_legs; // this one is for an attachment, weapon itself would have just bipod
    sourceAddress    = clamp;
    selection        = "bipod_legs";
    axis            = "bipod_legs_axis";
    minValue        = 0;
    maxValue        = 1;
    angle0            = (rad 0);
    angle1            = (rad 90);
};

{model.cfg}

class Leg_L_move // we use different animation for each leg as they are folded by default and rotate while unfolding, this one is for the left one
{
    type        = translation;
    source        = bipod_legs_length;
    selection    = "Leg_L";
    axis        = "Leg_L_axis"; // the axis is part of "bipod_legs" selection in model
    memory        = 1;
    minValue    = 0;
    maxValue    = 0.1;    // this #bipod extends up to 10 centimeters for example
    offset0        = 0;
    offset1        = 1;    // we use axis with length of 10 centimeters, that means translation needs to be multiplied by ten
};

Pistol holsters

class Pistol;
class Pistol_Base_F : Pistol
{
    class WeaponSlotsInfo;
};
class MyLittlePistol : Pistol_Base_F
{
    class WeaponSlotsInfo : WeaponSlotsInfo
    {
        holsterOffset = "holster";    // name of a memory point in weapon to serve as zero of the model
        holsterScale = 1;            // scale of gun in holster relative to standard size (0.5 means the gun is 50 % of original size)
    };
};

Magazine Proxies

Virtual Arsenal visibility

class cfgWeapons
{
    class myWeapon
    {
        baseWeapon = "myWeapon";
    };
    class myWeapon2 : myWeapon
    {
    };
    class myWeapon3 : myWeapon
    {
        baseWeapon = "myWeapon3";
    };
};

See Also