Skip to content

Weapon Animations Framework

jonpas edited this page Nov 10, 2018 · 5 revisions

requires CBA_A3 v3.6.0 or later

CBA includes a framework to animate bolt operated weapons and pump-action shotguns.

Config template

class CfgWeapons {
    class My_Weapon_Base;
    class My_Weapon: My_Weapon_Base {
        class EventHandlers {
            fired = "_this call CBA_fnc_weaponEvents"; // this weapon eventhandler is required!
        };
        class CBA_weaponEvents {
            handAction = "My_Bolt_Action_Animation"; // A hand animation played after every shot. Defined in CfgGesturesMale and CfgMovesBasic.
            sound = "My_Bolt_Action_Sound"; // A sound played along the animation. Defined in CfgSounds.
            soundLocation = "LeftHandMiddle1"; // Where the sound is played. Selection on the soldier, not the weapon! Alternative: RightHandMiddle1
            delay = 0.1; // Delay for sound and hand animation to start after the weapon has been shot, in seconds (default: 0).
            onEmpty = 0; // 1: Play sound and animation defined above on the last round, 0: don't (default: 1); The sound below is played anyway!
            hasOptic = 1; // Set to 1 to do optic check with inbuilt optic (no attachment) (default: 0).
            soundEmpty = ""; // Sound played after the last round of the magazine was shot.
            soundLocationEmpty = ""; // Where the sound for the last round is played. Same as soundLocation.
        };
    };
};

The Animation used as handAction has to be configured exactly like a reloadAction from the base game. Therefore, this guide can be followed for the most part.

The sound has to be configured in a similar way. This template for missions can be followed. It works the same for addons.

soundLocation must be a selection from the soldier. It can not be a selection in the weapon. The most suitable selections are RightHandMiddle1 and LeftHandMiddle1.

If the animation and sound should not be played for the last round of the magazine, onEmpty has to be set to 0.

Example config for LRR using a suitable rtm file from the base game

//requiredAddons A3_Anims_F_Config_Sdr

class CfgMovesBasic {
    class ManActions {
        CBA_GestureFireLRR = "CBA_GestureFireLRR";
    };
    class Actions {
        class NoActions: ManActions {
            CBA_GestureFireLRR[] = {"CBA_GestureFireLRR", "Gesture"};
        };
    };
};

class CfgGesturesMale {
    class States {
        class GestureReloadBase;
        class CBA_GestureFireLRR: GestureReloadBase {
            file = "a3\anims_f\data\anim\sdr\gst\gesturefirelrr.rtm";
            speed = -2.33;
            rightHandIKCurve[] = {0, 1, 0.08, 0, 0.92, 0, 1, 1};
        };
    };
};

class CfgWeapons {
    class Rifle_Long_Base_F;
    class LRR_base_F: Rifle_Long_Base_F {
        class EventHandlers {
            fired = "_this call CBA_fnc_weaponEvents";
        };
        class CBA_weaponEvents {
            handAction = "CBA_GestureFireLRR";
            sound = "";
            soundLocation = "RightHandMiddle1";
            onEmpty = 0;
        };
    };
};