brink_za 11 Posted September 22, 2015 Hi guys. I was playing around with BIS_fnc_randomPos to spawn 4 bunkers in an area, but then I realised I need to space them out (somewhat evenly). I'm creating the bunkers sequentially (1,2,3,4) so 1 will be BIS_fnc_randomPos, 2 would be BIS_fnc_randomPos and a condition to not be close to 1 by Xm, 3 would be BIS_fnc_randomPos and a condition to not be close to 1 and 2 by Xm etc. I'm not really sure that's the best method, but that's how I'm thinking it through at present. It was quite an achievement for me to just get the 4 bunkers to spawn randomly with detection triggers for capture ok don't expect too much ^_^ I'm pretty stumped after starting at the wiki trying to figure out how I can add conditions to this function... Here's what I have thus far. It's pretty much a brute force because I don't have lots of experience with scripting and just wanted to see it work quick. Is there a way I could get the {} code part of BIS_fnc_randomPos to do this even dispersion for me? Otherwise I suspect I will need to loop outside the function to satisfy this extra condition(s)? If you could point me in the right direction I would appreciate greatly. I'm sure I'm over complicating it and someone else has done this ezpz a thousand times. The source of the code comes from I&A radiotower spawn they deserve the credit :D I am most definitely not capable of getting this far on my own so yeah... // Spawn Sector Control Points // CREATE MORE LOGICAL/EVEN DISPERSION OF BUNKERS? // 1 _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; while {(count _flatPos) < 1} do { _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; }; _roughPos = [ ((_flatPos select 0) - 5) + (random 10), ((_flatPos select 1) - 5) + (random 10), 0 ]; Bunker1 = "Land_BagBunker_Large_F" createVehicle _flatPos; waitUntil { sleep 0.5; alive Bunker1 }; Bunker1 setVectorUp [0,0,1]; Bunker1 allowDamage false; "Sector1" setMarkerPos _flatPos; // 2 _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; while {(count _flatPos) < 1} do { _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; }; _roughPos = [ ((_flatPos select 0) - 5) + (random 10), ((_flatPos select 1) - 5) + (random 10), 0 ]; Bunker2 = "Land_BagBunker_Large_F" createVehicle _flatPos; waitUntil { sleep 0.5; alive Bunker2 }; Bunker2 setVectorUp [0,0,1]; Bunker2 allowDamage false; "Sector2" setMarkerPos _flatPos; // 3 _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; while {(count _flatPos) < 1} do { _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; }; _roughPos = [ ((_flatPos select 0) - 5) + (random 10), ((_flatPos select 1) - 5) + (random 10), 0 ]; Bunker3 = "Land_BagBunker_Large_F" createVehicle _flatPos; waitUntil { sleep 0.5; alive Bunker3 }; Bunker3 setVectorUp [0,0,1]; Bunker3 allowDamage false; "Sector3" setMarkerPos _flatPos; // 4 _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; while {(count _flatPos) < 1} do { _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; }; _roughPos = [ ((_flatPos select 0) - 5) + (random 10), ((_flatPos select 1) - 5) + (random 10), 0 ]; Bunker4 = "Land_BagBunker_Large_F" createVehicle _flatPos; waitUntil { sleep 0.5; alive Bunker4 }; Bunker4 setVectorUp [0,0,1]; Bunker4 allowDamage false; "Sector4" setMarkerPos _flatPos; 1 Share this post Link to post Share on other sites
Joe98 92 Posted September 22, 2015 Place a truck on the map. Name it truck1. Give it a radius of 200 meters so it always starts at a random location. In this example soldier green1 starts 20 meters to the east and 30 meters to the north of a truck named truck1 green1 setPos [(getPos truck1 select 0) +20, (getPos truck1 select 1) +30]; +20 = East side -20 = West side +30 = North side -30 = South side Instead of 20 meters if you want a random number between say 20 and 100 the command is: (Again the plus and minus refer to east, west, north and south) green1 setPos [(getPos truck1 select 0) - 20 - (random 80), (getPos truck1 select 1) - 20 - (random 80)] Share this post Link to post Share on other sites
brink_za 11 Posted September 23, 2015 Thanks Joe that's one way to do it for sure (if a little less random) and I may yet turn to it if I find no joy here. However, I was thinking more along the lines of using a For loop to 100 or something like this... for "_i" from 1 to 100 do { _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; while {(count _flatPos) < 1} do { _position = [[[getMarkerPos currentAO, 500],_dt],["water","out"]] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty[3, 1, 0.3, 30, 0, false]; }; _roughPos = [ ((_flatPos select 0) - 5) + (random 10), ((_flatPos select 1) - 5) + (random 10), 0 ]; _meters = Bunker1 distance _flatPos; if (_meters >= 500) exitWith {}; }; Bunker2 = "Land_BagBunker_Large_F" createVehicle _flatPos; waitUntil { sleep 0.5; alive Bunker2 }; Bunker2 setVectorUp [0,0,1]; Bunker2 allowDamage false; Bunker2 setDir random 360; "Sector2" setMarkerPos _flatPos; Ok well I tested the above out and it seems to work so far. I did it for all 3 bunkers and now they roughly spawn on the four corners of a square. Share this post Link to post Share on other sites