Add function for vehicle addons

This adds a remove and add ammo function for vehicles. Also a keep flares check if the vehicle ammo got removed.
Server admins can add/remove different weapons to vehicles by just editing server_spawnVehicle.
This commit is contained in:
A Man
2022-03-22 18:27:33 +01:00
parent 637f1f4450
commit 981e217b8e
12 changed files with 148 additions and 82 deletions

View File

@@ -141,52 +141,18 @@ if (_outcome != "PASS") then {
processInitCommands;
[_weapons,_magazines,_backpacks,_object] call fn_addCargo;
_clearTurrets = {
//By denvdmj (probably, I found it on the biki)
private ["_weaponArray","_findRecurse","_class","_obj","_turret","_mags"];
_obj = _this;
_weaponArray = [];
_weaponArray set [count _weaponArray,[-1]];
_findRecurse = {
private ["_root", "_class", "_path", "_currentPath", "_thisThis"];
_root = (_this select 0);
_path = +(_this select 1);
_thisThis = _this select 2;
for "_i" from 0 to count _root -1 do {
_class = _root select _i;
if (isClass _class) then {
_currentPath = _path + [_i];
{_weaponArray set [count _weaponArray, _currentPath];} count getArray (_class >> "weapons");
_class = _class >> "turrets";
if (isClass _class) then {[_class, _currentPath, _thisThis] call _findRecurse;};
};
};
};
[configFile >> "CfgVehicles" >> typeOf (_obj) >> "turrets", [], _this] call _findRecurse;
{
_turret = _x;
_mags = _obj magazinesTurret _turret;
{_obj removeMagazinesTurret[_x,_turret];} count _mags;
} forEach _weaponArray;
};
_object setFuel _fuel;
[_object,_newHitpoints] call server_setHitpoints;
[_object,"all",true] call server_updateObject;
[_object,DZE_clearVehicleAmmo,false] call server_vehicleAddons;
_object call fnc_veh_ResetEH;
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";
{if (_object isKindOf _x) exitWith {_object disableTIEquipment true;}} count vkc_disableThermal;
if (vkc_clearAmmo) then {_object call _clearTurrets;};
publicVariable "PVDZE_veh_Init";
dze_waiting = "success";
(owner _activatingPlayer) publicVariableClient "dze_waiting";