Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. ; ****************************************************************
  2. ; Sliding factor.
  3. ; Created by: Dead3yez
  4. ; ****************************************************************
  5.  
  6. _veh = _this select 0
  7. _handlin = _this select 1
  8.  
  9. #start
  10. ;speed and height required
  11. _h = getposatl _veh select 2
  12. _s = speed _veh
  13. if ((_h < 1) and (_s > 10))then {goto "checkveldir"}
  14. ~0.01
  15. goto "start"
  16.  
  17.  
  18. #checkveldir
  19. ; To return vector direcion: atan ( y / x )
  20. _velx = velocity _veh select 0
  21. _vely = velocity _veh select 1
  22. _velz = velocity _veh select 2
  23. _veldir = _velx atan2 _vely
  24.  
  25. ; point to correct calculation, for return value 0 - 360
  26. _vehdir = getdir _veh
  27. if ((_veldir > -180) and (_veldir < 0)) then  {goto "calc1"} else {goto "calc2"}
  28. ~0.01
  29. goto "start"
  30.  
  31. ; calculations to return value 0 - 360, not 0 - -180 or 0 - 180
  32. #calc1
  33. _velact = 360 + _veldir
  34. goto "calcdif"
  35.  
  36. #calc2
  37. _velact = _veldir
  38. goto "calcdif"
  39.  
  40.  
  41. #calcdif
  42. ; To prevent values over 360 and under 0, to calculate correct distance
  43. If (_velact < _vehdir) then {goto "difis1"}
  44. if (_velact > _vehdir) then {goto "difis2"}
  45. ~0.01
  46. goto "start"
  47.  
  48. #difis1
  49. _dif = _vehdir - _velact
  50. #difis2
  51. _dif = (360 + _velact) - _vehdir
  52.  
  53.  
  54. ; when vector angle difference to vehicle direction is greater than set value, ~75 is good value
  55. if ((_dif >= 361) and (_dif <= 450)) then {goto "changevec"}
  56. if ((_dif <= 359) and (_dif >= 270)) then {goto "changevec"}
  57. if ((_dif <= 89) and (_dif >= 0)) then {goto "changevec"}
  58.  
  59. ~0.01
  60. goto "start"
  61.  
  62.  
  63. #changevec
  64. ; hint format[" %1 \n %2 \n %3 \n %4", _veldir, _vehdir, _velact, _dif]
  65. ; change vector depending on speed, vel dir and veh dir
  66. _vx = sin _veldir
  67. _vy = cos _veldir
  68. _hx = sin _vehdir
  69. _hy = cos _vehdir
  70. _factx = _vx - _hx
  71. _facty = _vy - _hy
  72. _dec = -_s / _handlin
  73.  
  74. if (_s > 0) then {_veh setvelocity [_velx + (_factx * _dec), _vely + (_facty * _dec), _velz]}
  75. ; if (_s > 35) then {goto "flip"} (isnotfinished)
  76. ~0.01
  77. goto "start"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement