From f2bda7c434a1f5375f7c7657dec3c946258c087c Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 24 Aug 2015 04:17:24 +0200 Subject: [PATCH] Added hitpoint groups framework --- addons/repair/CfgVehicles.hpp | 14 ++++++++++++-- .../repair/functions/fnc_addRepairActions.sqf | 7 +++++-- addons/repair/functions/fnc_doRepair.sqf | 18 ++++++++++++++++-- addons/repair/script_component.hpp | 4 ---- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/addons/repair/CfgVehicles.hpp b/addons/repair/CfgVehicles.hpp index 7c465f50ce..b4196dcf16 100644 --- a/addons/repair/CfgVehicles.hpp +++ b/addons/repair/CfgVehicles.hpp @@ -285,7 +285,10 @@ class CfgVehicles { transportRepair = 0; }; - class Heli_Transport_04_base_F; + class Helicopter_Base_H; + class Heli_Transport_04_base_F: Helicopter_Base_H { + GVAR(hitpointGroup[]) = {"Glass_1_hitpoint", "Glass_2_hitpoint", "Glass_3_hitpoint", "Glass_4_hitpoint", "Glass_5_hitpoint", "Glass_6_hitpoint", "Glass_7_hitpoint", "Glass_8_hitpoint", "Glass_9_hitpoint", "Glass_10_hitpoint", "Glass_11_hitpoint", "Glass_12_hitpoint", "Glass_13_hitpoint", "Glass_14_hitpoint", "Glass_15_hitpoint", "Glass_16_hitpoint", "Glass_17_hitpoint", "Glass_18_hitpoint", "Glass_19_hitpoint", "Glass_20_hitpoint"}; + }; class O_Heli_Transport_04_repair_F: Heli_Transport_04_base_F { GVAR(canRepair) = 1; transportRepair = 0; @@ -303,12 +306,19 @@ class CfgVehicles { transportRepair = 0; }; - class Offroad_01_base_F; + class Car_F; + class Offroad_01_base_F: Car_F { + GVAR(hitpointGroup[]) = {"HitGlass1", "HitGlass2"}; + }; class Offroad_01_repair_base_F: Offroad_01_base_F { GVAR(canRepair) = 1; transportRepair = 0; }; + class MRAP_01_base_F: Car_F { + GVAR(hitpointGroup[]) = {"HitGlass1", "HitGlass2", "HitGlass3", "HitGlass4", "HitGlass5", "HitGlass6"}; + }; + class B_Truck_01_mover_F; class B_Truck_01_Repair_F: B_Truck_01_mover_F { GVAR(canRepair) = 1; diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 3503dff3f0..5353986a4b 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -75,8 +75,11 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1; [_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 {}; + private "_hitpointGroup"; + // Exit if the hitpoint is in group and not main group hitpoint (which gets added as group repair action) + _hitpointGroup = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroup); + _hitpointGroup = if (isArray _hitpointGroup) then {getArray _hitpointGroup} else {[]}; + if (count _hitpointGroup > 0 && {_x in _hitpointGroup} && {_x != _hitpointGroup select 0}) exitWith {}; // exit if the hitpoint is virtual if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {}; diff --git a/addons/repair/functions/fnc_doRepair.sqf b/addons/repair/functions/fnc_doRepair.sqf index dfc21830c9..fb53f033a6 100644 --- a/addons/repair/functions/fnc_doRepair.sqf +++ b/addons/repair/functions/fnc_doRepair.sqf @@ -17,11 +17,11 @@ */ #include "script_component.hpp" +private ["_hitPointDamage", "_text", "_hitpointGroup"]; params ["_unit", "_vehicle", "_hitPoint"]; TRACE_3("params",_unit,_vehicle,_hitPoint); // get current hitpoint damage -private "_hitPointDamage"; _hitPointDamage = _vehicle getHitPointDamage _hitPoint; _hitPointDamage = _hitPointDamage - 0.5; @@ -31,9 +31,23 @@ _hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage)); // raise event to set the new hitpoint damage ["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent); +// Repair the rest in the group (don't need to worry about specific damage as it's not checked) +_hitpointGroup = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroup); +_hitpointGroup = if (isArray _hitpointGroup) then {getArray _hitpointGroup} else {[]}; +if (count _hitpointGroup > 0) then { + ([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitpoints"]; + _hitpointGroup deleteAt 0; // Remove main group hitpoint + { + if (_x in _hitpoints) then { + _vehicle setHitPointDamage [_x, 0]; + } else { + diag_log text format ["[ACE] ERROR: Invalid hitpoint %1 in hitpointGroup of %2", _x, _vehicle]; + }; + } forEach _hitpointGroup; +}; + // display text message if enabled if (GVAR(DisplayTextOnRepair)) then { - private "_text"; _text = format ["STR_ACE_Repair_%1", _hitPoint]; if (isLocalized _text) then { 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"];