From 55c782e31baec32ec5878ede1704676f2e28088a Mon Sep 17 00:00:00 2001 From: 3Mydlo3 Date: Thu, 7 Mar 2024 00:04:38 +0100 Subject: [PATCH] Add config for civilian >> UnitTypes[] and CarTypes[] --- addons/civilian/XEH_PREP.hpp | 2 +- addons/civilian/XEH_preInit.sqf | 2 +- ...CiviliansConfig.sqf => fnc_initConfig.sqf} | 12 +++++++++- .../vehicles/functions/fnc_initVehicles.sqf | 24 ++++++++++++++----- 4 files changed, 31 insertions(+), 9 deletions(-) rename addons/civilian/functions/{fnc_initCiviliansConfig.sqf => fnc_initConfig.sqf} (69%) diff --git a/addons/civilian/XEH_PREP.hpp b/addons/civilian/XEH_PREP.hpp index 6e591bb9..279b6c5a 100644 --- a/addons/civilian/XEH_PREP.hpp +++ b/addons/civilian/XEH_PREP.hpp @@ -10,6 +10,6 @@ PREP(getNearestCity); PREP(getNearestVehicle); PREP(initCity); PREP(initCivilians); -PREP(initCiviliansConfig); +PREP(initConfig); PREP(initCivilian); PREP(unassignCivilianFromCity); diff --git a/addons/civilian/XEH_preInit.sqf b/addons/civilian/XEH_preInit.sqf index c4cda66c..a83dc469 100644 --- a/addons/civilian/XEH_preInit.sqf +++ b/addons/civilian/XEH_preInit.sqf @@ -42,7 +42,7 @@ if (isServer) then { GVAR(uniforms) = []; GVAR(vests) = []; GVAR(headgear) = []; - call FUNC(initCiviliansConfig); + call FUNC(initConfig); publicVariable QGVAR(backpacks); publicVariable QGVAR(uniforms); publicVariable QGVAR(vests); diff --git a/addons/civilian/functions/fnc_initCiviliansConfig.sqf b/addons/civilian/functions/fnc_initConfig.sqf similarity index 69% rename from addons/civilian/functions/fnc_initCiviliansConfig.sqf rename to addons/civilian/functions/fnc_initConfig.sqf index 959b9384..bb5cf740 100644 --- a/addons/civilian/functions/fnc_initCiviliansConfig.sqf +++ b/addons/civilian/functions/fnc_initConfig.sqf @@ -16,7 +16,17 @@ */ // Get all civilian units config -private _civilianUnitsConfigs = QUOTE((configFile >> 'CfgVehicles' >> 'C_man_1') in ([_x] call EFUNC(common,configGetAllParents))) configClasses (configFile >> "CfgVehicles"); + +private _customCivilianUnits = getArray (missionConfigFile >> "CfgSerialKillers" >> "Civilian" >> "UnitTypes"); + +private _civilianUnitsConfigs = if (_customCivilianUnits isNotEqualTo []) then { + _customCivilianUnits apply {configFile >> "CfgVehicles" >> _x}; +} else { + // By default load all civilian units + QUOTE((configFile >> 'CfgVehicles' >> 'C_man_1') in ([_x] call EFUNC(common,configGetAllParents))) configClasses (configFile >> "CfgVehicles"); +}; + +// TODO: Add blacklisted units config to exclude VR guys { // Add to units list diff --git a/addons/vehicles/functions/fnc_initVehicles.sqf b/addons/vehicles/functions/fnc_initVehicles.sqf index 3a69fd55..3ae3a33a 100644 --- a/addons/vehicles/functions/fnc_initVehicles.sqf +++ b/addons/vehicles/functions/fnc_initVehicles.sqf @@ -17,12 +17,24 @@ private _i = GVAR(emptyVehiclesLimit); -// Retrieve all civilian car types from config -private _civilianCarTypes = "( (getNumber (_x >> 'scope') >= 2) - && { - getText (_x >> 'vehicleClass') in ['Car'] - && {getNumber (_x >> 'side') == 3} - })" configClasses (configFile >> "CfgVehicles"); +private _originalBlacklistedAreasAndGround = GVAR(vehicleBlacklistedAreas) + ["ground"]; +private _originalBlacklistedAreasAndWater = GVAR(vehicleBlacklistedAreas) + ["water"]; + +// Retrieve civilian car types from config +private _customCivilianCarTypes = getArray (missionConfigFile >> "CfgSerialKillers" >> "Civilian" >> "CarTypes"); + +private _civilianCarTypes = if (_customCivilianCarTypes isNotEqualTo []) then { + _customCivilianCarTypes apply {configFile >> "CfgVehicles" >> _x} +} else { + // By default get all civilian side vehicles + "( (getNumber (_x >> 'scope') >= 2) + && { + getText (_x >> 'vehicleClass') in ['Car'] + && {getNumber (_x >> 'side') == 3} + })" configClasses (configFile >> "CfgVehicles"); +}; + +// TODO: Consider blacklist while {_i > 0} do { private _carType = selectRandom _civilianCarTypes;