{"name":"BIS_fnc_unpackStaticWeapon","title":"BIS fnc unpackStaticWeapon","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_unpackStaticWeapon","revid":352038,"updated":"2024-02-01T23:24:28Z","groups":["Weapons"],"status":"ok","games":{"arma3":"1.00"},"since":"arma3 1.00","arma3_since":"1.00","description":"This function will move given support team to the given weapon position.\nThe weapon crew will unpack carried weapon and start watching given target position.\nRequires three personnel in the team: Team Leader, Gunner and Asst. Gunner.\nThis function is MP compatible.\nWhen the weapon is unpacked, the \"StaticWeaponUnpacked\" scripted EH is called.\n\n> [!NOTE]\n> If a unit flees, all bets are off and the function will exit leaving units on their own.\n> To guarantee weapon disassembly, make sure the group has maximum courage: `_group allowFleeing 0;`.","syntaxes":[{"syntax":"[group, weaponPos, targetPos, leaderPos] call BIS_fnc_unpackStaticWeapon","params":[{"name":"group","type":"Group or Object","description":"the support team group or a unit from this group","type_expr":"Group | Object"},{"name":"weaponPos","type":"Array, String or Object","description":"weapon placement position, object position or marker","type_expr":"Array | String | Object"},{"name":"targetPos","type":"Array, String or Object","description":"target position, object position to watch or marker","type_expr":"Array | String | Object"},{"name":"leaderPos","type":"Array, String or Object","optional":true,"description":"position, object or marker group leader should move to","type_expr":"Array | String | Object","text":"leaderPos: Array, String or Object - (Optional) position, object or marker group leader should move to"}],"returns":{"type":"Nothing","type_expr":"Nothing"}}],"examples":[{"code":["[leader1, \"weapon_mrk\", \"target_mrk\"] call BIS_fnc_unpackStaticWeapon;"]},{"code":["group1 allowFleeing 0;\n[group1, \"weapon_mrk\", tank1, \"leader_mrk\"] call BIS_fnc_unpackStaticWeapon;"]}],"see_also":["BIS_fnc_packStaticWeapon","BIS_fnc_addScriptedEventHandler"],"notes":[{"user":"Killzone_Kid","date":"2017-01-06T23:10:00Z","text":"The following script will create a group consisting of a Team Leader, Gunner and Asst. Gunner and give the group 2 random MOVE waypoints. After the group reached the 1st waypoint, waypoint statement will execute BIS_fnc_unpackStaticWeapon and the group will stop and unpack static weapon, while leader is given random position to go to. After 7 seconds the BIS_fnc_packStaticWeapon is executed and the group packs and heads to 2nd waypoint.\n\n```sqf\nprivate _group = createGroup west;\nprivate _pos = player getRelPos [20, 0];\nprivate _randomDir = random 360;\nprivate _wp1 = _group addWaypoint [_pos getPos [20, _randomDir], 10];\n_wp1 setWaypointType \"MOVE\";\n_wp1 setWaypointStatements [\"true\", \"\n    group this allowFleeing 0;\n    [group this, 'StaticWeaponUnpacked', {\n        _this spawn\n        {\n            sleep 7;\n            [_this select 0] call BIS_fnc_packStaticWeapon;\n        };\n    }] call BIS_fnc_addScriptedEventHandler;\n    [\n        this,\n        this,\n        this getPos [1000, random 360],\n        this getPos [10, 0]\n    ] call BIS_fnc_unpackStaticWeapon;\n\"];\nprivate _wp2 = _group addWaypoint [_pos getPos [20, _randomDir - 180], 10];\n_wp2 setWaypointType \"MOVE\";\nprivate _leader = _group createUnit [\"B_Soldier_TL_F\", _pos, [], 0, \"NONE\"];\nprivate _gunner = _group createUnit [\"B_Support_GMG_F\", _pos, [], 0, \"NONE\"];\nprivate _assistant = _group createUnit [\"B_Support_AMG_F\", _pos, [], 0, \"NONE\"];\nunits _group doFollow _leader;\n```"}]}