ACE3/addons/interaction/functions/fnc_getDoor.sqf
Phyma 288f956316 Open glass and CUP doors (#5226)
* Fixed glassdoor

Fixed so glassdoor now works with ace slow open.

* Made it more pretty with new file

Made it more pretty with new file

* Tidy up a bit

* Removed white space

* Replace tabs with spaces

Replace tabs with spaces

* Simplified and added comments

* Changes + was stupid was commit

Changes to go with code guidlines and extra check if door is empty

* Tabs to spaces

* Small fixes + Fixed so CUP houses now works

Fixed so CUP houses now works

* Remove todo

* Fixed requested changes

* Removed whitespaces
2017-06-02 16:50:53 -05:00

50 lines
1.2 KiB
Plaintext

/*
* Author: commy2, Phyma
* Find door.
*
* Arguments:
* 0: Distance <NUMBER>
*
* Return Value:
* House objects and door <ARRAY>
* 0: House <OBJECT>
* 1: Door Name <STRING>
*
* Example:
* [player, target] call ace_interaction_fnc_getDoor
*
* Public: No
*/
#include "script_component.hpp"
params ["_distance"];
private ["_position0", "_position1", "_intersections", "_house", "_door"];
_position0 = positionCameraToWorld [0, 0, 0];
_position1 = positionCameraToWorld [0, 0, _distance];
_intersections = lineIntersectsSurfaces [AGLToASL _position0, AGLToASL _position1, cameraOn, objNull, true, 1, "GEOM"];
if (_intersections isEqualTo []) exitWith {[objNull, ""]};
_house = _intersections select 0 select 2;
// shithouse is bugged
if (typeOf _house == "") exitWith {[objNull, ""]};
_intersections = [_house, "GEOM"] intersect [_position0, _position1];
_door = toLower (_intersections select 0 select 0);
if (isNil "_door") exitWith {[_house, ""]};
//Check if door is glass because then we need to find the proper location of the door so we can use it
if ((_door find "glass") != -1) then {
_door = [_distance, _house, _door] call FUNC(getGlassDoor);
};
if (isNil "_door") exitWith {[_house, ""]};
[_house, _door]