ACE3/addons/common/functions/fnc_isInBuilding.sqf

47 lines
1.1 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
* 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>
*
* Example:
* [bob] call ace_common_fnc_isInBuilding
*
2015-09-18 19:12:40 +00:00
* Public: Yes
*/
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