Jump to content
Sign in to follow this  
Toasted Duckie

createUnit and make him leave group

Recommended Posts

Hey folks, I want to be able to create a unit by clicking on the map, and then have it leave the group its assigned to.

I can place the unit, but using the "join grpNull" command doesn't do anything. In fact, I think that it doesn't work, because I somehow can't get the init in the createunit command to work..

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"soldierEB" createUnit [getMarkerPos "marker", grp2,"[this] join grpNull"]

sad_o.gif

Share this post


Link to post
Share on other sites

I think the init line doesn't work.(bugged still can anyone confirm?)

Or perhaps the createUnit from OFP has been replaced by

http://community.bistudio.com/wiki/createUnit_array

this returns an object which you can work with.

i.e

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_mySoldier = grp2  createUnit ["soldierEB", getMarkerPos "marker",[],0,"NONE"];

[_mySoldier] join grpNull;

Its been a while since I spawned units, but I guess that'll work.

Share this post


Link to post
Share on other sites

You seem to use the createunit command wrong. before the command you put the type of unit, after you put

[positition,group,init,etc]

so that would become:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_mySoldier = "SoldierEB" createUnit [getMarkerPos "marker", grp2;

[_mySoldier] join grpNull;

But that just doesnt seem to work confused_o.gif

When I make a game-logic called grp2 the units won't start running like crazy towards it, but I'm wondering if they'd follow waypoints then...

infact, using _mySoldier = .. won't work, when I put

[_mySoldier] setdamage 1

beneath it, nothing happens.. the created units don't seem to have a identity or name assigned to them..

Share this post


Link to post
Share on other sites

I don't think you can group him up with a Game Logic. confused_o.gif

Try with joining him up with another East soldier.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_mySoldier setdamage 1

http://community.bistudio.com/wiki/setDamage

Should work, remove the [] around

Share this post


Link to post
Share on other sites

You can group them to game logics, the createUnits command does ABSOLUTELY not work, UNLESS a unit is member of a group. Since they spawn when grouped to gamelogics, you can.

I'll try your suggestion, standby.

Edit: Nope, that doesn't do anything to the unit. It just doesn't have a name assigned to it for some reason sad_o.gif

Share this post


Link to post
Share on other sites

Okay I've worked around it, by having the grp2 leader join grpNull. Problem now is that I still can't give individual commands to the units created (such as waypoints, moveorders or assign them to enter vehicles..)

Share this post


Link to post
Share on other sites

Nice.

I was to mention the group thing, but you found that out on your own.

SetPos etc seem to work with game logics, however "doMove" only work for "real" groups.

One odd thing I did find out was that "moveTo" doesn't work when joining the created unit to (group eastDude1) for example.

Anyone knows why?

createUnit.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_dummyUnit","_marker","_mySoldier"];

_dummyUnit = _this select 0;

_marker = _this select 1;

_mySoldier = (group _dummyUnit) createUnit ["soldierEB", getMarkerPos _marker,[],0,"NONE"];

[_mySoldier] join grpNull;

Started from a radio alpha trigger(can be anything)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nil = [<unit or gameLogic>,"<markerName>"] execVM "createUnit.sqf"

Note: gameLogic as I mentioned doesn't work with move commands.

Quote[/b] ]You seem to use the createunit command wrong

Actually I doesn't use it wrongly.

We're just talking about two different commands.

http://community.bistudio.com/wiki/createUnit <-- you.

http://community.bistudio.com/wiki/createUnit_array <-- me.

Share this post


Link to post
Share on other sites
Guest

I noticed the unit is being joined to GrpNull immediately after the spawn script line..

The wiki states the unit must be joined to *a* group after the CreatUnitArray command for various commands to work on the unit.

Hence I would think joining the unit to your dummy's group, then join to group null, but youd likely need a delay in there for the game to register the first group join before going to the grpNull.

Like?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

createUnit.sqf

Code Sample

private ["_dummyUnit","_marker","_mySoldier"];

_dummyUnit = _this select 0;

_marker = _this select 1;

_mySoldier = (group _dummyUnit) createUnit ["soldierEB", getMarkerPos _marker,[],0,"NONE"];

_mySoldier join (group _dummyUnit);

Sleep 5;

[_mySoldier] join grpNull;

Share this post


Link to post
Share on other sites

Hi Special Ed.

Try this script.

createUnit.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//---the_taurus

//moveTo doesn't work!?

private ["_gameLogic","_marker","_location","_mySoldier"];

_dummyUnit = _this select 0;

_marker = _this select 1;

_location = _this select 2;

_mySoldier = (group _dummyUnit) createUnit ["soldierEB", getMarkerPos _marker,[],0,"NONE"];

player sideChat format ["%1 is in group: %2",_mySoldier,group _mySoldier];

sleep 1;

[_mySoldier] join grpNull;

player groupChat format ["Now %1 is in group: %2",_mySoldier,group _mySoldier];

//additional stuff

sleep 1.5;

//Can't be done if created with game logic group

_mySoldier doMove getPos _location;

while{not(((currentCommand _mySoldier) == "") and (unitReady _mySoldier))} do{

//nothing until...

sleep 0.5;

};

//it gets to the location

sleep 1;

//SetPos works with Game Logics too

_mySoldier setPos [getPos _location select 0, getPos _location select 1, 25];

Radio Alpha:

onAct: nil = [<some east guy>,<"marker">,<some object>] execVM "createUnit.sqf"

I spammed the radio command and never was the unit in a grpNull(i.e. not in a group at all)?

The group ID changes tho', as we expect after the <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[_mySoldier] join grpNull

You'll notice that the soldier is moving to the position, and then setPosed into the air.

After a while its "raining men" so to speak smile_o.gif

Also when joining you need to have an array such as

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[_guy] join someGroup;

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  

×