ACE3/addons/common/functions/fnc_isInBuilding.sqf

47 lines
1.2 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
*
* Check if the unit is in a building. Will return true if the unit is sitting in a bush.
*
* Argument:
* 0: Unit (Object)
*
* Return value:
* Is the unit in a building? (Bool)
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
#define DISTANCE 10
2015-05-14 18:06:06 +00:00
private ["_position", "_positionX", "_positionY", "_positionZ", "_intersections"];
2015-05-14 18:06:06 +00:00
PARAMS_1(_unit);
_position = eyePos _unit;
_positionX = _position select 0;
_positionY = _position select 1;
_positionZ = _position select 2;
_intersections = 0;
if (lineIntersects [_position, [_positionX, _positionY, _positionZ + DISTANCE]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX + DISTANCE, _positionY, _positionZ]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX - DISTANCE, _positionY, _positionZ]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX, _positionY + DISTANCE, _positionZ]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX, _positionY - DISTANCE, _positionZ]]) then {
_intersections = _intersections + 1;
};
_intersections > 3