Advertisement
GMCoder

Untitled

Mar 31st, 2020
2,705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.11 KB | None | 0 0
  1. @name Motorcycle
  2. @inputs
  3. @outputs YY
  4. @persist E:entity Zpower Color:vector In A Gear Gearmul Speed F Mul YY YZ Vel:vector Driver:entity Turn Go Rpm Timer
  5. @trigger
  6.  
  7.  
  8.  
  9. if(first()) {
  10. ###color variable####
  11. Color=vec(random(255),random(255),random(255))
  12. #####################
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. #############################
  22.  
  23. E=entity():isConstrainedTo()
  24. E:setMass(200)
  25. E:setAlpha(0)
  26. entity():setAlpha(0)
  27. E:killPod()
  28.  
  29. ###check seat###
  30. if(E==noentity()) {print("Chip was not spawned on a seat, selfdestructing...")
  31.  
  32. selfDestruct()
  33. }
  34.  
  35.  
  36. #A is the angle of the seat
  37. A=14
  38.  
  39.  
  40. holoCreate(0)
  41. holoParent(0,E)
  42. holoAng(0,E:toWorld(ang(0,0,A)))
  43. holoPos(0,E:toWorld(vec(0,6,-1)))
  44.  
  45.  
  46. ######turning holo
  47. holoCreate(20)
  48. holoPos(20,holoEntity(0):toWorld(vec(0,22,10)))
  49. holoAng(20,holoEntity(0):toWorld(ang()))
  50. holoParent(20,E)
  51.  
  52. #wheels
  53.  
  54. holoCreate(1)
  55. holoCreate(2)
  56. holoScaleUnits(1,vec(27,27,30))
  57. holoScaleUnits(2,vec(27,27,30))
  58. holoAng(1,holoEntity(0):toWorld(ang(90,0,0)))
  59. holoAng(2,holoEntity(0):toWorld(ang(90,0,0)))
  60. holoPos(1,holoEntity(0):toWorld(vec(0,-28,-5)))
  61. holoPos(2,holoEntity(0):toWorld(vec(0,32,-5)))
  62. holoModel(1,"hqtorus2")
  63. holoModel(2,"hqtorus2")
  64. holoParent(1,0)
  65. holoParent(2,20)
  66. holoMaterial(1,"phoenix_storms/car_tire")
  67. holoMaterial(2,"phoenix_storms/car_tire")
  68.  
  69. #main body
  70. holoCreate(3)
  71. holoPos(3,holoEntity(0):toWorld(vec(0,2,1)))
  72. holoScale(3,vec(0.9,1.2,2))
  73. holoAng(3,holoEntity(0):toWorld(ang(0,0,-60)))
  74. holoParent(3,0)
  75.  
  76. holoCreate(4)
  77. holoPos(4,holoEntity(0):toWorld(vec(0,2,4)))
  78. holoModel(4,"hq_sphere")
  79. holoScale(4,vec(0.8,1.6,2.2))
  80. holoAng(4,holoEntity(0):toWorld(ang(0,0,-90)))
  81. holoParent(4,0)
  82.  
  83. holoCreate(5)
  84. holoPos(5,holoEntity(0):toWorld(vec(0,-18,14)))
  85. holoModel(5,"hq_sphere")
  86. holoScale(5,vec(0.85,0.7,3.3))
  87. holoAng(5,holoEntity(0):toWorld(ang(0,0,65)))
  88. holoParent(5,0)
  89.  
  90.  
  91. #handlebar
  92. holoCreate(6)
  93. holoModel(6,"hqsphere")
  94. holoPos(6,holoEntity(0):toWorld(vec(0,14,12)))
  95. holoScale(6,vec(1.2,1.2,2.2))
  96. holoAng(6,holoEntity(0):toWorld(ang(0,0,-90)))
  97. holoParent(6,0)
  98.  
  99.  
  100. #suspension
  101. holoCreate(8)
  102. holoPos(8,holoEntity(0):toWorld(vec(-6.2,-16,-2)))
  103. holoScale(8,vec(0.3,0.8,2.4))
  104. holoAng(8,holoEntity(0):toWorld(ang(0,0,-90)))
  105. holoParent(8,0)
  106.  
  107.  
  108. holoCreate(9)
  109. holoCreate(10)
  110. holoScaleUnits(9,vec(5,5,10))
  111. holoScaleUnits(10,vec(5,5,10))
  112. holoAng(9,holoEntity(0):toWorld(ang(90,0,0)))
  113. holoAng(10,holoEntity(0):toWorld(ang(90,0,0)))
  114. holoPos(9,holoEntity(0):toWorld(vec(-2,-28,-5)))
  115. holoPos(10,holoEntity(0):toWorld(vec(0,32,-5)))
  116. holoModel(9,"cylinder")
  117. holoModel(10,"cylinder")
  118. holoParent(9,0)
  119. holoParent(10,20)
  120.  
  121. holoCreate(11)
  122. holoCreate(12)
  123. holoScaleUnits(11,vec(27,27,2))
  124. holoScaleUnits(12,vec(27,27,2))
  125. holoAng(11,holoEntity(0):toWorld(ang(90,0,0)))
  126. holoAng(12,holoEntity(0):toWorld(ang(90,0,0)))
  127. holoPos(11,holoEntity(0):toWorld(vec(0,-28,-5)))
  128. holoPos(12,holoEntity(0):toWorld(vec(0,32,-5)))
  129. holoModel(11,"cylinder")
  130. holoModel(12,"cylinder")
  131. holoParent(11,0)
  132. holoParent(12,20)
  133.  
  134. holoCreate(13)
  135. holoModel(13,"hqcylinder")
  136. holoPos(13,holoEntity(0):toWorld(vec(-6.1,28.5,3.5)))
  137. holoScale(13,vec(0.25,0.4,1.8))
  138. holoAng(13,holoEntity(0):toWorld(ang(0,0,25)))
  139. holoParent(13,20)
  140.  
  141. holoCreate(14)
  142. holoModel(14,"hqcylinder")
  143. holoPos(14,holoEntity(0):toWorld(vec(6.1,28.5,3.5)))
  144. holoScale(14,vec(0.25,0.4,1.8))
  145. holoAng(14,holoEntity(0):toWorld(ang(0,0,25)))
  146. holoParent(14,20)
  147.  
  148. #handlingbar and instruments
  149. holoCreate(15)
  150. holoModel(15,"cylinder")
  151. holoPos(15,holoEntity(0):toWorld(vec(0,21,15)))
  152. holoScale(15,vec(0.9,1.1,0.2))
  153. holoAng(15,holoEntity(0):toWorld(ang(180,0,-70)))
  154. holoParent(15,E)
  155.  
  156. holoCreate(16)
  157. holoModel(16,"hqcylinder")
  158. holoPos(16,holoEntity(0):toWorld(vec(0,19,18)))
  159. holoScale(16,vec(0.45,0.2,0.45))
  160. holoAng(16,holoEntity(0):toWorld(ang(0,0,25)))
  161. holoParent(16,20)
  162.  
  163. holoCreate(17)
  164. holoModel(17,"hqcylinder")
  165. holoPos(17,holoEntity(0):toWorld(vec(5.5,16.5,19)))
  166. holoScale(17,vec(0.2,0.2,0.83))
  167. holoAng(17,holoEntity(0):toWorld(ang(90,0,25)))
  168. holoParent(17,20)
  169.  
  170. holoCreate(18)
  171. holoModel(18,"hqcylinder")
  172. holoPos(18,holoEntity(0):toWorld(vec(-5.5,16.5,19)))
  173. holoScale(18,vec(0.2,0.2,0.83))
  174. holoAng(18,holoEntity(0):toWorld(ang(90,0,-25)))
  175. holoParent(18,20)
  176.  
  177.  
  178. holoAlpha(20,0)
  179.  
  180.  
  181.  
  182.  
  183. ####colors
  184. holoColor(21,vec(30,30,30))
  185. holoColor(22,vec(255,100,0))
  186. holoMaterial(15,"phoenix_storms/mat/mat_phx_carbonfiber")
  187. holoMaterial(3,"phoenix_storms/metalbox")
  188. holoColor(4,Color)
  189. holoColor(5,Color)
  190. holoColor(6,Color)
  191. holoColor(7,Color)
  192. holoMaterial(8,"phoenix_storms/metalbox")
  193. holoMaterial(0,"phoenix_storms/metalbox")
  194. holoMaterial(13,"phoenix_storms/metalbox")
  195. holoMaterial(14,"phoenix_storms/metalbox")
  196. holoMaterial(16,"phoenix_storms/metalbox")
  197. holoMaterial(17,"phoenix_storms/car_tire")
  198. holoMaterial(18,"phoenix_storms/car_tire")
  199. holoColor(19,Color)
  200. holoColor(11,vec(10,10,10))
  201. holoColor(12,vec(10,10,10))
  202. holoMaterial(9,"phoenix_storms/metalbox")
  203. holoMaterial(10,"phoenix_storms/metalbox")
  204. holoColor(15,vec(100,100,100))
  205. }
  206. runOnTick(1)
  207. if(E:isFrozen()==0) {
  208. ######################
  209. Driver=E:driver()
  210.  
  211. #rangers
  212. rangerFilter(E)
  213. Fr=rangerOffset(999,holoEntity(2):pos()+vec(0,0,30),vec(0,0,-999))
  214. rangerFilter(E)
  215. Br=rangerOffset(999,holoEntity(1):pos()+vec(0,0,30),vec(0,0,-999))
  216. rangerFilter(E)
  217. Er=rangerOffset(999,E:pos()+vec(0,0,30),vec(0,0,-999))
  218. ####backwards ranger
  219. rangerFilter(E)
  220. Bkr=rangerOffset(350,E:pos(),-E:forward())
  221. if(Bkr:distance()<70 & Bkr:entity():isPlayer()==0) {Zpower=0} else{Zpower=1}
  222.  
  223. #positioning
  224. Pos=Er:position()+Er:hitNormal()*26+holoEntity(0):right()*-Rpm*Gearmul
  225.  
  226. #power if height is small
  227. if(Fr:distance()+Br:distance() <127) {
  228. E:applyForce(((Pos-E:pos())*7.5-E:vel())*E:mass()*vec(1,1,Zpower))
  229.  
  230. ###finding the angle over the ground
  231. Angles=ang(-14,0,0)+((Er:position()+Er:hitNormal()*26)-(Fr:position()+Fr:hitNormal()*26)):toAngle()
  232.  
  233.  
  234. }else{Angles=E:angles()-ang(0,0,YY)}
  235.  
  236.  
  237. #angle
  238. Entity = E
  239. #separeting brake and thrust
  240. Left=Driver:keyAttack1() Right=Driver:keyAttack2()
  241. #finding eye directction
  242. Eye = vec(Driver:eye():dot(E:right()),Driver:eye():dot(E:right()),0)
  243. Eye = Eye:setY(-Eye:y())*(5-E:vel():length()*0.001)
  244.  
  245.  
  246. #rpm
  247. if(Left==1) {Rpm+=(2-(Gearmul*1.6))} else{Rpm-=0.5} if(Rpm>350) {Rpm=348} if(Rpm<0) {Rpm=0}
  248. if(Right==1) {Rpm-=2}
  249. ###gears###
  250. if(Gear==0 & Left==1) {Gear+=1}
  251. if(Rpm>348 & Gear < 6) {Gear+=1 Rpm-=100} if(Gear>6) {Gear=6}
  252. if(Rpm< 150 & Gear>0 & Right==1 | Gear>0 & Rpm <40) {Gear-=1 Rpm+=50} if(Gear<0) {Gear=0}
  253. Gearmul=Gear*0.2
  254.  
  255. if(Fr:distance() >75) {YZ+=(Left-Right)*0.05 YY+=YZ } else{YY=0 YZ=0}
  256. if(YZ>3) {YZ=3}
  257. if(YZ<-3) {YZ=-3}
  258.  
  259. ##setting the angle
  260. Angle = ang(Eye:y()*-8,E:angles():yaw()+Eye:y(),Angles:pitch()+YY)
  261. Torque = Entity:toLocal(rotationVector(quat(Angle) / quat(Entity)) + Entity:pos())
  262. Entity:applyTorque((Torque*500-Entity:angVelVector()*20)*Entity:inertia())
  263.  
  264.  
  265. ##tirerolling
  266.  
  267. Vel=(entity():pos()+entity():vel():normalized()*100)
  268.  
  269.  
  270. if(Vel:distance(holoEntity(1):pos())>(Vel:distance(holoEntity(2):pos())) ) {F=-1} else{F=1}
  271.  
  272.  
  273.  
  274. if(Br:distance()<56){Speed=entity():vel():length()*0.05*F}
  275. if(Br:distance()>56& Speed>0) {Speed-=0.3}
  276. if(Br:distance()>56& Speed<0) {Speed+=0.3}
  277. Mul+=Speed
  278. Ang=holoEntity(9):toWorld(ang(0,Mul,0))
  279. holoAng(1,Ang)
  280. Ang2=holoEntity(10):toWorld(ang(0,Mul,0))
  281. holoAng(2,Ang2)
  282.  
  283. holoAng(20,holoEntity(0):toWorld(ang(0,Eye:y()*7,0)))
  284.  
  285. ####sounds
  286. if(Driver:isPlayer()==1) {Timer+=1 In+=1} else{Gear=0 Timer=0 In=0 soundStop(1)} if(Timer>200) {Timer=0}
  287. if(Timer==5) {E:soundPlay(1,0,"vehicles/airboat/fan_motor_fullthrottle_loop1.wav")}
  288. soundPitch(1,Rpm*0.6+20+(Timer*0.01))
  289.  
  290.  
  291.  
  292. ##failure consequences
  293. #rangerFilter(E)
  294. #Fail=rangerOffset(300,E:pos(),holoEntity(0):up())
  295. #if(Fail:distance()<70 & E:driver():isPlayer()==1) {E:ejectPod() Rpm=0 E:soundPlay(2,0,"physics/body/body_medium_impact_hard4.wav") }
  296. }
  297.  
  298. if(dupefinished()) {reset()}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement