ACE3/addons/arsenal/functions/fnc_verifyLoadout.sqf
Josuan Albin 1d6e07d18f Add ACE Arsenal stats (#6110)
* Add test class

* Add stats mockup

* Merge branch 'master' of https://github.com/acemod/ACE3 into arsenalStats

* Finish mockup, add basic hide/show logic

* Add base for stats

* Use CBA EHs for stats to allow 3rd party mods of it

* Add handleStats and most of the UI behaviors for stats

* Continue work on stats

* Add container stats

* Add page support for stats

* Add text for the ROF stat

* Add accuracy in MOA for the accuracy stat

* Change accuracy shown number to 1 decimal instead of 2

* Add MIL in the dispersion stat text

* Change stats layout, remove dummy text strings

* Add some AB stats

* Remove last test string

* Replace configExtremes by normal lookup where it's relevant

* Add "undefined value" string when AB stat isn't present

Mostly for laucnhers

* Fix typo in preInit

* Change drag model stat to ballistic coef

* Fix issue with unused stats, change text to white when bar is present

* Rewrite some part of handleStats

Reason: add support for conditions, less redundant code, less reasons for dedmen to emasculate me

* Re-add _hideUnusedFnc, handle empty stats arrays

* Pass args to stat conditions, add test condition stat

* Add hearing related stats

* Remove the padding between stats and the stat bar / text

* Add strings for stats

* Change stats window to fit baer's suggestion

* Algin the close stats button, add missing strings

* Finish code review

* Add missing newline

* Remove duplicate strings

* Add explosive range stat

* Use proper string for the explo range stat

* Fix capitalization for ctrlParent

* Fix conditional stats blocking other stats

* Add better integration for ballistics, hearing and explosive stats

* Replace the private array in handleStat by params

* Add backblast stats

* Add backblast stat strings

* Add flashlight map color and g-force reduction stats

* Shorten preInit

* Change stats close button to fit arsenal design

* Improve stats page indicator look

* Rework how stats are stored and retrieved

* Remove args config entry, add priority entry, add vanilla weapon stats

* Add vanilla container stats

* Remove some lines in preInit

* Add ballistics stats

* Add hearing stats

* Remove uneeded config entries

* Add explosive range stat

* Add backblast stats

* Add spaces after semicolons in statements

To make JJ happy because I don't care.

* Add flashlights map color stat

* Add gforce reduction stat

FINALLY FUCKING DONE

* Fix headers for the new stats funcs

* Add add / remove stat API

* Fix typo in removeStat header

* Remove uneeded inline func

* Clean up add / remove stat

* Move all CfgACEArsenalStats entries to their own file

* Replace STR_ACE_Ballistics_statAmmo by a BI string

* Add script profiler related macro and code

* Use the highest ballistic coef instead of first one defined

* Add support for future ammo displayname

* Add ACE_standardAtmosphere for ballistic coef

* Add mag muzzle velocity stat

* Add weapon muzzle velocity stat

* Add comment explaining the ENABLE_PERF_PROFILING macro

* Change cfgACEArsenalStats to ACE_Arsenal_Stats

* Make JJ less pissy about spaces around =

* Fix indentation in weaponMuzzleVelocity, use param

* Use GVAR and EGVAR when appropriate

* Prefix all stats except the base class

* Fix Merge

* Fix aspect ratio scaling of stats panel

* Minor fixes
2018-02-15 10:03:22 -06:00

240 lines
8.7 KiB
Plaintext

/*
* Author: Alganthe
* Verify the provided loadout.
*
* Arguments:
* 0: Loadout <ARRAY> (getUnitLoadout format)
*
* Return Value:
* Verified loadout and missing / unavailable items list and count <ARRAY>
*
* Public: No
*/
#include "script_component.hpp"
#include "..\defines.hpp"
params ["_loadout"];
private _weaponCfg = configFile >> "CfgWeapons";
private _magCfg = configFile >> "CfgMagazines";
private _vehcCfg = configFile >> "CfgVehicles";
private _glassesCfg = configFile >> "CfgGlasses";
private _weaponsArray = GVAR(virtualItems) select 0;
private _accsArray = GVAR(virtualItems) select 1;
private _nullItemsAmount = 0;
private _unavailableItemsAmount = 0;
private _nullItemsList = [];
private _unavailableItemsList = [];
private _fnc_weaponCheck = {
params ["_dataPath"];
if (count _dataPath != 0) then {
{
if (_x isEqualType "") then {
private _item = _x;
if (_item != "") then {
if (isClass (_weaponCfg >> _item)) then {
if !(CHECK_WEAPON_OR_ACC) then {
_unavailableItemsList pushBackUnique _item;
_dataPath set [_forEachIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
_dataPath set [_forEachIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
} else {
if (count _x != 0) then {
private _mag = _x select 0;
if (isClass (_magCfg >> _mag)) then {
if !(_mag in (GVAR(virtualItems) select 2)) then {
_unavailableItemsList pushBackUnique _mag;
_dataPath set [_forEachIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _mag;
_dataPath set [_forEachIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
};
} foreach _dataPath;
};
};
for "_dataIndex" from 0 to 9 do {
switch (_dataIndex) do {
case 0;
case 1;
case 2;
case 8: {
[_loadout select _dataIndex] call _fnc_weaponCheck;
};
case 3;
case 4;
case 5: {
private _containerArray = (_loadout select _dataIndex);
if (count _containerArray != 0) then {
_containerArray params ["_item", "_containerItems"];
if (isClass (_vehcCfg >> _item) || {isClass (_weaponCfg >> _item)}) then {
if !(CHECK_CONTAINER) then {
_unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
} else {
if (count _containerItems != 0) then {
{
private _currentIndex = _forEachIndex;
switch (count _x) do {
case 2: {
if ((_x select 0) isEqualType "") then {
private _item = _x select 0;
if (CLASS_CHECK_ITEM) then {
if !(CHECK_CONTAINER_ITEMS) then {
_unavailableItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
};
} else {
[(((_loadout select _dataIndex) select 1) select _currentIndex) select 0] call _fnc_weaponCheck;
};
};
case 3: {
private _item = _x select 0;
if (isClass (_magCfg >> _item)) then {
if !(
_item in (GVAR(virtualItems) select 2) ||
_item in (GVAR(virtualItems) select 15) ||
_item in (GVAR(virtualItems) select 16)
) then {
_unavailableItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
((_loadout select _dataIndex) select 1) set [_currentIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
};
} foreach _containerItems;
};
};
} else {
_nullItemsList pushBackUnique _item;
_loadout set [_dataIndex, []];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
};
case 6: {
private _item = _loadout select _dataIndex;
if (_item != "") then {
if (isClass (_weaponCfg >> _item)) then {
if !(_item in (GVAR(virtualItems) select 3)) then {
_unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
};
case 7: {
private _item = _loadout select _dataIndex;
if (_item != "") then {
if (isClass (_glassesCfg >> _item)) then {
if !(_item in (GVAR(virtualItems) select 7)) then {
_unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
};
case 9: {
for "_subIndex" from 0 to 4 do {
private _item = (_loadout select _dataIndex) select _subIndex;
if (_item != "") then {
if (isClass (_weaponCfg >> _item)) then {
if !(CHECK_ASSIGNED_ITEMS) then {
_unavailableItemsList pushBackUnique _item;
(_loadout select _dataIndex) set [_subIndex, ""];
_unavailableItemsAmount = _unavailableItemsAmount + 1;
};
} else {
_nullItemsList pushBackUnique _item;
(_loadout select _dataIndex) set [_subIndex, ""];
_nullItemsAmount = _nullItemsAmount + 1;
};
};
};
};
};
};
[_loadout, _nullItemsAmount, _unavailableItemsAmount, _nullItemsList, _unavailableItemsList]