ACE3/addons/interaction/functions/fnc_getDoor.sqf

43 lines
989 B
Plaintext
Raw Normal View History

/*
* Author: commy2
* Get door
*
* Arguments:
* 0: Distance <NUMBER>
*
* Return value:
* House objects and door <ARRAY>
* 0: House <OBJECT>
* 1: Door Name <STRING>
*
* Example:
* _array = [player, target] call ace_interaction_fnc_getDoor
*
* Public: No
*/
2015-01-11 23:13:47 +00:00
#include "script_component.hpp"
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
PARAMS_1(_distance);
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
private ["_position0", "_position1", "_intersections", "_count", "_house", "_door"];
2015-01-11 19:32:51 +00:00
_position0 = positionCameraToWorld [0, 0, 0];
_position1 = positionCameraToWorld [0, 0, _distance];
_intersections = lineIntersectsWith [ATLToASL _position0, ATLToASL _position1, objNull, objNull, true];
_count = count _intersections;
if (_count == 0) exitWith {[objNull, ""]};
_house = _intersections select (_count - 1);
// shithouse is bugged
if (typeOf _house == "") exitWith {[objNull, ""]};
_intersections = [_house, "GEOM"] intersect [_position0, _position1];
_door = _intersections select 0 select 0;
if (isNil "_door") exitWith {[_house, ""]};
2015-05-09 20:14:00 +00:00
2015-01-11 19:32:51 +00:00
[_house, _door]