Adds inept_fnc_randomPointInCircle.

Trying to find overwatch waypoints better.
M ineptifex/cfgfunctions.ext +3 -2
@@ 11,6 11,8 @@ class INEPT
         class applyToAll {};
         class applyToAllIP {};
         class assignToVehicle {};
+        class averageNumber {};
+        class averagePosition {};
         class conditionalSelectIP {};
         class indexOfBest {};
         class indexOfFirstAtRandom {};

          
@@ 18,10 20,9 @@ class INEPT
         class isSameInstance {};
         class magazinesForWeaponCfg {};
         class popRandom {};
+        class randomPointInCircle {};
         class selectFractionAtRandom {};
         class selectFractionAtRandomIP {};
-        class averageNumber {};
-        class averagePosition {};
     };
 
     class vector

          
M ineptifex/fn_configurePawnWaypoint.sqf +9 -5
@@ 56,7 56,7 @@ case WP_TYPE_GARRISON:
     if (_garrison_me isEqualTo [])
         exitWith {/* Don't garrison if nobody is on foot? */};
 
-    private _buildings = (leader _grp) nearObjects ["Building", 75];
+    private _buildings = ([_pawn] call INEPT_fnc_getPawnPos) nearObjects ["Building", 75];
     LOGVAR(_buildings);
     private _idx =
         [

          
@@ 201,9 201,11 @@ case WP_TYPE_OVERWATCH:
         _aoi select AOI_DISPERSION
         );
     // TODO, we are using a magic number, give it a name
-    if (_area select AREA_WIDTH > 300
-        or {_area select AREA_HEIGHT > 300}) then
+    if (_aoi select AOI_DISPERSION > 250) then
     {
+        // TODO - It's probably better if we just avoid picking spots that
+        // other people are going to....
+        //
         // We do this because it helps even things out. If our AOI is pretty
         // big and meant to cover a fairly large region, but there is a
         // relatively small area that has very high quality observation points,

          
@@ 211,8 213,10 @@ case WP_TYPE_OVERWATCH:
         // always be picked, which results in the rest of the AOI not being
         // covered. This tries to eliminate some of that bias and even things
         // out a bit more.
-        VAR(_areas) = [_area, 150] call INEPT_fnc_subdivide;
-        _area = NEW_CIRCLE(_areas call BIS_fnc_selectRandom, 150);
+        //VAR(_areas) = [_area, 150] call INEPT_fnc_subdivide;
+        private _origin = [_aoi select AOI_POS, (_aoi select AOI_DISPERSION) - 250] call INEPT_fnc_randomPointInCircle;
+        _area = NEW_CIRCLE(_origin, 250);
+        LOGMSG("Shits too big, picked a smaller one");
         LOGVAR(_area);
     };
     VAR(_subareas) = [_area, WP_SUBDIVISION_RADIUS] call INEPT_fnc_subdivide;

          
A => ineptifex/fn_randomPointInCircle.sqf +28 -0
@@ 0,0 1,28 @@ 
+// Arguments
+//   _pos: 2d/3d pos, origin of circle
+//   _rad: circle radius
+// Returns:
+//   Position of random point in the circle described by the parameters,
+//   position has same dimension as the _pos parameter, only the x and y
+//   elements are modified (probably).
+
+params ["_pos", "_rad"];
+
+// https://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly
+private _u = random 1 + random 1;
+private _r = if (_u > 1) then { 2 - _u } else { _u };
+private _t = pi * 2 * random 1;
+private "_final_pos";
+if (count _pos > 2) then
+{
+    private _randvec = [_r * cos (180 * _t), _r * sin (180 * _t), _pos select 2];
+    _final_pos = _pos vectorAdd (_randvec vectorMultiply _rad);
+    _final_pos resize 2;
+}
+else
+{
+    private _randvec = [_r * cos (180 * _t), _r * sin (180 * _t), 0];
+    _final_pos = (_pos + [0]) vectorAdd (_randvec vectorMultiply _rad);
+    _final_pos resize 2;
+};
+_final_pos

          
M init.sqf +1 -1
@@ 11,7 11,7 @@ 
 
 LOGENTRY();
 
-//INEPT_fnc_configurePawnWaypoint_is_verbose = true;
+INEPT_fnc_configurePawnWaypoint_is_verbose = true;
 //INEPT_fnc_behaviorDefendTick_is_verbose = true;
 
 // EnticingEdict specific stuff