From 6dadd52817cab4d24894bfb7598b7853dca9f9da Mon Sep 17 00:00:00 2001 From: second_coming Date: Wed, 22 Jun 2016 16:13:23 +0100 Subject: [PATCH] V49 --- changeLog.txt | 18 ++ config.cpp | 1 - config.sqf | 33 +- scripts/functions/fnc_findsafePos.sqf | 2 +- scripts/functions/fnc_unstick.sqf | 2 +- scripts/occupationLootCrates.sqf | 2 +- scripts/occupationTransport.sqf | 433 +++++++++++++------------- 7 files changed, 270 insertions(+), 221 deletions(-) diff --git a/changeLog.txt b/changeLog.txt index cc2ce14..55c2c92 100644 --- a/changeLog.txt +++ b/changeLog.txt @@ -1,3 +1,21 @@ +================================================================================= +V49 (22-06-2016) +================================================================================= +Changed the map marker names for loot crates to stop clashing with a previously +released loot crate script + +Fixed a bug in the unstick script which was resulting in the patrol order being +wiped after the vehicle was unstuck + +Added SC_useApexClasses to config (allow or disallow use of Apex items in Occupation) + +Added SC_colourTransport to config (allow or disallow the changing of the colour +of the public transport) + +Added SC_secureTransport to config (allow or disallow damage to the public transport +and its driver, set to false to allow damage). If the driver dies then the vehicle +will explode. + ================================================================================= V48 (16-06-2016) ================================================================================= diff --git a/config.cpp b/config.cpp index f83e6b2..8417674 100644 --- a/config.cpp +++ b/config.cpp @@ -4,7 +4,6 @@ class CfgPatches units[] = {}; weapons[] = {}; requiredVersion = 0.1; - a3_exile_occupation_version = "v48 (16-06-2016)"; requiredAddons[] = {"a3_dms"}; author[]= {"second_coming"}; }; diff --git a/config.sqf b/config.sqf index 552c39c..14d9631 100644 --- a/config.sqf +++ b/config.sqf @@ -15,7 +15,8 @@ SC_debug = false; // set to true to turn on debug features (not for live servers) -SC_useMapOverrides = false; // set to true to enable over riding options per map (see the bottom of this file for examples) +SC_useApexClasses = false; // true if you want to use the Apex class list, false to use vanilla Arma +SC_useMapOverrides = true; // set to true to enable over riding options per map (see the bottom of this file for examples) SC_extendedLogging = false; // set to true for additional logging SC_processReporter = true; // log the a list of active server processes every 60 seconds (useful for debugging server problems) SC_infiSTAR_log = true; // true Use infiSTAR logging, false logs to server rpt @@ -26,9 +27,9 @@ SC_scaleAI = 10; // any more than _scaleAI players on the server an SC_removeUserMapMarkers = true; // true to delete map markers placed by players every 10 seconds -SC_fastNights = false; // true if you want night time to go faster than daytime +SC_fastNights = true; // true if you want night time to go faster than daytime SC_fastNightsStarts = 18; // Start fast nights at this hour (24 hour clock) eg. 18 for 6pm -SC_fastNightsMultiplierNight= 16; // the time multiplier to use at night (12 = 12x speed) +SC_fastNightsMultiplierNight= 24; // the time multiplier to use at night (12 = 12x speed) SC_fastNightsEnds = 6; // End fast nights at this hour (24 hour clock) eg. 6 for 6am SC_fastNightsMultiplierDay = 4; // the time multiplier to use during daylight hours (4 = 4x speed) @@ -93,6 +94,7 @@ SC_BanditAssignedItems = ["ItemMap","ItemCompass","ItemRadio","ItemWatch"]; SC_BanditLauncher = []; SC_BanditBackpack = ["B_HuntingBackpack","B_Kitbag_cbr","B_Kitbag_mcamo","B_Kitbag_sgg","B_OutdoorPack_blk","B_OutdoorPack_blu","B_OutdoorPack_tan","B_TacticalPack_blk","B_TacticalPack_mcamo","B_TacticalPack_ocamo","B_TacticalPack_oli","B_TacticalPack_rgr"]; + SC_occupyStatic = false; // true if you want to add AI in specific locations SC_staticBandits = [ //[[pos],ai count,radius,search buildings] @@ -105,7 +107,9 @@ 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_occupyTransport = true; // true if you want pubic transport (travels between traders) -SC_occupyTransportClass = ["Exile_Chopper_Mohawk_FIA","Exile_Chopper_Mohawk_FIA","Exile_Car_LandRover_Urban"]; // to always use the same vehicle, specify one option only +SC_colourTransport = true; // true if you want the public transport coloured +SC_secureTransport = true; // true if you want the public transport and pilot to be indestructible +SC_occupyTransportClass = ["Exile_Chopper_Mohawk_FIA"]; // to always use the same vehicle, specify one option only SC_occupyTransportStartPos = []; // if empty defaults to map centre SC_occupyTransportAnnounce = false; // true if you want the pilot/driver to talk to passengers in vehicle chat, false if not @@ -116,8 +120,8 @@ SC_occupyTransportMessages = []; 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 = 7; // number of AI to spawn at each crate -SC_LootCrateGuardsRandomize = false; // Use a random number of guards up to a maximum = SC_LootCrateGuards (so between 1 and SC_LootCrateGuards) +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_LootCrateGuards (so between 1 and SC_LootCrateGuards) SC_occupyLootCratesMarkers = true; // true if you want to have markers on the loot crate spawns SC_ropeAttach = false; // Allow lootcrates to be airlifted (for SC_occupyLootCrates and SC_occupyHeliCrashes) @@ -158,7 +162,7 @@ SC_blackListedAreas = [ SC_occupyHeliCrashes = true; // true if you want to have Dayz style helicrashes SC_numberofHeliCrashesFire = true; // true if you want the crash on fire, false if you just want smoke -SC_numberofHeliCrashes = 5; // if SC_occupyHeliCrashes = true spawn this many loot crates (overrided below for Namalsk) +SC_numberofHeliCrashes = 5; // if SC_occupyHeliCrashes = true spawn this many loot crates // Array of possible common items to go in heli crash crates ["classname",fixed amount,random amount] NOT INCLUDING WEAPONS // ["HandGrenade",0,2] this example would add between 0 and 2 HandGrenade to the crate (fixed 0 plus 0-2 random) @@ -292,19 +296,32 @@ if (worldName == 'Napf' AND SC_useMapOverrides) then if (worldName == 'Tanoa' AND SC_useMapOverrides) then { SC_occupyTraders = true; + SC_useApexClasses = true; +}; + +// Overrides to use Apex weapons, gear and vehicles if SC_useApexClasses = true +if(SC_useApexClasses) then +{ SC_BanditWeapon = [ "arifle_MX_khk_F","arifle_MX_GL_khk_F","arifle_MX_SW_khk_F","arifle_MXC_khk_F","arifle_MXM_khk_F","arifle_AK12_F","arifle_AK12_GL_F","arifle_AKM_F", "arifle_AKS_F","arifle_ARX_blk_F","arifle_ARX_ghex_F","arifle_ARX_hex_F","arifle_CTAR_blk_F","arifle_CTAR_GL_blk_F","arifle_CTARS_blk_F","arifle_SPAR_01_blk_F","arifle_SPAR_01_khk_F", "arifle_SPAR_01_snd_F","arifle_SPAR_01_GL_blk_F","arifle_SPAR_01_GL_khk_F","arifle_SPAR_01_GL_snd_F","arifle_SPAR_02_blk_F","arifle_SPAR_02_khk_F","arifle_SPAR_02_snd_F", "arifle_SPAR_03_blk_F","arifle_SPAR_03_khk_F","arifle_SPAR_03_snd_F"]; SC_BanditUniforms = [ "U_I_C_Soldier_Para_1_F","U_I_C_Soldier_Para_2_F","U_I_C_Soldier_Para_3_F","U_I_C_Soldier_Para_4_F","U_I_C_Soldier_Para_5_F","U_I_C_Soldier_Bandit_1_F","U_I_C_Soldier_Bandit_2_F", "U_I_C_Soldier_Bandit_3_F","U_I_C_Soldier_Bandit_4_F","U_I_C_Soldier_Bandit_5_F","U_I_C_Soldier_Camo_F","U_B_CTRG_Soldier_urb_1_F","U_B_CTRG_Soldier_urb_2_F","U_B_CTRG_Soldier_urb_3_F"]; - SC_VehicleClassToUse = [ + SC_VehicleClassToUse = [ ["B_GEN_Offroad_01_gen_F",0], ["C_Offroad_02_unarmed_F",0], ["I_C_Offroad_02_unarmed_F",0] ]; + SC_VehicleClassToUseRare = [ + ["B_LSV_01_unarmed_black_F",1], + ["O_T_LSV_02_unarmed_black_F",1], + ["O_T_Truck_03_device_ghex_F",1] + ]; + SC_occupyTransportClass = ["Exile_Chopper_Mohawk_FIA","C_Offroad_02_unarmed_black_F","B_LSV_01_unarmed_black_F"]; }; + if (SC_debug) then { SC_extendedLogging = true; diff --git a/scripts/functions/fnc_findsafePos.sqf b/scripts/functions/fnc_findsafePos.sqf index 93645f6..1601c0d 100644 --- a/scripts/functions/fnc_findsafePos.sqf +++ b/scripts/functions/fnc_findsafePos.sqf @@ -72,4 +72,4 @@ while{!_validspot} do if (isNil "_validspot") then { _validspot = false; }; }; -_position +_position \ No newline at end of file diff --git a/scripts/functions/fnc_unstick.sqf b/scripts/functions/fnc_unstick.sqf index 9268d36..5766182 100644 --- a/scripts/functions/fnc_unstick.sqf +++ b/scripts/functions/fnc_unstick.sqf @@ -75,7 +75,7 @@ if(count(crew _vehicle) > 0)then _GroupLeader = leader (group _vehicle); _GroupLeader doMove _originalSpawnLocation; - [_group, _originalSpawnLocation, 2000] call bis_fnc_taskPatrol; + [_group2, _originalSpawnLocation, 2000] call bis_fnc_taskPatrol; _group2 setBehaviour "AWARE"; _group2 setCombatMode "RED"; diff --git a/scripts/occupationLootCrates.sqf b/scripts/occupationLootCrates.sqf index 5646d78..f1378d7 100644 --- a/scripts/occupationLootCrates.sqf +++ b/scripts/occupationLootCrates.sqf @@ -132,4 +132,4 @@ for "_i" from 1 to SC_numberofLootCrates do }; }forEach SC_LootCrateItems; -}; +}; \ No newline at end of file diff --git a/scripts/occupationTransport.sqf b/scripts/occupationTransport.sqf index a893998..510b4da 100644 --- a/scripts/occupationTransport.sqf +++ b/scripts/occupationTransport.sqf @@ -1,244 +1,259 @@ if (!isServer) exitWith {}; -_logDetail = format ["[OCCUPATION:transport]:: Starting @ %1",time]; -[_logDetail] call SC_fnc_log; - -private["_spawnLocation","_transport","_transportSpeed","_transportType","_wp","_transportBehaviour","_transportWaitingTime","_transportGunner"]; - -if( count SC_occupyTransportStartPos == 0) then +while {true} do { - _middle = worldSize/2; - _spawnCenter = [_middle,_middle,0]; - SC_occupyTransportStartPos = _spawnCenter; -}; - -SC_occupyTransportClassToUse = SC_occupyTransportClass call BIS_fnc_selectRandom; - -if!(SC_occupyTransportClassToUse isKindOf "LandVehicle" OR SC_occupyTransportClassToUse isKindOf "Air") exitWith -{ - _logDetail = format ["[OCCUPATION:transport]:: Only land vehicles or helicopters can be used as public transport"]; - [_logDetail] call SC_fnc_log; -}; - -if(SC_occupyTransportClassToUse isKindOf "LandVehicle") then -{ - _transportType = "land"; - _logDetail = format ["[OCCUPATION:transport]:: Spawning near map centre %1 @ %2",SC_occupyTransportStartPos,time]; + _logDetail = format ["[OCCUPATION:transport]:: Starting @ %1",time]; [_logDetail] call SC_fnc_log; - _positionOftransport = [SC_occupyTransportStartPos,0,500,25,0,10,0] call BIS_fnc_findSafePos; + private["_spawnLocation","_transport","_transportSpeed","_transportType","_wp","_transportBehaviour","_transportWaitingTime","_transportGunner"]; - // Get position of nearest roads - _nearRoads = _positionOftransport nearRoads 2000; - _nearestRoad = _nearRoads select 0; - _nearestRoadPos = position (_nearRoads select 0); - _spawnLocation = [_nearestRoadPos select 0, _nearestRoadPos select 1, 0]; - _transportSpeed = "LIMITED"; - _transportBehaviour = "SAFE"; - _transportWaitingTime = 10; -} -else -{ - _transportType = "heli"; - _spawnLocation = [SC_occupyTransportStartPos select 0, SC_occupyTransportStartPos select 1, 200]; - _transportSpeed = "NORMAL"; - _transportBehaviour = "CARELESS"; - _transportWaitingTime = 60; -}; - - -// Check there are enough waypoints to use -_markerCount = 0; -{ - _markerName = _x; - _markerPos = getMarkerPos _markerName; - if (markerType _markerName == "ExileTraderZone" OR markerType _markerName == "o_unknown") then - { - _markerCount = _markerCount + 1; + if( count SC_occupyTransportStartPos == 0) then + { + _middle = worldSize/2; + _spawnCenter = [_middle,_middle,0]; + SC_occupyTransportStartPos = _spawnCenter; }; -} forEach allMapMarkers; + SC_occupyTransportClassToUse = SC_occupyTransportClass call BIS_fnc_selectRandom; -if(_markerCount < 2) then -{ - _logDetail = format ["[OCCUPATION:transport]:: failed to find more than 1 ExileTraderZone or o_unknown map markers @ %1",time]; - [_logDetail] call SC_fnc_log; -} -else -{ - // Create the driver/pilot and ensure he doest react to gunfire or being shot at. - _group = createGroup resistance; - _group setCombatMode "BLUE"; - _group setVariable ["DMS_AllowFreezing",false,true]; - - // Spawn Vehicle - - if(_transportType == "heli") then - { - _transport = createVehicle [SC_occupyTransportClassToUse, _spawnLocation, [], 0, "NONE"]; - _transport setVehiclePosition [_spawnLocation, [], 0, "FLY"]; - _transport setVariable ["vehicleID", _spawnLocation, true]; - _transport setFuel 1; - _transport setDamage 0; - _transport engineOn true; - _transport flyInHeight 100; - } - else - { - _transport = createVehicle [SC_occupyTransportClassToUse, _spawnLocation, [], 0, "CAN_COLLIDE"]; - }; - - sleep 0.2; - - if(isNull _transport) exitWith + if!(SC_occupyTransportClassToUse isKindOf "LandVehicle" OR SC_occupyTransportClassToUse isKindOf "Air") exitWith { - _logDetail = format ["[OCCUPATION:transport]:: %1 failed to spawn, check it is a valid vehicle class name",SC_occupyTransportClassToUse]; + _logDetail = format ["[OCCUPATION:transport]:: Only land vehicles or helicopters can be used as public transport"]; + [_logDetail] call SC_fnc_log; + }; + + if(SC_occupyTransportClassToUse isKindOf "LandVehicle") then + { + _transportType = "land"; + _logDetail = format ["[OCCUPATION:transport]:: Spawning near map centre %1 @ %2",SC_occupyTransportStartPos,time]; [_logDetail] call SC_fnc_log; - }; - _transport addEventHandler ["handleDamage", { false }]; - _transport allowdamage false; + _positionOftransport = [SC_occupyTransportStartPos,0,500,25,0,10,0] call BIS_fnc_findSafePos; - if( _transportType == "land") then - { - //_transport setObjectTextureGlobal [0,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; - } + // Get position of nearest roads + _nearRoads = _positionOftransport nearRoads 2000; + _nearestRoad = _nearRoads select 0; + _nearestRoadPos = position (_nearRoads select 0); + _spawnLocation = [_nearestRoadPos select 0, _nearestRoadPos select 1, 0]; + _transportSpeed = "LIMITED"; + _transportBehaviour = "SAFE"; + _transportWaitingTime = 10; + } else - { - _transport setObjectTextureGlobal [0,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; - _transport setObjectTextureGlobal [1,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; - _transport setObjectTextureGlobal [2,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; - }; - - - _group addVehicle _transport; - - _transport enableCopilot false; - - _transportDriver = _group createUnit [DMS_AI_Classname, _spawnLocation, [], 0,"FORM"]; - removeGoggles _transportDriver; - _transportDriver forceAddUniform "U_IG_Guerilla3_1"; - _transportDriver addVest "V_TacVest_blk_POLICE"; - _transportDriver addHeadgear "H_Cap_blk"; - removeBackpackGlobal _transportDriver; - _transportDriver addBackpackGlobal "B_Parachute"; - _transportDriver disableAI 'AUTOTARGET'; - _transportDriver disableAI 'TARGET'; - _transportDriver disableAI 'SUPPRESSION'; - _transportDriver setCaptive true; - _transportDriver allowDamage false; - _transportDriver assignasdriver _transport; - _transportDriver moveInDriver _transport; - [_transportDriver] orderGetin true; - _transport lockDriver true; - _transport lockTurret [[0],true]; - - SC_transportArray = SC_transportArray + [_transport]; - _transport setVariable ["SC_assignedDriver", _transportDriver,true]; - _transport setVariable ["SC_transport", true,true]; - _transport setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - _transportDriver setVariable ["DMS_AssignedVeh",_transport]; - _transportDriver setVariable ["SC_lastSpoke", time, true]; - _transport addEventHandler ["getin", "_this call SC_fnc_getOnBus;"]; - _transport addEventHandler ["getout", "_this call SC_fnc_getOffBus;"]; - - clearBackpackCargoGlobal _transport; - clearItemCargoGlobal _transport; - clearMagazineCargoGlobal _transport; - clearWeaponCargoGlobal _transport; - _transport setVariable ["ExileIsPersistent", false]; - _transport setVariable["vehPos",_spawnLocation,true]; - _transport setFuel 1; - - _logDetail = format['[OCCUPATION:transport] Vehicle %1 spawned @ %2',SC_occupyTransportClassToUse,_spawnLocation]; - [_logDetail] call SC_fnc_log; - - _logDetail = format ["[OCCUPATION:transport]:: Found %1 markers to use as pickup points @ %2",_markerCount,time]; - [_logDetail] call SC_fnc_log; - - _textures = getObjectTextures _transport; - - _logDetail = format ["[OCCUPATION:transport]:: textures for vehicle are: %1",_textures]; - [_logDetail] call SC_fnc_log; - + { + _transportType = "heli"; + _spawnLocation = [SC_occupyTransportStartPos select 0, SC_occupyTransportStartPos select 1, 200]; + _transportSpeed = "NORMAL"; + _transportBehaviour = "CARELESS"; + _transportWaitingTime = 60; + }; + // Check there are enough waypoints to use _markerCount = 0; { _markerName = _x; _markerPos = getMarkerPos _markerName; if (markerType _markerName == "ExileTraderZone" OR markerType _markerName == "o_unknown") then - { - _wp = _group addWaypoint [_markerPos, 100]; - _wp setWaypointType "MOVE"; - _wp setWaypointBehaviour _transportBehaviour; - _wp setWaypointspeed _transportSpeed; - - _wp = _group addWaypoint [_markerPos, 25]; - _wp setWaypointType "TR UNLOAD"; - _wp setWaypointBehaviour "SAFE"; - _wp setWaypointspeed "LIMITED"; - _wp setWaypointTimeout [_transportWaitingTime,_transportWaitingTime,_transportWaitingTime]; + { _markerCount = _markerCount + 1; }; - + } forEach allMapMarkers; - - - // Add a final CYCLE - _wp = _group addWaypoint [_spawnLocation, 20]; - _wp setWaypointType "CYCLE"; - _wp setWaypointBehaviour _transportBehaviour; - _wp setWaypointspeed _transportSpeed; - _wp setWaypointTimeout [_transportWaitingTime,_transportWaitingTime,_transportWaitingTime]; - - _transportPos = position _transport; - _mk = createMarker ["transportLocation",_transportPos]; - - if(_transportType == "land") then - { - "transportLocation" setMarkerType "loc_BusStop"; - "transportLocation" setMarkerText "Occupation Public Bus"; + if(_markerCount < 2) then + { + _logDetail = format ["[OCCUPATION:transport]:: failed to find more than 1 ExileTraderZone or o_unknown map markers @ %1",time]; + [_logDetail] call SC_fnc_log; } else { - "transportLocation" setMarkerType "c_air"; - "transportLocation" setMarkerText "Occupation Airlines"; - "transportLocation" setMarkerColor "ColorBLUFOR"; - }; + // Create the driver/pilot and ensure he doest react to gunfire or being shot at. + _group = createGroup resistance; + _group setCombatMode "BLUE"; + _group setVariable ["DMS_AllowFreezing",false,true]; + // Spawn Vehicle - diag_log format['[OCCUPATION:transport] Running']; - _transportDriver = _transport getVariable "SC_assignedDriver"; - - // Make _transportDriver stop when players near him. - while {true} do - { - - _pos = position _transport; - _mk setMarkerPos _pos; - _nearPlayers = (count (_pos nearEntities [['Exile_Unit_Player'],25])); - - if (_nearPlayers >= 1 && _transportType == "land") then + if(_transportType == "heli") then { - uiSleep 0.5; + _transport = createVehicle [SC_occupyTransportClassToUse, _spawnLocation, [], 0, "NONE"]; + _transport setVehiclePosition [_spawnLocation, [], 0, "FLY"]; + _transport setVariable ["vehicleID", _spawnLocation, true]; _transport setFuel 1; - _transport setVehicleAmmo 1; - _transportDriver disableAI "MOVE"; - uiSleep 3; + _transport setDamage 0; + _transport engineOn true; + _transport flyInHeight 100; } else - { - _transport setFuel 1; - _transport setVehicleAmmo 1; - uiSleep 3; - _transportDriver enableAI "MOVE"; + { + _transport = createVehicle [SC_occupyTransportClassToUse, _spawnLocation, [], 0, "CAN_COLLIDE"]; }; - if(!Alive _transportDriver) exitWith {}; - uiSleep 5; - }; - deleteMarker _mk; -}; -_logDetail = format ["[OCCUPATION:transport]:: Ended @ %1",time]; -[_logDetail] call SC_fnc_log; \ No newline at end of file + + sleep 0.2; + + if(isNull _transport) exitWith + { + _logDetail = format ["[OCCUPATION:transport]:: %1 failed to spawn, check it is a valid vehicle class name",SC_occupyTransportClassToUse]; + [_logDetail] call SC_fnc_log; + }; + + if(SC_secureTransport) then + { + _transport addEventHandler ["handleDamage", { false }]; + _transport allowdamage false; + }; + + + if( _transportType == "land" && SC_colourTransport) then + { + //_transport setObjectTextureGlobal [0,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; + } + else + { + _transport setObjectTextureGlobal [0,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; + _transport setObjectTextureGlobal [1,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; + _transport setObjectTextureGlobal [2,"#(argb,8,8,3)color(0.518,0.519,0.7,0.2)"]; + }; + + + _group addVehicle _transport; + + _transport enableCopilot false; + + _transportDriver = _group createUnit [DMS_AI_Classname, _spawnLocation, [], 0,"FORM"]; + removeGoggles _transportDriver; + _transportDriver forceAddUniform "U_IG_Guerilla3_1"; + _transportDriver addVest "V_TacVest_blk_POLICE"; + _transportDriver addHeadgear "H_Cap_blk"; + removeBackpackGlobal _transportDriver; + _transportDriver addBackpackGlobal "B_Parachute"; + _transportDriver disableAI 'AUTOTARGET'; + _transportDriver disableAI 'TARGET'; + _transportDriver disableAI 'SUPPRESSION'; + _transportDriver setCaptive true; + _transportDriver assignasdriver _transport; + _transportDriver moveInDriver _transport; + [_transportDriver] orderGetin true; + _transport lockDriver true; + _transport lockTurret [[0],true]; + + if(SC_secureTransport) then + { + _transportDriver allowDamage false; + }; + + SC_transportArray = SC_transportArray + [_transport]; + _transport setVariable ["SC_assignedDriver", _transportDriver,true]; + _transport setVariable ["SC_transport", true,true]; + _transport setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; + _transportDriver setVariable ["DMS_AssignedVeh",_transport]; + _transportDriver setVariable ["SC_lastSpoke", time, true]; + _transport addEventHandler ["getin", "_this call SC_fnc_getOnBus;"]; + _transport addEventHandler ["getout", "_this call SC_fnc_getOffBus;"]; + + clearBackpackCargoGlobal _transport; + clearItemCargoGlobal _transport; + clearMagazineCargoGlobal _transport; + clearWeaponCargoGlobal _transport; + _transport setVariable ["ExileIsPersistent", false]; + _transport setVariable["vehPos",_spawnLocation,true]; + _transport setFuel 1; + + _logDetail = format['[OCCUPATION:transport] Vehicle %1 spawned @ %2',SC_occupyTransportClassToUse,_spawnLocation]; + [_logDetail] call SC_fnc_log; + + _logDetail = format ["[OCCUPATION:transport]:: Found %1 markers to use as pickup points @ %2",_markerCount,time]; + [_logDetail] call SC_fnc_log; + + _textures = getObjectTextures _transport; + + _logDetail = format ["[OCCUPATION:transport]:: textures for vehicle are: %1",_textures]; + [_logDetail] call SC_fnc_log; + + + + _markerCount = 0; + { + _markerName = _x; + _markerPos = getMarkerPos _markerName; + if (markerType _markerName == "ExileTraderZone" OR markerType _markerName == "o_unknown") then + { + _wp = _group addWaypoint [_markerPos, 100]; + _wp setWaypointType "MOVE"; + _wp setWaypointBehaviour _transportBehaviour; + _wp setWaypointspeed _transportSpeed; + + _wp = _group addWaypoint [_markerPos, 25]; + _wp setWaypointType "TR UNLOAD"; + _wp setWaypointBehaviour "SAFE"; + _wp setWaypointspeed "LIMITED"; + _wp setWaypointTimeout [_transportWaitingTime,_transportWaitingTime,_transportWaitingTime]; + _markerCount = _markerCount + 1; + }; + + } forEach allMapMarkers; + + + + // Add a final CYCLE + _wp = _group addWaypoint [_spawnLocation, 20]; + _wp setWaypointType "CYCLE"; + _wp setWaypointBehaviour _transportBehaviour; + _wp setWaypointspeed _transportSpeed; + _wp setWaypointTimeout [_transportWaitingTime,_transportWaitingTime,_transportWaitingTime]; + + _transportPos = position _transport; + _mk = createMarker ["transportLocation",_transportPos]; + + if(_transportType == "land") then + { + "transportLocation" setMarkerType "loc_BusStop"; + "transportLocation" setMarkerText "Occupation Public Bus"; + } + else + { + "transportLocation" setMarkerType "c_air"; + "transportLocation" setMarkerText "Occupation Airlines"; + "transportLocation" setMarkerColor "ColorBLUFOR"; + }; + + + diag_log format['[OCCUPATION:transport] Running']; + _transportDriver = _transport getVariable "SC_assignedDriver"; + + // Make _transportDriver stop when players near him. + while {alive _transportDriver} do + { + + _pos = position _transport; + _mk setMarkerPos _pos; + _nearPlayers = (count (_pos nearEntities [['Exile_Unit_Player'],25])); + + if (_nearPlayers >= 1 && _transportType == "land") then + { + uiSleep 0.5; + _transport setFuel 1; + _transport setVehicleAmmo 1; + _transportDriver disableAI "MOVE"; + uiSleep 3; + } + else + { + _transport setFuel 1; + _transport setVehicleAmmo 1; + uiSleep 3; + _transportDriver enableAI "MOVE"; + }; + if(!Alive _transportDriver) exitWith {}; + uiSleep 5; + }; + deleteMarker _mk; + _transport setDamage 1; + }; + _logDetail = format ["[OCCUPATION:transport]:: Transport destroyed @ %1 (%2)",_pos,time]; + [_logDetail] call SC_fnc_log; + + // Spawn another heli + uiSleep 15; // delay the start +}; \ No newline at end of file