2016-03-23 11:05:19 +00:00
|
|
|
private["_wp","_wp2","_wp3"];
|
|
|
|
|
|
|
|
if (!isServer) exitWith {};
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = format ["[OCCUPATION Static]:: Starting Monitor"];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
2016-03-23 11:05:19 +00:00
|
|
|
|
2016-04-02 19:06:53 +00:00
|
|
|
_middle = worldSize/2;
|
|
|
|
_spawnCenter = [_middle,_middle,0]; // Centre point for the map
|
|
|
|
_maxDistance = _middle; // Max radius for the map
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
_maxAIcount = SC_maxAIcount;
|
|
|
|
_minFPS = SC_minFPS;
|
2016-04-02 19:06:53 +00:00
|
|
|
_debug = SC_debug;
|
|
|
|
_useLaunchers = DMS_ai_use_launchers;
|
2016-03-23 11:05:19 +00:00
|
|
|
_scaleAI = SC_scaleAI;
|
|
|
|
|
2016-04-02 19:06:53 +00:00
|
|
|
_statics = SC_statics; // details for the static spawns
|
|
|
|
_static = [];
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
_currentPlayerCount = count playableUnits;
|
|
|
|
if(_currentPlayerCount > _scaleAI) then
|
|
|
|
{
|
|
|
|
_maxAIcount = _maxAIcount - (_currentPlayerCount - _scaleAI) ;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Don't spawn additional AI if the server fps is below 8
|
2016-04-02 19:06:53 +00:00
|
|
|
if(diag_fps < _minFPS) exitWith
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Static]:: Held off spawning more AI as the server FPS is only %1",diag_fps];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
_aiActive = count(_spawnCenter nearEntities ["O_recon_F", _maxDistance+1000]);
|
2016-04-02 19:06:53 +00:00
|
|
|
if(_aiActive > _maxAIcount) exitWith
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Static]:: %1 active AI, so not spawning AI this time",_aiActive];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do
|
|
|
|
{
|
|
|
|
_currentStatic = _statics select _i;
|
|
|
|
_spawnPosition = _currentStatic select 0;
|
|
|
|
_aiCount = _currentStatic select 1;
|
|
|
|
_radius = _currentStatic select 2;
|
|
|
|
_staticSearch = _currentStatic select 3;
|
|
|
|
_underground = _currentStatic select 4;
|
|
|
|
|
2016-04-06 10:29:59 +00:00
|
|
|
_logDetail = format ["[OCCUPATION Static]:: Checking static spawn @ %1",_spawnPosition,_aiCount];
|
2016-04-02 19:06:53 +00:00
|
|
|
[_logDetail] call SC_fnc_log;
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
_okToSpawn = true;
|
|
|
|
Sleep 0.1;
|
|
|
|
|
|
|
|
while{_okToSpawn} do
|
|
|
|
{
|
|
|
|
|
|
|
|
// Don't spawn additional AI if there are already AI in range
|
2016-04-06 10:29:59 +00:00
|
|
|
_aiNear = count(_spawnPosition nearEntities ["O_recon_F", 250]);
|
2016-04-02 19:06:53 +00:00
|
|
|
if(_aiNear > 0) exitwith
|
|
|
|
{
|
|
|
|
_okToSpawn = false;
|
|
|
|
if(_debug) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Static]:: %1 already has %2 active AI patrolling",_spawnPosition,_aiNear];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
};
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
// Don't spawn additional AI if there are players in range
|
2016-04-02 19:06:53 +00:00
|
|
|
if([_spawnPosition, 400] call ExileClient_util_world_isAlivePlayerInRange) exitwith
|
|
|
|
{
|
|
|
|
_okToSpawn = false;
|
|
|
|
if(_debug) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Static]:: %1 has players too close",_spawnPosition];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
};
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
if(_okToSpawn) then
|
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Get AI to patrol the area
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
_groupRadius = _radius;
|
|
|
|
_difficulty = "random";
|
|
|
|
_side = "bandit";
|
|
|
|
|
|
|
|
DMS_ai_use_launchers = false;
|
|
|
|
_group = [_spawnPosition, _aiCount, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
|
|
|
|
[ _group,_spawnPosition,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior;
|
|
|
|
DMS_ai_use_launchers = true;
|
|
|
|
|
|
|
|
// Get the AI to shut the fuck up :)
|
|
|
|
enableSentences false;
|
|
|
|
enableRadio false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!_staticSearch) then
|
|
|
|
{
|
|
|
|
[_group, _spawnPosition, _groupRadius] call bis_fnc_taskPatrol;
|
|
|
|
_group setBehaviour "AWARE";
|
|
|
|
_group setCombatMode "RED";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2016-03-30 08:33:25 +00:00
|
|
|
_buildings = _spawnPosition nearObjects ["building", _groupRadius];
|
2016-03-23 11:05:19 +00:00
|
|
|
{
|
|
|
|
_buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
|
|
|
|
if(count _buildingPositions > 0) then
|
|
|
|
{
|
|
|
|
|
|
|
|
// Find Highest Point
|
|
|
|
_highest = [0,0,0];
|
|
|
|
{
|
|
|
|
if(_x select 2 > _highest select 2) then
|
|
|
|
{
|
|
|
|
_highest = _x;
|
|
|
|
};
|
|
|
|
|
|
|
|
} foreach _buildingPositions;
|
|
|
|
_spawnPosition = _highest;
|
|
|
|
|
|
|
|
_i = _buildingPositions find _spawnPosition;
|
|
|
|
_wp = _group addWaypoint [_spawnPosition, 0] ;
|
|
|
|
_wp setWaypointFormation "Column";
|
2016-04-02 19:06:53 +00:00
|
|
|
_wp setWaypointBehaviour "COMBAT";
|
2016-03-23 11:05:19 +00:00
|
|
|
_wp setWaypointCombatMode "RED";
|
|
|
|
_wp setWaypointCompletionRadius 1;
|
|
|
|
_wp waypointAttachObject _x;
|
|
|
|
_wp setwaypointHousePosition _i;
|
2016-04-02 19:06:53 +00:00
|
|
|
_wp setWaypointType "SAD";
|
2016-03-23 11:05:19 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
} foreach _buildings;
|
|
|
|
if(count _buildings > 0 ) then
|
|
|
|
{
|
|
|
|
_wp setWaypointType "CYCLE";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = format ["[OCCUPATION Static]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
2016-03-23 11:05:19 +00:00
|
|
|
|
2016-04-06 10:29:59 +00:00
|
|
|
if(SC_mapMarkers && !isNil "_foundBuilding") then
|
2016-03-23 11:05:19 +00:00
|
|
|
{
|
|
|
|
_marker = createMarker [format ["%1", _foundBuilding],_spawnPosition];
|
|
|
|
_marker setMarkerShape "Icon";
|
|
|
|
_marker setMarkerSize [3,3];
|
|
|
|
_marker setMarkerType "mil_dot";
|
|
|
|
_marker setMarkerBrush "Solid";
|
|
|
|
_marker setMarkerAlpha 0.5;
|
|
|
|
_marker setMarkerColor "ColorRed";
|
|
|
|
_marker setMarkerText "Occupied Area (static)";
|
|
|
|
};
|
|
|
|
|
|
|
|
_okToSpawn = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = "[OCCUPATION Static]: Ended";
|
|
|
|
[_logDetail] call SC_fnc_log;
|