2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2023-07-06 03:52:04 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2, kymckay, LinkIsGrim
|
|
|
|
* Get list of vehicle hitpoints to ignore
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Vehicle <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* HitPoints to ignore <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
2023-09-25 18:55:23 +00:00
|
|
|
* [vehicle] call ace_repair_fnc_getSelectionsToIgnore
|
2023-07-06 03:52:04 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_vehicle"];
|
|
|
|
|
|
|
|
private _type = typeOf _vehicle;
|
2023-09-25 18:55:23 +00:00
|
|
|
TRACE_2("getSelectionsToIgnore",_vehicle,_type);
|
2023-07-06 03:52:04 +00:00
|
|
|
private _initializedClasses = missionNamespace getVariable [QGVAR(hitPointsToIgnoreInitializedClasses), createHashMap];
|
|
|
|
if (_type in _initializedClasses) exitWith {_initializedClasses get _type};
|
|
|
|
|
|
|
|
private _vehCfg = configOf _vehicle;
|
|
|
|
private _hitpointGroups = getArray (_vehCfg >> QGVAR(hitpointGroups));
|
|
|
|
private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehicle, "commander", true])) apply {_x # 3};
|
|
|
|
|
|
|
|
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]];
|
|
|
|
// get hitpoints of wheels with their selections
|
|
|
|
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
|
|
|
|
|
2023-09-25 18:55:23 +00:00
|
|
|
private _indexesToIgnore = [];
|
2023-07-06 03:52:04 +00:00
|
|
|
private _processedSelections = [];
|
|
|
|
|
|
|
|
{
|
|
|
|
private _selection = _x;
|
|
|
|
private _hitpoint = toLower (_hitPoints select _forEachIndex);
|
|
|
|
private _isWheelOrTrack = _selection in _wheelHitSelections || {_hitpoint in _wheelHitPoints} || {_hitpoint in TRACK_HITPOINTS};
|
|
|
|
|
|
|
|
if (_hitpoint isEqualTo "") then { // skip empty hitpoint
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore pushBack _forEachIndex;
|
2023-07-06 03:52:04 +00:00
|
|
|
continue
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_isWheelOrTrack && {_selection in _processedSelections || {_selection isEqualTo ""}}) then { // skip duplicate or empty selection wheel/track
|
|
|
|
TRACE_3("Skipping duplicate Wheel/Track or empty selection",_hitpoint,_forEachIndex,_selection);
|
|
|
|
/*#ifdef DEBUG_MODE_FULL
|
|
|
|
systemChat format ["Skipping duplicate wheel, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
|
|
|
#endif*/
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore pushBack _forEachIndex;
|
2023-07-06 03:52:04 +00:00
|
|
|
_processedSelections pushBack _selection;
|
|
|
|
continue
|
|
|
|
};
|
|
|
|
|
|
|
|
if ("glass" in _hitpoint) then { // skip glass
|
|
|
|
TRACE_3("Skipping glass",_hitpoint,_forEachIndex,_selection);
|
|
|
|
/*#ifdef DEBUG_MODE_FULL
|
|
|
|
systemChat format ["Skipping glass, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
|
|
|
#endif*/
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore pushBack _forEachIndex;
|
2023-07-06 03:52:04 +00:00
|
|
|
_processedSelections pushBack _selection;
|
|
|
|
continue
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_hitpoint select [0,7] isEqualTo "hitera_" || {_hitpoint select [0,8] isEqualTo "hitslat_"} || {_hitpoint select [0,4] isEqualTo "era_"}) then { // skip era/slat
|
|
|
|
TRACE_3("Skipping ERA/Slat HitPoint",_hitpoint,_forEachIndex,_selection);
|
|
|
|
/*#ifdef DEBUG_MODE_FULL
|
|
|
|
systemChat format ["Skipping ERA/SLAT, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
|
|
|
#endif*/
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore pushBack _forEachIndex;
|
2023-07-06 03:52:04 +00:00
|
|
|
_processedSelections pushBack _selection;
|
|
|
|
continue
|
|
|
|
};
|
|
|
|
|
|
|
|
private _armorComponent = "";
|
|
|
|
if (_selection == "") then { // some hitpoints have empty selection but defined armor component (mostly RHS)
|
|
|
|
{
|
|
|
|
private _turretHitpointCfg = ([_vehCfg, _x] call CBA_fnc_getTurret) >> "HitPoints";
|
|
|
|
private _hitpointsCfg = "configName _x == _hitpoint" configClasses _turretHitpointCfg;
|
|
|
|
if (_hitpointsCfg isNotEqualTo []) exitWith {
|
|
|
|
TRACE_2("turret hitpoint configFound",_hitpoint,_x);
|
2023-09-25 18:55:23 +00:00
|
|
|
_hitpointsCfg = _hitpointsCfg # 0;
|
2023-07-06 03:52:04 +00:00
|
|
|
// only do turret hitpoints and stuff linked to visuals
|
2023-09-25 18:55:23 +00:00
|
|
|
if (
|
|
|
|
(_hitpoint in ["hitturret", "hitgun"]) ||
|
|
|
|
{(getNumber (_hitpointsCfg >> "isGun")) == 1} ||
|
|
|
|
{(getNumber (_hitpointsCfg >> "isTurret")) == 1} ||
|
|
|
|
{(getText (_hitpointsCfg >> "visual")) != ""}
|
|
|
|
) then {
|
|
|
|
_armorComponent = getText (_hitpointsCfg >> "armorComponent");
|
2023-07-06 03:52:04 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _turretPaths;
|
|
|
|
if (_armorComponent == "") then {
|
|
|
|
private _hitpointsCfg = "configName _x == _hitpoint" configClasses (_vehCfg >> "HitPoints");
|
2023-09-25 18:55:23 +00:00
|
|
|
if (_hitpointsCfg isNotEqualTo []) then {
|
|
|
|
_hitpointsCfg = _hitpointsCfg # 0;
|
|
|
|
if (
|
|
|
|
(getNumber (_hitpointsCfg >> "isGun")) == 1 ||
|
|
|
|
{(getNumber (_hitpointsCfg >> "isTurret")) == 1} ||
|
|
|
|
{(getText (_hitpointsCfg >> "visual")) != ""}
|
|
|
|
) then {
|
|
|
|
_armorComponent = getText (_hitpointsCfg >> "armorComponent");
|
|
|
|
};
|
2023-07-06 03:52:04 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((_selection == "") && {_armorComponent == ""}) then {
|
|
|
|
TRACE_3("Skipping no selection OR armor component",_hitpoint,_forEachIndex,_selection);
|
|
|
|
/*#ifdef DEBUG_MODE_FULL
|
|
|
|
systemChat format ["Skipping no selection OR armor component, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
|
|
|
#endif*/
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore pushBack _forEachIndex;
|
2023-07-06 03:52:04 +00:00
|
|
|
_processedSelections pushBack _selection;
|
|
|
|
continue
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!(getText (_vehCfg >> "HitPoints" >> _hitpoint >> "depends") in ["", "0"])) then { // skip depends hitpoints, should be normalized by engine
|
|
|
|
TRACE_3("Skipping depends hitpoint",_hitpoint,_forEachIndex,_selection);
|
|
|
|
/*#ifdef DEBUG_MODE_FULL
|
|
|
|
systemChat format ["Skipping depends hitpoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
|
|
|
#endif*/
|
2023-07-28 03:32:30 +00:00
|
|
|
|
|
|
|
private _groupIndex = _hitpointGroups findIf {_x # 0 == _hitpoint};
|
|
|
|
if (_groupIndex != -1) then {
|
|
|
|
ERROR_2("[%1] hitpoint [%2] is both a group-parent and a depends and will be unrepairable",_type,_hitpoint);
|
|
|
|
ERROR_1("group: %1",_hitpointGroups # _groupIndex);
|
|
|
|
};
|
|
|
|
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore pushBack _forEachIndex;
|
2023-07-06 03:52:04 +00:00
|
|
|
_processedSelections pushBack _selection;
|
|
|
|
continue
|
|
|
|
};
|
|
|
|
|
2023-07-28 03:32:30 +00:00
|
|
|
if (ANY_OF(_hitpointGroups, ANY_OF(_x select 1, _x == _hitpoint))) then { // skip child hitpoints
|
2023-07-06 03:52:04 +00:00
|
|
|
TRACE_3("Skipping child hitpoint",_hitpoint,_forEachIndex,_selection);
|
|
|
|
/*#ifdef DEBUG_MODE_FULL
|
|
|
|
systemChat format ["Skipping child hitpoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
|
|
|
#endif*/
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore pushBack _forEachIndex;
|
2023-07-06 03:52:04 +00:00
|
|
|
_processedSelections pushBack _selection;
|
|
|
|
continue
|
|
|
|
};
|
|
|
|
|
|
|
|
_processedSelections pushBack _selection;
|
|
|
|
} forEach _hitSelections;
|
|
|
|
|
2023-09-25 18:55:23 +00:00
|
|
|
_initializedClasses set [_type, _indexesToIgnore];
|
2023-07-06 03:52:04 +00:00
|
|
|
missionNamespace setVariable [QGVAR(hitPointsToIgnoreInitializedClasses), _initializedClasses];
|
|
|
|
|
2023-09-25 18:55:23 +00:00
|
|
|
_indexesToIgnore
|