2015-02-21 23:44:11 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Checks if a unit is in a designated medical facility
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit <OBJECT>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2015-02-21 23:44:11 +00:00
|
|
|
* Is in medical facility <BOOL>
|
|
|
|
*
|
2016-01-10 05:54:48 +00:00
|
|
|
* Example:
|
|
|
|
* [player] call ace_medical_fnc_isInMedicalFacility
|
|
|
|
*
|
2015-02-21 23:44:11 +00:00
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_unit"];
|
2015-02-21 23:44:11 +00:00
|
|
|
|
2016-01-10 05:54:48 +00:00
|
|
|
//Cache the results as this function could be called rapidly
|
|
|
|
(_unit getVariable [QGVAR(cacheInFacility), [-9, false]]) params ["_expireTime", "_lastResult"];
|
2016-03-02 10:01:39 +00:00
|
|
|
if (CBA_missionTime < _expireTime) exitWith {_lastResult};
|
2016-01-10 05:54:48 +00:00
|
|
|
|
|
|
|
private _eyePos = eyePos _unit;
|
|
|
|
private _isInBuilding = false;
|
2015-02-21 23:44:11 +00:00
|
|
|
|
2016-01-10 05:54:48 +00:00
|
|
|
private _medicalFacility =
|
2015-02-21 23:44:11 +00:00
|
|
|
[
|
|
|
|
"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"
|
|
|
|
];
|
|
|
|
|
2016-01-10 05:54:48 +00:00
|
|
|
private _objects = (lineIntersectsWith [_unit modelToWorldVisual [0, 0, (_eyePos select 2)], _unit modelToWorldVisual [0, 0, (_eyePos select 2) +10], _unit]);
|
2015-02-21 23:44:11 +00:00
|
|
|
{
|
2015-11-30 16:14:05 +00:00
|
|
|
if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitWith {
|
2015-02-21 23:44:11 +00:00
|
|
|
_isInBuilding = true;
|
|
|
|
};
|
2015-11-30 16:23:48 +00:00
|
|
|
} forEach _objects;
|
2015-02-21 23:44:11 +00:00
|
|
|
if (!_isInBuilding) then {
|
2016-01-10 05:54:48 +00:00
|
|
|
_objects = _unit nearObjects 7.5;
|
2015-02-21 23:44:11 +00:00
|
|
|
{
|
2015-11-30 16:14:05 +00:00
|
|
|
if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitWith {
|
2015-02-21 23:44:11 +00:00
|
|
|
_isInBuilding = true;
|
|
|
|
};
|
2015-11-30 16:23:48 +00:00
|
|
|
} forEach _objects;
|
2015-02-21 23:44:11 +00:00
|
|
|
};
|
2016-01-10 05:54:48 +00:00
|
|
|
|
|
|
|
//Save the results (with a 1 second expiry)
|
2016-03-02 10:01:39 +00:00
|
|
|
_unit setVariable [QGVAR(cacheInFacility), [CBA_missionTime + 1, _isInBuilding]];
|
2016-01-10 05:54:48 +00:00
|
|
|
|
2015-02-21 23:44:11 +00:00
|
|
|
_isInBuilding;
|