mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Repair - Fix adding actions for hitpoints with the same name (#9430)
This commit is contained in:
parent
5283b487ff
commit
cf4fe835c3
@ -21,7 +21,7 @@ PREP(fullRepairProgress);
|
||||
PREP(getClaimObjects);
|
||||
PREP(getFullRepairTime);
|
||||
PREP(getHitPointString);
|
||||
PREP(getHitPointsToIgnore);
|
||||
PREP(getSelectionsToIgnore);
|
||||
PREP(getPatchWheelTime);
|
||||
PREP(getPostRepairDamage);
|
||||
PREP(getRepairItems);
|
||||
|
@ -29,8 +29,8 @@ TRACE_2("addRepairActions", _vehicle,_type);
|
||||
private _initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
|
||||
if (_type in _initializedClasses) exitWith {};
|
||||
|
||||
// get hitPoints to ignore
|
||||
private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore);
|
||||
// get selections to ignore
|
||||
private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
|
||||
|
||||
// get all hitpoints and selections
|
||||
(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 _hitPointsAddedStrings = [];
|
||||
private _hitPointsAddedAmount = [];
|
||||
private _processedSelections = [];
|
||||
private _icon = ["a3\ui_f\data\igui\cfg\actions\repair_ca.paa", "#FFFFFF"];
|
||||
|
||||
private _vehCfg = configOf _vehicle;
|
||||
@ -53,10 +52,14 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
|
||||
{
|
||||
private _selection = _x;
|
||||
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];
|
||||
|
||||
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 _action = [_name, _text, _patchIcon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
|
||||
[_type, 0, [_root], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
|
||||
_processedSelections pushBack _selection;
|
||||
} 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)
|
||||
// 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')
|
||||
@ -156,8 +152,6 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
|
||||
_hitPointsAddedAmount = _trackArray select 2;
|
||||
|
||||
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];
|
||||
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)};
|
||||
@ -176,8 +170,6 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
|
||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
};
|
||||
};
|
||||
|
||||
_processedSelections pushBack _selection;
|
||||
};
|
||||
} forEach _hitSelections;
|
||||
|
||||
|
@ -32,11 +32,10 @@ if (_totalTime - _elapsedTime > ([_engineer, _vehicle] call FUNC(getFullRepairTi
|
||||
private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
|
||||
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
|
||||
|
||||
private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore);
|
||||
private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
|
||||
|
||||
private _firstDamagedIndex = {
|
||||
private _hitPoint = _hitPoints select _forEachIndex;
|
||||
if (_x > 0 && {!(_hitPoint in _hitPointsToIgnore)}) exitWith {_forEachIndex};
|
||||
if (_x > 0 && {!(_forEachIndex in _selectionsToIgnore)}) exitWith {_forEachIndex};
|
||||
-1
|
||||
} forEach _damageValues;
|
||||
|
||||
|
@ -21,14 +21,13 @@ params ["_engineer", "_vehicle"];
|
||||
private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
|
||||
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
|
||||
|
||||
private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore);
|
||||
private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
|
||||
|
||||
private _repairsNeeded = 0;
|
||||
private _doExtraRepair = false;
|
||||
{
|
||||
if (_x <= 0) then {continue}; // skip hitpoints that don't need repairs
|
||||
private _hitPoint = _hitPoints select _forEachIndex;
|
||||
if (_hitPoint in _hitPointsToIgnore) then { // only add extra repair for ignore hitpoints if they're damaged
|
||||
if (_forEachIndex in _selectionsToIgnore) then { // only add extra repair for ignore hitpoints if they're damaged
|
||||
_doExtraRepair = true;
|
||||
continue
|
||||
};
|
||||
|
@ -10,7 +10,7 @@
|
||||
* HitPoints to ignore <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [vehicle] call ace_repair_fnc_getHitpointsToIgnore
|
||||
* [vehicle] call ace_repair_fnc_getSelectionsToIgnore
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -18,7 +18,7 @@
|
||||
params ["_vehicle"];
|
||||
|
||||
private _type = typeOf _vehicle;
|
||||
TRACE_2("getHitPointsToIgnore",_vehicle,_type);
|
||||
TRACE_2("getSelectionsToIgnore",_vehicle,_type);
|
||||
private _initializedClasses = missionNamespace getVariable [QGVAR(hitPointsToIgnoreInitializedClasses), createHashMap];
|
||||
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
|
||||
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
|
||||
|
||||
private _hitPointsToIgnore = [""]; // always ignore empty hitpoints
|
||||
private _indexesToIgnore = [];
|
||||
private _processedSelections = [];
|
||||
|
||||
{
|
||||
@ -39,6 +39,7 @@ private _processedSelections = [];
|
||||
private _isWheelOrTrack = _selection in _wheelHitSelections || {_hitpoint in _wheelHitPoints} || {_hitpoint in TRACK_HITPOINTS};
|
||||
|
||||
if (_hitpoint isEqualTo "") then { // skip empty hitpoint
|
||||
_indexesToIgnore pushBack _forEachIndex;
|
||||
continue
|
||||
};
|
||||
|
||||
@ -47,7 +48,7 @@ private _processedSelections = [];
|
||||
/*#ifdef DEBUG_MODE_FULL
|
||||
systemChat format ["Skipping duplicate wheel, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
||||
#endif*/
|
||||
_hitPointsToIgnore pushBackUnique _hitpoint;
|
||||
_indexesToIgnore pushBack _forEachIndex;
|
||||
_processedSelections pushBack _selection;
|
||||
continue
|
||||
};
|
||||
@ -57,7 +58,7 @@ private _processedSelections = [];
|
||||
/*#ifdef DEBUG_MODE_FULL
|
||||
systemChat format ["Skipping glass, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
||||
#endif*/
|
||||
_hitPointsToIgnore pushBackUnique _hitpoint;
|
||||
_indexesToIgnore pushBack _forEachIndex;
|
||||
_processedSelections pushBack _selection;
|
||||
continue
|
||||
};
|
||||
@ -67,7 +68,7 @@ private _processedSelections = [];
|
||||
/*#ifdef DEBUG_MODE_FULL
|
||||
systemChat format ["Skipping ERA/SLAT, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
||||
#endif*/
|
||||
_hitPointsToIgnore pushBackUnique _hitpoint;
|
||||
_indexesToIgnore pushBack _forEachIndex;
|
||||
_processedSelections pushBack _selection;
|
||||
continue
|
||||
};
|
||||
@ -79,16 +80,29 @@ private _processedSelections = [];
|
||||
private _hitpointsCfg = "configName _x == _hitpoint" configClasses _turretHitpointCfg;
|
||||
if (_hitpointsCfg isNotEqualTo []) exitWith {
|
||||
TRACE_2("turret hitpoint configFound",_hitpoint,_x);
|
||||
_hitpointsCfg = _hitpointsCfg # 0;
|
||||
// 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 {
|
||||
_armorComponent = getText (_hitpointsCfg # 0 >> "armorComponent");
|
||||
if (
|
||||
(_hitpoint in ["hitturret", "hitgun"]) ||
|
||||
{(getNumber (_hitpointsCfg >> "isGun")) == 1} ||
|
||||
{(getNumber (_hitpointsCfg >> "isTurret")) == 1} ||
|
||||
{(getText (_hitpointsCfg >> "visual")) != ""}
|
||||
) then {
|
||||
_armorComponent = getText (_hitpointsCfg >> "armorComponent");
|
||||
};
|
||||
};
|
||||
} forEach _turretPaths;
|
||||
if (_armorComponent == "") then {
|
||||
private _hitpointsCfg = "configName _x == _hitpoint" configClasses (_vehCfg >> "HitPoints");
|
||||
if (_hitpointsCfg isNotEqualTo [] && {(getText (_hitpointsCfg # 0 >> "visual")) != ""}) then {
|
||||
_armorComponent = getText (_hitpointsCfg # 0 >> "armorComponent");
|
||||
if (_hitpointsCfg isNotEqualTo []) then {
|
||||
_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
|
||||
systemChat format ["Skipping no selection OR armor component, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
||||
#endif*/
|
||||
_hitPointsToIgnore pushBackUnique _hitpoint;
|
||||
_indexesToIgnore pushBack _forEachIndex;
|
||||
_processedSelections pushBack _selection;
|
||||
continue
|
||||
};
|
||||
@ -115,7 +129,7 @@ private _processedSelections = [];
|
||||
ERROR_1("group: %1",_hitpointGroups # _groupIndex);
|
||||
};
|
||||
|
||||
_hitPointsToIgnore pushBackUnique _hitpoint;
|
||||
_indexesToIgnore pushBack _forEachIndex;
|
||||
_processedSelections pushBack _selection;
|
||||
continue
|
||||
};
|
||||
@ -125,7 +139,7 @@ private _processedSelections = [];
|
||||
/*#ifdef DEBUG_MODE_FULL
|
||||
systemChat format ["Skipping child hitpoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
|
||||
#endif*/
|
||||
_hitPointsToIgnore pushBackUnique _hitpoint;
|
||||
_indexesToIgnore pushBack _forEachIndex;
|
||||
_processedSelections pushBack _selection;
|
||||
continue
|
||||
};
|
||||
@ -133,7 +147,7 @@ private _processedSelections = [];
|
||||
_processedSelections pushBack _selection;
|
||||
} forEach _hitSelections;
|
||||
|
||||
_initializedClasses set [_type, _hitPointsToIgnore];
|
||||
_initializedClasses set [_type, _indexesToIgnore];
|
||||
missionNamespace setVariable [QGVAR(hitPointsToIgnoreInitializedClasses), _initializedClasses];
|
||||
|
||||
_hitPointsToIgnore
|
||||
_indexesToIgnore
|
Loading…
Reference in New Issue
Block a user