From 1c48de5f5e5feaefdbfb2db65b1b9ede23d1fc81 Mon Sep 17 00:00:00 2001 From: second_coming Date: Wed, 4 May 2016 09:57:54 +0100 Subject: [PATCH] V31 Roll Back Problems with versions after this which caused out of memory errors --- changeLog.txt | 37 --- config.sqf | 5 +- initServer.sqf | 4 +- readme.txt | 11 + scripts/functions/fnc_addMarker.sqf | 22 +- scripts/functions/fnc_selectGear.sqf | 4 +- scripts/occupationLog.sqf | 4 +- scripts/occupationMonitor.sqf | 61 ++--- scripts/occupationSea.sqf | 277 +++++++++++----------- scripts/occupationSky.sqf | 291 +++++++++++------------ scripts/occupationVehicle.sqf | 313 ++++++++++++------------- scripts/processReporter.sqf | 31 --- scripts/reactions/airHit.sqf | 38 ++- scripts/reactions/comeUnstuck.sqf | 14 +- scripts/reactions/driverKilled.sqf | 6 + scripts/reactions/getIn.sqf | 10 +- scripts/reactions/getOut.sqf | 32 +++ scripts/reactions/refuel.sqf | 18 ++ scripts/reactions/repairVehicle.sqf | 35 ++- scripts/reactions/unitMPHit.sqf | 2 +- scripts/reactions/unitMPKilled.sqf | 12 + scripts/reactions/vehicleDestroyed.sqf | 44 ++-- scripts/startOccupation.sqf | 21 +- 23 files changed, 643 insertions(+), 649 deletions(-) delete mode 100644 changeLog.txt create mode 100644 readme.txt delete mode 100644 scripts/processReporter.sqf diff --git a/changeLog.txt b/changeLog.txt deleted file mode 100644 index d6a183b..0000000 --- a/changeLog.txt +++ /dev/null @@ -1,37 +0,0 @@ -================================================================================= -V35 (03-05-2016) -================================================================================= -Fixed typo in an eventhandler - -================================================================================= -V34 (03-05-2016) -================================================================================= -Altered a lot of the eventhandler in an attempt to stop the out of memory errors - -================================================================================= -V33 (30-04-2016) -================================================================================= -Added server thread monitoring option for diagnosing server issues - -================================================================================= -V32 (29-04-2016) -================================================================================= -Added checks for valide vehicles in Sky, Sea and Vehicle modules - -================================================================================= -V28-V31 (27-04-2016) -================================================================================= -Altereed a few eventhandlers - -Fixed multiple static spawns so they are independent of each other - -================================================================================= -V27 (26-04-2016) -================================================================================= -Added the option fully control the gear assigned to bandit and survivor units - -Added the option for helicopters as public transport, the heli travels between traders and lands for about 60 seconds. Setting SC_occupyTransportClass to a helicopter classname will switch it over to using a helicopter, if you want to continue using the land vehicle set SC_occupyTransportClass to a land vehicle. - -Added the option to set the maximum crew (crew count will be a random number between the max and min). The applies for all AI vehicles. - -Added a separate SC_VehicleClassToUseRare list of vehicles which spawn 10% of the time in place of the standard SC_VehicleClassToUse list. \ No newline at end of file diff --git a/config.sqf b/config.sqf index 3511713..07aad35 100644 --- a/config.sqf +++ b/config.sqf @@ -13,9 +13,8 @@ // Shared Config for each occupation monitor -SC_debug = false; // set to true to turn on debug features (not for live servers) -SC_extendedLogging = false; // set to true for additional logging -SC_processReporter = true; // true if you want to log server threads every 60 seconds (useful to spot problems on the server) +SC_debug = false; // set to true to turn on debug features (not for live servers) +SC_extendedLogging = false; // set to true for additional logging SC_infiSTAR_log = true; // true Use infiSTAR logging, false logs to server rpt SC_maxAIcount = 100; // the maximum amount of AI, if the AI count is above this then additional AI won't spawn SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false diff --git a/initServer.sqf b/initServer.sqf index e27c7b0..f3ca97e 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v35 (03-05-2016)"; +SC_occupationVersion = "v31 (04-05-2016) Roll back"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -24,7 +24,7 @@ SC_occupationVersion = "v35 (03-05-2016)"; { diag_log format ["[OCCUPATION]:: Occupation %2 Giving the server time to start before starting [OCCUPATION] (%1)",time,SC_occupationVersion]; waitUntil { !(isNil "DMS_MinMax_Y_Coords") }; - + sleep 10; diag_log format ["[OCCUPATION MOD]:: Occupation %2 Loading Config at %1",time,SC_occupationVersion]; diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..0d6c9f0 --- /dev/null +++ b/readme.txt @@ -0,0 +1,11 @@ +An AI spawner and monitor to be used in conjunction with DMS and will not work without it: 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 + +To install place the pbo into the @ExileServer/addons folder + +For more info: http://www.exilemod.com/topic/12517-release-exile-occupation-roaming-ai + +I do not give permission for anyone to sell or charge for the installation of any part of this set of scripts. + +second_coming 2016 \ No newline at end of file diff --git a/scripts/functions/fnc_addMarker.sqf b/scripts/functions/fnc_addMarker.sqf index c515574..ea22adc 100644 --- a/scripts/functions/fnc_addMarker.sqf +++ b/scripts/functions/fnc_addMarker.sqf @@ -3,7 +3,25 @@ private["_newUniform","_newVest","_newHeadgear","_arrowClass"]; _side = _this select 0; _unit = _this select 1; -if(_side == "survivor") then +_unit removeAllMPEventHandlers "mphit"; + + +switch (_side) do { - _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; + case "survivor": + { + _arrowClass = "Sign_Arrow_Green_F"; + _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; + }; + case "bandit": + { + _arrowClass = "Sign_Arrow_F"; + }; }; + +if(SC_debug) then +{ + _tag = createVehicle [_arrowClass, position _unit, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_unit,[0,0,0.6],"Head"]; +}; +_unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; \ No newline at end of file diff --git a/scripts/functions/fnc_selectGear.sqf b/scripts/functions/fnc_selectGear.sqf index 8f23298..68061e2 100644 --- a/scripts/functions/fnc_selectGear.sqf +++ b/scripts/functions/fnc_selectGear.sqf @@ -24,7 +24,7 @@ switch (_side) do for "_i" from 1 to _amountOfMagazines do { _newMagazine = SC_SurvivorMagazines call BIS_fnc_selectRandom; - _quantity = 1; + _quantity = 1 + round random (2); _magazines pushBack [_newMagazine,_quantity]; }; }; @@ -63,7 +63,7 @@ _pistolAttachmentsChance = round (random 100); if(_pistolAttachmentsChance < 50) then { _pistolAttachments = [""]; }; _backpackChance = round (random 100); -if(_backpackChance < 20) then { _backpack = ""; }; +if(_backpackChance < 40) then { _backpack = ""; }; _launcherChance = round (random 100); if(_launcherChance < 40 OR isNil "_launcher") then { _launcher = ""; }; diff --git a/scripts/occupationLog.sqf b/scripts/occupationLog.sqf index 7751544..40c5f7e 100644 --- a/scripts/occupationLog.sqf +++ b/scripts/occupationLog.sqf @@ -2,9 +2,7 @@ _logDetail = _this select 0; -if(isNil "INFISTARVERSION") then { SC_infiSTAR_log = false; }; - -if(SC_infiSTAR_log) then +if(SC_infiSTAR_log && !isNil "INFISTARVERSION") then { ['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG; } diff --git a/scripts/occupationMonitor.sqf b/scripts/occupationMonitor.sqf index e2283ee..dab107f 100644 --- a/scripts/occupationMonitor.sqf +++ b/scripts/occupationMonitor.sqf @@ -2,52 +2,35 @@ _logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; [_logDetail] call SC_fnc_log; { - if(!isNull _x) then + _logDetail = format ["[OCCUPATION:Unstick]:: Air: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + sleep 5; + _originalSpawnLocation = _x getVariable "SC_vehicleSpawnLocation"; + _pos = position _x; + _nearestMarker = [allMapMarkers, _pos] call BIS_fnc_nearestPosition; // Nearest Marker to the Location + _posNearestMarker = getMarkerPos _nearestMarker; + if(_pos distance _posNearestMarker < 750) then { - _logDetail = format ["[OCCUPATION:Unstick]:: Air: %1 is active",_x]; - [_logDetail] call SC_fnc_log; - _x setFuel 1; - [_x] call SC_fnc_comeUnstuck; - sleep 5; - } - else - { - SC_liveHelis = SC_liveHelis - 1; - SC_liveHelisArray = SC_liveHelisArray - [_x]; - }; - + _GroupLeader = leader (group _x); + _GroupLeader doMove _originalSpawnLocation; + }; }forEach SC_liveHelisArray; { - if(!isNull _x) then - { - _logDetail = format ["[OCCUPATION:Unstick]:: Land: %1 is active",_x]; - [_logDetail] call SC_fnc_log; - _x setFuel 1; - [_x] call SC_fnc_comeUnstuck; - sleep 5; - } - else - { - SC_liveVehicles = SC_liveVehicles - 1; - SC_liveVehiclesArray = SC_liveVehiclesArray - [_x]; - }; + _logDetail = format ["[OCCUPATION:Unstick]:: Land: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; }forEach SC_liveVehiclesArray; { - if(!isNull _x) then - { - _logDetail = format ["[OCCUPATION:Unstick]:: Sea: %1 is active",_x]; - [_logDetail] call SC_fnc_log; - _x setFuel 1; - [_x] call SC_fnc_comeUnstuck; - sleep 5; - } - else - { - SC_liveBoats = SC_liveBoats - 1; - SC_liveBoatsArray = SC_liveBoatsArray - [_x]; - }; + _logDetail = format ["[OCCUPATION:Unstick]:: Sea: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; }forEach SC_liveBoatsArray; diff --git a/scripts/occupationSea.sqf b/scripts/occupationSea.sqf index 8b4b799..3ed212a 100644 --- a/scripts/occupationSea.sqf +++ b/scripts/occupationSea.sqf @@ -44,162 +44,153 @@ for "_i" from 1 to _vehiclesToSpawn do { private["_group"]; _spawnLocation = [ 250, 0, 1, 1000, 1000, 1000, 1000, 1000, true, true ] call DMS_fnc_findSafePos; - + _group = createGroup SC_BanditSide; _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]; - if(!isNil "_vehicle") then + // Remove the overpowered weapons from boats + _vehicle removeWeaponTurret ["HMG_01",[0]]; + _vehicle removeWeaponTurret ["GMG_40mm",[0]]; + + SC_liveBoats = SC_liveBoats + 1; + SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle]; + + _vehicle setVehiclePosition [_spawnLocation, [], 0, "NONE"]; + _vehicle setVariable ["vehicleID", _spawnLocation, true]; + _vehicle setFuel 1; + _vehicle setDamage 0; + _vehicle engineOn true; + _vehicle lock 0; + _vehicle setVehicleLock "UNLOCKED"; + _vehicle setVariable ["ExileIsLocked", 0, true]; + _vehicle action ["LightOn", _vehicle]; + sleep 0.2; + _group addVehicle _vehicle; + + // Calculate the number of seats in the vehicle and fill the required amount + _crewRequired = SC_minimumCrewAmount; + if(SC_maximumCrewAmount > SC_minimumCrewAmount) then + { + _crewRequired = floor(random[SC_minimumCrewAmount,SC_maximumCrewAmount-SC_minimumCrewAmount,SC_maximumCrewAmount]); + }; + _amountOfCrew = 0; + _unitPlaced = false; + _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; { - _group = createGroup SC_BanditSide; - _vehicle setPosASL _spawnLocation; - _vehicle setVariable["vehPos",_spawnLocation,true]; - _vehicle setVariable["vehClass",_VehicleClassToUse,true]; - _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - - // Remove the overpowered weapons from boats - _vehicle removeWeaponTurret ["HMG_01",[0]]; - _vehicle removeWeaponTurret ["GMG_40mm",[0]]; - - SC_liveBoats = SC_liveBoats + 1; - SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle]; - - _vehicle setVehiclePosition [_spawnLocation, [], 0, "NONE"]; - _vehicle setVariable ["vehicleID", _spawnLocation, true]; - _vehicle setFuel 1; - _vehicle setDamage 0; - _vehicle engineOn true; - _vehicle lock 0; - _vehicle setVehicleLock "UNLOCKED"; - _vehicle setVariable ["ExileIsLocked", 0, true]; - _vehicle action ["LightOn", _vehicle]; - sleep 0.2; - _group addVehicle _vehicle; - - // Calculate the number of seats in the vehicle and fill the required amount - _crewRequired = SC_minimumCrewAmount; - if(SC_maximumCrewAmount > SC_minimumCrewAmount) then - { - _crewRequired = floor(random[SC_minimumCrewAmount,SC_maximumCrewAmount-SC_minimumCrewAmount,SC_maximumCrewAmount]); - }; - _amountOfCrew = 0; _unitPlaced = false; - _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; + _vehicleRole = _x select 0; + _vehicleSeat = _x select 1; + if(_vehicleRole == "Driver") then { - _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; - _amountOfCrew = _amountOfCrew + 1; - _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; - _amountOfCrew = _amountOfCrew + 1; - _unit moveInTurret [_vehicle, _vehicleSeat]; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - _unitPlaced = true; - }; - if(_vehicleRole == "CARGO" && _amountOfCrew < _crewRequired) then - { - _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; - _amountOfCrew = _amountOfCrew + 1; - _unit assignAsCargo _vehicle; - _unit moveInCargo _vehicle; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - _unitPlaced = true; - }; + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + _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; + _amountOfCrew = _amountOfCrew + 1; + _unit moveInTurret [_vehicle, _vehicleSeat]; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unitPlaced = true; + }; + if(_vehicleRole == "CARGO" && _amountOfCrew < _crewRequired) then + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + _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; - - { - _unit = _x; - [_unit] joinSilent grpNull; - [_unit] joinSilent _group; - }foreach units _group; - - if(SC_infiSTAR_log) then + if(SC_extendedLogging && _unitPlaced) then { - _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; + _logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle]; [_logDetail] call SC_fnc_log; - }; + }; + } forEach _vehicleRoles; + + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + }foreach units _group; - - clearMagazineCargoGlobal _vehicle; - clearWeaponCargoGlobal _vehicle; - clearItemCargoGlobal _vehicle; + if(SC_infiSTAR_log) then + { + _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; + [_logDetail] call SC_fnc_log; + }; - _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; - _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; - _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; - - // Add weapons with ammo to the vehicle - _possibleWeapons = - [ - "arifle_MXM_Black_F", - "arifle_MXM_F", - "srifle_DMR_01_F", - "srifle_DMR_02_camo_F", - "srifle_DMR_02_F", - "srifle_DMR_02_sniper_F", - "srifle_DMR_03_F", - "srifle_DMR_03_khaki_F", - "srifle_DMR_03_multicam_F", - "srifle_DMR_03_tan_F", - "srifle_DMR_03_woodland_F", - "srifle_DMR_04_F", - "srifle_DMR_04_Tan_F", - "srifle_DMR_05_blk_F", - "srifle_DMR_05_hex_F", - "srifle_DMR_05_tan_f", - "srifle_DMR_06_camo_F", - "srifle_DMR_06_olive_F", - "srifle_EBR_F", - "srifle_GM6_camo_F", - "srifle_GM6_F", - "srifle_LRR_camo_F", - "srifle_LRR_F" - ]; - _amountOfWeapons = 1 + (random 3); - - for "_i" from 1 to _amountOfWeapons do - { - _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; - _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; - - _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); - _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; - }; + + clearMagazineCargoGlobal _vehicle; + clearWeaponCargoGlobal _vehicle; + clearItemCargoGlobal _vehicle; - - [_group, _spawnLocation, 4000] call bis_fnc_taskPatrol; - _group setBehaviour "AWARE"; - _group setCombatMode "RED"; - _vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; - _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; - _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_boatHit;"]; - _vehicle setVariable ["SC_crewEjected", false,true]; - sleep 0.2; - - } - else - { - _logDetail = format['[OCCUPATION:Sea] Vehicle %1 failed to spawn @ %2',_VehicleClassToUse, _spawnLocation]; - [_logDetail] call SC_fnc_log; - }; + _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; + _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; + _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; + + // Add weapons with ammo to the vehicle + _possibleWeapons = + [ + "arifle_MXM_Black_F", + "arifle_MXM_F", + "srifle_DMR_01_F", + "srifle_DMR_02_camo_F", + "srifle_DMR_02_F", + "srifle_DMR_02_sniper_F", + "srifle_DMR_03_F", + "srifle_DMR_03_khaki_F", + "srifle_DMR_03_multicam_F", + "srifle_DMR_03_tan_F", + "srifle_DMR_03_woodland_F", + "srifle_DMR_04_F", + "srifle_DMR_04_Tan_F", + "srifle_DMR_05_blk_F", + "srifle_DMR_05_hex_F", + "srifle_DMR_05_tan_f", + "srifle_DMR_06_camo_F", + "srifle_DMR_06_olive_F", + "srifle_EBR_F", + "srifle_GM6_camo_F", + "srifle_GM6_F", + "srifle_LRR_camo_F", + "srifle_LRR_F" + ]; + _amountOfWeapons = 1 + (random 3); + + for "_i" from 1 to _amountOfWeapons do + { + _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; + _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; + + _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); + _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + }; + + + [_group, _spawnLocation, 4000] call bis_fnc_taskPatrol; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + _vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; + _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_boatHit;"]; + _vehicle setVariable ["SC_crewEjected", false,true]; + sleep 0.2; + }; + _logDetail = format['[OCCUPATION:Sea] Running']; [_logDetail] call SC_fnc_log; \ No newline at end of file diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index b9b6539..e655f4c 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -68,162 +68,155 @@ for "_i" from 1 to _vehiclesToSpawn do _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 SC_BanditSide; _VehicleClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom; - _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; - if(!isNil "_vehicle") then - { - _group = createGroup SC_BanditSide; - _group addVehicle _vehicle; - _vehicle setVariable["vehPos",_spawnLocation,true]; - _vehicle setVariable["vehClass",_VehicleClassToUse,true]; - _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; + _group addVehicle _vehicle; + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - SC_liveHelis = SC_liveHelis + 1; - SC_liveHelisArray = SC_liveHelisArray + [_vehicle]; + SC_liveHelis = SC_liveHelis + 1; + SC_liveHelisArray = SC_liveHelisArray + [_vehicle]; - _vehicle setVehiclePosition [_spawnLocation, [], 0, "FLY"]; - _vehicle setVariable ["vehicleID", _spawnLocation, true]; - _vehicle setFuel 1; - _vehicle setDamage 0; - _vehicle engineOn true; - _vehicle flyInHeight 150; - _vehicle lock 0; - _vehicle setVehicleLock "UNLOCKED"; - _vehicle setVariable ["ExileIsLocked", 0, true]; - _vehicle action ["LightOn", _vehicle]; - - // Calculate the number of seats in the vehicle and fill the required amount - _crewRequired = SC_minimumCrewAmount; - if(SC_maximumCrewAmount > SC_minimumCrewAmount) then - { - _crewRequired = floor(random[SC_minimumCrewAmount,SC_maximumCrewAmount-SC_minimumCrewAmount,SC_maximumCrewAmount]); - }; - _amountOfCrew = 0; - _unitPlaced = false; - _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; - { - _unitPlaced = false; - _vehicleRole = _x select 0; - _vehicleSeat = _x select 1; - if(_vehicleRole == "Driver") then - { - _loadOut = ["bandit"] call SC_fnc_selectGear; - _unit = [_group,_spawnLocation,"custom","random","bandit","Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; - _amountOfCrew = _amountOfCrew + 1; - _unit assignAsDriver _vehicle; - _unit moveInDriver _vehicle; - //_vehicle lockDriver true; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - removeBackpackGlobal _unit; - _unit addBackpackGlobal "B_Parachute"; - _unitPlaced = true; - }; - if(_vehicleRole == "Turret") then - { - _loadOut = ["bandit"] call SC_fnc_selectGear; - _unit = [_group,_spawnLocation,"custom","random","bandit","Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; - _amountOfCrew = _amountOfCrew + 1; - _unit moveInTurret [_vehicle, _vehicleSeat]; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - removeBackpackGlobal _unit; - _unit addBackpackGlobal "B_Parachute"; - _unitPlaced = true; - }; - if(_vehicleRole == "CARGO" && _amountOfCrew < _crewRequired) then - { - _loadOut = ["bandit"] call SC_fnc_selectGear; - _unit = [_group,_spawnLocation,"custom","random","bandit","Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; - _amountOfCrew = _amountOfCrew + 1; - _unit assignAsCargo _vehicle; - _unit moveInCargo _vehicle; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - removeBackpackGlobal _unit; - _unit addBackpackGlobal "B_Parachute"; - _unitPlaced = true; - }; - if(SC_extendedLogging) then - { - _logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle]; - [_logDetail] call SC_fnc_log; - }; - } forEach _vehicleRoles; + _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 number of seats in the vehicle and fill the required amount + _crewRequired = SC_minimumCrewAmount; + if(SC_maximumCrewAmount > SC_minimumCrewAmount) then + { + _crewRequired = floor(random[SC_minimumCrewAmount,SC_maximumCrewAmount-SC_minimumCrewAmount,SC_maximumCrewAmount]); + }; + _amountOfCrew = 0; + _unitPlaced = false; + _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; + { + _unitPlaced = false; + _vehicleRole = _x select 0; + _vehicleSeat = _x select 1; + if(_vehicleRole == "Driver") then + { + _loadOut = ["bandit"] call SC_fnc_selectGear; + _unit = [_group,_spawnLocation,"custom","random","bandit","Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + _unit assignAsDriver _vehicle; + _unit moveInDriver _vehicle; + //_vehicle lockDriver true; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + _unitPlaced = true; + }; + if(_vehicleRole == "Turret") then + { + _loadOut = ["bandit"] call SC_fnc_selectGear; + _unit = [_group,_spawnLocation,"custom","random","bandit","Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + _unit moveInTurret [_vehicle, _vehicleSeat]; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + _unitPlaced = true; + }; + if(_vehicleRole == "CARGO" && _amountOfCrew < _crewRequired) then + { + _loadOut = ["bandit"] call SC_fnc_selectGear; + _unit = [_group,_spawnLocation,"custom","random","bandit","Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + _unit assignAsCargo _vehicle; + _unit moveInCargo _vehicle; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + _unitPlaced = true; + }; + if(SC_extendedLogging) then + { + _logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle]; + [_logDetail] call SC_fnc_log; + }; + } forEach _vehicleRoles; - { - _unit = _x; - [_unit] joinSilent grpNull; - [_unit] joinSilent _group; - }foreach units _group; + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + }foreach units _group; - if(SC_extendedLogging && _unitPlaced) then - { - _logDetail = format['[OCCUPATION:Sky] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; - [_logDetail] call SC_fnc_log; - }; - - clearMagazineCargoGlobal _vehicle; - clearWeaponCargoGlobal _vehicle; - clearItemCargoGlobal _vehicle; - - _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; - _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; - _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; - - // Add weapons with ammo to the vehicle - _possibleWeapons = - [ - "arifle_MXM_Black_F", - "arifle_MXM_F", - "srifle_DMR_01_F", - "srifle_DMR_02_camo_F", - "srifle_DMR_02_F", - "srifle_DMR_02_sniper_F", - "srifle_DMR_03_F", - "srifle_DMR_03_khaki_F", - "srifle_DMR_03_multicam_F", - "srifle_DMR_03_tan_F", - "srifle_DMR_03_woodland_F", - "srifle_DMR_04_F", - "srifle_DMR_04_Tan_F", - "srifle_DMR_05_blk_F", - "srifle_DMR_05_hex_F", - "srifle_DMR_05_tan_f", - "srifle_DMR_06_camo_F", - "srifle_DMR_06_olive_F", - "srifle_EBR_F", - "srifle_GM6_camo_F", - "srifle_GM6_F", - "srifle_LRR_camo_F", - "srifle_LRR_F" - ]; - _amountOfWeapons = 1 + (random 3); - - for "_i" from 1 to _amountOfWeapons do - { - _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; - _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; - - _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); - _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; - }; - - - [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; - _group setBehaviour "AWARE"; - _group setCombatMode "RED"; - _vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; - _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; - _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; - _vehicle setVariable ["SC_crewEjected", false,true]; - sleep 0.2; - } - else - { - _logDetail = format['[OCCUPATION:Sky] Vehicle %1 failed to spawn @ %2',_VehicleClassToUse, _spawnLocation]; - [_logDetail] call SC_fnc_log; + if(SC_extendedLogging && _unitPlaced) then + { + _logDetail = format['[OCCUPATION:Sky] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; + [_logDetail] call SC_fnc_log; }; + + clearMagazineCargoGlobal _vehicle; + clearWeaponCargoGlobal _vehicle; + clearItemCargoGlobal _vehicle; + + _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; + _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; + _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; + + // Add weapons with ammo to the vehicle + _possibleWeapons = + [ + "arifle_MXM_Black_F", + "arifle_MXM_F", + "srifle_DMR_01_F", + "srifle_DMR_02_camo_F", + "srifle_DMR_02_F", + "srifle_DMR_02_sniper_F", + "srifle_DMR_03_F", + "srifle_DMR_03_khaki_F", + "srifle_DMR_03_multicam_F", + "srifle_DMR_03_tan_F", + "srifle_DMR_03_woodland_F", + "srifle_DMR_04_F", + "srifle_DMR_04_Tan_F", + "srifle_DMR_05_blk_F", + "srifle_DMR_05_hex_F", + "srifle_DMR_05_tan_f", + "srifle_DMR_06_camo_F", + "srifle_DMR_06_olive_F", + "srifle_EBR_F", + "srifle_GM6_camo_F", + "srifle_GM6_F", + "srifle_LRR_camo_F", + "srifle_LRR_F" + ]; + _amountOfWeapons = 1 + (random 3); + + for "_i" from 1 to _amountOfWeapons do + { + _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; + _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; + + _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); + _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + }; + + + [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + _vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; + _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; + _vehicle setVariable ["SC_crewEjected", false,true]; + sleep 0.2; + }; diff --git a/scripts/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index 04f4519..17dbb7e 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -103,11 +103,22 @@ if(_vehiclesToSpawn >= 1) then _pos = [_position,10,250,5,0,20,0] call BIS_fnc_findSafePos; // Get position of nearest roads - _nearRoads = _pos nearRoads 2000; + _nearRoads = _pos nearRoads 500; _nearestRoad = _nearRoads select 0; _nearestRoad = position (_nearRoads select 0); _spawnLocation = [_nearestRoad select 0, _pos select 1, 0]; + _group = createGroup SC_BanditSide; + if(_side == "survivor") then + { + deleteGroup _group; + _group = createGroup SC_SurvivorSide; + }; + + _group setVariable ["DMS_LockLocality",nil]; + _group setVariable ["DMS_SpawnedGroup",true]; + _group setVariable ["DMS_Group_Side", _side]; + _VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom; // Percentage chance to spawn a rare vehicle @@ -119,170 +130,154 @@ if(_vehiclesToSpawn >= 1) then _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; + _group addVehicle _vehicle; + + SC_liveVehicles = SC_liveVehicles + 1; + SC_liveVehiclesArray = SC_liveVehiclesArray + [_vehicle]; + + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; + _vehicle setFuel 1; + _vehicle engineOn true; - if(!isNil "_vehicle") then + if(SC_occupyVehiclesLocked) then { - _group = createGroup SC_BanditSide; - if(_side == "survivor") then - { - deleteGroup _group; - _group = createGroup SC_SurvivorSide; - }; - - _group setVariable ["DMS_LockLocality",nil]; - _group setVariable ["DMS_SpawnedGroup",true]; - _group setVariable ["DMS_Group_Side", _side]; - - _group 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; - - if(SC_occupyVehiclesLocked) then - { - _vehicle lock 2; - _vehicle setVehicleLock "LOCKED"; - _vehicle setVariable ["ExileIsLocked", 1, true]; - } - else - { - _vehicle lock 0; - _vehicle setVehicleLock "UNLOCKED"; - _vehicle setVariable ["ExileIsLocked", 0, true]; - }; - - _vehicle setSpeedMode "LIMITED"; - _vehicle limitSpeed 60; - _vehicle action ["LightOn", _vehicle]; - - // Calculate the number of seats in the vehicle and fill the required amount - _crewRequired = SC_minimumCrewAmount; - if(SC_maximumCrewAmount > SC_minimumCrewAmount) then - { - _crewRequired = floor(random[SC_minimumCrewAmount,SC_maximumCrewAmount-SC_minimumCrewAmount,SC_maximumCrewAmount]); - }; - _amountOfCrew = 0; - _unitPlaced = false; - _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; - { - _unitPlaced = false; - _vehicleRole = _x select 0; - _vehicleSeat = _x select 1; - if(_vehicleRole == "Driver") then - { - _loadOut = [_side] call SC_fnc_selectGear; - _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; - _amountOfCrew = _amountOfCrew + 1; - _unit disableAI "FSM"; - [_side,_unit] call SC_fnc_addMarker; - _unit removeAllMPEventHandlers "mphit"; - _unit removeAllMPEventHandlers "mpkilled"; - _unit disableAI "TARGET"; - _unit disableAI "AUTOTARGET"; - _unit disableAI "AUTOCOMBAT"; - _unit disableAI "COVER"; - _unit disableAI "SUPPRESSION"; - _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 addEventHandler ["getout", "_this call SC_fnc_getOut;"]; - _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; - _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; - }; - if(_vehicleRole == "Turret" && _amountOfCrew < _crewRequired) then - { - _loadOut = [_side] call SC_fnc_selectGear; - _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; - _amountOfCrew = _amountOfCrew + 1; - [_side,_unit] call SC_fnc_addMarker; - _unit moveInTurret [_vehicle, _vehicleSeat]; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; - _unitPlaced = true; - }; - if(_vehicleRole == "CARGO" && _amountOfCrew < _crewRequired) then - { - _loadOut = [_side] call SC_fnc_selectGear; - _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; - _amountOfCrew = _amountOfCrew + 1; - [_side,_unit] call SC_fnc_addMarker; - _unit assignAsCargo _vehicle; - _unit moveInCargo _vehicle; - _unit setVariable ["DMS_AssignedVeh",_vehicle]; - _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; - _unitPlaced = true; - }; - if(SC_extendedLogging && _unitPlaced) then - { - _logDetail = format['[OCCUPATION:Vehicle] %1 %2 added to vehicle %3',_side,_vehicleRole,_vehicle]; - [_logDetail] call SC_fnc_log; - }; - if(_amountOfCrew == _crewRequired) exitWith{}; - } forEach _vehicleRoles; - - // Get the AI to shut the fuck up :) - enableSentences false; - enableRadio false; - - _logDetail = format['[OCCUPATION:Vehicle] %3 vehicle %1 spawned @ %2',_VehicleClassToUse,_spawnLocation,_side]; - [_logDetail] call SC_fnc_log; - sleep 15; - - { - _x enableAI "FSM"; - }forEach units _group; - - [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; - _group setBehaviour "SAFE"; - _group setCombatMode "RED"; - sleep 0.2; - - clearMagazineCargoGlobal _vehicle; - clearWeaponCargoGlobal _vehicle; - clearItemCargoGlobal _vehicle; - - _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; - _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; - _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; - - // Add weapons with ammo to the vehicle - _possibleWeapons = - [ - "arifle_MXM_Black_F", - "arifle_MXM_F", - "arifle_MX_SW_Black_F", - "arifle_MX_SW_F", - "LMG_Mk200_F", - "LMG_Zafir_F" - ]; - _amountOfWeapons = 1 + (random 3); - - for "_i" from 1 to _amountOfWeapons do - { - _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; - _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; - - _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); - _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; - }; + _vehicle lock 2; + _vehicle setVehicleLock "LOCKED"; + _vehicle setVariable ["ExileIsLocked", 1, true]; } else { - _logDetail = format['[OCCUPATION:Vehicle] Vehicle %1 failed to spawn @ %2',_VehicleClassToUse, _spawnLocation]; - [_logDetail] call SC_fnc_log; + _vehicle lock 0; + _vehicle setVehicleLock "UNLOCKED"; + _vehicle setVariable ["ExileIsLocked", 0, true]; }; + + _vehicle setSpeedMode "LIMITED"; + _vehicle limitSpeed 60; + _vehicle action ["LightOn", _vehicle]; + + + + + + // Calculate the number of seats in the vehicle and fill the required amount + _crewRequired = SC_minimumCrewAmount; + if(SC_maximumCrewAmount > SC_minimumCrewAmount) then + { + _crewRequired = floor(random[SC_minimumCrewAmount,SC_maximumCrewAmount-SC_minimumCrewAmount,SC_maximumCrewAmount]); + }; + _amountOfCrew = 0; + _unitPlaced = false; + _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; + { + _unitPlaced = false; + _vehicleRole = _x select 0; + _vehicleSeat = _x select 1; + if(_vehicleRole == "Driver") then + { + _loadOut = [_side] call SC_fnc_selectGear; + _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + _unit disableAI "FSM"; + [_side,_unit] call SC_fnc_addMarker; + _unit removeAllMPEventHandlers "mphit"; + _unit removeAllMPEventHandlers "mpkilled"; + _unit disableAI "TARGET"; + _unit disableAI "AUTOTARGET"; + _unit disableAI "AUTOCOMBAT"; + _unit disableAI "COVER"; + _unit disableAI "SUPPRESSION"; + _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 addEventHandler ["getout", "_this call SC_fnc_getOut;"]; + _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; + }; + if(_vehicleRole == "Turret" && _amountOfCrew < _crewRequired) then + { + _loadOut = [_side] call SC_fnc_selectGear; + _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + [_side,_unit] call SC_fnc_addMarker; + _unit moveInTurret [_vehicle, _vehicleSeat]; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; + _unitPlaced = true; + }; + if(_vehicleRole == "CARGO" && _amountOfCrew < _crewRequired) then + { + _loadOut = [_side] call SC_fnc_selectGear; + _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; + _amountOfCrew = _amountOfCrew + 1; + [_side,_unit] call SC_fnc_addMarker; + _unit assignAsCargo _vehicle; + _unit moveInCargo _vehicle; + _unit setVariable ["DMS_AssignedVeh",_vehicle]; + _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; + _unitPlaced = true; + }; + if(SC_extendedLogging && _unitPlaced) then + { + _logDetail = format['[OCCUPATION:Vehicle] %1 %2 added to vehicle %3',_side,_vehicleRole,_vehicle]; + [_logDetail] call SC_fnc_log; + }; + if(_amountOfCrew == _crewRequired) exitWith{}; + } forEach _vehicleRoles; + + // Get the AI to shut the fuck up :) + enableSentences false; + enableRadio false; + + _logDetail = format['[OCCUPATION:Vehicle] %3 vehicle %1 spawned @ %2',_VehicleClassToUse,_spawnLocation,_side]; + [_logDetail] call SC_fnc_log; + sleep 15; + + { + _x enableAI "FSM"; + }forEach units _group; + + [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; + _group setBehaviour "SAFE"; + _group setCombatMode "RED"; + sleep 0.2; + + clearMagazineCargoGlobal _vehicle; + clearWeaponCargoGlobal _vehicle; + clearItemCargoGlobal _vehicle; + + _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; + _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; + _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; + + // Add weapons with ammo to the vehicle + _possibleWeapons = + [ + "arifle_MXM_Black_F", + "arifle_MXM_F", + "arifle_MX_SW_Black_F", + "arifle_MX_SW_F", + "LMG_Mk200_F", + "LMG_Zafir_F" + ]; + _amountOfWeapons = 1 + (random 3); + + for "_i" from 1 to _amountOfWeapons do + { + _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; + _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; + + _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); + _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + }; }; }; diff --git a/scripts/processReporter.sqf b/scripts/processReporter.sqf deleted file mode 100644 index 28aa65e..0000000 --- a/scripts/processReporter.sqf +++ /dev/null @@ -1,31 +0,0 @@ -if(!isNil "INFISTARVERSION") then -{ - _logDetail = "======================================================================================================="; - ['A3_EXILE_PROCESSREPORTER',_logDetail] call FNC_A3_CUSTOMLOG; - - _logDetail = format['[processReporter] Started @ %4 : [FPS: %1|PLAYERS: %2|THREADS: %3]',diag_fps,count allplayers,count diag_activeSQFScripts,time]; - ['A3_EXILE_PROCESSREPORTER',_logDetail] call FNC_A3_CUSTOMLOG; - - _logDetail = "======================================================================================================="; - ['A3_EXILE_PROCESSREPORTER',_logDetail] call FNC_A3_CUSTOMLOG; - - { - _logDetail = format ["[processReporter] %1 @ %2",_x,time]; - ['A3_EXILE_PROCESSREPORTER',_logDetail] call FNC_A3_CUSTOMLOG; - } forEach diag_activeSQFScripts; - - _logDetail = format ["[processReporter] Ended @ %1",time]; - ['A3_EXILE_PROCESSREPORTER',_logDetail] call FNC_A3_CUSTOMLOG; -} -else -{ - diag_log "======================================================================================================="; - diag_log format['[processReporter] Started @ %4 : [FPS: %1|PLAYERS: %2|THREADS: %3]',diag_fps,count allplayers,count diag_activeSQFScripts,time]; - diag_log "======================================================================================================="; - { - diag_log format ["[processReporter] %1 @ %2",_x,time]; - } forEach diag_activeSQFScripts; - diag_log format ["[processReporter] Ended @ %1",time]; -}; - - diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index 486ed06..0d377b6 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -16,7 +16,31 @@ if(SC_extendedLogging) then }; _ejectChance = round (random 100) + (_heliDamage * 100); -if(_heliDamage > 0.2 && !_crewEjected && _ejectChance > 100) then + +_essentials = [ "HitAvionics","HitEngine1","HitEngine2","HitEngine","HitHRotor","HitVRotor","HitTransmission", + "HitHydraulics","HitGear","HitHStabilizerL1","HitHStabilizerR1","HitVStabilizer1","HitFuel"]; + +_damagedEssentials = 0; +{ + if ((_heli getHitPointDamage _x) > 0) then + { + if(_x == "HitFuel" && _heliDamage < 1) then + { + _heli setHitPointDamage ["HitFuel", 0]; + _heli setFuel 1; + }; + _damage = _heli getHitPointDamage _x; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Sky]:: Heli %1 checking part %2 (damage: %4) @ %3",_heli, _x, time,_damage]; + [_logDetail] call SC_fnc_log; + }; + if(_damage > 0) then { _damagedEssentials = _damagedEssentials + 1; }; + }; +} forEach _essentials; + + +if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 100) then { _target = _this select 1; [_heli, _target] spawn @@ -57,10 +81,9 @@ if(_heliDamage > 0.2 && !_crewEjected && _ejectChance > 100) then }; -if(_heliDamage > 0.7) then +if(_heliDamage > 0.7 && _damagedEssentials > 0) then { - _heli = _this select 0; - if(SC_extendedLogging) 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; @@ -86,14 +109,11 @@ if(_heliDamage > 0.7) then _wp setWaypointBehaviour "COMBAT"; _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 10; - _wp setWaypointType "TR UNLOAD"; + _wp setWaypointType "GETOUT"; [_group2, _destination, 250] call bis_fnc_taskPatrol; _group2 setBehaviour "COMBAT"; _group2 setCombatMode "RED"; }; -if(_heliDamage <= 0.7) then -{ - _heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; -}; \ No newline at end of file +_heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; \ No newline at end of file diff --git a/scripts/reactions/comeUnstuck.sqf b/scripts/reactions/comeUnstuck.sqf index 477071f..bdbf9c4 100644 --- a/scripts/reactions/comeUnstuck.sqf +++ b/scripts/reactions/comeUnstuck.sqf @@ -33,11 +33,6 @@ if(count(crew _vehicle) > 0)then _vehicle setVectorUp [0,0,1]; _originalSpawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; - - if(isNil "_originalSpawnLocation") then - { - _originalSpawnLocation = [_curPos, 50, 1000, 3, 2, 20, 0] call BIS_fnc_findSafePos; - }; _group = group _vehicle; _vehClass = typeOf _vehicle; @@ -73,14 +68,17 @@ if(count(crew _vehicle) > 0)then _vehicle setVariable["vehPos",_newPos]; }; -// Remove dead units from the group _group = group _vehicle; + +// Remove dead units from the group { if(!alive _x) then { [_x] join grpNull; }; }forEach units _group; -if(count units _group < 1) then +if(count units _group > 0) then { - _vehicle call SC_fnc_vehicleDestroyed; + _vehicle lock 0; + _vehicle setVehicleLock "UNLOCKED"; + _vehicle setVariable ["ExileIsLocked", 0, true]; }; diff --git a/scripts/reactions/driverKilled.sqf b/scripts/reactions/driverKilled.sqf index 1ef1541..deaf3be 100644 --- a/scripts/reactions/driverKilled.sqf +++ b/scripts/reactions/driverKilled.sqf @@ -50,6 +50,12 @@ if(count units _group > 0) then _driver removeAllMPEventHandlers "mphit"; _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; + if(SC_debug) then + { + _tag = createVehicle ["Sign_Arrow_Yellow_F", position _driver, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_driver,[0,0,0.6],"Head"]; + }; + _driver doMove (position _vehicle); _driver action ["movetodriver", _vehicle]; diff --git a/scripts/reactions/getIn.sqf b/scripts/reactions/getIn.sqf index 06e5c4b..e70bd22 100644 --- a/scripts/reactions/getIn.sqf +++ b/scripts/reactions/getIn.sqf @@ -1,11 +1,11 @@ // Triggered if a player gets in a captured AI vehicle // Marks the vehicle as claimed by a player and frees up a slot to spawn another AI controlled vehicle -_vehicle = _this select 0; -_unit = _this select 2; +_unit = _this select 0; if(isPlayer _unit) then { + _vehicle = vehicle _unit; [_vehicle] call SC_fnc_vehicleDestroyed; if(SC_extendedLogging) then @@ -16,6 +16,12 @@ if(isPlayer _unit) then } else { + if(SC_debug) then + { + { deleteVehicle _x; } forEach attachedObjects _unit; + }; + + if(damage _vehicle > 0) then { [_vehicle] call SC_fnc_repairVehicle; diff --git a/scripts/reactions/getOut.sqf b/scripts/reactions/getOut.sqf index e69de29..3ec52bb 100644 --- a/scripts/reactions/getOut.sqf +++ b/scripts/reactions/getOut.sqf @@ -0,0 +1,32 @@ +// Triggered if an AI unit leaves an AI vehicle + +_unit = _this select 0; +_vehicle = _this select 2; +_driver = _vehicle getVariable "SC_assignedDriver"; +_arrowClass = "Sign_Arrow_F"; + +if(!alive _unit) exitWith {}; + +if(side _unit == SC_SurvivorSide) then +{ + _arrowClass = "Sign_Arrow_Green_F"; +} +else +{ + _arrowClass = "Sign_Arrow_F"; +}; + +if(_unit == _driver) then +{ + _arrowClass = "Sign_Arrow_Yellow_F"; +}; + +if(SC_debug && alive _unit && vehicle _unit != _unit) then +{ + _tag = createVehicle [_arrowClass, position _unit, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_unit,[0,0,0.6],"Head"]; +} +else +{ + { deleteVehicle _x; } forEach attachedObjects _unit; +}; \ No newline at end of file diff --git a/scripts/reactions/refuel.sqf b/scripts/reactions/refuel.sqf index e69de29..06ad962 100644 --- a/scripts/reactions/refuel.sqf +++ 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 57c1756..402211e 100644 --- a/scripts/reactions/repairVehicle.sqf +++ b/scripts/reactions/repairVehicle.sqf @@ -64,29 +64,28 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then _driver playMoveNow "Acts_carFixingWheel"; sleep 8; _driver switchMove ""; - if(!alive _driver) exitWith{}; - _driver playMoveNow "Acts_carFixingWheel"; - sleep 2; - _vehicle setDamage 0; - _driver switchMove ""; - _driver assignAsDriver _vehicle; - _driver moveInDriver _vehicle; - _driver action ["movetodriver", _vehicle]; - + 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 = _group addWaypoint [position _vehicle, 0] ; _wp setWaypointFormation "Column"; _wp setWaypointCompletionRadius 1; _wp setWaypointType "GETIN"; sleep 5; - _spawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; - if(!isNil "_spawnLocation") then - { - _driver action ["movetodriver", _vehicle]; - _vehicle forceSpeed -1; - [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; - _group setBehaviour "SAFE"; - _group setCombatMode "RED"; - }; + _spawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; + _driver action ["movetodriver", _vehicle]; + _vehicle forceSpeed -1; + [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; + _group setBehaviour "SAFE"; + _group setCombatMode "RED"; + }; } else diff --git a/scripts/reactions/unitMPHit.sqf b/scripts/reactions/unitMPHit.sqf index 3cab843..3eb7f28 100644 --- a/scripts/reactions/unitMPHit.sqf +++ b/scripts/reactions/unitMPHit.sqf @@ -13,7 +13,7 @@ if (side _aggressor == RESISTANCE) then _group = createGroup WEST; { _unit = _x; - [_unit] joinSilent grpNull; + //[_unit] joinSilent grpNull; [_unit] joinSilent _group; _unit removeAllMPEventHandlers "mphit"; }foreach units _initialGroup; diff --git a/scripts/reactions/unitMPKilled.sqf b/scripts/reactions/unitMPKilled.sqf index e69de29..363dcda 100644 --- a/scripts/reactions/unitMPKilled.sqf +++ b/scripts/reactions/unitMPKilled.sqf @@ -0,0 +1,12 @@ +// Get the variables from the event handler +_unit = _this select 0; +_killer = _this select 1; + +// remove all eventhandlers from the dead unit +_unit removeAllMPEventHandlers "mphit"; +[_unit] join grpNull; + +if(SC_debug) then +{ + { deleteVehicle _x; } forEach attachedObjects _unit; +}; diff --git a/scripts/reactions/vehicleDestroyed.sqf b/scripts/reactions/vehicleDestroyed.sqf index a6593ed..71d91e5 100644 --- a/scripts/reactions/vehicleDestroyed.sqf +++ b/scripts/reactions/vehicleDestroyed.sqf @@ -2,33 +2,25 @@ // SC_liveVehiclesArray = array of active vehicles _vehicle = _this select 0; +_vehicle removeAllMPEventHandlers "mphit"; +_vehicle removeAllMPEventHandlers "mpkilled"; +_vehicle removeAllEventHandlers "getin"; +_vehicle removeAllEventHandlers "getout"; -if(!isNil "_vehicle") then +if(_vehicle isKindOf "LandVehicle") then { - _vehicle = _this select 0; - _vehicle removeAllMPEventHandlers "mphit"; - _vehicle removeAllMPEventHandlers "mpkilled"; - _vehicle removeAllEventHandlers "getin"; - _vehicle removeAllEventHandlers "getout"; - _vehicle lock 0; - _vehicle setVehicleLock "UNLOCKED"; - _vehicle setVariable ["ExileIsLocked", 0, true]; - - if(_vehicle isKindOf "LandVehicle") then - { - SC_liveVehicles = SC_liveVehicles - 1; - SC_liveVehiclesArray = SC_liveVehiclesArray - [_vehicle]; - }; + 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 "Air") then +{ + SC_liveHelis = SC_liveHelis - 1; + SC_liveHelisArray = SC_liveHelisArray - [_vehicle]; +}; - if(_vehicle isKindOf "Ship") then - { - SC_liveBoats = SC_liveBoats - 1; - SC_liveBoatsArray = SC_liveBoatsArray - [_vehicle]; - }; -}; \ No newline at end of file +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 f91539c..3341e65 100644 --- a/scripts/startOccupation.sqf +++ b/scripts/startOccupation.sqf @@ -10,18 +10,9 @@ if(SC_debug) then { SC_refreshTime = 60; }else{ SC_refreshTime = 300; }; // Add selected occupation scripts to Exile Threading System -if(SC_processReporter) then -{ - fnc_processReporter = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\processReporter.sqf"; - - diag_log format ["[processReporter]:: Initialised at %1",time]; - [60, fnc_processReporter, [], true] call ExileServer_system_thread_addTask; -}; - if (SC_fastNights) then { fnc_checkMultiplier = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationFastNights.sqf"; - diag_log format ["[OCCUPATION:FastNights]:: Initialised at %1",time]; [60, fnc_checkMultiplier, [], true] call ExileServer_system_thread_addTask; }; @@ -57,35 +48,35 @@ if(SC_occupyStatic) then if(SC_occupySky) then { - uiSleep 30; // delay the start + uiSleep 15; // delay the start 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 30; // delay the start + 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 30; // delay the start + uiSleep 15; // delay the start 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 30; // delay the start + uiSleep 15; // delay the start 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 30; // delay the start + uiSleep 15; // delay the start fnc_occupationMilitary = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMilitary.sqf"; [SC_refreshTime, fnc_occupationMilitary, [], true] call ExileServer_system_thread_addTask; }; @@ -95,7 +86,7 @@ if(SC_occupyTransport) then [] execVM "\x\addons\a3_exile_occupation\scripts\occupationTransport.sqf"; }; -uiSleep 30; // delay the start +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;