Jump to content
Sign in to follow this  

Help: Random Spawn

Recommended Posts

Hey I'm trying to get my script to randomly select a location specified in an array and spawn units accordingly. Only problem is that while the unit does spawn, the other spawn locations end up getting a few units spawned there as well. Can anyone one find the error?


_spawnPoints = ["spawn_1", "spawn_2", "spawn_3"];

_indUnitList = [

_spawnMarker = _spawnPoints select (floor random (count _spawnPoints));

_unkSpawnPosition = getMarkerPos _spawnMarker;

IndGroup = [_unkSpawnPosition, INDEPENDENT, _indUnitList] call BIS_fnc_spawnGroup;
IndGroup allowFeeling 0;
IndGroup enableDynamicSimulation true;

sleep 0.5;


EDIT: Never mind guys, I guess when I was alt tabbing I somehow managed to place a few units. But if anyone reads this, do they have a more efficient way of doing this?

Edited by JohnRayMitch
Found Solution

Share this post

Link to post
Share on other sites

Posted this in a thread earlier this week (last week? who knows):

GOM_fnc_spawnPatrol = {
	params ["_pos","_units","_side","_size","_distance"];
	_grp = createGroup [_side,true];
	for "_i" from 0 to _size do {
		selectRandomWeighted _units createUnit [_pos, _grp];
	//patrol random points at n distance
	while {{alive _x} count units _grp > 0} do {
		waitUntil {sleep (5 + random 20);unitReady leader _grp AND combatMode leader _grp != "COMBAT"};
		_grp move (_pos getPos [random _distance,random 360]);

//90% chance to spawn soldier_f, 10% chance to spawn TL_F
_units = [

_patrol = [getPos player,_units,east,10,50] spawn GOM_fnc_spawnPatrol;

Easy to go from there.



  • Like 1
  • Thanks 1

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