2016-03-17 15:49:37 +00:00
|
|
|
if (!isServer) exitWith {};
|
2016-04-12 10:14:07 +00:00
|
|
|
|
|
|
|
private["_wp","_wp2","_wp3"];
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = format ["[OCCUPATION Military]:: Starting Monitor"];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-04-02 19:06:53 +00:00
|
|
|
_maxAIcount = SC_maxAIcount;
|
|
|
|
_minFPS = SC_minFPS;
|
2016-03-18 10:49:00 +00:00
|
|
|
_useLaunchers = DMS_ai_use_launchers;
|
2016-04-02 19:06:53 +00:00
|
|
|
_scaleAI = SC_scaleAI;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-03-23 11:05:19 +00:00
|
|
|
_buildings = SC_buildings; // Class names for the military buildings to patrol
|
|
|
|
_building = [];
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
_currentPlayerCount = count playableUnits;
|
|
|
|
if(_currentPlayerCount > _scaleAI) then
|
|
|
|
{
|
|
|
|
_maxAIcount = _maxAIcount - (_currentPlayerCount - _scaleAI) ;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Select an area to scan as nearObjects on the entire map is slooooooooow
|
2016-03-18 10:49:00 +00:00
|
|
|
_areaToScan = [ 0, 900, 1, 500, 500, 0, 0, 0, true, false ] call DMS_fnc_findSafePos;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
// 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 Military]:: Held off spawning more AI as the server FPS is only %1",diag_fps];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
|
2016-04-12 00:25:35 +00:00
|
|
|
_aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-04-02 19:06:53 +00:00
|
|
|
//_aiActive = count(_spawnCenter nearEntities ["O_recon_F", _maxDistance+1000]);
|
|
|
|
if(_aiActive > _maxAIcount) exitWith
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Military]:: %1 active AI, so not spawning AI this time",_aiActive];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do
|
|
|
|
{
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = format ["[OCCUPATION Military]:: scanning buildings around %2 started at %1",time,_areaToScan];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-04-10 14:42:45 +00:00
|
|
|
_currentBuilding = _buildings select _i;
|
|
|
|
_building = _areaToScan nearObjects [_currentBuilding, 750];
|
|
|
|
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = format ["[OCCUPATION Military]:: scan for %2 building finished at %1",time,_currentBuilding];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-03-22 14:13:51 +00:00
|
|
|
for [{_n = 0},{_n < (count _building)-1},{_n =_n + 1}] do
|
2016-03-17 15:49:37 +00:00
|
|
|
{
|
|
|
|
_okToSpawn = true;
|
2016-03-22 14:13:51 +00:00
|
|
|
Sleep 0.1;
|
2016-03-17 15:49:37 +00:00
|
|
|
_foundBuilding = (_building select _n);
|
|
|
|
_location = getPos _foundBuilding;
|
|
|
|
_pos = [_location select 0, _location select 1, 0];
|
|
|
|
|
2016-04-02 19:06:53 +00:00
|
|
|
if(SC_extendedLogging) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Military]:: Testing position: %1",_pos];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
while{_okToSpawn} do
|
|
|
|
{
|
2016-03-23 11:05:19 +00:00
|
|
|
// Percentage chance to spawn (roll 60 or more to spawn AI)
|
2016-03-17 15:49:37 +00:00
|
|
|
_spawnChance = round (random 100);
|
2016-04-02 19:06:53 +00:00
|
|
|
if(_spawnChance < 60) exitWith
|
|
|
|
{
|
|
|
|
_okToSpawn = false;
|
|
|
|
if(SC_extendedLogging) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Military]:: Rolled %1 so not spawning AI this time",_spawnChance];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
// Don't spawn if too near a player base
|
|
|
|
_nearBase = (nearestObjects [_pos,["Exile_Construction_Flag_Static"],500]) select 0;
|
2016-04-02 19:06:53 +00:00
|
|
|
if (!isNil "_nearBase") exitwith
|
|
|
|
{
|
|
|
|
_okToSpawn = false;
|
|
|
|
if(SC_extendedLogging) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Military]:: %1 is too close to player base",_pos];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
// Don't spawn AI near traders and spawn zones
|
|
|
|
_nearestMarker = [allMapMarkers, _pos] call BIS_fnc_nearestPosition; // Nearest Marker to the Location
|
|
|
|
_posNearestMarker = getMarkerPos _nearestMarker;
|
2016-04-02 19:06:53 +00:00
|
|
|
if(_pos distance _posNearestMarker < 500) exitwith
|
|
|
|
{
|
|
|
|
_okToSpawn = false;
|
|
|
|
if(SC_extendedLogging) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Military]:: %1 is too close to a %2",_pos,_nearestMarker];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
// Don't spawn additional AI if there are already AI in range
|
|
|
|
_aiNear = count(_pos nearEntities ["O_recon_F", 500]);
|
2016-04-02 19:06:53 +00:00
|
|
|
if(_aiNear > 0) exitwith
|
|
|
|
{
|
|
|
|
_okToSpawn = false;
|
|
|
|
if(SC_extendedLogging) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Military]:: %1 already has %2 active AI patrolling",_pos,_aiNear];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
// Don't spawn additional AI if there are players in range
|
2016-04-02 19:06:53 +00:00
|
|
|
if([_pos, 200] call ExileClient_util_world_isAlivePlayerInRange) exitwith
|
|
|
|
{
|
|
|
|
_okToSpawn = false;
|
|
|
|
if(SC_extendedLogging) then
|
|
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION Military]:: %1 has players too close",_pos];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
|
|
|
|
if(_okToSpawn) then
|
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Get AI to patrol the area
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
_aiCount = 2 + (round (random 3));
|
|
|
|
_groupRadius = 100;
|
|
|
|
_difficulty = "random";
|
|
|
|
_side = "bandit";
|
|
|
|
_spawnPosition = _pos;
|
2016-04-02 19:06:53 +00:00
|
|
|
|
2016-03-18 10:49:00 +00:00
|
|
|
// Get the AI to shut the fuck up :)
|
|
|
|
enableSentences false;
|
|
|
|
enableRadio false;
|
2016-04-02 19:06:53 +00:00
|
|
|
|
2016-03-23 11:05:19 +00:00
|
|
|
if(!SC_useWaypoints) then
|
2016-03-17 15:49:37 +00:00
|
|
|
{
|
2016-03-18 10:49:00 +00:00
|
|
|
DMS_ai_use_launchers = false;
|
|
|
|
_group = [_spawnPosition, _aiCount, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
|
|
|
|
DMS_ai_use_launchers = true;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-03-18 10:49:00 +00:00
|
|
|
[_group, _pos, _groupRadius] call bis_fnc_taskPatrol;
|
2016-04-06 10:29:59 +00:00
|
|
|
_group setBehaviour "COMBAT";
|
2016-03-18 10:49:00 +00:00
|
|
|
_group setCombatMode "RED";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
DMS_ai_use_launchers = false;
|
|
|
|
_group = [_spawnPosition, _aiCount, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
|
|
|
|
DMS_ai_use_launchers = true;
|
|
|
|
|
2016-04-11 12:59:33 +00:00
|
|
|
{
|
|
|
|
_unit = _x;
|
|
|
|
[_unit] joinSilent grpNull;
|
|
|
|
[_unit] joinSilent _group;
|
|
|
|
}foreach units _group;
|
|
|
|
|
2016-03-30 08:33:25 +00:00
|
|
|
[ _group,_pos,_difficulty,"COMBAT" ] call DMS_fnc_SetGroupBehavior;
|
2016-03-18 10:49:00 +00:00
|
|
|
|
|
|
|
_buildings = _pos nearObjects ["house", _groupRadius];
|
|
|
|
{
|
|
|
|
_buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
|
|
|
|
if(count _buildingPositions > 0) then
|
|
|
|
{
|
2016-04-10 14:42:45 +00:00
|
|
|
_y = _x;
|
|
|
|
|
2016-03-18 10:49:00 +00:00
|
|
|
// Find Highest Point
|
|
|
|
_highest = [0,0,0];
|
|
|
|
{
|
|
|
|
if(_x select 2 > _highest select 2) then
|
|
|
|
{
|
|
|
|
_highest = _x;
|
|
|
|
};
|
|
|
|
|
|
|
|
} foreach _buildingPositions;
|
|
|
|
_spawnPosition = _highest;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-03-18 10:49:00 +00:00
|
|
|
_i = _buildingPositions find _spawnPosition;
|
|
|
|
_wp = _group addWaypoint [_spawnPosition, 0] ;
|
|
|
|
_wp setWaypointFormation "Column";
|
2016-04-10 14:42:45 +00:00
|
|
|
_wp setWaypointBehaviour "AWARE";
|
2016-03-18 10:49:00 +00:00
|
|
|
_wp setWaypointCombatMode "RED";
|
|
|
|
_wp setWaypointCompletionRadius 1;
|
2016-04-10 14:42:45 +00:00
|
|
|
_wp waypointAttachObject _y;
|
2016-03-18 10:49:00 +00:00
|
|
|
_wp setwaypointHousePosition _i;
|
2016-04-10 14:42:45 +00:00
|
|
|
_wp setWaypointType "SAD";
|
2016-03-18 10:49:00 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
} foreach _buildings;
|
|
|
|
if(count _buildings > 0 ) then
|
|
|
|
{
|
|
|
|
_wp setWaypointType "CYCLE";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-03-17 15:49:37 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = format ["[OCCUPATION Military]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition];
|
|
|
|
[_logDetail] call SC_fnc_log;
|
2016-03-17 15:49:37 +00:00
|
|
|
|
2016-03-23 11:05:19 +00:00
|
|
|
if(SC_mapMarkers) then
|
2016-03-17 15:49:37 +00:00
|
|
|
{
|
|
|
|
_marker = createMarker [format ["%1", _foundBuilding],_pos];
|
|
|
|
_marker setMarkerShape "Icon";
|
|
|
|
_marker setMarkerSize [3,3];
|
|
|
|
_marker setMarkerType "mil_dot";
|
|
|
|
_marker setMarkerBrush "Solid";
|
|
|
|
_marker setMarkerAlpha 0.5;
|
|
|
|
_marker setMarkerColor "ColorRed";
|
|
|
|
_marker setMarkerText "Occupied Military Area";
|
2016-04-02 19:06:53 +00:00
|
|
|
};
|
2016-03-17 15:49:37 +00:00
|
|
|
_okToSpawn = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2016-04-02 19:06:53 +00:00
|
|
|
_logDetail = "[OCCUPATION Military]: Ended";
|
|
|
|
[_logDetail] call SC_fnc_log;
|