mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix for unrepairable depends hitpoints
This commit is contained in:
parent
287a8d3a0e
commit
bf5c661305
@ -156,13 +156,19 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
|
|||||||
_hitPointsAddedStrings = _trackArray select 1;
|
_hitPointsAddedStrings = _trackArray select 1;
|
||||||
_hitPointsAddedAmount = _trackArray select 2;
|
_hitPointsAddedAmount = _trackArray select 2;
|
||||||
|
|
||||||
// Add name of dependant hitpoints to the parent hitpoint
|
|
||||||
{
|
{
|
||||||
|
// Add names of depends hitpoints to the parent hitpoint
|
||||||
if (_hitpoint == (_x select 0)) then {
|
if (_hitpoint == (_x select 0)) then {
|
||||||
private _dependsHitpoint = (_x select 1);
|
private _dependsHitpoint = (_x select 1);
|
||||||
([_dependsHitpoint, "%1", _dependsHitpoint, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_dependsText", ""];
|
([_dependsHitpoint, "%1", _dependsHitpoint, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_dependsText", ""];
|
||||||
_text = _text + " / " + _dependsText;
|
_text = _text + " / " + _dependsText;
|
||||||
};
|
};
|
||||||
|
// Add name of parent hitpoint to the depends hitpoint
|
||||||
|
if (_hitpoint == (_x select 1)) then {
|
||||||
|
private _dependsParentHitpoint = (_x select 0);
|
||||||
|
([_dependsParentHitpoint, "%1", _dependsParentHitpoint, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_dependsParentText", ""];
|
||||||
|
_text = _dependsParentText + " / " + _text;
|
||||||
|
};
|
||||||
} forEach _dependsArray;
|
} forEach _dependsArray;
|
||||||
|
|
||||||
if (_hitpoint in TRACK_HITPOINTS) then {
|
if (_hitpoint in TRACK_HITPOINTS) then {
|
||||||
|
@ -26,6 +26,8 @@ private _postRepairDamageMin = [_unit, _action isEqualTo "fullRepair"] call FUNC
|
|||||||
|
|
||||||
(getAllHitPointsDamage _vehicle) params ["_allHitPoints"];
|
(getAllHitPointsDamage _vehicle) params ["_allHitPoints"];
|
||||||
private _hitPointClassname = _allHitPoints select _hitPointIndex;
|
private _hitPointClassname = _allHitPoints select _hitPointIndex;
|
||||||
|
private _initializedDepends = missionNamespace getVariable [QGVAR(dependsHitPointsInitializedClasses), createHashMap];
|
||||||
|
private _repairedHitpoints = [];
|
||||||
|
|
||||||
// get current hitpoint damage
|
// get current hitpoint damage
|
||||||
private _hitPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
private _hitPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
||||||
@ -58,6 +60,7 @@ if (isArray _hitpointGroupConfig) then {
|
|||||||
private _subPointNewDamage = (_subPointCurDamage - 0.5) max _postRepairDamageMin;
|
private _subPointNewDamage = (_subPointCurDamage - 0.5) max _postRepairDamageMin;
|
||||||
if (_subPointNewDamage < _subPointCurDamage) then {
|
if (_subPointNewDamage < _subPointCurDamage) then {
|
||||||
TRACE_3("repairing sub point", _vehicle, _subHitIndex, _subPointNewDamage);
|
TRACE_3("repairing sub point", _vehicle, _subHitIndex, _subPointNewDamage);
|
||||||
|
_repairedHitpoints pushBack _subHitIndex;
|
||||||
[QGVAR(setVehicleHitPointDamage), [_vehicle, _subHitIndex, _subPointNewDamage], _vehicle] call CBA_fnc_targetEvent;
|
[QGVAR(setVehicleHitPointDamage), [_vehicle, _subHitIndex, _subPointNewDamage], _vehicle] call CBA_fnc_targetEvent;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -66,6 +69,31 @@ if (isArray _hitpointGroupConfig) then {
|
|||||||
} forEach (getArray _hitpointGroupConfig);
|
} forEach (getArray _hitpointGroupConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Fix damagable depends hitpoints with ignored parent
|
||||||
|
private _type = typeOf _vehicle;
|
||||||
|
private _vehicleDependsArray = _initializedDepends get _type;
|
||||||
|
{
|
||||||
|
_x params ["_parentHitpoint","_dependsHitpoint"];
|
||||||
|
if (_hitPointClassname == _dependsHitpoint) exitWith {
|
||||||
|
private _dependsIndex = _allHitPoints findIf {_x == _dependsHitpoint};
|
||||||
|
private _parentIndex = _allHitPoints findIf {_x == _parentHitpoint};
|
||||||
|
if (_parentIndex in _repairedHitpoints) then {
|
||||||
|
TRACE_2("Skipping repair, depends parent fixed in hitpoint groups",_parentHitpoint,_vehicle);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
private _parentHitpointCurDamage = _vehicle getHitIndex _parentIndex;
|
||||||
|
private _parentHitpointNewDamage = (_parentHitpointCurDamage - 0.5) max _postRepairDamageMin;
|
||||||
|
private _dependsHitpointCurDamage = _vehicle getHitIndex _dependsIndex;
|
||||||
|
private _dependsHitpointNewDamage = (_dependsHitpointCurDamage - 0.5) max _postRepairDamageMin;
|
||||||
|
if (_parentHitpointNewDamage < _parentHitpointCurDamage
|
||||||
|
|| _dependsHitpointNewDamage < _dependsHitpointCurDamage) then {
|
||||||
|
TRACE_4("Repairing depends parent", _vehicle, _dependsIndex, _parentIndex, _parentHitpointNewDamage);
|
||||||
|
[QGVAR(setVehicleHitPointDamage), [_vehicle, _parentIndex, _parentHitpointNewDamage], _vehicle] call CBA_fnc_targetEvent;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} forEach _vehicleDependsArray;
|
||||||
|
|
||||||
// display text message if enabled
|
// display text message if enabled
|
||||||
if (GVAR(DisplayTextOnRepair)) then {
|
if (GVAR(DisplayTextOnRepair)) then {
|
||||||
// Find localized string
|
// Find localized string
|
||||||
|
@ -136,10 +136,11 @@ private _processedSelections = [];
|
|||||||
ERROR_2("[%1] hitpoint [%2] is both a group-parent and a depends and will be unrepairable",_type,_hitpoint);
|
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);
|
ERROR_1("group: %1",_hitpointGroups # _groupIndex);
|
||||||
};
|
};
|
||||||
private _dependsParentHitpoint = [_vehCfg >> "HitPoints" >> _hitpoint, "depends"] call BIS_fnc_returnConfigEntry;
|
private _parentHitpoint = getText (_vehCfg >> "HitPoints" >> _hitpoint >> "depends");
|
||||||
|
_parentHitpoint = toLower _parentHitpoint;
|
||||||
|
_dependsArray pushBack [_parentHitpoint, _hitpoint];
|
||||||
|
|
||||||
_indexesToIgnore pushBack _forEachIndex;
|
_indexesToIgnore pushBack _forEachIndex;
|
||||||
_dependsArray pushBack [_dependsParentHitpoint, _hitpoint];
|
|
||||||
_processedSelections pushBack _selection;
|
_processedSelections pushBack _selection;
|
||||||
continue
|
continue
|
||||||
};
|
};
|
||||||
@ -157,6 +158,18 @@ private _processedSelections = [];
|
|||||||
_processedSelections pushBack _selection;
|
_processedSelections pushBack _selection;
|
||||||
} forEach _hitSelections;
|
} forEach _hitSelections;
|
||||||
|
|
||||||
|
// Remove depends hitpoints with ignored parents from ignore list
|
||||||
|
{
|
||||||
|
_x params ["_parentHitpoint", "_dependsHitpoint"];
|
||||||
|
private _parentIndex = _hitPoints findIf {_parentHitpoint == _x};
|
||||||
|
private _dependsIndex = _hitPoints findIf {_dependsHitpoint == _x};
|
||||||
|
if (_parentIndex in _indexesToIgnore) then {
|
||||||
|
TRACE_2("Removing depends hitpoint from ignored",_dependsHitpoint,_dependsIndex);
|
||||||
|
private _dependsIgnoreArrayIndex = _indexesToIgnore findIf {_dependsIndex == _x};
|
||||||
|
_indexesToIgnore deleteAt _dependsIgnoreArrayIndex;
|
||||||
|
};
|
||||||
|
} forEach _dependsArray;
|
||||||
|
|
||||||
_initializedClasses set [_type, _indexesToIgnore];
|
_initializedClasses set [_type, _indexesToIgnore];
|
||||||
missionNamespace setVariable [QGVAR(hitPointsToIgnoreInitializedClasses), _initializedClasses];
|
missionNamespace setVariable [QGVAR(hitPointsToIgnoreInitializedClasses), _initializedClasses];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user