diff --git a/config.cpp b/config.cpp index ab46e7b..35356f5 100644 --- a/config.cpp +++ b/config.cpp @@ -1,4 +1,5 @@ -class CfgPatches { +class CfgPatches +{ class a3_exile_occupation { units[] = {}; weapons[] = {}; @@ -6,6 +7,7 @@ class CfgPatches { author[]= {"second_coming"}; }; }; + class CfgFunctions { class yorkshire { class main { @@ -17,4 +19,3 @@ class CfgFunctions { }; }; }; - diff --git a/config.sqf b/config.sqf index 28b2494..04e258e 100644 --- a/config.sqf +++ b/config.sqf @@ -2,7 +2,6 @@ // // Server Occupation script by second_coming // -// Version 3 // // http://www.exilemod.com/profile/60-second_coming/ // @@ -16,10 +15,10 @@ SC_debug = false; // set to true to turn on debug features (not for live servers) SC_extendedLogging = true; // set to true for additional logging -SC_infiSTAR_log = true; // true Use infiSTAR logging, false logs to server rpt +SC_infiSTAR_log = false; // 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 -SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false +SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false SC_minFPS = 5; // any lower than minFPS on the server and additional AI won't spawn SC_scaleAI = 10; // any more than _scaleAI players on the server and _maxAIcount is reduced for each extra player @@ -27,70 +26,82 @@ SC_scaleAI = 10; // any more than _scaleAI players on the server an 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) + // Occupation Places (towns, villages & cities roaming AI) 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) + + // Occupation Military (roaming AI near military buildings) +SC_occupyMilitary = false; // 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", + "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","Land_Army_hut3_long_int", + "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_occupyVehicle = true; // true if you want to have roaming AI vehicles SC_occupySky = true; // true if you want to have roaming AI helis +SC_occupySea = false; // true if you want to have roaming AI boats + + + SC_occupyLootCrates = true; // true if you want to have random loot crates with guards -SC_numberofLootCrates = 6; // if SC_occupyLootCrates = true spawn this many loot crates (overrided for Namalsk in occupationLootCrates.sqf) +SC_numberofLootCrates = 6; // if SC_occupyLootCrates = true spawn this many loot crates (overrided below for Namalsk) +SC_LootCrateGuards = 4; // number of AI to spawn at each crate +SC_LootCrateGuardsRandomize = true; // Use a random number of guards up to a maximum = SC_numberofGuards (so between 1 and SC_numberofGuards) SC_occupyLootCratesMarkers = true; // true if you want to have markers on the loot crate spawns + + SC_occupyHeliCrashes = true; // true if you want to have Dayz style helicrashes +SC_numberofHeliCrashes = 5; // if SC_occupyHeliCrashes = true spawn this many loot crates (overrided below for Namalsk) + +SC_statics = [ [[1178,2524,0],8,250,true] ]; //[[pos],ai count,radius,search buildings] -SC_statics = [ [[1178,2524,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) -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", - "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", - "Land_Army_hut3_long_int", - "Land_Army_hut_int", - "Land_Army_hut2_int" - ]; // Settings for roaming ground vehicle AI -SC_maxNumberofVehicles = 3; -SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green","Exile_Car_UAZ_Open_Green","Exile_Car_Offroad_Guerilla03"]; - - +SC_maxNumberofVehicles = 4; +SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green","Exile_Bike_QuadBike_Black","Exile_Car_Octavius_White"]; // Settings for roaming airborne AI (non armed helis will just fly around) -SC_maxNumberofHelis = 1; -SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"]; - +SC_maxNumberofHelis = 1; +SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"]; - // namalsk specific settings +// Settings for roaming seaborne AI (non armed boats will just sail around) +SC_maxNumberofBoats = 1; +SC_BoatClassToUse = [ "B_Boat_Armed_01_minigun_F","I_Boat_Armed_01_minigun_F","O_Boat_Transport_01_F","Exile_Boat_MotorBoat_Police" ]; + +// AI Custom Loadouts + + // namalsk specific settings if (worldName == 'Namalsk') then { SC_maxAIcount = 80; SC_occupySky = false; + SC_maxNumberofVehicles = 2; + SC_numberofLootCrates = 3; + SC_numberofHeliCrashes = 2; + SC_maxNumberofBoats = 1; }; + + // Don't alter anything below this point SC_liveVehicles = 0; -publicVariable "SC_liveVehicles"; +SC_liveVehiclesArray = []; SC_liveHelis = 0; -publicVariable "SC_liveHelis"; -publicVariable "SC_numberofLootCrates"; \ No newline at end of file +SC_liveHelisArray = []; +SC_liveBoats = 0; +SC_liveBoatsArray = []; + +publicVariable "SC_liveVehicles"; +publicVariable "SC_liveVehiclesArray"; +publicVariable "SC_liveHelis"; +publicVariable "SC_liveHelisArray"; +publicVariable "SC_liveBoats"; +publicVariable "SC_liveBoatsArray"; +publicVariable "SC_numberofLootCrates"; \ No newline at end of file diff --git a/initServer.sqf b/initServer.sqf index 46d97de..5669593 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -// Version 3 +SC_occupationVersion = "v8 (09-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -20,22 +20,36 @@ // //////////////////////////////////////////////////////////////////////////////////////////// -SC_occupationVersion = "3.0"; +[] spawn +{ + waitUntil { !(isNil "DMS_MinMax_Y_Coords") }; -diag_log format ["[OCCUPATION MOD]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; + diag_log format ["[OCCUPATION MOD]:: Occupation %2 Loading Config at %1",time,SC_occupationVersion]; -// EventHandlers for AI reactions -SC_fnc_repairVehicle = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\repairVehicle.sqf"; -SC_fnc_reactUnit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\reactUnit.sqf"; -SC_fnc_driverKilled = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\driverKilled.sqf"; -SC_fnc_airHit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\airHit.sqf"; -SC_fnc_getIn = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\getIn.sqf"; + // Get the config for Occupation + call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.sqf"; -// Get the config for Occupation -call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.sqf"; + // Select the log style depending on config settings + SC_fnc_log = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationLog.sqf"; -// Select the log style depending on config settings -SC_fnc_log = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationLog.sqf"; + // EventHandlers for AI reactions + SC_fnc_repairVehicle = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\repairVehicle.sqf"; + SC_fnc_vehicleDestroyed = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\vehicleDestroyed.sqf"; + SC_fnc_reactUnit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\reactUnit.sqf"; + SC_fnc_driverKilled = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\driverKilled.sqf"; + SC_fnc_airHit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\airHit.sqf"; + SC_fnc_boatHit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\boatHit.sqf"; + SC_fnc_getIn = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\getIn.sqf"; + SC_fnc_refuel = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\refuel.sqf"; + SC_fnc_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\comeUnstuck.sqf"; -// Start Occupation -[] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; \ No newline at end of file + _logDetail = "============================================================================================================="; + [_logDetail] call SC_fnc_log; + _logDetail = format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; + [_logDetail] call SC_fnc_log; + _logDetail = "============================================================================================================="; + [_logDetail] call SC_fnc_log; + + // Start Occupation + [] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; +}; \ No newline at end of file diff --git a/scripts/occupationHeliCrashes.sqf b/scripts/occupationHeliCrashes.sqf index aa1351d..45d05ab 100644 --- a/scripts/occupationHeliCrashes.sqf +++ b/scripts/occupationHeliCrashes.sqf @@ -1,12 +1,5 @@ if (!isServer) exitWith {}; -_numberofCrashes = 5; // this is the number of helicrashes that you want to spawn - -if (worldName == 'Namalsk') then -{ - _numberofCrashes = 2; // lower number for a smaller map -}; - _displayMarkers = SC_debug; // only use for debug, no need for actual gameplay private['_position']; @@ -14,7 +7,10 @@ private['_position']; _logDetail = format ["[OCCUPATION:HeliCrashes]:: Initialised at %1",time]; [_logDetail] call SC_fnc_log; -for "_i" from 1 to _numberofCrashes do +_logDetail = format['[OCCUPATION:HeliCrashes]:: worldname: %1 crashes to spawn: %2',worldName,SC_numberofHeliCrashes]; +[_logDetail] call SC_fnc_log; + +for "_i" from 1 to SC_numberofHeliCrashes do { _validspot = false; while{!_validspot} do diff --git a/scripts/occupationLootCrates.sqf b/scripts/occupationLootCrates.sqf index 113d474..25ded79 100644 --- a/scripts/occupationLootCrates.sqf +++ b/scripts/occupationLootCrates.sqf @@ -3,11 +3,6 @@ if (!isServer) exitWith {}; _logDetail = format ["[OCCUPATION:LootCrates]:: Starting Occupation Loot Crates"]; [_logDetail] call SC_fnc_log; -if (worldName == 'Namalsk') then -{ - SC_numberofLootCrates = 3; // this is the number of crates that you want to spawn -}; - _logDetail = format['[OCCUPATION:LootCrates]:: worldname: %1 crates to spawn: %2',worldName,SC_numberofLootCrates]; [_logDetail] call SC_fnc_log; @@ -43,7 +38,13 @@ for "_i" from 1 to SC_numberofLootCrates do }; //Infantry spawn using DMS - _AICount = 1 + (round (random 2)); + _AICount = SC_LootCrateGuards; + + if(SC_LootCrateGuardsRandomize) then + { + _AICount = 1 + (round (random (SC_LootCrateGuards-1))); + }; + _spawnPosition = [_position select 0, _position select 1, 0]; _group = [_spawnPosition, _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup; @@ -55,8 +56,10 @@ for "_i" from 1 to SC_numberofLootCrates do _group setBehaviour "AWARE"; _group setCombatMode "RED"; - _logDetail = text format ["[OCCUPATION:LootCrates]:: Creating crate %3 @ drop zone %1 with %2 guards",_position,_AICount,_i]; - + _logDetail = format ["[OCCUPATION:LootCrates]:: Creating crate %3 at drop zone %1 with %2 guards",_position,_AICount,_i]; + [_logDetail] call SC_fnc_log; + + _box = "CargoNet_01_box_F" createvehicle _position; clearMagazineCargoGlobal _box; clearWeaponCargoGlobal _box; @@ -84,5 +87,4 @@ for "_i" from 1 to SC_numberofLootCrates do _box addItemCargoGlobal ["Exile_Item_WoodWindowKit", 1 + (random 1)]; _box addItemCargoGlobal ["Exile_Item_WoodDoorwayKit", 1 + (random 1)]; _box addItemCargoGlobal ["Exile_Item_WoodFloorPortKit", 1 + (random 2)]; -}; - +}; \ No newline at end of file diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index 152321c..3f94742 100644 --- a/scripts/occupationMilitary.sqf +++ b/scripts/occupationMilitary.sqf @@ -42,8 +42,9 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do _logDetail = format ["[OCCUPATION Military]:: scanning buildings around %2 started at %1",time,_areaToScan]; [_logDetail] call SC_fnc_log; - _building = _areaToScan nearObjects [_buildings select _i, 750]; - _currentBuilding = _buildings select _i; + _currentBuilding = _buildings select _i; + _building = _areaToScan nearObjects [_currentBuilding, 750]; + _logDetail = format ["[OCCUPATION Military]:: scan for %2 building finished at %1",time,_currentBuilding]; [_logDetail] call SC_fnc_log; @@ -145,28 +146,11 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do DMS_ai_use_launchers = true; [_group, _pos, _groupRadius] call bis_fnc_taskPatrol; - _group setBehaviour "SAD"; + _group setBehaviour "COMBAT"; _group setCombatMode "RED"; } else { - - _buildingPositions = [_foundBuilding, 5] 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; - }; - DMS_ai_use_launchers = false; _group = [_spawnPosition, _aiCount, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup; @@ -179,7 +163,8 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; if(count _buildingPositions > 0) then { - + _y = _x; + // Find Highest Point _highest = [0,0,0]; { @@ -194,12 +179,12 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do _i = _buildingPositions find _spawnPosition; _wp = _group addWaypoint [_spawnPosition, 0] ; _wp setWaypointFormation "Column"; - _wp setWaypointBehaviour "SAD"; + _wp setWaypointBehaviour "AWARE"; _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 1; - _wp waypointAttachObject _x; + _wp waypointAttachObject _y; _wp setwaypointHousePosition _i; - _wp setWaypointType "MOVE"; + _wp setWaypointType "SAD"; }; } foreach _buildings; diff --git a/scripts/occupationMonitor.sqf b/scripts/occupationMonitor.sqf new file mode 100644 index 0000000..f49d1f2 --- /dev/null +++ b/scripts/occupationMonitor.sqf @@ -0,0 +1,28 @@ +_logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; +[_logDetail] call SC_fnc_log; + +{ + _logDetail = format ["[OCCUPATION:Unstick]:: Air: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + sleep 5; +}forEach SC_liveHelisArray; + +{ + _logDetail = format ["[OCCUPATION:Unstick]:: Land: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; +}forEach SC_liveVehiclesArray; + +{ + _logDetail = format ["[OCCUPATION:Unstick]:: Sea: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; +}forEach SC_liveBoatsArray; + +_logDetail = format ["[OCCUPATION:Unstick]:: Finished at %1",time]; +[_logDetail] call SC_fnc_log; \ No newline at end of file diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index 8d88417..f89f322 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -15,7 +15,8 @@ private["_wp","_wp2","_wp3"]; if (!isServer) exitWith {}; -_logDetail = format ["[OCCUPATION]:: Starting Occupation Monitor"]; + +_logDetail = format ["[OCCUPATION]:: Starting Occupation Monitor @ %1",time]; [_logDetail] call SC_fnc_log; _middle = worldSize/2; @@ -37,15 +38,21 @@ if(_currentPlayerCount > _scaleAI) then // Don't spawn additional AI if the server fps is below _minFPS if(diag_fps < _minFPS) exitWith { - _logDetail = format ["[OCCUPATION]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; - [_logDetail] call SC_fnc_log; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Places]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; + [_logDetail] call SC_fnc_log; + }; }; -_aiActive = count(_spawnCenter nearEntities ["O_recon_F", 20000]); +_aiActive = {alive _x && side _x == EAST} count allUnits; if(_aiActive > _maxAIcount) exitWith { - _logDetail = format ["[OCCUPATION]:: %1 active AI, so not spawning AI this time",_aiActive]; - [_logDetail] call SC_fnc_log; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Places]:: %1 active AI, so not spawning AI this time",_aiActive]; + [_logDetail] call SC_fnc_log; + }; }; _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCityCapital"], _maxDistance]); @@ -58,7 +65,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: Testing location name: %1 position: %2",_locationName,_pos]; + _logDetail = format ["[OCCUPATION:Places]:: Testing location name: %1 position: %2",_locationName,_pos]; [_logDetail] call SC_fnc_log; }; @@ -71,7 +78,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: Rolled %1 so not spawning AI this time",_spawnChance,_locationName]; + _logDetail = format ["[OCCUPATION:Places]:: Rolled %1 so not spawning AI this time",_spawnChance,_locationName]; [_logDetail] call SC_fnc_log; }; }; @@ -83,7 +90,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 is too close to player base",_locationName]; + _logDetail = format ["[OCCUPATION:Places]:: %1 is too close to player base",_locationName]; [_logDetail] call SC_fnc_log; }; }; @@ -96,7 +103,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 is too close to a %2",_locationName,_nearestMarker]; + _logDetail = format ["[OCCUPATION:Places]:: %1 is too close to a %2",_locationName,_nearestMarker]; [_logDetail] call SC_fnc_log; }; }; @@ -107,7 +114,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 has players too close",_locationName]; + _logDetail = format ["[OCCUPATION:Places]:: %1 has players too close",_locationName]; [_logDetail] call SC_fnc_log; }; }; @@ -119,7 +126,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 already has %2 active AI patrolling",_locationName,_aiNear]; + _logDetail = format ["[OCCUPATION:Places]:: %1 already has %2 active AI patrolling",_locationName,_aiNear]; [_logDetail] call SC_fnc_log; }; }; @@ -131,9 +138,9 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// _aiCount = 1; _groupRadius = 100; - if(_locationType isEqualTo "NameCityCapital") then { _aiCount = 5; _groupRadius = 300; }; - if(_locationType isEqualTo "NameCity") then { _aiCount = 2 + (round (random 3)); _groupRadius = 200; }; - if(_locationType isEqualTo "NameVillage") then { _aiCount = 1 + (round (random 2)); _groupRadius = 100; }; + if(_locationType isEqualTo "NameCityCapital") then { _aiCount = 5; _groupRadius = 300; }; + if(_locationType isEqualTo "NameCity") then { _aiCount = 2 + (round (random 3)); _groupRadius = 200; }; + if(_locationType isEqualTo "NameVillage") then { _aiCount = 1 + (round (random 2)); _groupRadius = 100; }; if(_aiCount < 1) then { _aiCount = 1; }; _difficulty = "random"; @@ -161,10 +168,13 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _buildings = _pos nearObjects ["building", _groupRadius]; { - _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; - if(count _buildingPositions > 0) then + _isEnterable = [_x] call BIS_fnc_isBuildingEnterable; + + if(_isEnterable) then { - + _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; + _y = _x; + // Find Highest Point _highest = [0,0,0]; { @@ -174,15 +184,14 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi }; } foreach _buildingPositions; - _spawnPosition = _highest; + _wpPosition = _highest; - _i = _buildingPositions find _spawnPosition; - _wp = _group addWaypoint [_spawnPosition, 0] ; - _wp setWaypointFormation "Column"; + _i = _buildingPositions find _wpPosition; + _wp = _group addWaypoint [_wpPosition, 0] ; _wp setWaypointBehaviour "COMBAT"; _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 1; - _wp waypointAttachObject _x; + _wp waypointAttachObject _y; _wp setwaypointHousePosition _i; _wp setWaypointType "SAD"; @@ -204,7 +213,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi enableSentences false; enableRadio false; [_group2, _pos, _groupRadius] call bis_fnc_taskPatrol; - _group2 setBehaviour "DESTROY"; + _group2 setBehaviour "AWARE"; _group2 setCombatMode "RED"; }; @@ -222,7 +231,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _marker setMarkerText "Occupied Area"; }; - _logDetail = format ["[OCCUPATION]:: Spawning %2 AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition]; + _logDetail = format ["[OCCUPATION:Places]:: Spawning %2 AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition]; [_logDetail] call SC_fnc_log; _okToSpawn = false; }; diff --git a/scripts/occupationSea.sqf b/scripts/occupationSea.sqf new file mode 100644 index 0000000..49b18e6 --- /dev/null +++ b/scripts/occupationSea.sqf @@ -0,0 +1,181 @@ +_logDetail = format['[OCCUPATION:Sea] Started']; +[_logDetail] call SC_fnc_log; + +if (!isServer) exitWith {}; + +// more than _scaleAI players on the server and the max AI count drops per additional player +_currentPlayerCount = count playableUnits; +_maxAIcount = SC_maxAIcount; + +if(_currentPlayerCount > SC_scaleAI) then +{ + _maxAIcount = _maxAIcount - (_currentPlayerCount - SC_scaleAI) ; +}; + +// Don't spawn additional AI if the server fps is below _minFPS +if(diag_fps < SC_minFPS) exitWith +{ + _logDetail = format ["[OCCUPATION:Sea]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; + [_logDetail] call SC_fnc_log; +}; + +_aiActive = {alive _x && side _x == EAST} count allUnits; +if(_aiActive > _maxAIcount) exitWith +{ + _logDetail = format ["[OCCUPATION:Sea]:: %1 active AI, so not spawning AI this time",_aiActive]; + [_logDetail] call SC_fnc_log; +}; + +if(SC_liveBoats >= SC_maxNumberofBoats) exitWith +{ + if(SC_extendedLogging) then + { + _logDetail = format['[OCCUPATION:Sea] End check %1 currently active (max %2) @ %3',SC_liveBoats,SC_maxNumberofBoats,time]; + [_logDetail] call SC_fnc_log; + }; +}; + +_vehiclesToSpawn = (SC_maxNumberofBoats - SC_liveBoats); +_middle = worldSize/2; +_spawnCenter = [_middle,_middle,0]; +_maxDistance = _middle; + +for "_i" from 1 to _vehiclesToSpawn do +{ + private["_group"]; + _spawnLocation = [ 250, 0, 1, 1000, 1000, 1000, 1000, 1000, true, true ] call DMS_fnc_findSafePos; + _group = createGroup east; + _VehicleClassToUse = SC_BoatClassToUse call BIS_fnc_selectRandom; + _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; + _vehicle setPosASL _spawnLocation; + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; + + // Remove the overpowered weapons from boats + _vehicle removeWeaponTurret ["HMG_01",[0]]; + _vehicle removeWeaponTurret ["GMG_40mm",[0]]; + + SC_liveBoats = SC_liveBoats + 1; + SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle]; + + _vehicle setVehiclePosition [_spawnLocation, [], 0, "NONE"]; + _vehicle setVariable ["vehicleID", _spawnLocation, true]; + _vehicle setFuel 1; + _vehicle setDamage 0; + _vehicle engineOn true; + _vehicle lock 0; + _vehicle setVehicleLock "UNLOCKED"; + _vehicle setVariable ["ExileIsLocked", 0, true]; + _vehicle action ["LightOn", _vehicle]; + sleep 0.2; + _group addVehicle _vehicle; + + + // Calculate the crew requried + _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; + { + _unitPlaced = false; + _vehicleRole = _x select 0; + _vehicleSeat = _x select 1; + if(_vehicleRole == "Driver") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit assignAsDriver _vehicle; + _unit moveInDriver _vehicle; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unitPlaced = true; + }; + if(_vehicleRole == "Turret") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit moveInTurret [_vehicle, _vehicleSeat]; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unitPlaced = true; + }; + if(_vehicleRole == "CARGO") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit assignAsCargo _vehicle; + _unit moveInCargo _vehicle; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unitPlaced = true; + }; + if(SC_extendedLogging && _unitPlaced) then + { + _logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle]; + [_logDetail] call SC_fnc_log; + }; + } forEach _vehicleRoles; + + + if(SC_infiSTAR_log) then + { + _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; + [_logDetail] call SC_fnc_log; + }; + + + clearMagazineCargoGlobal _vehicle; + clearWeaponCargoGlobal _vehicle; + clearItemCargoGlobal _vehicle; + + _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; + _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; + _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; + + // Add weapons with ammo to the vehicle + _possibleWeapons = + [ + "arifle_MXM_Black_F", + "arifle_MXM_F", + "srifle_DMR_01_F", + "srifle_DMR_02_camo_F", + "srifle_DMR_02_F", + "srifle_DMR_02_sniper_F", + "srifle_DMR_03_F", + "srifle_DMR_03_khaki_F", + "srifle_DMR_03_multicam_F", + "srifle_DMR_03_tan_F", + "srifle_DMR_03_woodland_F", + "srifle_DMR_04_F", + "srifle_DMR_04_Tan_F", + "srifle_DMR_05_blk_F", + "srifle_DMR_05_hex_F", + "srifle_DMR_05_tan_f", + "srifle_DMR_06_camo_F", + "srifle_DMR_06_olive_F", + "srifle_EBR_F", + "srifle_GM6_camo_F", + "srifle_GM6_F", + "srifle_LRR_camo_F", + "srifle_LRR_F" + ]; + _amountOfWeapons = 1 + (random 3); + + for "_i" from 1 to _amountOfWeapons do + { + _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; + _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; + + _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); + _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + }; + + + [_group, _spawnLocation, 4000] call bis_fnc_taskPatrol; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + _vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; + _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_boatHit;"]; + _vehicle setVariable ["SC_crewEjected", false,true]; + sleep 0.2; + +}; + + +_logDetail = format['[OCCUPATION:Sea] Running']; +[_logDetail] call SC_fnc_log; \ No newline at end of file diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index 593ffc5..1f51e1a 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -3,14 +3,36 @@ _logDetail = format['[OCCUPATION:Sky] Started']; if (!isServer) exitWith {}; +// more than _scaleAI players on the server and the max AI count drops per additional player +_currentPlayerCount = count playableUnits; +_maxAIcount = SC_maxAIcount; + +if(_currentPlayerCount > SC_scaleAI) then +{ + _maxAIcount = _maxAIcount - (_currentPlayerCount - SC_scaleAI) ; +}; + +// Don't spawn additional AI if the server fps is below _minFPS +if(diag_fps < SC_minFPS) exitWith +{ + _logDetail = format ["[OCCUPATION:Sky]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; + [_logDetail] call SC_fnc_log; +}; + +_aiActive = {alive _x && side _x == EAST} count allUnits; +if(_aiActive > _maxAIcount) exitWith +{ + _logDetail = format ["[OCCUPATION:Sky]:: %1 active AI, so not spawning AI this time",_aiActive]; + [_logDetail] call SC_fnc_log; +}; + if(SC_liveHelis >= SC_maxNumberofHelis) exitWith { if(SC_extendedLogging) then { _logDetail = format['[OCCUPATION:Sky] End check %1 currently active (max %2) @ %3',SC_liveHelis,SC_maxNumberofHelis,time]; [_logDetail] call SC_fnc_log; - }; - + }; }; _vehiclesToSpawn = (SC_maxNumberofHelis - SC_liveHelis); @@ -42,39 +64,91 @@ for "_i" from 1 to _vehiclesToSpawn do _Location = _locations call BIS_fnc_selectRandom; _pos = position _Location; _position = [_pos select 0, _pos select 1, 300]; - _spawnLocation = [_position,10,100,5,0,20,0] call BIS_fnc_findSafePos; - _height = 250 + (round (random 200)); - _helispawnLocation = [_spawnLocation select 0, _spawnLocation select 1, _height]; + _safePos = [_position,10,100,5,0,20,0] call BIS_fnc_findSafePos; + _height = 350 + (round (random 200)); + _spawnLocation = [_safePos select 0, _safePos select 1, _height]; - _group = createGroup east; - _HeliClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom; - _vehicle1 = [ [_helispawnLocation], _group, "assault", "difficult", "bandit", _HeliClassToUse ] call DMS_fnc_SpawnAIVehicle; - SC_liveHelis = SC_liveHelis + 1; - _vehicle1 setVehicleLock "UNLOCKED"; - _vehicle1 setVariable ["ExileIsLocked", 0, true]; + _group = createGroup east; + _VehicleClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom; + _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; + _group addVehicle _vehicle; + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; + + SC_liveHelis = SC_liveHelis + 1; + SC_liveHelisArray = SC_liveHelisArray + [_vehicle]; + + _vehicle setVehiclePosition [_spawnLocation, [], 0, "FLY"]; + _vehicle setVariable ["vehicleID", _spawnLocation, true]; + _vehicle setFuel 1; + _vehicle setDamage 0; + _vehicle engineOn true; + _vehicle flyInHeight 150; + _vehicle lock 0; + _vehicle setVehicleLock "UNLOCKED"; + _vehicle setVariable ["ExileIsLocked", 0, true]; + _vehicle action ["LightOn", _vehicle]; + + + + // Calculate the crew requried + _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; + { + _vehicleRole = _x select 0; + _vehicleSeat = _x select 1; + if(_vehicleRole == "Driver") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit assignAsDriver _vehicle; + _unit moveInDriver _vehicle; + _vehicle lockDriver true; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + }; + if(_vehicleRole == "Turret") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit moveInTurret [_vehicle, _vehicleSeat]; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + }; + if(_vehicleRole == "CARGO") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit assignAsCargo _vehicle; + _unit moveInCargo _vehicle; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + }; + if(SC_extendedLogging) then + { + _logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle]; + [_logDetail] call SC_fnc_log; + }; + } forEach _vehicleRoles; + + if(SC_infiSTAR_log) then { - _logDetail = format['[OCCUPATION:Sky] %1 spawned @ %2',_HeliClassToUse,_spawnLocation]; + _logDetail = format['[OCCUPATION:Sky] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; [_logDetail] call SC_fnc_log; }; - _vehicle1 setVehiclePosition [_spawnLocation, [], 0, "FLY"]; - _vehicle1 setVariable ["vehicleID", _spawnLocation, true]; - _vehicle1 setFuel 1; - _vehicle1 setDamage 0; - _vehicle1 engineOn true; - _vehicle1 flyInHeight 150; - sleep 0.2; + - clearMagazineCargoGlobal _vehicle1; - clearWeaponCargoGlobal _vehicle1; - clearItemCargoGlobal _vehicle1; + clearMagazineCargoGlobal _vehicle; + clearWeaponCargoGlobal _vehicle; + clearItemCargoGlobal _vehicle; - _vehicle1 addMagazineCargoGlobal ["HandGrenade", (random 2)]; - _vehicle1 addItemCargoGlobal ["ItemGPS", (random 1)]; - _vehicle1 addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; - _vehicle1 addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; - _vehicle1 addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; + _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; + _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; + _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; // Add weapons with ammo to the vehicle _possibleWeapons = @@ -108,20 +182,20 @@ for "_i" from 1 to _vehiclesToSpawn do for "_i" from 1 to _amountOfWeapons do { _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; - _vehicle1 addWeaponCargoGlobal [_weaponToAdd,1]; + _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); - _vehicle1 addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; }; [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; - _group setBehaviour "CARELESS"; + _group setBehaviour "AWARE"; _group setCombatMode "RED"; - _vehicle1 addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; - _vehicle1 addMPEventHandler ["mpkilled", "SC_liveHelis = SC_liveHelis - 1;"]; - _vehicle1 addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; - _vehicle1 setVariable ["SC_crewEjected", false,true]; + _vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; + _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; + _vehicle setVariable ["SC_crewEjected", false,true]; sleep 0.2; }; diff --git a/scripts/occupationStatic.sqf b/scripts/occupationStatic.sqf index 66da71d..dbbb19e 100644 --- a/scripts/occupationStatic.sqf +++ b/scripts/occupationStatic.sqf @@ -45,9 +45,8 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do _aiCount = _currentStatic select 1; _radius = _currentStatic select 2; _staticSearch = _currentStatic select 3; - _underground = _currentStatic select 4; - _logDetail = format ["[OCCUPATION Static]:: Adding %2 AI to static spawn @ %1",_spawnPosition,_aiCount]; + _logDetail = format ["[OCCUPATION Static]:: Checking static spawn @ %1",_spawnPosition,_aiCount]; [_logDetail] call SC_fnc_log; _okToSpawn = true; @@ -57,7 +56,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do { // Don't spawn additional AI if there are already AI in range - _aiNear = count(_spawnPosition nearEntities ["O_recon_F", 125]); + _aiNear = count(_spawnPosition nearEntities ["O_recon_F", 250]); if(_aiNear > 0) exitwith { _okToSpawn = false; @@ -89,7 +88,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do _side = "bandit"; DMS_ai_use_launchers = false; - _group = [_spawnPosition, _aiCount, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup; + _group = [_spawnPosition, _aiCount, _difficulty, "assault", _side] call DMS_fnc_SpawnAIGroup; [ _group,_spawnPosition,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior; DMS_ai_use_launchers = true; @@ -107,51 +106,47 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do } else { - - _buildings = _spawnPosition nearObjects ["building", _groupRadius]; { - _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; - if(count _buildingPositions > 0) then + _isEnterable = [_x] call BIS_fnc_isBuildingEnterable; + + if(_isEnterable) then { - + _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; + _y = _x; // Find Highest Point _highest = [0,0,0]; { - if(_x select 2 > _highest select 2) then + 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 "COMBAT"; + _wpPosition = _highest; + //diag_log format ["Static Patrol %3 waypoint added - building: %1 position: %2",_y,_highest,_group]; + _i = _buildingPositions find _wpPosition; + _wp = _group addWaypoint [_wpPosition, 0] ; + _wp setWaypointBehaviour "AWARE"; _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 1; - _wp waypointAttachObject _x; + _wp waypointAttachObject _y; _wp setwaypointHousePosition _i; _wp setWaypointType "SAD"; }; } foreach _buildings; - if(count _buildings > 0 ) then + if(count _buildings > 0 && !isNil "_wp") then { _wp setWaypointType "CYCLE"; }; - }; - - - - + }; + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// _logDetail = format ["[OCCUPATION Static]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition]; [_logDetail] call SC_fnc_log; - if(SC_mapMarkers) then + if(SC_mapMarkers && !isNil "_foundBuilding") then { _marker = createMarker [format ["%1", _foundBuilding],_spawnPosition]; _marker setMarkerShape "Icon"; diff --git a/scripts/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index 5d0b0f4..a9a907c 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -3,6 +3,30 @@ if (!isServer) exitWith {}; _logDetail = format['[OCCUPATION:Vehicle] Started']; [_logDetail] call SC_fnc_log; + +// more than _scaleAI players on the server and the max AI count drops per additional player +_currentPlayerCount = count playableUnits; +_maxAIcount = SC_maxAIcount; + +if(_currentPlayerCount > SC_scaleAI) then +{ + _maxAIcount = _maxAIcount - (_currentPlayerCount - SC_scaleAI) ; +}; + +// Don't spawn additional AI if the server fps is below _minFPS +if(diag_fps < SC_minFPS) exitWith +{ + _logDetail = format ["[OCCUPATION:Vehicle]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; + [_logDetail] call SC_fnc_log; +}; + +_aiActive = {alive _x && side _x == EAST} count allUnits; +if(_aiActive > _maxAIcount) exitWith +{ + _logDetail = format ["[OCCUPATION:Vehicle]:: %1 active AI, so not spawning AI this time",_aiActive]; + [_logDetail] call SC_fnc_log; +}; + if(SC_liveVehicles >= SC_maxNumberofVehicles) exitWith { if(SC_extendedLogging) then @@ -59,7 +83,7 @@ if(_vehiclesToSpawn >= 1) then private["_group"]; _Location = _locations call BIS_fnc_selectRandom; _position = position _Location; - _pos = [_position,10,100,5,0,20,0] call BIS_fnc_findSafePos; + _pos = [_position,10,250,5,0,20,0] call BIS_fnc_findSafePos; // Get position of nearest roads @@ -69,9 +93,16 @@ if(_vehiclesToSpawn >= 1) then _spawnLocation = [_nearestRoad select 0, _pos select 1, 0]; _group = createGroup east; - SC_liveVehicles = SC_liveVehicles + 1; _VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom; _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; + _group addVehicle _vehicle; + + SC_liveVehicles = SC_liveVehicles + 1; + SC_liveVehiclesArray = SC_liveVehiclesArray + [_vehicle]; + + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; _vehicle setFuel 1; _vehicle engineOn true; _vehicle lock 0; @@ -81,40 +112,60 @@ if(_vehiclesToSpawn >= 1) then _vehicle limitSpeed 60; _vehicle action ["LightOn", _vehicle]; - _vehicle addEventHandler ["getin", "_this call SC_fnc_getIn;"]; - _vehicle addMPEventHandler ["mpkilled", "SC_liveVehicles = SC_liveVehicles - 1;"]; - _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; - _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - - _group addVehicle _vehicle; - _driver = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; - if(SC_debug) then - { - _tag = createVehicle ["Sign_Arrow_Green_F", position _driver, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_driver,[0,0,0.6],"Head"]; - }; - sleep 1; - _driver setVariable ["DMS_AssignedVeh",_vehicle]; - _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; - _driver setVariable ["SC_drivenVehicle", _vehicle,true]; - _vehicle setVariable ["SC_assignedDriver", _driver,true]; - _driver action ["movetodriver", _vehicle]; - _driver assignAsDriver _vehicle; - sleep 0.2; - _crewCount = - { - private _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; - _unit moveInTurret [_vehicle, _x]; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - _unit assignAsCargo _vehicle; - sleep 0.2; - true - } count (allTurrets [_vehicle, true]); - _group setBehaviour "CARELESS"; - _group setCombatMode "BLUE"; - sleep 10; - + // Calculate the crew requried + _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; + { + _unitPlaced = false; + _vehicleRole = _x select 0; + _vehicleSeat = _x select 1; + if(_vehicleRole == "Driver") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit disableAI "TARGET"; + _unit disableAI "AUTOTARGET"; + _unit disableAI "AUTOCOMBAT"; + _unit disableAI "COVER"; + _unit disableAI "SUPPRESSION"; + sleep 0.1; + if(SC_debug) then + { + _tag = createVehicle ["Sign_Arrow_Green_F", position _unit, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_unit,[0,0,0.6],"Head"]; + }; + sleep 0.1; + _unit assignAsDriver _vehicle; + _unit moveInDriver _vehicle; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unit setVariable ["SC_drivenVehicle", _vehicle,true]; + _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; + _vehicle setVariable ["SC_assignedDriver", _unit,true]; + _vehicle addEventHandler ["getin", "_this call SC_fnc_getIn;"]; + _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; + }; + if(_vehicleRole == "Turret") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit moveInTurret [_vehicle, _vehicleSeat]; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unitPlaced = true; + }; + if(_vehicleRole == "CARGO") then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit assignAsCargo _vehicle; + _unit moveInCargo _vehicle; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unitPlaced = true; + }; + if(SC_extendedLogging && _unitPlaced) then + { + _logDetail = format['[OCCUPATION:Vehicle] %1 added to vehicle %2',_vehicleRole,_vehicle]; + [_logDetail] call SC_fnc_log; + }; + } forEach _vehicleRoles; + // Get the AI to shut the fuck up :) enableSentences false; diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index e1994cd..d4321fb 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -24,7 +24,12 @@ _damagedEssentials = 0; { if ((_heli getHitPointDamage _x) > 0) then { - _damage = _heli getHitPointDamage _x; + if(_x == "HitFuel" && _heliDamage < 1) then + { + _heli setHitPointDamage ["HitFuel", 0]; + _heli setFuel 1; + }; + _damage = _heli getHitPointDamage _x; if(SC_extendedLogging) then { _logDetail = format ["[OCCUPATION:Sky]:: Heli %1 checking part %2 (damage: %4) @ %3",_heli, _x, time,_damage]; @@ -35,70 +40,78 @@ _damagedEssentials = 0; } forEach _essentials; -if(_damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then +if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 100) then { - - [_heli ] spawn + _target = _this select 1; + [_heli, _target] spawn { _veh = _this select 0; - { - if(SC_extendedLogging) then - { - _heliPosition = getPosATL _veh; - _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 ejecting passengers at %3 (time: %1)",time,_this select 0,_this select 1,_heliPosition]; - [_logDetail] call SC_fnc_log; - }; - _unit = _x select 0; - if (isNull driver _veh) then - { - _unit action ["EJECT", _veh]; - }; - } forEach (fullCrew _veh); + _group2 = createGroup east; + if(SC_extendedLogging) then + { + _heliPosition = getPosATL _veh; + _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 ejecting passengers at %3 (time: %1)",time,_veh,_heliPosition]; + [_logDetail] call SC_fnc_log; + }; + { + _unit = _x; + _unit joinSilent _group2; + _unit action ["EJECT", _veh]; + } forEach (assignedCargo _veh); + + _target = _this select 1; + _group2 reveal [_target,1.5]; + _destination = getPos _target; + _group2 allowFleeing 0; + _wp = _group2 addWaypoint [_destination, 0] ; + _wp setWaypointFormation "Column"; + _wp setWaypointBehaviour "COMBAT"; + _wp setWaypointCombatMode "RED"; + _wp setWaypointCompletionRadius 1; + _wp setWaypointType "SAD"; + + [_group2, _destination, 500] call bis_fnc_taskPatrol; + _group2 allowFleeing 0; + _group2 setBehaviour "AWARE"; + _group2 setCombatMode "RED"; }; _heli setVariable ["SC_crewEjected", true,true]; - _target = _this select 1; - _pilot = driver _heli; - _group = group _heli; - _group reveal [_target,1.5]; - - _destination = getPos _target; - [_group, _destination, 250] call bis_fnc_taskPatrol; - _group allowFleeing 0; - _group setBehaviour "AWARE"; - _group setSpeedMode "FULL"; - _group setCombatMode "RED"; _heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; }; -if(_heliDamage > 0.5 && _damagedEssentials > 0) then +if(_heliDamage > 0.7 && _damagedEssentials > 0) then { if(SC_extendedLogging) then { _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 damaged and force landing at %3 (time: %1)",time,_this select 0,_this select 1,_heliPosition]; [_logDetail] call SC_fnc_log; }; - _heli removeAllMPEventHandlers "mphit"; - _heli removeAllMPEventHandlers "mpkilled"; + + [_heli] call SC_fnc_vehicleDestroyed; _currentHeliPos = getPos _heli; _destination = [_currentHeliPos, 1, 150, 10, 0, 20, 0] call BIS_fnc_findSafePos; - SC_liveHelis = SC_liveHelis - 1; - _heli land "LAND"; _heli setVehicleLock "UNLOCKED"; _target = _this select 1; - _pilot = driver _heli; _group = group _heli; - _group reveal [_target,1.5]; + _group reveal [_target,2.5]; + _destination = position _target; - _group allowFleeing 0; - _wp = _group addWaypoint [_destination, 0] ; - _wp setWaypointFormation "Column"; + _heli land "LAND"; + _group2 = createGroup east; + { + _x join _group2; + } forEach (fullCrew _heli); + + _group2 allowFleeing 0; + _wp = _group2 addWaypoint [_destination, 0] ; _wp setWaypointBehaviour "COMBAT"; _wp setWaypointCombatMode "RED"; - _wp setWaypointCompletionRadius 1; - _wp setWaypointType "SAD"; - [_group, _destination, 250] call bis_fnc_taskPatrol; - _group setBehaviour "COMBAT"; - _group setCombatMode "RED"; + _wp setWaypointCompletionRadius 10; + _wp setWaypointType "GETOUT"; + + [_group2, _destination, 250] call bis_fnc_taskPatrol; + _group2 setBehaviour "COMBAT"; + _group2 setCombatMode "RED"; }; \ No newline at end of file diff --git a/scripts/reactions/boatHit.sqf b/scripts/reactions/boatHit.sqf new file mode 100644 index 0000000..c373aa4 --- /dev/null +++ b/scripts/reactions/boatHit.sqf @@ -0,0 +1,123 @@ +_boat = _this select 0; +_boat removeAllMPEventHandlers "mphit"; +_boatDamage = getDammage _boat; +_boatPosition = getPosASL _boat; +_boatHeight = getPosASL _boat select 2; +_crewEjected = _boat getVariable "SC_crewEjected"; + +_damageLimit = 0.2; +_engineDamage = false; +_fueltankDamage = false; + +if(SC_extendedLogging) then +{ + _logDetail = format ["[OCCUPATION:Sea]:: Sea unit %2 hit by %3 at %1 (damage: %4)",time,_this select 0,_this select 1,_boatDamage]; + [_logDetail] call SC_fnc_log; +}; +_ejectChance = round (random 100) + (_boatDamage * 100); + + +_essentials = [ "HitAvionics","HitEngine1","HitEngine2","HitEngine","HitHRotor","HitVRotor","HitTransmission", + "HitHydraulics","HitGear","HitHStabilizerL1","HitHStabilizerR1","HitVStabilizer1","HitFuel"]; + +_damagedEssentials = 0; +{ + if ((_boat getHitPointDamage _x) > 0) then + { + if(_x == "HitFuel") then + { + _boat setHitPointDamage ["HitFuel", 0]; + _boat setFuel 1; + }; + _damage = _boat getHitPointDamage _x; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Sea]:: Boat %1 checking part %2 (damage: %4) @ %3",_boat, _x, time,_damage]; + [_logDetail] call SC_fnc_log; + }; + if(_damage > 0) then { _damagedEssentials = _damagedEssentials + 1; }; + }; +} forEach _essentials; + + +if(_boatDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then +{ + + [_boat ] spawn + { + _veh = _this select 0; + if(SC_extendedLogging) then + { + _boatPosition = getPosATL _veh; + _logDetail = format ["[OCCUPATION:Sea]:: Sea unit %2 ejecting passengers at %3 (time: %1)",time,_veh,_boatPosition]; + [_logDetail] call SC_fnc_log; + }; + { + + _unit = _x select 0; + + if (!(_unit == gunner _veh) && !(_unit == driver _veh)) then + { + _unit action ["EJECT", _veh]; + }; + } forEach (fullCrew _veh); + + }; + _boat setVariable ["SC_crewEjected", true,true]; + _target = _this select 1; + _pilot = driver _boat; + _group = group _boat; + _group reveal [_target,1.5]; + + _destination = getPos _target; + _group allowFleeing 0; + _wp = _group addWaypoint [_destination, 0] ; + _wp setWaypointFormation "Column"; + _wp setWaypointBehaviour "COMBAT"; + _wp setWaypointCombatMode "RED"; + _wp setWaypointCompletionRadius 1; + _wp setWaypointType "SAD"; + + + [_group, _destination, 250] call bis_fnc_taskPatrol; + _group allowFleeing 0; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + _boat addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; +}; + + +if(_boatDamage > 0.7 && _damagedEssentials > 0) then +{ + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 damaged and force landing at %3 (time: %1)",time,_this select 0,_this select 1,_boatPosition]; + [_logDetail] call SC_fnc_log; + }; + + [_boat] call SC_fnc_vehicleDestroyed; + _currentHeliPos = getPos _boat; + _destination = [_currentHeliPos, 1, 150, 10, 0, 20, 0] call BIS_fnc_findSafePos; + _boat setVehicleLock "UNLOCKED"; + _target = _this select 1; + _group = group _boat; + _group reveal [_target,2.5]; + _destination = position _target; + + _boat land "LAND"; + _group2 = createGroup east; + { + _x join _group2; + } forEach (fullCrew _boat); + + _group2 allowFleeing 0; + _wp = _group2 addWaypoint [_destination, 0] ; + _wp setWaypointBehaviour "COMBAT"; + _wp setWaypointCombatMode "RED"; + _wp setWaypointCompletionRadius 10; + _wp setWaypointType "GETOUT"; + + [_group2, _destination, 250] call bis_fnc_taskPatrol; + _group2 setBehaviour "COMBAT"; + _group2 setCombatMode "RED"; +}; \ No newline at end of file diff --git a/scripts/reactions/comeUnstuck.sqf b/scripts/reactions/comeUnstuck.sqf new file mode 100644 index 0000000..a2e6e5e --- /dev/null +++ b/scripts/reactions/comeUnstuck.sqf @@ -0,0 +1,78 @@ +// Unstuck based on a function written by Chris (infiSTAR) +// http://pastebin.com/73pjvXPw + + +private["_vehicle","_curPos","_oldvehPos","_engineTime","_newPos"]; +_vehicle = _this select 0; + +if(isNil "_vehicle") exitWith{}; + +if(count(crew _vehicle) > 0)then +{ + _curPos = position _vehicle; + _newPos = _curPos; + _oldvehPos = _vehicle getVariable["vehPos",[0,0,0]]; + if(isNil "_oldvehPos") then { _oldvehPos = [0,0,0]; }; + if(str _oldvehPos != "[0,0,0]")then + { + if(_curPos distance _oldvehPos < 2)then + { + _engineTime = _vehicle getVariable["engineTime",-1]; + if(_engineTime < 0)then + { + _vehicle setVariable["engineTime",time]; + }; + if(time - _engineTime > 10)then + { + + _logDetail = format ["[OCCUPATION:Unstuck]:: %1 is stuck,attempting to unstick from %2 @ %3",_vehicle,_curPos,time]; + [_logDetail] call SC_fnc_log; + + _vehicle setVariable["engineTime",-1]; + + _vehicle setVectorUp [0,0,1]; + + _originalSpawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; + _group = group _vehicle; + //_vehClass = _vehicle getVariable "vehClass"; + _vehClass = typeOf _vehicle; + + if(_vehicle isKindOf "LandVehicle") then + { + //_newPos = [ _curPos, 1, 50, [ 0, 0, 1, 0, 0, 0, 0, 0, true] ] call DMS_fnc_FindSafePos_InRange; + //_newPos = [_curPos, 5, 100, 3, 0, 20, 0] call BIS_fnc_findSafePos; + _tempPos = _curPos findEmptyPosition [0,100,_vehClass]; + _newPos = [_tempPos select 0, _tempPos select 1, 0]; + //_newPos = _curPos; + //_vehicle setDamage 0.2; + }; + + if(_vehicle isKindOf "Ship") then + { + //_newPos = [ _curPos, 1,50, [ 0, 0, 1, 0, 0, 0, 0, 0, true, true ] ] call DMS_fnc_FindSafePos_InRange; + _newPos = [_curPos, 5, 100, 3, 2, 20, 0] call BIS_fnc_findSafePos; + //_tempPos = _curPos findEmptyPosition [0,100,_vehClass]; + //_newPos = [_tempPos select 0, _tempPos select 1, 0]; + _newPos = _curPos; + _vehicle setDamage 0.2; + }; + + if(_vehicle isKindOf "Air") then + { + _newPos = _curPos; + }; + _GroupLeader = leader (group _vehicle); + _GroupLeader doMove _originalSpawnLocation; + [_group, _originalSpawnLocation, 2000] call bis_fnc_taskPatrol; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + + _logDetail = format ["[OCCUPATION:Unstuck]:: %1 was stuck and was moved from %2 to %3 @ %4",_vehicle,_curPos,_newPos, time]; + [_logDetail] call SC_fnc_log; + + }; + }; + }; + _vehicle setVariable["vehPos",_newPos]; +}; + diff --git a/scripts/reactions/driverKilled.sqf b/scripts/reactions/driverKilled.sqf index 1766af3..0368a5c 100644 --- a/scripts/reactions/driverKilled.sqf +++ b/scripts/reactions/driverKilled.sqf @@ -9,7 +9,7 @@ if(SC_extendedLogging) then _deadDriver = _this select 0; _deadDriver removeAllMPEventHandlers "mpkilled"; -_vehicleDriven = _deadDriver getVariable "SC_drivenVehicle"; +_vehicle = _deadDriver getVariable "SC_drivenVehicle"; if(SC_debug) then @@ -18,55 +18,62 @@ if(SC_debug) then }; // Select a replacement driver -_vehicleDriven removeAllMPEventHandlers "mphit"; -_vehGroup = group _vehicleDriven; -[_deadDriver] join grpNull; -if(count units _vehGroup > 0) then +_vehicle removeAllMPEventHandlers "mphit"; +_group = group _vehicle; + +// Remove dead units from the group { - _logDetail = format ["[OCCUPATION:Vehicle]:: vehicle: %1 group: %2 units left:%3",_vehicleDriven,_vehGroup,count units _vehGroup]; - [_logDetail] call SC_fnc_log; - _groupMembers = units _vehGroup; - _replacementDriver = _groupMembers call BIS_fnc_selectRandom; + if(!alive _x) then { [_x] join grpNull; }; +}forEach units _group; + +if(count units _group > 0) then +{ + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Vehicle]:: vehicle: %1 group: %2 units left:%3",_vehicle,_group,count units _group]; + [_logDetail] call SC_fnc_log; + }; + - if(!alive _replacementDriver) exitWith { [_replacementDriver] call SC_fnc_driverKilled; }; - - if (isNil "_replacementDriver") exitWith - { - _logDetail = format ["[OCCUPATION:Vehicle]:: No replacement Driver found for vehicle %1",_vehicleDriven]; - [_logDetail] call SC_fnc_log; - }; + _groupMembers = units _group; + _driver = _groupMembers call BIS_fnc_selectRandom; + + _driver disableAI "TARGET"; + _driver disableAI "AUTOTARGET"; + _driver disableAI "AUTOCOMBAT"; + _driver disableAI "COVER"; + _driver assignAsDriver _vehicle; + _driver setVariable ["DMS_AssignedVeh",_vehicle]; + _driver setVariable ["SC_drivenVehicle", _vehicle,true]; + _vehicle setVariable ["SC_assignedDriver", _driver,true]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; + _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; + if(SC_debug) then { - _tag = createVehicle ["Sign_Arrow_Green_F", position _replacementDriver, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_replacementDriver,[0,0,0.6],"Head"]; + _tag = createVehicle ["Sign_Arrow_Green_F", position _driver, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_driver,[0,0,0.6],"Head"]; }; - - _replacementDriver disableAI "TARGET"; - _replacementDriver disableAI "AUTOTARGET"; - _replacementDriver disableAI "AUTOCOMBAT"; - _replacementDriver disableAI "COVER"; - - _replacementDriver assignAsDriver _vehicleDriven; - - _vehicleDriven addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; - _replacementDriver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; - _replacementDriver setVariable ["DMS_AssignedVeh",_vehicleDriven]; - _replacementDriver setVariable ["SC_drivenVehicle", _vehicleDriven,true]; - _vehicleDriven setVariable ["SC_assignedDriver", _replacementDriver,true]; - _replacementDriver doMove (position _vehicleDriven); - _replacementDriver action ["movetodriver", _vehicleDriven]; + + _driver doMove (position _vehicle); + _driver action ["movetodriver", _vehicle]; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION:Vehicle]:: Replacement Driver found (%1) for vehicle %2",_replacementDriver,_vehicleDriven]; + _logDetail = format ["[OCCUPATION:Vehicle]:: Replacement Driver found (%1) for vehicle %2",_driver,_vehicle]; [_logDetail] call SC_fnc_log; }; - if(damage _vehicleDriven > 0) then + if(damage _vehicle > 0) then { - [_replacementDriver] call SC_fnc_repairVehicle; + [_vehicle] call SC_fnc_repairVehicle; }; +} +else +{ + _logDetail = format ["[OCCUPATION:Vehicle]:: No replacement Driver found for vehicle %1",_vehicle]; + [_logDetail] call SC_fnc_log; }; diff --git a/scripts/reactions/getIn.sqf b/scripts/reactions/getIn.sqf index e499552..8948649 100644 --- a/scripts/reactions/getIn.sqf +++ b/scripts/reactions/getIn.sqf @@ -6,9 +6,7 @@ _unit = _this select 0; if(isPlayer _unit) then { _vehicle = vehicle _unit; - _vehicle removeAllMPEventHandlers "mphit"; - _vehicle removeAllMPEventHandlers "mpkilled"; - SC_liveVehicles = SC_liveVehicles - 1; + [_vehicle] call SC_fnc_vehicleDestroyed; if(SC_extendedLogging) then { diff --git a/scripts/reactions/refuel.sqf b/scripts/reactions/refuel.sqf new file mode 100644 index 0000000..06ad962 --- /dev/null +++ b/scripts/reactions/refuel.sqf @@ -0,0 +1,18 @@ +// Triggered when a vehicle runs out of fuel but only if not damaged + +_vehicle = _this select 0; +_fuel = _this select 1; + +diag_log format["[OCCUPATION:refuelcheck] _vehicle: %1 ---- _fuel: %2 ",_vehicle,_fuel]; +/* +if(!isNil "_vehicle" && !isNil "_fuel") then +{ + _damage = getdammage _vehicle; + + if(_damage <> 0 && !_fuel) then + { + _vehicle setFuel 1; + _vehicle engineOn true; + }; +}; +*/ diff --git a/scripts/reactions/repairVehicle.sqf b/scripts/reactions/repairVehicle.sqf index 011f8d3..34f043b 100644 --- a/scripts/reactions/repairVehicle.sqf +++ b/scripts/reactions/repairVehicle.sqf @@ -47,9 +47,15 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then [_vehicle,_assignedDriver ] spawn { _vehicle = _this select 0; - _vehicle forceSpeed 0; - _vehGroup = group _vehicle; + _vehicle forceSpeed 0; + _group = group _vehicle; _driver = _this select 1; + _driver disableAI "TARGET"; + _driver disableAI "AUTOTARGET"; + _driver disableAI "AUTOCOMBAT"; + _driver disableAI "COVER"; + _driver disableAI "SUPPRESSION"; + sleep 1; _driver action ["getOut", _vehicle]; if(SC_debug) then @@ -58,41 +64,34 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then _tag attachTo [_driver,[0,0,0.6],"Head"]; }; sleep 0.2; - _driver doMove (position _vehicle); - _driver disableAI "TARGET"; - _driver disableAI "AUTOTARGET"; - _driver disableAI "AUTOCOMBAT"; - _driver disableAI "COVER"; + _driver doMove (position _vehicle); _driverDir = _driver getDir _vehicle; - //_driver setDir _driverDir + 180; _driver setUnitPos "MIDDLE"; sleep 0.5; _driver playMoveNow "Acts_carFixingWheel"; - sleep 2; - _driver playMoveNow "Acts_carFixingWheel"; - sleep 2; - _driver playMoveNow "Acts_carFixingWheel"; - sleep 2; + sleep 8; _driver switchMove ""; if(alive _driver) then { _vehicle setDamage 0; _driver playMoveNow "Acts_carFixingWheel"; sleep 2; + _driver switchMove ""; _driver assignAsDriver _vehicle; + _driver moveInDriver _vehicle; _driver action ["movetodriver", _vehicle]; }; - _wp = _vehGroup addWaypoint [position _vehicle, 0] ; + _wp = _group addWaypoint [position _vehicle, 0] ; _wp setWaypointFormation "Column"; _wp setWaypointCompletionRadius 1; _wp setWaypointType "GETIN"; - sleep 10; + sleep 5; _spawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; _driver action ["movetodriver", _vehicle]; _vehicle forceSpeed -1; - [_vehGroup, _spawnLocation, 2000] call bis_fnc_taskPatrol; - _vehGroup setBehaviour "AWARE"; - _vehGroup setCombatMode "RED"; + [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; }; } diff --git a/scripts/reactions/vehicleDestroyed.sqf b/scripts/reactions/vehicleDestroyed.sqf index e69de29..82c2ebb 100644 --- a/scripts/reactions/vehicleDestroyed.sqf +++ b/scripts/reactions/vehicleDestroyed.sqf @@ -0,0 +1,24 @@ +// SC_liveVehicles = count of vehicle +// SC_liveVehiclesArray = array of active vehicles + +_vehicle = _this select 0; +_vehicle removeAllMPEventHandlers "mphit"; +_vehicle removeAllMPEventHandlers "mpkilled"; + +if(_vehicle isKindOf "LandVehicle") then +{ + SC_liveVehicles = SC_liveVehicles - 1; + SC_liveVehiclesArray = SC_liveVehiclesArray - [_vehicle]; +}; + +if(_vehicle isKindOf "Air") then +{ + SC_liveHelis = SC_liveHelis - 1; + SC_liveHelisArray = SC_liveHelisArray - [_vehicle]; +}; + +if(_vehicle isKindOf "Ship") then +{ + SC_liveBoatss = SC_liveBoatss - 1; + SC_liveBoatsArray = SC_liveBoatsArray - [_vehicle]; +}; diff --git a/scripts/startOccupation.sqf b/scripts/startOccupation.sqf index 68757a4..8758133 100644 --- a/scripts/startOccupation.sqf +++ b/scripts/startOccupation.sqf @@ -1,7 +1,7 @@ -_logDetail = format ["[OCCUPATION]:: Occupation v%2 Giving the server time to start before starting [OCCUPATION] (%1)",time,SC_occupationVersion]; +_logDetail = format ["[OCCUPATION]:: Occupation %2 Giving the server time to start before starting [OCCUPATION] (%1)",time,SC_occupationVersion]; [_logDetail] call SC_fnc_log; -uiSleep 30; -_logDetail = format ["[OCCUPATION]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; +uiSleep 60; +_logDetail = format ["[OCCUPATION]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; [_logDetail] call SC_fnc_log; @@ -28,37 +28,48 @@ if(SC_occupyHeliCrashes) then if(SC_occupyStatic) then { uiSleep 15; // delay the start - fnc_occupationStaticMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationStatic.sqf"; - [SC_refreshTime, fnc_occupationStaticMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationStatic = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationStatic.sqf"; + [SC_refreshTime, fnc_occupationStatic, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupySky) then { uiSleep 15; // delay the start - fnc_occupationSkyMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationSky.sqf"; - [SC_refreshTime, fnc_occupationSkyMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationSky = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationSky.sqf"; + [SC_refreshTime, fnc_occupationSky, [], true] call ExileServer_system_thread_addTask; +}; + +if(SC_occupySea) then +{ + uiSleep 15; // delay the start + fnc_occupationSea = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationSea.sqf"; + [SC_refreshTime, fnc_occupationSea, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupyVehicle) then { uiSleep 15; // delay the start - fnc_occupationVehicleMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationVehicle.sqf"; - [SC_refreshTime, fnc_occupationVehicleMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationVehicle = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationVehicle.sqf"; + [SC_refreshTime, fnc_occupationVehicle, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupyPlaces) then { uiSleep 15; // delay the start - fnc_occupationMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationPlaces.sqf"; - [SC_refreshTime, fnc_occupationMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationPlaces = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationPlaces.sqf"; + [SC_refreshTime, fnc_occupationPlaces, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupyMilitary) then { uiSleep 15; // delay the start - fnc_occupationMilitaryMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMilitary.sqf"; - [SC_refreshTime, fnc_occupationMilitaryMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationMilitary = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMilitary.sqf"; + [SC_refreshTime, fnc_occupationMilitary, [], true] call ExileServer_system_thread_addTask; }; +uiSleep 15; // delay the start +fnc_occupationMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMonitor.sqf"; +[SC_refreshTime, fnc_occupationMonitor, [], true] call ExileServer_system_thread_addTask; + _logDetail = format ["[OCCUPATION]:: threads added at %1",time]; [_logDetail] call SC_fnc_log; \ No newline at end of file