Jump to content
Sign in to follow this  
lawman_actual

Discussion; commanding newly spawned units

Recommended Posts

I'm trying to work on a basic system whereby a deceased unit is added to a count of units "on standby".

When there is (for example) 4 units on standby, the 4 dead units are replaced by a new fireteam, who are then assigned an objective from scratch and wander off to do their thing.

So my query is about how I go about referring to these newly spawned units after they have spawned?

Example

Let's say I've spawned just 1 new unit.

I want that unit in a group, and I want to move that group somewhere.

???? join groupleadersname

How?

Share this post


Link to post
Share on other sites
_unitPos = [1760,5920,0]; 
_group = createGroup west; 
_unit = "B_engineer_F" createUnit [_unitPos, _group]; 
_wpPos = [1765,5872,0]; 
_radius = 10;
_wp = _group addWaypoint [_wpPos, _radius];
_unit setCurrentWaypoint _wp;

Share this post


Link to post
Share on other sites
_unitPos = [1760,5920,0]; 
_group = createGroup west; 
_unit = "B_engineer_F" createUnit [_unitPos, _group]; 
_wpPos = [1765,5872,0]; 
_radius = 10;
_wp = _group addWaypoint [_wpPos, _radius];
_unit setCurrentWaypoint _wp;

Ok, so you're saying you add the new unit to a group through the createUnit command and then you have to control it through it's group?

I attempted to work with this yesterday but I couldn't get the group to create.

I read on the BI page on createGroup that;

" An HQ (center) for that side must already be in the Mission.sqm or have been initialized with createCenter"

This might explain why I couldn't seem to get the new unit to join a group.

I had a radio trigger that was supposed to display units within a group in sidechat so I could check if the unit was being added properly, but it would only return "any".

From what I could gather the group wasn't being created.

How do I create a "HQ centre" in the Mission.sqm?

Thanks

Share this post


Link to post
Share on other sites

I've been messing around with this for a day or two and I'm still having some difficulty.

I've got the four units I want to spawn in, but I can't seem to get them to move where I want.

Here's the script I'm working with;

_newgroup = createGroup west;

_leadunit = "B_Soldier_GL_F" createUnit [getMarkerPos "respawn1",_newgroup,"",0.5,"CORPORAL"];
sleep 1;

"B_soldier_AR_F" createUnit [getMarkerPos "respawn1",_newgroup];
sleep 1;

"B_medic_F" createUnit [getMarkerPos "respawn1",_newgroup];
sleep 1;

"B_Soldier_F" createUnit [getMarkerPos "respawn1",_newgroup];


player groupChat "checkpoint 1 passed";

_wpPos = getMarkerPos "point1";
_thisobjective = _newgroup addWaypoint [_wpPos];
_leadunit setCurrentWaypoint _thisobjective;

player groupChat "checkpoint 2 passed";

The checkpoints are all passing so I know the script is finishing.

Note that I also ran a groupChat to call out _wpPos after it was set; the coordinates came back correct, so I know that it is correctly selecting 'point1' as the waypoint destination

Everything else works Ok, but the units just stand there and don't move anywhere.

---------- Post added at 10:32 ---------- Previous post was at 10:29 ----------

Disregard my last.

Discovered a second later that adding the radius makes it work. :rolleyes:

---------- Post added at 11:54 ---------- Previous post was at 10:32 ----------

Slight problem adding something to the init of a created unit.

I can get the unit to spawn just fine using a code like this;

_leadunit = "B_Soldier_GL_F" createUnit [getMarkerPos "respawn1",_newgroup,"",0.5,"CORPORAL"];

But I need to make it so that newly spawned units trigger a script on their death.

So I tried the following;

_leadunit = "B_Soldier_GL_F" createUnit [getMarkerPos "respawn1",_newgroup, _leadunit addEventHandler ["killed", {null = [] execVM "respawni.sqf";}],0.5,"CORPORAL"];

No Dice. The script carries on, but the unit I want doesn't spawn in.

Seems weird since the code I've added is almost exactly the same as what I've placed in the init of starting units;

this addEventHandler ["killed", {null = [] execVM "respawni.sqf";}];

The above works just fine.

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  

×