diff --git a/config.cpp b/config.cpp index ab46e7b..35356f5 100644 --- a/config.cpp +++ b/config.cpp @@ -1,4 +1,5 @@ -class CfgPatches { +class CfgPatches +{ class a3_exile_occupation { units[] = {}; weapons[] = {}; @@ -6,6 +7,7 @@ class CfgPatches { author[]= {"second_coming"}; }; }; + class CfgFunctions { class yorkshire { class main { @@ -17,4 +19,3 @@ class CfgFunctions { }; }; }; - diff --git a/config.sqf b/config.sqf index 755b4e4..c012e3d 100644 --- a/config.sqf +++ b/config.sqf @@ -98,4 +98,4 @@ publicVariable "SC_liveHelis"; publicVariable "SC_liveHelisArray"; publicVariable "SC_liveBoats"; publicVariable "SC_liveBoatsArray"; -publicVariable "SC_numberofLootCrates"; +publicVariable "SC_numberofLootCrates"; \ No newline at end of file diff --git a/initServer.sqf b/initServer.sqf index 39d0276..d328ec0 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -49,4 +49,4 @@ _logDetail = "================================================================== [_logDetail] call SC_fnc_log; // Start Occupation -[] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; +[] execVM "\x\addons\a3_exile_occupation\scripts\startOccupation.sqf"; \ No newline at end of file diff --git a/scripts/occupationHeliCrashes.sqf b/scripts/occupationHeliCrashes.sqf index aa1351d..d75cfb2 100644 --- a/scripts/occupationHeliCrashes.sqf +++ b/scripts/occupationHeliCrashes.sqf @@ -1,10 +1,8 @@ if (!isServer) exitWith {}; -_numberofCrashes = 5; // this is the number of helicrashes that you want to spawn - if (worldName == 'Namalsk') then { - _numberofCrashes = 2; // lower number for a smaller map + SC_numberofHeliCrashes = 2; // lower number for a smaller map }; _displayMarkers = SC_debug; // only use for debug, no need for actual gameplay @@ -14,7 +12,10 @@ private['_position']; _logDetail = format ["[OCCUPATION:HeliCrashes]:: Initialised at %1",time]; [_logDetail] call SC_fnc_log; -for "_i" from 1 to _numberofCrashes do +_logDetail = format['[OCCUPATION:HeliCrashes]:: worldname: %1 crashes to spawn: %2',worldName,SC_numberofHeliCrashes]; +[_logDetail] call SC_fnc_log; + +for "_i" from 1 to SC_numberofHeliCrashes do { _validspot = false; while{!_validspot} do diff --git a/scripts/occupationLootCrates.sqf b/scripts/occupationLootCrates.sqf index 113d474..4258807 100644 --- a/scripts/occupationLootCrates.sqf +++ b/scripts/occupationLootCrates.sqf @@ -43,7 +43,13 @@ for "_i" from 1 to SC_numberofLootCrates do }; //Infantry spawn using DMS - _AICount = 1 + (round (random 2)); + _AICount = SC_LootCrateGuards; + + if(SC_LootCrateGuardsRandomize) then + { + _AICount = 1 + (round (random (SC_LootCrateGuards-1))); + }; + _spawnPosition = [_position select 0, _position select 1, 0]; _group = [_spawnPosition, _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup; @@ -56,7 +62,8 @@ for "_i" from 1 to SC_numberofLootCrates do _group setCombatMode "RED"; _logDetail = text format ["[OCCUPATION:LootCrates]:: Creating crate %3 @ drop zone %1 with %2 guards",_position,_AICount,_i]; - + [_logDetail] call SC_fnc_log; + _box = "CargoNet_01_box_F" createvehicle _position; clearMagazineCargoGlobal _box; clearWeaponCargoGlobal _box; diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index 152321c..e7ae462 100644 --- a/scripts/occupationMilitary.sqf +++ b/scripts/occupationMilitary.sqf @@ -145,7 +145,7 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do DMS_ai_use_launchers = true; [_group, _pos, _groupRadius] call bis_fnc_taskPatrol; - _group setBehaviour "SAD"; + _group setBehaviour "COMBAT"; _group setCombatMode "RED"; } else diff --git a/scripts/occupationMonitor.sqf b/scripts/occupationMonitor.sqf new file mode 100644 index 0000000..4bb9799 --- /dev/null +++ b/scripts/occupationMonitor.sqf @@ -0,0 +1,28 @@ +_logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; +[_logDetail] call SC_fnc_log; + +{ + _logDetail = format ["[OCCUPATION:Unstick]:: Air: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + sleep 5; +}forEach SC_liveHelisArray; + +{ + _logDetail = format ["[OCCUPATION:Unstick]:: Land: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_comeUnstuck; + sleep 5; +}forEach SC_liveVehiclesArray; + +{ + _logDetail = format ["[OCCUPATION:Unstick]:: Sea: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_comeUnstuck; + sleep 5; +}forEach SC_liveBoatsArray; + +_logDetail = format ["[OCCUPATION:Unstick]:: Finished at %1",time]; +[_logDetail] call SC_fnc_log; \ No newline at end of file diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index 8d88417..e44c51f 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -37,14 +37,14 @@ if(_currentPlayerCount > _scaleAI) then // Don't spawn additional AI if the server fps is below _minFPS if(diag_fps < _minFPS) exitWith { - _logDetail = format ["[OCCUPATION]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; + _logDetail = format ["[OCCUPATION:Places]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; [_logDetail] call SC_fnc_log; }; -_aiActive = count(_spawnCenter nearEntities ["O_recon_F", 20000]); +_aiActive = {alive _x && side _x == EAST} count allUnits; if(_aiActive > _maxAIcount) exitWith { - _logDetail = format ["[OCCUPATION]:: %1 active AI, so not spawning AI this time",_aiActive]; + _logDetail = format ["[OCCUPATION:Places]:: %1 active AI, so not spawning AI this time",_aiActive]; [_logDetail] call SC_fnc_log; }; @@ -58,7 +58,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: Testing location name: %1 position: %2",_locationName,_pos]; + _logDetail = format ["[OCCUPATION:Places]:: Testing location name: %1 position: %2",_locationName,_pos]; [_logDetail] call SC_fnc_log; }; @@ -71,7 +71,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: Rolled %1 so not spawning AI this time",_spawnChance,_locationName]; + _logDetail = format ["[OCCUPATION:Places]:: Rolled %1 so not spawning AI this time",_spawnChance,_locationName]; [_logDetail] call SC_fnc_log; }; }; @@ -83,7 +83,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 is too close to player base",_locationName]; + _logDetail = format ["[OCCUPATION:Places]:: %1 is too close to player base",_locationName]; [_logDetail] call SC_fnc_log; }; }; @@ -96,7 +96,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 is too close to a %2",_locationName,_nearestMarker]; + _logDetail = format ["[OCCUPATION:Places]:: %1 is too close to a %2",_locationName,_nearestMarker]; [_logDetail] call SC_fnc_log; }; }; @@ -107,7 +107,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 has players too close",_locationName]; + _logDetail = format ["[OCCUPATION:Places]:: %1 has players too close",_locationName]; [_logDetail] call SC_fnc_log; }; }; @@ -119,7 +119,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _okToSpawn = false; if(SC_extendedLogging) then { - _logDetail = format ["[OCCUPATION]:: %1 already has %2 active AI patrolling",_locationName,_aiNear]; + _logDetail = format ["[OCCUPATION:Places]:: %1 already has %2 active AI patrolling",_locationName,_aiNear]; [_logDetail] call SC_fnc_log; }; }; @@ -131,9 +131,9 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// _aiCount = 1; _groupRadius = 100; - if(_locationType isEqualTo "NameCityCapital") then { _aiCount = 5; _groupRadius = 300; }; - if(_locationType isEqualTo "NameCity") then { _aiCount = 2 + (round (random 3)); _groupRadius = 200; }; - if(_locationType isEqualTo "NameVillage") then { _aiCount = 1 + (round (random 2)); _groupRadius = 100; }; + if(_locationType isEqualTo "NameCityCapital") then { _aiCount = 5; _groupRadius = 300; }; + if(_locationType isEqualTo "NameCity") then { _aiCount = 2 + (round (random 3)); _groupRadius = 200; }; + if(_locationType isEqualTo "NameVillage") then { _aiCount = 1 + (round (random 2)); _groupRadius = 100; }; if(_aiCount < 1) then { _aiCount = 1; }; _difficulty = "random"; @@ -204,7 +204,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi enableSentences false; enableRadio false; [_group2, _pos, _groupRadius] call bis_fnc_taskPatrol; - _group2 setBehaviour "DESTROY"; + _group2 setBehaviour "AWARE"; _group2 setCombatMode "RED"; }; @@ -222,7 +222,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _marker setMarkerText "Occupied Area"; }; - _logDetail = format ["[OCCUPATION]:: Spawning %2 AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition]; + _logDetail = format ["[OCCUPATION:Places]:: Spawning %2 AI in at %3 to patrol %1",_locationName,_aiCount,_spawnPosition]; [_logDetail] call SC_fnc_log; _okToSpawn = false; }; diff --git a/scripts/occupationSea.sqf b/scripts/occupationSea.sqf new file mode 100644 index 0000000..be70475 --- /dev/null +++ b/scripts/occupationSea.sqf @@ -0,0 +1,118 @@ +_logDetail = format['[OCCUPATION:Sea] Started']; +[_logDetail] call SC_fnc_log; + +if (!isServer) exitWith {}; + +if(SC_liveBoats >= SC_maxNumberofBoats) exitWith +{ + if(SC_extendedLogging) then + { + _logDetail = format['[OCCUPATION:Sea] End check %1 currently active (max %2) @ %3',SC_liveBoats,SC_maxNumberofBoats,time]; + [_logDetail] call SC_fnc_log; + }; +}; + +_vehiclesToSpawn = (SC_maxNumberofBoats - SC_liveBoats); +_middle = worldSize/2; +_spawnCenter = [_middle,_middle,0]; +_maxDistance = _middle; + +for "_i" from 1 to _vehiclesToSpawn do +{ + private["_group"]; + + _spawnLocation = [ 250, 0, 1, 1000, 1000, 1000, 1000, 1000, true, true ] call DMS_fnc_findSafePos; + //_spawnLocation = [(_pos), 80, 10] call ExileClient_util_world_findWaterPosition; + _group = createGroup east; + _BoatClassToUse = SC_BoatClassToUse call BIS_fnc_selectRandom; + _vehicle1 = [ [_spawnLocation], _group, "assault", "difficult", "bandit", _BoatClassToUse ] call DMS_fnc_SpawnAIVehicle; + _vehicle1 setPosASL _spawnLocation; + _vehicle1 setVariable["vehPos",_spawnLocation,true]; + _vehicle1 setVariable["vehClass",_BoatClassToUse,true]; + + // Remove the overpowered weapons from boats + _vehicle1 removeWeaponTurret ["HMG_01",[0]]; + _vehicle1 removeWeaponTurret ["GMG_40mm",[0]]; + + SC_liveBoats = SC_liveBoats + 1; + SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle1]; + + _vehicle1 setVehicleLock "UNLOCKED"; + _vehicle1 setVariable ["ExileIsLocked", 0, true]; + if(SC_infiSTAR_log) then + { + _logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_BoatClassToUse,_spawnLocation]; + [_logDetail] call SC_fnc_log; + }; + _vehicle1 setVehiclePosition [_spawnLocation, [], 0, "NONE"]; + _vehicle1 setVariable ["vehicleID", _spawnLocation, true]; + _vehicle1 setFuel 1; + _vehicle1 setDamage 0; + _vehicle1 engineOn true; + _vehicle1 flyInHeight 150; + sleep 0.2; + + + clearMagazineCargoGlobal _vehicle1; + clearWeaponCargoGlobal _vehicle1; + clearItemCargoGlobal _vehicle1; + + _vehicle1 addMagazineCargoGlobal ["HandGrenade", (random 2)]; + _vehicle1 addItemCargoGlobal ["ItemGPS", (random 1)]; + _vehicle1 addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; + _vehicle1 addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; + _vehicle1 addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; + + // Add weapons with ammo to the vehicle + _possibleWeapons = + [ + "arifle_MXM_Black_F", + "arifle_MXM_F", + "srifle_DMR_01_F", + "srifle_DMR_02_camo_F", + "srifle_DMR_02_F", + "srifle_DMR_02_sniper_F", + "srifle_DMR_03_F", + "srifle_DMR_03_khaki_F", + "srifle_DMR_03_multicam_F", + "srifle_DMR_03_tan_F", + "srifle_DMR_03_woodland_F", + "srifle_DMR_04_F", + "srifle_DMR_04_Tan_F", + "srifle_DMR_05_blk_F", + "srifle_DMR_05_hex_F", + "srifle_DMR_05_tan_f", + "srifle_DMR_06_camo_F", + "srifle_DMR_06_olive_F", + "srifle_EBR_F", + "srifle_GM6_camo_F", + "srifle_GM6_F", + "srifle_LRR_camo_F", + "srifle_LRR_F" + ]; + _amountOfWeapons = 1 + (random 3); + + for "_i" from 1 to _amountOfWeapons do + { + _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; + _vehicle1 addWeaponCargoGlobal [_weaponToAdd,1]; + + _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); + _vehicle1 addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; + }; + + + [_group, _spawnLocation, 4000] call bis_fnc_taskPatrol; + _group setBehaviour "CARELESS"; + _group setCombatMode "RED"; + _vehicle1 addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; + _vehicle1 addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle1 addMPEventHandler ["mphit", "_this call SC_fnc_boatHit;"]; + _vehicle1 setVariable ["SC_crewEjected", false,true]; + sleep 0.2; + +}; + + +_logDetail = format['[OCCUPATION:Sea] Running']; +[_logDetail] call SC_fnc_log; \ No newline at end of file diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index 593ffc5..552b455 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -9,8 +9,7 @@ if(SC_liveHelis >= SC_maxNumberofHelis) exitWith { _logDetail = format['[OCCUPATION:Sky] End check %1 currently active (max %2) @ %3',SC_liveHelis,SC_maxNumberofHelis,time]; [_logDetail] call SC_fnc_log; - }; - + }; }; _vehiclesToSpawn = (SC_maxNumberofHelis - SC_liveHelis); @@ -49,7 +48,17 @@ for "_i" from 1 to _vehiclesToSpawn do _group = createGroup east; _HeliClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom; _vehicle1 = [ [_helispawnLocation], _group, "assault", "difficult", "bandit", _HeliClassToUse ] call DMS_fnc_SpawnAIVehicle; - SC_liveHelis = SC_liveHelis + 1; + _vehicle1 setVariable["vehPos",_helispawnLocation,true]; + _vehicle1 setVariable["vehClass",_HeliClassToUse,true]; + { + _unit = _x; + removeBackpackGlobal _unit; + _unit addBackpackGlobal "B_Parachute"; + }forEach units _group; + + SC_liveHelis = SC_liveHelis + 1; + SC_liveHelisArray = SC_liveHelisArray + [_vehicle1]; + _vehicle1 setVehicleLock "UNLOCKED"; _vehicle1 setVariable ["ExileIsLocked", 0, true]; if(SC_infiSTAR_log) then @@ -119,7 +128,7 @@ for "_i" from 1 to _vehiclesToSpawn do _group setBehaviour "CARELESS"; _group setCombatMode "RED"; _vehicle1 addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"]; - _vehicle1 addMPEventHandler ["mpkilled", "SC_liveHelis = SC_liveHelis - 1;"]; + _vehicle1 addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; _vehicle1 addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; _vehicle1 setVariable ["SC_crewEjected", false,true]; sleep 0.2; diff --git a/scripts/occupationStatic.sqf b/scripts/occupationStatic.sqf index 66da71d..4202725 100644 --- a/scripts/occupationStatic.sqf +++ b/scripts/occupationStatic.sqf @@ -47,7 +47,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do _staticSearch = _currentStatic select 3; _underground = _currentStatic select 4; - _logDetail = format ["[OCCUPATION Static]:: Adding %2 AI to static spawn @ %1",_spawnPosition,_aiCount]; + _logDetail = format ["[OCCUPATION Static]:: Checking static spawn @ %1",_spawnPosition,_aiCount]; [_logDetail] call SC_fnc_log; _okToSpawn = true; @@ -57,7 +57,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do { // Don't spawn additional AI if there are already AI in range - _aiNear = count(_spawnPosition nearEntities ["O_recon_F", 125]); + _aiNear = count(_spawnPosition nearEntities ["O_recon_F", 250]); if(_aiNear > 0) exitwith { _okToSpawn = false; @@ -151,7 +151,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do _logDetail = format ["[OCCUPATION Static]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition]; [_logDetail] call SC_fnc_log; - if(SC_mapMarkers) then + if(SC_mapMarkers && !isNil "_foundBuilding") then { _marker = createMarker [format ["%1", _foundBuilding],_spawnPosition]; _marker setMarkerShape "Icon"; diff --git a/scripts/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index 5d0b0f4..9c72ecf 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -59,7 +59,7 @@ if(_vehiclesToSpawn >= 1) then private["_group"]; _Location = _locations call BIS_fnc_selectRandom; _position = position _Location; - _pos = [_position,10,100,5,0,20,0] call BIS_fnc_findSafePos; + _pos = [_position,10,250,5,0,20,0] call BIS_fnc_findSafePos; // Get position of nearest roads @@ -69,9 +69,14 @@ if(_vehiclesToSpawn >= 1) then _spawnLocation = [_nearestRoad select 0, _pos select 1, 0]; _group = createGroup east; - SC_liveVehicles = SC_liveVehicles + 1; _VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom; _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; + _vehicle setVariable["vehPos",_spawnLocation,true]; + _vehicle setVariable["vehClass",_VehicleClassToUse,true]; + + SC_liveVehicles = SC_liveVehicles + 1; + SC_liveVehiclesArray = SC_liveVehiclesArray + [_vehicle]; + _vehicle setFuel 1; _vehicle engineOn true; _vehicle lock 0; @@ -81,25 +86,29 @@ if(_vehiclesToSpawn >= 1) then _vehicle limitSpeed 60; _vehicle action ["LightOn", _vehicle]; - _vehicle addEventHandler ["getin", "_this call SC_fnc_getIn;"]; - _vehicle addMPEventHandler ["mpkilled", "SC_liveVehicles = SC_liveVehicles - 1;"]; - _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; - _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; - + _group addVehicle _vehicle; - _driver = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _driver = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + sleep 0.5; if(SC_debug) then { _tag = createVehicle ["Sign_Arrow_Green_F", position _driver, [], 0, "CAN_COLLIDE"]; _tag attachTo [_driver,[0,0,0.6],"Head"]; }; - sleep 1; + sleep 0.5; _driver setVariable ["DMS_AssignedVeh",_vehicle]; - _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; _driver setVariable ["SC_drivenVehicle", _vehicle,true]; - _vehicle setVariable ["SC_assignedDriver", _driver,true]; _driver action ["movetodriver", _vehicle]; - _driver assignAsDriver _vehicle; + _driver assignAsDriver _vehicle; + _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; + + _vehicle setVariable ["SC_assignedDriver", _driver,true]; + _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; + _vehicle addEventHandler ["getin", "_this call SC_fnc_getIn;"]; + _vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"]; + _vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; + _group setBehaviour "CARELESS"; + _group setCombatMode "BLUE"; sleep 0.2; _crewCount = { @@ -108,14 +117,12 @@ if(_vehiclesToSpawn >= 1) then _unit setVariable ["DMS_AssignedVeh",_vehicle]; _unit assignAsCargo _vehicle; sleep 0.2; + _group setBehaviour "CARELESS"; + _group setCombatMode "BLUE"; true } count (allTurrets [_vehicle, true]); - _group setBehaviour "CARELESS"; - _group setCombatMode "BLUE"; - sleep 10; - // Get the AI to shut the fuck up :) enableSentences false; enableRadio false; diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index e1994cd..0e1cc03 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -35,21 +35,23 @@ _damagedEssentials = 0; } forEach _essentials; -if(_damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then +if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then { [_heli ] spawn { _veh = _this select 0; + if(SC_extendedLogging) then + { + _heliPosition = getPosATL _veh; + _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 ejecting passengers at %3 (time: %1)",time,_veh,_heliPosition]; + [_logDetail] call SC_fnc_log; + }; { - if(SC_extendedLogging) then - { - _heliPosition = getPosATL _veh; - _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 ejecting passengers at %3 (time: %1)",time,_this select 0,_this select 1,_heliPosition]; - [_logDetail] call SC_fnc_log; - }; + _unit = _x select 0; - if (isNull driver _veh) then + + if (!(_unit == gunner _veh) && !(_unit == driver _veh)) then { _unit action ["EJECT", _veh]; }; @@ -62,35 +64,7 @@ if(_damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then _group = group _heli; _group reveal [_target,1.5]; - _destination = getPos _target; - [_group, _destination, 250] call bis_fnc_taskPatrol; - _group allowFleeing 0; - _group setBehaviour "AWARE"; - _group setSpeedMode "FULL"; - _group setCombatMode "RED"; - _heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; -}; - - -if(_heliDamage > 0.5 && _damagedEssentials > 0) then -{ - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 damaged and force landing at %3 (time: %1)",time,_this select 0,_this select 1,_heliPosition]; - [_logDetail] call SC_fnc_log; - }; - _heli removeAllMPEventHandlers "mphit"; - _heli removeAllMPEventHandlers "mpkilled"; - _currentHeliPos = getPos _heli; - _destination = [_currentHeliPos, 1, 150, 10, 0, 20, 0] call BIS_fnc_findSafePos; - SC_liveHelis = SC_liveHelis - 1; - _heli land "LAND"; - _heli setVehicleLock "UNLOCKED"; - _target = _this select 1; - _pilot = driver _heli; - _group = group _heli; - _group reveal [_target,1.5]; - + _destination = getPos _target; _group allowFleeing 0; _wp = _group addWaypoint [_destination, 0] ; _wp setWaypointFormation "Column"; @@ -98,7 +72,47 @@ if(_heliDamage > 0.5 && _damagedEssentials > 0) then _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 1; _wp setWaypointType "SAD"; + + [_group, _destination, 250] call bis_fnc_taskPatrol; - _group setBehaviour "COMBAT"; - _group setCombatMode "RED"; + _group allowFleeing 0; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + _heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; +}; + + +if(_heliDamage > 0.7 && _damagedEssentials > 0) then +{ + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 damaged and force landing at %3 (time: %1)",time,_this select 0,_this select 1,_heliPosition]; + [_logDetail] call SC_fnc_log; + }; + + [_heli] call SC_fnc_vehicleDestroyed; + _currentHeliPos = getPos _heli; + _destination = [_currentHeliPos, 1, 150, 10, 0, 20, 0] call BIS_fnc_findSafePos; + _heli setVehicleLock "UNLOCKED"; + _target = _this select 1; + _group = group _heli; + _group reveal [_target,2.5]; + _destination = position _target; + + _heli land "LAND"; + _group2 = createGroup east; + { + _x join _group2; + } forEach (fullCrew _heli); + + _group2 allowFleeing 0; + _wp = _group2 addWaypoint [_destination, 0] ; + _wp setWaypointBehaviour "COMBAT"; + _wp setWaypointCombatMode "RED"; + _wp setWaypointCompletionRadius 10; + _wp setWaypointType "GETOUT"; + + [_group2, _destination, 250] call bis_fnc_taskPatrol; + _group2 setBehaviour "COMBAT"; + _group2 setCombatMode "RED"; }; \ No newline at end of file diff --git a/scripts/reactions/boatHit.sqf b/scripts/reactions/boatHit.sqf new file mode 100644 index 0000000..e69de29 diff --git a/scripts/reactions/comeUnstuck.sqf b/scripts/reactions/comeUnstuck.sqf new file mode 100644 index 0000000..d0d109c --- /dev/null +++ b/scripts/reactions/comeUnstuck.sqf @@ -0,0 +1,75 @@ +// Unstuck based on a function written by Chris (infiSTAR) +// http://pastebin.com/73pjvXPw + + +private["_vehicle","_curPos","_oldvehPos","_engineTime","_newPos"]; +_vehicle = _this select 0; + +if(count(crew _vehicle) > 0)then +{ + _curPos = position _vehicle; + _newPos = _curPos; + _oldvehPos = _vehicle getVariable["vehPos",[0,0,0]]; + if(isNil "_oldvehPos") then { _oldvehPos = [0,0,0]; }; + if(str _oldvehPos != "[0,0,0]")then + { + if(_curPos distance _oldvehPos < 2)then + { + _engineTime = _vehicle getVariable["engineTime",-1]; + if(_engineTime < 0)then + { + _vehicle setVariable["engineTime",time]; + }; + if(time - _engineTime > 10)then + { + + _logDetail = format ["[OCCUPATION:Unstuck]:: %1 is stuck,attempting to unstick from %2 @ %3",_vehicle,_curPos,time]; + [_logDetail] call SC_fnc_log; + + _vehicle setVariable["engineTime",-1]; + + _vehicle setVectorUp [0,0,1]; + + _originalSpawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; + _group = group _vehicle; + //_vehClass = _vehicle getVariable "vehClass"; + _vehClass = typeOf _vehicle; + + if(_vehicle isKindOf "LandVehicle") then + { + //_newPos = [ _curPos, 1, 15, [ 0, 0, 1, 0, 0, 0, 0, 0, true] ] call DMS_fnc_FindSafePos_InRange; + //_newPos = [_curPos, 5, 20, 3, 0, 20, 0] call BIS_fnc_findSafePos; + _tempPos = _curPos findEmptyPosition [0,50,_vehClass]; + _newPos = [_tempPos select 0, _tempPos select 1, 0]; + _vehicle setPosATL _newPos; + }; + + if(_vehicle isKindOf "Ship") then + { + //_newPos = [ _curPos, 1,15, [ 0, 0, 1, 0, 0, 0, 0, 0, true, true ] ] call DMS_fnc_FindSafePos_InRange; + //_newPos = [_curPos, 5, 20, 3, 2, 20, 0] call BIS_fnc_findSafePos; + _newPos = _curPos findEmptyPosition [0,50,_vehClass]; + _newPos = [_newPos select 0, _newPos select 1, 0]; + _vehicle setPosATL _newPos; + + }; + + if(_vehicle isKindOf "Air") then + { + _newPos = _curPos; + }; + _GroupLeader = leader (group _vehicle); + _GroupLeader doMove _originalSpawnLocation; + [_group, _originalSpawnLocation, 2000] call bis_fnc_taskPatrol; + _group setBehaviour "AWARE"; + _group setCombatMode "RED"; + + _logDetail = format ["[OCCUPATION:Unstuck]:: %1 was stuck and was moved from %2 to %3 @ %4",_vehicle,_curPos,_newPos, time]; + [_logDetail] call SC_fnc_log; + + }; + }; + }; + _vehicle setVariable["vehPos",_newPos]; +}; + diff --git a/scripts/reactions/driverKilled.sqf b/scripts/reactions/driverKilled.sqf index 1766af3..f4c6433 100644 --- a/scripts/reactions/driverKilled.sqf +++ b/scripts/reactions/driverKilled.sqf @@ -28,7 +28,13 @@ if(count units _vehGroup > 0) then _groupMembers = units _vehGroup; _replacementDriver = _groupMembers call BIS_fnc_selectRandom; - if(!alive _replacementDriver) exitWith { [_replacementDriver] call SC_fnc_driverKilled; }; + while(!(alive _replacementDriver) && (count units _vehGroup > 0)) do + { + [_replacementDriver] join grpNull; + if(count units _vehGroup < 1) exitWith {}; + _groupMembers = units _vehGroup; + _replacementDriver = _groupMembers call BIS_fnc_selectRandom; + }; if (isNil "_replacementDriver") exitWith { @@ -36,24 +42,25 @@ if(count units _vehGroup > 0) then [_logDetail] call SC_fnc_log; }; - if(SC_debug) then - { - _tag = createVehicle ["Sign_Arrow_Green_F", position _replacementDriver, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_replacementDriver,[0,0,0.6],"Head"]; - }; - + _replacementDriver disableAI "TARGET"; _replacementDriver disableAI "AUTOTARGET"; _replacementDriver disableAI "AUTOCOMBAT"; _replacementDriver disableAI "COVER"; _replacementDriver assignAsDriver _vehicleDriven; - - _vehicleDriven addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; - _replacementDriver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; _replacementDriver setVariable ["DMS_AssignedVeh",_vehicleDriven]; _replacementDriver setVariable ["SC_drivenVehicle", _vehicleDriven,true]; - _vehicleDriven setVariable ["SC_assignedDriver", _replacementDriver,true]; + _vehicleDriven setVariable ["SC_assignedDriver", _replacementDriver,true]; + _vehicleDriven addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"]; + _replacementDriver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; + + if(SC_debug) then + { + _tag = createVehicle ["Sign_Arrow_Green_F", position _replacementDriver, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_replacementDriver,[0,0,0.6],"Head"]; + }; + _replacementDriver doMove (position _vehicleDriven); _replacementDriver action ["movetodriver", _vehicleDriven]; diff --git a/scripts/reactions/getIn.sqf b/scripts/reactions/getIn.sqf index e499552..8948649 100644 --- a/scripts/reactions/getIn.sqf +++ b/scripts/reactions/getIn.sqf @@ -6,9 +6,7 @@ _unit = _this select 0; if(isPlayer _unit) then { _vehicle = vehicle _unit; - _vehicle removeAllMPEventHandlers "mphit"; - _vehicle removeAllMPEventHandlers "mpkilled"; - SC_liveVehicles = SC_liveVehicles - 1; + [_vehicle] call SC_fnc_vehicleDestroyed; if(SC_extendedLogging) then { diff --git a/scripts/reactions/refuel.sqf b/scripts/reactions/refuel.sqf new file mode 100644 index 0000000..06ad962 --- /dev/null +++ b/scripts/reactions/refuel.sqf @@ -0,0 +1,18 @@ +// Triggered when a vehicle runs out of fuel but only if not damaged + +_vehicle = _this select 0; +_fuel = _this select 1; + +diag_log format["[OCCUPATION:refuelcheck] _vehicle: %1 ---- _fuel: %2 ",_vehicle,_fuel]; +/* +if(!isNil "_vehicle" && !isNil "_fuel") then +{ + _damage = getdammage _vehicle; + + if(_damage <> 0 && !_fuel) then + { + _vehicle setFuel 1; + _vehicle engineOn true; + }; +}; +*/ diff --git a/scripts/reactions/repairVehicle.sqf b/scripts/reactions/repairVehicle.sqf index 011f8d3..3586617 100644 --- a/scripts/reactions/repairVehicle.sqf +++ b/scripts/reactions/repairVehicle.sqf @@ -48,6 +48,7 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then { _vehicle = _this select 0; _vehicle forceSpeed 0; + sleep 1; _vehGroup = group _vehicle; _driver = _this select 1; _driver action ["getOut", _vehicle]; diff --git a/scripts/reactions/vehicleDestroyed.sqf b/scripts/reactions/vehicleDestroyed.sqf index e69de29..82c2ebb 100644 --- a/scripts/reactions/vehicleDestroyed.sqf +++ b/scripts/reactions/vehicleDestroyed.sqf @@ -0,0 +1,24 @@ +// SC_liveVehicles = count of vehicle +// SC_liveVehiclesArray = array of active vehicles + +_vehicle = _this select 0; +_vehicle removeAllMPEventHandlers "mphit"; +_vehicle removeAllMPEventHandlers "mpkilled"; + +if(_vehicle isKindOf "LandVehicle") then +{ + SC_liveVehicles = SC_liveVehicles - 1; + SC_liveVehiclesArray = SC_liveVehiclesArray - [_vehicle]; +}; + +if(_vehicle isKindOf "Air") then +{ + SC_liveHelis = SC_liveHelis - 1; + SC_liveHelisArray = SC_liveHelisArray - [_vehicle]; +}; + +if(_vehicle isKindOf "Ship") then +{ + SC_liveBoatss = SC_liveBoatss - 1; + SC_liveBoatsArray = SC_liveBoatsArray - [_vehicle]; +}; diff --git a/scripts/startOccupation.sqf b/scripts/startOccupation.sqf index 68757a4..b3e598a 100644 --- a/scripts/startOccupation.sqf +++ b/scripts/startOccupation.sqf @@ -1,6 +1,6 @@ _logDetail = format ["[OCCUPATION]:: Occupation v%2 Giving the server time to start before starting [OCCUPATION] (%1)",time,SC_occupationVersion]; [_logDetail] call SC_fnc_log; -uiSleep 30; +uiSleep 60; _logDetail = format ["[OCCUPATION]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion]; [_logDetail] call SC_fnc_log; @@ -28,37 +28,48 @@ if(SC_occupyHeliCrashes) then if(SC_occupyStatic) then { uiSleep 15; // delay the start - fnc_occupationStaticMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationStatic.sqf"; - [SC_refreshTime, fnc_occupationStaticMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationStatic = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationStatic.sqf"; + [SC_refreshTime, fnc_occupationStatic, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupySky) then { uiSleep 15; // delay the start - fnc_occupationSkyMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationSky.sqf"; - [SC_refreshTime, fnc_occupationSkyMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationSky = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationSky.sqf"; + [SC_refreshTime, fnc_occupationSky, [], true] call ExileServer_system_thread_addTask; +}; + +if(SC_occupySea) then +{ + uiSleep 15; // delay the start + fnc_occupationSea = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationSea.sqf"; + [SC_refreshTime, fnc_occupationSea, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupyVehicle) then { uiSleep 15; // delay the start - fnc_occupationVehicleMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationVehicle.sqf"; - [SC_refreshTime, fnc_occupationVehicleMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationVehicle = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationVehicle.sqf"; + [SC_refreshTime, fnc_occupationVehicle, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupyPlaces) then { uiSleep 15; // delay the start - fnc_occupationMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationPlaces.sqf"; - [SC_refreshTime, fnc_occupationMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationPlaces = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationPlaces.sqf"; + [SC_refreshTime, fnc_occupationPlaces, [], true] call ExileServer_system_thread_addTask; }; if(SC_occupyMilitary) then { uiSleep 15; // delay the start - fnc_occupationMilitaryMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMilitary.sqf"; - [SC_refreshTime, fnc_occupationMilitaryMonitor, [], true] call ExileServer_system_thread_addTask; + fnc_occupationMilitary = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMilitary.sqf"; + [SC_refreshTime, fnc_occupationMilitary, [], true] call ExileServer_system_thread_addTask; }; +uiSleep 15; // delay the start +fnc_occupationMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMonitor.sqf"; +[SC_refreshTime, fnc_occupationMonitor, [], true] call ExileServer_system_thread_addTask; + _logDetail = format ["[OCCUPATION]:: threads added at %1",time]; [_logDetail] call SC_fnc_log; \ No newline at end of file