BIS fnc packStaticWeapon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(note)
m (Text replacement - "{{Feature|Informative|" to "{{Feature|informative|")
 
(49 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.00


| arma3 |= Game name
|gr1= Weapons


|1.00|= Game version
|descr= This function will make weapon team pack a static weapon. The weapon crew will pack carried weapon (or given weapon if different) and follow leader. Requires three personnel in the team: Team Leader, Gunner and Asst. Gunner. This function is MP compatible
____________________________________________________________________________________________
<br><br>
When the weapon is packed, scripted EH "StaticWeaponPacked" is called with the following params:
* [group, leader, gunner, assistant, weaponBag, tripodBag]


| <pre>/*
{{Feature|informative|If a unit flees, all bets are off and the function will exit leaving units on their own. To guarantee weapon disassembly, make sure the group has maximum courage <sqf>_group allowFleeing 0;</sqf>}}
File: fn_packStaticWeapon.sqf


Description:
|s1= [group, weapon, leaderPos] call [[BIS_fnc_packStaticWeapon]]
Function which uses a weapon team to pack a static weapon such
as the HMG or Mortar. Requires three personnel in the team as
a minimum (leader, gunner, assistant).


Parameter(s):
|p1= group: [[Group]] or [[Object]] - the support team group or a unit from this group
_this select 0: the support team group (group)
|p2= weapon: [[Object]] - (Optional) weapon to pack. If [[nil]], current group weapon is packed
_this select 1: the weapon (option if weapon registered as "supportWeaponSetup" variable)
*/
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_packStaticWeapon]]; --> |= Syntax
|p3= leaderPos: [[Array]], [[String]] or [[Object]] - (Optional) position, object or marker to which the group leader should move after the weapon is packed. By default the group will resume on to the next assigned waypoint. If this param is provided, group will not go to the next waypoint and will move to given position instead


|p1= |= Parameter 1
|r1= [[Nothing]]


| |= Return value
|x1= <sqf>[leader1] call BIS_fnc_packStaticWeapon;</sqf>
____________________________________________________________________________________________


|x1= <code></code> |=
|x2= <sqf>
____________________________________________________________________________________________
group1 allowFleeing 0;
 
[group1, nil, "leaderpos_marker"] call BIS_fnc_packStaticWeapon;
| |= See also
</sqf>


|seealso= [[BIS_fnc_unpackStaticWeapon]] [[BIS_fnc_addScriptedEventHandler]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Killzone_Kid
<!-- Note Section BEGIN -->
|timestamp= 20170106232300
 
|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.
<!-- Note Section END -->
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.
</dl>
After 7 seconds the [[BIS_fnc_packStaticWeapon]] is executed and the group packs and heads to 2nd waypoint.
 
<sqf>
<h3 style="display:none">Bottom Section</h3>
private _group = createGroup west;
[[Category:Function Group: Actions|{{uc:packStaticWeapon}}]]
private _pos = player getRelPos [20, 0];
[[Category:Functions|{{uc:packStaticWeapon}}]]
private _randomDir = random 360;
[[Category:{{Name|arma3}}: Functions|{{uc:packStaticWeapon}}]]
private _wp1 = _group addWaypoint [_pos getPos [20, _randomDir], 10];
 
_wp1 setWaypointType "MOVE";
<!-- CONTINUE Notes -->
_wp1 setWaypointStatements ["true", "
<dl class="command_description">
group this allowFleeing 0;
<dd class="notedate">Posted on January 6, 2017 - 23:23 (UTC)</dd>
[group this, 'StaticWeaponUnpacked', {
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
_this spawn
<dd class="note">
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.
<code>[[private]] _group = [[createGroup]] [[west]];
[[private]] _pos = [[player]] [[getRelPos]] [20, 0];
[[private]] _randomDir = [[random]] 360;
[[private]] _wp1 = _group [[addWaypoint]] [_pos [[getPos]] [20, _randomDir], 10];
_wp1 [[setWaypointType]] "MOVE";
_wp1 [[setWaypointStatements]] ["true", "
[[group]] this [[allowFleeing]] 0;
<nowiki>[</nowiki>[[group]] this, 'StaticWeaponUnpacked', {
_this [[spawn]]
{
{
[[sleep]] 7;
sleep 7;
[_this [[select]] 0] [[call]] [[BIS_fnc_packStaticWeapon]];
[_this select 0] call BIS_fnc_packStaticWeapon;
};
};
}] [[call]] [[BIS_fnc_addScriptedEventHandler]];
}] call BIS_fnc_addScriptedEventHandler;
[
[
this,  
this,  
this,  
this,  
this [[getPos]] [1000, [[random]] 360],  
this getPos [1000, random 360],  
this [[getPos]] [10, 0]
this getPos [10, 0]
] [[call]] [[BIS_fnc_unpackStaticWeapon]];
] call BIS_fnc_unpackStaticWeapon;
"];
"];
[[private]] _wp2 = _group [[addWaypoint]] [_pos [[getPos]] [20, _randomDir - 180], 10];
private _wp2 = _group addWaypoint [_pos getPos [20, _randomDir - 180], 10];
_wp2 [[setWaypointType]] "MOVE";
_wp2 setWaypointType "MOVE";
[[private]] _leader = _group [[createUnit]] ["B_Soldier_TL_F", _pos, [], 0, "NONE"];
private _leader = _group createUnit ["B_Soldier_TL_F", _pos, [], 0, "NONE"];
[[private]] _gunner = _group [[createUnit]] ["B_Support_GMG_F", _pos, [], 0, "NONE"];
private _gunner = _group createUnit ["B_Support_GMG_F", _pos, [], 0, "NONE"];
[[private]] _assistant = _group [[createUnit]] ["B_Support_AMG_F", _pos, [], 0, "NONE"];
private _assistant = _group createUnit ["B_Support_AMG_F", _pos, [], 0, "NONE"];
[[units]] _group [[doFollow]] _leader;
units _group doFollow _leader;
</code>
</sqf>
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 00:25, 2 February 2024

Hover & click on the images for description

Description

Description:
This function will make weapon team pack a static weapon. The weapon crew will pack carried weapon (or given weapon if different) and follow leader. Requires three personnel in the team: Team Leader, Gunner and Asst. Gunner. This function is MP compatible

When the weapon is packed, scripted EH "StaticWeaponPacked" is called with the following params:
  • [group, leader, gunner, assistant, weaponBag, tripodBag]
If a unit flees, all bets are off and the function will exit leaving units on their own. To guarantee weapon disassembly, make sure the group has maximum courage
_group allowFleeing 0;
Execution:
call
Groups:
Weapons

Syntax

Syntax:
[group, weapon, leaderPos] call BIS_fnc_packStaticWeapon
Parameters:
group: Group or Object - the support team group or a unit from this group
weapon: Object - (Optional) weapon to pack. If nil, current group weapon is packed
leaderPos: Array, String or Object - (Optional) position, object or marker to which the group leader should move after the weapon is packed. By default the group will resume on to the next assigned waypoint. If this param is provided, group will not go to the next waypoint and will move to given position instead
Return Value:
Nothing

Examples

Example 1:
[leader1] call BIS_fnc_packStaticWeapon;
Example 2:
group1 allowFleeing 0; [group1, nil, "leaderpos_marker"] call BIS_fnc_packStaticWeapon;

Additional Information

See also:
BIS_fnc_unpackStaticWeapon BIS_fnc_addScriptedEventHandler

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Killzone_Kid - c
Posted on Jan 06, 2017 - 23:23 (UTC)
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.
private _group = createGroup west; private _pos = player getRelPos [20, 0]; private _randomDir = random 360; private _wp1 = _group addWaypoint [_pos getPos [20, _randomDir], 10]; _wp1 setWaypointType "MOVE"; _wp1 setWaypointStatements ["true", " group this allowFleeing 0; [group this, 'StaticWeaponUnpacked', { _this spawn { sleep 7; [_this select 0] call BIS_fnc_packStaticWeapon; }; }] call BIS_fnc_addScriptedEventHandler; [ this, this, this getPos [1000, random 360], this getPos [10, 0] ] call BIS_fnc_unpackStaticWeapon; "]; private _wp2 = _group addWaypoint [_pos getPos [20, _randomDir - 180], 10]; _wp2 setWaypointType "MOVE"; private _leader = _group createUnit ["B_Soldier_TL_F", _pos, [], 0, "NONE"]; private _gunner = _group createUnit ["B_Support_GMG_F", _pos, [], 0, "NONE"]; private _assistant = _group createUnit ["B_Support_AMG_F", _pos, [], 0, "NONE"]; units _group doFollow _leader;