From 5c33f7736cc9a7461e3c04fac14223dac1bdaf30 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 01:51:34 +0200 Subject: [PATCH 1/8] Added support in repair for hitpoints with non-center selections --- .../repair/functions/fnc_addRepairActions.sqf | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 3503dff3f0..5b98192cb5 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -27,17 +27,13 @@ _initializedClasses = GETMVAR(GVAR(initializedClasses),[]); // do nothing if the class is already initialized if (_type in _initializedClasses) exitWith {}; -// get all hitpoints -private "_hitPoints"; -_hitPoints = [_vehicle] call EFUNC(common,getHitPointsWithSelections) select 0; + +// get all hitpoints and selections +([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitPoints", "_hitPointsSelections"]; // get hitpoints of wheels with their selections -private ["_wheelHitPointsWithSelections", "_wheelHitPoints", "_wheelHitPointSelections"]; +([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitPointSelections"]; -_wheelHitPointsWithSelections = [_vehicle] call FUNC(getWheelHitPointsWithSelections); - -_wheelHitPoints = _wheelHitPointsWithSelections select 0; -_wheelHitPointSelections = _wheelHitPointsWithSelections select 1; // add repair events to this vehicle class { @@ -96,7 +92,7 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1; }; _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; - _selection = ""; + _selection = _vehicle selectionPosition (_hitPointsSelections select (_hitPoints find _x)); _condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)}; _statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)}; @@ -112,7 +108,11 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1; } else { private "_action"; _action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction); - [_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass); + if (_selection isEqualTo [0, 0, 0]) then { + [_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass); + } else { + [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); + } }; }; } forEach _hitPoints; From 1253d1267c248050da8c1705f6dde6e7c6a97905 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 01:54:12 +0200 Subject: [PATCH 2/8] Inlined selection check --- addons/repair/functions/fnc_addRepairActions.sqf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 5b98192cb5..78972c9334 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -108,11 +108,11 @@ if (_type in _initializedClasses) exitWith {}; } else { private "_action"; _action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction); - if (_selection isEqualTo [0, 0, 0]) then { - [_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass); - } else { - [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); - } + [ _type, + 0, + if (_selection isEqualTo [0, 0 ,0]) then { ["ACE_MainActions", QGVAR(Repair)] } else { [] }, + _action + ] call EFUNC(interact_menu,addActionToClass); }; }; } forEach _hitPoints; From 94c4c411e262d6e166a2fda3991f82048faa41b7 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 03:23:37 +0200 Subject: [PATCH 3/8] Added custom hitpoint selection framework with a starting example, removed blacklist --- addons/repair/CfgVehicles.hpp | 5 ++++ .../repair/functions/fnc_addRepairActions.sqf | 30 +++++++++++++++---- addons/repair/script_component.hpp | 4 --- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/addons/repair/CfgVehicles.hpp b/addons/repair/CfgVehicles.hpp index 7c465f50ce..35b3a6b07c 100644 --- a/addons/repair/CfgVehicles.hpp +++ b/addons/repair/CfgVehicles.hpp @@ -334,4 +334,9 @@ class CfgVehicles { GVAR(canRepair) = 1; transportRepair = 0; }; + + class Quadbike_01_base_F; + class B_Quadbike_01_F: Quadbike_01_base_F { + GVAR(hitpointPositions[]) = {"HitEngine", "0, 0.5, -0.7", "HitFuel", "0, 0, -0.5"}; + }; }; diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 78972c9334..77e21c0fab 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -71,15 +71,12 @@ if (_type in _initializedClasses) exitWith {}; [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); } else { - // exit if the hitpoint is in the blacklist, e.g. glasses - if (_x in IGNORED_HITPOINTS) exitWith {}; - // exit if the hitpoint is virtual if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {}; // add misc repair action - private ["_name", "_text", "_icon", "_selection", "_condition", "_statement"]; + private ["_name", "_text", "_icon", "_selection", "_customSelectionsCfg", "_customSelectionsIndex", "_customSelection", "_condition", "_statement"]; _name = format ["Repair_%1", _x]; @@ -92,7 +89,28 @@ if (_type in _initializedClasses) exitWith {}; }; _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; - _selection = _vehicle selectionPosition (_hitPointsSelections select (_hitPoints find _x)); + + _selection = ""; + // Get custom position if available + _customSelectionsCfg = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions); + if (isArray _customSelectionsCfg) then { + _customSelectionsCfg = getArray _customSelectionsCfg; + _customSelectionsIndex = _customSelectionsCfg find _x; + if (_customSelectionsIndex != -1) then { + _customSelection = _customSelectionsCfg select (_customSelectionsIndex + 1); + // If comma is present assume position in array, else selection name + if (_customSelection find "," != -1) then { + _selection = call compile ("[" + _customSelection + "]") + } else { + _selection = _vehicle selectionPosition _customSelection; + }; + }; + }; + // If position still empty (not a position array or selection name) try extracting from model + if (typeName _selection == "STRING" && {_selection == ""}) then { + _selection = _vehicle selectionPosition (_hitPointsSelections select (_hitPoints find _x)); + }; + _condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)}; _statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)}; @@ -110,7 +128,7 @@ if (_type in _initializedClasses) exitWith {}; _action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction); [ _type, 0, - if (_selection isEqualTo [0, 0 ,0]) then { ["ACE_MainActions", QGVAR(Repair)] } else { [] }, + if (_selection isEqualTo [0, 0 ,0]) then { ["ACE_MainActions", QGVAR(Repair)] } else { [] }, // Put inside main actions if no other position was found above _action ] call EFUNC(interact_menu,addActionToClass); }; diff --git a/addons/repair/script_component.hpp b/addons/repair/script_component.hpp index 23c52bdec8..0714b1a568 100644 --- a/addons/repair/script_component.hpp +++ b/addons/repair/script_component.hpp @@ -10,7 +10,3 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" - - -#define IGNORED_HITPOINTS ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitGlass7","HitGlass8","HitGlass9","HitGlass10","HitGlass11","HitGlass12","HitGlass13","HitGlass14","HitGlass15","HitRGlass","HitLGlass"] -// #define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"]; From 32d5ac99d9291d17d339b272a5fcd8c5c42748c3 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 17:56:34 +0200 Subject: [PATCH 4/8] Readded ignored hitpoints --- addons/repair/functions/fnc_addRepairActions.sqf | 3 +++ addons/repair/script_component.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 77e21c0fab..5f83374991 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -71,6 +71,9 @@ if (_type in _initializedClasses) exitWith {}; [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); } else { + // exit if the hitpoint is in the blacklist, e.g. glasses +- if (_x in IGNORED_HITPOINTS) exitWith {}; + // exit if the hitpoint is virtual if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {}; diff --git a/addons/repair/script_component.hpp b/addons/repair/script_component.hpp index 0714b1a568..967fc01f3d 100644 --- a/addons/repair/script_component.hpp +++ b/addons/repair/script_component.hpp @@ -10,3 +10,6 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + +#define IGNORED_HITPOINTS ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitGlass7","HitGlass8","HitGlass9","HitGlass10","HitGlass11","HitGlass12","HitGlass13","HitGlass14","HitGlass15","HitRGlass","HitLGlass"] +-// #define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"]; From 449af180c75967314bc00549242eac07bd6b8db3 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 17:58:19 +0200 Subject: [PATCH 5/8] Moved check for zero position in it's own line --- addons/repair/functions/fnc_addRepairActions.sqf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 5f83374991..04d55f50ec 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -129,11 +129,12 @@ if (_type in _initializedClasses) exitWith {}; } else { private "_action"; _action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction); - [ _type, - 0, - if (_selection isEqualTo [0, 0 ,0]) then { ["ACE_MainActions", QGVAR(Repair)] } else { [] }, // Put inside main actions if no other position was found above - _action - ] call EFUNC(interact_menu,addActionToClass); + // Put inside main actions if no other position was found above + if (_selection isEqualTo [0, 0, 0]) then { + [_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass); + } else { + [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); + }; }; }; } forEach _hitPoints; From 04da19190fb9de6703a7a73db404dbaa541b9f2f Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 18:17:56 +0200 Subject: [PATCH 6/8] Changed custom hitpoint positions config entry to 2d array --- addons/repair/CfgVehicles.hpp | 2 +- .../repair/functions/fnc_addRepairActions.sqf | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/addons/repair/CfgVehicles.hpp b/addons/repair/CfgVehicles.hpp index 35b3a6b07c..99a3588803 100644 --- a/addons/repair/CfgVehicles.hpp +++ b/addons/repair/CfgVehicles.hpp @@ -337,6 +337,6 @@ class CfgVehicles { class Quadbike_01_base_F; class B_Quadbike_01_F: Quadbike_01_base_F { - GVAR(hitpointPositions[]) = {"HitEngine", "0, 0.5, -0.7", "HitFuel", "0, 0, -0.5"}; + GVAR(hitpointPositions[]) = { {"HitEngine", {0, 0.5, -0.7}}, {"HitFuel", {0, 0, -0.5}} }; }; }; diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 04d55f50ec..8298682173 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -79,7 +79,7 @@ if (_type in _initializedClasses) exitWith {}; // add misc repair action - private ["_name", "_text", "_icon", "_selection", "_customSelectionsCfg", "_customSelectionsIndex", "_customSelection", "_condition", "_statement"]; + private ["_name", "_text", "_icon", "_selection", "_customSelectionsConfig", "_currentHitpoint", "_condition", "_statement"]; _name = format ["Repair_%1", _x]; @@ -94,21 +94,27 @@ if (_type in _initializedClasses) exitWith {}; _icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; _selection = ""; + // Get custom position if available - _customSelectionsCfg = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions); - if (isArray _customSelectionsCfg) then { - _customSelectionsCfg = getArray _customSelectionsCfg; - _customSelectionsIndex = _customSelectionsCfg find _x; - if (_customSelectionsIndex != -1) then { - _customSelection = _customSelectionsCfg select (_customSelectionsIndex + 1); - // If comma is present assume position in array, else selection name - if (_customSelection find "," != -1) then { - _selection = call compile ("[" + _customSelection + "]") - } else { - _selection = _vehicle selectionPosition _customSelection; + _customSelectionsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions); + if (isArray _customSelectionsConfig) then { + // Loop through custom hitpoint positions array + _currentHitpoint = _x; + { + _x params ["_hitpoint", "_position"]; + // Exit with supplied custom position when same hitpoint name found or print RPT error if it's invalid + if (_hitpoint == _currentHitpoint) exitWith { + if (typeName _position == "ARRAY") exitWith { + _selection = _position; // Position in model space + }; + if (typeName _position == "STRING") exitWith { + _selection = _vehicle selectionPosition _position; // Selection name + }; + diag_log text format ["[ACE] ERROR: Invalid custom position %1 of hitpoint %2 in vehicle %3", _position, _hitpoint, _vehicle]; }; - }; + } forEach (getArray _customSelectionsConfig); }; + // If position still empty (not a position array or selection name) try extracting from model if (typeName _selection == "STRING" && {_selection == ""}) then { _selection = _vehicle selectionPosition (_hitPointsSelections select (_hitPoints find _x)); From cb6efc7c9a7d4a55f25b62c48216910acae7b6d3 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 18:18:54 +0200 Subject: [PATCH 7/8] Removed copy/paste minuses --- addons/repair/functions/fnc_addRepairActions.sqf | 2 +- addons/repair/script_component.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 8298682173..0a0e35c06e 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -72,7 +72,7 @@ if (_type in _initializedClasses) exitWith {}; } else { // exit if the hitpoint is in the blacklist, e.g. glasses -- if (_x in IGNORED_HITPOINTS) exitWith {}; + if (_x in IGNORED_HITPOINTS) exitWith {}; // exit if the hitpoint is virtual if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {}; diff --git a/addons/repair/script_component.hpp b/addons/repair/script_component.hpp index 967fc01f3d..9cd33fad9e 100644 --- a/addons/repair/script_component.hpp +++ b/addons/repair/script_component.hpp @@ -12,4 +12,4 @@ #include "\z\ace\addons\main\script_macros.hpp" #define IGNORED_HITPOINTS ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitGlass7","HitGlass8","HitGlass9","HitGlass10","HitGlass11","HitGlass12","HitGlass13","HitGlass14","HitGlass15","HitRGlass","HitLGlass"] --// #define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"]; +// #define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"]; From 2c521527f4c58940372cbc2901d1f0d703e74b0a Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 18:19:25 +0200 Subject: [PATCH 8/8] Readded newline --- addons/repair/script_component.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/repair/script_component.hpp b/addons/repair/script_component.hpp index 9cd33fad9e..23c52bdec8 100644 --- a/addons/repair/script_component.hpp +++ b/addons/repair/script_component.hpp @@ -11,5 +11,6 @@ #include "\z\ace\addons\main\script_macros.hpp" + #define IGNORED_HITPOINTS ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitGlass7","HitGlass8","HitGlass9","HitGlass10","HitGlass11","HitGlass12","HitGlass13","HitGlass14","HitGlass15","HitRGlass","HitLGlass"] // #define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"];