Advertisement
Faguss

EXT_fnc_inForest

Jul 1st, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. comment {
  2. function EXT_fnc_inForest extracted from WW4_EXT by Kenoxite
  3. WW4_EXT\addons\ww4ext_scripts.pbo\lib\terrain.sqf
  4. https://forums.bohemia.net/forums/topic/145818-ww4-extended-unofficial-expansion-for-ww4-25/
  5. };
  6.  
  7.  
  8.  
  9. comment{
  10. IN FOREST
  11. Returns if the location is inside a forest.
  12. Result in forest corners, borders and between forest tiles is unreliable.
  13.  
  14. Uses measurements of vanilla forests done by Rellikki.
  15.  
  16. Parameters:
  17. - Required:
  18. * _p: position
  19.  
  20. - Optional:
  21. * _v: check for vanilla forests only. If false, glades will also be detected. Default is true
  22. * _r: radius. Default is 20
  23. * _s: step. Default is 5
  24. };
  25. EXT_fnc_inForest = {
  26. private ["_p","_f","_ss","_z","_nO","_r","_x","_y","_i","_d","_v","_s"];
  27.  
  28. _p=_this select 0;
  29. _v=if(count _this > 1)then{_this select 1}else{true};
  30. _r=if(count _this > 2)then{_this select 2}else{20};
  31. _s=if(count _this > 3)then{_this select 3}else{5};
  32.  
  33. _x=_p select 0;
  34. _y=_p select 1;
  35. _f=false;
  36. _i=_s;
  37. while {_i<_r && !_f} do {
  38. _d=0;
  39. while {_d<360 && !_f} do {
  40. _nO=nearestObject [_x+_i *sin(_d),_y+_i *cos(_d)];
  41. _z=getPos _nO select 2;
  42. _ss="logic" camcreate [_x,_y,0];
  43. if((_nO distance _ss)<=40)then{if(_v)then{if((_z >= 18.0418 && _z <= 23.1900) || (_z >= 25.8946 && _z <= 28.5844) || (_z >= 23.4063 && _z <= 24.344) || (_z >= 11.6016 && _z <= 12.7339))then{_f=true}}else{if(_z>12)then{_f=true}}};
  44. camdestroy _ss;
  45. _d=_d+30;
  46. };
  47. _i=_i+_s;
  48. };
  49. _f
  50. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement