ACE3/addons/common/functions/fnc_getHitPointsWithSelections.sqf

62 lines
1.6 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
*
* Returns all hitpoints and their selections of any vehicle. Might contain duplicates if the turrets contain non unique hitpoints with different selection names.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
*
* Return Value:
* The hitpoints with selections. Format: [hitpoints, selections]. They correspond by index. (Array)
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-05-14 22:12:40 +00:00
private ["_config", "_hitpoints", "_selections", "_i"];
2015-05-14 18:06:06 +00:00
PARAMS_1(_vehicle);
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_hitpoints = [];
_selections = [];
// get all classes that can contain hitpoints
private "_hitpointClasses";
_hitpointClasses = [_config >> "HitPoints"];
{
2015-02-19 18:14:52 +00:00
private "_class";
_class = ([_config, _x] call FUNC(getTurretConfigPath)) >> "HitPoints";
2015-02-19 18:14:52 +00:00
if (isClass _class) then {
_hitpointClasses pushBack _class;
};
} forEach allTurrets _vehicle;
// iterate through all classes with hitpoints and their parents
{
2015-02-19 18:14:52 +00:00
private "_class";
_class = _x;
2015-02-19 18:14:52 +00:00
while {isClass _class} do {
2015-02-19 18:14:52 +00:00
for "_i" from 0 to (count _class - 1) do {
if (isClass (_class select _i)) then {
private ["_entry", "_selection"];
_entry = configName (_class select _i);
_selection = getText (_class select _i >> "name");
if (!(_selection in _selections) && {!isNil {_vehicle getHit _selection}}) then {
_hitpoints pushBack _entry;
_selections pushBack _selection;
};
2015-02-19 18:14:52 +00:00
};
};
2015-02-19 18:14:52 +00:00
_class = inheritsFrom _class;
};
} forEach _hitpointClasses;
[_hitpoints, _selections]