Skip to content

Commit

Permalink
Add config for civilian >> UnitTypes[] and CarTypes[]
Browse files Browse the repository at this point in the history
  • Loading branch information
3Mydlo3 committed Mar 6, 2024
1 parent 6000646 commit 55c782e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion addons/civilian/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ PREP(getNearestCity);
PREP(getNearestVehicle);
PREP(initCity);
PREP(initCivilians);
PREP(initCiviliansConfig);
PREP(initConfig);
PREP(initCivilian);
PREP(unassignCivilianFromCity);
2 changes: 1 addition & 1 deletion addons/civilian/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 18 additions & 6 deletions addons/vehicles/functions/fnc_initVehicles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 55c782e

Please sign in to comment.