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.
|
|
|
|
*
|
|
|
|
* 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"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
#define DISTANCE 10
|
|
|
|
|
2015-05-14 18:06:06 +00:00
|
|
|
private ["_position", "_positionX", "_positionY", "_positionZ", "_intersections"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-14 18:06:06 +00:00
|
|
|
PARAMS_1(_unit);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
_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
|