From c5da32e4707bbef6254157de08a780e4af6096ae Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 4 Nov 2015 14:36:26 -0600 Subject: [PATCH 1/2] Medical Handle Damage - check hitpoints if selection is weird --- addons/medical/functions/fnc_handleDamage.sqf | 4 +-- .../functions/fnc_translateSelections.sqf | 36 ++++++++++++++++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/addons/medical/functions/fnc_handleDamage.sqf b/addons/medical/functions/fnc_handleDamage.sqf index 4174f3a0f3c..6d955e72fd4 100644 --- a/addons/medical/functions/fnc_handleDamage.sqf +++ b/addons/medical/functions/fnc_handleDamage.sqf @@ -16,7 +16,7 @@ */ #include "script_component.hpp" -params ["_unit", "_selection", "_damage", "_shooter", "_projectile"]; +params ["_unit", "_selection", "_damage", "_shooter", "_projectile", "_hitPointIndex"]; TRACE_5("ACE_DEBUG: HandleDamage Called",_unit, _selection, _damage, _shooter, _projectile); // bug, apparently can fire for remote units in special cases @@ -43,7 +43,7 @@ if (_selection == "legs") exitWith {_unit getHit "legs"}; // This will convert new selection names into selection names that the medical system understands // TODO This should be cleaned up when we revisit the medical system at a later stage // and instead we should deal with the new hitpoints directly -_selection = [_selection] call FUNC(translateSelections); +_selection = [_unit, _selection, _hitPointIndex] call FUNC(translateSelections); _this set [1, _selection]; // ensure that the parameters are set correctly // If the damage is being weird, we just tell it to fuck off. Ignore: "hands", "legs", "?" diff --git a/addons/medical/functions/fnc_translateSelections.sqf b/addons/medical/functions/fnc_translateSelections.sqf index 410005888e0..94cb5dcb288 100644 --- a/addons/medical/functions/fnc_translateSelections.sqf +++ b/addons/medical/functions/fnc_translateSelections.sqf @@ -4,29 +4,39 @@ * Aims to deal with the new hitpoint system introduced in Arma3 v1.50 and later. * * Arguments: - * 0: selection name + * 0: Unit + * 1: selection name + * 2: HitPoint Index * * Return Value: * translated selection name * * Example: - * ["pelvis"] call ace_medical_fnc_translateSelections + * [bob, "pelvis", 4] call ace_medical_fnc_translateSelections * Returns "body" * * Public: No */ +#include "script_component.hpp" #define HEAD_SELECTIONS ["face_hub", "neck", "head"] +#define HEAD_HITPOINTS ["hitface", "hitneck", "hithead"] #define TORSO_SELECTIONS ["pelvis", "spine1", "spine2", "spine3", "body"] +#define TORSO_HITPOINTS ["hitpelvis", "hitabdomen", "hitdiaphragm", "hitchest", "hitbody"] #define L_ARM_SELECTIONS ["hand_l"] +#define L_ARM_HITPOINTS ["HitLeftArm", "hand_l"] #define R_ARM_SELECTIONS ["hand_r"] +#define R_ARM_HITPOINTS ["HitRightArm", "hand_r"] #define L_LEG_SELECTIONS ["leg_l"] +#define L_LEG_HITPOINTS ["HitLeftLeg", "leg_l"] #define R_LEG_SELECTIONS ["leg_r"] +#define R_LEG_HITPOINTS ["HitRightLeg", "leg_r"] -params ["_selection"]; +params ["_unit", "_selection", "_hitPointIndex"]; -if (_selection in HEAD_SELECTIONS) exitwith {"head"}; -if (_selection in TORSO_SELECTIONS) exitwith {"body"}; +if (_selection == "") exitWith {""}; +if (_selection in HEAD_SELECTIONS) exitWith {"head"}; +if (_selection in TORSO_SELECTIONS) exitWith {"body"}; // Not necessary unless we get more hitpoints variants in an next arma update /*if (_selection in L_ARM_SELECTIONS) exitwith {"hand_l"}; @@ -34,4 +44,20 @@ if (_selection in R_ARM_SELECTIONS) exitwith {"hand_r"}; if (_selection in L_LEG_SELECTIONS) exitwith {"leg_l"}; if (_selection in R_LEG_SELECTIONS) exitwith {"leg_r"};*/ +//Backup method to detect weird selections/hitpoints +if ((_selection == "?") || {!(_selection in GVAR(SELECTIONS))}) exitWith { + if (_hitPointIndex < 0) exitWith {_selection}; + local _hitPoint = toLower configName ((configProperties [(configFile >> "CfgVehicles" >> (typeOf _unit) >> "HitPoints")]) select _hitPointIndex); + TRACE_4("Weird sel/hit", _unit, _selection, _hitPointIndex, _hitPoint); + + if (_hitPoint in HEAD_HITPOINTS) exitWith {"head"}; + if (_hitPoint in TORSO_HITPOINTS) exitWith {"body"}; + if (_hitPoint in L_ARM_HITPOINTS) exitWith {"hand_l"}; + if (_hitPoint in R_ARM_HITPOINTS) exitWith {"hand_r"}; + if (_hitPoint in L_LEG_HITPOINTS) exitWith {"leg_l"}; + if (_hitPoint in R_LEG_HITPOINTS) exitWith {"leg_r"}; + + _selection +}; + _selection; From 1cebe613fa693784151d5faaf82f608e08ca19eb Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 4 Nov 2015 14:38:32 -0600 Subject: [PATCH 2/2] Fix Capitialzation --- addons/medical/functions/fnc_translateSelections.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/medical/functions/fnc_translateSelections.sqf b/addons/medical/functions/fnc_translateSelections.sqf index 94cb5dcb288..a5f03281819 100644 --- a/addons/medical/functions/fnc_translateSelections.sqf +++ b/addons/medical/functions/fnc_translateSelections.sqf @@ -24,13 +24,13 @@ #define TORSO_SELECTIONS ["pelvis", "spine1", "spine2", "spine3", "body"] #define TORSO_HITPOINTS ["hitpelvis", "hitabdomen", "hitdiaphragm", "hitchest", "hitbody"] #define L_ARM_SELECTIONS ["hand_l"] -#define L_ARM_HITPOINTS ["HitLeftArm", "hand_l"] +#define L_ARM_HITPOINTS ["hitleftarm", "hand_l"] #define R_ARM_SELECTIONS ["hand_r"] -#define R_ARM_HITPOINTS ["HitRightArm", "hand_r"] +#define R_ARM_HITPOINTS ["hitrightarm", "hand_r"] #define L_LEG_SELECTIONS ["leg_l"] -#define L_LEG_HITPOINTS ["HitLeftLeg", "leg_l"] +#define L_LEG_HITPOINTS ["hitleftleg", "leg_l"] #define R_LEG_SELECTIONS ["leg_r"] -#define R_LEG_HITPOINTS ["HitRightLeg", "leg_r"] +#define R_LEG_HITPOINTS ["hitrightleg", "leg_r"] params ["_unit", "_selection", "_hitPointIndex"];