Moved inline functions to their own files...
This commit is contained in:
parent
905423fc73
commit
bd5dec4874
|
@ -62,132 +62,9 @@ _playerMagazines = _playerMagazines apply {toLower _x};
|
|||
player removeMagazines _x;
|
||||
} forEach ((_playerMagazines arrayIntersect _playerMagazines) - KP_liberation_allowed_items);
|
||||
|
||||
// This is essentially slightly modified CBA_fnc_removeWeaponCargo because it's not possible to remove
|
||||
// weapons from containers (uniform, vest, backpack) with removeWeapon.
|
||||
private _removeWeapons = {
|
||||
params [["_container", objNull, [objNull]]];
|
||||
if (isNull _container) exitWith {
|
||||
[]
|
||||
};
|
||||
|
||||
private _removed = [];
|
||||
private _weaponsItemsCargo = weaponsItemsCargo _container;
|
||||
clearWeaponCargoGlobal _container;
|
||||
|
||||
private _weaponComponents = {
|
||||
params [["_weapon", "", [""]]];
|
||||
private _config = configFile >> "CfgWeapons" >> _weapon;
|
||||
|
||||
// Return empty array if the weapon doesn't exist
|
||||
if (!isClass _config) exitWith {
|
||||
[];
|
||||
};
|
||||
|
||||
// get attachments
|
||||
private _attachments = [];
|
||||
{
|
||||
_attachments pushBack toLower getText (_x >> "item");
|
||||
} forEach ("true" configClasses (_config >> "LinkedItems")); // inheritance is apparently disabled for these
|
||||
|
||||
// get first parent without attachments
|
||||
private _baseWeapon = "";
|
||||
while {isClass _config && {getNumber (_config >> "scope") > 0}} do { // Some preset weapons are scope = 1
|
||||
if (count (_config >> "LinkedItems") == 0) exitWith {
|
||||
_baseWeapon = configName _config;
|
||||
};
|
||||
|
||||
_config = inheritsFrom _config;
|
||||
};
|
||||
|
||||
private _components = [toLower _baseWeapon];
|
||||
_components append _attachments;
|
||||
|
||||
_components
|
||||
};
|
||||
|
||||
{
|
||||
_x params ["_weapon", "_muzzle", "_pointer", "_optic", "_magazine", "_magazineGL", "_bipod"];
|
||||
|
||||
// weaponsItems magazineGL does not exist if not loaded (not even as empty array)
|
||||
if (count _x < 7) then {
|
||||
_bipod = _magazineGL;
|
||||
_magazineGL = "";
|
||||
};
|
||||
|
||||
// Some weapons don't have non-preset parents
|
||||
_components = _weapon call _weaponComponents;
|
||||
private _weaponNonPreset = _components select 0;
|
||||
|
||||
if (_weaponNonPreset == "") then {
|
||||
_weaponNonPreset = _weapon;
|
||||
};
|
||||
|
||||
if (toLower _weapon in KP_liberation_allowed_items) then {
|
||||
_container addWeaponCargoGlobal [_weaponNonPreset, 1];
|
||||
|
||||
// If weapon does not have a non-preset parent, only add attachments that were custom added
|
||||
// Removed attachments cannot be handled (engine limitation) and will be readded due to having to readd preset weapon
|
||||
private _presetAttachments = [];
|
||||
if (_weaponNonPreset == _weapon) then {
|
||||
_presetAttachments = _components;
|
||||
};
|
||||
if !(toLower _muzzle in _presetAttachments) then {
|
||||
if (toLower _muzzle in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_muzzle, 1];
|
||||
} else {
|
||||
_removed pushBack _muzzle;
|
||||
}
|
||||
};
|
||||
if !(toLower _pointer in _presetAttachments) then {
|
||||
if (toLower _pointer in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_pointer, 1];
|
||||
} else {
|
||||
_removed pushBack _pointer;
|
||||
}
|
||||
};
|
||||
if !(toLower _optic in _presetAttachments) then {
|
||||
if (toLower _optic in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_optic, 1];
|
||||
} else {
|
||||
_removed pushBack _optic;
|
||||
}
|
||||
};
|
||||
if !(toLower _bipod in _presetAttachments) then {
|
||||
if (toLower _optic in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_optic, 1];
|
||||
} else {
|
||||
_removed pushBack _optic;
|
||||
}
|
||||
};
|
||||
|
||||
_magazine params [["_magazineClass", ""], ["_magazineAmmoCount", 0]];
|
||||
if (_magazineClass != "") then {
|
||||
if (toLower _magazineClass in KP_liberation_allowed_items) then {
|
||||
_container addMagazineAmmoCargo [_magazineClass, 1, _magazineAmmoCount];
|
||||
} else {
|
||||
_removed pushBack _magazineClass;
|
||||
}
|
||||
};
|
||||
|
||||
_magazineGL params [["_magazineGLClass", ""], ["_magazineGLAmmoCount", 0]];
|
||||
if (_magazineGLClass != "") then {
|
||||
if (toLower _magazineGLClass in KP_liberation_allowed_items) then {
|
||||
_container addMagazineAmmoCargo [_magazineGLClass, 1, _magazineGLAmmoCount];
|
||||
} else {
|
||||
_removed pushBack _magazineGLClass;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
_removed pushBack _weapon;
|
||||
}
|
||||
} forEach _weaponsItemsCargo;
|
||||
|
||||
_removed;
|
||||
};
|
||||
|
||||
_removedItems append ([uniformContainer player] call _removeWeapons);
|
||||
_removedItems append ([vestContainer player] call _removeWeapons);
|
||||
_removedItems append ([backpackContainer player] call _removeWeapons);
|
||||
_removedItems append ([uniformContainer player] call F_removeWeaponCargo);
|
||||
_removedItems append ([vestContainer player] call F_removeWeaponCargo);
|
||||
_removedItems append ([backpackContainer player] call F_removeWeaponCargo);
|
||||
|
||||
private _weapons = weapons player;
|
||||
_weapons = _weapons apply {toLower _x};
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
F_getWeaponComponents
|
||||
|
||||
File: F_kp_getWeaponComponents.sqf
|
||||
Author: Zharf, based on CBA_fnc_weaponComponents by commy2
|
||||
Date: 2019-06-21
|
||||
Last Update: 2019-06-21
|
||||
|
||||
Description:
|
||||
Snatched from CBA since we don't depend on it yet.
|
||||
Reports class name of base weapon without attachments and all attachments belonging to a pre equipped weapon.
|
||||
Base weapon and attachments are reported in lower case capitalization.
|
||||
Fixed version of BIS_fnc_weaponComponents.
|
||||
|
||||
Parameter(s):
|
||||
0: STRING - a weapons class name with attachments build in
|
||||
|
||||
Returns:
|
||||
ARRAY
|
||||
*/
|
||||
|
||||
params [["_weapon", "", [""]]];
|
||||
private _config = configFile >> "CfgWeapons" >> _weapon;
|
||||
|
||||
// Return empty array if the weapon doesn't exist
|
||||
if (!isClass _config) exitWith {
|
||||
[];
|
||||
};
|
||||
|
||||
// get attachments
|
||||
private _attachments = [];
|
||||
{
|
||||
_attachments pushBack toLower getText (_x >> "item");
|
||||
} forEach ("true" configClasses (_config >> "LinkedItems")); // inheritance is apparently disabled for these
|
||||
|
||||
// get first parent without attachments
|
||||
private _baseWeapon = "";
|
||||
while {isClass _config && {getNumber (_config >> "scope") > 0}} do { // Some preset weapons are scope = 1
|
||||
if (count (_config >> "LinkedItems") == 0) exitWith {
|
||||
_baseWeapon = configName _config;
|
||||
};
|
||||
|
||||
_config = inheritsFrom _config;
|
||||
};
|
||||
|
||||
private _components = [toLower _baseWeapon];
|
||||
_components append _attachments;
|
||||
|
||||
_components
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
F_removeWeaponCargo
|
||||
|
||||
File: F_kp_removeWeaponCargo.sqf
|
||||
Author: Zharf, based on CBA_fnc_removeWeaponCargo by Jonpas
|
||||
Date: 2019-06-21
|
||||
Last Update: 2019-06-21
|
||||
|
||||
Description:
|
||||
Removes weapons not found in KP_liberation_allowed_items from a cargo space
|
||||
|
||||
Warning: All weapon attachments/magazines in container will become detached.
|
||||
Warning: Preset weapons without non-preset parents will get their attachments readded (engine limitation).
|
||||
|
||||
Parameter(s):
|
||||
0: OBJECT - Object with cargo
|
||||
|
||||
Returns:
|
||||
ARRAY
|
||||
*/
|
||||
|
||||
params [["_container", objNull, [objNull]]];
|
||||
if (isNull _container) exitWith {
|
||||
[]
|
||||
};
|
||||
|
||||
private _removed = [];
|
||||
private _weaponsItemsCargo = weaponsItemsCargo _container;
|
||||
clearWeaponCargoGlobal _container;
|
||||
|
||||
{
|
||||
_x params ["_weapon", "_muzzle", "_pointer", "_optic", "_magazine", "_magazineGL", "_bipod"];
|
||||
|
||||
// weaponsItems magazineGL does not exist if not loaded (not even as empty array)
|
||||
if (count _x < 7) then {
|
||||
_bipod = _magazineGL;
|
||||
_magazineGL = "";
|
||||
};
|
||||
|
||||
// Some weapons don't have non-preset parents
|
||||
_components = _weapon call F_getWeaponComponents;
|
||||
private _weaponNonPreset = _components select 0;
|
||||
|
||||
if (_weaponNonPreset == "") then {
|
||||
_weaponNonPreset = _weapon;
|
||||
};
|
||||
|
||||
if (toLower _weapon in KP_liberation_allowed_items) then {
|
||||
_container addWeaponCargoGlobal [_weaponNonPreset, 1];
|
||||
|
||||
// If weapon does not have a non-preset parent, only add attachments that were custom added
|
||||
// Removed attachments cannot be handled (engine limitation) and will be readded due to having to readd preset weapon
|
||||
private _presetAttachments = [];
|
||||
if (_weaponNonPreset == _weapon) then {
|
||||
_presetAttachments = _components;
|
||||
};
|
||||
if !(toLower _muzzle in _presetAttachments) then {
|
||||
if (toLower _muzzle in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_muzzle, 1];
|
||||
} else {
|
||||
_removed pushBack _muzzle;
|
||||
}
|
||||
};
|
||||
if !(toLower _pointer in _presetAttachments) then {
|
||||
if (toLower _pointer in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_pointer, 1];
|
||||
} else {
|
||||
_removed pushBack _pointer;
|
||||
}
|
||||
};
|
||||
if !(toLower _optic in _presetAttachments) then {
|
||||
if (toLower _optic in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_optic, 1];
|
||||
} else {
|
||||
_removed pushBack _optic;
|
||||
}
|
||||
};
|
||||
if !(toLower _bipod in _presetAttachments) then {
|
||||
if (toLower _optic in KP_liberation_allowed_items) then {
|
||||
_container addItemCargoGlobal [_optic, 1];
|
||||
} else {
|
||||
_removed pushBack _optic;
|
||||
}
|
||||
};
|
||||
|
||||
_magazine params [["_magazineClass", ""], ["_magazineAmmoCount", 0]];
|
||||
if (_magazineClass != "") then {
|
||||
if (toLower _magazineClass in KP_liberation_allowed_items) then {
|
||||
_container addMagazineAmmoCargo [_magazineClass, 1, _magazineAmmoCount];
|
||||
} else {
|
||||
_removed pushBack _magazineClass;
|
||||
}
|
||||
};
|
||||
|
||||
_magazineGL params [["_magazineGLClass", ""], ["_magazineGLAmmoCount", 0]];
|
||||
if (_magazineGLClass != "") then {
|
||||
if (toLower _magazineGLClass in KP_liberation_allowed_items) then {
|
||||
_container addMagazineAmmoCargo [_magazineGLClass, 1, _magazineGLAmmoCount];
|
||||
} else {
|
||||
_removed pushBack _magazineGLClass;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
_removed pushBack _weapon;
|
||||
}
|
||||
} forEach _weaponsItemsCargo;
|
||||
|
||||
_removed;
|
||||
|
|
@ -57,6 +57,8 @@ F_getResistanceTier = compileFinal preprocessFileLineNumbers "scripts\shared\fun
|
|||
F_spawnGuerillaGroup = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_spawnGuerillaGroup.sqf";
|
||||
F_createCrate = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_createCrate.sqf";
|
||||
F_isClassUAV = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_isClassUAV.sqf";
|
||||
F_getWeaponComponents = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_getWeaponComponents.sqf";
|
||||
F_removeWeaponCargo = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_removeWeaponCargo.sqf";
|
||||
F_checkGear = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_checkGear.sqf";
|
||||
F_setFobMass = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_setFobMass.sqf";
|
||||
F_getSaveableParam = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_getSaveableParam.sqf";
|
||||
|
|
Loading…
Reference in New Issue