redarmy 422 Posted March 30 I trying to further randomize a wapypoints position within a marker. currently using it in such a way that it finds the centre point and gets a random distance from it to create a wp,like so: randomPoint= selectRandom ["AO", "AO"]; _wp = BB addWaypoint [getmarkerpos randomPoint,1000]; _wp setwaypointtype "GETOUT"; Now,instead of 1000, i want no distance,i just want the wp to be generated anywhere within the marker named AO. Whats the best way of doing this? Share this post Link to post Share on other sites
Schatten 290 Posted March 30 https://community.bistudio.com/wiki/BIS_fnc_randomPosTrigger Share this post Link to post Share on other sites
redarmy 422 Posted March 30 1 hour ago, Schatten said: https://community.bistudio.com/wiki/BIS_fnc_randomPosTrigger I Dont quite understand . random pos trigger? Im attempting to generate waypoints at random withing a marker area. The wiki doesnt show any reasonably useful examples. care to elaborate? Share this post Link to post Share on other sites
Schatten 290 Posted March 30 According to the function syntax and example, it also accepts markers. Share this post Link to post Share on other sites
redarmy 422 Posted March 30 38 minutes ago, Schatten said: According to the function syntax and example, it also accepts markers. I read that,though no combination of efforts of applying it to my original syntax works. I dont think it works with waypoints,unless someone can verify. Share this post Link to post Share on other sites
Schatten 290 Posted March 30 _wp = BB addWaypoint [randomPoint call BIS_fnc_randomPosTrigger, -1]; 1 Share this post Link to post Share on other sites
redarmy 422 Posted March 30 18 minutes ago, Schatten said: _wp = BB addWaypoint [randomPoint call BIS_fnc_randomPosTrigger, -1]; Perfect,thank you. Can i ask.. "-1" is signaling a random distance in the area from centre point? Like "0" would just send them to the centre each time? Iv been only recently learning about adding waypoints through scripting recently its pretty cool and opens up alot of possibility. Share this post Link to post Share on other sites
Schatten 290 Posted March 30 2 minutes ago, redarmy said: Can i ask.. "-1" is signaling a random distance in the area from centre point? No, according to the BIKI: Quote -1 can be used for exact waypoint placement Just noticed, that PositionASL should be used if radius is negative, so this is fixed version: _wp = BB addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; Share this post Link to post Share on other sites
redarmy 422 Posted March 30 6 minutes ago, Schatten said: No, according to the BIKI: Just noticed, that PositionASL should be used if radius is negative, so this is fixed version: _wp = BB addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; Is this to do with sea and ground level? For finding a safe ground or something? Share this post Link to post Share on other sites
Schatten 290 Posted March 30 Don't know for sure -- I just write scripts in accordance to the BIKI, and it says that if radius is zero or positive, then you should use PositionAGL, otherwise you should use PositionASL. Share this post Link to post Share on other sites
redarmy 422 Posted March 30 12 minutes ago, Schatten said: Don't know for sure -- I just write scripts in accordance to the BIKI, and it says that if radius is zero or positive, then you should use PositionAGL, otherwise you should use PositionASL. hmmm tested it and it doesnt check for water,sends them into the ocean . Strangely enough my original post syntax ,never sent them into water,it detected ground. It was a snippet of a larger syntax with multiple waypoints. Regardless,this will do nicely: randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Alpha1; _wp = Alpha1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Alpha1 setBehaviour "Aware"; _wp = Alpha1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Alpha2; _wp = Alpha2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Alpha2 setBehaviour "Aware"; _wp = Alpha2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Alpha2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Bravo1; _wp = Bravo1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Bravo1 setBehaviour "Aware"; _wp = Bravo1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Bravo2; _wp = Bravo2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Bravo2 setBehaviour "Aware"; _wp = Bravo2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Bravo2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Charlie1; _wp = Charlie1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Charlie1 setBehaviour "Aware"; _wp = Charlie1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Charlie2; _wp = Charlie2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Charlie2 setBehaviour "Aware"; _wp = Charlie2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Charlie2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Delta1; _wp = Delta1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Delta1 setBehaviour "Aware"; _wp = Delta1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Delta2; _wp = Delta2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Delta2 setBehaviour "Aware"; _wp = Delta2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Delta2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Recon1; _wp = Recon1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Recon1 setBehaviour "Aware"; _wp = Recon1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon1 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; randomPoint= selectRandom ["AO", "AO"]; { deleteWaypoint _x } forEachReversed waypoints Recon2; _wp = Recon2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "GETOUT"; _wp setWaypointSpeed "NORMAL"; Recon2 setBehaviour "Aware"; _wp = Recon2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "SAD"; _wp = Recon2 addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1]; _wp setwaypointtype "CYCLE"; Share this post Link to post Share on other sites
Larrow 2822 Posted March 31 As all groups are handled the same you could just do something like... Spoiler _fnc_addWaypoint = { params[ "_group", [ "_pos", "", [ "", [] ] ], [ "_type", "MOVE", [ "" ] ] ]; private _wp = switch ( _pos ) do { //Marker case ( _pos isEqualType "" && { getMarkerPos _pos isNotEqualTo [0,0,0] } ) : { _group addWaypoint[ AGLToASL ( _pos call BIS_fnc_randomPosTrigger ), -1 ]; }; //Waypoint case ( _pos isEqualType [] && { _pos #0 isEqualType grpNull && { _pos #1 isEqualType 0 } } ) : { _group addWaypoint[ AGLToASL waypointPosition _pos, -1 ]; }; }; if ( isNil "_wp" ) exitWith { "Waypoint not created" call BIS_fnc_error; }; _wp setWaypointType _type; _wp }; _marker = selectRandom[ "AO", "AO" ]; { _x params[ "_group" ]; _wp = [ _group, _marker, "GETOUT" ] call _fnc_addWaypoint; _wp setWaypointSpeed "NORMAL"; _group setBehaviour "Aware"; _group setCurrentWaypoint _wp; for "_i" from 1 to 5 do { [ _group, _marker, "SAD" ] call _fnc_addWaypoint; }; [ _group, _wp, "CYCLE" ] call _fnc_addWaypoint; }forEach[ Alpha1, Alpha2, Bravo1, Bravo2, Charlie1, Charlie2, Delta1, Delta2, Recon1, Recon2 ]; 1 Share this post Link to post Share on other sites
redarmy 422 Posted March 31 9 hours ago, Larrow said: As all groups are handled the same you could just do something like... Hide contents _fnc_addWaypoint = { params[ "_group", [ "_pos", "", [ "", [] ] ], [ "_type", "MOVE", [ "" ] ] ]; private _wp = switch ( _pos ) do { //Marker case ( _pos isEqualType "" && { getMarkerPos _pos isNotEqualTo [0,0,0] } ) : { _group addWaypoint[ AGLToASL ( _pos call BIS_fnc_randomPosTrigger ), -1 ]; }; //Waypoint case ( _pos isEqualType [] && { _pos #0 isEqualType grpNull && { _pos #1 isEqualType 0 } } ) : { _group addWaypoint[ AGLToASL waypointPosition _pos, -1 ]; }; }; if ( isNil "_wp" ) exitWith { "Waypoint not created" call BIS_fnc_error; }; _wp setWaypointType _type; _wp }; _marker = selectRandom[ "AO", "AO" ]; { _x params[ "_group" ]; _wp = [ _group, _marker, "GETOUT" ] call _fnc_addWaypoint; _wp setWaypointSpeed "NORMAL"; _group setBehaviour "Aware"; _group setCurrentWaypoint _wp; for "_i" from 1 to 5 do { [ _group, _marker, "SAD" ] call _fnc_addWaypoint; }; [ _group, _wp, "CYCLE" ] call _fnc_addWaypoint; }forEach[ Alpha1, Alpha2, Bravo1, Bravo2, Charlie1, Charlie2, Delta1, Delta2, Recon1, Recon2 ]; Thank you Larrow. Is there any difference performance wise? Share this post Link to post Share on other sites
Larrow 2822 Posted April 1 9 hours ago, redarmy said: Is there any difference performance wise? No, just easier to read, if you need to change anything it only has to be done in one place rather than multiple times in a large amount of code. So maybe yes, for your fingers and eyes 😄 1 Share this post Link to post Share on other sites