fn_slingHelmet.sqf 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. _unit = _this select 0;
  2. _side = _this select 1;
  3. _helmetAttached = _unit getVariable ["GEARF_HelmetAttached", false];
  4. if (headgear _unit == "") then {
  5. systemChat "No headgear to sling.";
  6. } else {
  7. _headgear = headgear _unit;
  8. removeHeadgear _unit;
  9. _helmetHolder = "GroundWeaponHolder" createVehicle [0,0,0];
  10. _helmetHolder addItemCargoGlobal [_headgear, 1];
  11. _unit setVariable ["GEARF_HelmetAttachedClass", _headgear];
  12. _unit setVariable ["GEARF_HelmetAttached", true];
  13. _additional = [];
  14. (backpackItems _unit) apply {
  15. _parents = [configFile >> "CfgWeapons" >> _x >> "ItemInfo", true] call BIS_fnc_returnParents;
  16. if("HeadgearItem" in _parents) then {
  17. _additional append [_x];
  18. };
  19. };
  20. _additionalClass = _additional select 0;
  21. _unit addHeadgear _additionalClass;
  22. _unit removeItemFromBackpack _additionalClass;
  23. switch (_side) do {
  24. case "left": {
  25. _helmetHolder attachTo [_unit, [0.52,0.1,1.72],"lfemur"];
  26. [_helmetHolder, [0,5,120]] call GEARF_fnc_rotateObject;
  27. };
  28. case "right": {
  29. _helmetHolder attachTo [_unit, [-0.41,0.25,1.72],"rfemur"];
  30. [_helmetHolder, [0,-5,-120]] call GEARF_fnc_rotateObject;
  31. };
  32. };
  33. };
  34. aaa attachTo [player, [-0.21,0.15,1.72],"lfemur"];