Code cleanup

Changes to variable names for consistency, minor formatting fixes, removal of redundand comments
This commit is contained in:
Ivanowicz 2023-12-08 23:46:28 +01:00
parent b551fc1ca4
commit 773dfb58b0
13 changed files with 106 additions and 106 deletions

View File

@ -23,7 +23,7 @@ if !(hasInterface && {GVAR(enabled)}) exitWith {};
params ["_vehicle"];
private _type = typeOf _vehicle;
TRACE_2("addRepairActions", _vehicle,_type);
TRACE_2("addRepairActions",_vehicle,_type);
// do nothing if the class is already initialized
private _initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
@ -31,7 +31,7 @@ if (_type in _initializedClasses) exitWith {};
if (_type == "") exitWith {};
// get selections to ignore
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_selectionsToIgnore"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_indexesToIgnore"];
// get all hitpoints and selections
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]]; // Since 1.82 these are all lower case
@ -46,53 +46,53 @@ private _icon = ["a3\ui_f\data\igui\cfg\actions\repair_ca.paa", "#FFFFFF"];
private _vehCfg = configOf _vehicle;
// Custom position can be defined via config for associated hitpoint
private _hitpointPositions = getArray (_vehCfg >> QGVAR(hitpointPositions));
private _hitPointPositions = getArray (_vehCfg >> QGVAR(hitpointPositions));
// Get turret paths
private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehicle, "commander", true])) apply {_x # 3};
{
private _selection = _x;
private _hitpoint = toLower (_hitPoints select _forEachIndex);
private _hitPoint = toLower (_hitPoints select _forEachIndex);
// Skip ignored selections
if (_forEachIndex in _selectionsToIgnore) then {
TRACE_3("Skipping ignored hitpoint",_hitpoint,_forEachIndex,_selection);
if (_forEachIndex in _indexesToIgnore) 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);
TRACE_3("Adding Wheel Actions",_hitPoint,_forEachIndex,_selection);
// An action to replace the wheel is required
_name = format ["Replace_%1_%2", _forEachIndex, _hitpoint];
_name = format ["Replace_%1_%2", _forEachIndex, _hitPoint];
_text = localize LSTRING(ReplaceWheel);
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(repair)};
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitPoint], _position, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
// Create a wheel interaction
private _root = format ["Wheel_%1_%2", _forEachIndex, _hitpoint];
private _action = [_root, localize LSTRING(Wheel), ["","#FFFFFF"], {}, {true}, {}, [_hitpoint], _position, 2, nil, LINKFUNC(modifySelectionInteraction)] call EFUNC(interact_menu,createAction);
private _root = format ["Wheel_%1_%2", _forEachIndex, _hitPoint];
private _action = [_root, localize LSTRING(Wheel), ["","#FFFFFF"], {}, {true}, {}, [_hitPoint], _position, 2, nil, LINKFUNC(modifySelectionInteraction)] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
// An action to remove the wheel is required
private _name = format ["Remove_%1_%2", _forEachIndex, _hitpoint];
private _name = format ["Remove_%1_%2", _forEachIndex, _hitPoint];
private _text = localize LSTRING(RemoveWheel);
private _condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
private _statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
private _action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
private _action = [_name, _text, _icon, _statement, _condition, {}, [_hitPoint], _position, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [_root], _action] call EFUNC(interact_menu,addActionToClass);
// An action to patch the wheel is required.
private _name = format ["Patch_%1_%2", _forEachIndex, _hitpoint];
private _name = format ["Patch_%1_%2", _forEachIndex, _hitPoint];
private _patchIcon = QPATHTOF(ui\patch_ca.paa);
private _text = localize LSTRING(PatchWheel);
private _condition = {("vehicle" in GVAR(patchWheelLocation)) && {[_this select 1, _this select 0, _this select 2 select 0, "PatchWheel"] call DFUNC(canRepair)}};
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);
} else {
// Some hitpoints do not have a selection but do have an armorComponent value (seems to mainly be RHS)
@ -100,46 +100,46 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
// this code won't support identically named hitpoints (e.g. commander turret: Duplicate HitPoint name 'HitTurret')
private _armorComponent = "";
if (_selection == "") then {
private _hitpointsCfg = "configName _x == _hitpoint" configClasses (_vehCfg >> "HitPoints");
if (_hitpointsCfg isNotEqualTo []) then {
_armorComponent = getText (_hitpointsCfg # 0 >> "armorComponent");
private _hitPointsCfg = "configName _x == _hitPoint" configClasses (_vehCfg >> "HitPoints");
if (_hitPointsCfg isNotEqualTo []) then {
_armorComponent = getText (_hitPointsCfg # 0 >> "armorComponent");
};
if (_armorComponent == "") then {
{
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);
_armorComponent = getText (_hitpointsCfg # 0 >> "armorComponent");
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);
_armorComponent = getText (_hitPointsCfg # 0 >> "armorComponent");
};
} forEach _turretPaths;
};
if (_armorComponent != "") then { INFO_3("%1: %2 no selection: using armorComponent %3",_type,_hitpoint,_armorComponent); };
if (_armorComponent != "") then { INFO_3("%1: %2 no selection: using armorComponent %3",_type,_hitPoint,_armorComponent); };
};
// Find the action position
private _position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];
if ("rotor" in _hitpoint || "hull" in _hitpoint || "engine" in _hitpoint) then {
if ("rotor" in _hitPoint || "hull" in _hitPoint || "engine" in _hitPoint) then {
_position = compile format ["_target selectionPosition ['%1', 'HitPoints', 'AveragePoint'];", _selection];
};
{
_x params ["_hit", "_pos"];
if (_hitpoint == _hit) exitWith {
if (_hitPoint == _hit) exitWith {
if (_pos isEqualType []) exitWith {
_position = _pos; // Position in model space
};
if (_pos isEqualType "") exitWith {
_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _pos];
};
ERROR_3("Invalid custom position %1 of hitpoint %2 in vehicle %3.",_position,_hitpoint,_type);
ERROR_3("Invalid custom position %1 of hitpoint %2 in vehicle %3.",_position,_hitPoint,_type);
};
} forEach _hitpointPositions;
} forEach _hitPointPositions;
// if no selection then use the FireLOD to position the action
if ((_selection == "") && {_position isEqualTo {_target selectionPosition ['', 'HitPoints'];}}) then {
if ((_vehicle selectionPosition [_armorComponent, "FireGeometry"]) isEqualTo [0,0,0]) then {
WARNING_3("[%1: %2: %3] armorComponent does not exist?",_type,_hitpoint,_armorComponent);
WARNING_3("[%1: %2: %3] armorComponent does not exist?",_type,_hitPoint,_armorComponent);
_position = [0,0,0]; // just stick it on mainActions
} else {
_position = compile format ["_target selectionPosition ['%1', 'FireGeometry'];", _armorComponent];
@ -151,20 +151,20 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
private _name = format ["Repair_%1_%2", _forEachIndex, _selection];
// Find localized string and track those added for numerization
([_hitpoint, "%1", _hitpoint, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"];
([_hitPoint, "%1", _hitPoint, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"];
_hitPointsAddedNames = _trackArray select 0;
_hitPointsAddedStrings = _trackArray select 1;
_hitPointsAddedAmount = _trackArray select 2;
if (_hitpoint in TRACK_HITPOINTS) then {
if (_hitPoint in TRACK_HITPOINTS) then {
_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 _statement = {[_this select 1, _this select 0, _this select 2 select 0, "RepairTrack"] call DFUNC(repair)};
private _action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 4] call EFUNC(interact_menu,createAction);
private _action = [_name, _text, _icon, _statement, _condition, {}, [_hitPoint], _position, 4] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
} else {
TRACE_4("Adding MiscRepair",_hitpoint,_forEachIndex,_selection,_text);
TRACE_4("Adding MiscRepair",_hitPoint,_forEachIndex,_selection,_text);
private _condition = {[_this select 1, _this select 0, _this select 2 select 0, "MiscRepair"] call DFUNC(canRepair)};
private _statement = {[_this select 1, _this select 0, _this select 2 select 0, "MiscRepair"] call DFUNC(repair)};
private _action = [_name, _text, _icon, _statement, _condition, {}, [_forEachIndex], _position, 5] call EFUNC(interact_menu,createAction);

View File

@ -17,48 +17,49 @@
* Public: No
*/
params ["_caller", "_target", "_hitPointIndex"];
params ["_unit", "_vehicle", "_hitPointIndex"];
TRACE_3("params",_unit,_vehicle,_hitPointIndex);
(getAllHitPointsDamage _target) params ["_allHitPoints", "", "_allHitPointDamages"];
(getAllHitPointsDamage _vehicle) params ["_hitPoints", "", "_damageValues"];
if !([_caller, _target, ["isNotDragging", "isNotCarrying", "isNotSwimming", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
if !([_unit, _vehicle, ["isNotDragging", "isNotCarrying", "isNotSwimming", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Get hitpoint groups if available
private _hitpointGroupConfig = configOf _target >> QGVAR(hitpointGroups);
private _hitpointGroup = [];
if (isArray _hitpointGroupConfig) then {
private _hitPointClassname = _allHitPoints select _hitPointIndex;
private _hitPointGroupConfig = configOf _vehicle >> QGVAR(hitpointGroups);
private _hitPointGroup = [];
if (isArray _hitPointGroupConfig) then {
private _hitPointClassname = _hitPoints select _hitPointIndex;
// 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};
private _subHitPoint = _x;
private _subHitIndex = _hitPoints 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,_vehicle);
} else {
_hitpointGroup pushBack _subHitIndex;
_hitPointGroup pushBack _subHitIndex;
};
} forEach _subHitArray;
};
} forEach (getArray _hitpointGroupConfig);
} forEach (getArray _hitPointGroupConfig);
};
// Add current hitpoint to the group
_hitpointGroup pushBack _hitPointIndex;
_hitPointGroup pushBack _hitPointIndex;
// Get post repair damage
private _postRepairDamage = [_caller] call FUNC(getPostRepairDamage);
private _postRepairDamage = [_unit] call FUNC(getPostRepairDamage);
// Return true if damage can be repaired on any hitpoint in the group, else false
private _return = false;
{
if ((_allHitPointDamages select _x) > _postRepairDamage) exitWith {
if ((_damageValues select _x) > _postRepairDamage) exitWith {
_return = true;
};
} forEach _hitpointGroup;
} forEach _hitPointGroup;
_return

View File

@ -18,8 +18,8 @@
* Public: Yes
*/
params ["_caller", "_target", "_hitPoint", "_className"];
TRACE_4("params",_caller,_target,_hitPoint,_className);
params ["_unit", "_target", "_hitPoint", "_className"];
TRACE_4("params",_unit,_target,_hitPoint,_className);
private _config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
if !(isClass _config) exitWith {false}; // or go for a default?
@ -35,10 +35,10 @@ private _engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
};
0;
};
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
if !([_unit, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
private _items = _config call FUNC(getRepairItems);
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
if (count _items > 0 && {!([_unit, _items] call FUNC(hasItems))}) exitWith {false};
private _return = true;
if (getText (_config >> "condition") != "") then {
@ -51,7 +51,7 @@ if (getText (_config >> "condition") != "") then {
if (_condition isEqualType false) then {
_return = _condition;
} else {
_return = [_caller, _target, _hitPoint, _className] call _condition;
_return = [_unit, _target, _hitPoint, _className] call _condition;
};
};
@ -66,8 +66,8 @@ if (!_return) exitWith {false};
private _repairLocations = getArray (_config >> "repairLocations");
if (!("All" in _repairLocations)) then {
private _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
private _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
private _repairFacility = {([_unit] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
private _repairVeh = {([_unit] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
{
if (_x == "field") exitWith {_return = true;};
if (_x == "RepairFacility" && _repairFacility) exitWith {_return = true;};
@ -91,7 +91,7 @@ if (!_return) exitWith {false};
//Check that there are required objects nearby
private _requiredObjects = getArray (_config >> "claimObjects");
if (_requiredObjects isNotEqualTo []) then {
private _objectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
private _objectsAvailable = [_unit, 5, _requiredObjects] call FUNC(getClaimObjects);
if (_objectsAvailable isEqualTo []) then {
TRACE_2("Missing Required Objects",_requiredObjects,_objectsAvailable);
_return = false

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:
@ -26,8 +26,8 @@ private _postRepairDamageMin = [_unit, _action isEqualTo "fullRepair"] call FUNC
(getAllHitPointsDamage _vehicle) params ["_allHitPoints"];
private _hitPointClassname = _allHitPoints select _hitPointIndex;
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["","_dependsIndexMap"];
private _repairedHitpoints = [];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["", "_dependsIndexMap"];
private _repairedHitPoints = [];
// get current hitpoint damage
private _hitPointCurDamage = _vehicle getHitIndex _hitPointIndex;
@ -39,52 +39,52 @@ if (_hitPointNewDamage < _hitPointCurDamage) then {
private _parentIndex = _dependsIndexMap get _hitPointIndex;
if (isNil "_parentIndex") then {
// raise event to set the new hitpoint damage
TRACE_3("repairing main point", _vehicle, _hitPointIndex, _hitPointNewDamage);
TRACE_3("repairing main point",_vehicle,_hitPointIndex,_hitPointNewDamage);
[QGVAR(setVehicleHitPointDamage), [_vehicle, _hitPointIndex, _hitPointNewDamage], _vehicle] call CBA_fnc_targetEvent;
_hitPointCurDamage = _hitPointNewDamage;
} else {
// Fix damagable depends hitpoints with ignored parent (current hitpoint gets normalized)
private _parentHitpointCurDamage = _vehicle getHitIndex _parentIndex;
private _parentHitpointNewDamage = _parentHitpointCurDamage;
if (_parentHitpointCurDamage > _postRepairDamageMin) then {
_parentHitpointNewDamage = (_parentHitpointCurDamage - 0.5) max _postRepairDamageMin;
private _parentHitPointCurDamage = _vehicle getHitIndex _parentIndex;
private _parentHitPointNewDamage = _parentHitPointCurDamage;
if (_parentHitPointCurDamage > _postRepairDamageMin) then {
_parentHitPointNewDamage = (_parentHitPointCurDamage - 0.5) max _postRepairDamageMin;
};
_repairedHitpoints pushBack _parentIndex;
TRACE_4("Repairing depends and parent",_vehicle,_hitPointIndex,_parentIndex,_parentHitpointNewDamage);
[QGVAR(setVehicleHitPointDamage), [_vehicle, _parentIndex, _parentHitpointNewDamage], _vehicle] call CBA_fnc_targetEvent;
_hitPointCurDamage = _parentHitpointNewDamage;
_repairedHitPoints pushBack _parentIndex;
TRACE_4("Repairing depends and parent",_vehicle,_hitPointIndex,_parentIndex,_parentHitPointNewDamage);
[QGVAR(setVehicleHitPointDamage), [_vehicle, _parentIndex, _parentHitPointNewDamage], _vehicle] call CBA_fnc_targetEvent;
_hitPointCurDamage = _parentHitPointNewDamage;
};
};
// 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 {
if (_subHitIndex in _repairedHitPoints) then {
TRACE_2("Skipping repair, sub hitpoint already fixed in depends",_subHitIndex,_vehicle);
} else {
private _subPointCurDamage = _vehicle getHitIndex _hitPointIndex;
private _subPointNewDamage = (_subPointCurDamage - 0.5) max _postRepairDamageMin;
if (_subPointNewDamage < _subPointCurDamage) then {
TRACE_3("repairing sub point",_vehicle,_subHitIndex,_subPointNewDamage);
_repairedHitpoints pushBack _subHitIndex;
_repairedHitPoints pushBack _subHitIndex;
[QGVAR(setVehicleHitPointDamage), [_vehicle, _subHitIndex, _subPointNewDamage], _vehicle] call CBA_fnc_targetEvent;
};
};
};
} forEach _subHitArray;
};
} forEach (getArray _hitpointGroupConfig);
} forEach (getArray _hitPointGroupConfig);
};
// display text message if enabled

View File

@ -22,20 +22,19 @@
*/
params ["_args", "_elapsedTime", "_totalTime"];
_args params ["_engineer", "_vehicle", "", "_action"];
_args params ["_unit", "_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 > ([_engineer, _vehicle] call FUNC(getFullRepairTime)) - (GVAR(miscRepairTime) * GVAR(timeCoefficientFullRepair))) exitWith {true};
if (_totalTime - _elapsedTime > ([_unit, _vehicle] call FUNC(getFullRepairTime)) - (GVAR(miscRepairTime) * GVAR(timeCoefficientFullRepair))) exitWith {true};
private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
(getAllHitPointsDamage _vehicle) params ["", "", "_damageValues"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_selectionsToIgnore"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_indexesToIgnore"];
private _firstDamagedIndex = {
if (_x > 0 && {!(_forEachIndex in _selectionsToIgnore)}) exitWith {_forEachIndex};
if (_x > 0 && {!(_forEachIndex in _indexesToIgnore)}) exitWith {_forEachIndex};
-1
} forEach _damageValues;
@ -44,6 +43,6 @@ private _firstDamagedIndex = {
if (_firstDamagedIndex == -1) exitWith {true};
// Repair the first damaged hitpoint
[_engineer, _vehicle, _firstDamagedIndex, _action] call FUNC(doRepair);
[_unit, _vehicle, _firstDamagedIndex, _action] call FUNC(doRepair);
true

View File

@ -16,18 +16,18 @@
* Public: No
*/
params ["_engineer", "_vehicle"];
params ["_unit", "_vehicle"];
TRACE_2("params",_unit,_vehicle);
private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
(getAllHitPointsDamage _vehicle) params ["", "", "_damageValues"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_selectionsToIgnore"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_indexesToIgnore"];
private _repairsNeeded = 0;
private _doExtraRepair = false;
{
if (_x <= 0) then {continue}; // skip hitpoints that don't need repairs
if (_forEachIndex in _selectionsToIgnore) then { // only add extra repair for ignore hitpoints if they're damaged
if (_forEachIndex in _indexesToIgnore) then { // only add extra repair for ignore hitpoints if they're damaged
_doExtraRepair = true;
continue
};

View File

@ -37,7 +37,7 @@ if (_track) then {
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 ((toLower _hitPoint) find "hit" == 0) then {

View File

@ -50,7 +50,7 @@ private _wheelHitPointSelections = [];
if ((_wheelBoneNameResized != "") && {_x find _wheelBoneNameResized == 0}) exitWith { // same as above. Requirement for physx.
_wheelHitPoint = _hitPoints select _forEachIndex;
_wheelHitPointSelection = _hitPointSelections select _forEachIndex;
TRACE_2("wheel found [Orginal]", _wheelName, _wheelHitPoint);
TRACE_2("wheel found [Orginal]",_wheelName,_wheelHitPoint);
};
} forEach _hitPointSelections;
@ -83,7 +83,7 @@ private _wheelHitPointSelections = [];
if (_bestIndex != -1) then {
_wheelHitPoint = _hitPoints select _bestIndex;
_wheelHitPointSelection = _hitPointSelections select _bestIndex;
TRACE_2("wheel found [Backup]", _wheelName, _wheelHitPoint);
TRACE_2("wheel found [Backup]",_wheelName,_wheelHitPoint);
};
};
};

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

@ -51,7 +51,7 @@ if (_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

@ -47,7 +47,7 @@ if (_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 {};
if !(local _vehicle) exitWith {ERROR_1("Vehicle Not Local %1",_vehicle);};
// save array with damage values of all hitpoints
(getAllHitPointsDamage _vehicle) params [["_allHitPoints", []], ["_allHitPointsSelections", []], ["_allHitPointDamages", []]];
(getAllHitPointsDamage _vehicle) params ["", "", "_damageValues"];
// 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 _allHitPointDamages;
} forEach _damageValues;
// normalize hitpoints
[_vehicle] call FUNC(normalizeHitPoints);

View File

@ -26,9 +26,9 @@ TRACE_4("params",_vehicle,typeOf _vehicle,_hitPointIndex,_hitPointDamage);
if !(local _vehicle) exitWith {ERROR_1("Vehicle Not Local %1", _vehicle);};
// get all hitpoints and selections and damages
(getAllHitPointsDamage _vehicle) params ["", ["_hitSelections", []], ["_damageValues", []]];
(getAllHitPointsDamage _vehicle) params ["", "_hitSelections", "_damageValues"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_selectionsToIgnore", "_dependsIndexMap"];
([_vehicle] call FUNC(getSelectionsToIgnore)) params ["_indexesToIgnore", "_dependsIndexMap"];
// exit if the hitpoint is not valid
if ((_hitPointIndex < 0) || {_hitPointIndex >= (count _hitSelections)}) exitWith {ERROR_2("NOT A VALID HITPOINT: %1-%2",_hitPointIndex,_vehicle);};
@ -40,7 +40,7 @@ private _realHitPointCount = 0;
private _hitPointDamageSumOld = 0;
private _hitPointDamageRepaired = 0; //positive for repairs : newSum = (oldSum - repaired)
{
if (!(_forEachIndex in _selectionsToIgnore) && !(_forEachIndex in _dependsIndexMap)) then {
if (!(_forEachIndex in _indexesToIgnore) && !(_forEachIndex in _dependsIndexMap)) then {
_realHitPointCount = _realHitPointCount + 1;
_hitPointDamageSumOld = _hitPointDamageSumOld + (_damageValues select _forEachIndex);
if (_forEachIndex == _hitPointIndex) then {