From 1781629c13086f27939570a1e1a8830536093db7 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Feb 2015 00:44:11 +0100 Subject: [PATCH] Added isMedic, isMedicalVehicle, isInMedicalFacility and hasTourniquetAppliedTo functions. --- addons/medical/XEH_preInit.sqf | 4 ++ .../functions/fnc_hasTourniquetAppliedTo.sqf | 21 ++++++++ .../functions/fnc_isInMedicalFacility.sqf | 54 +++++++++++++++++++ addons/medical/functions/fnc_isMedic.sqf | 34 ++++++++++++ .../functions/fnc_isMedicalVehicle.sqf | 19 +++++++ 5 files changed, 132 insertions(+) create mode 100644 addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf create mode 100644 addons/medical/functions/fnc_isInMedicalFacility.sqf create mode 100644 addons/medical/functions/fnc_isMedic.sqf create mode 100644 addons/medical/functions/fnc_isMedicalVehicle.sqf diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 3ffe1815c7..33690a1542 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -44,6 +44,10 @@ PREP(onTreatmentCompleted); PREP(reactionToDamage); PREP(useItem); PREP(hasItem); +PREP(hasTourniquetAppliedTo); +PREP(isMedic); +PREP(isInMedicalFacility); +PREP(isMedicalVehicle); GVAR(injuredUnitCollection) = []; call FUNC(parseConfigForInjuries); diff --git a/addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf b/addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf new file mode 100644 index 0000000000..6183854e45 --- /dev/null +++ b/addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf @@ -0,0 +1,21 @@ +/* + * Author: Glowbal + * Check if unit has a tourniquet applied to the specified bodypart + * + * Arguments: + * 0: The Unit + * 1: SelectionName + * + * ReturnValue: + * Has tourniquet applied + * + * Public: Yes + */ + +#include "script_component.hpp" + +private ["_target", "_selectionName"]; +_target = _this select 0; +_selectionName = _this select 1; + +(((_target getvariable [QGVAR(tourniquets), [0,0,0,0,0,0]]) select ([_selectionName] call FUNC(selectionNameToNumber))) > 0); diff --git a/addons/medical/functions/fnc_isInMedicalFacility.sqf b/addons/medical/functions/fnc_isInMedicalFacility.sqf new file mode 100644 index 0000000000..b1521b288b --- /dev/null +++ b/addons/medical/functions/fnc_isInMedicalFacility.sqf @@ -0,0 +1,54 @@ +/* + * Author: Glowbal + * Checks if a unit is in a designated medical facility + * + * Arguments: + * 0: The Unit + * + * ReturnValue: + * Is in medical facility + * + * Public: Yes + */ + +#include "script_component.hpp" + +private ["_unit","_eyePos","_objects","_isInBuilding","_medicalFacility"]; +_unit = _this select 0; + +_eyePos = eyePos _unit; +_isInBuilding = false; + +_medicalFacility = + [ + "TK_GUE_WarfareBFieldhHospital_Base_EP1", + "TK_GUE_WarfareBFieldhHospital_EP1", + "TK_WarfareBFieldhHospital_Base_EP1", + "TK_WarfareBFieldhHospital_EP1", + "US_WarfareBFieldhHospital_Base_EP1", + "US_WarfareBFieldhHospital_EP1", + "MASH_EP1", + "MASH", + "Land_A_Hospital", + "CDF_WarfareBFieldhHospital", + "GUE_WarfareBFieldhHospital", + "INS_WarfareBFieldhHospital", + "RU_WarfareBFieldhHospital", + "USMC_WarfareBFieldhHospital" + ]; + +_objects = (lineIntersectsWith [_unit modelToWorld [0, 0, (_eyePos select 2)], _unit modelToWorld [0, 0, (_eyePos select 2) +10], _unit]); +{ + if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitwith { + _isInBuilding = true; + }; +}foreach _objects; +if (!_isInBuilding) then { + _objects = position _unit nearObjects 7.5; + { + if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitwith { + _isInBuilding = true; + }; + }foreach _objects; +}; +_isInBuilding; diff --git a/addons/medical/functions/fnc_isMedic.sqf b/addons/medical/functions/fnc_isMedic.sqf new file mode 100644 index 0000000000..d3d4b51e7e --- /dev/null +++ b/addons/medical/functions/fnc_isMedic.sqf @@ -0,0 +1,34 @@ +/* + * Author: Glowbal + * Check if a unit is any medical class + * + * Arguments: + * 0: The Unit + * 1: Class + * + * ReturnValue: + * Is in of medic class + * + * Public: Yes + */ + +#include "script_component.hpp" + +private ["_unit","_class","_return"]; +_unit = _this select 0; +_medicN = if (count _this > 1) then {_this select 1} else {1}; + +if (isnil QGVAR(setting_advancedMedicRoles)) exitwith { + true; +}; + +if (GVAR(setting_advancedMedicRoles)) then { + _class = _unit getvariable [QGVAR(medicClass), 0]; + if (_class >= _medicN) then { + _return = true; + }; +} else { + _return = true; +}; + +_return; diff --git a/addons/medical/functions/fnc_isMedicalVehicle.sqf b/addons/medical/functions/fnc_isMedicalVehicle.sqf new file mode 100644 index 0000000000..bf13c51a6a --- /dev/null +++ b/addons/medical/functions/fnc_isMedicalVehicle.sqf @@ -0,0 +1,19 @@ +/* + * Author: Glowbal + * Check if vehicle is a medical vehicle + * + * Arguments: + * 0: The Vehicle + * + * ReturnValue: + * Is in of medic class + * + * Public: Yes + */ +#include "script_component.hpp" + +private ["_veh"]; +_veh = _this select 0; + +if !(_veh getvariable [QGVAR(isMedicalVehicle), true]) exitwith {false}; // exit in case the false is set. +((getNumber(configFile >> "CfgVehicles" >> typeOf _veh >> QGVAR(isMedicalVehicle)) == 1) || (_veh getvariable [QGVAR(isMedicalVehicle), false]));