diff --git a/changeLog.txt b/changeLog.txt index ef7762d..b82d6f9 100644 --- a/changeLog.txt +++ b/changeLog.txt @@ -1,3 +1,10 @@ +================================================================================= +V54 (26-07-2016) +================================================================================= +Reworked military spawning to include the entire map rather than a small area +Tweaked the spawning of AI in an attempt to stop groups of AI randomly murdering +each other when spawning (thanks to Zupa for the pointers) + ================================================================================= V53 (20-07-2016) ================================================================================= diff --git a/config.cpp b/config.cpp index 3a04710..72959c2 100644 --- a/config.cpp +++ b/config.cpp @@ -4,7 +4,7 @@ class CfgPatches units[] = {}; weapons[] = {}; requiredVersion = 0.1; - a3_exile_occupation_version = "v53 (20-07-2016)"; + a3_exile_occupation_version = "v54 (26-07-2016)"; requiredAddons[] = {"a3_dms"}; author[]= {"second_coming"}; }; diff --git a/config.sqf b/config.sqf index 78de29f..bfb247f 100644 --- a/config.sqf +++ b/config.sqf @@ -109,7 +109,7 @@ 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_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","B_T_VTOL_01_infantry_blue_F"]; // to always use the same vehicle, specify one option only +SC_occupyTransportClass = ["Exile_Chopper_Hummingbird_Green"]; // to always use the same vehicle, specify one option only SC_occupyTransportStartPos = []; // if empty defaults to map centre @@ -159,17 +159,19 @@ SC_LootCrateItems = [ ["Exile_Item_MetalPole",1,0], ["Exile_Item_LightBulb",1,0], ["Exile_Item_FuelCanisterEmpty",1,0], - ["Exile_Item_WoodPlank",1,8], - ["Exile_Item_woodFloorKit",1,2], - ["Exile_Item_WoodWindowKit",1,1], - ["Exile_Item_WoodDoorwayKit",1,1], - ["Exile_Item_WoodFloorPortKit",1,2], + ["Exile_Item_WoodPlank",0,8], + ["Exile_Item_woodFloorKit",0,2], + ["Exile_Item_WoodWindowKit",0,1], + ["Exile_Item_WoodDoorwayKit",0,1], + ["Exile_Item_WoodFloorPortKit",0,2], ["Exile_Item_Laptop",0,1], ["Exile_Item_CodeLock",0,1], ["Exile_Item_Cement",2,10], ["Exile_Item_Sand",2,10], ["Exile_Item_MetalWire",1,5], - ["Exile_Item_WaterCanisterEmpty",0,2] + ["Exile_Item_WaterCanisterEmpty",0,2], + ["Exile_Item_Shovel",0,1], + ["Exile_Item_MetalScrews",0,5] ]; SC_blackListedAreas = [ @@ -264,37 +266,29 @@ SC_BanditFirstNames = ["Alex","Nikita","George","Daniel","Adam","Alexander SC_BanditLastNames = ["Dimitrov","Petrov","Horvat","Novak","Dvorak","Vesely","Horak","Hansen","Larsen","Tamm","Ivanov","Pavlov","Virtanen"]; -SC_occupyMilitary = false; // true if you want military buildings patrolled +SC_occupyMilitary = true; // true if you want military buildings patrolled // Array of buildings to add military patrols to -SC_buildings = [ "Land_TentHangar_V1_F","Land_Hangar_F", - "Land_Airport_Tower_F","Land_Cargo_House_V1_F", - "Land_Cargo_House_V3_F","Land_Cargo_HQ_V1_F", - "Land_Cargo_HQ_V2_F","Land_Cargo_HQ_V3_F", - "Land_u_Barracks_V2_F","Land_i_Barracks_V2_F", - "Land_i_Barracks_V1_F","Land_Cargo_Patrol_V1_F", - "Land_Cargo_Patrol_V2_F","Land_Cargo_Tower_V1_F", - "Land_Cargo_Tower_V1_No1_F","Land_Cargo_Tower_V1_No2_F", - "Land_Cargo_Tower_V1_No3_F","Land_Cargo_Tower_V1_No4_F", - "Land_Cargo_Tower_V1_No5_F","Land_Cargo_Tower_V1_No6_F", - "Land_Cargo_Tower_V1_No7_F","Land_Cargo_Tower_V2_F", - "Land_Cargo_Tower_V3_F","Land_MilOffices_V1_F", - "Land_Radar_F","Land_budova4_winter","land_hlaska", - "Land_Vysilac_FM","land_st_vez","Land_ns_Jbad_Mil_Barracks", - "Land_ns_Jbad_Mil_ControlTower","Land_ns_Jbad_Mil_House", - "land_pozorovatelna","Land_vys_budova_p1", - "Land_Vez","Land_Mil_Barracks_i", - "Land_Mil_Barracks_L","Land_Mil_Barracks", - "Land_Hlidac_budka","Land_Ss_hangar", - "Land_Mil_ControlTower","Land_a_stationhouse", - "Land_Farm_WTower","Land_Mil_Guardhouse", - "Land_A_statue01","Land_A_Castle_Gate", - "Land_A_Castle_Donjon","Land_A_Castle_Wall2_30", - "Land_A_Castle_Stairs_A", - "Land_i_Barracks_V1_dam_F","Land_Cargo_Patrol_V3_F", - "Land_Radar_Small_F","Land_Dome_Big_F", - "Land_Dome_Small_F","Land_Army_hut3_long_int", - "Land_Army_hut_int","Land_Army_hut2_int" +SC_buildings = [ "Land_TentHangar_V1_F","Land_Hangar_F","Land_Airport_Tower_F","Land_Cargo_House_V1_F", + "Land_Cargo_House_V3_F","Land_Cargo_HQ_V1_F","Land_Cargo_HQ_V2_F","Land_Cargo_HQ_V3_F", + "Land_u_Barracks_V2_F","Land_i_Barracks_V2_F","Land_i_Barracks_V1_F","Land_Cargo_Patrol_V1_F", + "Land_Cargo_Patrol_V2_F","Land_Cargo_Tower_V1_F","Land_Cargo_Tower_V1_No1_F","Land_Cargo_Tower_V1_No2_F", + "Land_Cargo_Tower_V1_No3_F","Land_Cargo_Tower_V1_No4_F","Land_Cargo_Tower_V1_No5_F","Land_Cargo_Tower_V1_No6_F", + "Land_Cargo_Tower_V1_No7_F","Land_Cargo_Tower_V2_F","Land_Cargo_Tower_V3_F","Land_MilOffices_V1_F", + "Land_Radar_F","Land_budova4_winter","land_hlaska","Land_Vysilac_FM","land_st_vez","Land_ns_Jbad_Mil_Barracks", + "Land_ns_Jbad_Mil_ControlTower","Land_ns_Jbad_Mil_House","land_pozorovatelna","Land_vys_budova_p1", + "Land_Vez","Land_Mil_Barracks_i","Land_Mil_Barracks_L","Land_Mil_Barracks", + "Land_Hlidac_budka","Land_Ss_hangar","Land_Mil_ControlTower","Land_a_stationhouse", + "Land_Farm_WTower","Land_Mil_Guardhouse","Land_A_statue01","Land_A_Castle_Gate", + "Land_A_Castle_Donjon","Land_A_Castle_Wall2_30","Land_A_Castle_Stairs_A", + "Land_i_Barracks_V1_dam_F","Land_Cargo_Patrol_V3_F","Land_Radar_Small_F","Land_Dome_Big_F", + "Land_Dome_Small_F","Land_Army_hut3_long_int","Land_Army_hut_int","Land_Army_hut2_int", + // Additional Buildings + "Land_Barracks_01_camo_F","Land_Barracks_01_grey_F","land_AII_last_floor","land_AII_middle_floor", + "land_AII_upper_part","Land_Ind_IlluminantTower","Land_Misc_deerstand","Land_ns_Jbad_A_Stationhouse", + "Land_Airport_01_controlTower_F","Land_Airport_01_terminal_F","Land_Airport_02_controlTower_F", + "Land_Airport_02_terminal_F","Land_Cargo_House_V4_F","Land_Cargo_HQ_V4_F","Land_Cargo_Patrol_V4_F", + "Land_Cargo_Tower_V4_F" ]; // namalsk specific settings (if you want to override settings for specific maps if you run multiple servers) @@ -319,20 +313,18 @@ if (worldName == 'Napf' AND SC_useMapOverrides) then if (worldName == 'Tanoa' AND SC_useMapOverrides) then { SC_useApexClasses = true; - SC_maxAIcount = 80; - SC_maxNumberofVehicles = 3; - SC_scaleAI = 1; + SC_maxAIcount = 80; }; // 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"]; + "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"]; + "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 = [ ["B_GEN_Offroad_01_gen_F",0], ["C_Offroad_02_unarmed_F",0], @@ -356,7 +348,7 @@ if (SC_debug) then SC_occupyMilitary = true; SC_occupyStatic = true; SC_occupySky = true; - SC_occupySea = true; + SC_occupySea = false; SC_occupyTransport = true; SC_occupyLootCrates = true; SC_occupyHeliCrashes = true; diff --git a/scripts/eventHandlers/vehicleDestroyed.sqf b/scripts/eventHandlers/vehicleDestroyed.sqf index e3b5559..fbc20df 100644 --- a/scripts/eventHandlers/vehicleDestroyed.sqf +++ b/scripts/eventHandlers/vehicleDestroyed.sqf @@ -1,6 +1,6 @@ _vehicle = _this select 0; _vehicle removeAllMPEventHandlers "mphit"; -_vehicle removeAllMPEventHandlers "mpkilled"; +//_vehicle removeAllMPEventHandlers "mpkilled"; _vehicle removeAllEventHandlers "getin"; _vehicle removeAllEventHandlers "getout"; diff --git a/scripts/functions/fnc_isSafePos.sqf b/scripts/functions/fnc_isSafePos.sqf index f0aaf33..af667b8 100644 --- a/scripts/functions/fnc_isSafePos.sqf +++ b/scripts/functions/fnc_isSafePos.sqf @@ -16,7 +16,7 @@ private _validspot = true; { _distance = _position distance2D _blacklistPos; - if(_distance < _blacklistRadius) exitWith + if(_distance < _blacklistRadius) then { _validspot = false; diag_log format["%1 is %2m from blacklisted position %3 (blacklisted)",_position,_distance,_blacklistPos]; @@ -24,20 +24,23 @@ private _validspot = true; }; }forEach SC_blackListedAreas; -//Check if near player territory -private _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],SC_minDistanceToTerritory]) select 0; -if (!isNil "_nearBase") then { _validspot = false; }; +if(_validspot) then +{ + //Check if near player territory + private _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],SC_minDistanceToTerritory]) select 0; + if (!isNil "_nearBase") then { _validspot = false; }; -// is position in range of a territory? -if([_position, SC_minDistanceToTerritory] call ExileClient_util_world_isTerritoryInRange) exitwith { _validspot = false; }; + // is position in range of a territory? + if([_position, SC_minDistanceToTerritory] call ExileClient_util_world_isTerritoryInRange) exitwith { _validspot = false; }; -// is position in range of a trader zone? -if([_position, SC_minDistanceToTraders] call ExileClient_util_world_isTraderZoneInRange) exitwith { _validspot = false; }; + // is position in range of a trader zone? + if([_position, SC_minDistanceToTraders] call ExileClient_util_world_isTraderZoneInRange) exitwith { _validspot = false; }; -// is position in range of a spawn zone? -if([_position, SC_minDistanceToSpawnZones] call ExileClient_util_world_isSpawnZoneInRange) exitwith { _validspot = false; }; + // is position in range of a spawn zone? + if([_position, SC_minDistanceToSpawnZones] call ExileClient_util_world_isSpawnZoneInRange) exitwith { _validspot = false; }; -// is position in range of a player? -if([_position, SC_minDistanceToPlayer] call ExileClient_util_world_isAlivePlayerInRange) exitwith { _validspot = false; }; + // is position in range of a player? + if([_position, SC_minDistanceToPlayer] call ExileClient_util_world_isAlivePlayerInRange) exitwith { _validspot = false; }; +}; _validspot \ No newline at end of file diff --git a/scripts/functions/fnc_spawnStatics.sqf b/scripts/functions/fnc_spawnStatics.sqf index bd63aeb..57b649e 100644 --- a/scripts/functions/fnc_spawnStatics.sqf +++ b/scripts/functions/fnc_spawnStatics.sqf @@ -66,6 +66,11 @@ if(_side == "survivor") then { _currentSide = SC_SurvivorSide }; { _loadOut = [_side] call SC_fnc_selectGear; _unit = [_initialGroup,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unit allowFleeing 0; + _unit allowDamage false; + _unit disableAI "AUTOTARGET"; + _unit disableAI "TARGET"; + _unit disableAI "MOVE"; _unitName = [_side] call SC_fnc_selectName; if(!isNil "_unitName") then { _unit setName _unitName; }; _unit setVariable ["SC_staticUID",_staticUID]; @@ -88,6 +93,10 @@ if(_side == "survivor") then { _currentSide = SC_SurvivorSide }; _unit = _x; [_unit] joinSilent grpNull; [_unit] joinSilent _group; + _unit allowDamage true; + _unit enableAI "AUTOTARGET"; + _unit enableAI "TARGET"; + _unit enableAI "MOVE"; [_side,_unit] call SC_fnc_addMarker; _unit setCaptive false; }foreach units _initialGroup; diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index 60fa21f..7308d33 100644 --- a/scripts/occupationMilitary.sqf +++ b/scripts/occupationMilitary.sqf @@ -19,7 +19,7 @@ if(_currentPlayerCount > _scaleAI) then _maxAIcount = _maxAIcount - (_currentPlayerCount - _scaleAI) ; }; -// Don't spawn additional AI if the server fps is below 8 +// Don't spawn additional AI if the server fps is below _minFPS if(diag_fps < _minFPS) exitWith { _logDetail = format ["[OCCUPATION Military]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; @@ -34,211 +34,177 @@ if(_aiActive > _maxAIcount) exitWith [_logDetail] call SC_fnc_log; }; -// Select an area to scan as nearObjects on the entire map is slooooooooow -_areaToScan = [ false, false ] call SC_fnc_findsafePos; + { - _logDetail = format ["[OCCUPATION Military]:: scanning buildings around %2 started at %1",time,_areaToScan]; - [_logDetail] call SC_fnc_log; + _okToSpawn = true; + Sleep 0.1; + + _foundBuilding = _x select 0; + _location = getPos _foundBuilding; + _pos = [_location select 0, _location select 1, 0]; - _currentBuilding = _x; - _building = _areaToScan nearObjects [_currentBuilding, _maxDistance]; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION Military]:: Testing position: %1",_pos]; + [_logDetail] call SC_fnc_log; + }; - _logDetail = format ["[OCCUPATION Military]:: scan for %2 building finished at %1",time,_currentBuilding]; - [_logDetail] call SC_fnc_log; - - - { - _okToSpawn = true; - Sleep 0.1; - _foundBuilding = _x; - _location = getPos _foundBuilding; - _pos = [_location select 0, _location select 1, 0]; - - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION Military]:: Testing position: %1",_pos]; - [_logDetail] call SC_fnc_log; - }; - - while{_okToSpawn} do - { - // Percentage chance to spawn (roll 70 or more to spawn AI) - _spawnChance = round (random 100); - if(_spawnChance < 70) exitWith - { - _okToSpawn = false; - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION Military]:: Rolled %1 so not spawning AI this time",_spawnChance]; - [_logDetail] call SC_fnc_log; - }; - }; - - // Don't spawn if too near a player base - _nearBase = (nearestObjects [_pos,["Exile_Construction_Flag_Static"],500]) select 0; - if (!isNil "_nearBase") exitwith - { - _okToSpawn = false; - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION Military]:: %1 is too close to player base",_pos]; - [_logDetail] call SC_fnc_log; - }; - }; - - // Don't spawn AI near traders and spawn zones - _nearestMarker = [allMapMarkers, _pos] call BIS_fnc_nearestPosition; // Nearest Marker to the Location - _posNearestMarker = getMarkerPos _nearestMarker; - if(_pos distance _posNearestMarker < 500) exitwith - { - _okToSpawn = false; - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION Military]:: %1 is too close to a %2",_pos,_nearestMarker]; - [_logDetail] call SC_fnc_log; - }; - }; - - // Don't spawn additional AI if there are already AI in range - _aiNear = count(_pos nearEntities ["O_recon_F", 500]); - if(_aiNear > 0) exitwith - { - _okToSpawn = false; - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION Military]:: %1 already has %2 active AI patrolling",_pos,_aiNear]; - [_logDetail] call SC_fnc_log; - }; - }; - - // Don't spawn additional AI if there are players in range - if([_pos, 250] call ExileClient_util_world_isAlivePlayerInRange) exitwith - { - _okToSpawn = false; - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION Military]:: %1 has players too close",_pos]; - [_logDetail] call SC_fnc_log; - }; - }; - - if(_okToSpawn) then - { - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Get AI to patrol the area - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - _aiCount = 2 + (round (random 1)); - _groupRadius = 100; - _difficulty = "random"; - _side = SC_BanditSide; - _spawnPosition = _pos; - - // Get the AI to shut the fuck up :) - enableSentences false; - enableRadio false; - - if(!SC_useWaypoints) then - { - DMS_ai_use_launchers = false; - _group = [_spawnPosition, _aiCount, _difficulty, "random", "bandit"] call DMS_fnc_SpawnAIGroup; - DMS_ai_use_launchers = _useLaunchers; - - { - _unit = _x; - [_unit] joinSilent grpNull; - [_unit] joinSilent _group; - _unitName = ["bandit"] call SC_fnc_selectName; - if(!isNil "_unitName") then { _unit setName _unitName; }; - reload _unit; - 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"; - } - else - { - - DMS_ai_use_launchers = false; - _group = [_spawnPosition, _aiCount, _difficulty, "random", "bandit"] call DMS_fnc_SpawnAIGroup; - DMS_ai_use_launchers = _useLaunchers; - - { - _unit = _x; - [_unit] joinSilent grpNull; - [_unit] joinSilent _group; - _unitName = ["bandit"] call SC_fnc_selectName; - if(!isNil "_unitName") then { _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,_difficulty,"COMBAT" ] call DMS_fnc_SetGroupBehavior; - - _buildings = _pos nearObjects ["house", _groupRadius]; - { - _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; - if(count _buildingPositions > 0) then - { - _y = _x; - - // Find Highest Point - _highest = [0,0,0]; - { - if(_x select 2 > _highest select 2) then - { - _highest = _x; - }; - - } foreach _buildingPositions; - _spawnPosition = _highest; - - _i = _buildingPositions find _spawnPosition; - _wp = _group addWaypoint [_spawnPosition, 0] ; - _wp setWaypointFormation "Column"; - _wp setWaypointBehaviour "AWARE"; - _wp setWaypointCombatMode "RED"; - _wp setWaypointCompletionRadius 1; - _wp waypointAttachObject _y; - _wp setwaypointHousePosition _i; - _wp setWaypointType "SAD"; - - }; - } foreach _buildings; - if(count _buildings > 0 ) then - { - _wp setWaypointType "CYCLE"; - }; - }; - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - _logDetail = format ["[OCCUPATION Military]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition]; - [_logDetail] call SC_fnc_log; - - if(SC_mapMarkers) then - { - _marker = createMarker [format ["%1", _foundBuilding],_pos]; - _marker setMarkerShape "Icon"; - _marker setMarkerSize [3,3]; - _marker setMarkerType "mil_dot"; - _marker setMarkerBrush "Solid"; - _marker setMarkerAlpha 0.5; - _marker setMarkerColor "ColorRed"; - _marker setMarkerText "Occupied Military Area"; - }; - _okToSpawn = false; - }; + while{_okToSpawn && !isNil "_pos"} do + { + // Percentage chance to spawn (roll 80 or more to spawn AI) + _spawnChance = round (random 100); + if(_spawnChance < 80) exitWith + { + _okToSpawn = false; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION Military]:: Rolled %1 so not spawning AI this time",_spawnChance]; + [_logDetail] call SC_fnc_log; + }; }; - }foreach _building; -}foreach _buildings; + + _safePos = [ _pos ] call SC_fnc_isSafePos; + if(!_safePos OR isNil "_safePos") then + { + _okToSpawn = false; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION Military]:: %1 determined as an unsafe position to spawn AI",_pos]; + [_logDetail] call SC_fnc_log; + }; + }; + + + // Don't spawn additional AI if there are already AI in range + _aiNear = count(_pos nearEntities [DMS_AI_Classname, 500]); + if(_aiNear > 0) exitwith + { + _okToSpawn = false; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION Military]:: %1 already has %2 active AI patrolling",_pos,_aiNear]; + [_logDetail] call SC_fnc_log; + }; + }; + + + if(_okToSpawn) then + { + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Get AI to patrol the area + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + _aiCount = 2 + (round (random 1)); + _groupRadius = 100; + _difficulty = "random"; + _side = SC_BanditSide; + _spawnPosition = _pos; + + // Get the AI to shut the fuck up :) + enableSentences false; + enableRadio false; + + if(!SC_useWaypoints) then + { + DMS_ai_use_launchers = false; + _group = [_spawnPosition, _aiCount, _difficulty, "random", "bandit"] call DMS_fnc_SpawnAIGroup; + DMS_ai_use_launchers = _useLaunchers; + + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + _unitName = ["bandit"] call SC_fnc_selectName; + if(!isNil "_unitName") then { _unit setName _unitName; }; + reload _unit; + 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 "AWARE"; + _group setCombatMode "RED"; + } + else + { + + DMS_ai_use_launchers = false; + _group = [_spawnPosition, _aiCount, _difficulty, "random", "bandit"] call DMS_fnc_SpawnAIGroup; + DMS_ai_use_launchers = _useLaunchers; + + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + _unitName = ["bandit"] call SC_fnc_selectName; + if(!isNil "_unitName") then { _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,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior; + + _buildings = _pos nearObjects ["house", _groupRadius]; + { + _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions; + if(count _buildingPositions > 0) then + { + _y = _x; + + // Find Highest Point + _highest = [0,0,0]; + { + if(_x select 2 > _highest select 2) then + { + _highest = _x; + }; + + } foreach _buildingPositions; + _spawnPosition = _highest; + + _i = _buildingPositions find _spawnPosition; + _wp = _group addWaypoint [_spawnPosition, 0] ; + _wp setWaypointFormation "Column"; + _wp setWaypointBehaviour "AWARE"; + _wp setWaypointCombatMode "RED"; + _wp setWaypointCompletionRadius 1; + _wp waypointAttachObject _y; + _wp setwaypointHousePosition _i; + _wp setWaypointType "SAD"; + + }; + } foreach _buildings; + if(count _buildings > 0 ) then + { + _wp setWaypointType "CYCLE"; + }; + }; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + _logDetail = format ["[OCCUPATION Military]:: Spawning %1 AI in at %2 to patrol",_aiCount,_spawnPosition]; + [_logDetail] call SC_fnc_log; + + if(SC_mapMarkers) then + { + _marker = createMarker [format ["%1", _foundBuilding],_pos]; + _marker setMarkerShape "Icon"; + _marker setMarkerSize [3,3]; + _marker setMarkerType "mil_dot"; + _marker setMarkerBrush "Solid"; + _marker setMarkerAlpha 0.5; + _marker setMarkerColor "ColorRed"; + _marker setMarkerText "Occupied Military Area"; + }; + _okToSpawn = false; + }; + }; +}foreach SC_completeMilitaryList; + _logDetail = "[OCCUPATION Military]: Ended"; [_logDetail] call SC_fnc_log; \ No newline at end of file diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index 175dd9e..5189a0b 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -142,7 +142,12 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi 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; + _unit = [_group,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unit allowFleeing 0; + _unit allowDamage false; + _unit disableAI "AUTOTARGET"; + _unit disableAI "TARGET"; + _unit disableAI "MOVE"; _unit setVariable ["SC_unitLocationName", _locationName,true]; _unit setVariable ["SC_unitLocationPosition", _pos,true]; _unit setVariable ["SC_unitSide", _side,true]; @@ -158,7 +163,11 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi { _unit = _x; [_unit] joinSilent grpNull; - [_unit] joinSilent _group; + [_unit] joinSilent _group; + _unit allowDamage true; + _unit enableAI "AUTOTARGET"; + _unit enableAI "TARGET"; + _unit enableAI "MOVE"; _unitName = [_side] call SC_fnc_selectName; if(!isNil "_unitName") then { _unit setName _unitName; }; [_side,_unit] call SC_fnc_addMarker; @@ -234,6 +243,11 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi { _loadOut = ["bandit"] call SC_fnc_selectGear; _unit = [_group2,_spawnPosition,"custom","random",_side,"soldier",_loadOut] call DMS_fnc_SpawnAISoldier; + _unit allowFleeing 0; + _unit allowDamage false; + _unit disableAI "AUTOTARGET"; + _unit disableAI "TARGET"; + _unit disableAI "MOVE"; _unit setVariable ["SC_unitLocationName", _locationName,true]; _unit setVariable ["SC_unitLocationPosition", _pos,true]; _unit setVariable ["SC_unitSide", _side,true]; @@ -253,6 +267,10 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _unit = _x; [_unit] joinSilent grpNull; [_unit] joinSilent _group2; + _unit allowDamage true; + _unit enableAI "AUTOTARGET"; + _unit enableAI "TARGET"; + _unit enableAI "MOVE"; [_side,_unit] call SC_fnc_addMarker; _unitName = [_side] call SC_fnc_selectName; if(!isNil "_unitName") then { _unit setName _unitName; }; diff --git a/scripts/occupationTransport.sqf b/scripts/occupationTransport.sqf index a6a2cd6..0da4449 100644 --- a/scripts/occupationTransport.sqf +++ b/scripts/occupationTransport.sqf @@ -119,7 +119,7 @@ while {true} do _transport setFuel 1; _transport setDamage 0; _transport engineOn true; - _transport flyInHeight 100; + _transport flyInHeight 300; } else { diff --git a/scripts/startOccupation.sqf b/scripts/startOccupation.sqf index ffc0d10..a13a404 100644 --- a/scripts/startOccupation.sqf +++ b/scripts/startOccupation.sqf @@ -37,6 +37,36 @@ if (SC_fastNights) then [60, fnc_checkMultiplier, [], true] call ExileServer_system_thread_addTask; }; +if(SC_occupyMilitary) then +{ + uiSleep 15; // delay the start + + // Create a static list of military buildings rather than scanning every time we want to spawn military guards + _logDetail = format ["[OCCUPATION Military]:: Starting building scan @ ",time]; + [_logDetail] call SC_fnc_log; + _middle = worldSize/2; + _areaToScan = [_middle,_middle,0]; // Centre point for the map + _maxDistance = 20000; // Max radius for the map + SC_completeMilitaryList = []; + { + _currentBuilding = _x; + _foundBuilding = _areaToScan nearObjects [_currentBuilding, _maxDistance]; + { + _pos = position _x; + SC_completeMilitaryList pushBack _foundBuilding; + _logDetail = format ["[OCCUPATION Military]:: Added building: %1 (object: %3) found at location: %2 @ ",_currentBuilding,_pos,_x]; + [_logDetail] call SC_fnc_log; + }forEach _foundBuilding; + + }forEach SC_buildings; + + _logDetail = format ["[OCCUPATION Military]:: Ended building scan @ ",time]; + [_logDetail] call SC_fnc_log; + + fnc_occupationMilitary = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMilitary.sqf"; + [SC_refreshTime, fnc_occupationMilitary, [], true] call ExileServer_system_thread_addTask; +}; + if(SC_occupyRandomSpawn) then { uiSleep 15; // delay the start @@ -90,13 +120,6 @@ if(SC_occupyPlaces) then [SC_refreshTime, fnc_occupationPlaces, [], true] call ExileServer_system_thread_addTask; }; -if(SC_occupyMilitary) then -{ - uiSleep 15; // delay the start - fnc_occupationMilitary = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMilitary.sqf"; - [SC_refreshTime, fnc_occupationMilitary, [], true] call ExileServer_system_thread_addTask; -}; - if(SC_occupyTransport) then { uiSleep 15; // delay the start