Einzelnen Beitrag anzeigen
Alt 10.07.2016, 09:57   #11 (permalink)
Sarogahtyp
Newbie
 
Benutzerbild von Sarogahtyp
 
Registriert seit: 20.06.2016
Beiträge: 37
Standard

Code:
_sugarPos = nil;

while {isNil "_sugarPos"} do
{

_centerPos = [] call BIS_fnc_randomPos;
_bushes = nearestTerrainObjects [_centerPos, ["Bush"], 200,false];

{

if ((str _x) find "b_sugarcane_sapling_row_f"!=-1) exitWith {_sugarPos = getPos _x;}; 

} count _bushes;
};

_marker = createMarker ["Marker_1", _sugarPos]; 
_marker setMarkerShape "ICON"; 
_marker setMarkerType "hd_dot";
Dies deckt auch gleich den Fall ab wenn kein zuckerrohr in _bushes ist, dann wird gleich eine neue zufallsposition ermittelt und dort gesucht. Das läuft solange bis was gefunden wird.

For do ist meines wissens etwas langsamer als count und ich würd nearestTerrainObjects nicht sortieren lassen weil es dann auch schneller läuft. Du möchtest ja eh ne zufällige position haben, da ist das nicht notwendig.
__________________
Sarogahtyps Spawn Script Creator - SSSC
the easy way to cache ur units, vehicles and their waypoints

Geändert von Sarogahtyp (10.07.2016 um 10:02 Uhr).
Sarogahtyp ist offline