Jump to content
Sign in to follow this  
SpitShine

Troubles with randomising a spawn

Recommended Posts

I'm making a mission with a randomly placed objective and three randomly placed optional objectives and while I can get the main objective to spawn in a random location just fine, and the optional objectives to do the same, what I want to do is spawn the optional objectives in one of their random locations only if they are within a certain distance from the main one.

How do I got about scripting this? I'm completely stumped.

Share this post


Link to post
Share on other sites

Yeah well... how?

_mainspawn = ["mainspawn1","mainspawn2","mainspawn3","mainspawn4","mainspawn5"] BIS_fnc_selectRandom;

_randomspawn = ["randomspawn1","randomspawn2","randomspawn3","randomspawn4","randomspawn5"] call BIS_fnc_selectRandom;

_mainpos = (getmarkerpos _mainspawn);

_randompos = (getmarkerpos _randomspawn)

if (_mainpos distance _randompos < 2500) then {randomobject setpos _randompos} else {????????????}

Share this post


Link to post
Share on other sites

doing this off the top of my head so it is probably full of syntax errors...

_newArray = [];
_mainspawn = ["mainspawn1","mainspawn2","mainspawn3","mainspawn4 ","mainspawn5"] BIS_fnc_selectRandom;
_randomspawn = ["randomspawn1","randomspawn2","randomspawn3","rand omspawn4","randomspawn5"];

{
    if ((getPos _mainSpawn) distance (getPos _x) < 2500) then {
         _newArray = _newArray + ["_x"];
    };
} foreach _randomSpawn;


_newRand = _newArray call BIS_fnc_selectRandom;

This way, you check the sde objectives for their distance before you chose one at random.

Das

ps - I might have messed up the newArray + _x line in the way I cast _x as an array, haven't done that yet in ARMA.

Share this post


Link to post
Share on other sites

if ((getPos zonebase) distance (getPos _x) < 2500) then {

Error getpos: type string, expected array, location

Apparently the above doesn't work

---------- Post added at 03:03 ---------- Previous post was at 02:52 ----------

_randomArray = [];
_randomspawn = ["radiomarker", "radiomarker_1", "radiomarker_2", "radiomarker_3", "radiomarker_4", "radiomarker_5", 
"radiomarker_6", "radiomarker_7", "radiomarker_8", "radiomarker_9", "radiomarker_10", "radiomarker_11", "radiomarker_12", 
"radiomarker_13", "radiomarker_14", "radiomarker_15", "radiomarker_16", "radiomarker_17", "radiomarker_18", "radiomarker_19", 
"radiomarker_20", "radiomarker_21", "radiomarker_22", "radiomarker_23", "radiomarker_24", "radiomarker_25", "radiomarker_26", 
"radiomarker_27", "radiomarker_28", "radiomarker_29"];
{
if ((getPos zonebase) distance (getmarkerpos "_x") < 5000) then {
_randomArray = _randomArray + "_x";
};
} foreach _randomSpawn;
_setradiomarker = _randomArray call BIS_fnc_selectRandom;
_radiopos = (getmarkerpos _setradiomarker);
radiotower setpos _radiopos;

This gives me an error saying _randomarray is empty

Share this post


Link to post
Share on other sites

try not putting quotes around the _x. That is what I meant about casting. By putting quotes around it, you are making it a string. Oh, and the other stupid thing I did is you need to use getMarkerPos, not getPos.

feh

DasClark

ps - I am typing this from work so I can't guaranty the answer as I cant test it but I think this is right.

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  

×