JohnRayMitch 1 Posted January 24, 2019 (edited) 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 = [ "CUP_I_TK_GUE_Soldier", "CUP_I_TK_GUE_Soldier_TL", "CUP_I_TK_GUE_Soldier_MG", "CUP_I_TK_GUE_Soldier_AT", "CUP_I_TK_GUE_Soldier_AAT", "CUP_I_TK_GUE_Soldier_M16A2", "CUP_I_TK_GUE_Soldier_GL", "CUP_I_TK_GUE_Soldier_HAT", "CUP_I_TK_GUE_Soldier_AK_47S", "CUP_I_TK_GUE_Soldier_AR", "CUP_I_TK_GUE_Soldier_AA", "CUP_I_TK_GUE_Commander", "CUP_I_TK_GUE_Guerilla_Medic", "CUP_I_TK_GUE_Guerilla_Enfield", "CUP_I_TK_GUE_Demo", "CUP_I_TK_GUE_Sniper", "CUP_I_TK_GUE_Mechanic" ]; _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 January 24, 2019 by JohnRayMitch Found Solution Share this post Link to post Share on other sites
beno_83au 1369 Posted January 24, 2019 _unkSpawnPosition = getMarkerPos (selectRandom ["spawn_1", "spawn_2", "spawn_3"]); -> selectRandom 2 Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted January 24, 2019 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 = [ "O_G_Soldier_F",0.9,"O_G_Soldier_TL_F",0.1 ]; _patrol = [getPos player,_units,east,10,50] spawn GOM_fnc_spawnPatrol; Easy to go from there. Cheers 1 1 Share this post Link to post Share on other sites