Revert rogue changes 2

This commit is contained in:
johnb432 2024-07-23 16:31:11 +02:00
parent 94518c6418
commit b2fb679659
12 changed files with 93 additions and 83 deletions

View File

@ -31,7 +31,7 @@ if (_type in _initializedClasses) exitWith {};
if (_type == "") exitWith {};
// get selections to ignore
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_indexesToIgnore"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_selectionsToIgnore"];
// get all hitpoints and selections
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]]; // Since 1.82 these are all lower case
@ -55,7 +55,7 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
private _hitpoint = toLowerANSI (_hitPoints select _forEachIndex);
// Skip ignored selections
if (_forEachIndex in _indexesToIgnore) then {
if (_forEachIndex in _selectionsToIgnore) then {
TRACE_3("Skipping ignored hitpoint",_hitpoint,_forEachIndex,_selection);
continue
};
@ -109,7 +109,7 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
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);
TRACE_2("turret hitpoint configFound",_hitpoint,_x);
_armorComponent = getText (_hitpointsCfg # 0 >> "armorComponent");
};
} forEach _turretPaths;

View File

@ -19,13 +19,10 @@
params ["_unit", "_target"];
TRACE_2("params",_unit,_target);
private _return = false;
private _allHitPointsDamage = getAllHitPointsDamage _target;
if (_allHitPointsDamage isNotEqualTo []) then {
_return = ((_allHitPointsDamage select 2) findIf {_x > 0} != -1);
((_allHitPointsDamage select 2) findIf {_x > 0} != -1)
} else {
_return = (damage _target) > 0;
(damage _target) > 0
};
_return

View File

@ -38,7 +38,7 @@ if (isArray _hitpointGroupConfig) then {
private _subHitpoint = _x;
private _subHitIndex = _allHitPoints findIf {_x == _subHitpoint};
if (_subHitIndex == -1) then {
ERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_subHitpoint,_target)
ERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_subHitpoint,_target);
} else {
_hitpointGroup pushBack _subHitIndex;
};

View File

@ -6,7 +6,7 @@
* Arguments:
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitPointIndex <NUMBER>
* 2: Selected hitpointIndex <NUMBER>
* 3: Repair action classname <STRING>
*
* Return Value:
@ -57,18 +57,18 @@ if (_hitPointNewDamage < _hitPointCurDamage) then {
};
// Get hitpoint groups if available
private _hitPointGroupConfig = configOf _vehicle >> QGVAR(hitpointGroups);
if (isArray _hitPointGroupConfig) then {
private _hitpointGroupConfig = configOf _vehicle >> QGVAR(hitpointGroups);
if (isArray _hitpointGroupConfig) then {
// Retrieve hitpoint subgroup if current hitpoint is main hitpoint of a group
{
_x params ["_masterHitPoint", "_subHitArray"];
_x params ["_masterHitpoint", "_subHitArray"];
// Exit using found hitpoint group if this hitpoint is leader of any
if (_masterHitPoint == _hitPointClassname) exitWith {
if (_masterHitpoint == _hitPointClassname) exitWith {
{
private _subHitPoint = _x;
private _subHitIndex = _allHitPoints findIf {_x == _subHitPoint}; //convert hitpoint classname to index
private _subHitpoint = _x;
private _subHitIndex = _allHitPoints findIf {_x == _subHitpoint}; //convert hitpoint classname to index
if (_subHitIndex == -1) then {
ERROR_2("Invalid hitpoint %1 in hitPointGroups of %2",_subHitPoint,_vehicle);
ERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_subHitpoint,_vehicle);
} else {
if (_subHitIndex in _repairedHitPoints) then {
TRACE_2("Skipping repair, sub hitpoint already fixed in depends",_subHitIndex,_vehicle);
@ -84,7 +84,7 @@ if (isArray _hitPointGroupConfig) then {
};
} forEach _subHitArray;
};
} forEach (getArray _hitPointGroupConfig);
} forEach (getArray _hitpointGroupConfig);
};
// display text message if enabled

View File

@ -22,19 +22,20 @@
*/
params ["_args", "_elapsedTime", "_totalTime"];
_args params ["_unit", "_vehicle", "", "_action"];
_args params ["_engineer", "_vehicle", "", "_action"];
if !((alive _vehicle) && {(abs speed _vehicle) < 1}) exitWith {false}; // make sure vehicle doesn't drive off
// Not enough time has elapsed to repair a hitpoint
if (_totalTime - _elapsedTime > ([_unit, _vehicle] call FUNC(getFullRepairTime)) - (GVAR(miscRepairTime) * GVAR(timeCoefficientFullRepair))) exitWith {true};
if (_totalTime - _elapsedTime > ([_engineer, _vehicle] call FUNC(getFullRepairTime)) - (GVAR(miscRepairTime) * GVAR(timeCoefficientFullRepair))) exitWith {true};
(getAllHitPointsDamage _vehicle) params ["", "", "_damageValues"];
private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_indexesToIgnore"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_selectionsToIgnore"];
private _firstDamagedIndex = {
if (_x > 0 && {!(_forEachIndex in _indexesToIgnore)}) exitWith {_forEachIndex};
if (_x > 0 && {!(_forEachIndex in _selectionsToIgnore)}) exitWith {_forEachIndex};
-1
} forEach _damageValues;
@ -43,6 +44,6 @@ private _firstDamagedIndex = {
if (_firstDamagedIndex == -1) exitWith {true};
// Repair the first damaged hitpoint
[_unit, _vehicle, _firstDamagedIndex, _action] call FUNC(doRepair);
[_engineer, _vehicle, _firstDamagedIndex, _action] call FUNC(doRepair);
true

View File

@ -16,18 +16,18 @@
* Public: No
*/
params ["_unit", "_vehicle"];
TRACE_2("params",_unit,_vehicle);
params ["_engineer", "_vehicle"];
(getAllHitPointsDamage _vehicle) params ["", "", "_damageValues"];
private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_indexesToIgnore"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_selectionsToIgnore"];
private _repairsNeeded = 0;
private _doExtraRepair = false;
{
if (_x <= 0) then {continue}; // skip hitpoints that don't need repairs
if (_forEachIndex in _indexesToIgnore) 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
};

View File

@ -29,7 +29,7 @@ private _track = _trackArray isNotEqualTo [];
private _text = LSTRING(Hit);
// Remove # prefix
if ((_hitPoint select [0, 1]) == "#") then { _hitPoint = _hitPoint select [1] };
if ((_hitpoint select [0, 1]) == "#") then { _hitPoint = _hitPoint select [1] };
// Remove "Hit" from hitpoint name if one exists
private _toFind = if ((toLowerANSI _hitPoint) find "hit" == 0) then {

View File

@ -27,14 +27,11 @@ params ["_vehicle"];
private _type = typeOf _vehicle;
TRACE_2("getSelectionsToIgnore",_vehicle,_type);
private _initializedClasses = GETMVAR(GVAR(ignoredAndDependsInitializedClasses),createHashMap);
if (_type in _initializedClasses) exitWith {
TRACE_2("retrieved cached selections",_vehicle,_type);
_initializedClasses get _type;
}; //you return different amount of values each time
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 _hitpointGroups = getArray (_vehCfg >> QGVAR(hitpointGroups));
private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehicle, "commander", true])) apply {_x # 3};
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]];
@ -48,33 +45,42 @@ private _complexDependsMap = createHashMap;
{
private _selection = _x;
private _hitPoint = toLowerANSI (_hitPoints select _forEachIndex);
private _isWheelOrTrack = _selection in _wheelHitSelections || {_hitPoint in _wheelHitPoints} || {_hitPoint in TRACK_HITPOINTS};
private _hitpoint = toLowerANSI (_hitPoints select _forEachIndex);
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
};
if (_isWheelOrTrack && {_selection in _processedSelections || {_selection isEqualTo ""}}) then {
TRACE_3("Skipping duplicate Wheel/Track or empty selection",_hitPoint,_forEachIndex,_selection);
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*/
_indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection;
continue
};
if ("glass" in _hitPoint) then {
TRACE_3("Skipping glass",_hitPoint,_forEachIndex,_selection);
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*/
_indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection;
continue
};
if (_hitPoint select [0,7] isEqualTo "hitera_" || {_hitPoint select [0,4] isEqualTo "era_"}
|| {_hitPoint select [0,8] isEqualTo "hitslat_"} || {_hitPoint select [0,5] isEqualTo "slat_"}
|| {_hitPoint select [0,9] isEqualTo "sideskirt"} || {_hitPoint select [0,6] isEqualTo "armor_"}
|| {_hitPoint select [0,3] isEqualTo "mud"} || {_hitPoint select [0,9] isEqualTo "smoketube"}) then {
TRACE_3("Skipping ERA/Slat/Sideskirt/Armor/Mudguard/Smoketube HitPoint",_hitPoint,_forEachIndex,_selection);
if (_hitpoint select [0,7] isEqualTo "hitera_" || {_hitpoint select [0,4] isEqualTo "era_"} // skip era/slat
|| {_hitpoint select [0,8] isEqualTo "hitslat_"} || {_hitpoint select [0,5] isEqualTo "slat_"}
|| {_hitpoint select [0,9] isEqualTo "sideskirt"} || {_hitpoint select [0,6] isEqualTo "armor_"}
|| {_hitpoint select [0,3] isEqualTo "mud"} || {_hitpoint select [0,9] isEqualTo "smoketube"}) then {
TRACE_3("Skipping ERA/Slat/Sideskirt/Armor/Mudguard/Smoketube HitPoint",_hitpoint,_forEachIndex,_selection);
/*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping ERA/Slat/Sideskirt/Armor/Mudguard/Smoketube HitPoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
#endif*/
_indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection;
continue
@ -83,52 +89,55 @@ private _complexDependsMap = createHashMap;
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 config found",_hitPoint,_x);
_hitPointsCfg = _hitPointsCfg # 0;
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);
_hitpointsCfg = _hitpointsCfg # 0;
// only do turret hitpoints and stuff linked to visuals
if (
(_hitPoint in ["hitturret", "hitgun"]) ||
{(getNumber (_hitPointsCfg >> "isGun")) == 1} ||
{(getNumber (_hitPointsCfg >> "isTurret")) == 1} ||
{(getText (_hitPointsCfg >> "visual")) != ""}
(_hitpoint in ["hitturret", "hitgun"]) ||
{(getNumber (_hitpointsCfg >> "isGun")) == 1} ||
{(getNumber (_hitpointsCfg >> "isTurret")) == 1} ||
{(getText (_hitpointsCfg >> "visual")) != ""}
) then {
_armorComponent = getText (_hitPointsCfg >> "armorComponent");
_armorComponent = getText (_hitpointsCfg >> "armorComponent");
};
};
} forEach _turretPaths;
if (_armorComponent == "") then {
private _hitPointsCfg = "configName _x == _hitPoint" configClasses (_vehCfg >> "HitPoints");
if (_hitPointsCfg isNotEqualTo []) then {
_hitPointsCfg = _hitPointsCfg # 0;
private _hitpointsCfg = "configName _x == _hitpoint" configClasses (_vehCfg >> "HitPoints");
if (_hitpointsCfg isNotEqualTo []) then {
_hitpointsCfg = _hitpointsCfg # 0;
if (
(getNumber (_hitPointsCfg >> "isGun")) == 1 ||
{(getNumber (_hitPointsCfg >> "isTurret")) == 1} ||
{(getText (_hitPointsCfg >> "visual")) != ""}
(getNumber (_hitpointsCfg >> "isGun")) == 1 ||
{(getNumber (_hitpointsCfg >> "isTurret")) == 1} ||
{(getText (_hitpointsCfg >> "visual")) != ""}
) then {
_armorComponent = getText (_hitPointsCfg >> "armorComponent");
_armorComponent = getText (_hitpointsCfg >> "armorComponent");
};
};
};
};
if ((_selection == "") && {_armorComponent == ""}) then {
TRACE_3("Skipping no selection OR armor component",_hitPoint,_forEachIndex,_selection);
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*/
_indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection;
continue
};
if !(getText (_vehCfg >> "HitPoints" >> _hitPoint >> "depends") in ["", "0"]) then {
if !(getText (_vehCfg >> "HitPoints" >> _hitpoint >> "depends") in ["", "0"]) then {
// Caches depends hitpoints and their parents
private _parentHitPoint = getText (_vehCfg >> "HitPoints" >> _hitPoint >> "depends");
private _parentHitPoint = getText (_vehCfg >> "HitPoints" >> _hitpoint >> "depends");
private _parentHitPointIndex = _hitPoints findIf {_x == _parentHitPoint};
if (_parentHitPointIndex != -1) then {
_dependsIndexMap set [_forEachIndex, _parentHitPointIndex];
TRACE_3("Depends hitpoint and parent index",_hitPoint,_forEachIndex,_parentHitPoint);
TRACE_3("Depends hitpoint and parent index",_hitpoint,_forEachIndex,_parentHitPoint);
} else {
// Multiple/Complex parents or broken parents
_indexesToIgnore pushBack _forEachIndex;
@ -146,15 +155,15 @@ private _complexDependsMap = createHashMap;
} forEachReversed _parentHitPoints;
if (_validComplexHitPoint || _parentHitPoint == "total") then {
TRACE_3("Skipping depends and setting complex parent",_hitPoint,_forEachIndex,_parentHitPoint);
TRACE_3("Skipping depends and setting complex parent",_hitpoint,_forEachIndex,_parentHitPoint);
_complexDependsMap set [_forEachIndex, [_parentHitPoint, _parentHitPoints]];
_dependsIndexMap set [_forEachIndex, _parentHitPointIndex];
} else {
TRACE_3("Skipping depends with broken complex parent",_hitPoint,_forEachIndex,_parentHitPoint);
private _groupIndex = _hitPointGroups findIf {_x # 0 == _hitPoint};
TRACE_3("Skipping depends with broken complex parent",_hitpoint,_forEachIndex,_parentHitPoint);
private _groupIndex = _hitpointGroups findIf {_x # 0 == _hitpoint};
if (_groupIndex != -1) then {
ERROR_2("[%1] hitpoint [%2] is both a group-parent and an ignored depends and will be unrepairable",_type,_hitPoint);
ERROR_1("group: %1",_hitPointGroups # _groupIndex);
ERROR_2("[%1] hitpoint [%2] is both a group-parent and an ignored depends and will be unrepairable",_type,_hitpoint);
ERROR_1("group: %1",_hitpointGroups # _groupIndex);
};
};
};
@ -162,8 +171,11 @@ private _complexDependsMap = createHashMap;
continue
};
if (ANY_OF(_hitpointGroups,ANY_OF(_x select 1,_x == _hitpoint))) then {
TRACE_3("Skipping child hitpoint",_hitPoint,_forEachIndex,_selection);
if (ANY_OF(_hitpointGroups,ANY_OF(_x select 1,_x == _hitpoint))) then { // skip child hitpoints
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*/
_indexesToIgnore pushBack _forEachIndex;
_processedSelections pushBack _selection;
continue
@ -173,6 +185,6 @@ private _complexDependsMap = createHashMap;
} forEach _hitSelections;
_initializedClasses set [_type, [_indexesToIgnore, _dependsIndexMap, _complexDependsMap]];
SETMVAR(GVAR(ignoredAndDependsInitializedClasses),_initializedClasses);
missionNamespace setVariable [QGVAR(hitPointsToIgnoreInitializedClasses), _initializedClasses];
[_indexesToIgnore, _dependsIndexMap, _complexDependsMap]

View File

@ -107,7 +107,7 @@ if !(_return && alive _target) exitWith {false};
//Claim required objects
{
TRACE_2("Claiming",_x,typeOf _x);
TRACE_2("Claiming",_x,(typeOf _x));
[_caller, _x, false] call EFUNC(common,claim);
} forEach _claimObjectsAvailable;

View File

@ -53,7 +53,7 @@ if (!isNil "_weaponSelect") then {
//Unclaim repair objects:
{
TRACE_2("Releasing",_x,typeOf _x);
TRACE_2("Releasing",_x,(typeOf _x));
[objNull, _x, false] call EFUNC(common,claim);
} forEach _claimedObjects;

View File

@ -49,7 +49,7 @@ if (!isNil "_weaponSelect") then {
//Unclaim repair objects:
{
TRACE_2("Releasing",_x,typeOf _x);
TRACE_2("Releasing",_x,(typeOf _x));
[objNull, _x, false] call EFUNC(common,claim);
} forEach _claimedObjects;

View File

@ -21,10 +21,10 @@ params ["_vehicle", "_damage", ["_useEffects", false]];
TRACE_2("params",_vehicle,_damage);
// can't execute all commands if the vehicle isn't local. exit here.
if !(local _vehicle) exitWith {ERROR_1("Vehicle Not Local %1",_vehicle);};
if !(local _vehicle) exitWith {};
// save array with damage values of all hitpoints
(getAllHitPointsDamage _vehicle) params ["", "", ["_damageValues", []]];
(getAllHitPointsDamage _vehicle) params [["_allHitPoints", []], ["_allHitPointsSelections", []], ["_allHitPointDamages", []]];
// set damage of the vehicle
private _damageDisabled = !isDamageAllowed _vehicle;
@ -37,7 +37,7 @@ _vehicle setDamage [_damage, _useEffects];
// restore original hitpoint damage values
{
_vehicle setHitIndex [_forEachIndex, _x];
} forEach _damageValues;
} forEach _allHitPointDamages;
// normalize hitpoints
[_vehicle] call FUNC(normalizeHitPoints);