v5 06/04/2016

various fixes and changes to AI reactions
This commit is contained in:
second_coming 2016-04-06 11:29:59 +01:00
parent 887f26612b
commit ef72464dbc
21 changed files with 431 additions and 112 deletions

View File

@ -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 {
};
};
};

View File

@ -98,4 +98,4 @@ publicVariable "SC_liveHelis";
publicVariable "SC_liveHelisArray";
publicVariable "SC_liveBoats";
publicVariable "SC_liveBoatsArray";
publicVariable "SC_numberofLootCrates";
publicVariable "SC_numberofLootCrates";

View File

@ -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";

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;
};

118
scripts/occupationSea.sqf Normal file
View File

@ -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;

View File

@ -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;

View File

@ -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";

View File

@ -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;

View File

@ -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";
};

View File

View File

@ -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];
};

View File

@ -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];

View File

@ -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
{

View File

@ -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;
};
};
*/

View File

@ -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];

View File

@ -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];
};

View File

@ -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;