This is an old revision of the document!
Using CBA extended eventhandlers, even though I think the vanilla game supports similar as well (class EventHandlers → class TAG → events..).
Anyhoo, first create a BACE baseclass under CfgWeapons, so you can inherit etc more easily without having to copy/paste the whole thing each time, etc
class NORTH_boltRifle_Base: Rifle_Base_F {
class NORTH_boltActionCasingEject {
class casingEject {//leave this class out if casing ejectging is not desired
casingType = "FXCartridge_762";
ejectTime = 0.8;
ejectTimeReload = 1;
ejectPosOffSet[] = {};
ejectVelocityRandom[] = {};
ejectVectorDir[] = {};
casingEjectSound[] = {{"NORTH_bace_brassting", 5}};
};
class boltAction {
actionName = "NORTH_M39Boltinganim";
actionDelay = 0;
actionSound[] = {
{"NORTH_m39_boltaction_01", 15, 0.25},
{"NORTH_m39_boltaction_02", 15, 0.25},
{"NORTH_m39_boltaction_03", 15, 0.25},
{"NORTH_m39_boltaction_04", 15, 0.25}
};
actionSoundPos = "";
actionSoundDelay = 0;
actionSoundEmpty[] = {};
actionSoundEmptyPos = "";
actionSoundEmptyDelay = 0;
};
};
class EventHandlers {
class NORTH_bace {
fired = "\
if (local (_this # 0)) then {\
_this call NORTH_bace_fnc_firedMain;\
};\
";
reload = "\
_this call NORTH_bace_fnc_reloadMagazine;\
";
reloaded = "_this call NORTH_bace_fnc_reloadedMagazine";
};
};
};
What the config tokens mean:
casingType
The casing to be ejected. CfgVehicles class, can not be left empty
ejectTime
Delay time in seconds, casing ejects after this delay. ReloadTime/2 is usually pretty close to bolt fully open. There is a short 0.15 second hardcoded pause in teh scripts, this may be a subject for change tho
EjectTimeReload
Delay time in seconds after magazine reload has been initiated. Casing ejects after this delay.
EjectPosOffSet
OPTIONAL. Offset for ejectPosition [x, y, z], some trial and error arbitrary values (see NORTH_bace_fnc_helper for, well, help..). If left empty default values used (ejectPosOffSet[] = {-0.14, 0.05})
ejectVelocityRandom
OPTIONAL velocity modifier for the ejected casings velocity, [x, y, z].
Use values compatible with the 'random' scripting command, as in number or array (of three numbers, see BIS wiki).
If left empty default values used:
ejectVelocityRandom[] = {{-0.5, 0, 1.5}, {-0.5, 0, 1.5}, {0.5, 1, 1.5}}
.
The final value applied to each velocity vector element is 2 * (random (ejectVelocityRandom select N)).
ejectVectorDir
OPTIONAL casing direction vector [x, y, z]. If left empty default values used
casingEjectSound
For autism, sound to play when casing is ejected.
For single sound format is {“CfgSounds class”, audible distance}, for example
casingEjectSound[] = {{"NORTH_bace_brassting", 5}};
When more than one sound is used format is {“CfgSounds class”, audible distance, weight}, for example
casingEjectSound[] = {
{"NORTH_bace_brassting0", 5, 0.3},
{"NORTH_bace_brassting1", 5, 0.3},
{"NORTH_bace_brassting2", 5, 0.3}
};
’weight’ is the a value used in weighted random, as in likelihood of being selected.
actionName
Class name for the gesture to be played when gun action is operated.
ActionDelay
Delay in seconds for delaying the above action gestire to be played after action is initiated
actionSound
Sound(s) to play when action is performed.
For single sound format is {CfgSounds class, audible distance}.
When more than one sound is used format is {“CfgSounds class”, audible distance, weight}, weight means the probability of the sound being played (weighted random).
For example:
actionSound[]={
{"my_sound_01", 10, 0.33},
{"my_sound_02", 10, 0.33},
{"my_sound_03", 10, 0.33}
};
actionSoundPos
Position where to play the above sound at, can be either a selection name (string) on the soldier model or a position (array) in MODEL SPACE.
NOTE that the sound will follow the selection used.
actionSoundDelay
Delay in seconds before the above sound is played
actionSoundEmpty
Sound to play when last shot has been fired. As in like the classic 'pling' when M1 Garand ejects the empty mag. Same rules apply as with all the previous sound definitions
actionSoundEmptyPos
Position where to play the above sound at, can be either a selection name (string) on the soldier model or a position (array) in MODEL SPACE.
NOTE that the sound will follow the selection used.
actionSoundEmptyDelay
Delay in seconds before the above sound is played
==== NORTH_bace_fnc_helper ====
This is a helper function to define the position for the casing eject, or any other eject position.
Preview with a player and when holding the wanted weapon execute [-0.14, 0.05] NORTH_bace_fnc_helper in the debug console.
It will create a helper object to visualize the position with. The position is the lowest corner of the helper object.
The position is calculated from the player's left hand position (“LeftHand” selection), and it's in model space. Values are in meters.
The values are [y, z], y = position along the weapon's length, z = height.
Default for bolt rifles is [-0.14, 0.05]
When you enter a new value and execute again the helper object moves to the set position.
Once the values are satisfactory copy/paste them into the config ejectPosOffSet[] array.
To exit the helper function add a third parameter true and execute it, as in something like [-0.14, 0.05, true] call NORTH_bace_fnc_helper