2015-11-01 15:35:25 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Translate selection names into medical usable hit selection names.
|
|
|
|
* Aims to deal with the new hitpoint system introduced in Arma3 v1.50 and later.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-11-04 20:36:26 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: selection name <STRING>
|
2015-11-21 17:11:13 +00:00
|
|
|
* 2: HitPoint Index/True to get hitpoint <SCALAR><BOOL>
|
2015-11-01 15:35:25 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-11-21 17:11:13 +00:00
|
|
|
* translated selection/hitpoint name <STRING>
|
2015-11-01 15:35:25 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2015-11-04 20:36:26 +00:00
|
|
|
* [bob, "pelvis", 4] call ace_medical_fnc_translateSelections
|
2015-11-01 15:35:25 +00:00
|
|
|
* Returns "body"
|
|
|
|
*
|
2015-11-21 17:11:13 +00:00
|
|
|
* [bob, "body", true] call ace_medical_fnc_translateSelections
|
|
|
|
* Returns "HitBody"
|
|
|
|
*
|
2015-11-01 15:35:25 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
2015-11-04 20:36:26 +00:00
|
|
|
#include "script_component.hpp"
|
2015-11-01 15:35:25 +00:00
|
|
|
|
|
|
|
#define HEAD_SELECTIONS ["face_hub", "neck", "head"]
|
2015-11-04 20:36:26 +00:00
|
|
|
#define HEAD_HITPOINTS ["hitface", "hitneck", "hithead"]
|
2015-11-01 15:35:25 +00:00
|
|
|
#define TORSO_SELECTIONS ["pelvis", "spine1", "spine2", "spine3", "body"]
|
2015-11-04 20:36:26 +00:00
|
|
|
#define TORSO_HITPOINTS ["hitpelvis", "hitabdomen", "hitdiaphragm", "hitchest", "hitbody"]
|
2015-11-01 15:35:25 +00:00
|
|
|
#define L_ARM_SELECTIONS ["hand_l"]
|
2015-11-04 20:38:32 +00:00
|
|
|
#define L_ARM_HITPOINTS ["hitleftarm", "hand_l"]
|
2015-11-01 15:35:25 +00:00
|
|
|
#define R_ARM_SELECTIONS ["hand_r"]
|
2015-11-04 20:38:32 +00:00
|
|
|
#define R_ARM_HITPOINTS ["hitrightarm", "hand_r"]
|
2015-11-01 15:35:25 +00:00
|
|
|
#define L_LEG_SELECTIONS ["leg_l"]
|
2015-11-04 20:38:32 +00:00
|
|
|
#define L_LEG_HITPOINTS ["hitleftleg", "leg_l"]
|
2015-11-01 15:35:25 +00:00
|
|
|
#define R_LEG_SELECTIONS ["leg_r"]
|
2015-11-04 20:38:32 +00:00
|
|
|
#define R_LEG_HITPOINTS ["hitrightleg", "leg_r"]
|
2015-11-01 15:35:25 +00:00
|
|
|
|
2015-11-04 20:36:26 +00:00
|
|
|
params ["_unit", "_selection", "_hitPointIndex"];
|
2015-11-01 15:35:25 +00:00
|
|
|
|
2015-11-04 20:36:26 +00:00
|
|
|
if (_selection == "") exitWith {""};
|
2015-11-21 17:11:13 +00:00
|
|
|
|
|
|
|
//Get Selection from standard selection ["head","body","hand_l","hand_r","leg_l","leg_r"]
|
|
|
|
if (_hitPointIndex isEqualTo true) exitWith {
|
|
|
|
private _returnHitPoint = GVAR(HITPOINTS) select (GVAR(SELECTIONS) find _selection);
|
|
|
|
//If the selection is a valid hitpoint just return it:
|
|
|
|
if (!isNil {_unit getHitPointDamage _returnHitPoint}) exitWith {
|
|
|
|
_returnHitPoint;
|
|
|
|
};
|
|
|
|
|
|
|
|
//Those VR fuckers have weird limb hitpoints
|
|
|
|
private _hitPoints = switch (_selection) do {
|
|
|
|
case ("hand_l"): {L_ARM_HITPOINTS};
|
|
|
|
case ("hand_r"): {R_ARM_HITPOINTS};
|
|
|
|
case ("leg_l"): {L_LEG_HITPOINTS};
|
|
|
|
case ("leg_r"): {R_LEG_HITPOINTS};
|
|
|
|
case ("head"): {HEAD_HITPOINTS};
|
|
|
|
case ("body"): {TORSO_HITPOINTS};
|
|
|
|
default {[]};
|
|
|
|
};
|
|
|
|
{
|
|
|
|
if (!isNil {_unit getHitPointDamage _x}) exitWith {
|
|
|
|
_returnHitPoint = _x;
|
|
|
|
};
|
|
|
|
} forEach _hitPoints;
|
|
|
|
_returnHitPoint
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//Get Selection from Selection/HitIndex:
|
|
|
|
|
2015-11-04 20:36:26 +00:00
|
|
|
if (_selection in HEAD_SELECTIONS) exitWith {"head"};
|
|
|
|
if (_selection in TORSO_SELECTIONS) exitWith {"body"};
|
2015-11-01 15:35:25 +00:00
|
|
|
|
|
|
|
// Not necessary unless we get more hitpoints variants in an next arma update
|
2015-11-30 16:14:05 +00:00
|
|
|
/*if (_selection in L_ARM_SELECTIONS) exitWith {"hand_l"};
|
|
|
|
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"};*/
|
2015-11-01 15:35:25 +00:00
|
|
|
|
2015-11-04 20:36:26 +00:00
|
|
|
//Backup method to detect weird selections/hitpoints
|
|
|
|
if ((_selection == "?") || {!(_selection in GVAR(SELECTIONS))}) exitWith {
|
|
|
|
if (_hitPointIndex < 0) exitWith {_selection};
|
2015-11-17 16:43:07 +00:00
|
|
|
private _hitPoint = toLower configName ((configProperties [(configFile >> "CfgVehicles" >> (typeOf _unit) >> "HitPoints")]) select _hitPointIndex);
|
2015-11-04 20:36:26 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2015-11-01 15:35:25 +00:00
|
|
|
_selection;
|