2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
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-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-18 19:12:40 +00:00
|
|
|
#define CHECK_DISTANCE 10
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
params [["_unit", objNull, [objNull]]];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _position = eyePos _unit;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _intersections = 0;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-18 19:12:40 +00:00
|
|
|
if (lineIntersects [_position, _position vectorAdd [0, 0, +CHECK_DISTANCE]]) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_intersections = _intersections + 1;
|
|
|
|
};
|
|
|
|
|
2015-09-18 19:12:40 +00:00
|
|
|
if (lineIntersects [_position, _position vectorAdd [+CHECK_DISTANCE, 0, 0]]) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_intersections = _intersections + 1;
|
|
|
|
};
|
|
|
|
|
2015-09-18 19:12:40 +00:00
|
|
|
if (lineIntersects [_position, _position vectorAdd [-CHECK_DISTANCE, 0, 0]]) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_intersections = _intersections + 1;
|
|
|
|
};
|
|
|
|
|
2015-09-18 19:12:40 +00:00
|
|
|
if (lineIntersects [_position, _position vectorAdd [0, +CHECK_DISTANCE, 0]]) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_intersections = _intersections + 1;
|
|
|
|
};
|
|
|
|
|
2015-09-18 19:12:40 +00:00
|
|
|
if (lineIntersects [_position, _position vectorAdd [0, -CHECK_DISTANCE, 0]]) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_intersections = _intersections + 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
_intersections > 3
|