From e9061a2e44a09d8fbc8c695bcf0a9081bee8b1a9 Mon Sep 17 00:00:00 2001 From: second_coming Date: Thu, 5 May 2016 12:23:52 +0100 Subject: [PATCH] v35 changes & fixes --- changeLog.txt | 25 ++ config.sqf | 7 +- initServer.sqf | 6 +- scripts/functions/fnc_selectName.sqf | 20 ++ scripts/functions/fnc_spawnStatics.sqf | 4 +- scripts/occupationLootCrates.sqf | 2 + scripts/occupationMilitary.sqf | 15 ++ scripts/occupationPlaces.sqf | 8 +- scripts/occupationSea.sqf | 283 ++++++++++++----------- scripts/occupationSky.sqf | 290 ++++++++++++------------ scripts/occupationVehicle.sqf | 301 +++++++++++++------------ scripts/reactions/airHit.sqf | 3 +- scripts/reactions/driverKilled.sqf | 3 +- scripts/reactions/getIn.sqf | 17 +- scripts/reactions/getOffBus.sqf | 3 +- scripts/reactions/getOnBus.sqf | 3 +- scripts/reactions/refuel.sqf | 18 -- scripts/reactions/repairVehicle.sqf | 18 +- 18 files changed, 559 insertions(+), 467 deletions(-) create mode 100644 changeLog.txt create mode 100644 scripts/functions/fnc_selectName.sqf delete mode 100644 scripts/reactions/refuel.sqf diff --git a/changeLog.txt b/changeLog.txt new file mode 100644 index 0000000..1e1562d --- /dev/null +++ b/changeLog.txt @@ -0,0 +1,25 @@ +================================================================================= +V35 (03-05-2016) +================================================================================= +Added checks for valid vehicles in Sky, Sea and Vehicle modules +Added the ability to add names to be used for AI +Altered eventhandlers triggered to repair land vehicles that were getting stuck in a loop +Added the option to ignore AI count when spawning land vehicles (set SC_occupyVehicleIgnoreCount = true) + +================================================================================= +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 07aad35..7c59818 100644 --- a/config.sqf +++ b/config.sqf @@ -36,6 +36,7 @@ SC_minDistanceToSpawnZones = 500; // Distance in metres (Briti SC_minDistanceToTraders = 500; // Distance in metres (British spelling, sue me :p ) Only used by occupy Places SC_occupyVehicle = true; // true if you want to have roaming AI vehicles +SC_occupyVehicleIgnoreCount = true; // true if you want spawn vehicles regardless of overall AI count SC_occupyVehiclesLocked = false; // true if AI vehicles to stay locked until all the linked AI are dead SC_occupyTraders = false; // (WORK IN PROGRESS, NOT WORKING YET) true if you want to create trader camps at positions specified in SC_occupyTraderDetails @@ -223,7 +224,11 @@ SC_BoatClassToUse = [ "Exile_Boat_MotorBoat_Police" ]; - +// Arrays of names used to generate names for AI +SC_SurvivorFirstNames = ["John","Dave","Steve","Rob","Richard","Bob","Andrew","Nick","Adrian","Mark","Adam","Will","Graham"]; +SC_SurvivorLastNames = ["Smith","Jones","Davids","Johnson","Jobs","Andrews","White","Brown","Taylor","Walker","Williams","Clarke","Jackson","Woods"]; +SC_BanditFirstNames = ["Alex","Nikita","George","Daniel","Adam","Alexander","Sasha","Sergey","Dmitry","Anton","Jakub","Vlad","Maxim","Oleg","Denis","Wojtek"]; +SC_BanditLastNames = ["Dimitrov","Petrov","Horvat","Novak","Dvorak","Vesely","Horak","Hansen","Larsen","Tamm","Ivanov","Pavlov","Virtanen"]; // namalsk specific settings (if you want to override settings for specific maps if you run multiple servers) if (worldName == 'Namalsk') then diff --git a/initServer.sqf b/initServer.sqf index f3ca97e..2c68422 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v31 (04-05-2016) Roll back"; +SC_occupationVersion = "v35 (05-05-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -45,7 +45,7 @@ SC_occupationVersion = "v31 (04-05-2016) Roll back"; 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_getOut = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\getOut.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"; SC_fnc_unitMPHit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\unitMPHit.sqf"; SC_fnc_unitMPKilled = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\unitMPKilled.sqf"; @@ -56,7 +56,7 @@ SC_occupationVersion = "v31 (04-05-2016) Roll back"; SC_fnc_addMarker = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\functions\fnc_addMarker.sqf"; SC_fnc_spawnstatics = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\functions\fnc_spawnStatics.sqf"; SC_fnc_selectGear = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\functions\fnc_selectGear.sqf"; - + SC_fnc_selectName = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\functions\fnc_selectName.sqf"; _logDetail = "============================================================================================================="; [_logDetail] call SC_fnc_log; diff --git a/scripts/functions/fnc_selectName.sqf b/scripts/functions/fnc_selectName.sqf new file mode 100644 index 0000000..a487500 --- /dev/null +++ b/scripts/functions/fnc_selectName.sqf @@ -0,0 +1,20 @@ +// Select names for AI based on the side +_side = _this select 0; +_firstName = "Tyler"; +_lastName = "Durden"; + +switch (_side) do +{ + case "survivor": + { + _firstName = SC_SurvivorFirstNames call BIS_fnc_selectRandom; + _lastName = SC_SurvivorLastNames call BIS_fnc_selectRandom; + }; + case "bandit": + { + _firstName = SC_BanditFirstNames call BIS_fnc_selectRandom; + _lastName = SC_BanditLastNames call BIS_fnc_selectRandom; + }; +}; +_name = format["%1 %2",_firstName,_lastName]; +_name \ No newline at end of file diff --git a/scripts/functions/fnc_spawnStatics.sqf b/scripts/functions/fnc_spawnStatics.sqf index d8876bd..a4e4610 100644 --- a/scripts/functions/fnc_spawnStatics.sqf +++ b/scripts/functions/fnc_spawnStatics.sqf @@ -65,7 +65,9 @@ if(_side == "survivor") then { _currentSide = SC_SurvivorSide }; for "_i" from 1 to _aiCount do { _loadOut = [_side] call SC_fnc_selectGear; - _unit = [_initialGroup,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unit = [_initialGroup,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unitName = [_side] call SC_fnc_selectName; + _unit setName _unitName; _unit setVariable ["SC_staticUID",_staticUID]; _unit setVariable ["SC_staticSpawnPos",_spawnPosition]; _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_staticUnitMPKilled;"]; diff --git a/scripts/occupationLootCrates.sqf b/scripts/occupationLootCrates.sqf index 62983c7..7c14de4 100644 --- a/scripts/occupationLootCrates.sqf +++ b/scripts/occupationLootCrates.sqf @@ -55,6 +55,8 @@ for "_i" from 1 to SC_numberofLootCrates do { _loadOut = ["bandit"] call SC_fnc_selectGear; _unit = [_group,_spawnPosition,"custom","random","bandit","soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unitName = ["bandit"] call SC_fnc_selectName; + _unit setName _unitName; }; // Get the AI to shut the fuck up :) diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index 0287a1a..ae70fc0 100644 --- a/scripts/occupationMilitary.sqf +++ b/scripts/occupationMilitary.sqf @@ -144,6 +144,19 @@ _areaToScan = [ 0, 900, 1, 500, 500, 0, 0, 0, true, false ] call DMS_fnc_findSaf _group = [_spawnPosition, _aiCount, _difficulty, "random", "bandit"] call DMS_fnc_SpawnAIGroup; DMS_ai_use_launchers = true; + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + _unitName = ["bandit"] call SC_fnc_selectName; + _unit setName _unitName; + if(SC_debug) then + { + _tag = createVehicle ["Sign_Arrow_Blue_F", position _unit, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_unit,[0,0,0.6],"Head"]; + }; + }foreach units _group; + [_group, _pos, _groupRadius] call bis_fnc_taskPatrol; _group setBehaviour "COMBAT"; _group setCombatMode "RED"; @@ -159,6 +172,8 @@ _areaToScan = [ 0, 900, 1, 500, 500, 0, 0, 0, true, false ] call DMS_fnc_findSaf _unit = _x; [_unit] joinSilent grpNull; [_unit] joinSilent _group; + _unitName = ["bandit"] call SC_fnc_selectName; + _unit setName _unitName; if(SC_debug) then { _tag = createVehicle ["Sign_Arrow_Blue_F", position _unit, [], 0, "CAN_COLLIDE"]; diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index e25b65e..93bb7e0 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -194,8 +194,10 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi DMS_ai_use_launchers = false; for "_i" from 1 to _aiCount do { - _loadOut = [_side] call SC_fnc_selectGear; - _unit = [_group,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _loadOut = [_side] call SC_fnc_selectGear; + _unit = [_group,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unitName = [_side] call SC_fnc_selectName; + _unit setName _unitName; }; DMS_ai_use_launchers = _useLaunchers; @@ -277,6 +279,8 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi { _loadOut = ["bandit"] call SC_fnc_selectGear; _unit = [_group2,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unitName = [_side] call SC_fnc_selectName; + _unit setName _unitName; }; DMS_ai_use_launchers = _useLaunchers; diff --git a/scripts/occupationSea.sqf b/scripts/occupationSea.sqf index 3ed212a..c568fe5 100644 --- a/scripts/occupationSea.sqf +++ b/scripts/occupationSea.sqf @@ -47,148 +47,163 @@ for "_i" from 1 to _vehiclesToSpawn do _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]; - // Remove the overpowered weapons from boats - _vehicle removeWeaponTurret ["HMG_01",[0]]; - _vehicle removeWeaponTurret ["GMG_40mm",[0]]; + if(_vehicle) then + { + _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]; + 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; - { - _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; - }; - - if(SC_extendedLogging && _unitPlaced) then + _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 { - _logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle]; + _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 + { + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unitName = ["bandit"] call SC_fnc_selectName; + _unit setName _unitName; + _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; + _unitName = ["bandit"] call SC_fnc_selectName; + _unit setName _unitName; + _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; + _unitName = ["bandit"] call SC_fnc_selectName; + _unit setName _unitName; + _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 + { + _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; [_logDetail] call SC_fnc_log; - }; - } forEach _vehicleRoles; - - { - _unit = _x; - [_unit] joinSilent grpNull; - [_unit] joinSilent _group; - }foreach units _group; + }; - if(SC_infiSTAR_log) then - { - _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; - [_logDetail] call SC_fnc_log; - }; + + clearMagazineCargoGlobal _vehicle; + clearWeaponCargoGlobal _vehicle; + clearItemCargoGlobal _vehicle; - - 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]; + }; - _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; - + + [_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 (check classname is correct)',_VehicleClassToUse]; + [_logDetail] call SC_fnc_log; + }; + }; diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index e655f4c..ad4b606 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -72,151 +72,161 @@ for "_i" from 1 to _vehiclesToSpawn do _group = createGroup SC_BanditSide; _VehicleClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom; _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; - _group addVehicle _vehicle; - _vehicle setVariable["vehPos",_spawnLocation,true]; - _vehicle setVariable["vehClass",_VehicleClassToUse,true]; - _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - - SC_liveHelis = SC_liveHelis + 1; - SC_liveHelisArray = SC_liveHelisArray + [_vehicle]; - - _vehicle setVehiclePosition [_spawnLocation, [], 0, "FLY"]; - _vehicle setVariable ["vehicleID", _spawnLocation, true]; - _vehicle setFuel 1; - _vehicle setDamage 0; - _vehicle engineOn true; - _vehicle flyInHeight 150; - _vehicle lock 0; - _vehicle setVehicleLock "UNLOCKED"; - _vehicle setVariable ["ExileIsLocked", 0, true]; - _vehicle action ["LightOn", _vehicle]; - - // Calculate the 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; - - 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; + if(_vehicle) then + { + _group addVehicle _vehicle; + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - _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 + 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; + + { + _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 { - _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; - _vehicle addWeaponCargoGlobal [_weaponToAdd,1]; - - _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); - _vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + _logDetail = format['[OCCUPATION:Sky] aircraft %1 failed to spawn (check classname is correct)',_VehicleClassToUse]; + [_logDetail] call SC_fnc_log; }; - - - [_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 17dbb7e..6df22f3 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -27,7 +27,7 @@ if(diag_fps < SC_minFPS) exitWith [_logDetail] call SC_fnc_log; }; -_aiActive = {alive _x && (side _x == SC_BanditSide OR side _x == SC_SurvivorSide)} count allUnits; +_aiActive = {alive _x && (side _x == SC_BanditSide OR side _x == SC_SurvivorSide) && !SC_occupyVehicleIgnoreCount} count allUnits; if(_aiActive > _maxAIcount) exitWith { _logDetail = format ["[OCCUPATION:Vehicle]:: %1 active AI, so not spawning AI this time",_aiActive]; @@ -130,154 +130,169 @@ 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(SC_occupyVehiclesLocked) then + if(_vehicle) then { - _vehicle lock 2; - _vehicle setVehicleLock "LOCKED"; - _vehicle setVariable ["ExileIsLocked", 1, 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; + + 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]; + _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;"]; + + + + + // 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; + _unitName = [_side] call SC_fnc_selectName; + _unit setName _unitName; + _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]; + + }; + if(_vehicleRole == "Turret" && _amountOfCrew < _crewRequired) then + { + _loadOut = [_side] call SC_fnc_selectGear; + _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; + _unitName = [_side] call SC_fnc_selectName; + _unit setName _unitName; + _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; + _unitName = [_side] call SC_fnc_selectName; + _unit setName _unitName; + _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]; + }; } else { - _vehicle lock 0; - _vehicle setVehicleLock "UNLOCKED"; - _vehicle setVariable ["ExileIsLocked", 0, true]; + _logDetail = format['[OCCUPATION:Vehicle] vehicle %1 failed to spawn (check classname is correct)',_VehicleClassToUse]; + [_logDetail] call SC_fnc_log; }; - - _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/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index 0d377b6..d683d91 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -109,7 +109,8 @@ if(_heliDamage > 0.7 && _damagedEssentials > 0) then _wp setWaypointBehaviour "COMBAT"; _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 10; - _wp setWaypointType "GETOUT"; + //_wp setWaypointType "GETOUT"; + _wp setWaypointType "TR Unload"; [_group2, _destination, 250] call bis_fnc_taskPatrol; _group2 setBehaviour "COMBAT"; diff --git a/scripts/reactions/driverKilled.sqf b/scripts/reactions/driverKilled.sqf index deaf3be..59f629d 100644 --- a/scripts/reactions/driverKilled.sqf +++ b/scripts/reactions/driverKilled.sqf @@ -8,7 +8,6 @@ if(SC_extendedLogging) then }; _deadDriver = _this select 0; -//_deadDriver removeAllMPEventHandlers "mpkilled"; _vehicle = _deadDriver getVariable "SC_drivenVehicle"; if(SC_debug) then @@ -36,6 +35,8 @@ if(count units _group > 0) then _groupMembers = units _group; _driver = _groupMembers call BIS_fnc_selectRandom; + + if(_deadDriver == _driver) exitWith { [_vehicle] call SC_fnc_vehicleDestroyed; }; _driver disableAI "TARGET"; _driver disableAI "AUTOTARGET"; diff --git a/scripts/reactions/getIn.sqf b/scripts/reactions/getIn.sqf index e70bd22..44f9dfa 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 -_unit = _this select 0; +_vehicle = _this select 0; +_unit = _this select 2; if(isPlayer _unit) then { - _vehicle = vehicle _unit; [_vehicle] call SC_fnc_vehicleDestroyed; if(SC_extendedLogging) then @@ -16,15 +16,6 @@ if(isPlayer _unit) then } else { - if(SC_debug) then - { - { deleteVehicle _x; } forEach attachedObjects _unit; - }; - - - if(damage _vehicle > 0) then - { - [_vehicle] call SC_fnc_repairVehicle; - - }; + if(SC_debug) then { { deleteVehicle _x; } forEach attachedObjects _unit; }; + //if(damage _vehicle > 0) then { [_vehicle] call SC_fnc_repairVehicle; }; }; \ No newline at end of file diff --git a/scripts/reactions/getOffBus.sqf b/scripts/reactions/getOffBus.sqf index acedcaa..3fd782c 100644 --- a/scripts/reactions/getOffBus.sqf +++ b/scripts/reactions/getOffBus.sqf @@ -8,5 +8,4 @@ if(_transport isKindOf "LandVehicle") then _transport setFuel 0; _transportDriver = driver _transport; _transportDriver disableAI "MOVE"; -}; - +}; \ No newline at end of file diff --git a/scripts/reactions/getOnBus.sqf b/scripts/reactions/getOnBus.sqf index bbdb670..e4cc8e3 100644 --- a/scripts/reactions/getOnBus.sqf +++ b/scripts/reactions/getOnBus.sqf @@ -1,5 +1,4 @@ // Triggered if a player gets on the public transport _transport = _this select 0; -_unit = _this select 2; - +_unit = _this select 2; \ No newline at end of file diff --git a/scripts/reactions/refuel.sqf b/scripts/reactions/refuel.sqf deleted file mode 100644 index 06ad962..0000000 --- a/scripts/reactions/refuel.sqf +++ /dev/null @@ -1,18 +0,0 @@ -// 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 402211e..024c8af 100644 --- a/scripts/reactions/repairVehicle.sqf +++ b/scripts/reactions/repairVehicle.sqf @@ -6,12 +6,15 @@ _vehicle removeAllMPEventHandlers "mphit"; _vehicleDamage = damage _vehicle; _damagedWheels = 0; -_damageLimit = 0.2; +_damageLimit = 1; _engineDamage = false; _fueltankDamage = false; _assignedDriver = _vehicle getVariable "SC_assignedDriver"; -if(isNull assignedDriver _vehicle) exitWith { [_assignedDriver] call SC_fnc_driverKilled; }; +if(!alive _assignedDriver) exitWith +{ + [_assignedDriver] call SC_fnc_driverKilled; +}; _wheels = ["HitLFWheel","HitLF2Wheel","HitRFWheel","HitRF2Wheel","HitLBWheel","HitLMWheel","HitRBWheel","HitRMWheel"]; _damagedWheels = 0; @@ -24,7 +27,7 @@ _damagedWheels = 0; _logDetail = format ["[OCCUPATION:repairVehicle]:: Vehicle %1 checking wheel %2 (damage: %4) @ %3",_vehicle, _x, time,_damage]; [_logDetail] call SC_fnc_log; }; - if(_damage > 0) then { _damagedWheels = _damagedWheels + 1; }; + if(_damage == 1) then { _damagedWheels = _damagedWheels + 1; }; }; } forEach _wheels; @@ -50,19 +53,22 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then _vehicle forceSpeed 0; _group = group _vehicle; _driver = _this select 1; + _driver disableAI "MOVE"; _driver disableAI "TARGET"; _driver disableAI "AUTOTARGET"; _driver disableAI "AUTOCOMBAT"; _driver disableAI "COVER"; - _driver disableAI "SUPPRESSION"; - sleep 1; + _driver disableAI "SUPPRESSION"; + _driver disableAI "FSM"; + sleep 0.3; _driver action ["getOut", _vehicle]; _driver doMove (position _vehicle); _driverDir = _driver getDir _vehicle; + _driver setDir _driverDir; _driver setUnitPos "MIDDLE"; sleep 0.5; _driver playMoveNow "Acts_carFixingWheel"; - sleep 8; + sleep 4; _driver switchMove ""; if(alive _driver) then {