From 94c4c411e262d6e166a2fda3991f82048faa41b7 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 03:23:37 +0200 Subject: [PATCH] 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"];