Revert rogue changes 1

This commit is contained in:
johnb432 2024-07-23 16:11:07 +02:00
parent e25cb3b53d
commit 94518c6418
3 changed files with 57 additions and 58 deletions

View File

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

View File

@ -18,8 +18,8 @@
* Public: Yes
*/
params ["_unit", "_target", "_hitPoint", "_className"];
TRACE_4("params",_unit,_target,_hitPoint,_className);
params ["_caller", "_target", "_hitPoint", "_className"];
TRACE_4("params",_caller,_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 !([_unit, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
private _items = _config call FUNC(getRepairItems);
if (_items isNotEqualTo [] && {!([_unit, _items] call FUNC(hasItems))}) exitWith {false};
if (_items isNotEqualTo [] && {!([_caller, _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 = [_unit, _target, _hitPoint, _className] call _condition;
_return = [_caller, _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 = {([_unit] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
private _repairVeh = {([_unit] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
private _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
private _repairVeh = {([_caller] 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 = [_unit, 5, _requiredObjects] call FUNC(getClaimObjects);
private _objectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
if (_objectsAvailable isEqualTo []) then {
TRACE_2("Missing Required Objects",_requiredObjects,_objectsAvailable);
_return = false