Global variable rename & added static spawns

This commit is contained in:
second_coming 2016-03-23 11:05:19 +00:00
parent 9f37dfa703
commit 9747535b5c
9 changed files with 287 additions and 112 deletions

View File

@ -1 +1 @@
x\addons\a3_exile_occupation
x\addons\a3_exile_occupation

View File

@ -1,73 +1,76 @@
// Shared Config for each occupation monitor
debug = false; // set to true for additional logging
maxAIcount = 100; // the maximum amount of AI, if the AI count is above this then additional AI won't spawn
SC_debug = false; // set to true for additional logging
SC_maxAIcount = 100; // the maximum amount of AI, if the AI count is above this then additional AI won't spawn
// As Namalsk is a smaller map, lower the maximum AI count
if (worldName == 'Namalsk') then { maxAIcount = 80; };
if (worldName == 'Namalsk') then { SC_maxAIcount = 80; };
mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false
minFPS = 8; // any lower than minFPS on the server and additional AI won't spawn
SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false
SC_minFPS = 8; // any lower than minFPS on the server and additional AI won't spawn
scaleAI = 10; // any more than _scaleAI players on the server and _maxAIcount is reduced for each extra player
SC_scaleAI = 10; // any more than _scaleAI players on the server and _maxAIcount is reduced for each extra player
useWaypoints = true; // When spawning AI create waypoints to make them enter buildings
// (can affect performance when the AI is spawned and the waypoints are calculated)
SC_useWaypoints = true; // When spawning AI create waypoints to make them enter buildings
// (can affect performance when the AI is spawned and the waypoints are calculated)
occupyPlaces = true; // true if you want villages,towns,cities patrolled
occupyMilitary = false; // true if you want military buildings patrolled (specify which types of building in occupationMilitary.sqf)
occupyStatic = false; // true if you want to garrison AI in specific locations (not working yet)
occupyVehicle = true; // true if you want to have roaming AI vehicles
occupySky = true; // true if you want to have roaming AI helis
SC_occupyPlaces = true; // true if you want villages,towns,cities patrolled
SC_occupyMilitary = false; // true if you want military buildings patrolled (specify which types of building in occupationMilitary.sqf)
SC_occupyStatic = false; // 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_occupySky = true; // true if you want to have roaming AI helis
SC_statics = [
[[4151,6697,0],4,100,true],
[[3560,6673,0],4,100,true]
]; //[[pos],ai count,radius,search buildings]
// Which buildings to patrol with the occupyMilitary option (adding more classnames could affect server performance when the spawning occurs)
buildings = ["Land_Cargo_Patrol_V1_F",
"Land_i_Barracks_V1_F",
"Land_i_Barracks_V1_dam_F",
"Land_i_Barracks_V2_F",
"Land_u_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",
"Land_Cargo_Patrol_V3_F",
"Land_Cargo_Tower_V1_F",
"Land_Cargo_Tower_V1_No1_F",
"Land_Cargo_Tower_V1_No2_F",
"Land_Cargo_Tower_V1_No3_F",
"Land_Cargo_Tower_V1_No4_F",
"Land_Cargo_Tower_V1_No5_F",
"Land_Cargo_Tower_V1_No6_F",
"Land_Cargo_Tower_V1_No7_F",
"Land_Cargo_Tower_V2_F",
"Land_Cargo_Tower_V3_F",
"Land_MilOffices_V1_F",
"Land_Radar_F",
"Land_Radar_Small_F",
"Land_Dome_Big_F",
"Land_Dome_Small_F"];
SC_buildings = ["Land_Cargo_Patrol_V1_F",
"Land_i_Barracks_V1_F",
"Land_i_Barracks_V1_dam_F",
"Land_i_Barracks_V2_F",
"Land_u_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",
"Land_Cargo_Patrol_V3_F",
"Land_Cargo_Tower_V1_F",
"Land_Cargo_Tower_V1_No1_F",
"Land_Cargo_Tower_V1_No2_F",
"Land_Cargo_Tower_V1_No3_F",
"Land_Cargo_Tower_V1_No4_F",
"Land_Cargo_Tower_V1_No5_F",
"Land_Cargo_Tower_V1_No6_F",
"Land_Cargo_Tower_V1_No7_F",
"Land_Cargo_Tower_V2_F",
"Land_Cargo_Tower_V3_F",
"Land_MilOffices_V1_F",
"Land_Radar_F",
"Land_Radar_Small_F",
"Land_Dome_Big_F",
"Land_Dome_Small_F"];
// Settings for roaming ground vehicle AI
maxNumberofVehicles = 3; // Number of roaming vehicles required, randomly selected from VehicleClassToUse
VehicleClassToUse = ["Exile_Car_LandRover_Green",
"Exile_Car_UAZ_Open_Green",
"Exile_Car_Offroad_Armed_Guerilla01"];
SC_maxNumberofVehicles = 3; // Number of roaming vehicles required, randomly selected from VehicleClassToUse
SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green",
"Exile_Car_UAZ_Open_Green",
"Exile_Car_Offroad_Armed_Guerilla01"];
// Settings for roaming airborne AI
maxNumberofHelis = 1; // Number of roaming vehicles required, randomly selected from HeliClassToUse
HeliClassToUse = ["Exile_Chopper_Huey_Armed_Green",
"Exile_Chopper_Hellcat_Green",
"Exile_Chopper_Mohawk_FIA"];
SC_maxNumberofHelis = 1; // Number of roaming vehicles required, randomly selected from HeliClassToUse (only use armed helis for now)
SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green" ];
// Don't alter anything below this point
liveVehicles = 0;
publicVariable "liveVehicles";
liveHelis = 0;
publicVariable "liveHelis";
SC_liveVehicles = 0;
publicVariable "SC_liveVehicles";
SC_liveHelis = 0;
publicVariable "SC_liveHelis";

View File

@ -1,3 +1,3 @@
diag_log format ["[OCCUPATION MOD]:: Initialised at %1",time];
[] execVM "\x\addons\a3_exile_occupation\config.sqf";
[] execVM "\x\addons\a3_exile_occupation\startOccupation.sqf";
[] execVM "\x\addons\a3_exile_occupation\startOccupation.sqf";

View File

@ -11,6 +11,7 @@
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
private["_wp","_wp2","_wp3"];
if (!isServer) exitWith {};
@ -20,11 +21,11 @@ _middle = worldSize/2;
_spawnCenter = [_middle,_middle,0]; // Centre point for the map
_maxDistance = _middle; // Max radius for the map
_maxAIcount = maxAIcount;
_minFPS = minFPS;
_debug = debug;
_maxAIcount = SC_maxAIcount;
_minFPS = SC_minFPS;
_debug = SC_debug;
_useLaunchers = DMS_ai_use_launchers;
_scaleAI = scaleAI;
_scaleAI = SC_scaleAI;
// more than _scaleAI players on the server and the max AI count drops per additional player
_currentPlayerCount = count playableUnits;
@ -97,7 +98,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
enableSentences false;
enableRadio false;
if(!useWaypoints) then
if(!SC_useWaypoints) then
{
[_group, _pos, _groupRadius] call bis_fnc_taskPatrol;
_group setBehaviour "DESTROY";
@ -158,7 +159,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(mapMarkers) then
if(SC_mapMarkers) then
{
_marker = createMarker [format ["%1", _spawnPosition],_pos];
_marker setMarkerShape "Icon";
@ -175,4 +176,4 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
};
};
} forEach _locations;
} forEach _locations;

View File

@ -11,6 +11,7 @@
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
private["_wp","_wp2","_wp3"];
if (!isServer) exitWith {};
@ -20,14 +21,14 @@ _middle = worldSize/2;
_spawnCenter = [_middle,_middle,0]; // Centre point for the map
_maxDistance = _middle; // Max radius for the map
_maxAIcount = maxAIcount;
_minFPS = minFPS;
_debug = debug;
_maxAIcount = SC_maxAIcount;
_minFPS = SC_minFPS;
_debug = SC_debug;
_useLaunchers = DMS_ai_use_launchers;
_scaleAI = scaleAI;
_scaleAI = SC_scaleAI;
_buildings = buildings; // Class names for the military buildings to patrol
_building = [];
_buildings = SC_buildings; // Class names for the military buildings to patrol
_building = [];
_currentPlayerCount = count playableUnits;
if(_currentPlayerCount > _scaleAI) then
@ -65,9 +66,9 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do
while{_okToSpawn} do
{
// Percentage chance to spawn (roll 80 or more to spawn AI)
// Percentage chance to spawn (roll 60 or more to spawn AI)
_spawnChance = round (random 100);
if(_spawnChance < 80) exitWith { _okToSpawn = false; if(_debug) then { diag_log format ["[OCCUPATION Military]:: Rolled %1 so not spawning AI this time",_spawnChance];};};
if(_spawnChance < 60) exitWith { _okToSpawn = false; if(_debug) then { diag_log format ["[OCCUPATION Military]:: Rolled %1 so not spawning AI this time",_spawnChance];};};
// Don't spawn if too near a player base
_nearBase = (nearestObjects [_pos,["Exile_Construction_Flag_Static"],500]) select 0;
@ -104,7 +105,7 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do
if(!useWaypoints) then
if(!SC_useWaypoints) then
{
DMS_ai_use_launchers = false;
_group = [_spawnPosition, _aiCount, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
@ -181,7 +182,7 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diag_log format ["[OCCUPATION Military]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition];
if(mapMarkers) then
if(SC_mapMarkers) then
{
_marker = createMarker [format ["%1", _foundBuilding],_pos];
_marker setMarkerShape "Icon";
@ -198,4 +199,4 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do
};
};
};
diag_log "[OCCUPATION Military]: Ended";
diag_log "[OCCUPATION Military]: Ended";

View File

@ -1,13 +1,24 @@
/** ROAMING TRADER by JohnO **/
// Trader vehicle handling added by second_coming
////////////////////////////////////////////////////////////////////////
//
// Server Occupation script by second_coming
//
// Version 2.0
//
// http://www.exilemod.com/profile/60-second_coming/
//
// This script uses the fantastic DMS by Defent and eraser1
//
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
diag_log format['[OCCUPATION:Sky] Started'];
if (!isServer) exitWith {};
if(liveHelis >= maxNumberofHelis) exitWith {};
if(SC_liveHelis >= SC_maxNumberofHelis) exitWith {};
_vehiclesToSpawn = (maxNumberofHelis - liveHelis);
_vehiclesToSpawn = (SC_maxNumberofHelis - SC_liveHelis);
_middle = worldSize/2;
_spawnCenter = [_middle,_middle,0];
_maxDistance = _middle;
@ -38,9 +49,8 @@ for "_i" from 1 to _vehiclesToSpawn do
_position = position _Location;
_spawnLocation = [_position select 0, _position select 1, 500];
_group = createGroup east;
_HeliClassToUse = HeliClassToUse call BIS_fnc_selectRandom;
_HeliClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom;
_vehicle1 = [ [_spawnLocation], _group, "assault", "difficult", "bandit", _HeliClassToUse ] call DMS_fnc_SpawnAIVehicle;
diag_log format['[OCCUPATION:Sky] %1 spawned @ %2',_HeliClassToUse,_spawnLocation];
_vehicle1 setVehiclePosition [_spawnLocation, [], 0, "FLY"];
@ -48,14 +58,15 @@ for "_i" from 1 to _vehiclesToSpawn do
_vehicle1 setFuel 1;
_vehicle1 engineOn true;
_vehicle1 flyInHeight 150;
[_group, _spawnLocation, 2000] call bis_fnc_taskPatrol;
_group setBehaviour "AWARE";
_group setCombatMode "RED";
liveHelis = liveHelis + 1;
_vehicle1 addEventHandler ["killed", "liveHelis = liveHelis - 1;"];
SC_liveHelis = SC_liveHelis + 1;
_vehicle1 addEventHandler ["killed", "SC_liveHelis = SC_liveHelis - 1;"];
sleep 5;
};
diag_log format['[OCCUPATION:Sky] Running'];
diag_log format['[OCCUPATION:Sky] Running'];

View File

@ -1 +1,158 @@
// Placeholder
////////////////////////////////////////////////////////////////////////
//
// Server Occupation script by second_coming
//
// Version 2.0
//
// http://www.exilemod.com/profile/60-second_coming/
//
// This script uses the fantastic DMS by Defent and eraser1
//
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
private["_wp","_wp2","_wp3"];
if (!isServer) exitWith {};
diag_log format ["[OCCUPATION Static]:: Starting Monitor"];
_middle = worldSize/2;
_spawnCenter = [_middle,_middle,0]; // Centre point for the map
_maxDistance = _middle; // Max radius for the map
_maxAIcount = SC_maxAIcount;
_minFPS = SC_minFPS;
_debug = SC_debug;
_useLaunchers = DMS_ai_use_launchers;
_scaleAI = SC_scaleAI;
_statics = SC_statics; // details for the static spawns
_static = [];
_currentPlayerCount = count playableUnits;
if(_currentPlayerCount > _scaleAI) then
{
_maxAIcount = _maxAIcount - (_currentPlayerCount - _scaleAI) ;
};
// Don't spawn additional AI if the server fps is below 8
if(diag_fps < _minFPS) exitWith { diag_log format ["[OCCUPATION Static]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; };
_aiActive = count(_spawnCenter nearEntities ["O_recon_F", _maxDistance+1000]);
if(_aiActive > _maxAIcount) exitWith { diag_log format ["[OCCUPATION Static]:: %1 active AI, so not spawning AI this time",_aiActive]; };
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;
diag_log format ["[OCCUPATION Static]:: Adding %2 AI to static spawn @ %1",_spawnPosition,_aiCount];
_okToSpawn = true;
Sleep 0.1;
while{_okToSpawn} do
{
// Don't spawn additional AI if there are already AI in range
_aiNear = count(_spawnPosition nearEntities ["O_recon_F", 125]);
if(_aiNear > 0) exitwith { _okToSpawn = false; if(_debug) then { diag_log format ["[OCCUPATION Static]:: %1 already has %2 active AI patrolling",_spawnPosition,_aiNear];}; };
// Don't spawn additional AI if there are players in range
if([_spawnPosition, 1] call ExileClient_util_world_isAlivePlayerInRange) exitwith { _okToSpawn = false; if(_debug) then { diag_log format ["[OCCUPATION Static]:: %1 has players too close",_spawnPosition];}; };
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
{
_buildings = _spawnPosition nearObjects ["house", _groupRadius];
{
_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";
_wp setWaypointBehaviour "DESTROY";
_wp setWaypointCombatMode "RED";
_wp setWaypointCompletionRadius 1;
_wp waypointAttachObject _x;
_wp setwaypointHousePosition _i;
_wp setWaypointType "MOVE";
};
} foreach _buildings;
if(count _buildings > 0 ) then
{
_wp setWaypointType "CYCLE";
};
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diag_log format ["[OCCUPATION Static]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition];
if(SC_mapMarkers) then
{
_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;
};
};
};
diag_log "[OCCUPATION Static]: Ended";

View File

@ -5,9 +5,9 @@ diag_log format['[OCCUPATION:Vehicle] Started'];
if (!isServer) exitWith {};
if(liveVehicles >= maxNumberofVehicles) exitWith {};
if(SC_liveVehicles >= SC_maxNumberofVehicles) exitWith {};
_vehiclesToSpawn = (maxNumberofVehicles - liveVehicles);
_vehiclesToSpawn = (SC_maxNumberofVehicles - SC_liveVehicles);
_middle = worldSize/2;
_spawnCenter = [_middle,_middle,0];
_maxDistance = _middle;
@ -44,10 +44,10 @@ for "_j" from 1 to _vehiclesToSpawn do
_nearestRoad = position (_nearRoads select 0);
_group = createGroup east;
_VehicleClassToUse = VehicleClassToUse call BIS_fnc_selectRandom;
_VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom;
_vehicleObject = [ [_nearestRoad], _group, "assault", "difficult", "bandit",_VehicleClassToUse ] call DMS_fnc_SpawnAIVehicle;
diag_log format['[OCCUPATION:Vehicle] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation];
_vehicleObject addEventHandler ["killed", "liveVehicles = liveVehicles - 1;"];
_vehicleObject addEventHandler ["killed", "SC_liveVehicles = SC_liveVehicles - 1;"];
_vehicleObject setSpeedMode "Normal";
_vehicleObject limitSpeed 60;
_vehicleObject action ["LightOn", _vehicleObject];
@ -55,9 +55,9 @@ for "_j" from 1 to _vehiclesToSpawn do
_group setBehaviour "AWARE";
_group setCombatMode "RED";
liveVehicles = liveVehicles + 1;
SC_liveVehicles = SC_liveVehicles + 1;
sleep 5;
};
diag_log format['[OCCUPATION:Vehicle] Running'];
diag_log format['[OCCUPATION:Vehicle] Running'];

View File

@ -3,46 +3,48 @@ uiSleep 30;
diag_log format ["[OCCUPATION]:: Initialised at %1",time];
if(debug) then { refreshTime = 60; }else{ refreshTime = 300; };
if(SC_debug) then { SC_refreshTime = 60; }else{ SC_refreshTime = 300; };
// Add selected occupation scripts to Exile Threading System
if(occupySky) then
if(SC_occupyStatic) then
{
uiSleep 30; // delay the start
fnc_occupationSkyMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupationSky.sqf";
[refreshTime, fnc_occupationSkyMonitor, [], true] call ExileServer_system_thread_addTask;
};
if(occupyVehicle) then
{
uiSleep 30; // delay the start
fnc_occupationVehicleMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupationVehicle.sqf";
[refreshTime, fnc_occupationVehicleMonitor, [], true] call ExileServer_system_thread_addTask;
};
if(occupyStatic) then
{
uiSleep 30; // delay the start
uiSleep 15; // delay the start
fnc_occupationStaticMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupationStatic.sqf";
[refreshTime, fnc_occupationStaticMonitor, [], true] call ExileServer_system_thread_addTask;
[SC_refreshTime, fnc_occupationStaticMonitor, [], true] call ExileServer_system_thread_addTask;
};
if(occupyPlaces) then
if(SC_occupySky) then
{
uiSleep 30; // delay the start
uiSleep 15; // delay the start
fnc_occupationSkyMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupationSky.sqf";
[SC_refreshTime, fnc_occupationSkyMonitor, [], true] call ExileServer_system_thread_addTask;
};
if(SC_occupyVehicle) then
{
uiSleep 15; // delay the start
fnc_occupationVehicleMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupationVehicle.sqf";
[SC_refreshTime, fnc_occupationVehicleMonitor, [], true] call ExileServer_system_thread_addTask;
};
if(SC_occupyPlaces) then
{
uiSleep 15; // delay the start
fnc_occupationMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupation.sqf";
[refreshTime, fnc_occupationMonitor, [], true] call ExileServer_system_thread_addTask;
[SC_refreshTime, fnc_occupationMonitor, [], true] call ExileServer_system_thread_addTask;
};
if(occupyMilitary) then
if(SC_occupyMilitary) then
{
uiSleep 30; // delay the start
uiSleep 15; // delay the start
fnc_occupationMilitaryMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupationMilitary.sqf";
[refreshTime, fnc_occupationMilitaryMonitor, [], true] call ExileServer_system_thread_addTask;
[SC_refreshTime, fnc_occupationMilitaryMonitor, [], true] call ExileServer_system_thread_addTask;
};
diag_log format ["[OCCUPATION]:: threads added at %1",time];
diag_log format ["[OCCUPATION]:: threads added at %1",time];