diff --git a/config.sqf b/config.sqf index 97ad377..6942cbc 100644 --- a/config.sqf +++ b/config.sqf @@ -37,7 +37,7 @@ SC_SurvivorsChance = 33; // chance in % to spawn surv // Occupation Military (roaming AI near military buildings) -SC_occupyMilitary = false; // true if you want military buildings patrolled (specify which types of building below) +SC_occupyMilitary = true; // true if you want military buildings patrolled (specify which types of building below) SC_buildings = [ "Land_Cargo_Patrol_V1_F","Land_i_Barracks_V1_F","Land_i_Barracks_V1_dam_F", "Land_i_Barracks_V2_F", "Land_Cargo_House_V1_F","Land_Cargo_HQ_V1_F","Land_Cargo_HQ_V2_F","Land_Cargo_HQ_V3_F","Land_Cargo_Patrol_V2_F", diff --git a/initServer.sqf b/initServer.sqf index 9088098..11714f4 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v12 (13-04-2016)"; +SC_occupationVersion = "v13 (13-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -43,6 +43,7 @@ SC_occupationVersion = "v12 (13-04-2016)"; SC_fnc_getIn = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\getIn.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"; _logDetail = "============================================================================================================="; [_logDetail] call SC_fnc_log; diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index c831f45..3d0527c 100644 --- a/scripts/occupationMilitary.sqf +++ b/scripts/occupationMilitary.sqf @@ -30,29 +30,28 @@ if(diag_fps < _minFPS) exitWith _aiActive = {alive _x && (side _x == EAST OR side _x == WEST)} count allUnits; -//_aiActive = count(_spawnCenter nearEntities ["O_recon_F", _maxDistance+1000]); if(_aiActive > _maxAIcount) exitWith { _logDetail = format ["[OCCUPATION Military]:: %1 active AI, so not spawning AI this time",_aiActive]; [_logDetail] call SC_fnc_log; }; -for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do + { _logDetail = format ["[OCCUPATION Military]:: scanning buildings around %2 started at %1",time,_areaToScan]; [_logDetail] call SC_fnc_log; - _currentBuilding = _buildings select _i; + _currentBuilding = _x; _building = _areaToScan nearObjects [_currentBuilding, 750]; _logDetail = format ["[OCCUPATION Military]:: scan for %2 building finished at %1",time,_currentBuilding]; [_logDetail] call SC_fnc_log; - for [{_n = 0},{_n < (count _building)-1},{_n =_n + 1}] do + { _okToSpawn = true; Sleep 0.1; - _foundBuilding = (_building select _n); + _foundBuilding = _x; _location = getPos _foundBuilding; _pos = [_location select 0, _location select 1, 0]; @@ -114,7 +113,7 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do }; // Don't spawn additional AI if there are players in range - if([_pos, 200] call ExileClient_util_world_isAlivePlayerInRange) exitwith + if([_pos, 250] call ExileClient_util_world_isAlivePlayerInRange) exitwith { _okToSpawn = false; if(SC_extendedLogging) then @@ -218,7 +217,7 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do _okToSpawn = false; }; }; - }; -}; + }foreach _building; +}foreach _buildings; _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 399a546..5783fdc 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -185,7 +185,7 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi if(_side == "survivor") then { deleteGroup _group; - _group = createGroup WEST; + _group = createGroup WEST; }; _group setVariable ["DMS_LockLocality",nil]; @@ -193,11 +193,12 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _group setVariable ["DMS_Group_Side", _side]; { - _unit = _x; + _unit = _x; [_unit] joinSilent grpNull; [_unit] joinSilent _group; if(_side == "survivor") then { + _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; removeUniform _unit; _unit forceAddUniform "Exile_Uniform_BambiOverall"; if(SC_debug) then @@ -275,9 +276,9 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi _group2 = createGroup EAST; if(_side == "survivor") then - { + { deleteGroup _group2; - _group2 = createGroup WEST; + _group2 = createGroup WEST; }; _group2 setVariable ["DMS_LockLocality",nil]; @@ -294,21 +295,22 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi [_unit] joinSilent _group2; if(_side == "survivor") then { + _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; removeUniform _unit; _unit forceAddUniform "Exile_Uniform_BambiOverall"; if(SC_debug) then { _tag = createVehicle ["Sign_Arrow_Green_F", position _unit, [], 0, "CAN_COLLIDE"]; _tag attachTo [_unit,[0,0,0.6],"Head"]; - } - else + }; + } + else + { + if(SC_debug) then { - if(SC_debug) then - { - _tag = createVehicle ["Sign_Arrow_F", position _unit, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_unit,[0,0,0.6],"Head"]; - }; - }; + _tag = createVehicle ["Sign_Arrow_F", position _unit, [], 0, "CAN_COLLIDE"]; + _tag attachTo [_unit,[0,0,0.6],"Head"]; + }; }; }foreach units _initialGroup2; diff --git a/scripts/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index 3272d03..f82e3cb 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -197,6 +197,7 @@ if(_vehiclesToSpawn >= 1) then _unit = [_group,_spawnLocation,"assault","random",_side,"Vehicle"] call DMS_fnc_SpawnAISoldier; if(_side == "survivor") then { + _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; removeUniform _unit; _unit forceAddUniform "Exile_Uniform_BambiOverall"; }; @@ -209,6 +210,7 @@ if(_vehiclesToSpawn >= 1) then _unit = [_group,_spawnLocation,"assault","random",_side,"Vehicle"] call DMS_fnc_SpawnAISoldier; if(_side == "survivor") then { + _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; removeUniform _unit; _unit forceAddUniform "Exile_Uniform_BambiOverall"; }; diff --git a/scripts/reactions/unitMPHit.sqf b/scripts/reactions/unitMPHit.sqf new file mode 100644 index 0000000..a1fc67b --- /dev/null +++ b/scripts/reactions/unitMPHit.sqf @@ -0,0 +1,21 @@ +// Get the variables from the event handler +_unit = _this select 0; +_aggressor = _this select 1; +_damage = _this select 2; + +// remove the eventhandler to stop it triggering multiple times simultaneously +_unit removeAllMPEventHandlers "mphit"; + +if (side _aggressor == RESISTANCE) then +{ + // Make victim and his group aggressive to players + _group = group _unit; + _group reveal [_aggressor, 2.5]; + _group moveTo (position _aggressor); +}; + +if(alive _unit) then +{ + // reapply the eventhandler + _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; +};