ACE3/addons/repair/functions/fnc_isInRepairFacility.sqf

42 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

#include "..\script_component.hpp"
/*
* Author: Glowbal
* Checks if a unit is in a repair facility.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
2015-08-15 13:49:41 +00:00
* Is inside a repair facility <BOOL>
*
* Example:
* player call ace_repair_fnc_isInRepairFacility
*
* Public: Yes
*/
#define CHECK_OBJECTS(var) ((var) findIf _checkObject != -1)
params [["_unit", objNull, [objNull]]];
TRACE_1("params",_unit);
2015-08-09 06:54:44 +00:00
private _checkObject = {
private _config = configOf _x;
private _canRepair = getNumber (_config >> QGVAR(canRepair));
if (_canRepair == 0) then {
_canRepair = getNumber (_config >> "transportRepair");
};
_x getVariable ["ACE_isRepairFacility", _canRepair > 0] in [1, true] // can be integer or boolean
&& {!(_x isKindOf "AllVehicles")} // check if it's not repair vehicle
&& {alive _x}
};
2015-08-09 06:54:44 +00:00
private _fnc_check = {
private _position = _unit modelToWorldVisual [0, 0, eyePos _unit select 2];
CHECK_OBJECTS(lineIntersectsWith [ARR_3(_position,_position vectorAdd [ARR_3(0,0,10)],_unit)])
|| {CHECK_OBJECTS(_unit nearObjects 7.5)}
};
2018-08-06 16:27:14 +00:00
[[], _fnc_check, _unit, QGVAR(inRepairFacilityCache), IN_REPAIR_FACILITY_CACHE_EXPIRY] call EFUNC(common,cachedCall);