Forum Jump :

Author Message


Posts: 51
Rank:


Level: Member

Country: ca
Location: Victoria, British Columbia
Occupation: Canadian Forces Weapon Technician
Age:
In-game name: PiZZADOX

 
#1 Posted at 2015-01-13 00:28        
     
I am attempting to detect player weapon status, and since the weaponLowered command has not been ported to Arma 2 in an update and I doubt it would unfortunately, has anyone had any luck in making a function to return whether the weapon is lowered or raised? I would have figured that the action "WeaponOnBack" would have a check before it executed, but I haven't found anything yet.

I really don't want to reinvent the wheel haha, so far all I have is a series of selectionposition checks that have to be relative to stance, animation state, etc. That, or eventhandlers that rely on the assumption that the player starts with their weapon raised and shouts a variable when the player lowers their weapon.

Any ideas?

Edit:
//attempts to find weapon state = lowered or raised based on animation name

_unit = _this;
_haswep = primaryWeapon _unit;
_state = animationstate _unit;

hint format ["started with animation name\n%1",_state];

sleep 3;

if (primaryweapon _unit == "") exitwith {hint "player has no weapon!"};

sleep 1;

_raisedresult = [_state, "Sras"] call CBA_fnc_find;
_raisedresult2 = [_state, "sras"] call CBA_fnc_find;

if ((_raisedresult >= 0) || (_raisedresult2 >= 0)) exitwith {hint "player's weapon is raised"};

sleep 1;

_loweredresult = [_state, "Slow"] call CBA_fnc_find;
_loweredresult2 = [_state, "slow"] call CBA_fnc_find;

if ((_loweredresult >= 0) || (_loweredresult2 >= 0)) exitwith {hint "player's weapon is lowered"};

hint "unsuccessful search\n :(";

Thank god for CBA functions. :)

Its not perfect if you have custom animations but it seems BIS stuck to a somewhat logical animation naming system.

This post was edited by PiZZADOX (2015-01-13 02:02, ago)