Repair - Fix adding actions for hitpoints with the same name (#9430)

This commit is contained in:
Grim 2023-09-25 14:55:23 -04:00 committed by GitHub
parent 5283b487ff
commit cf4fe835c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 39 deletions

View File

@ -21,7 +21,7 @@ PREP(fullRepairProgress);
PREP(getClaimObjects); PREP(getClaimObjects);
PREP(getFullRepairTime); PREP(getFullRepairTime);
PREP(getHitPointString); PREP(getHitPointString);
PREP(getHitPointsToIgnore); PREP(getSelectionsToIgnore);
PREP(getPatchWheelTime); PREP(getPatchWheelTime);
PREP(getPostRepairDamage); PREP(getPostRepairDamage);
PREP(getRepairItems); PREP(getRepairItems);

View File

@ -29,8 +29,8 @@ TRACE_2("addRepairActions", _vehicle,_type);
private _initializedClasses = GETMVAR(GVAR(initializedClasses),[]); private _initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
if (_type in _initializedClasses) exitWith {}; if (_type in _initializedClasses) exitWith {};
// get hitPoints to ignore // get selections to ignore
private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore); private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
// get all hitpoints and selections // get all hitpoints and selections
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]]; // Since 1.82 these are all lower case (getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]]; // Since 1.82 these are all lower case
@ -41,7 +41,6 @@ private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore);
private _hitPointsAddedNames = []; private _hitPointsAddedNames = [];
private _hitPointsAddedStrings = []; private _hitPointsAddedStrings = [];
private _hitPointsAddedAmount = []; private _hitPointsAddedAmount = [];
private _processedSelections = [];
private _icon = ["a3\ui_f\data\igui\cfg\actions\repair_ca.paa", "#FFFFFF"]; private _icon = ["a3\ui_f\data\igui\cfg\actions\repair_ca.paa", "#FFFFFF"];
private _vehCfg = configOf _vehicle; private _vehCfg = configOf _vehicle;
@ -53,10 +52,14 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
{ {
private _selection = _x; private _selection = _x;
private _hitpoint = toLower (_hitPoints select _forEachIndex); private _hitpoint = toLower (_hitPoints select _forEachIndex);
if (_selection in _wheelHitSelections) then {
// Wheels should always be unique
if (_selection in _processedSelections) exitWith {TRACE_3("Duplicate Wheel",_hitpoint,_forEachIndex,_selection);};
// Skip ignored selections
if (_forEachIndex in _selectionsToIgnore) then {
TRACE_3("Skipping ignored hitpoint",_hitpoint,_forEachIndex,_selection);
continue
};
if (_selection in _wheelHitSelections) then {
private _position = compile format ["_target selectionPosition ['%1', 'HitPoints', 'AveragePoint'];", _selection]; private _position = compile format ["_target selectionPosition ['%1', 'HitPoints', 'AveragePoint'];", _selection];
TRACE_3("Adding Wheel Actions",_hitpoint,_forEachIndex,_selection); TRACE_3("Adding Wheel Actions",_hitpoint,_forEachIndex,_selection);
@ -90,14 +93,7 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
private _statement = {[_this select 1, _this select 0, _this select 2 select 0, "PatchWheel"] call DFUNC(repair)}; private _statement = {[_this select 1, _this select 0, _this select 2 select 0, "PatchWheel"] call DFUNC(repair)};
private _action = [_name, _text, _patchIcon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction); private _action = [_name, _text, _patchIcon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [_root], _action] call EFUNC(interact_menu,addActionToClass); [_type, 0, [_root], _action] call EFUNC(interact_menu,addActionToClass);
_processedSelections pushBack _selection;
} else { } else {
// Skip ignored hitpoints
if (_hitpoint in _hitPointsToIgnore) exitWith {
TRACE_3("Skipping ignored hitpoint",_hitpoint,_forEachIndex,_selection);
};
// Some hitpoints do not have a selection but do have an armorComponent value (seems to mainly be RHS) // Some hitpoints do not have a selection but do have an armorComponent value (seems to mainly be RHS)
// Ref https://community.bistudio.com/wiki/Arma_3_Damage_Enhancement // Ref https://community.bistudio.com/wiki/Arma_3_Damage_Enhancement
// this code won't support identically named hitpoints (e.g. commander turret: Duplicate HitPoint name 'HitTurret') // this code won't support identically named hitpoints (e.g. commander turret: Duplicate HitPoint name 'HitTurret')
@ -156,8 +152,6 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
_hitPointsAddedAmount = _trackArray select 2; _hitPointsAddedAmount = _trackArray select 2;
if (_hitpoint in TRACK_HITPOINTS) then { if (_hitpoint in TRACK_HITPOINTS) then {
// Tracks should always be unique
if (_selection in _processedSelections) exitWith {TRACE_3("Duplicate Track",_hitpoint,_forEachIndex,_selection);};
_position = compile format ["private _return = _target selectionPosition ['%1', 'HitPoints']; _return set [1, 0]; _return", _selection]; _position = compile format ["private _return = _target selectionPosition ['%1', 'HitPoints']; _return set [1, 0]; _return", _selection];
TRACE_4("Adding RepairTrack",_hitpoint,_forEachIndex,_selection,_text); TRACE_4("Adding RepairTrack",_hitpoint,_forEachIndex,_selection,_text);
private _condition = {[_this select 1, _this select 0, _this select 2 select 0, "RepairTrack"] call DFUNC(canRepair)}; private _condition = {[_this select 1, _this select 0, _this select 2 select 0, "RepairTrack"] call DFUNC(canRepair)};
@ -176,8 +170,6 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
}; };
}; };
_processedSelections pushBack _selection;
}; };
} forEach _hitSelections; } forEach _hitSelections;

View File

@ -32,11 +32,10 @@ if (_totalTime - _elapsedTime > ([_engineer, _vehicle] call FUNC(getFullRepairTi
private _allHitPointsDamage = getAllHitPointsDamage _vehicle; private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"]; _allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore); private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
private _firstDamagedIndex = { private _firstDamagedIndex = {
private _hitPoint = _hitPoints select _forEachIndex; if (_x > 0 && {!(_forEachIndex in _selectionsToIgnore)}) exitWith {_forEachIndex};
if (_x > 0 && {!(_hitPoint in _hitPointsToIgnore)}) exitWith {_forEachIndex};
-1 -1
} forEach _damageValues; } forEach _damageValues;

View File

@ -21,14 +21,13 @@ params ["_engineer", "_vehicle"];
private _allHitPointsDamage = getAllHitPointsDamage _vehicle; private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"]; _allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore); private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
private _repairsNeeded = 0; private _repairsNeeded = 0;
private _doExtraRepair = false; private _doExtraRepair = false;
{ {
if (_x <= 0) then {continue}; // skip hitpoints that don't need repairs if (_x <= 0) then {continue}; // skip hitpoints that don't need repairs
private _hitPoint = _hitPoints select _forEachIndex; if (_forEachIndex in _selectionsToIgnore) then { // only add extra repair for ignore hitpoints if they're damaged
if (_hitPoint in _hitPointsToIgnore) then { // only add extra repair for ignore hitpoints if they're damaged
_doExtraRepair = true; _doExtraRepair = true;
continue continue
}; };

View File

@ -10,7 +10,7 @@
* HitPoints to ignore <ARRAY> * HitPoints to ignore <ARRAY>
* *
* Example: * Example:
* [vehicle] call ace_repair_fnc_getHitpointsToIgnore * [vehicle] call ace_repair_fnc_getSelectionsToIgnore
* *
* Public: No * Public: No
*/ */
@ -18,7 +18,7 @@
params ["_vehicle"]; params ["_vehicle"];
private _type = typeOf _vehicle; private _type = typeOf _vehicle;
TRACE_2("getHitPointsToIgnore",_vehicle,_type); TRACE_2("getSelectionsToIgnore",_vehicle,_type);
private _initializedClasses = missionNamespace getVariable [QGVAR(hitPointsToIgnoreInitializedClasses), createHashMap]; private _initializedClasses = missionNamespace getVariable [QGVAR(hitPointsToIgnoreInitializedClasses), createHashMap];
if (_type in _initializedClasses) exitWith {_initializedClasses get _type}; if (_type in _initializedClasses) exitWith {_initializedClasses get _type};
@ -30,7 +30,7 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
// get hitpoints of wheels with their selections // get hitpoints of wheels with their selections
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"]; ([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
private _hitPointsToIgnore = [""]; // always ignore empty hitpoints private _indexesToIgnore = [];
private _processedSelections = []; private _processedSelections = [];
{ {
@ -39,6 +39,7 @@ private _processedSelections = [];
private _isWheelOrTrack = _selection in _wheelHitSelections || {_hitpoint in _wheelHitPoints} || {_hitpoint in TRACK_HITPOINTS}; private _isWheelOrTrack = _selection in _wheelHitSelections || {_hitpoint in _wheelHitPoints} || {_hitpoint in TRACK_HITPOINTS};
if (_hitpoint isEqualTo "") then { // skip empty hitpoint if (_hitpoint isEqualTo "") then { // skip empty hitpoint
_indexesToIgnore pushBack _forEachIndex;
continue continue
}; };
@ -47,7 +48,7 @@ private _processedSelections = [];
/*#ifdef DEBUG_MODE_FULL /*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping duplicate wheel, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection]; systemChat format ["Skipping duplicate wheel, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
#endif*/ #endif*/
_hitPointsToIgnore pushBackUnique _hitpoint; _indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection; _processedSelections pushBack _selection;
continue continue
}; };
@ -57,7 +58,7 @@ private _processedSelections = [];
/*#ifdef DEBUG_MODE_FULL /*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping glass, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection]; systemChat format ["Skipping glass, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
#endif*/ #endif*/
_hitPointsToIgnore pushBackUnique _hitpoint; _indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection; _processedSelections pushBack _selection;
continue continue
}; };
@ -67,7 +68,7 @@ private _processedSelections = [];
/*#ifdef DEBUG_MODE_FULL /*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping ERA/SLAT, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection]; systemChat format ["Skipping ERA/SLAT, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
#endif*/ #endif*/
_hitPointsToIgnore pushBackUnique _hitpoint; _indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection; _processedSelections pushBack _selection;
continue continue
}; };
@ -79,16 +80,29 @@ private _processedSelections = [];
private _hitpointsCfg = "configName _x == _hitpoint" configClasses _turretHitpointCfg; private _hitpointsCfg = "configName _x == _hitpoint" configClasses _turretHitpointCfg;
if (_hitpointsCfg isNotEqualTo []) exitWith { if (_hitpointsCfg isNotEqualTo []) exitWith {
TRACE_2("turret hitpoint configFound",_hitpoint,_x); TRACE_2("turret hitpoint configFound",_hitpoint,_x);
_hitpointsCfg = _hitpointsCfg # 0;
// only do turret hitpoints and stuff linked to visuals // only do turret hitpoints and stuff linked to visuals
if ((_hitpoint in ["hitturret", "hitgun"]) || {(getNumber (_hitpointsCfg # 0 >> "isGun")) == 1} || {(getNumber (_hitpointsCfg # 0 >> "isTurret")) == 1} || {(getText (_hitpointsCfg # 0 >> "visual")) != ""}) then { if (
_armorComponent = getText (_hitpointsCfg # 0 >> "armorComponent"); (_hitpoint in ["hitturret", "hitgun"]) ||
{(getNumber (_hitpointsCfg >> "isGun")) == 1} ||
{(getNumber (_hitpointsCfg >> "isTurret")) == 1} ||
{(getText (_hitpointsCfg >> "visual")) != ""}
) then {
_armorComponent = getText (_hitpointsCfg >> "armorComponent");
}; };
}; };
} forEach _turretPaths; } forEach _turretPaths;
if (_armorComponent == "") then { if (_armorComponent == "") then {
private _hitpointsCfg = "configName _x == _hitpoint" configClasses (_vehCfg >> "HitPoints"); private _hitpointsCfg = "configName _x == _hitpoint" configClasses (_vehCfg >> "HitPoints");
if (_hitpointsCfg isNotEqualTo [] && {(getText (_hitpointsCfg # 0 >> "visual")) != ""}) then { if (_hitpointsCfg isNotEqualTo []) then {
_armorComponent = getText (_hitpointsCfg # 0 >> "armorComponent"); _hitpointsCfg = _hitpointsCfg # 0;
if (
(getNumber (_hitpointsCfg >> "isGun")) == 1 ||
{(getNumber (_hitpointsCfg >> "isTurret")) == 1} ||
{(getText (_hitpointsCfg >> "visual")) != ""}
) then {
_armorComponent = getText (_hitpointsCfg >> "armorComponent");
};
}; };
}; };
}; };
@ -98,7 +112,7 @@ private _processedSelections = [];
/*#ifdef DEBUG_MODE_FULL /*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping no selection OR armor component, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection]; systemChat format ["Skipping no selection OR armor component, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
#endif*/ #endif*/
_hitPointsToIgnore pushBackUnique _hitpoint; _indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection; _processedSelections pushBack _selection;
continue continue
}; };
@ -115,7 +129,7 @@ private _processedSelections = [];
ERROR_1("group: %1",_hitpointGroups # _groupIndex); ERROR_1("group: %1",_hitpointGroups # _groupIndex);
}; };
_hitPointsToIgnore pushBackUnique _hitpoint; _indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection; _processedSelections pushBack _selection;
continue continue
}; };
@ -125,7 +139,7 @@ private _processedSelections = [];
/*#ifdef DEBUG_MODE_FULL /*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping child hitpoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection]; systemChat format ["Skipping child hitpoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
#endif*/ #endif*/
_hitPointsToIgnore pushBackUnique _hitpoint; _indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection; _processedSelections pushBack _selection;
continue continue
}; };
@ -133,7 +147,7 @@ private _processedSelections = [];
_processedSelections pushBack _selection; _processedSelections pushBack _selection;
} forEach _hitSelections; } forEach _hitSelections;
_initializedClasses set [_type, _hitPointsToIgnore]; _initializedClasses set [_type, _indexesToIgnore];
missionNamespace setVariable [QGVAR(hitPointsToIgnoreInitializedClasses), _initializedClasses]; missionNamespace setVariable [QGVAR(hitPointsToIgnoreInitializedClasses), _initializedClasses];
_hitPointsToIgnore _indexesToIgnore