V57 Phantom AI Fix

This commit is contained in:
second_coming
2016-08-09 16:13:55 +01:00
parent 5a7b0c8c68
commit de859e164b
4 changed files with 229 additions and 197 deletions

View File

@ -1,3 +1,9 @@
=================================================================================
V57 (09-08-2016)
=================================================================================
OccupationPlaces module fixed when the location found can't find a safeposition to
spawn the AI
=================================================================================
V56 (05-08-2016)
=================================================================================

View File

@ -4,7 +4,7 @@ class CfgPatches
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
a3_exile_occupation_version = "V56 (05-08-2016)";
a3_exile_occupation_version = "V57 (09-08-2016)";
requiredAddons[] = {"a3_dms"};
author[]= {"second_coming"};
};

View File

@ -401,14 +401,14 @@ if (worldName == 'Namalsk' AND SC_useMapOverrides) then
if (worldName == 'Napf' AND SC_useMapOverrides) then
{
//SC_maxAIcount = 160;
//SC_maxNumberofVehicles = 5;
SC_maxAIcount = 160;
SC_maxNumberofVehicles = 5;
};
if (worldName == 'Chernarus' AND SC_useMapOverrides) then
{
//SC_maxAIcount = 160;
//SC_maxNumberofVehicles = 5;
SC_maxAIcount = 160;
SC_maxNumberofVehicles = 5;
};
if (worldName == 'Tanoa' AND SC_useMapOverrides) then
@ -449,17 +449,18 @@ if (SC_debug) then
{
SC_extendedLogging = true;
SC_processReporter = true;
SC_mapMarkers = false;
SC_occupyPlaces = false;
SC_occupyVehicle = true;
SC_mapMarkers = true;
SC_occupyPlaces = true;
SC_occupyVehicle = false;
SC_occupyMilitary = false;
SC_occupyStatic = false;
SC_occupySky = true;
SC_occupySea = true;
SC_occupySky = false;
SC_occupySea = false;
SC_occupyTraders = false;
SC_occupyTransport = false;
SC_occupyLootCrates = false;
SC_occupyHeliCrashes = false;
SC_maxAIcount = 160;
SC_maxAIcount = 200;
SC_maxNumberofVehicles = 5;
SC_maxNumberofBoats = 5;
SC_maxNumberofHelis = 5;

View File

@ -51,7 +51,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
_temppos = position _x;
_locationName = text _x;
_locationType = type _x;
_pos = [_temppos select 0, _temppos select 1, 0];
_pos = [_temppos select 0, _temppos select 1, _temppos select 2];
if(SC_extendedLogging) then
@ -60,60 +60,70 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
[_logDetail] call SC_fnc_log;
};
while{_okToSpawn} do
{
// Percentage chance to spawn (roll 80 or more to spawn AI)
_spawnChance = round (random 100);
if(_spawnChance < 80) exitWith
{
_okToSpawn = false;
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Places]:: Rolled %1 so not spawning AI this time",_spawnChance,_locationName];
[_logDetail] call SC_fnc_log;
};
};
// Percentage chance to spawn (roll 80 or more to spawn AI)
_spawnChance = round (random 100);
if(_spawnChance < 80) then
{
_okToSpawn = false;
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Places]:: Rolled %1 so not spawning AI this time",_spawnChance,_locationName];
[_logDetail] call SC_fnc_log;
};
}
else
{
_okToSpawn = [ _pos ] call SC_fnc_isSafePos;
if(isNil "_okToSpawn") then { _okToSpawn = false; };
// Don't spawn additional AI if there are already AI in range
_nearBanditAI = { side _x == SC_BanditSide AND _x distance _pos < 500 } count allUnits;
_nearSurvivorAI = { side _x == SC_SurvivorSide AND _x distance _pos < 500 } count allUnits;
_okToSpawn = [ _pos ] call SC_fnc_isSafePos;
if(isNil "_okToSpawn" OR !_okToSpawn) exitWith
{
_okToSpawn = false;
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Places]:: (%2) %1 is not a safe place to spawn",_pos,_locationName];
[_logDetail] call SC_fnc_log;
};
};
if(_nearBanditAI > 0 AND _nearSurvivorAI > 0) then
{
_okToSpawn = false;
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Places]:: %1 already has active AI patrolling",_locationName];
[_logDetail] call SC_fnc_log;
};
}
else
{
if(_nearSurvivorAI == 0) then
{
_sideToSpawn = random 100;
if(_sideToSpawn <= SC_SurvivorsChance) then
{
_side = "survivor";
}
else
{
_side = "bandit";
};
}
else
{
_side = "bandit";
};
};
// Don't spawn additional AI if there are already AI in range
_nearBanditAI = { side _x == SC_BanditSide AND _x distance _pos < 500 } count allUnits;
_nearSurvivorAI = { side _x == SC_SurvivorSide AND _x distance _pos < 500 } count allUnits;
if(_nearBanditAI > 0 AND _nearSurvivorAI > 0) exitWith
{
_okToSpawn = false;
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Places]:: %1 already has active AI patrolling",_locationName];
[_logDetail] call SC_fnc_log;
};
};
if(_okToSpawn) then
{
if(_nearSurvivorAI == 0) then
{
_sideToSpawn = random 100;
if(_sideToSpawn <= SC_SurvivorsChance) then
{
_side = "survivor";
}
else
{
_side = "bandit";
};
}
else
{
_side = "bandit";
};
if(!SC_occupyPlacesSurvivors) then { _side = "bandit"; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get AI to patrol the town
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_aiCount = 1;
@ -125,80 +135,93 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
if(_aiCount < 1) then { _aiCount = 1; };
_difficulty = "random";
_spawnPos = [_pos,10,100,5,0,20,0] call BIS_fnc_findSafePos;
_spawnPosition = [_spawnPos select 0, _spawnPos select 1,0];
//_safeSpawnPosition = [_pos,10,100,5,0,20,0] call BIS_fnc_findSafePos;
_safeSpawnPosition = _pos findEmptyPosition [0,50,"B_T_MRAP_01_F"];
_group = createGroup SC_BanditSide;
if(_side == "survivor") then
{
deleteGroup _group;
_group = createGroup SC_SurvivorSide;
};
_group setVariable ["DMS_AllowFreezing",false];
diag_log "==========================================================================================================================";
diag_log format["_pos: %1 _safeSpawnPosition: %2 _temppos: %3 location: %4 (%5)",_pos,_safeSpawnPosition,_temppos,_x,_locationName];
diag_log "==========================================================================================================================";
if(count _safeSpawnPosition == 0) exitWith
{
_okToSpawn = false;
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Places]:: Couldn't find safe position at %1",_locationName,_safeSpawnPosition];
[_logDetail] call SC_fnc_log;
};
};
_spawnPosition = [_safeSpawnPosition select 0, _safeSpawnPosition select 1, 0];
_group = createGroup SC_BanditSide;
if(_side == "survivor") then
{
deleteGroup _group;
_group = createGroup SC_SurvivorSide;
};
_group setVariable ["DMS_LockLocality",nil];
_group setVariable ["DMS_SpawnedGroup",true];
_group setVariable ["DMS_Group_Side", _side];
_group setVariable ["DMS_AllowFreezing",true];
DMS_ai_use_launchers = false;
for "_i" from 1 to _aiCount do
{
_loadOut = [_side] call SC_fnc_selectGear;
_unit = [_group,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier;
_unit allowFleeing 0;
_unit allowDamage false;
_unit disableAI "AUTOTARGET";
_unit disableAI "TARGET";
_unit disableAI "MOVE";
_unit setVariable ["SC_unitLocationName", _locationName,true];
_unit setVariable ["SC_unitLocationPosition", _pos,true];
_unit setVariable ["SC_unitSide", _side,true];
_unit addMPEventHandler ["mpkilled", "_this call SC_fnc_locationUnitMPKilled;"];
};
for "_i" from 1 to _aiCount do
{
_loadOut = [_side] call SC_fnc_selectGear;
_unit = [_group,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier;
_unit allowFleeing 0;
_unit allowDamage false;
_unit disableAI "AUTOTARGET";
_unit disableAI "TARGET";
_unit disableAI "MOVE";
_unit setVariable ["SC_unitLocationName", _locationName,true];
_unit setVariable ["SC_unitLocationPosition", _spawnPosition,true];
_unit setVariable ["SC_unitSide", _side,true];
_unit addMPEventHandler ["mpkilled", "_this call SC_fnc_locationUnitMPKilled;"];
};
DMS_ai_use_launchers = _useLaunchers;
_group setVariable ["DMS_LockLocality",nil];
_group setVariable ["DMS_SpawnedGroup",true];
_group setVariable ["DMS_Group_Side", _side];
{
_unit = _x;
[_unit] joinSilent grpNull;
[_unit] joinSilent _group;
_unit allowDamage true;
_unit enableAI "AUTOTARGET";
_unit enableAI "TARGET";
_unit enableAI "MOVE";
_unitName = [_side] call SC_fnc_selectName;
if(!isNil "_unitName") then { _unit setName _unitName; };
[_side,_unit] call SC_fnc_addMarker;
reload _unit;
}foreach units _group;
_group setVariable ["DMS_AllowFreezing",true];
{
_unit = _x;
[_unit] joinSilent grpNull;
[_unit] joinSilent _group;
_unit allowDamage true;
_unit enableAI "AUTOTARGET";
_unit enableAI "TARGET";
_unit enableAI "MOVE";
_unitName = [_side] call SC_fnc_selectName;
if(!isNil "_unitName") then { _unit setName _unitName; };
[_side,_unit] call SC_fnc_addMarker;
reload _unit;
}foreach units _group;
// Get the AI to shut the fuck up :)
enableSentences false;
enableRadio false;
if(!SC_useWaypoints) then
{
[_group, _pos, _groupRadius] call bis_fnc_taskPatrol;
[_group, _spawnPosition, _groupRadius] call bis_fnc_taskPatrol;
_group setBehaviour "COMBAT";
_group setCombatMode "RED";
}
else
{
[ _group,_pos,_difficulty,"COMBAT" ] call DMS_fnc_SetGroupBehavior;
[ _group,_spawnPosition,_difficulty,"COMBAT" ] call DMS_fnc_SetGroupBehavior;
_buildings = _pos nearObjects ["building", _groupRadius];
_buildings = _spawnPosition nearObjects ["building", _groupRadius];
{
_isEnterable = [_x] call BIS_fnc_isBuildingEnterable;
if(_isEnterable) then
{
_buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
_y = _x;
_buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
_y = _x;
// Find Highest Point
_highest = [0,0,0];
{
@ -229,112 +252,114 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
if(_locationType isEqualTo "NameCityCapital") then
{
_group2 = createGroup SC_BanditSide;
if(_side == "survivor") then
{
deleteGroup _group2;
_group2 = createGroup SC_SurvivorSide;
};
_group2 setVariable ["DMS_AllowFreezing",false];
DMS_ai_use_launchers = false;
for "_i" from 1 to 5 do
{
_loadOut = ["bandit"] call SC_fnc_selectGear;
_unit = [_group2,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier;
_unit allowFleeing 0;
_group2 = createGroup SC_BanditSide;
if(_side == "survivor") then
{
deleteGroup _group2;
_group2 = createGroup SC_SurvivorSide;
};
_group2 setVariable ["DMS_AllowFreezing",false];
DMS_ai_use_launchers = false;
for "_i" from 1 to 5 do
{
_loadOut = ["bandit"] call SC_fnc_selectGear;
_unit = [_group2,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier;
_unit allowFleeing 0;
_unit allowDamage false;
_unit disableAI "AUTOTARGET";
_unit disableAI "TARGET";
_unit disableAI "MOVE";
_unit setVariable ["SC_unitLocationName", _locationName,true];
_unit setVariable ["SC_unitLocationPosition", _pos,true];
_unit setVariable ["SC_unitSide", _side,true];
_unit addMPEventHandler ["mpkilled", "_this call SC_fnc_locationUnitMPKilled;"];
};
DMS_ai_use_launchers = _useLaunchers;
_group2 setVariable ["DMS_LockLocality",nil];
_group2 setVariable ["DMS_SpawnedGroup",true];
_group2 setVariable ["DMS_Group_Side", _side];
_unit setVariable ["SC_unitLocationName", _locationName,true];
_unit setVariable ["SC_unitLocationPosition", _spawnPosition,true];
_unit setVariable ["SC_unitSide", _side,true];
_unit addMPEventHandler ["mpkilled", "_this call SC_fnc_locationUnitMPKilled;"];
};
DMS_ai_use_launchers = _useLaunchers;
_group2 setVariable ["DMS_LockLocality",nil];
_group2 setVariable ["DMS_SpawnedGroup",true];
_group2 setVariable ["DMS_Group_Side", _side];
// Get the AI to shut the fuck up :)
enableSentences false;
enableRadio false;
{
_unit = _x;
[_unit] joinSilent grpNull;
[_unit] joinSilent _group2;
_unit allowDamage true;
_unit enableAI "AUTOTARGET";
_unit enableAI "TARGET";
_unit enableAI "MOVE";
[_side,_unit] call SC_fnc_addMarker;
_unitName = [_side] call SC_fnc_selectName;
if(!isNil "_unitName") then { _unit setName _unitName; };
reload _unit;
}foreach units _group2;
_group2 setVariable ["DMS_AllowFreezing",true];
[_group2, _pos, _groupRadius] call bis_fnc_taskPatrol;
{
_unit = _x;
[_unit] joinSilent grpNull;
[_unit] joinSilent _group2;
_unit allowDamage true;
_unit enableAI "AUTOTARGET";
_unit enableAI "TARGET";
_unit enableAI "MOVE";
[_side,_unit] call SC_fnc_addMarker;
_unitName = [_side] call SC_fnc_selectName;
if(!isNil "_unitName") then { _unit setName _unitName; };
reload _unit;
}foreach units _group2;
_group2 setVariable ["DMS_AllowFreezing",true];
[_group2, _spawnPosition, _groupRadius] call bis_fnc_taskPatrol;
_group2 setBehaviour "AWARE";
_group2 setCombatMode "RED";
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_markerName = "Occupation Area";
_markerColour = "ColorOrange";
_markerName = "Occupation Area";
_markerColour = "ColorOrange";
if(SC_mapMarkers) then
{
deleteMarker format ["%1", _locationName];
_nearBanditAI = { side _x == SC_BanditSide AND _x distance _pos < 500 } count allUnits;
_nearSurvivorAI = { side _x == SC_SurvivorSide AND _x distance _pos < 500 } count allUnits;
if(_nearBanditAI > 0 && _nearSurvivorAI > 0) then
{
_markerName = "Survivors and Bandits";
_markerColour = "ColorOrange";
};
if(_nearBanditAI == 0 && _nearSurvivorAI > 0) then
{
_markerName = "Survivors";
_markerColour = "ColorGreen";
};
if(_nearBanditAI > 0 && _nearSurvivorAI == 0) then
{
_markerName = "Bandits";
_markerColour = "ColorRed";
};
_marker = createMarker [format ["%1", _locationName],_pos];
_nearBanditAI = { side _x == SC_BanditSide AND _x distance _spawnPosition < 500 } count allUnits;
_nearSurvivorAI = { side _x == SC_SurvivorSide AND _x distance _spawnPosition < 500 } count allUnits;
if(_nearBanditAI > 0 && _nearSurvivorAI > 0) then
{
_markerName = "Survivors and Bandits";
_markerColour = "ColorOrange";
};
if(_nearBanditAI == 0 && _nearSurvivorAI > 0) then
{
_markerName = "Survivors";
_markerColour = "ColorGreen";
};
if(_nearBanditAI > 0 && _nearSurvivorAI == 0) then
{
_markerName = "Bandits";
_markerColour = "ColorRed";
};
_marker = createMarker [format ["%1", _locationName],_spawnPosition];
_marker setMarkerShape "Icon";
_marker setMarkerSize [3,3];
_marker setMarkerType "mil_dot";
_marker setMarkerBrush "Solid";
_marker setMarkerText _markerName;
_marker setMarkerColor _markerColour;
_marker setMarkerText _markerName;
_marker setMarkerColor _markerColour;
_marker setMarkerAlpha 0.5;
if(_side == "survivor") then
{
_logDetail = format ["[OCCUPATION:Places]:: Spawning %2 survivor AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition];
}
else
{
_logDetail = format ["[OCCUPATION:Places]:: Spawning %2 bandit AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition];
};
[_logDetail] call SC_fnc_log;
_logDetail = format ["[OCCUPATION:Places]:: %1 Bandits:%2 Survivors:%3 Marker Colour:%4 Marker Name:%5",_locationName,_nearBanditAI,_nearSurvivorAI,_markerColour,_markerName];
[_logDetail] call SC_fnc_log;
};
_okToSpawn = false;
};
if(_side == "survivor") then
{
_logDetail = format ["[OCCUPATION:Places]:: Spawning %2 survivor AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition];
}
else
{
_logDetail = format ["[OCCUPATION:Places]:: Spawning %2 bandit AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition];
};
[_logDetail] call SC_fnc_log;
_logDetail = format ["[OCCUPATION:Places]:: %1 Bandits:%2 Survivors:%3 Marker Colour:%4 Marker Name:%5",_locationName,_nearBanditAI,_nearSurvivorAI,_markerColour,_markerName];
[_logDetail] call SC_fnc_log;
};
};
};
sleep 0.2;
} forEach _locations;