all the updates!

update, adding eventhandlers to vehicle AI and an additional loot crate
option
This commit is contained in:
second_coming 2016-03-26 15:41:31 +00:00
parent 6a9b5d1206
commit 766ae4042b
10 changed files with 446 additions and 37 deletions

View File

@ -1,6 +1,7 @@
// Shared Config for each occupation monitor
SC_debug = false; // set to true for additional logging
SC_debug = false; // set to true for additional logging and to speed up the spawn rate for testing
SC_infiSTAR_log = true; // Use infiSTAR logging
SC_maxAIcount = 100; // the maximum amount of AI, if the AI count is above this then additional AI won't spawn
// As Namalsk is a smaller map, lower the maximum AI count
@ -20,6 +21,8 @@ SC_occupyMilitary = false; // true if you want military buildings patrolle
SC_occupyStatic = false; // true if you want to garrison AI in specific locations (not working yet)
SC_occupyVehicle = true; // true if you want to have roaming AI vehicles
SC_occupySky = true; // true if you want to have roaming AI helis
SC_occupyLootCrates = true; // true if you want to have random loot crates with guards
SC_occupyLootCratesMarkers = true; // true if you want to have markers on the loot crate spawns
SC_statics = [
[[4151,6697,0],4,100,true],
@ -27,32 +30,36 @@ SC_statics = [
]; //[[pos],ai count,radius,search buildings]
// Which buildings to patrol with the occupyMilitary option (adding more classnames could affect server performance when the spawning occurs)
SC_buildings = ["Land_Cargo_Patrol_V1_F",
"Land_i_Barracks_V1_F",
"Land_i_Barracks_V1_dam_F",
"Land_i_Barracks_V2_F",
"Land_u_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",
"Land_Cargo_Patrol_V3_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_Radar_Small_F",
"Land_Dome_Big_F",
"Land_Dome_Small_F"];
SC_buildings = [ "Land_Cargo_Patrol_V1_F",
"Land_i_Barracks_V1_F",
"Land_i_Barracks_V1_dam_F",
"Land_i_Barracks_V2_F",
"Land_u_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",
"Land_Cargo_Patrol_V3_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_Radar_Small_F",
"Land_Dome_Big_F",
"Land_Dome_Small_F",
"Land_Army_hut3_long_int",
"Land_Army_hut_int",
"Land_Army_hut2_int"
];
// Settings for roaming ground vehicle AI
SC_maxNumberofVehicles = 3; // Number of roaming vehicles required, randomly selected from VehicleClassToUse
@ -64,7 +71,7 @@ SC_VehicleClassToUse = [ "Exile_Car_LandRover_Green",
// Settings for roaming airborne AI
SC_maxNumberofHelis = 1; // Number of roaming vehicles required, randomly selected from HeliClassToUse (only use armed helis for now)
SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green" ];
SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green"];

View File

@ -1,3 +1,15 @@
diag_log format ["[OCCUPATION MOD]:: Initialised at %1",time];
[] execVM "\x\addons\a3_exile_occupation\config.sqf";
[] execVM "\x\addons\a3_exile_occupation\startOccupation.sqf";
SC_fnc_repairVehicle = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\reactions\repairVehicle.sqf";
SC_fnc_reactUnit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\reactions\reactUnit.sqf";
SC_fnc_driverKilled = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\reactions\driverKilled.sqf";
SC_fnc_airHit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\reactions\airHit.sqf";
call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\config.sqf";
[] execVM "\x\addons\a3_exile_occupation\startOccupation.sqf";
if(SC_occupyLootCrates) then
{
call compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\occupationLootCrates.sqf";
};

View File

@ -176,4 +176,5 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
};
};
sleep 0.2;
} forEach _locations;

126
occupationLootCrates.sqf Normal file
View File

@ -0,0 +1,126 @@
////////////////////////////////////////////////////////////////////////
//
// Server Occupation script by second_coming
//
// Version 2.0
//
// http://www.exilemod.com/profile/60-second_coming/
//
// This script uses the fantastic DMS by Defent and eraser1
//
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
if (!isServer) exitWith {};
diag_log format ["[OCCUPATION:LootCrates]:: Starting Occupation Loot Crates"];
_middle = worldSize/2;
_spawnCenter = [_middle,_middle,0];
_max = _middle;
_numberofcrates = 3; // this is the number of crates that you want to spawn
if (worldName == 'Altis') then
{
_spawnCenter = [15834.2,15787.8,0];
_max = 16000;
_numberofcrates = 6; // this is the number of crates that you want to spawn
};
if (worldName == 'Chernarus') then
{
_spawnCenter = [7652.9634, 7870.8076,0];
_max = 7500;
_numberofcrates = 6; // this is the number of crates that you want to spawn
};
if (worldName == 'Taviana') then
{
_spawnCenter = [12800, 12800,0];
_max = 12800;
_numberofcrates = 6; // this is the number of crates that you want to spawn
};
diag_log format['[OCCUPATION:LootCrates]:: worldname: %1 Centre: %2 radius: %3',worldName,_spawnCenter,_max];
_min = 0; // minimum distance from the center position (Number) in meters
_mindist = 15; // minimum distance from the nearest object (Number) in meters, ie. spawn at least this distance away from anything within x meters..
_water = 0; // water mode (Number) 0: cannot be in water , 1: can either be in water or not , 2: must be in water
_shoremode = 0; // 0: does not have to be at a shore , 1: must be at a shore
_marker = SC_occupyLootCratesMarkers; // Draw a green circle in which the crate will be spawned randomly
private['_position'];
for "_i" from 1 to _numberofcrates do
{
_validspot = false;
while{!_validspot} do
{
sleep 0.2;
_position = [_spawnCenter,_min,_max,_mindist,_water,20,_shoremode] call BIS_fnc_findSafePos;
_validspot = true;
// Check for nearby spawn points and traders
_nearestMarker = [allMapMarkers, _position] call BIS_fnc_nearestPosition;
_posNearestMarker = getMarkerPos _nearestMarker;
if(_position distance _posNearestMarker < 500) then { _validspot = false; };
//Check if near another crate site
_nearOtherCrate = (nearestObjects [_position,["CargoNet_01_box_F"],500]) select 0;
if (!isNil "_nearOtherCrate") then { _validspot = false; };
//Check if near player base
_nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],350]) select 0;
if (!isNil "_nearBase") then { _validspot = false; };
};
if (_marker) then
{
_mapMarkerName = format ["loot_marker_%1", _i];
_event_marker = createMarker [ format ["loot_marker_%1", _i], _position];
_event_marker setMarkerColor "ColorGreen";
_event_marker setMarkerAlpha 1;
_event_marker setMarkerText "Gear Crate";
_event_marker setMarkerType "loc_Tree";
_event_marker setMarkerBrush "Vertical";
_event_marker setMarkerSize [(3), (3)];
};
//Infantry spawn using DMS
_AICount = 1 + (round (random 2));
_ai_posx = _position select 0;
_ai_posy = _position select 1;
_ai_posz = 0;
[[_ai_posx, _ai_posy, _ai_posz], _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup;
diag_log text format ["[OCCUPATION:LootCrates]:: Creating crate %3 @ drop zone %1 with %2 guards",_position,_AICount,_i];
_box = "CargoNet_01_box_F" createvehicle _position;
clearMagazineCargoGlobal _box;
clearWeaponCargoGlobal _box;
clearItemCargoGlobal _box;
_box enableRopeAttach false; // Stop people airlifting the crate
_box setVariable ["permaLoot",true]; // stay until reset
_box allowDamage false; // Prevent boxes to explode when spawning
_box addItemCargoGlobal ["Exile_Melee_Axe", 1];
_box addItemCargoGlobal ["Exile_Item_GloriousKnakworst", 1 + (random 2)];
_box addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 1 + (random 2)];
_box addItemCargoGlobal ["Exile_Item_Beer", 5 + (random 1)];
_box addItemCargoGlobal ["Exile_Item_Laptop", (random 1)];
_box addItemCargoGlobal ["Exile_Item_BaseCameraKit", (random 2)];
_box addItemCargoGlobal ["Exile_Item_InstaDoc", 1 + (random 1)];
_box addItemCargoGlobal ["Exile_Item_Matches", 1];
_box addItemCargoGlobal ["Exile_Item_CookingPot", 1];
_box addItemCargoGlobal ["Exile_Item_CodeLock", (random 1)];
_box addItemCargoGlobal ["Exile_Item_MetalPole", 1];
_box addItemCargoGlobal ["Exile_Item_LightBulb", 1];
_box addItemCargoGlobal ["Exile_Item_FuelCanisterEmpty", 1];
_box addItemCargoGlobal ["Exile_Item_WoodPlank", 1 + (random 8)];
_box addItemCargoGlobal ["Exile_Item_woodFloorKit", 1 + (random 2)];
_box addItemCargoGlobal ["Exile_Item_WoodWindowKit", 1 + (random 1)];
_box addItemCargoGlobal ["Exile_Item_WoodDoorwayKit", 1 + (random 1)];
_box addItemCargoGlobal ["Exile_Item_WoodFloorPortKit", 1 + (random 2)];
};

View File

@ -47,24 +47,33 @@ for "_i" from 1 to _vehiclesToSpawn do
_Location = _locations call BIS_fnc_selectRandom;
_position = position _Location;
_spawnLocation = [_position select 0, _position select 1, 500];
_spawnLocation = [_position select 0, _position select 1, 300];
_group = createGroup east;
_HeliClassToUse = SC_HeliClassToUse call BIS_fnc_selectRandom;
_vehicle1 = [ [_spawnLocation], _group, "assault", "difficult", "bandit", _HeliClassToUse ] call DMS_fnc_SpawnAIVehicle;
diag_log format['[OCCUPATION:Sky] %1 spawned @ %2',_HeliClassToUse,_spawnLocation];
if(SC_infiSTAR_log) then
{
_logDetail = format['[OCCUPATION:Sky] %1 spawned @ %2',_HeliClassToUse,_spawnLocation];
['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG;
};
_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;
[_group, _spawnLocation, 2000] call bis_fnc_taskPatrol;
_group setBehaviour "AWARE";
_group setCombatMode "RED";
SC_liveHelis = SC_liveHelis + 1;
_vehicle1 addEventHandler ["killed", "SC_liveHelis = SC_liveHelis - 1;"];
sleep 5;
_vehicle1 addMPEventHandler ["mpkilled", "SC_liveHelis = SC_liveHelis - 1;"];
_vehicle1 addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"];
_vehicle1 setVariable ["SC_crewEjected", false,true];
sleep 0.2;
};

View File

@ -57,9 +57,21 @@ for "_j" from 1 to _vehiclesToSpawn do
_group = createGroup east;
_VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom;
_vehicleObject = [ [_nearestRoad], _group, "assault", "difficult", "bandit",_VehicleClassToUse ] call DMS_fnc_SpawnAIVehicle;
// Get the AI to shut the fuck up :)
enableSentences false;
enableRadio false;
diag_log format['[OCCUPATION:Vehicle] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation];
_vehicleObject addEventHandler ["killed", "SC_liveVehicles = SC_liveVehicles - 1;"];
_vehicleObject setSpeedMode "Normal";
_vehicleObject addMPEventHandler ["mpkilled", "SC_liveVehicles = SC_liveVehicles - 1;"];
_vehicleObject addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"];
_driverVeh = driver _vehicleObject;
_driverVeh addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"];
_driverVeh setVariable ["SC_drivenVehicle", _vehicleObject,true];
_vehicleObject setSpeedMode "LIMITED";
_vehicleObject limitSpeed 60;
_vehicleObject action ["LightOn", _vehicleObject];
[_group, _spawnLocation, 2000] call bis_fnc_taskPatrol;
@ -67,7 +79,7 @@ for "_j" from 1 to _vehiclesToSpawn do
_group setCombatMode "RED";
SC_liveVehicles = SC_liveVehicles + 1;
sleep 5;
sleep 0.2;
};

108
reactions/airHit.sqf Normal file
View File

@ -0,0 +1,108 @@
////////////////////////////////////////////////////////////////////////
//
// Server Occupation script by second_coming
//
// Version 2.0
//
// http://www.exilemod.com/profile/60-second_coming/
//
// This script uses the fantastic DMS by Defent and eraser1
//
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
_heli = _this select 0;
_heliDamage = getDammage _heli;
_heliPosition = getPosATL _heli;
_heliHeight = getPosATL _heli select 2;
_crewEjected = _heli getVariable "SC_crewEjected";
if(SC_infiSTAR_log) then
{
_logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 hit by %3 at %1 (damage: %4)",time,_this select 0,_this select 1,_heliDamage];
['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG;
};
_ejectChance = round (random 100) + (_heliDamage * 100);
if(_heliDamage > 0 && _ejectChance > 70 && !_crewEjected) then
{
_heli removeAllMPEventHandlers "mphit";
[_heli ] spawn
{
_veh = _this select 0;
{
if(SC_infiSTAR_log) 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];
['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG;
};
_unit = _x select 0;
if (isNull driver _veh) then
{
moveOut _unit;
_parachute = "Steerable_Parachute_F" createVehicle getPos _unit;
_parachute setDir (getDir _unit);
_unit moveInDriver _parachute;
_heliPosition = getPosATL _heli;
_parachutePosition = [_heliPosition select 0, _heliPosition select 1, (_heliPosition select 2)-5];
_parachute setPos _parachutePosition;
sleep 0.1;
_parachute enableSimulationGlobal true;
};
} forEach (fullCrew _veh);
};
_heli setVariable ["SC_crewEjected", true,true];
_target = _this select 1;
_pilot = driver _heli;
_group = group _pilot;
_group reveal [_target,1.5];
_destination = getPos _target;
[_group, _destination, 250] call bis_fnc_taskPatrol;
_group setBehaviour "COMBAT";
_group setCombatMode "RED";
_group allowFleeing 0;
_group setBehaviour "AWARE";
_group setSpeedMode "FULL";
_group setCombatMode "RED";
_heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"];
};
if(_heliDamage >= 0.5) then
{
if(SC_infiSTAR_log) then
{
_logDetail = format ["[OCCUPATION:Sky]:: Air unit %2 damaged and force landing at %3 (time: %1)",time,_this select 0,_this select 1,_heliPosition];
['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG;
};
_heli removeAllMPEventHandlers "mphit";
_heli removeAllMPEventHandlers "mpkilled";
SC_liveHelis = SC_liveHelis - 1;
_heli land "LAND";
_heli setVehicleLock "UNLOCKED";
_target = _this select 1;
_pilot = driver _heli;
_group = group _pilot;
_group reveal [_target,1.5];
_destination = getPos _target;
[_group, _destination, 250] call bis_fnc_taskPatrol;
_group setBehaviour "COMBAT";
_group setCombatMode "RED";
_group allowFleeing 0;
_group setBehaviour "AWARE";
_group setSpeedMode "FULL";
_group setCombatMode "RED";
};

View File

@ -0,0 +1,60 @@
////////////////////////////////////////////////////////////////////////
//
// Server Occupation script by second_coming
//
// Version 2.0
//
// http://www.exilemod.com/profile/60-second_coming/
//
// This script uses the fantastic DMS by Defent and eraser1
//
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
if(SC_infiSTAR_log) then
{
_logDetail = format ["[OCCUPATION:Vehicle]:: Unit %2 (driver) killed at %1",time,_this select 0];
['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG;
};
_deadDriver = _this select 0;
_deadDriver removeAllMPEventHandlers "mpkilled";
_deadDriver removeAllMPEventHandlers "mphit";
// Select a replacement driver
_vehicleDriven = _deadDriver getVariable "SC_drivenVehicle";
_vehGroup = group _deadDriver;
[_deadDriver] join grpNull;
_nearAI = (position _vehicleDriven) nearEntities [["O_recon_F"], 100];
_replacementDriver = _nearAI call BIS_fnc_selectRandom;
if(SC_infiSTAR_log) then
{
_logDetail = format ["[OCCUPATION:Vehicle]:: Replacement Driver found (%1) for vehicle %2",_replacementDriver,_vehicleDriven];
['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG;
};
// add event handlers for the new driver
_replacementDriver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"];
_replacementDriver setVariable ["SC_drivenVehicle", _vehicleDriven,true];
_vehicle removeAllMPEventHandlers "mphit";
_vehicleDriven addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"];
_replacementDriver assignAsDriver _vehicleDriven;
_vehicleDamage = getDammage _vehicleDriven;
// If the vehicle is already damaged then fix it, otherwise get in as the driver
if(_vehicleDamage > 0) then
{
[_vehicleDriven] call SC_fnc_repairVehicle;
}
else
{
[_replacementDriver] orderGetIn true;
//_replacementDriver moveInDriver _vehicleDriven;
};

15
reactions/reactUnit.sqf Normal file
View File

@ -0,0 +1,15 @@
////////////////////////////////////////////////////////////////////////
//
// Server Occupation script by second_coming
//
// Version 2.0
//
// http://www.exilemod.com/profile/60-second_coming/
//
// This script uses the fantastic DMS by Defent and eraser1
//
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
//
////////////////////////////////////////////////////////////////////////
diag_log format ["[OCCUPATION]:: Unit %2 killed at %1",time,_this];

View File

@ -0,0 +1,59 @@
////////////////////////////////////////////////////////////////////////
//
// Server Occupation script by second_coming
//
// Version 2.0
//
// http://www.exilemod.com/profile/60-second_coming/
//
// This script uses the fantastic DMS by Defent and eraser1
//
// http://www.exilemod.com/topic/61-dms-defents-mission-system/
// special thanks to eichi for pointers on this script :)
////////////////////////////////////////////////////////////////////////
_vehicle = _this select 0;
_vehicleDamage = getDammage _vehicle;
_wheels = ["HitLF2Wheel","HitLFWheel","HitRFWheel","HitRF2Wheel"];
_damagedWheels = 0;
{
if ((_vehicle getHitPointDamage _x) >= 0.5) then
{
_damagedWheels = _damagedWheels + 1;
};
} forEach _wheels;
if(_damagedWheels >= 1 && alive (driver _vehicle)) then
{
if(SC_infiSTAR_log) then
{
_logDetail = format ["[OCCUPATION:repairVehicle]:: Unit %2 reaction to event at %1",time,_this select 0];
['A3_EXILE_OCCUPATION',_logDetail] call FNC_A3_CUSTOMLOG;
};
_vehicle removeAllMPEventHandlers "mphit";
[_vehicle ] spawn
{
_vehicleToFix = _this select 0;
_driverVeh = driver _vehicleToFix;
_vehicleToFix forceSpeed 0;
sleep 2;
_driverVeh action ["Eject", _vehicleToFix];
_driverVeh doWatch (position _vehicleToFix);
_driverVeh playActionNow "medicStart";
sleep 10;
_driverVeh switchMove "";
_driverVeh playActionNow "medicStart";
sleep 4;
_vehicleToFix setDamage 0;
_driverVeh switchMove "";
_driverVeh playActionNow "medicStop";
sleep 2;
_driverVeh assignAsDriver _vehicleToFix;
_driverVeh moveInDriver _vehicleToFix;
_vehicleToFix forceSpeed -1;
_vehicleToFix addMPEventHandler ["mphit", "_this call SC_fnc_repairVehicle;"];
};
};