Vehicle AI & AI Behaviour tweaks

This commit is contained in:
second_coming
2016-04-08 14:48:25 +01:00
parent 4120471787
commit d3338161ce
9 changed files with 397 additions and 226 deletions

View File

@ -2,7 +2,6 @@
//
// Server Occupation script by second_coming
//
// v5 (06-04-2016)
//
// http://www.exilemod.com/profile/60-second_coming/
//
@ -14,9 +13,9 @@
// Shared Config for each occupation monitor
SC_debug = true; // set to true to turn on debug features (not for live servers)
SC_debug = false; // set to true to turn on debug features (not for live servers)
SC_extendedLogging = true; // set to true for additional logging
SC_infiSTAR_log = false; // true Use infiSTAR logging, false logs to server rpt
SC_infiSTAR_log = true; // true Use infiSTAR logging, false logs to server rpt
SC_maxAIcount = 100; // the maximum amount of AI, if the AI count is above this then additional AI won't spawn
SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false
@ -53,7 +52,7 @@ SC_occupySea = false; // true if you want to have roaming AI boats
SC_occupyLootCrates = true; // true if you want to have random loot crates with guards
SC_numberofLootCrates = 6; // if SC_occupyLootCrates = true spawn this many loot crates (overrided below for Namalsk)
SC_LootCrateGuards = 4; // number of AI to spawn at each crate
SC_LootCrateGuardsRandomize = false; // Use a random number of guards up to a maximum = SC_numberofGuards (so between 1 and SC_numberofGuards)
SC_LootCrateGuardsRandomize = true; // Use a random number of guards up to a maximum = SC_numberofGuards (so between 1 and SC_numberofGuards)
SC_occupyLootCratesMarkers = true; // true if you want to have markers on the loot crate spawns
@ -65,7 +64,7 @@ SC_statics = [ [[1178,2524,0],4,100,true] ]; //[[pos],ai c
// Settings for roaming ground vehicle AI
SC_maxNumberofVehicles = 5;
SC_maxNumberofVehicles = 3;
SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green","Exile_Car_UAZ_Open_Green","Exile_Car_Offroad_Guerilla03"];
// Settings for roaming airborne AI (non armed helis will just fly around)
@ -73,19 +72,20 @@ SC_maxNumberofHelis = 1;
SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"];
// Settings for roaming seaborne AI (non armed boats will just sail around)
SC_maxNumberofBoats = 2;
SC_maxNumberofBoats = 1;
SC_BoatClassToUse = [ "B_Boat_Armed_01_minigun_F","I_Boat_Armed_01_minigun_F","O_Boat_Transport_01_F","O_G_Boat_Transport_01_F" ];
// AI Custom Loadouts
// namalsk specific settings
// namalsk specific settings
if (worldName == 'Namalsk') then
{
SC_maxAIcount = 80;
SC_occupySky = false;
SC_maxNumberofVehicles = 3;
SC_maxNumberofVehicles = 2;
SC_numberofLootCrates = 3;
SC_numberofHeliCrashes = 2;
SC_maxNumberofBoats = 2;
SC_maxNumberofBoats = 1;
};

View File

@ -2,7 +2,7 @@
//
// Server Occupation script by second_coming
//
SC_occupationVersion = "v6 (07-04-2016)";
SC_occupationVersion = "v7 (08-04-2016)";
//
// http://www.exilemod.com/profile/60-second_coming/
//
@ -22,7 +22,7 @@ SC_occupationVersion = "v6 (07-04-2016)";
diag_log format ["[OCCUPATION MOD]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion];
diag_log format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion];
// Get the config for Occupation
call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.sqf";
@ -43,7 +43,7 @@ SC_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_ex
_logDetail = "=============================================================================================================";
[_logDetail] call SC_fnc_log;
_logDetail = format ["[OCCUPATION MOD]:: Occupation v%2 Initialised at %1",time,SC_occupationVersion];
_logDetail = format ["[OCCUPATION MOD]:: Occupation %2 Initialised at %1",time,SC_occupationVersion];
[_logDetail] call SC_fnc_log;
_logDetail = "=============================================================================================================";
[_logDetail] call SC_fnc_log;

View File

@ -15,6 +15,7 @@
private["_wp","_wp2","_wp3"];
if (!isServer) exitWith {};
_logDetail = format ["[OCCUPATION]:: Starting Occupation Monitor"];
[_logDetail] call SC_fnc_log;
@ -161,10 +162,11 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
_buildings = _pos nearObjects ["building", _groupRadius];
{
_buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
if(count _buildingPositions > 0) then
_isEnterable = [_x] call BIS_fnc_isBuildingEnterable;
if(_isEnterable) then
{
_buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
// Find Highest Point
_highest = [0,0,0];
{

View File

@ -3,6 +3,29 @@ _logDetail = format['[OCCUPATION:Sea] Started'];
if (!isServer) exitWith {};
// more than _scaleAI players on the server and the max AI count drops per additional player
_currentPlayerCount = count playableUnits;
_maxAIcount = SC_maxAIcount;
if(_currentPlayerCount > SC_scaleAI) then
{
_maxAIcount = _maxAIcount - (_currentPlayerCount - SC_scaleAI) ;
};
// Don't spawn additional AI if the server fps is below _minFPS
if(diag_fps < SC_minFPS) exitWith
{
_logDetail = format ["[OCCUPATION:Sea]:: Held off spawning more AI as the server FPS is only %1",diag_fps];
[_logDetail] call SC_fnc_log;
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
_logDetail = format ["[OCCUPATION:Sea]:: %1 active AI, so not spawning AI this time",_aiActive];
[_logDetail] call SC_fnc_log;
};
if(SC_liveBoats >= SC_maxNumberofBoats) exitWith
{
if(SC_extendedLogging) then
@ -20,49 +43,88 @@ _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];
_vehicle1 setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true];
_spawnLocation = [ 250, 0, 1, 1000, 1000, 1000, 1000, 1000, true, true ] call DMS_fnc_findSafePos;
_group = createGroup east;
_VehicleClassToUse = SC_BoatClassToUse call BIS_fnc_selectRandom;
_vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"];
_vehicle setPosASL _spawnLocation;
_vehicle setVariable["vehPos",_spawnLocation,true];
_vehicle setVariable["vehClass",_VehicleClassToUse,true];
_vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true];
// Remove the overpowered weapons from boats
_vehicle1 removeWeaponTurret ["HMG_01",[0]];
_vehicle1 removeWeaponTurret ["GMG_40mm",[0]];
_vehicle removeWeaponTurret ["HMG_01",[0]];
_vehicle removeWeaponTurret ["GMG_40mm",[0]];
SC_liveBoats = SC_liveBoats + 1;
SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle1];
SC_liveBoatsArray = SC_liveBoatsArray + [_vehicle];
_vehicle setVehiclePosition [_spawnLocation, [], 0, "NONE"];
_vehicle setVariable ["vehicleID", _spawnLocation, true];
_vehicle setFuel 1;
_vehicle setDamage 0;
_vehicle engineOn true;
_vehicle lock 0;
_vehicle setVehicleLock "UNLOCKED";
_vehicle setVariable ["ExileIsLocked", 0, true];
_vehicle action ["LightOn", _vehicle];
sleep 0.2;
_group addVehicle _vehicle;
// Calculate the crew requried
_vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles;
{
_unitPlaced = false;
_vehicleRole = _x select 0;
_vehicleSeat = _x select 1;
if(_vehicleRole == "Driver") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit assignAsDriver _vehicle;
_unit moveInDriver _vehicle;
_unit setVariable ["DMS_AssignedVeh",_vehicle];
_unitPlaced = true;
};
if(_vehicleRole == "Turret") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit moveInTurret [_vehicle, _vehicleSeat];
_unit setVariable ["DMS_AssignedVeh",_vehicle];
_unitPlaced = true;
};
if(_vehicleRole == "CARGO") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit assignAsCargo _vehicle;
_unit moveInCargo _vehicle;
_unit setVariable ["DMS_AssignedVeh",_vehicle];
_unitPlaced = true;
};
if(SC_extendedLogging && _unitPlaced) then
{
_logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle];
[_logDetail] call SC_fnc_log;
};
} forEach _vehicleRoles;
_vehicle1 setVehicleLock "UNLOCKED";
_vehicle1 setVariable ["ExileIsLocked", 0, true];
if(SC_infiSTAR_log) then
{
_logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_BoatClassToUse,_spawnLocation];
_logDetail = format['[OCCUPATION:Sea] %1 spawned @ %2',_VehicleClassToUse,_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;
clearMagazineCargoGlobal _vehicle;
clearWeaponCargoGlobal _vehicle;
clearItemCargoGlobal _vehicle;
_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)];
_vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)];
_vehicle addItemCargoGlobal ["ItemGPS", (random 1)];
_vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)];
_vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)];
_vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)];
// Add weapons with ammo to the vehicle
_possibleWeapons =
@ -96,20 +158,20 @@ for "_i" from 1 to _vehiclesToSpawn do
for "_i" from 1 to _amountOfWeapons do
{
_weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom;
_vehicle1 addWeaponCargoGlobal [_weaponToAdd,1];
_vehicle addWeaponCargoGlobal [_weaponToAdd,1];
_magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines");
_vehicle1 addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3];
_vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3];
};
[_group, _spawnLocation, 4000] call bis_fnc_taskPatrol;
_group setBehaviour "CARELESS";
_group setBehaviour "AWARE";
_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];
_vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"];
_vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"];
_vehicle addMPEventHandler ["mphit", "_this call SC_fnc_boatHit;"];
_vehicle setVariable ["SC_crewEjected", false,true];
sleep 0.2;
};

View File

@ -3,6 +3,29 @@ _logDetail = format['[OCCUPATION:Sky] Started'];
if (!isServer) exitWith {};
// more than _scaleAI players on the server and the max AI count drops per additional player
_currentPlayerCount = count playableUnits;
_maxAIcount = SC_maxAIcount;
if(_currentPlayerCount > SC_scaleAI) then
{
_maxAIcount = _maxAIcount - (_currentPlayerCount - SC_scaleAI) ;
};
// Don't spawn additional AI if the server fps is below _minFPS
if(diag_fps < SC_minFPS) exitWith
{
_logDetail = format ["[OCCUPATION:Sky]:: Held off spawning more AI as the server FPS is only %1",diag_fps];
[_logDetail] call SC_fnc_log;
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
_logDetail = format ["[OCCUPATION:Sky]:: %1 active AI, so not spawning AI this time",_aiActive];
[_logDetail] call SC_fnc_log;
};
if(SC_liveHelis >= SC_maxNumberofHelis) exitWith
{
if(SC_extendedLogging) then
@ -41,50 +64,91 @@ for "_i" from 1 to _vehiclesToSpawn do
_Location = _locations call BIS_fnc_selectRandom;
_pos = position _Location;
_position = [_pos select 0, _pos select 1, 300];
_spawnLocation = [_position,10,100,5,0,20,0] call BIS_fnc_findSafePos;
_height = 250 + (round (random 200));
_helispawnLocation = [_spawnLocation select 0, _spawnLocation select 1, _height];
_safePos = [_position,10,100,5,0,20,0] call BIS_fnc_findSafePos;
_height = 350 + (round (random 200));
_spawnLocation = [_safePos select 0, _safePos select 1, _height];
_group = createGroup east;
_HeliClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom;
_vehicle1 = [ [_helispawnLocation], _group, "assault", "difficult", "bandit", _HeliClassToUse ] call DMS_fnc_SpawnAIVehicle;
_vehicle1 setVariable["vehPos",_helispawnLocation,true];
_vehicle1 setVariable["vehClass",_HeliClassToUse,true];
_vehicle1 setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true];
{
_unit = _x;
removeBackpackGlobal _unit;
_unit addBackpackGlobal "B_Parachute";
}forEach units _group;
_group = createGroup east;
_VehicleClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom;
_vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"];
_group addVehicle _vehicle;
_vehicle setVariable["vehPos",_spawnLocation,true];
_vehicle setVariable["vehClass",_VehicleClassToUse,true];
_vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true];
SC_liveHelis = SC_liveHelis + 1;
SC_liveHelisArray = SC_liveHelisArray + [_vehicle1];
SC_liveHelisArray = SC_liveHelisArray + [_vehicle];
_vehicle setVehiclePosition [_spawnLocation, [], 0, "FLY"];
_vehicle setVariable ["vehicleID", _spawnLocation, true];
_vehicle setFuel 1;
_vehicle setDamage 0;
_vehicle engineOn true;
_vehicle flyInHeight 150;
_vehicle lock 0;
_vehicle setVehicleLock "UNLOCKED";
_vehicle setVariable ["ExileIsLocked", 0, true];
_vehicle action ["LightOn", _vehicle];
// Calculate the crew requried
_vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles;
{
_vehicleRole = _x select 0;
_vehicleSeat = _x select 1;
if(_vehicleRole == "Driver") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit assignAsDriver _vehicle;
_unit moveInDriver _vehicle;
_vehicle lockDriver true;
_unit setVariable ["DMS_AssignedVeh",_vehicle];
removeBackpackGlobal _unit;
_unit addBackpackGlobal "B_Parachute";
};
if(_vehicleRole == "Turret") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit moveInTurret [_vehicle, _vehicleSeat];
_unit setVariable ["DMS_AssignedVeh",_vehicle];
removeBackpackGlobal _unit;
_unit addBackpackGlobal "B_Parachute";
};
if(_vehicleRole == "CARGO") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit assignAsCargo _vehicle;
_unit moveInCargo _vehicle;
_unit setVariable ["DMS_AssignedVeh",_vehicle];
removeBackpackGlobal _unit;
_unit addBackpackGlobal "B_Parachute";
};
if(SC_extendedLogging) then
{
_logDetail = format['[OCCUPATION:Sky] %1 added to %2',_vehicleRole,_vehicle];
[_logDetail] call SC_fnc_log;
};
} forEach _vehicleRoles;
_vehicle1 setVehicleLock "UNLOCKED";
_vehicle1 setVariable ["ExileIsLocked", 0, true];
if(SC_infiSTAR_log) then
{
_logDetail = format['[OCCUPATION:Sky] %1 spawned @ %2',_HeliClassToUse,_spawnLocation];
_logDetail = format['[OCCUPATION:Sky] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation];
[_logDetail] call SC_fnc_log;
};
_vehicle1 setVehiclePosition [_spawnLocation, [], 0, "FLY"];
_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;
clearMagazineCargoGlobal _vehicle;
clearWeaponCargoGlobal _vehicle;
clearItemCargoGlobal _vehicle;
_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)];
_vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)];
_vehicle addItemCargoGlobal ["ItemGPS", (random 1)];
_vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)];
_vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)];
_vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)];
// Add weapons with ammo to the vehicle
_possibleWeapons =
@ -118,20 +182,20 @@ for "_i" from 1 to _vehiclesToSpawn do
for "_i" from 1 to _amountOfWeapons do
{
_weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom;
_vehicle1 addWeaponCargoGlobal [_weaponToAdd,1];
_vehicle addWeaponCargoGlobal [_weaponToAdd,1];
_magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines");
_vehicle1 addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3];
_vehicle addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3];
};
[_group, _spawnLocation, 2000] call bis_fnc_taskPatrol;
_group setBehaviour "CARELESS";
_group setBehaviour "AWARE";
_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_airHit;"];
_vehicle1 setVariable ["SC_crewEjected", false,true];
_vehicle addEventHandler ["getin", "_this call SC_fnc_claimVehicle;"];
_vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"];
_vehicle addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"];
_vehicle setVariable ["SC_crewEjected", false,true];
sleep 0.2;
};

View File

@ -3,6 +3,30 @@ if (!isServer) exitWith {};
_logDetail = format['[OCCUPATION:Vehicle] Started'];
[_logDetail] call SC_fnc_log;
// more than _scaleAI players on the server and the max AI count drops per additional player
_currentPlayerCount = count playableUnits;
_maxAIcount = SC_maxAIcount;
if(_currentPlayerCount > SC_scaleAI) then
{
_maxAIcount = _maxAIcount - (_currentPlayerCount - SC_scaleAI) ;
};
// Don't spawn additional AI if the server fps is below _minFPS
if(diag_fps < SC_minFPS) exitWith
{
_logDetail = format ["[OCCUPATION:Vehicle]:: Held off spawning more AI as the server FPS is only %1",diag_fps];
[_logDetail] call SC_fnc_log;
};
_aiActive = {alive _x && side _x == EAST} count allUnits;
if(_aiActive > _maxAIcount) exitWith
{
_logDetail = format ["[OCCUPATION:Vehicle]:: %1 active AI, so not spawning AI this time",_aiActive];
[_logDetail] call SC_fnc_log;
};
if(SC_liveVehicles >= SC_maxNumberofVehicles) exitWith
{
if(SC_extendedLogging) then
@ -71,12 +95,14 @@ if(_vehiclesToSpawn >= 1) then
_group = createGroup east;
_VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom;
_vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"];
_vehicle setVariable["vehPos",_spawnLocation,true];
_vehicle setVariable["vehClass",_VehicleClassToUse,true];
_group addVehicle _vehicle;
SC_liveVehicles = SC_liveVehicles + 1;
SC_liveVehiclesArray = SC_liveVehiclesArray + [_vehicle];
_vehicle setVariable["vehPos",_spawnLocation,true];
_vehicle setVariable["vehClass",_VehicleClassToUse,true];
_vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true];
_vehicle setFuel 1;
_vehicle engineOn true;
_vehicle lock 0;
@ -86,42 +112,62 @@ if(_vehiclesToSpawn >= 1) then
_vehicle limitSpeed 60;
_vehicle action ["LightOn", _vehicle];
_group addVehicle _vehicle;
_driver = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
sleep 0.5;
if(SC_debug) then
// Calculate the crew requried
_vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles;
{
_tag = createVehicle ["Sign_Arrow_Green_F", position _driver, [], 0, "CAN_COLLIDE"];
_tag attachTo [_driver,[0,0,0.6],"Head"];
};
sleep 0.5;
_driver setVariable ["DMS_AssignedVeh",_vehicle];
_driver setVariable ["SC_drivenVehicle", _vehicle,true];
_driver action ["movetodriver", _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 =
{
private _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit moveInTurret [_vehicle, _x];
_unit setVariable ["DMS_AssignedVeh",_vehicle];
_unit assignAsCargo _vehicle;
sleep 0.2;
_group setBehaviour "CARELESS";
_group setCombatMode "BLUE";
true
} count (allTurrets [_vehicle, true]);
_unitPlaced = false;
_vehicleRole = _x select 0;
_vehicleSeat = _x select 1;
if(_vehicleRole == "Driver") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit disableAI "TARGET";
_unit disableAI "AUTOTARGET";
_unit disableAI "AUTOCOMBAT";
_unit disableAI "COVER";
_unit disableAI "SUPPRESSION";
sleep 0.1;
if(SC_debug) then
{
_tag = createVehicle ["Sign_Arrow_Green_F", position _unit, [], 0, "CAN_COLLIDE"];
_tag attachTo [_unit,[0,0,0.6],"Head"];
};
sleep 0.1;
_unit assignAsDriver _vehicle;
_unit moveInDriver _vehicle;
_unit setVariable ["DMS_AssignedVeh",_vehicle];
_unit setVariable ["SC_drivenVehicle", _vehicle,true];
_unit addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"];
_vehicle setVariable ["SC_assignedDriver", _unit,true];
_vehicle addEventHandler ["getin", "_this call SC_fnc_getIn;"];
_vehicle addMPEventHandler ["mpkilled", "_this call SC_fnc_vehicleDestroyed;"];
_vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"];
};
if(_vehicleRole == "Turret") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit moveInTurret [_vehicle, _vehicleSeat];
_unit setVariable ["DMS_AssignedVeh",_vehicle];
_unitPlaced = true;
};
if(_vehicleRole == "CARGO") then
{
_unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier;
_unit assignAsCargo _vehicle;
_unit moveInCargo _vehicle;
_unit setVariable ["DMS_AssignedVeh",_vehicle];
_unitPlaced = true;
};
if(SC_extendedLogging && _unitPlaced) then
{
_logDetail = format['[OCCUPATION:Vehicle] %1 added to vehicle %2',_vehicleRole,_vehicle];
[_logDetail] call SC_fnc_log;
};
} forEach _vehicleRoles;
_group setBehaviour "CARELESS";
_group setCombatMode "BLUE";
// Get the AI to shut the fuck up :)
enableSentences false;

View File

@ -24,7 +24,12 @@ _damagedEssentials = 0;
{
if ((_heli getHitPointDamage _x) > 0) then
{
_damage = _heli getHitPointDamage _x;
if(_x == "HitFuel") then
{
_heli setHitPointDamage ["HitFuel", 0];
_heli setFuel 1;
};
_damage = _heli getHitPointDamage _x;
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Sky]:: Heli %1 checking part %2 (damage: %4) @ %3",_heli, _x, time,_damage];
@ -35,49 +40,43 @@ _damagedEssentials = 0;
} forEach _essentials;
if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 80) then
if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 100) then
{
[_heli ] spawn
_target = _this select 1;
[_heli, _target] spawn
{
_veh = _this select 0;
_group2 = createGroup east;
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;
};
{
_unit = _x select 0;
if (!(_unit == gunner _veh) && !(_unit == driver _veh)) then
{
_unit action ["EJECT", _veh];
};
} forEach (fullCrew _veh);
{
_unit = _x select 0;
_unit joinSilent _group2;
_unit action ["EJECT", _veh];
} forEach (assignedCargo _veh);
_target = _this select 1;
_group2 reveal [_target,1.5];
_destination = getPos _target;
_group2 allowFleeing 0;
_wp = _group2 addWaypoint [_destination, 0] ;
_wp setWaypointFormation "Column";
_wp setWaypointBehaviour "COMBAT";
_wp setWaypointCombatMode "RED";
_wp setWaypointCompletionRadius 1;
_wp setWaypointType "SAD";
[_group2, _destination, 500] call bis_fnc_taskPatrol;
_group2 allowFleeing 0;
_group2 setBehaviour "AWARE";
_group2 setCombatMode "RED";
};
_heli setVariable ["SC_crewEjected", true,true];
_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";
_wp setWaypointBehaviour "COMBAT";
_wp setWaypointCombatMode "RED";
_wp setWaypointCompletionRadius 1;
_wp setWaypointType "SAD";
[_group, _destination, 250] call bis_fnc_taskPatrol;
_group allowFleeing 0;
_group setBehaviour "AWARE";
_group setCombatMode "RED";
_heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"];
};

View File

@ -9,7 +9,7 @@ if(SC_extendedLogging) then
_deadDriver = _this select 0;
_deadDriver removeAllMPEventHandlers "mpkilled";
_vehicleDriven = _deadDriver getVariable "SC_drivenVehicle";
_vehicle = _deadDriver getVariable "SC_drivenVehicle";
if(SC_debug) then
@ -18,62 +18,62 @@ if(SC_debug) then
};
// Select a replacement driver
_vehicleDriven removeAllMPEventHandlers "mphit";
_vehGroup = group _vehicleDriven;
_vehicle removeAllMPEventHandlers "mphit";
_group = group _vehicle;
[_deadDriver] join grpNull;
if(count units _vehGroup > 0) then
{
_logDetail = format ["[OCCUPATION:Vehicle]:: vehicle: %1 group: %2 units left:%3",_vehicleDriven,_vehGroup,count units _vehGroup];
[_logDetail] call SC_fnc_log;
_groupMembers = units _vehGroup;
_replacementDriver = _groupMembers call BIS_fnc_selectRandom;
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
{
_logDetail = format ["[OCCUPATION:Vehicle]:: No replacement Driver found for vehicle %1",_vehicleDriven];
[_logDetail] call SC_fnc_log;
};
_replacementDriver disableAI "TARGET";
_replacementDriver disableAI "AUTOTARGET";
_replacementDriver disableAI "AUTOCOMBAT";
_replacementDriver disableAI "COVER";
{
if(!alive _x) then { [_x] join grpNull; };
}forEach units _group;
if(count units _group > 0) then
{
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Vehicle]:: vehicle: %1 group: %2 units left:%3",_vehicle,_group,count units _group];
[_logDetail] call SC_fnc_log;
};
_replacementDriver assignAsDriver _vehicleDriven;
_replacementDriver setVariable ["DMS_AssignedVeh",_vehicleDriven];
_replacementDriver setVariable ["SC_drivenVehicle", _vehicleDriven,true];
_vehicleDriven setVariable ["SC_assignedDriver", _replacementDriver,true];
_vehicleDriven addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"];
_replacementDriver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"];
_groupMembers = units _group;
_driver = _groupMembers call BIS_fnc_selectRandom;
_driver disableAI "TARGET";
_driver disableAI "AUTOTARGET";
_driver disableAI "AUTOCOMBAT";
_driver disableAI "COVER";
_driver assignAsDriver _vehicle;
_driver setVariable ["DMS_AssignedVeh",_vehicle];
_driver setVariable ["SC_drivenVehicle", _vehicle,true];
_vehicle setVariable ["SC_assignedDriver", _driver,true];
_vehicle addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"];
_driver 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"];
_tag = createVehicle ["Sign_Arrow_Green_F", position _driver, [], 0, "CAN_COLLIDE"];
_tag attachTo [_driver,[0,0,0.6],"Head"];
};
_replacementDriver doMove (position _vehicleDriven);
_replacementDriver action ["movetodriver", _vehicleDriven];
_driver doMove (position _vehicle);
_driver action ["movetodriver", _vehicle];
if(SC_extendedLogging) then
{
_logDetail = format ["[OCCUPATION:Vehicle]:: Replacement Driver found (%1) for vehicle %2",_replacementDriver,_vehicleDriven];
_logDetail = format ["[OCCUPATION:Vehicle]:: Replacement Driver found (%1) for vehicle %2",_driver,_vehicle];
[_logDetail] call SC_fnc_log;
};
if(damage _vehicleDriven > 0) then
if(damage _vehicle > 0) then
{
[_replacementDriver] call SC_fnc_repairVehicle;
[_driver] call SC_fnc_repairVehicle;
};
}
else
{
_logDetail = format ["[OCCUPATION:Vehicle]:: No replacement Driver found for vehicle %1",_vehicle];
[_logDetail] call SC_fnc_log;
};

View File

@ -47,10 +47,15 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then
[_vehicle,_assignedDriver ] spawn
{
_vehicle = _this select 0;
_vehicle forceSpeed 0;
sleep 1;
_vehGroup = group _vehicle;
_vehicle forceSpeed 0;
_group = group _vehicle;
_driver = _this select 1;
_driver disableAI "TARGET";
_driver disableAI "AUTOTARGET";
_driver disableAI "AUTOCOMBAT";
_driver disableAI "COVER";
_driver disableAI "SUPPRESSION";
sleep 1;
_driver action ["getOut", _vehicle];
if(SC_debug) then
@ -59,41 +64,34 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then
_tag attachTo [_driver,[0,0,0.6],"Head"];
};
sleep 0.2;
_driver doMove (position _vehicle);
_driver disableAI "TARGET";
_driver disableAI "AUTOTARGET";
_driver disableAI "AUTOCOMBAT";
_driver disableAI "COVER";
_driver doMove (position _vehicle);
_driverDir = _driver getDir _vehicle;
//_driver setDir _driverDir + 180;
_driver setUnitPos "MIDDLE";
sleep 0.5;
_driver playMoveNow "Acts_carFixingWheel";
sleep 2;
_driver playMoveNow "Acts_carFixingWheel";
sleep 2;
_driver playMoveNow "Acts_carFixingWheel";
sleep 2;
sleep 8;
_driver switchMove "";
if(alive _driver) then
{
_vehicle setDamage 0;
_driver playMoveNow "Acts_carFixingWheel";
sleep 2;
_driver switchMove "";
_driver assignAsDriver _vehicle;
_driver moveInDriver _vehicle;
_driver action ["movetodriver", _vehicle];
};
_wp = _vehGroup addWaypoint [position _vehicle, 0] ;
_wp = _group addWaypoint [position _vehicle, 0] ;
_wp setWaypointFormation "Column";
_wp setWaypointCompletionRadius 1;
_wp setWaypointType "GETIN";
sleep 10;
sleep 5;
_spawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation";
_driver action ["movetodriver", _vehicle];
_vehicle forceSpeed -1;
[_vehGroup, _spawnLocation, 2000] call bis_fnc_taskPatrol;
_vehGroup setBehaviour "AWARE";
_vehGroup setCombatMode "RED";
[_group, _spawnLocation, 2000] call bis_fnc_taskPatrol;
_group setBehaviour "AWARE";
_group setCombatMode "RED";
};
}