From 4b05f73f28dd7074d5692383e4656e9c15dc0ecb Mon Sep 17 00:00:00 2001 From: second_coming Date: Wed, 6 Apr 2016 11:26:17 +0100 Subject: [PATCH 01/12] Update initServer.sqf --- initServer.sqf | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/initServer.sqf b/initServer.sqf index 46d97de..39d0276 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -// Version 3 +SC_occupationVersion = "v5 (06-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -20,16 +20,20 @@ // //////////////////////////////////////////////////////////////////////////////////////////// -SC_occupationVersion = "3.0"; + diag_log format ["[OCCUPATION MOD]:: Occupation v%2 Initialised 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_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_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\comeUnstuck.sqf"; // Get the config for Occupation call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.sqf"; @@ -37,5 +41,12 @@ 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"; +_logDetail = "============================================================================================================="; +[_logDetail] call SC_fnc_log; +_logDetail = format ["[OCCUPATION MOD]:: Occupation v%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 +[] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; From 887f26612b0077f9cb2e2ead53d95ce14f3ae5f7 Mon Sep 17 00:00:00 2001 From: second_coming Date: Wed, 6 Apr 2016 11:26:39 +0100 Subject: [PATCH 02/12] Update config.sqf --- config.sqf | 95 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 45 deletions(-) diff --git a/config.sqf b/config.sqf index 28b2494..755b4e4 100644 --- a/config.sqf +++ b/config.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -// Version 3 +// v5 (06-04-2016) // // http://www.exilemod.com/profile/60-second_coming/ // @@ -14,12 +14,12 @@ // Shared Config for each occupation monitor -SC_debug = false; // set to true to turn on debug features (not for live servers) +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_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 -SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false +SC_mapMarkers = true; // 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 +27,75 @@ 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) -SC_occupyStatic = false; // true if you want to garrison AI in specific locations (not working yet) + + // Occupation Military (roaming AI near military buildings) +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", + "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 = 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_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_LootCrateGuards = 3; // 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 for Namalsk in occupationHeliCrashes.sqf) + +SC_statics = [ [[1178,2524,0],4,100,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_maxNumberofVehicles = 10; SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green","Exile_Car_UAZ_Open_Green","Exile_Car_Offroad_Guerilla03"]; - - // Settings for roaming airborne AI (non armed helis will just fly around) -SC_maxNumberofHelis = 1; +SC_maxNumberofHelis = 2; SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"]; + +// Settings for roaming seaborne AI (non armed boats will just sail around) +SC_maxNumberofBoats = 0; +SC_BoatClassToUse = [ "B_Boat_Armed_01_minigun_F","I_Boat_Armed_01_minigun_F","O_Boat_Transport_01_F","O_G_Boat_Transport_01_F" ]; // namalsk specific settings if (worldName == 'Namalsk') then { - SC_maxAIcount = 80; - SC_occupySky = false; + //SC_maxAIcount = 80; + //SC_occupySky = false; }; // 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"; From ef72464dbcc6f5f3b7a4d76d6f0b624905365e7e Mon Sep 17 00:00:00 2001 From: second_coming Date: Wed, 6 Apr 2016 11:29:59 +0100 Subject: [PATCH 03/12] v5 06/04/2016 various fixes and changes to AI reactions --- config.cpp | 5 +- config.sqf | 2 +- initServer.sqf | 2 +- scripts/occupationHeliCrashes.sqf | 9 +- scripts/occupationLootCrates.sqf | 11 ++- scripts/occupationMilitary.sqf | 2 +- scripts/occupationMonitor.sqf | 28 ++++++ scripts/occupationPlaces.sqf | 28 +++--- scripts/occupationSea.sqf | 118 +++++++++++++++++++++++++ scripts/occupationSky.sqf | 17 +++- scripts/occupationStatic.sqf | 6 +- scripts/occupationVehicle.sqf | 39 ++++---- scripts/reactions/airHit.sqf | 92 +++++++++++-------- scripts/reactions/boatHit.sqf | 0 scripts/reactions/comeUnstuck.sqf | 75 ++++++++++++++++ scripts/reactions/driverKilled.sqf | 29 +++--- scripts/reactions/getIn.sqf | 4 +- scripts/reactions/refuel.sqf | 18 ++++ scripts/reactions/repairVehicle.sqf | 1 + scripts/reactions/vehicleDestroyed.sqf | 24 +++++ scripts/startOccupation.sqf | 33 ++++--- 21 files changed, 431 insertions(+), 112 deletions(-) create mode 100644 scripts/occupationMonitor.sqf create mode 100644 scripts/occupationSea.sqf create mode 100644 scripts/reactions/boatHit.sqf create mode 100644 scripts/reactions/comeUnstuck.sqf create mode 100644 scripts/reactions/refuel.sqf 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 755b4e4..c012e3d 100644 --- a/config.sqf +++ b/config.sqf @@ -98,4 +98,4 @@ publicVariable "SC_liveHelis"; publicVariable "SC_liveHelisArray"; publicVariable "SC_liveBoats"; publicVariable "SC_liveBoatsArray"; -publicVariable "SC_numberofLootCrates"; +publicVariable "SC_numberofLootCrates"; \ No newline at end of file diff --git a/initServer.sqf b/initServer.sqf index 39d0276..d328ec0 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -49,4 +49,4 @@ _logDetail = "================================================================== [_logDetail] call SC_fnc_log; // Start Occupation -[] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; +[] 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..d75cfb2 100644 --- a/scripts/occupationHeliCrashes.sqf +++ b/scripts/occupationHeliCrashes.sqf @@ -1,10 +1,8 @@ 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 + SC_numberofHeliCrashes = 2; // lower number for a smaller map }; _displayMarkers = SC_debug; // only use for debug, no need for actual gameplay @@ -14,7 +12,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..4258807 100644 --- a/scripts/occupationLootCrates.sqf +++ b/scripts/occupationLootCrates.sqf @@ -43,7 +43,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; @@ -56,7 +62,8 @@ for "_i" from 1 to SC_numberofLootCrates do _group setCombatMode "RED"; _logDetail = text format ["[OCCUPATION:LootCrates]:: Creating crate %3 @ 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; diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index 152321c..e7ae462 100644 --- a/scripts/occupationMilitary.sqf +++ b/scripts/occupationMilitary.sqf @@ -145,7 +145,7 @@ 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 diff --git a/scripts/occupationMonitor.sqf b/scripts/occupationMonitor.sqf new file mode 100644 index 0000000..4bb9799 --- /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_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_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..e44c51f 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -37,14 +37,14 @@ 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 = 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 = format ["[OCCUPATION:Places]:: %1 active AI, so not spawning AI this time",_aiActive]; [_logDetail] call SC_fnc_log; }; @@ -58,7 +58,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 +71,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 +83,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 +96,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 +107,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 +119,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 +131,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"; @@ -204,7 +204,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 +222,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..be70475 --- /dev/null +++ b/scripts/occupationSea.sqf @@ -0,0 +1,118 @@ +_logDetail = format['[OCCUPATION:Sea] Started']; +[_logDetail] call SC_fnc_log; + +if (!isServer) exitWith {}; + +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; + //_spawnLocation = [(_pos), 80, 10] call ExileClient_util_world_findWaterPosition; + _group = createGroup east; + _BoatClassToUse = SC_BoatClassToUse call BIS_fnc_selectRandom; + _vehicle1 = [ [_spawnLocation], _group, "assault", "difficult", "bandit", _BoatClassToUse ] call DMS_fnc_SpawnAIVehicle; + _vehicle1 setPosASL _spawnLocation; + _vehicle1 setVariable["vehPos",_spawnLocation,true]; + _vehicle1 setVariable["vehClass",_BoatClassToUse,true]; + + // Remove the overpowered weapons from boats + _vehicle1 removeWeaponTurret ["HMG_01",[0]]; + _vehicle1 removeWeaponTurret ["GMG_40mm",[0]]; + + SC_liveBoats = SC_liveBoats + 1; + SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle1]; + + _vehicle1 setVehicleLock "UNLOCKED"; + _vehicle1 setVariable ["ExileIsLocked", 0, true]; + if(SC_infiSTAR_log) then + { + _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_BoatClassToUse,_spawnLocation]; + [_logDetail] call SC_fnc_log; + }; + _vehicle1 setVehiclePosition [_spawnLocation, [], 0, "NONE"]; + _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; + + _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)]; + + // 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; + _vehicle1 addWeaponCargoGlobal [_weaponToAdd,1]; + + _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); + _vehicle1 addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + }; + + + [_group, _spawnLocation, 4000] call bis_fnc_taskPatrol; + _group setBehaviour "CARELESS"; + _group setCombatMode "RED"; + _vehicle1 addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; + _vehicle1 addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle1 addMPEventHandler ["mphit", "_this call SC_fnc_boatHit;"]; + _vehicle1 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..552b455 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -9,8 +9,7 @@ if(SC_liveHelis >= SC_maxNumberofHelis) exitWith { _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); @@ -49,7 +48,17 @@ for "_i" from 1 to _vehiclesToSpawn do _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 setVariable["vehPos",_helispawnLocation,true]; + _vehicle1 setVariable["vehClass",_HeliClassToUse,true]; + { + _unit = _x; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + }forEach units _group; + + SC_liveHelis = SC_liveHelis + 1; + SC_liveHelisArray = SC_liveHelisArray + [_vehicle1]; + _vehicle1 setVehicleLock "UNLOCKED"; _vehicle1 setVariable ["ExileIsLocked", 0, true]; if(SC_infiSTAR_log) then @@ -119,7 +128,7 @@ for "_i" from 1 to _vehiclesToSpawn do _group setBehaviour "CARELESS"; _group setCombatMode "RED"; _vehicle1 addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; - _vehicle1 addMPEventHandler ["mpkilled", "SC_liveHelis = SC_liveHelis - 1;"]; + _vehicle1 addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; _vehicle1 addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; _vehicle1 setVariable ["SC_crewEjected", false,true]; sleep 0.2; diff --git a/scripts/occupationStatic.sqf b/scripts/occupationStatic.sqf index 66da71d..4202725 100644 --- a/scripts/occupationStatic.sqf +++ b/scripts/occupationStatic.sqf @@ -47,7 +47,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do _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 +57,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; @@ -151,7 +151,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do _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..9c72ecf 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -59,7 +59,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 +69,14 @@ 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"]; + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + + SC_liveVehicles = SC_liveVehicles + 1; + SC_liveVehiclesArray = SC_liveVehiclesArray + [_vehicle]; + _vehicle setFuel 1; _vehicle engineOn true; _vehicle lock 0; @@ -81,25 +86,29 @@ 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; + _driver = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + sleep 0.5; 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; + sleep 0.5; _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; + _driver assignAsDriver _vehicle; + _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; + + _vehicle setVariable ["SC_assignedDriver", _driver,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,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;"]; + _group setBehaviour "CARELESS"; + _group setCombatMode "BLUE"; sleep 0.2; _crewCount = { @@ -108,14 +117,12 @@ if(_vehiclesToSpawn >= 1) then _unit setVariable ["DMS_AssignedVeh",_vehicle]; _unit assignAsCargo _vehicle; sleep 0.2; + _group setBehaviour "CARELESS"; + _group setCombatMode "BLUE"; true } count (allTurrets [_vehicle, true]); - _group setBehaviour "CARELESS"; - _group setCombatMode "BLUE"; - sleep 10; - // Get the AI to shut the fuck up :) enableSentences false; enableRadio false; diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index e1994cd..0e1cc03 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -35,21 +35,23 @@ _damagedEssentials = 0; } forEach _essentials; -if(_damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then +if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then { [_heli ] 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,_veh,_heliPosition]; + [_logDetail] call SC_fnc_log; + }; { - 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 + + if (!(_unit == gunner _veh) && !(_unit == driver _veh)) then { _unit action ["EJECT", _veh]; }; @@ -62,35 +64,7 @@ if(_damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then _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(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"; - _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]; - + _destination = getPos _target; _group allowFleeing 0; _wp = _group addWaypoint [_destination, 0] ; _wp setWaypointFormation "Column"; @@ -98,7 +72,47 @@ if(_heliDamage > 0.5 && _damagedEssentials > 0) then _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 1; _wp setWaypointType "SAD"; + + [_group, _destination, 250] call bis_fnc_taskPatrol; - _group setBehaviour "COMBAT"; - _group setCombatMode "RED"; + _group allowFleeing 0; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + _heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; +}; + + +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] call SC_fnc_vehicleDestroyed; + _currentHeliPos = getPos _heli; + _destination = [_currentHeliPos, 1, 150, 10, 0, 20, 0] call BIS_fnc_findSafePos; + _heli setVehicleLock "UNLOCKED"; + _target = _this select 1; + _group = group _heli; + _group reveal [_target,2.5]; + _destination = position _target; + + _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 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..e69de29 diff --git a/scripts/reactions/comeUnstuck.sqf b/scripts/reactions/comeUnstuck.sqf new file mode 100644 index 0000000..d0d109c --- /dev/null +++ b/scripts/reactions/comeUnstuck.sqf @@ -0,0 +1,75 @@ +// Unstuck based on a function written by Chris (infiSTAR) +// http://pastebin.com/73pjvXPw + + +private["_vehicle","_curPos","_oldvehPos","_engineTime","_newPos"]; +_vehicle = _this select 0; + +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, 15, [ 0, 0, 1, 0, 0, 0, 0, 0, true] ] call DMS_fnc_FindSafePos_InRange; + //_newPos = [_curPos, 5, 20, 3, 0, 20, 0] call BIS_fnc_findSafePos; + _tempPos = _curPos findEmptyPosition [0,50,_vehClass]; + _newPos = [_tempPos select 0, _tempPos select 1, 0]; + _vehicle setPosATL _newPos; + }; + + if(_vehicle isKindOf "Ship") then + { + //_newPos = [ _curPos, 1,15, [ 0, 0, 1, 0, 0, 0, 0, 0, true, true ] ] call DMS_fnc_FindSafePos_InRange; + //_newPos = [_curPos, 5, 20, 3, 2, 20, 0] call BIS_fnc_findSafePos; + _newPos = _curPos findEmptyPosition [0,50,_vehClass]; + _newPos = [_newPos select 0, _newPos select 1, 0]; + _vehicle setPosATL _newPos; + + }; + + 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..f4c6433 100644 --- a/scripts/reactions/driverKilled.sqf +++ b/scripts/reactions/driverKilled.sqf @@ -28,7 +28,13 @@ if(count units _vehGroup > 0) then _groupMembers = units _vehGroup; _replacementDriver = _groupMembers call BIS_fnc_selectRandom; - if(!alive _replacementDriver) exitWith { [_replacementDriver] call SC_fnc_driverKilled; }; + while(!(alive _replacementDriver) && (count units _vehGroup > 0)) do + { + [_replacementDriver] join grpNull; + if(count units _vehGroup < 1) exitWith {}; + _groupMembers = units _vehGroup; + _replacementDriver = _groupMembers call BIS_fnc_selectRandom; + }; if (isNil "_replacementDriver") exitWith { @@ -36,24 +42,25 @@ if(count units _vehGroup > 0) then [_logDetail] call SC_fnc_log; }; - if(SC_debug) then - { - _tag = createVehicle ["Sign_Arrow_Green_F", position _replacementDriver, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_replacementDriver,[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]; + _vehicleDriven setVariable ["SC_assignedDriver", _replacementDriver,true]; + _vehicleDriven addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; + _replacementDriver 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"]; + }; + _replacementDriver doMove (position _vehicleDriven); _replacementDriver action ["movetodriver", _vehicleDriven]; 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..3586617 100644 --- a/scripts/reactions/repairVehicle.sqf +++ b/scripts/reactions/repairVehicle.sqf @@ -48,6 +48,7 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then { _vehicle = _this select 0; _vehicle forceSpeed 0; + sleep 1; _vehGroup = group _vehicle; _driver = _this select 1; _driver action ["getOut", _vehicle]; 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..b3e598a 100644 --- a/scripts/startOccupation.sqf +++ b/scripts/startOccupation.sqf @@ -1,6 +1,6 @@ _logDetail = format ["[OCCUPATION]:: Occupation v%2 Giving the server time to start before starting [OCCUPATION] (%1)",time,SC_occupationVersion]; [_logDetail] call SC_fnc_log; -uiSleep 30; +uiSleep 60; _logDetail = format ["[OCCUPATION]:: Occupation v%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 From eacea8e54fcbd7edef118262e4b4044bb9ce033c Mon Sep 17 00:00:00 2001 From: second_coming Date: Wed, 6 Apr 2016 15:52:53 +0100 Subject: [PATCH 04/12] tweakamungous --- config.sqf | 38 ++++++++++++++++++------------- scripts/occupationHeliCrashes.sqf | 5 ---- scripts/occupationLootCrates.sqf | 5 ---- scripts/occupationSea.sqf | 1 + scripts/occupationSky.sqf | 1 + scripts/reactions/comeUnstuck.sqf | 21 +++++++++-------- 6 files changed, 35 insertions(+), 36 deletions(-) diff --git a/config.sqf b/config.sqf index c012e3d..7d0d02f 100644 --- a/config.sqf +++ b/config.sqf @@ -14,12 +14,12 @@ // Shared Config for each occupation monitor -SC_debug = true; // set to true to turn on debug features (not for live servers) +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_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 -SC_mapMarkers = true; // 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 @@ -31,7 +31,7 @@ SC_useWaypoints = true; // When spawning AI create waypoints to make t SC_occupyPlaces = true; // true if you want villages,towns,cities patrolled // Occupation Military (roaming AI near military buildings) -SC_occupyMilitary = true; // true if you want military buildings patrolled (specify which types of building below) +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", @@ -42,48 +42,54 @@ SC_buildings = [ "Land_Cargo_Patrol_V1_F","Land_i_Barracks_V1_F", "Land_Army_hut_int","Land_Army_hut2_int" ]; -SC_occupyStatic = true; // true if you want to garrison AI in specific locations (not working yet) +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_occupySea = true; // 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_LootCrateGuards = 3; // 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_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 for Namalsk in occupationHeliCrashes.sqf) +SC_numberofHeliCrashes = 5; // if SC_occupyHeliCrashes = true spawn this many loot crates (overrided below for Namalsk) SC_statics = [ [[1178,2524,0],4,100,true] ]; //[[pos],ai count,radius,search buildings] // Settings for roaming ground vehicle AI -SC_maxNumberofVehicles = 10; +SC_maxNumberofVehicles = 5; SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green","Exile_Car_UAZ_Open_Green","Exile_Car_Offroad_Guerilla03"]; // Settings for roaming airborne AI (non armed helis will just fly around) -SC_maxNumberofHelis = 2; -SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"]; +SC_maxNumberofHelis = 1; +SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"]; // Settings for roaming seaborne AI (non armed boats will just sail around) -SC_maxNumberofBoats = 0; -SC_BoatClassToUse = [ "B_Boat_Armed_01_minigun_F","I_Boat_Armed_01_minigun_F","O_Boat_Transport_01_F","O_G_Boat_Transport_01_F" ]; +SC_maxNumberofBoats = 2; +SC_BoatClassToUse = [ "B_Boat_Armed_01_minigun_F","I_Boat_Armed_01_minigun_F","O_Boat_Transport_01_F","O_G_Boat_Transport_01_F" ]; // namalsk specific settings if (worldName == 'Namalsk') then { - //SC_maxAIcount = 80; - //SC_occupySky = false; + SC_maxAIcount = 80; + SC_occupySky = false; + SC_maxNumberofVehicles = 3; + SC_numberofLootCrates = 3; + SC_numberofHeliCrashes = 2; + SC_maxNumberofBoats = 2; }; + + // Don't alter anything below this point SC_liveVehicles = 0; SC_liveVehiclesArray = []; diff --git a/scripts/occupationHeliCrashes.sqf b/scripts/occupationHeliCrashes.sqf index d75cfb2..45d05ab 100644 --- a/scripts/occupationHeliCrashes.sqf +++ b/scripts/occupationHeliCrashes.sqf @@ -1,10 +1,5 @@ if (!isServer) exitWith {}; -if (worldName == 'Namalsk') then -{ - SC_numberofHeliCrashes = 2; // lower number for a smaller map -}; - _displayMarkers = SC_debug; // only use for debug, no need for actual gameplay private['_position']; diff --git a/scripts/occupationLootCrates.sqf b/scripts/occupationLootCrates.sqf index 4258807..f4d61bd 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; diff --git a/scripts/occupationSea.sqf b/scripts/occupationSea.sqf index be70475..e4fa7cf 100644 --- a/scripts/occupationSea.sqf +++ b/scripts/occupationSea.sqf @@ -29,6 +29,7 @@ for "_i" from 1 to _vehiclesToSpawn do _vehicle1 setPosASL _spawnLocation; _vehicle1 setVariable["vehPos",_spawnLocation,true]; _vehicle1 setVariable["vehClass",_BoatClassToUse,true]; + _vehicle1 setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; // Remove the overpowered weapons from boats _vehicle1 removeWeaponTurret ["HMG_01",[0]]; diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index 552b455..117dba9 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -50,6 +50,7 @@ for "_i" from 1 to _vehiclesToSpawn do _vehicle1 = [ [_helispawnLocation], _group, "assault", "difficult", "bandit", _HeliClassToUse ] call DMS_fnc_SpawnAIVehicle; _vehicle1 setVariable["vehPos",_helispawnLocation,true]; _vehicle1 setVariable["vehClass",_HeliClassToUse,true]; + _vehicle1 setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; { _unit = _x; removeBackpackGlobal _unit; diff --git a/scripts/reactions/comeUnstuck.sqf b/scripts/reactions/comeUnstuck.sqf index d0d109c..09e0a0b 100644 --- a/scripts/reactions/comeUnstuck.sqf +++ b/scripts/reactions/comeUnstuck.sqf @@ -37,21 +37,22 @@ if(count(crew _vehicle) > 0)then if(_vehicle isKindOf "LandVehicle") then { - //_newPos = [ _curPos, 1, 15, [ 0, 0, 1, 0, 0, 0, 0, 0, true] ] call DMS_fnc_FindSafePos_InRange; - //_newPos = [_curPos, 5, 20, 3, 0, 20, 0] call BIS_fnc_findSafePos; - _tempPos = _curPos findEmptyPosition [0,50,_vehClass]; + //_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]; - _vehicle setPosATL _newPos; + //_newPos = _curPos; + //_vehicle setDamage 0.2; }; if(_vehicle isKindOf "Ship") then { - //_newPos = [ _curPos, 1,15, [ 0, 0, 1, 0, 0, 0, 0, 0, true, true ] ] call DMS_fnc_FindSafePos_InRange; - //_newPos = [_curPos, 5, 20, 3, 2, 20, 0] call BIS_fnc_findSafePos; - _newPos = _curPos findEmptyPosition [0,50,_vehClass]; - _newPos = [_newPos select 0, _newPos select 1, 0]; - _vehicle setPosATL _newPos; - + //_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 From f2a2236eb2ad97371b8d1bf151a1fcaf1d425108 Mon Sep 17 00:00:00 2001 From: second_coming Date: Thu, 7 Apr 2016 00:45:51 +0100 Subject: [PATCH 05/12] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3f4c61e..e5fbb37 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ http://www.exilemod.com/topic/61-dms-defents-mission-system/ Download the pbo version here: https://www.dropbox.com/s/dxy44l4mfu6ys53/a3_exile_occupation.pbo?dl=0 +If you download the version from github, ensure that the folder you turn into a pbo is called: +a3_exile_occupation +any other name and you will get an error: 'initServer.sqf not found' + To install place the pbo into the @ExileServer/addons folder For more info: From 2e620483131eafbc7be48d59688ede6b00ac9c50 Mon Sep 17 00:00:00 2001 From: second_coming Date: Thu, 7 Apr 2016 11:02:27 +0100 Subject: [PATCH 06/12] Fixed incompatibility with marma --- config.sqf | 8 ++++---- initServer.sqf | 12 ++++++------ scripts/occupationLootCrates.sqf | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config.sqf b/config.sqf index 7d0d02f..3497e22 100644 --- a/config.sqf +++ b/config.sqf @@ -14,9 +14,9 @@ // Shared Config for each occupation monitor -SC_debug = true; // set to true to turn on debug features (not for live servers) +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_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 @@ -46,14 +46,14 @@ SC_occupyStatic = false; // true if you want to garrison AI in spec 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 = true; // true if you want to have roaming AI boats +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 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_LootCrateGuardsRandomize = false; // 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 diff --git a/initServer.sqf b/initServer.sqf index d328ec0..610e8ae 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -24,6 +24,12 @@ SC_occupationVersion = "v5 (06-04-2016)"; diag_log format ["[OCCUPATION MOD]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; +// 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"; + // 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"; @@ -35,12 +41,6 @@ SC_fnc_getIn = compile preprocessFileLineNumbers "\x\addons\a3_exile_occup SC_fnc_refuel = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\refuel.sqf"; SC_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\comeUnstuck.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"; - _logDetail = "============================================================================================================="; [_logDetail] call SC_fnc_log; _logDetail = format ["[OCCUPATION MOD]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; diff --git a/scripts/occupationLootCrates.sqf b/scripts/occupationLootCrates.sqf index f4d61bd..25ded79 100644 --- a/scripts/occupationLootCrates.sqf +++ b/scripts/occupationLootCrates.sqf @@ -56,9 +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; @@ -86,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 From 4120471787dac4c1d371c1fa5ccd19d0f09dc165 Mon Sep 17 00:00:00 2001 From: second_coming Date: Thu, 7 Apr 2016 11:08:44 +0100 Subject: [PATCH 07/12] version update --- initServer.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initServer.sqf b/initServer.sqf index 610e8ae..ec165d1 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v5 (06-04-2016)"; +SC_occupationVersion = "v6 (07-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // From d3338161ce804f903cf74536581acc88a078ae75 Mon Sep 17 00:00:00 2001 From: second_coming Date: Fri, 8 Apr 2016 14:48:25 +0100 Subject: [PATCH 08/12] Vehicle AI & AI Behaviour tweaks --- config.sqf | 20 ++-- initServer.sqf | 6 +- scripts/occupationPlaces.sqf | 8 +- scripts/occupationSea.sqf | 142 +++++++++++++++++++-------- scripts/occupationSky.sqf | 146 ++++++++++++++++++++-------- scripts/occupationVehicle.sqf | 120 ++++++++++++++++------- scripts/reactions/airHit.sqf | 63 ++++++------ scripts/reactions/driverKilled.sqf | 82 ++++++++-------- scripts/reactions/repairVehicle.sqf | 36 ++++--- 9 files changed, 397 insertions(+), 226 deletions(-) diff --git a/config.sqf b/config.sqf index 3497e22..f3d9499 100644 --- a/config.sqf +++ b/config.sqf @@ -2,7 +2,6 @@ // // Server Occupation script by second_coming // -// v5 (06-04-2016) // // http://www.exilemod.com/profile/60-second_coming/ // @@ -14,9 +13,9 @@ // Shared Config for each occupation monitor -SC_debug = true; // set to true to turn on debug features (not for live servers) +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 = false; // true Use infiSTAR logging, false logs to server rpt +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 SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false @@ -53,7 +52,7 @@ 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 below for Namalsk) SC_LootCrateGuards = 4; // number of AI to spawn at each crate -SC_LootCrateGuardsRandomize = false; // Use a random number of guards up to a maximum = SC_numberofGuards (so between 1 and SC_numberofGuards) +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 @@ -65,7 +64,7 @@ SC_statics = [ [[1178,2524,0],4,100,true] ]; //[[pos],ai c // Settings for roaming ground vehicle AI -SC_maxNumberofVehicles = 5; +SC_maxNumberofVehicles = 3; SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green","Exile_Car_UAZ_Open_Green","Exile_Car_Offroad_Guerilla03"]; // Settings for roaming airborne AI (non armed helis will just fly around) @@ -73,19 +72,20 @@ SC_maxNumberofHelis = 1; SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"]; // Settings for roaming seaborne AI (non armed boats will just sail around) -SC_maxNumberofBoats = 2; +SC_maxNumberofBoats = 1; SC_BoatClassToUse = [ "B_Boat_Armed_01_minigun_F","I_Boat_Armed_01_minigun_F","O_Boat_Transport_01_F","O_G_Boat_Transport_01_F" ]; - + +// AI Custom Loadouts - // namalsk specific settings + // namalsk specific settings if (worldName == 'Namalsk') then { SC_maxAIcount = 80; SC_occupySky = false; - SC_maxNumberofVehicles = 3; + SC_maxNumberofVehicles = 2; SC_numberofLootCrates = 3; SC_numberofHeliCrashes = 2; - SC_maxNumberofBoats = 2; + SC_maxNumberofBoats = 1; }; diff --git a/initServer.sqf b/initServer.sqf index ec165d1..53632b0 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v6 (07-04-2016)"; +SC_occupationVersion = "v7 (08-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -22,7 +22,7 @@ SC_occupationVersion = "v6 (07-04-2016)"; -diag_log format ["[OCCUPATION MOD]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; +diag_log format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; // Get the config for Occupation call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.sqf"; @@ -43,7 +43,7 @@ SC_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_ex _logDetail = "============================================================================================================="; [_logDetail] call SC_fnc_log; -_logDetail = format ["[OCCUPATION MOD]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; +_logDetail = format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; [_logDetail] call SC_fnc_log; _logDetail = "============================================================================================================="; [_logDetail] call SC_fnc_log; diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index e44c51f..baa43b4 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -15,6 +15,7 @@ private["_wp","_wp2","_wp3"]; if (!isServer) exitWith {}; + _logDetail = format ["[OCCUPATION]:: Starting Occupation Monitor"]; [_logDetail] call SC_fnc_log; @@ -161,10 +162,11 @@ _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; // Find Highest Point _highest = [0,0,0]; { diff --git a/scripts/occupationSea.sqf b/scripts/occupationSea.sqf index e4fa7cf..49b18e6 100644 --- a/scripts/occupationSea.sqf +++ b/scripts/occupationSea.sqf @@ -3,6 +3,29 @@ _logDetail = format['[OCCUPATION:Sea] 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: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 @@ -20,49 +43,88 @@ _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; - //_spawnLocation = [(_pos), 80, 10] call ExileClient_util_world_findWaterPosition; - _group = createGroup east; - _BoatClassToUse = SC_BoatClassToUse call BIS_fnc_selectRandom; - _vehicle1 = [ [_spawnLocation], _group, "assault", "difficult", "bandit", _BoatClassToUse ] call DMS_fnc_SpawnAIVehicle; - _vehicle1 setPosASL _spawnLocation; - _vehicle1 setVariable["vehPos",_spawnLocation,true]; - _vehicle1 setVariable["vehClass",_BoatClassToUse,true]; - _vehicle1 setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; + _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 - _vehicle1 removeWeaponTurret ["HMG_01",[0]]; - _vehicle1 removeWeaponTurret ["GMG_40mm",[0]]; - + _vehicle removeWeaponTurret ["HMG_01",[0]]; + _vehicle removeWeaponTurret ["GMG_40mm",[0]]; + SC_liveBoats = SC_liveBoats + 1; - SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle1]; + 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; - _vehicle1 setVehicleLock "UNLOCKED"; - _vehicle1 setVariable ["ExileIsLocked", 0, true]; + if(SC_infiSTAR_log) then { - _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_BoatClassToUse,_spawnLocation]; + _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; [_logDetail] call SC_fnc_log; }; - _vehicle1 setVehiclePosition [_spawnLocation, [], 0, "NONE"]; - _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 = @@ -96,20 +158,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, 4000] call bis_fnc_taskPatrol; - _group setBehaviour "CARELESS"; + _group setBehaviour "AWARE"; _group setCombatMode "RED"; - _vehicle1 addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; - _vehicle1 addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; - _vehicle1 addMPEventHandler ["mphit", "_this call SC_fnc_boatHit;"]; - _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_boatHit;"]; + _vehicle setVariable ["SC_crewEjected", false,true]; sleep 0.2; }; diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index 117dba9..8df9178 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -3,6 +3,29 @@ _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 @@ -41,50 +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; - _vehicle1 setVariable["vehPos",_helispawnLocation,true]; - _vehicle1 setVariable["vehClass",_HeliClassToUse,true]; - _vehicle1 setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - { - _unit = _x; - removeBackpackGlobal _unit; - _unit addBackpackGlobal "B_Parachute"; - }forEach units _group; - + _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 + [_vehicle1]; + 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; - _vehicle1 setVehicleLock "UNLOCKED"; - _vehicle1 setVariable ["ExileIsLocked", 0, true]; + 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 = @@ -118,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", "_this call SC_fnc_vehicleDestroyed;"]; - _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/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index 9c72ecf..cb9eafb 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 @@ -71,12 +95,14 @@ if(_vehiclesToSpawn >= 1) then _group = createGroup east; _VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom; _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; - _vehicle setVariable["vehPos",_spawnLocation,true]; - _vehicle setVariable["vehClass",_VehicleClassToUse,true]; - + _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; @@ -86,42 +112,62 @@ if(_vehiclesToSpawn >= 1) then _vehicle limitSpeed 60; _vehicle action ["LightOn", _vehicle]; - - _group addVehicle _vehicle; - _driver = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; - sleep 0.5; - if(SC_debug) then + + // Calculate the crew requried + _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; { - _tag = createVehicle ["Sign_Arrow_Green_F", position _driver, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_driver,[0,0,0.6],"Head"]; - }; - sleep 0.5; - _driver setVariable ["DMS_AssignedVeh",_vehicle]; - _driver setVariable ["SC_drivenVehicle", _vehicle,true]; - _driver action ["movetodriver", _vehicle]; - _driver assignAsDriver _vehicle; - _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; - - _vehicle setVariable ["SC_assignedDriver", _driver,true]; - _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,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;"]; - _group setBehaviour "CARELESS"; - _group setCombatMode "BLUE"; - 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; - _group setBehaviour "CARELESS"; - _group setCombatMode "BLUE"; - true - } count (allTurrets [_vehicle, true]); + _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; + _group setBehaviour "CARELESS"; + _group setCombatMode "BLUE"; // Get the AI to shut the fuck up :) enableSentences false; diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index 0e1cc03..500ab15 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") 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,49 +40,43 @@ _damagedEssentials = 0; } forEach _essentials; -if(_heliDamage > 0.2 && _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; + _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 select 0; - - if (!(_unit == gunner _veh) && !(_unit == driver _veh)) then - { - _unit action ["EJECT", _veh]; - }; - } forEach (fullCrew _veh); + { + _unit = _x select 0; + _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 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"; _heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; }; diff --git a/scripts/reactions/driverKilled.sqf b/scripts/reactions/driverKilled.sqf index f4c6433..d64a153 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,62 +18,62 @@ if(SC_debug) then }; // Select a replacement driver -_vehicleDriven removeAllMPEventHandlers "mphit"; -_vehGroup = group _vehicleDriven; +_vehicle removeAllMPEventHandlers "mphit"; +_group = group _vehicle; [_deadDriver] join grpNull; -if(count units _vehGroup > 0) then -{ - _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; - - while(!(alive _replacementDriver) && (count units _vehGroup > 0)) do - { - [_replacementDriver] join grpNull; - if(count units _vehGroup < 1) exitWith {}; - _groupMembers = units _vehGroup; - _replacementDriver = _groupMembers call BIS_fnc_selectRandom; - }; - - if (isNil "_replacementDriver") exitWith - { - _logDetail = format ["[OCCUPATION:Vehicle]:: No replacement Driver found for vehicle %1",_vehicleDriven]; - [_logDetail] call SC_fnc_log; - }; - - _replacementDriver disableAI "TARGET"; - _replacementDriver disableAI "AUTOTARGET"; - _replacementDriver disableAI "AUTOCOMBAT"; - _replacementDriver disableAI "COVER"; +{ + 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; + }; + - _replacementDriver assignAsDriver _vehicleDriven; - _replacementDriver setVariable ["DMS_AssignedVeh",_vehicleDriven]; - _replacementDriver setVariable ["SC_drivenVehicle", _vehicleDriven,true]; - _vehicleDriven setVariable ["SC_assignedDriver", _replacementDriver,true]; - _vehicleDriven addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; - _replacementDriver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; + _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 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; + [_driver] 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/repairVehicle.sqf b/scripts/reactions/repairVehicle.sqf index 3586617..34f043b 100644 --- a/scripts/reactions/repairVehicle.sqf +++ b/scripts/reactions/repairVehicle.sqf @@ -47,10 +47,15 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then [_vehicle,_assignedDriver ] spawn { _vehicle = _this select 0; - _vehicle forceSpeed 0; - sleep 1; - _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 @@ -59,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"; }; } From ffc7625d356d60269575f76a53bb8e9115093771 Mon Sep 17 00:00:00 2001 From: second_coming Date: Fri, 8 Apr 2016 17:07:09 +0100 Subject: [PATCH 09/12] typo fix --- scripts/reactions/airHit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index 500ab15..a53acd0 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -54,7 +54,7 @@ if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance [_logDetail] call SC_fnc_log; }; { - _unit = _x select 0; + _unit = _x; _unit joinSilent _group2; _unit action ["EJECT", _veh]; } forEach (assignedCargo _veh); From 9d4a3f1d27166446568869a44a29615ee14e9b07 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 10 Apr 2016 03:43:09 +1200 Subject: [PATCH 10/12] Added spawn and waitUntil to wait until DMS has executed its postinit before initializing Occupation init --- initServer.sqf | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/initServer.sqf b/initServer.sqf index 53632b0..dd9a954 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -19,34 +19,35 @@ SC_occupationVersion = "v7 (08-04-2016)"; // second_coming 2016 // //////////////////////////////////////////////////////////////////////////////////////////// +[] spawn { + waitUntil { !(isNil "DMS_MinMax_Y_Coords") }; + diag_log format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; + // Get the config for Occupation + call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.sqf"; -diag_log format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; + // Select the log style depending on config settings + SC_fnc_log = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationLog.sqf"; -// Get the config for Occupation -call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.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_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\comeUnstuck.sqf"; -// Select the log style depending on config settings -SC_fnc_log = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationLog.sqf"; + _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; -// 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_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\comeUnstuck.sqf"; - -_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 + // Start Occupation + [] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; +}; From 38b0279cc8f3e6ff38d8fd61d88127c754d251de Mon Sep 17 00:00:00 2001 From: second_coming Date: Sat, 9 Apr 2016 19:28:01 +0100 Subject: [PATCH 11/12] typo fix --- scripts/reactions/driverKilled.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/reactions/driverKilled.sqf b/scripts/reactions/driverKilled.sqf index d64a153..0368a5c 100644 --- a/scripts/reactions/driverKilled.sqf +++ b/scripts/reactions/driverKilled.sqf @@ -20,8 +20,8 @@ if(SC_debug) then // Select a replacement driver _vehicle removeAllMPEventHandlers "mphit"; _group = group _vehicle; -[_deadDriver] join grpNull; +// Remove dead units from the group { if(!alive _x) then { [_x] join grpNull; }; }forEach units _group; @@ -68,7 +68,7 @@ if(count units _group > 0) then if(damage _vehicle > 0) then { - [_driver] call SC_fnc_repairVehicle; + [_vehicle] call SC_fnc_repairVehicle; }; } From 90e2fa3e16dc5d1c5e92147167bcd256fbdf5727 Mon Sep 17 00:00:00 2001 From: second_coming Date: Sun, 10 Apr 2016 15:42:45 +0100 Subject: [PATCH 12/12] bug fixes --- README.md | 4 - config.sqf | 10 +-- initServer.sqf | 54 ++++++------- scripts/occupationMilitary.sqf | 31 ++------ scripts/occupationMonitor.sqf | 4 +- scripts/occupationPlaces.sqf | 27 ++++--- scripts/occupationSky.sqf | 2 +- scripts/occupationStatic.sqf | 37 ++++----- scripts/occupationVehicle.sqf | 4 +- scripts/reactions/airHit.sqf | 2 +- scripts/reactions/boatHit.sqf | 123 ++++++++++++++++++++++++++++++ scripts/reactions/comeUnstuck.sqf | 2 + scripts/startOccupation.sqf | 4 +- 13 files changed, 206 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index e5fbb37..3f4c61e 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,6 @@ http://www.exilemod.com/topic/61-dms-defents-mission-system/ Download the pbo version here: https://www.dropbox.com/s/dxy44l4mfu6ys53/a3_exile_occupation.pbo?dl=0 -If you download the version from github, ensure that the folder you turn into a pbo is called: -a3_exile_occupation -any other name and you will get an error: 'initServer.sqf not found' - To install place the pbo into the @ExileServer/addons folder For more info: diff --git a/config.sqf b/config.sqf index f3d9499..04e258e 100644 --- a/config.sqf +++ b/config.sqf @@ -15,7 +15,7 @@ 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 @@ -59,13 +59,13 @@ SC_occupyLootCratesMarkers = true; // true if you want to have markers on th 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],4,100,true] ]; //[[pos],ai count,radius,search buildings] +SC_statics = [ [[1178,2524,0],8,250,true] ]; //[[pos],ai count,radius,search buildings] // 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; @@ -73,7 +73,7 @@ SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"]; // 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","O_G_Boat_Transport_01_F" ]; +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 diff --git a/initServer.sqf b/initServer.sqf index dd9a954..5669593 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v7 (08-04-2016)"; +SC_occupationVersion = "v8 (09-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -19,35 +19,37 @@ SC_occupationVersion = "v7 (08-04-2016)"; // second_coming 2016 // //////////////////////////////////////////////////////////////////////////////////////////// -[] spawn { + +[] spawn +{ waitUntil { !(isNil "DMS_MinMax_Y_Coords") }; - diag_log format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; + diag_log format ["[OCCUPATION MOD]:: Occupation %2 Loading Config at %1",time,SC_occupationVersion]; - // 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_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\comeUnstuck.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"; - _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; + _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"; -}; + // Start Occupation + [] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; +}; \ No newline at end of file diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index e7ae462..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; @@ -150,23 +151,6 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do } 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 index 4bb9799..f49d1f2 100644 --- a/scripts/occupationMonitor.sqf +++ b/scripts/occupationMonitor.sqf @@ -12,7 +12,7 @@ _logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; _logDetail = format ["[OCCUPATION:Unstick]:: Land: %1 is active",_x]; [_logDetail] call SC_fnc_log; _x setFuel 1; - [_x] call SC_comeUnstuck; + [_x] call SC_fnc_comeUnstuck; sleep 5; }forEach SC_liveVehiclesArray; @@ -20,7 +20,7 @@ _logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; _logDetail = format ["[OCCUPATION:Unstick]:: Sea: %1 is active",_x]; [_logDetail] call SC_fnc_log; _x setFuel 1; - [_x] call SC_comeUnstuck; + [_x] call SC_fnc_comeUnstuck; sleep 5; }forEach SC_liveBoatsArray; diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index baa43b4..f89f322 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -16,7 +16,7 @@ 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; @@ -38,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:Places]:: 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 = {alive _x && side _x == EAST} count allUnits; if(_aiActive > _maxAIcount) exitWith { - _logDetail = format ["[OCCUPATION:Places]:: %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]); @@ -167,6 +173,8 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi if(_isEnterable) then { _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; + _y = _x; + // Find Highest Point _highest = [0,0,0]; { @@ -176,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"; diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index 8df9178..1f51e1a 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -130,7 +130,7 @@ for "_i" from 1 to _vehiclesToSpawn do [_logDetail] call SC_fnc_log; }; } forEach _vehicleRoles; - + if(SC_infiSTAR_log) then { diff --git a/scripts/occupationStatic.sqf b/scripts/occupationStatic.sqf index 4202725..dbbb19e 100644 --- a/scripts/occupationStatic.sqf +++ b/scripts/occupationStatic.sqf @@ -45,7 +45,6 @@ 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]:: Checking static spawn @ %1",_spawnPosition,_aiCount]; [_logDetail] call SC_fnc_log; @@ -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,46 +106,42 @@ 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; diff --git a/scripts/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index cb9eafb..a9a907c 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -165,9 +165,7 @@ if(_vehiclesToSpawn >= 1) then [_logDetail] call SC_fnc_log; }; } forEach _vehicleRoles; - - _group setBehaviour "CARELESS"; - _group setCombatMode "BLUE"; + // Get the AI to shut the fuck up :) enableSentences false; diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index a53acd0..d4321fb 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -24,7 +24,7 @@ _damagedEssentials = 0; { if ((_heli getHitPointDamage _x) > 0) then { - if(_x == "HitFuel") then + if(_x == "HitFuel" && _heliDamage < 1) then { _heli setHitPointDamage ["HitFuel", 0]; _heli setFuel 1; diff --git a/scripts/reactions/boatHit.sqf b/scripts/reactions/boatHit.sqf index e69de29..c373aa4 100644 --- a/scripts/reactions/boatHit.sqf +++ 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 index 09e0a0b..a2e6e5e 100644 --- a/scripts/reactions/comeUnstuck.sqf +++ b/scripts/reactions/comeUnstuck.sqf @@ -5,6 +5,8 @@ private["_vehicle","_curPos","_oldvehPos","_engineTime","_newPos"]; _vehicle = _this select 0; +if(isNil "_vehicle") exitWith{}; + if(count(crew _vehicle) > 0)then { _curPos = position _vehicle; diff --git a/scripts/startOccupation.sqf b/scripts/startOccupation.sqf index b3e598a..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 60; -_logDetail = format ["[OCCUPATION]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; +_logDetail = format ["[OCCUPATION]:: Occupation %2 Initialised at %1",time,SC_occupationVersion]; [_logDetail] call SC_fnc_log;