Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------
- overForest function by Raptorsaurus
- Checks if a position or circular area will intersect (or come close to interecting)
- a forest area
- ** This function has not been tested with non-BIS forest models. **
- The required info passed to this function is:
- - Position (either 2D [x,y] or 3D [x,y,z]
- - Radius of circular area (put 0 if just checking a single point)
- Examples:
- _overForest = [getPos player, 20] call overForest
- if the player or the region within 20 m of him is in/over a forest _overForest will be true, otherwise it will be false
- _overForest = [getMarkerPos "marker", 0] call overForest
- If the marker is in a forest _overforest will be true, otherwise it will be false
- Initialize this function by putting this in your init.sqs:
- overForest = preprocessFile "overForest.sqf"
- ---------------------------------------------------------------*/
- private ["_refpos", "_rad", "_inc", "_refobj", "_overForest", "_dis", "_radinc", "_bad"];
- private ["_radcnt","_X","_Y","_objA", "_dir", "_obj", "_x2", "_y2", "_Z", "_safepos"];
- _refpos = _this select 0;
- _rad = (_this select 1) + 36;
- _radinc = _rad / ( (_rad / 10) - ((_rad / 10) % 1) );
- _bad = ["SmokeSource","Track","Mark","ObjectDestructed","Explosion","Crater","CraterOnVehicle","Slop","Smoke","DynamicSound"];
- _X = _refpos select 0;
- _Y = _refpos select 1;
- _Z = 18;
- _overForest = false;
- _refobj = "logic" createVehicle [0,0,1000];
- _safepos = [0,0,1000];
- _objA = [];
- _radcnt = 0;
- _inc = 0;
- While {_radcnt <= _rad && ! _overForest}
- Do
- {
- if (_radcnt > 0) then {_inc = 360 / ((360 / Asin (_radinc/_radcnt)) - ((360 / Asin (_radinc/_radcnt)) % 1))};
- _dir = 0;
- While {_dir < 360 && ! _overForest}
- Do
- {
- _obj = nearestObject [(_X + (_radcnt * Sin _dir)), (_Y + (_radcnt * Cos _dir)), _Z];
- if (format ["%1",_obj] != "<NULL-object>" && ! (_obj in _objA) && ! ((typeOf _obj) in _bad))
- then
- {
- _objA = _objA + [_obj];
- _x2 = (getPos _obj) select 0;
- _y2 = (getPos _obj) select 1;
- _dis = sqrt((_X - _x2) ^2 + (_Y - _y2) ^2);
- if (_dis <= _rad)
- then
- {
- _refobj setPos (getPos _obj);
- _dis = _refobj distance _obj;
- if ((_dis > 6.8 && _dis < 6.9) || (_dis > 10.9 && _dis < 12.5) || _dis > 13) then {_overforest = true};
- _refobj setPos _safepos;
- };
- };
- if (_inc > 0) then {_dir = _dir + _inc} else {_dir = 360};
- };
- _radcnt = _radcnt + _radinc;
- };
- deleteVehicle _refobj;
- _overForest
Add Comment
Please, Sign In to add comment