ACE3/addons/common/functions/fnc_isInBuilding.sqf

44 lines
1.0 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.
*
2015-09-18 19:12:40 +00:00
* Arguments:
* 0: Unit <OBJECT>
*
2016-06-18 09:50:41 +00:00
* Return Value:
2015-09-18 19:12:40 +00:00
* Is the unit in a building? <BOOL>
*
* Public: Yes
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-09-18 19:12:40 +00:00
#define CHECK_DISTANCE 10
params [["_unit", objNull, [objNull]]];
private _position = eyePos _unit;
private _intersections = 0;
2015-09-18 19:12:40 +00:00
if (lineIntersects [_position, _position vectorAdd [0, 0, +CHECK_DISTANCE]]) then {
_intersections = _intersections + 1;
};
2015-09-18 19:12:40 +00:00
if (lineIntersects [_position, _position vectorAdd [+CHECK_DISTANCE, 0, 0]]) then {
_intersections = _intersections + 1;
};
2015-09-18 19:12:40 +00:00
if (lineIntersects [_position, _position vectorAdd [-CHECK_DISTANCE, 0, 0]]) then {
_intersections = _intersections + 1;
};
2015-09-18 19:12:40 +00:00
if (lineIntersects [_position, _position vectorAdd [0, +CHECK_DISTANCE, 0]]) then {
_intersections = _intersections + 1;
};
2015-09-18 19:12:40 +00:00
if (lineIntersects [_position, _position vectorAdd [0, -CHECK_DISTANCE, 0]]) then {
_intersections = _intersections + 1;
};
_intersections > 3