Jump to content
Sign in to follow this  
MiXeR

Creating group with BIS_fnc_spawnGroup

Recommended Posts

Hi there. I trying to spawn an infantry group by this:

[getPosASL player, side player, "USMC_InfSquad"] call BIS_fnc_spawnGroup

But nothing happen. Spawning vehicles works fine.

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

"USMC_InfSquad" is not a config entry.

(configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad") would be one.

Edited by i0n0s

Share this post


Link to post
Share on other sites

So.. how should it be? I don't understand.

Edited by MiXeR

Share this post


Link to post
Share on other sites

I tried yesterday the fn_spawnVehicle and the fn_taskDefend but also nothing happen.

Can you post the comand to call the spawnVehicle or the fn_taskDefend please? I have probs with that. Would be nice! ^^

Share this post


Link to post
Share on other sites

all the BIS functions is why I really want a developers reference guide. So much goodies, so little information :D

Share this post


Link to post
Share on other sites
I tried yesterday the fn_spawnVehicle and the fn_taskDefend but also nothing happen.

Can you post the comand to call the spawnVehicle or the fn_taskDefend please? I have probs with that. Would be nice! ^^

Vehicle spawn: [getPosASL guy, 0, "M1A1", group player] call BIS_fnc_spawnVehicle

Share this post


Link to post
Share on other sites

HELL YEAH, i did it. :D

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

In the "[]" put list of infantry units.

But i still don't understand how to use "- amount of characters (Number)" and "- CfgGroups entry (Config)"

Edited by MiXeR

Share this post


Link to post
Share on other sites

Nice..thx a lot :)

Now hopefully i become the fn_taskDefend to work

Share this post


Link to post
Share on other sites

[getPos player, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup

[getPos Player, 0, "HMMWV", side player] call BIS_fnc_spawnVehicle

[group Bla, getPos Bla] call BIS_fnc_taskDefend

where Bla is a unit of an AI group.

Share this post


Link to post
Share on other sites

i0n0s, thanks a lot!

Share this post


Link to post
Share on other sites

Is it also possible to assign these groups tasks/waypoints? After for example spawning a tank

[position spawntank, 0, "M1A1", side player] call BIS_fnc_spawnVehicle

or spawning a group

[position spawngroup, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup

I would like to be able to get the tank or the group to move though assigned waypoints or to use "moveTo" to get them to move somewhere? The function probably assigns them names when they spawn but I wouldn't know where to find this...

Anyway, thanks for the info in this thread :)

Share this post


Link to post
Share on other sites
Is it also possible to assign these groups tasks/waypoints? After for example spawning a tank

[position spawntank, 0, "M1A1", side player] call BIS_fnc_spawnVehicle

or spawning a group

[position spawngroup, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup

I would like to be able to get the tank or the group to move though assigned waypoints or to use "moveTo" to get them to move somewhere? The function probably assigns them names when they spawn but I wouldn't know where to find this...

Anyway, thanks for the info in this thread :)

_grp = [position spawngroup, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup
_wp = _grp addWaypoint [getpos guy, 0];
_wp setWaypointType "MOVE"; 
_wp setWaypointSpeed "FULL"; 

Share this post


Link to post
Share on other sites

What's wrong in this code?

_grpfact = "USMC";
switch (_grpfact) do  
{
case "USMC": {hint "Ok"; _side = "west"};
case "CDF": {_side = "west"};
case "RU": {_side = "east"};
case "INS": {_side = "east"};
case "GUE": {_side = "resistance"};
};

hint _side;

hint _side; - doesn't work.

Share this post


Link to post
Share on other sites
Shouldn't it be:

hint format ["%1", _side]

?

It returns "any".

I trying to write a script to move created group:

_grppos = _this select 0;   
_grpfact = _this select 1; 
_grptype = _this select 2; 
_grpname = _this select 3; 

_wppos = _this select 4;    
_wptype = _this select 5;   
_wpspeed = _this select 6;  
_wpform = _this select 7;   
_wpt = _this select 8;     

switch (_grpfact) do  
{
case "USMC": {_side = "west"};
case "CDF": {_side = "west"};
case "RU": {_side = "east"};
case "INS": {_side = "east"};
case "GUE": {_side = "resistance"};
};

_grp = [getPos player, west, (configFile >> "CfgGroups" >> _side >> _grpfact >> _grptype >> _grpname)] call BIS_fnc_spawnGroup; 
_wp = _grp addWaypoint [_wppos, 0];
_wp setWaypointType _wptype; 
_wp setWaypointSpeed _wpspeed; 
_wp setWaypointFormation _wpform; 
_wp setWaypointTimeout _wpt;

But, if i use:

_grppos = _this select 0;   
_grpfact = _this select 1; 
_grptype = _this select 2; 
_grpname = _this select 3; 

_wppos = _this select 4;    
_wptype = _this select 5;   
_wpspeed = _this select 6;  
_wpform = _this select 7;   
_wpt = _this select 8;     

_side = "west";
_grp = [getPos player, west, (configFile >> "CfgGroups" >> _side >> _grpfact >> _grptype >> _grpname)] call BIS_fnc_spawnGroup; 
_wp = _grp addWaypoint [_wppos, 0];
_wp setWaypointType _wptype; 
_wp setWaypointSpeed _wpspeed; 
_wp setWaypointFormation _wpform; 
_wp setWaypointTimeout _wpt;

... all works fine. What's wrong? :confused:

Share this post


Link to post
Share on other sites

You are always declaring west in the _grp line? Or this might be correct...

Anyway, another question. If I have created a group using "BIS_fnc_spawnGroup" I can boss them around just fine and get them to go to waypoints. However, if I spawn a vehicle using "BIS_fnc_spawnVehicle" it will not go to assigned waypoints. I suspect this has to do with the fact it's not grouped or something. So I tried assigning my vehicle to a group, but that didn't work unfortunately. Anyone have any suggestions?

Share this post


Link to post
Share on other sites
What's wrong in this code?

private ["_side"];
_grpfact = "USMC";
switch (_grpfact) do  
{
case "USMC": {hint "Ok"; _side = "west"};
case "CDF": {_side = "west"};
case "RU": {_side = "east"};
case "INS": {_side = "east"};
case "GUE": {_side = "resistance"};
};

_side is only declared in the scope of the switch, therefore you have to declare it first in the outer scope. This is done via the private.

Share this post


Link to post
Share on other sites
What's wrong in this code?

_grpfact = "USMC";
switch (_grpfact) do  
{
case "USMC": {hint "Ok"; _side = "west"};
case "CDF": {_side = "west"};
case "RU": {_side = "east"};
case "INS": {_side = "east"};
case "GUE": {_side = "resistance"};
};

hint _side;

hint _side; - doesn't work.

Problem with variable scope.

You "declared" the _side variable in each of the switch's cases, so, it is local to those cases. Once you exit them (ie: now move onto hint _side), it is undefined.

Try this code:

_grpfact = "USMC";
_side = "west";
switch (_grpfact) do  
{
case "USMC": {hint "Ok"; _side = "west"};
case "CDF": {_side = "west"};
case "RU": {_side = "east"};
case "INS": {_side = "east"};
case "GUE": {_side = "resistance"};
};

hint format["%1", _side];

Also, I am pretty sure the side command returns a variable of type SIDE (not a string), so you would compare it like:

side player == west

Not:

side player == "west"

Not sure how you are doing it though.

EDIT: i0n0s beat me :P

Share this post


Link to post
Share on other sites
private ["_side"];
_grpfact = "USMC";
switch (_grpfact) do  
{
case "USMC": {hint "Ok"; _side = "west"};
case "CDF": {_side = "west"};
case "RU": {_side = "east"};
case "INS": {_side = "east"};
case "GUE": {_side = "resistance"};
};

_side is only declared in the scope of the switch, therefore you have to declare it first in the outer scope. This is done via the private.

YAY. Thank you again. :)

Share this post


Link to post
Share on other sites

Can anyone point out what's wrong with this?

_tank = [position spawnaten, 0, "M1A1", side player] call BIS_fnc_spawnVehicle
_tankgroup = creategroup USMC; // Or perhaps this should be WEST
_tank join grpNull
_tank join _tankgroup
_wp = _tankgroup addWaypoint [position wp1, 0];
_wp setWaypointType "MOVE"; 
_wp setWaypointSpeed "FULL";
_wp = _tankgroup addWaypoint [position wp2, 0];
_wp setWaypointType "MOVE"; 
_wp setWaypointSpeed "FULL";
_wp = _tankgroup addWaypoint [position wp3, 0];
_wp setWaypointType "DISMISS"; 
_wp setWaypointSpeed "FULL";

This works just fine:

_grp1 = [position spawnaten, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup
_wp = _grp1 addWaypoint [position wp1, 0];
_wp setWaypointType "MOVE"; 
_wp setWaypointSpeed "FULL";
_wp = _grp1 addWaypoint [position wp2, 0];
_wp setWaypointType "MOVE"; 
_wp setWaypointSpeed "FULL";
_wp = _grp1 addWaypoint [position wp3, 0];
_wp setWaypointType "DISMISS"; 
_wp setWaypointSpeed "FULL";

Share this post


Link to post
Share on other sites
Can anyone point out what's wrong with this?

_tankgroup = creategroup USMC; // Or perhaps this should be WEST

Try it with WEST instead of USMC?

Share this post


Link to post
Share on other sites

How to select unit features in script? I mean "In air", "In group".

Share this post


Link to post
Share on other sites

So the 3rd argument to BIS_fnc_spawnGroup has to be a config-file and must not be a string.

But, relief is already there! Have a look at:

modules.pbo\ambient_combat\data\scripts\functions\convertGroupStringToConfig.sqf

Either make sure you have an instance of the ACM running, so you can call:

_class = _classString call BIS_ACM_convertGroupStringToConfigFunc;

Or you copy that file into your mission-folder an precompile it by yourself in your init.sqf:

FN_stringToConfig = compile preprocessFile "convertGroupStringToConfig.sqf";
...
_class = _classString call FN_stringToConfig;

There's no need to reinvent the wheel. ;)

Share this post


Link to post
Share on other sites

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

An example:

_pos = getPos redfor_spawn;
_skill = [0.5, 0.5];
_side = EAST;
_units = ["RU_Soldier_SL", "RU_Soldier_TL", "RU_Soldier_AR", "RU_Soldier_AR", "RU_Soldier_LAT", "RU_Soldier_LAT", "RU_Soldier", "RU_Soldier"];

_newGroup = [_pos, _side, _units, [], [], _skill] call BIS_fnc_spawnGroup;

Worked fine for me.

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  

×