Now I read with interest this forum. This topic, of course, very old, and maybe there is some movement in that direction. But still, I will share a way free from the above-mentioned shortcomings.
// Initially, several useful functions
#define arg(X) (_this select (X))
//
// funcReadActionsProp
// syntax: [string unitClassName, string targetAnimation, string propertyName] call funcReadActionsProp
//
funcReadActionsProp = {
private "_moves";
_moves = getText ( configFile >> "CfgVehicles" >> arg(0) >> "moves" );
configFile >> _moves >> "Actions" >> getText (
configFile >> _moves >> "States" >> arg(1) >> "actions"
) >> arg(2)
};
//
// funcReadUpDegree
// syntax: (object soldier) call funcReadUpDegree
// Returns the value of the property UpDegree (AI Animation State) of the animation for the specified unit. Number type
// Possible values are defined in config game:
// enum {
// MANPOSNOWEAPON = 12,
// MANPOSHANDGUNSTAND = 9,
// MANPOSCROUCH = 6,
// MANPOSHANDGUNLYING = 5,
// MANPOSHANDGUNCROUCH = 7,
// MANPOSBINOCSTAND = 14,
// MANPOSDEAD = 0,
// MANPOSCOMBAT = 8,
// MANPOSBINOCLYING = 2,
// MANPOSSTAND = 10,
// MANPOSSWIMMING = 11,
// MANPOSWEAPON = 1,
// MANPOSLYING = 4,
// MANPOSLYINGNOWEAPON = 3,
// MANPOSBINOC = 13
// }
//
funcReadUpDegree = {
getNumber ( [typeOf _this, animationState _this, "upDegree"] call funcReadActionsProp )
};
//
// funcReadWeaponType
// syntax: (string weaponClassName) call funcReadWeaponType
// Returns the type of the weapon slot.
// One of the following:
// WeaponNoSlot 0 // Dummy weapons
// WeaponSlotPrimary 1 // Primary weapon
// WeaponSlotHandGun 2 // Handgun slot
// WeaponSlotSecondary 4 // Secondary weapon (launcher)
// WeaponSlotHandGunMag 16 // Handgun magazines (8x)(or grenades for M203/GP-25)
// WeaponSlotMag 256 // Magazine slots (12x / 8x for medics)
// WeaponSlotGoggle 4096 // Goggle slot (2x)
// WeaponHardMounted 65536 //
//
funcReadWeaponType = {
getNumber ( configFile >> "CfgWeapons" >> _this >> "type" )
};
/*
So, based on the definitions upDegree, we have
Rifle = 6, 8, 10, 4
Pistole = 9, 5, 7
AT = 1
Binoc = 2, 13, 14
thus, funcWeaponInHand as follows:
*/
funcWeaponInHand = {
private "_upDegree";
_upDegree = _this call funcReadUpDegree;
{
if( _upDegree in (
switch (_x call funcReadWeaponType) do {
case 1: {[6, 8, 10, 4]}; // primary weapon
case 5: {[6, 8, 10, 4]}; // and maschinegun also (primary and secondary weapon slot)
case 2: {[9, 5, 7]}; // handgun slot
case 4: {[1]}; // secondary weapon slot
case 4096: {[2, 13, 14]}; // goggle slot
default {[]};
}
))exitWith{ _x }; ""
} foreach weapons _this
};