Jump to content
Sign in to follow this  
Horner

Random Spawn

Recommended Posts

Hey, I used this code for random spawn except for the chernarus soldiers i used takistani "used on OA"

/////////////////////////////////////////////////////////

// Randomize placement of a group within 6 spots

/////////////////////////////////////////////////////////

if (! isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers.

// Create Group for units to be spawned into; must have group created BEFORE spawning units in.

groupPrimo = createGroup RESISTANCE;

// Pick Location ///////////////////////////////////////////////////////////////////////

n1 = round ((random 6) + 0.5); // generates random number from 1 to 6

if (n1 == 1) then

{

G1 = "GUE_Soldier_CO" createunit [getMarkerPos "marker1", groupPrimo];

G1 setdir 180;

G2 = "GUE_Soldier_MG" createunit [getMarkerPos "marker1", groupPrimo];

G2 setdir 180;

G3 = "GUE_Soldier_GL" createunit [getMarkerPos "marker1", groupPrimo];

G3 setdir 180;

G3 = "GUE_Soldier_AT" createunit [getMarkerPos "marker1", groupPrimo];

G3 setdir 180;

};

if (n1 == 2) then

{

G1 = "GUE_Soldier_CO" createunit [getMarkerPos "marker2", groupPrimo];

G1 setdir 180;

G2 = "GUE_Soldier_MG" createunit [getMarkerPos "marker2", groupPrimo];

G2 setdir 180;

G3 = "GUE_Soldier_GL" createunit [getMarkerPos "marker2", groupPrimo];

G3 setdir 180;

G3 = "GUE_Soldier_AT" createunit [getMarkerPos "marker2", groupPrimo];

G3 setdir 180;

};

if (n1 == 3) then

{

G1 = "GUE_Soldier_CO" createunit [getMarkerPos "marker3", groupPrimo];

G1 setdir 180;

G2 = "GUE_Soldier_MG" createunit [getMarkerPos "marker3", groupPrimo];

G2 setdir 180;

G3 = "GUE_Soldier_GL" createunit [getMarkerPos "marker3", groupPrimo];

G3 setdir 180;

G3 = "GUE_Soldier_AT" createunit [getMarkerPos "marker3", groupPrimo];

G3 setdir 180;

};

if (n1 == 4) then

{

G1 = "GUE_Soldier_CO" createunit [getMarkerPos "marker4", groupPrimo];

G1 setdir 180;

G2 = "GUE_Soldier_MG" createunit [getMarkerPos "marker4", groupPrimo];

G2 setdir 180;

G3 = "GUE_Soldier_GL" createunit [getMarkerPos "marker4", groupPrimo];

G3 setdir 180;

G3 = "GUE_Soldier_AT" createunit [getMarkerPos "marker4", groupPrimo];

G3 setdir 180;

};

if (n1 == 5) then

{

G1 = "GUE_Soldier_CO" createunit [getMarkerPos "marker5", groupPrimo];

G1 setdir 180;

G2 = "GUE_Soldier_MG" createunit [getMarkerPos "marker5", groupPrimo];

G2 setdir 180;

G3 = "GUE_Soldier_GL" createunit [getMarkerPos "marker5", groupPrimo];

G3 setdir 180;

G3 = "GUE_Soldier_AT" createunit [getMarkerPos "marker5", groupPrimo];

G3 setdir 180;

};

if (n1 == 6) then

{

G1 = "GUE_Soldier_CO" createunit [getMarkerPos "marker6", groupPrimo];

G1 setdir 180;

G2 = "GUE_Soldier_MG" createunit [getMarkerPos "marker6", groupPrimo];

G2 setdir 180;

G3 = "GUE_Soldier_GL" createunit [getMarkerPos "marker6", groupPrimo];

G3 setdir 180;

G3 = "GUE_Soldier_AT" createunit [getMarkerPos "marker6", groupPrimo];

G3 setdir 180;

};

okay they spawn, all works well, except i can walk up to them and they dont engage. What is going on?

Share this post


Link to post
Share on other sites

When there are no editor placed units of a faction, they really behave abnormal.

Just place a unit of the faction and set possiblility of presence to 0.

Could be your problem.

Share this post


Link to post
Share on other sites

use the createCenter command before the spawns if there are no units of that side present on the map before the spawn.

edit: Melmarkian beat me to it :)

Share this post


Link to post
Share on other sites

ok thanks guys ill see if it works :)

---------- Post added at 05:58 PM ---------- Previous post was at 05:51 PM ----------

wait demoized where do i put the createCenter command?

Share this post


Link to post
Share on other sites
if (! isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers.
_SideHQ = createCenter resistance;

Share this post


Link to post
Share on other sites
// Pick Location ///////////////////////////////////////////////////////////////////////

n1 = round ((random 6) + 0.5); // generates random number from 1 to 6

that is a error, it gives a 0.5 to any whole random number from random 6.

now you see that none of the options will ever start as not one of them is something.5....

should be:

n1 = round(random 6); but you can get the ocassional 0 and then noone will spawn, if this is not the plan, then use ceil instead.

n1 = ceil(random 6);

Share this post


Link to post
Share on other sites

but people spawn and the right people too they just dont engage.

Share this post


Link to post
Share on other sites

I see you are using the RESISTANCE side for the spawned groups. Are you sure you set them to hostile to the right side?

Share this post


Link to post
Share on other sites

Just for fun of it, this should do the same and is much shorter: (not tested)

_myunits = ["GUE_Soldier_CO","GUE_Soldier_MG","GUE_Soldier_GL","GUE_Soldier_AT"];

_n1 = ceil(random 6);

{_new = _x createunit [getMarkerpos format["marker%1",_n1],groupPrimo]} foreach _myunits;

Edited by ])rStrangelove

Share this post


Link to post
Share on other sites

Melmark when I go up to them the name is red that should mean they are hostile right?

Share this post


Link to post
Share on other sites

maybe try BIS_fnc_spawnGroup instead:

1: place a function module on map.

_group = [getMarkerPos "marker1", resistance, ["GUE_Soldier_CO","GUE_Soldier_MG","GUE_Soldier_GL","GUE_Soldier_AT"],[],[],[],[],[],180] call BIS_fnc_spawnGroup

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  

×