Jump to content
Sign in to follow this  
avibird 1

A few advanced questions about spawning units on players location not markers!

Recommended Posts

When using these commands [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

What is the "FORM" is this telling the units to get into formation after being spawned into the game ?

What is this for [] what can be put into this [] ?

the 300 is the distance that the units will spawn into the game from the player. Right now by default the units will spawn at random directions ( west,east,south and north) 300 meters from the player. Is there a way to make the units spawn at a set direction from the player for example always south and or east. I understand direction is set by-

0/360 = north

90 = east

180 = south

270 = west

I know how to use markers but do not want to use markers. I need to have the units spawn using the players location due to the dynamic mission objectives.

I have tryed multiple different codelines in the above commands but no luck. The main issue is that the AI groups sometimes gets spawned behind the enemy lines and gets raped before hooking up with the whole squad.

Thanks for any input on this. AVIBIRD

Share this post


Link to post
Share on other sites

[] is an array containing random marker locations for extra randomization incase you want that.

"FORM" is exactly what you said, it tells the units to go into formation once spawned, standard is Wedge. It can be changed with setFormation.

For set direction spawn, maybe try this:

{
_x setDir 0;
} foreach units _group;

The above assumes you have named the group you spawned _group (or rather assigned that variable to it)

Share this post


Link to post
Share on other sites
When using these commands [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

What is the "FORM" is this telling the units to get into formation after being spawned into the game ?

Yes.

What is this for [] what can be put into this [] ?

It's an array of markers which will be random selected if it contains more than one marker.

the 300 is the distance that the units will spawn into the game from the player.

Yes it's the placement radius.

Right now by default the units will spawn at random directions ( west,east,south and north) 300 meters from the player. Is there a way to make the units spawn at a set direction from the player for example always south and or east. I understand direction is set by-

0/360 = north

90 = east

180 = south

270 = west

Use setDir - http://community.bistudio.com/wiki/setDir

Here's an example spawning a unit around player position:

_pos = [(getPos player select 0) + sin(random 360) * 300, (getPos player select 1) + cos(random 360) * 300, 0];

_grp1 = createGroup east;

"RU_Soldier_TLB" createUnit [_pos, _grp1,"", 0.6, "corporal"];

Share this post


Link to post
Share on other sites

Thanks for the reply. Are you saying try to add your codeline/command to my script like this-

GroupB = CreateGroup WEST;

B1 = GroupB createUnit ["US_Soldier_SL_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B2 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B3 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B4 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B5 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B6 = GroupB createUnit ["US_Soldier_HAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B7 = GroupB createUnit ["US_Soldier_HAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B8 = GroupB createUnit ["US_Soldier_HAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B9 = GroupB createUnit ["US_Soldier_HAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B10 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B11 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B12 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B13 = GroupB createUnit ["US_Soldier_LAT_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B14 = GroupB createUnit ["US_Soldier_AA_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B15 = GroupB createUnit ["US_Soldier_AA_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 300, "FORM"];

B1 = leader GroupB;

{_x setSkill 1} foreach units GroupB;

{

_x setDir 0;

} foreach units GroupB;

sleep 1;

wp1 = GroupB addwaypoint [position Player, 25];

wp1 setwaypointtype "MOVE";

wp1 setWaypointCombatMode "YELLOW";

wp1 setWaypointFormation "DIAMOND";

wp1 setWaypointSpeed "FULL";

wp1 setWaypointBehaviour "AWARE";

wp1 setWaypointCompletionRadius 10;

wp1 setWaypointStatements ["true", ""];

hint "WE ARE HERE SIR";

waituntil {moveToCompleted leader GroupB};

sleep 120;

hint "";

wp2 = GroupB addwaypoint [position Player, 25];

wp2 waypointAttachVehicle vehicle player;

wp2 setwaypointtype "SAD";

wp2 setWaypointCombatMode "Yellow";

wp2 setWaypointFormation "WEDGE";

wp2 setWaypointSpeed "FULL";

wp2 setWaypointBehaviour "AWARE";

wp2 setWaypointCompletionRadius 10;

wp2 setWaypointStatements ["true", ""];

ECT............. MY script goes on .............

AVIBIRD

---------- Post added at 17:50 ---------- Previous post was at 17:46 ----------

JW did not see your post. How would I add your codeline into my script above. Would I just copy and drop into my code. Thanks this one of the things I have been looking for a while now lol.

Share this post


Link to post
Share on other sites

Include the _x setDir 0 in your previous forEach with setSkill 1, but it should work either way.

Share this post


Link to post
Share on other sites

Yes "form" tells them to get into formation.

Most of that info is already given in the wiki for the creatUnit array and createVehicle array commands? [] is for random placement by marker. You put the marker names in the array eg:

["marker1", "marker2", "marker3"]

As for a set distance and direction from the player - you looked at that example mission I made for you? The [(getpos player) select 0,(getpos player) select 1,0] bit is a position array - always in the format [x,y] or [x,y,z] 2D and 3D. You can create a position before you enter it eg:

_pos = [(getPosATL Player select 0) + (100 * sin(270)), (getPosATL Player select 1) + (100 * cos(270)), 0];
//you can then enter:
_unit = groupName createUnit ["SoldierWB", _pos, [], 0, "FORM"];

That will create the unit 100m West of the player (0 = exact position).

Share this post


Link to post
Share on other sites

Mattar yes it was cool to see what you did in the demo but could not get it to work in the above script for my INF units. I probably did not insert right or missed something really easy.

For example _pos = from your code above do I keep this or does this have to be something else from my script. It is the little things like this that gets me nuts lol.

Share this post


Link to post
Share on other sites

_pos is equal to whatever is between the [], it can be called anything you like from _pos to _xmarksthespot, it's a variable:

http://en.wikipedia.org/wiki/Variable_%28computer_science%29

It stores the information that was located between the [] for use later in the script. You can see what _pos really is by puting the following in a radio trigger:

pos = [(getPosATL Player select 0) + (100 * sin(270)), (getPosATL Player select 1) + (100 * cos(270)), 0];
player sidechat format ["%1",pos];

It will return something like [1193.89,1043.27,0] which is a positionATL [x,y,z] format.

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

Share this post


Link to post
Share on other sites

tryteyker your way using {_x setDir 0;} foreach units _group; Did not work and I tryed to use the codeline multiple ways(: did you test it yourself to see if it works!

JW customy and Mattar_tharkari both of your ways worked out fine. I knew there had to be a way to do this(: What I am seeing now there are different ways to skin a cat when it comes down to scripting lol. This is what gets me in a little trouble at times. I need to see the bigger picture at times. Thank you all for the help. Almost done just a few more issues to work out.

Share this post


Link to post
Share on other sites

You need to define _group first obviously.

So if you have something like this:

_group = [//details] call bis_fnc_spawngroup;
{
_x setDir 0;
_x setSkill 1;
} foreach units _group;

it will work.

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  

×