Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. @name ertex GyroPod
  2. @inputs CenterProp:entity On Eyepod:vector2 Camera:wirelink
  3. @outputs A:angle V:vector
  4. @persist E:entity A:angle VD:vector Home:vector O:entity
  5. @persist MaxTurningSpeed MaxSpeed MaxSpeedU Updaterate
  6. @trigger
  7.  
  8. #All E2ship is of the highest quality
  9. #The side is encrused with gems
  10. #Menacing spikes of ertex is along the edges
  11.  
  12. if(first()|changed(CenterProp)){
  13. E= CenterProp
  14. Home = E:pos()
  15. A=E:angles()
  16. O=owner()
  17. Updaterate=20 #ms
  18.  
  19. #speed classification stuff
  20. ShipClasses = table( #lookup tableS to set the max speed
  21. "Drone",
  22. "Fighter",
  23. "Frigate",
  24. "Cruiser",
  25. "Battlecruiser",
  26. "Battleship",
  27. "Dreadnaught",
  28. "Titan",
  29. "Station"
  30. )
  31. ShipSpeeds = table( #in units/s
  32. 10000,
  33. 8000,
  34. 3500,
  35. 2000,
  36. 1250,
  37. 1000,
  38. 500,
  39. 250,
  40. 0
  41. )
  42. ShipTurningSpeeds = table( #in degrees/s
  43. 80,
  44. 70,
  45. 40,
  46. 30,
  47. 20,
  48. 12,
  49. 8,
  50. 5,
  51. 0
  52. )
  53. Coreclass = E:isWeldedTo():getCoreEnt():getCoreClass()
  54. if(!E:isWeldedTo():getCoreEnt():isValid()){
  55. hint("place a core on this ship to make it valid",10)
  56. MaxSpeed = 100
  57. MaxSpeedU/0.04261185612
  58. MaxTurningSpeed = 80
  59. }
  60. I=0
  61. while(I<ShipSpeeds:count()){
  62. I++
  63. if(Coreclass == ShipClasses[I,string]){
  64. MaxSpeed = ShipSpeeds[I,number]*(0.04261185612)#convertion from U/s to mph, also maxspeed set
  65. MaxSpeedU = ShipSpeeds[I,number] #the max speed in units/s
  66. MaxTurningSpeed = ShipTurningSpeeds[I,number]
  67. hint(""+round(MaxSpeed)+"mph was set as maximum speed",5)
  68. hint(""+MaxTurningSpeed+" Deg/s is the fastest turning speed",5)
  69. MaxTurningSpeed = MaxTurningSpeed*(Updaterate/1000)
  70. hint(""+MaxTurningSpeed+" Deg/update is the fastest turning speed",5)
  71. }
  72. }
  73. #classification done
  74.  
  75. timer("main",Updaterate)
  76. }
  77.  
  78. runOnTick(1)
  79.  
  80.  
  81.  
  82.  
  83.  
  84. if(clk("main")){
  85. timer("main",Updaterate)
  86. #A is the angle of wich E will point
  87. #V is the vector in wich E will accelerate
  88. #note V is not set to zero after each itteration, and is transformed to VD that is
  89. #a clamped vector
  90.  
  91. A=A+ang(-clamp(Eyepod:y(),-MaxTurningSpeed,MaxTurningSpeed),-clamp(Eyepod:x(),-MaxTurningSpeed,MaxTurningSpeed),0)
  92.  
  93. if(On){
  94.  
  95. if(O:keyPressed("W")){
  96. V = V+E:forward()
  97. }
  98. if(O:keyPressed("S")){
  99. V = V-E:forward()
  100. }
  101. if(O:keyPressed("D")){
  102. V = V+E:right()
  103. }
  104. if(O:keyPressed("A")){
  105. V = V-E:right()
  106. }
  107. if(O:keyPressed("space")){
  108. V = V+E:up()
  109. }
  110. if(O:keyPressed("F")){
  111. V = V*0.95
  112. }
  113.  
  114.  
  115. E:setAng(A)
  116. VD=clamp(V,-MaxSpeedU,MaxSpeedU)
  117. E:setPos(E:pos()+VD)
  118. Camera["Position",vector] = E:pos()-owner():eye()*1000
  119. Camera["Angle",angle] = A
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement