BIS fnc spawnGroup: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - " |s1=[" to " |s1= [")
(46 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Function|=
{{RV|type=function
____________________________________________________________________________________________


| arma2 |=
|game1= arma2
|1.00|=
|version1= 1.00


|game2= TKOH |=
|game2= arma2oa
|version2= 1.00 |=
|version2= 1.50


|arg= |= MPARGUMENTS
|game3= tkoh
|version3= 1.00


|eff= |= MPEFFECTS
|game4= arma3
____________________________________________________________________________________________
|version4= 0.50


| Function which handles the spawning of a dynamic group of characters.  The composition of the [[group]] can be passed to the function.  Alternatively a number can be passed and the function will spawn that amount of characters with a random type.
|gr1= Object Manipulation


A side's Center must have been created before a group may be spawned.  Either by using [[createCenter]] or an editor placed (0% Probability of Presence is fine) unit of the appropriate side.
|arg=


|=
|eff=
____________________________________________________________________________________________


| [position, side, character details, ''relative positions, list of ranks, skill range, ammo count range, randomization controls, azimuth''] call '''BIS_fnc_spawnGroup''' |=
|descr= Function which handles the spawning of a dynamic group of characters.  The composition of the [[group]] can be passed to the function.  Alternatively a number can be passed and the function will spawn that amount of characters with a random type.


|p1= position - group's starting [[position]] ([[Array]]) |=
{{Feature|informative|'''Before {{arma3}}''' a side's Center must have been created before a group may be spawned either by using [[createCenter]] or an editor placed (0% Probability of Presence is fine) unit of the appropriate side.}}


|p2= side - group's [[Side]] ([[Side]]) |=
|s1= [position, side, toSpawn, relPositions, ranks, skillRange, ammoRange, randomControls, azimuth, precisePos, maxVehicles] call [[BIS_fnc_spawnGroup]]


|p3= character details - Can be three different types: a list of character types ([[Array]]), an amount of characters to spawn ([[Number]]) or a [[CfgGroups]] entry ([[Config]]) |=
|p1= position: [[Array]] format [[Position]] - group's starting position


|p4= (optional) a list of relative positions ([[Array]]) |=
|p2= side: [[Side]] - group's side


|p5= (optional) a list of ranks ([[Array]]) |=
|p3= toSpawn - Can be one of:
* [[Array]] - list of character types
* [[Number]] - amount of characters to spawn
* [[Config]] - [[CfgGroups]] entry


|p6= (optional) skill range ([[Array]]) |=
|p4= relPositions: [[Array]] of [[Position]]s (Optional, default []) a list of relative positions


|p7= (optional) ammunition count range ([[Array]]) |=
|p5= ranks: [[Array]] of [[String]]s/[[Number]]s - (Optional, default []) ranks (see [[BIS_fnc_setRank]]) - '''must''' be same size as ''toSpawn''<nowiki/>'s array


|p8= (optional) randomization controls ([[Array]]) 0: amount of mandatory units ([[Number]]) 1: spawn chance for remaining units ([[Number]]) |=
|p6= skillRange: [[Array]] of [[Number]]s - (Optional, default []) skill range format [min, max]


|p9= (optional) azimuth/[[Direction]] ([[Number]]) |=
|p7= ammoRange: [[Array]] of [[Number]]s - (Optional, default []) ammunition range (0..1) format [min, max]


|([[Group]]) |= Return value
|p8= randomControls: [[Array]] of [[Number]]s - (Optional, default [-1, 1]) to format [minUnits, chance]:
* minUnits: [[Number]] - (Optional, default -1) amount of mandatory units
* chance: [[Number]] - (Optional, default -1) spawn chance for remaining units in range 0..1


|x1= Spawn five random EAST units at aPos:
|p9= azimuth: [[Number]] - (Optional, default 0) azimuth/[[direction]]
<code>[getPos aPos, EAST, 5] call BIS_fnc_spawnGroup</code>|= EXAMPLE1


|x2= Spawn a Stryker MGS Platoon at marker "tankSpawn":
|p10= precisePos: [[Boolean]] - (Optional, default [[true]]) forces precise position placement
<code>[getMarkerPos "tankSpawn", side player, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Armored" >> "US_MGSPlatoon")] call BIS_fnc_spawnGroup</code>|= EXAMPLE2


|x3= Spawn a TK Militia Medic and Soldier at aPos facing south:
|p11= maxVehicles: [[Number]] - (Optional, default 10e10) vehicle number limit
<code>[getPos aPos, EAST, ["TK_INS_Bonesetter_EP1", "TK_INS_Soldier_2_EP1"],[],[],[],[],[],180] call BIS_fnc_spawnGroup</code>|= EXAMPLE3
__________


| [[ArmA_2:_CfgVehicles | Arma 2 CfgVehicles]] |= SEEALSO
|r1= [[Group]]


| |= MPBEHAVIOUR
|x1= Spawn five random EAST units at aPosition:
____________________________________________________________________________________________
<sqf>[getPosATL aPosition, east, 5] call BIS_fnc_spawnGroup;</sqf>
}}


|x2= Spawn a Stryker MGS Platoon at marker "tankSpawn":
<sqf>[getMarkerPos "tankSpawn", side player, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Armored" >> "US_MGSPlatoon")] call BIS_fnc_spawnGroup;</sqf>


<h3 style='display:none'>Bottom Section</h3>
|x3= Spawn a TK Militia Medic and Soldier at aPos facing south:
<sqf>[getPos aPos, east, ["TK_INS_Bonesetter_EP1", "TK_INS_Soldier_2_EP1"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;</sqf>


<dl class="command_description">
|seealso= [[:Category:CfgVehicles]] [[Arma 2: CfgVehicles]] [[Arma 3 Assets]]
<!-- Note Section BEGIN -->
}}
[[User:kylania | kylania]] 2011-8-15<br/>
Use the following for the Type string in the configFile entry:


Infantry
{{Note
Air
|user= Snake Plissken
Mechanized
|timestamp= 20160823024200
Motorized
|text= Sides are as follow:
Armored
* [[west]]/[[blufor]] = BLUFOR
* [[east]]/[[opfor]] = OPFOR
* [[resistance]]/[[independent]] = INDEPENDENT
* [[civilian]] = CIVILIAN.


The randomization controls is an array: [2, .5] Would be 2 units spawned with a 50% chance the other units would be spawned.  The chance is a number from 0 to 1.
To spawn one BLUFOR group ("MARK1" is the name given to a map marker):
<sqf>Group_Name_Here = [getMarkerPos "MARK1", WEST, ["B_G_Soldier_A_F", "B_G_Soldier_F", "B_G_Soldier_AR_F", "B_G_Soldier_LAT_F"]] call BIS_fnc_spawnGroup;</sqf>


Also the last optional argument is azimuth, but doesn't display in the text above. :)  There's an example for it though.
Or a random group OPFOR of seven units
<sqf>Group_Name_Here = [getMarkerPos "MARK1", EAST, 7] call BIS_fnc_spawnGroup;</sqf>


<br><br>[[User:Killzone_Kid | Killzone_Kid]]<br>
an independent group:
Function header:<br>
<sqf>Group_Name_Here = [getMarkerPos "MARK1", INDEPENDENT, ["I_G_Soldier_A_F", "I_G_Soldier_F", "I_G_Soldier_AR_F", "I_G_Soldier_LAT_F"]] call BIS_fnc_spawnGroup;</sqf>
<syntaxhighlight lang=javascript>
}}
/*
File: spawnGroup.sqf
Author: Joris-Jan van 't Land, modified by Thomas Ryan


Description:
{{Note
Function which handles the spawning of a dynamic group of characters.
|user= Cheitan
The composition of the group can be passed to the function.
|timestamp= 20170802190600
Alternatively a number can be passed and the function will spawn that
|text= When using this function for making a dynamic AI spawn, pay attention to the fact that none of the created groups will be marked for auto-deletion when the group become empty (all members dead). It means that it can be very easy to hit the 144 (288 for A3) max groups per side limitation, implying that no more AI or group can be created afterwards. To avoid this issue on Arma 3, don't forget to use [[deleteGroupWhenEmpty]] command in your script.
amount of characters with a random type.
}}
 
Parameter(s):
_this select 0: the group's starting position (Array)
_this select 1: the group's side (Side)
_this select 2: can be three different types:
- list of character types (Array)
- amount of characters (Number)
- CfgGroups entry (Config)
_this select 3: (optional) list of relative positions (Array)
_this select 4: (optional) list of ranks (Array)
_this select 5: (optional) skill range (Array)
_this select 6: (optional) ammunition count range (Array)
_this select 7: (optional) randomization controls (Array)
0: amount of mandatory units (Number)
1: spawn chance for the remaining units (Number)
_this select 8: (optional) azimuth (Number)
 
Returns:
The group (Group)
*/
</syntaxhighlight>
<!-- Note Section END -->
</dl>
[[Category:Function Group: Spawning|{{uc:spawnGroup}}]]
[[Category:Functions|{{uc:spawnGroup}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:spawnGroup}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:spawnGroup}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:spawnGroup}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:spawnGroup}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on August 23, 2016 - 02:42 (UTC)</dd>
<dt class="note">[[User:Snake Plissken|Snake Plissken]]</dt>
<dd class="note">
Factions are represented by the letters<br>
<br>WEST = BLUFOR
<br>EAST = OPFOR
<br>GUER = INDEPENDENT
<br>CIV = CIVIL.<br>
 
<br>To spawn one BLUFOR group, the command be
<br>"MARK1" is the name given to the marking placed on the map, where the group will appear.
<code>Group_Name_Here = [getMarkerPos "MARK1", WEST, ["B_G_Soldier_A_F", "B_G_Soldier_F", "B_G_Soldier_AR_F", "B_G_Soldier_LAT_F"]] call BIS_fnc_spawnGroup; </code>
 
<br>Or a random group OPFOR of seven units
<code>Group_Name_Here= [getMarkerPos "MARK1", EAST, 7 ] call BIS_fnc_spawnGroup; </code>
 
<br>But to spawn an independent group, is not using "GUER" but the name "INDEPENDENT"
<code>Group_Name_Here = [getMarkerPos "MARK1", INDEPENDENTE, ["I_G_Soldier_A_F", "I_G_Soldier_F", "I_G_Soldier_AR_F", "I_G_Soldier_LAT_F"]] call BIS_fnc_spawnGroup;</code>
<br>I can not say that the correct would be to put the name "GUER" as in other factions, or is this an error for a correction future.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Revision as of 00:12, 13 July 2022

Hover & click on the images for description

Description

Description:
Function which handles the spawning of a dynamic group of characters. The composition of the group can be passed to the function. Alternatively a number can be passed and the function will spawn that amount of characters with a random type.
Before Arma 3 a side's Center must have been created before a group may be spawned either by using createCenter or an editor placed (0% Probability of Presence is fine) unit of the appropriate side.
Execution:
call
Groups:
Object Manipulation

Syntax

Syntax:
[position, side, toSpawn, relPositions, ranks, skillRange, ammoRange, randomControls, azimuth, precisePos, maxVehicles] call BIS_fnc_spawnGroup
Parameters:
position: Array format Position - group's starting position
side: Side - group's side
toSpawn - Can be one of:
relPositions: Array of Positions (Optional, default []) a list of relative positions
ranks: Array of Strings/Numbers - (Optional, default []) ranks (see BIS_fnc_setRank) - must be same size as toSpawn's array
skillRange: Array of Numbers - (Optional, default []) skill range format [min, max]
ammoRange: Array of Numbers - (Optional, default []) ammunition range (0..1) format [min, max]
randomControls: Array of Numbers - (Optional, default [-1, 1]) to format [minUnits, chance]:
  • minUnits: Number - (Optional, default -1) amount of mandatory units
  • chance: Number - (Optional, default -1) spawn chance for remaining units in range 0..1
azimuth: Number - (Optional, default 0) azimuth/direction
precisePos: Boolean - (Optional, default true) forces precise position placement
maxVehicles: Number - (Optional, default 10e10) vehicle number limit
Return Value:
Group

Examples

Example 1:
Spawn five random EAST units at aPosition:
[getPosATL aPosition, east, 5] call BIS_fnc_spawnGroup;
Example 2:
Spawn a Stryker MGS Platoon at marker "tankSpawn":
[getMarkerPos "tankSpawn", side player, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Armored" >> "US_MGSPlatoon")] call BIS_fnc_spawnGroup;
Example 3:
Spawn a TK Militia Medic and Soldier at aPos facing south:
[getPos aPos, east, ["TK_INS_Bonesetter_EP1", "TK_INS_Soldier_2_EP1"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

Additional Information

See also:
Category:CfgVehicles Arma 2: CfgVehicles Arma 3 Assets

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
Snake Plissken - c
Posted on Aug 23, 2016 - 02:42 (UTC)
Sides are as follow: To spawn one BLUFOR group ("MARK1" is the name given to a map marker):
Group_Name_Here = [getMarkerPos "MARK1", WEST, ["B_G_Soldier_A_F", "B_G_Soldier_F", "B_G_Soldier_AR_F", "B_G_Soldier_LAT_F"]] call BIS_fnc_spawnGroup;
Or a random group OPFOR of seven units
Group_Name_Here = [getMarkerPos "MARK1", EAST, 7] call BIS_fnc_spawnGroup;
an independent group:
Group_Name_Here = [getMarkerPos "MARK1", INDEPENDENT, ["I_G_Soldier_A_F", "I_G_Soldier_F", "I_G_Soldier_AR_F", "I_G_Soldier_LAT_F"]] call BIS_fnc_spawnGroup;
Cheitan - c
Posted on Aug 02, 2017 - 19:06 (UTC)
When using this function for making a dynamic AI spawn, pay attention to the fact that none of the created groups will be marked for auto-deletion when the group become empty (all members dead). It means that it can be very easy to hit the 144 (288 for A3) max groups per side limitation, implying that no more AI or group can be created afterwards. To avoid this issue on Arma 3, don't forget to use deleteGroupWhenEmpty command in your script.