Jump to content
Sign in to follow this  
MiXeR

Creating group with BIS_fnc_spawnGroup

Recommended Posts

The third argument doesn't HAVE to be a config file, an array of unit classes works fine.

If you want to spawn a group as defined in CfgGroups, you have to. But yes, there are 3 different options for the 3rd. argument. Either you want to:

  • spawn a custom group, then pass a list of character types (Array),
    _newGroup = [_pos, _side, ["RU_Soldier_SL", "RU_Soldier_TL", "RU_Soldier_AR"]] call BIS_fnc_spawnGroup;


  • spawn a random n-unit group, then pass a amount of characters (Number) or
    _newGroup = [_pos, _side, 12] call BIS_fnc_spawnGroup;


  • spawn a predefined group, then pass a CfgGroups entry (Config).
    _newGroup = [_pos, _side, _config] call BIS_fnc_spawnGroup;


In conclusion, the function BIS_ACM_convertGroupStringToConfigFunc does come in very handy, unless you don't want to spawn groups as defined in CfgGroups.

Sure, there is no public documentation yet (comref, etc.), but I do realize the functions/scripts themselfes are IMHO very well documented. A quick glance at the contracts of the functions (description, parameters, return-value at the top of each file) is usually enough to make things work.

Share this post


Link to post
Share on other sites

Thx for the examples, Ruebe und beita. Works fine for me! ^^

Share this post


Link to post
Share on other sites

have we got a reference list of available group config names? It's not included in the classnames sticky.

Share this post


Link to post
Share on other sites

You search for the group classes of all Factions? Hope this helps.

Thx to Clayman for posting it in our forum ;)

[b]// USMC[/b]
USMC_InfSquad
USMC_FireTeam
USMC_FireTeam_MG
USMC_FireTeam_AT
USMC_FireTeam_Support
USMC_HeavyATTeam
USMC_SniperTeam
USMC_FRTeam
USMC_FRTeam_Razor

USMC_MotInfSection
USMC_MotInfSection_AT

USMC_MechInfSquad
USMC_MechReconSection

USMC_TankPlatoon

USMC_AH1ZSquadron
USMC_UH1YSquadron
USMC_MV22Squadron
USMC_MQ9Squadron
USMC_F35Squadron
USMC_AV8BFighterSquadron
USMC_AV8BBomberSquadron


[b]// CDF[/b]
CDF_InfSquad
CDF_InfSquad_Weapons
CDF_InfSection_AT
CDF_InfSection_AA
CDF_InfSection_MG
CDF_InfSection_Patrol
CDF_SniperTeam

CDF_MotInfSquad
CDF_MotInfSection
CDF_MotInfSection_Weapons

CDF_MechInfSquad
CDF_MechReconSection
CDF_MechATSection

CDF_TankPlatoon

CDF_Mi24DSquadron
CDF_Mi8Squadron


[b]// RU[/b]
RU_InfSquad
RU_InfSection
RU_InfSection_AT
RU_InfSection_AA
RU_InfSection_MG
RU_SniperTeam
RUS_ReconTeam
MVD_AssaultTeam

RU_MotInfSquad
RU_MotInfSection_Recon
RU_MotInfSection_Patrol

RU_MechInfSquad_1
RU_MechInfSquad_2

RU_TankPlatoon

RU_Mi24VSquadron
RU_Mi24PSquadron
RU_Pchela1TSquadron
RU_Ka52Squadron
RU_Mi8Squadron
RU_Su34FighterSquadron


[b]// INS[/b]
INS_InfSquad
INS_InfSquad_Weapons
INS_InfSection_AT
INS_InfSection_AA
INS_SniperTeam
INS_MilitiaSquad

INS_MotInfSquad
INS_MotInfSection

INS_MechInfSquad
INS_MechInfSection
INS_MechInfSection_AT

INS_TankSection

INS_Mi8Squadron


[b]// GUE[/b]
GUE_InfSquad
GUE_InfSquad_Assault
GUE_InfSquad_Weapons
GUE_InfTeam_1
GUE_InfTeam_2
GUE_InfTeam_AT
GUE_GrpInf_TeamAA
GUE_GrpInf_TeamSniper
GUE_MilitiaSquad

GUE_MotInfSection
GUE_MotInfSquad

GUE_MechInfSection
GUE_MechInfSquad

GUE_TankSection


[b]// CI[/b]V (works not with ACM?)
CIV_Crowd
CIV_City_1
CIV_City_2
CIV_Village_1
CIV_Village_2

Share this post


Link to post
Share on other sites

Is this supposed to only be able to spawn friendly units?

This works just fine if the player is Russian (activated from a radio trigger)

SpawnPos = getMarkerPos "matkerpos";
SpawnUnits = ["RU_Soldier_SL", "RU_Soldier_TL", "RU_Soldier_AR", "RU_Soldier_AR", "RU_Soldier_LAT", "RU_Soldier_LAT", "RU_Soldier", "RU_Soldier"];
Spawnskill = [0.5, 0.5];
_side = EAST;
[spawnPos, _side, SpawnUnits, [], [], SpawnSkill] call BIS_fnc_spawnGroup;

but spawns nothing if the player is BLUFOR.

Am I being thick?

Share this post


Link to post
Share on other sites

[group Bla, getPos Bla] call BIS_fnc_taskDefend

How can i set what side the group is going to be?

---------- Post added at 03:16 PM ---------- Previous post was at 03:15 PM ----------

nevermind my stupid question...should never ask anything right after a nap =D

Share this post


Link to post
Share on other sites

hmm,what am i doing wrong since this doesn't spawn anything via trigger set to "OFPOR - present)

[group Bla, getPos Bla] call BIS_fnc_taskDefend

Is this meant to be used with another line of code and to use the same "BLAs" =)? Like creating a group first and this would put them to defend task or something?

Is this like a "guard" waypoint set for the grp instantly or where does the "defend" refer to?

Share this post


Link to post
Share on other sites

Ah, i just dont get it...

I want to spawn a group with the soldiers i want, with the skill i want ect.

I have this:

_units = ["Ins_Lopotev", "Ins_Soldier_1", "Ins_Soldier_MG"];
_grp = [(getMarkerpos "1"),east,_units] call BIS_fnc_spawngroup;
[_grp, (getMarkerpos "1")] call BIS_fnc_taskDefend;

It works but how can i set the groupleader and the skill of the group ?

Edited by Wiggum

Share this post


Link to post
Share on other sites

Maybe this works...

_ranks = ["PRIVATE","SERGANT"];
_skill = 0.3 + random 0.3;
_units = 3 + random 5;
_grp = [(getMarkerpos "1"), east, _units, _ranks, _skill] call BIS_fnc_spawngroup;

Take a look at the description of BIS_fnc_spawngroup ;)

File: spawnGroup.sqf

Author: Joris-Jan van 't Land

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.

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)

*/

Share this post


Link to post
Share on other sites

Can anyone tell me why this does not work?

[getMarkerPos "spawn1", side player, (configFile >> "CfgGroups" >> "East" >> "ru" >> "[color="Red"]armor[/color]" >> "RU_TankPlatoon")] call BIS_fnc_spawnGroup

Figured it out and the differnet group should be:

Infantry

Air

Mechanized

Motorized

armored

Edited by cobra4v320

Share this post


Link to post
Share on other sites
Maybe this works...

_ranks = ["PRIVATE","SERGANT"];
_skill = 0.3 + random 0.3;
_units = 3 + random 5;
_grp = [(getMarkerpos "1"), east, _units, _ranks, _skill] call BIS_fnc_spawngroup;

How could I add a condition to this that if a player already has more than 5 AI in his group it would only state:

"You can't have more units"

?

Share this post


Link to post
Share on other sites

Hi all I apologise in advance i had posted this rquest in a different threat - but discovered this one more pertaining to my problem.

I have gamelogics set up in a mission which spawn a 2d composition with units guarding it. It worked in 1.02 fine but since 1.03 it doesnt spawn any units, I have tried various options and really dont want to do it by script file can anyone help with the spawngroup part of it as I am at a loss.

This is what I have in the gamelogic.

_newObjs = [getpos this, (random 360), ["usmc", "medium"]] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); grpD = [getpos this, West, 4 + (random 4)] call BIS_fnc_spawnGroup;[grpD, getpos this] call BIS_fnc_taskDefend

Share this post


Link to post
Share on other sites

Guys, when making totally random & spawned missions, remember that you need to have at least one enemy placed in the editor (presence 0 is enough). Dang it took a long time to figure out why it wasn't spawning anything. :)

Edited by Shuko

Share this post


Link to post
Share on other sites
Guys, when making totally random & spawned missions, remember that you need to have at least one enemy placed in the editor (presence 0 is enough). Dang it took a long time to figure out why it wasn't spawning anything. :)

Going by the 3D editor that creates a "center" for the group, you cant create any units on the side without it. Or at least that's how I understand it :)

Regarding spawning units dynamically, something I have noticed that can simplify mission creation ALOT - assuming you use a known location and not completely random one - is to make a script that remove all units at mission start while saving the setup/waypoints, then recreate the group with a certain trigger (for example "mission_x_start", whatever). This means you can place units in the editor as usual, with waypoints, synchronized to triggers, make encounters based on presence in an area, etc easily.

Share this post


Link to post
Share on other sites

Problem I have is this initialisation script worked fine in 1.02 without the need for a centre. Also I have already placed enemy units on the map so its not that either. If I need to create a centre though how would I go about it - could i create one in a gamelogic init?.

Edit - creating a centre doesnt work - I think something has changed in the spawngroup syntax for sure extra variables, but cant make heads nor tales of it..any help would be appreciated - I just wish that when they change things they document the changes for us so we arent spending hours fumbling in the dark for the right button..

_newObjs = [getpos this, (random 360), ["usmc", "medium"]] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf ")); grpD = [getpos this, West, 4 + (random 4)] call BIS_fnc_spawnGroup;[grpD, getpos this] call BIS_fnc_taskDefend

Again I dont mean to spam but surely I cant be the only one with this problem and I cannot find any solution thus far in any topic, but this gamelogic code is essential to my mission. Please help if you can.

Edited by Jingle

Share this post


Link to post
Share on other sites

Hi.

No matter what I do, what I try...nothing spawns.

The script I try activates, it even gets to the end, but no units are ever created.

This is also true for old methods, using createUnit or whatever it was.

Do I need to activate the script from a static object, or using a certain way to call the script?

Tried things like:

null = this execVM "spawn.sqf"

null = player execVM "spawn.sqf"

null = [this] execVM "spawn.sqf"

All fire the script, but no units.

Btw, if you wondering on any code ive used, its exactly the same as whats been said here before. Things like:

[getPosASL player, side player, ["USMC_Soldier_SL", "USMC_Soldier_AR"]] call BIS_fnc_spawnGroup;

EDIT:

I tried creating a trigger and placing:

dum = player execVM "spawn.sqf"

This spawned the units, but its fairly impractical for me. Does it have to be done this way, any other way ?

Edited by nullsystems

Share this post


Link to post
Share on other sites

If you are running your script from init.sqf etc. You need to wait for the module to init first. So, place this at the start of your spawn.sqf.

waituntil {BIS_fnc_init};

Share this post


Link to post
Share on other sites

Is there a way of using this, spawning 5 vehicles and getting them to spawn without them being on top of each other?

Share this post


Link to post
Share on other sites
Is there a way of using this, spawning 5 vehicles and getting them to spawn without them being on top of each other?

Randomise the array.

//randomise Array
_array = [1, 2, 3]; //x, y, z
_int = 5; //randomiser

_i = 0;
{
_array set [_i, _x - (0.5*_int) + random(_int)];
_i = _i + 1;
} foreach _array;

That isn't very elaborate however, you might be better off checking their boundingBoxes and making sure the aren't going to contact each other.

Edited by Rommel

Share this post


Link to post
Share on other sites
Again I dont mean to spam but surely I cant be the only one with this problem and I cannot find any solution thus far in any topic, but this gamelogic code is essential to my mission. Please help if you can.

Confirmed. I also cannot get this working from a gamelogic with 1.04. Worked fine with 1.03

_newObjs = [getpos this, (random 360), "Camp2_INS"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); 
grpD = [getpos this, Resistance, ["GUE_Soldier_CO", "GUE_Soldier_MG", "GUE_Soldier_1", "GUE_Soldier_2", "GUE_Soldier_3", "GUE_Soldier_GL"], [], ["LIEUTENANT", "CORPORAL", "CORPORAL", "PRIVATE", "PRIVATE", "PRIVATE"]] call BIS_fnc_spawnGroup; 
[grpD, getpos this] call BIS_fnc_taskDefend

Anyone have any ideas? I'll keep working on this...

UPDATE:

The script above should be modified to look like this (sleep not necessary but I like to lighten the load):

_comp = [this] spawn { if (isServer) then { sleep 0.1; waituntil {BIS_fnc_init}; _pos = getPos (_this select 0); _obj = [_pos, (random 360), "Camp2_INS"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); sleep 0.1; _grp = [_pos, Resistance, ["GUE_Soldier_CO", "GUE_Soldier_MG", "GUE_Soldier_1", "GUE_Soldier_2", "GUE_Soldier_3", "GUE_Soldier_GL"], [], ["LIEUTENANT", "CORPORAL", "CORPORAL", "PRIVATE", "PRIVATE", "PRIVATE"]] call BIS_fnc_spawnGroup; sleep 0.1; [_grp, _pos] call BIS_fnc_taskDefend; } }

or more pretty:

_comp = [this] spawn 
{ 
   if (isServer) then 
   { 
       sleep 0.1;
       waituntil {BIS_fnc_init}; 
       _pos = getPos (_this select 0);
       _obj = [_pos, (random 360), "Camp2_INS"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); 
       sleep 0.1;
       _grp = [_pos, Resistance, ["GUE_Soldier_CO", "GUE_Soldier_MG", "GUE_Soldier_1", "GUE_Soldier_2", "GUE_Soldier_3", "GUE_Soldier_GL"], [], ["LIEUTENANT", "CORPORAL", "CORPORAL", "PRIVATE", "PRIVATE", "PRIVATE"]] call BIS_fnc_spawnGroup; 
       sleep 0.1;
       [_grp, _pos] call BIS_fnc_taskDefend;
   }
}

Edited by Binesi
Script optimized

Share this post


Link to post
Share on other sites

Surely you aren't using local vars in an init field? I'm not sure how the center stuff is checked, but if the objects are read from mission.sqm in order and the logic is read before any of the Resistance units are read/created, there would be no center. Another thing that you have to remember with these spawn scripts (BIS ones) is that they need the Functions module, which also needs time to init itself. So, try this in the init field:

nul = spawn {
waituntil {BIS_fnc_init};
_newObjs = [getpos this, (random 360), "Camp2_INS"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); 
grpD = [getpos this, Resistance, ["GUE_Soldier_CO", "GUE_Soldier_MG", "GUE_Soldier_1", "GUE_Soldier_2", "GUE_Soldier_3", "GUE_Soldier_GL"], [], ["LIEUTENANT", "CORPORAL", "CORPORAL", "PRIVATE", "PRIVATE", "PRIVATE"]] call BIS_fnc_spawnGroup; 
[grpD, getpos this] call BIS_fnc_taskDefend;
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×