Survivor AI option added to OccupationPlaces

This commit is contained in:
second_coming 2016-04-12 01:25:35 +01:00
parent ca9d73de2a
commit 22475d3e46
9 changed files with 144 additions and 34 deletions

View File

@ -13,8 +13,8 @@
// Shared Config for each occupation monitor
SC_debug = true; // set to true to turn on debug features (not for live servers)
SC_extendedLogging = true; // set to true for additional logging
SC_debug = false; // set to true to turn on debug features (not for live servers)
SC_extendedLogging = false; // set to true for additional logging
SC_infiSTAR_log = true; // true Use infiSTAR logging, false logs to server rpt
SC_maxAIcount = 100; // the maximum amount of AI, if the AI count is above this then additional AI won't spawn
@ -27,10 +27,11 @@ SC_useWaypoints = true; // When spawning AI create waypoints to make t
// (can affect performance when the AI is spawned and the waypoints are calculated)
// Occupation Places (towns, villages & cities roaming AI)
SC_occupyPlaces = true; // true if you want villages,towns,cities patrolled
SC_occupyPlaces = true; // true if you want villages,towns,cities patrolled by bandits
SC_occupyPlacesSurvivors = true; // true if you want a chance to spawn survivor AI as well as bandits (SC_occupyPlaces must be true to use this option)
// Occupation Military (roaming AI near military buildings)
SC_occupyMilitary = false; // true if you want military buildings patrolled (specify which types of building below)
SC_occupyMilitary = true; // true if you want military buildings patrolled (specify which types of building below)
SC_buildings = [ "Land_Cargo_Patrol_V1_F","Land_i_Barracks_V1_F","Land_i_Barracks_V1_dam_F", "Land_i_Barracks_V2_F",
"Land_Cargo_House_V1_F","Land_Cargo_HQ_V1_F","Land_Cargo_HQ_V2_F","Land_Cargo_HQ_V3_F","Land_Cargo_Patrol_V2_F",
@ -41,7 +42,7 @@ SC_buildings = [ "Land_Cargo_Patrol_V1_F","Land_i_Barracks_V1_F",
"Land_Army_hut_int","Land_Army_hut2_int"
];
SC_occupyStatic = false; // true if you want to garrison AI in specific locations (not working yet)
SC_occupyStatic = true; // true if you want to garrison AI in specific locations (not working yet)
SC_occupyVehicle = true; // true if you want to have roaming AI vehicles
SC_occupyVehiclesLocked = true; // true if AI vehicles to stay locked until all the linked AI are dead

View File

@ -2,7 +2,7 @@
//
// Server Occupation script by second_coming
//
SC_occupationVersion = "v9 (11-04-2016)";
SC_occupationVersion = "v10 (12-04-2016)";
//
// http://www.exilemod.com/profile/60-second_coming/
//
@ -22,9 +22,9 @@ SC_occupationVersion = "v9 (11-04-2016)";
[] spawn
{
diag_log format ["[OCCUPATION]:: Occupation %2 Giving the server time to start before starting [OCCUPATION] (%1)",time,SC_occupationVersion];
waitUntil { !(isNil "DMS_MinMax_Y_Coords") };
sleep 30;
sleep 1;
diag_log format ["[OCCUPATION MOD]:: Occupation %2 Loading Config at %1",time,SC_occupationVersion];
// Get the config for Occupation

View File

@ -28,7 +28,7 @@ if(diag_fps < _minFPS) exitWith
[_logDetail] call SC_fnc_log;
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
_aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits;
//_aiActive = count(_spawnCenter nearEntities ["O_recon_F", _maxDistance+1000]);
if(_aiActive > _maxAIcount) exitWith

View File

@ -27,6 +27,17 @@ _maxAIcount = SC_maxAIcount;
_minFPS = SC_minFPS;
_useLaunchers = DMS_ai_use_launchers;
_scaleAI = SC_scaleAI;
_side = "bandit";
if(SC_occupyPlacesSurvivors) then
{
// Make survivors friendly to players and enemies to bandit AI
RESISTANCE setFriend[WEST,1];
WEST setFriend[RESISTANCE,1];
WEST setFriend[EAST,0];
EAST setFriend[WEST,0];
};
// more than _scaleAI players on the server and the max AI count drops per additional player
_currentPlayerCount = count playableUnits;
@ -45,7 +56,7 @@ if(diag_fps < _minFPS) exitWith
};
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
_aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
if(SC_extendedLogging) then
@ -109,7 +120,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
};
// Don't spawn additional AI if there are players in range
if([_pos, 200] call ExileClient_util_world_isAlivePlayerInRange) exitwith
if([_pos, 250] call ExileClient_util_world_isAlivePlayerInRange) exitwith
{
_okToSpawn = false;
if(SC_extendedLogging) then
@ -119,9 +130,36 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
};
};
// Don't spawn additional AI if there are already AI in range
_aiNear = count(_pos nearEntities ["O_recon_F", 500]);
if(_aiNear > 0) exitwith
if(_aiNear > 0) then
{
_nearEastAI = { side _x == EAST AND _x distance _pos < 500 } count allUnits;
_nearWestAI = { side _x == WEST AND _x distance _pos < 500 } count allUnits;
if(_nearEastAI == 0 AND _nearWestAI == 0) then
{
_sideToSpawn = random 100;
if(_sideToSpawn < 50) then
{
_side = "bandit";
}
else
{
_side = "survivor";
};
};
if(_nearEastAI > 0 AND _nearWestAI == 0) then
{
_side = "survivor";
};
if(_nearEastAI == 0 AND _nearWestAI > 0) then
{
_side = "bandit";
};
if(_nearEastAI > 0 AND _nearWestAI > 0) then
{
_okToSpawn = false;
if(SC_extendedLogging) then
@ -129,10 +167,13 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
_logDetail = format ["[OCCUPATION:Places]:: %1 already has %2 active AI patrolling",_locationName,_aiNear];
[_logDetail] call SC_fnc_log;
};
};
};
if(_okToSpawn) then
{
if(!SC_occupyPlacesSurvivors) then { _side = "bandit"; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get AI to patrol the town
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -144,19 +185,48 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
if(_aiCount < 1) then { _aiCount = 1; };
_difficulty = "random";
_side = "bandit";
_spawnPos = [_pos,10,100,5,0,20,0] call BIS_fnc_findSafePos;
_spawnPosition = [_spawnPos select 0, _spawnPos select 1,0];
DMS_ai_use_launchers = false;
_group = [_spawnPosition, _aiCount, "randomEasy", "assault", _side] call DMS_fnc_SpawnAIGroup;
_initialGroup = [_spawnPosition, _aiCount, "randomEasy", "assault", _side] call DMS_fnc_SpawnAIGroup;
DMS_ai_use_launchers = _useLaunchers;
_group = createGroup EAST;
if(_side == "survivor") then
{
deleteGroup _group;
_group = createGroup WEST;
};
_group setVariable ["DMS_LockLocality",nil];
_group setVariable ["DMS_SpawnedGroup",true];
_group setVariable ["DMS_Group_Side", _side];
{
_unit = _x;
[_unit] joinSilent grpNull;
[_unit] joinSilent _group;
}foreach units _group;
if(_side == "survivor") then
{
removeUniform _unit;
_unit forceAddUniform "Exile_Uniform_BambiOverall";
if(SC_debug) then
{
_tag = createVehicle ["Sign_Arrow_Green_F", position _unit, [], 0, "CAN_COLLIDE"];
_tag attachTo [_unit,[0,0,0.6],"Head"];
};
}
else
{
if(SC_debug) then
{
_tag = createVehicle ["Sign_Arrow_F", position _unit, [], 0, "CAN_COLLIDE"];
_tag attachTo [_unit,[0,0,0.6],"Head"];
};
};
}foreach units _initialGroup;
// Get the AI to shut the fuck up :)
enableSentences false;
@ -212,16 +282,51 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
if(_locationType isEqualTo "NameCityCapital") then
{
DMS_ai_use_launchers = false;
_group2 = [_spawnPosition, 5, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
_initialGroup2 = [_spawnPosition, 5, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
DMS_ai_use_launchers = _useLaunchers;
_group2 = createGroup EAST;
if(_side == "survivor") then
{
deleteGroup _group2;
_group2 = createGroup WEST;
};
_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;
if(side _unit == "survivor") then
{
removeUniform _unit;
_unit forceAddUniform "Exile_Uniform_BambiOverall";
if(SC_debug) then
{
_tag = createVehicle ["Sign_Arrow_Green_F", position _unit, [], 0, "CAN_COLLIDE"];
_tag attachTo [_unit,[0,0,0.6],"Head"];
}
else
{
if(SC_debug) then
{
_tag = createVehicle ["Sign_Arrow_F", position _unit, [], 0, "CAN_COLLIDE"];
_tag attachTo [_unit,[0,0,0.6],"Head"];
};
};
};
}foreach units _initialGroup2;
[_group2, _pos, _groupRadius] call bis_fnc_taskPatrol;
_group2 setBehaviour "AWARE";
_group2 setCombatMode "RED";
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -237,7 +342,14 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
_marker setMarkerText "Occupied Area";
};
_logDetail = format ["[OCCUPATION:Places]:: Spawning %2 AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition];
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;
_okToSpawn = false;
};

View File

@ -19,7 +19,7 @@ if(diag_fps < SC_minFPS) exitWith
[_logDetail] call SC_fnc_log;
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
_aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
_logDetail = format ["[OCCUPATION:Sea]:: %1 active AI, so not spawning AI this time",_aiActive];

View File

@ -19,7 +19,7 @@ if(diag_fps < SC_minFPS) exitWith
[_logDetail] call SC_fnc_log;
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
_aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
_logDetail = format ["[OCCUPATION:Sky]:: %1 active AI, so not spawning AI this time",_aiActive];

View File

@ -31,7 +31,7 @@ if(diag_fps < _minFPS) exitWith
[_logDetail] call SC_fnc_log;
};
_aiActive = count(_spawnCenter nearEntities ["O_recon_F", _maxDistance+1000]);
_aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
_logDetail = format ["[OCCUPATION Static]:: %1 active AI, so not spawning AI this time",_aiActive];

View File

@ -20,7 +20,7 @@ if(diag_fps < SC_minFPS) exitWith
[_logDetail] call SC_fnc_log;
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
_aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
_logDetail = format ["[OCCUPATION:Vehicle]:: %1 active AI, so not spawning AI this time",_aiActive];

View File

@ -1,6 +1,3 @@
_logDetail = format ["[OCCUPATION]:: Occupation %2 Giving the server time to start before starting [OCCUPATION] (%1)",time,SC_occupationVersion];
[_logDetail] call SC_fnc_log;
uiSleep 60;
_logDetail = format ["[OCCUPATION]:: Occupation %2 Initialised at %1",time,SC_occupationVersion];
[_logDetail] call SC_fnc_log;