Jump to content
Sign in to follow this  
Ice_Rhino

Name Spawned Soldiers

Recommended Posts

Hi

I am using this code, or a variant of it, I can see where you specify the classname of the unit you wish to spawn but is there a way to name the individual unit(s) spawned?

[color=#333333][font=arial]_mygroup = [getmarkerpos "mygroupstart", EAST, ["O_officer_F"],[],[],[],[],[][/font][/color][color=#333333][font=arial]***,180] call BIS_fnc_spawnGroup;[/font][/color]

Any help appreciated

Share this post


Link to post
Share on other sites

JS, I looked at that before posting but I can't see the naming the units though, I can see the classname etc, but where is the naming of the individual?

Share this post


Link to post
Share on other sites
JS, I looked at that before posting but I can't see the naming the units though, I can see the classname etc, but where is the naming of the individual?

Ahhhh, saw classname so the normal "name" didn't register :p, I'm not too sure, depends on what your trying to name, the unit variable or the description name?

Share this post


Link to post
Share on other sites

Hi

I want to spawn a Fire Team, Team Leader, Rifleman, Grenadier & Auto-Rifleman, they will all be in a group named say 'OPF_Team_1'. The complication comes when I want to name the Team Leader say 'opf_patrol_1a;, Rifleman as 'opf_patrol_1b' etc etc.

[color=#333333][font=arial]_opf[/font][/color]_team_1[color=#333333][font=arial] = [getmarkerpos "mygroupstart", EAST, ["O_officer_F"],[],[],[],[],[][/font][/color][color=#333333][font=arial]***,180] call BIS_fnc_spawnGroup;[/font][/color]

This code allows the group creation and group name, but it is the naming of the individuals I need to find out how to do/

Any clearer?

Share this post


Link to post
Share on other sites
Hi

I want to spawn a Fire Team, Team Leader, Rifleman, Grenadier & Auto-Rifleman, they will all be in a group named say 'OPF_Team_1'. The complication comes when I want to name the Team Leader say 'opf_patrol_1a;, Rifleman as 'opf_patrol_1b' etc etc.

[color=#333333][font=arial]_opf[/font][/color]_team_1[color=#333333][font=arial] = [getmarkerpos "mygroupstart", EAST, ["O_officer_F"],[],[],[],[],[][/font][/color][color=#333333][font=arial]***,180] call BIS_fnc_spawnGroup;[/font][/color]

This code allows the group creation and group name, but it is the naming of the individuals I need to find out how to do/

Any clearer?

How about using units and leader?

units (group player);//my example
or
units _opf_team_1;

Returns(my example):

[b Alpha 1-1:1 (PLAYER),B Alpha 1-1:2,B Alpha 1-1:3,B Alpha 1-1:4,B Alpha 1-1:5,B Alpha 1-1:6,B Alpha 1-1:7,B Alpha 1-1:8]

From here you should be able to do this

_second_man = (units _grp) select 1;//second man
or
opf_patrol_1b = (units _opf_team_1) select 1;

and

_lead_man = leader _grp;//leader
or
opf_patrol_1a = leader _opf_team_1;

https://community.bistudio.com/wiki/units

https://community.bistudio.com/wiki/leader

https://community.bistudio.com/wiki/select

Edited by Benargee

Share this post


Link to post
Share on other sites

Any clearer?

Yes, try something like:

_unitVarName = 1;
{

_x setVehicleVarName format ["opf_patrol_%1", _unitVarName]; //I know it's something like this, the command is probably not correct...

_unitVarName = _unitVarName +1;

} foreach unit _opf_team_1;

I'm trying to alter what F2K Sel did here: http://forums.bistudio.com/showthread.php?183100-Waypoint-Load-Function-Problem&p=2776110&viewfull=1#post2776110

Share this post


Link to post
Share on other sites

After your code runs, try something like this:

{
missionNamespace setVariable[format["mygroupstart%1", (_forEachIndex + 1)], _x];
}forEach (units _mygroup);

using missionNamespace setVariable is a way to inject variables directly into the mission namespace (not sure how to explain this, pretty much everything that happens happens in the mission namespace) (probably) and to create dynamically named variables. It is a faster/better alternative to using call compile format which can achieve the same results. (definitely)

what this code does is... (pseudocode)

for each of the units in _mygroup, a new variable is created named "mygroupstart" + number the of the current index plus 1, because you place an object inside the variable becomes an object variable and you can run code using their handles. (probably)

Here is a visualization (that hopefully comes out formatted correctly)

variables = "mygroupstart1", "mygroupstart2","mygroupstart3","mygroupstart4"
                 /|\              /|\            /|\             /|\
                  |                |              |               |
                  |                |              |               |
_mygroup =      [man1,            man2,          man3,           man4]

(probably)

hope that helps (hope it's right, too. I'm a little drunk.)

EDIT: I got the names wrong when I read the post earlier!

alphabet = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z];
{
   missionNamespace setVariable[format["opf_team_1%1", (alphabet select _forEachIndex)], _x];
}forEach (units _mygroup);

variables = "opf_team_1a", "opf_team_1b","opf_team_1c","opf_team_1d"
                 /|\            /|\          /|\           /|\
                  |              |            |             |
                  |              |            |             |
ofp_team_1 =     [man1,          man2,        man3,         man4]

Now this will have the effect you want.

Edited by DreadedEntity
forgot ; at the end of forEach in code

Share this post


Link to post
Share on other sites
Ahhhh, saw classname so the normal "name" didn't register :p, I'm not too sure, depends on what your trying to name, the unit variable or the description name?

How could you set the description of a unit please? There's a getDescription function, but no "setDescrition"?

Share this post


Link to post
Share on other sites
How could you set the description of a unit please? There's a getDescription function, but no "setDescrition"?

Well, if you are doing a singleplayer mission you can use setName, however, the only other thing that will work (that I can find) is setIdentity.

https://community.bistudio.com/wiki/setName

https://community.bistudio.com/wiki/setIdentity

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  

×