Update fn_isInsideBuilding.sqf

Adding private tags and an exithwith if the object is null. This happends a lot.
This commit is contained in:
A Man
2019-12-16 15:12:23 +01:00
parent d40c53c9d9
commit cc127c646b

View File

@@ -10,14 +10,15 @@
// - arg#1 is a boolean: check also whether arg#0 is inside (bounding box of) some non-enterable buildings around. Can be used to check if a player or an installed item is on a building roof.
// - arg#0 is posATL, arg#1 should be a building
private ["_unit","_inside","_building","_size"];
private ["_check","_unit","_inside","_building","_size","_type"];
_check = {
private ["_inside"];
private ["_building", "_point", "_inside", "_offset", "_relPos", "_boundingBox", "_min", "_max", "_myX", "_myY", "_myZ"];
_building = _this select 0;
_point = _this select 1;
_inside = false;
if (isNull _building) exitwith {_inside};
_point = _this select 1;
_offset = 1; // shrink building boundingbox by this length.
_relPos = _building worldToModel _point;
@@ -64,7 +65,7 @@ else {
if ((!_inside) AND {(count _this > 1)}) then { // if optional argument is a boolean
{
_building = _x;
_type = typeOf _x;
_type = typeOf _building;
if ((((!(_type IN DayZ_SafeObjects)) // not installable objects
AND {(!(_type isKindOf "ReammoBox"))}) // not lootpiles (weaponholders and ammoboxes)
AND {((_size + (sizeOf _type)) > _unit distance _x)}) // objects might colliding
@@ -76,4 +77,4 @@ else {
};
//diag_log ("fnc_isInsideBuilding Check: " + str(_inside)+ " last building:"+str(_building));
_inside
_inside