plugger 0 Posted March 16, 2007 Goodaye, I have four empty markers on the map in a SP mission. I'm running a simple init.sqf script (below) at the start in order that one of the four markers is selected as the insertion point for the Player Recon group. The script runs without errors but my Player group always starts in the one spot, i.e no randomness. I've tried different approaches with no luck and I'd appreciate any guidance that you might have. I'm also just starting out with the scripting and I realise that I may have made some fundamental error of logic. Here's my script. //init sqf //provides a random start insertion pt between one of 4 possibilities //on the map are four empty markers named start 1 to 4 //get positions of the four markers _pos1 = getMarkerPos "Start 1"; _pos2 = getMarkerPos "Start 2"; _pos3 = getMarkerPos "Start 3"; _pos4 = getMarkerPos "Start 4"; _rnumber = random 3; _array = [ _pos1, _pos2, _pos3, _pos4]; //create insertion marker and place at one of four random positions _markerobj = createMarker["insert",(_array select _rnumber)]; _markerobj setMarkerShape "ICON"; "insert" setMarkerType "START"; Cheers, Plugger Share this post Link to post Share on other sites
lethal 0 Posted March 16, 2007 mhh.. interesting.. some languages need to initialize the random number generator first or they would get the same sequence of numbers everytime. don't know if it'll help any but i would try adding a "sleep (random 0.1);" before and see if that makes any difference... edit: not sure but does random 3 give all 4 the same chance of being chosen? i would use "(random 4) - 0.5;" to be absolutely equal. biki says: Quote[/b] ]-0.5 rounds up to 0-0.5 <= index <= 0.5 rounds to 0 0.5 rounds down to 0 0.5 < index < 1.5 rounds to 1 1.5 rounds up to 2 1.5 <= index <= 2.5 rounds to 2 2.5 rounds down to 2 2.5 < index < 3.5 rounds to 3 Share this post Link to post Share on other sites
celery 8 Posted March 16, 2007 Could it be that the select command doesn't recognize broken numbers? You might have to make it: _rnumber = random 4; (_array select (floor _rnumber)) Share this post Link to post Share on other sites
lethal 0 Posted March 16, 2007 nope, it should work. at least according to what the biki says. Share this post Link to post Share on other sites
Asuriel 0 Posted March 17, 2007 Goodaye,I have four empty markers on the map in a SP mission. I'm running a simple init.sqf script (below) at the start in order that one of the four markers is selected as the insertion point for the Player Recon group. The script runs without errors but my Player group always starts in the one spot, i.e no randomness. I've tried different approaches with no luck and I'd appreciate any guidance that you might have. I'm also just starting out with the scripting and I realise that I may have made some fundamental error of logic. Here's my script. //init sqf //provides a random start insertion pt between one of 4 possibilities //on the map are four empty markers named start 1 to 4 //get positions of the four markers _pos1 = getMarkerPos "Start 1"; _pos2 = getMarkerPos "Start 2"; _pos3 = getMarkerPos "Start 3"; _pos4 = getMarkerPos "Start 4"; _rnumber = random 3; _array = [ _pos1, _pos2, _pos3, _pos4]; //create insertion marker and place at one of four random positions _markerobj = createMarker["insert",(_array select _rnumber)]; _markerobj setMarkerShape "ICON"; "insert" setMarkerType "START"; Cheers, Plugger do you change the group's position in the leader's ini line to the starting marker or did you forget to add it in the ini.sqs? cause simply selecting a random pos and adding a marker, won't move your group to that position. try <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x setpos (_array select _rnumber)} foreach units this or change <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this to the group's name (of course you have to name the group first by adding <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">groupname = group this to any units ini line. not sure if that will work with an ini.sq(f;s). ok i made it an ini.sqs (not sqf) but it works. the group is named sfrec. it actually is random, but it often sets you in the same spot. here it is: test.intro - offline you have 48 hours to download. after that i'll delete it of my uni-server. Share this post Link to post Share on other sites
Blanco 0 Posted March 17, 2007 You don't need a script for that. Create 4 empty markers and group (F2) one each of them with the leader of the group. It's tricky cos you can't see the markers anymore when you press F2 to group them. Hover your mouse over one a marker until you see his name. Hold the LMB and drag a blue line between the marker and the unit and do this for each marker. The (whole) group will start random on one of the 4 markerpositions. Share this post Link to post Share on other sites
NeZz_DK 1 Posted March 17, 2007 are marker names with spaces in allowed? Share this post Link to post Share on other sites
plugger 0 Posted March 17, 2007 Goodaye, Thanks for the help. The idea (blanco) without the script worked fine. I couldn't access the script that Asuriel provided the link to but I appreciated the advise. Cheers, Plugger Share this post Link to post Share on other sites