Here is how I do it, using Domination as base, located in x_scripts\x_createsecondary.sqf:
Code:
_poss = [];
while {count _poss == 0} do {
_poss = [_target_array2 select 0, _target_array2 select 2] call XfGetRanPointCircleBig;
switch (d_params_LocationDifficulty) do {
//no check needed for case 0.
case 1: {if ((_poss distance [((_target_array2 select 0) select 0), ((_target_array2 select 0) select 1)] < (_target_array2 select 2)*0.4)) then {_poss = []}};
case 2: {if ((_poss distance [((_target_array2 select 0) select 0), ((_target_array2 select 0) select 1)] < (_target_array2 select 2)*0.8)) then {_poss = []}};
};
sleep 0.04;
};
And the function (located in x_scripts\x_funcs\x_functions2.sqf):
Code:
// get a random point inside a circle for bigger objects
// parameters:
// center position, radius of the circle
// example: _random_point = [position trigger1, 200] call XfGetRanPointCircleBig;
XfGetRanPointCircleBig = {
private ["_center", "_radius", "_center_x", "_center_y", "_ret_val", "_co", "_angle", "_x1", "_y1", "_nobs", "_helper"];
_center = _this select 0;_radius = _this select 1;
_center_x = _center select 0;_center_y = _center select 1;
_ret_val = [];_co = 0;
while {count _ret_val == 0 && _co < 50} do {
_angle = floor (random 360);
_x1 = _center_x - ((random _radius) * sin _angle);
_y1 = _center_y - ((random _radius) * cos _angle);
if (!(surfaceiswater [_x1, _y1])) then {
_nobs = [_x1,_y1,0] nearObjects ["Static",20];
if (count _nobs == 0) then {
_helper = "RoadCone" createVehicleLocal [_x1,_y1,0];
if (!(surfaceIsWater [position _helper select 0, position _helper select 1])) then {
_slope = [position _helper, 5] call XfGetSlope;
if (_slope < 0.5 && !(isOnRoad (position _helper))) then {
_ret_val = [position _helper select 0,position _helper select 1,0];
};
};
deleteVehicle _helper;
};
};
if (count _ret_val == 0) then {
_co = _co + 1;
};
};
_ret_val
};
_target_array2 select 0 contains the position.
_target_array2 select 2 contains the radius.
_target_array2 select 1 contains the location, but is not used in these scripts.