supinus

score shit

Apr 6th, 2025
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.85 KB | Gaming | 0 0
  1. -- Please do not share this script without permission from the author.
  2. -- Author: JBoondock
  3. -- Version: 1.0
  4. -- Patreon: www.patreon.com/JBoondock
  5.  
  6. local requiredSpeed = 95
  7. local PBlink = 'http' .. 's://www.myinstants.com/media/sounds/holy-shit.mp3'
  8.  
  9. local MackMessages = { 'MAAAACK!!!!', 'M A C K S A U C E', 'You Hesitated....', 'bRUH', 'No Shot...',
  10. 'Ain\'t no way you were makin that.' }
  11. local CloseMessages = { 'IN THAT!!!!! 3x', 'IN THERE. 3x', 'D I V E 3x', 'SKRRT!!! 3x' }
  12.  
  13. local comboMeter = 1
  14. local dangerouslySlowTimer = 0
  15. local totalScore = 0
  16. local personalBest = 0
  17.  
  18. local uiCustomPos = vec2(0, 0)
  19. local uiMoveMode = false
  20. local lastUiMoveKeyState = false
  21.  
  22. local muteToggle = false
  23. local lastMuteKeyState = false
  24. local messageState = false
  25.  
  26. function script.prepare(dt)
  27. return ac.getCarState(1).speedKmh > 60
  28. end
  29.  
  30. function script.update(dt)
  31. local uiMoveKeyState = ac.isKeyDown(ac.KeyIndex.B)
  32. if uiMoveKeyState and lastUiMoveKeyState ~= uiMoveKeyState then
  33. uiMoveMode = not uiMoveMode
  34. lastUiMoveKeyState = uiMoveKeyState
  35. if messageState then
  36. addMessage('UI Move mode Disabled', -1)
  37. messageState = false
  38. else
  39. addMessage('UI Move mode Enabled', -1)
  40. messageState = true
  41. end
  42. elseif not uiMoveKeyState then
  43. lastUiMoveKeyState = false
  44. end
  45.  
  46. if ui.mouseClicked(ui.MouseButton.Left) then
  47. if uiMoveMode then
  48. uiCustomPos = ui.mousePos()
  49. end
  50. end
  51.  
  52. local muteKeyState = ac.isKeyDown(ac.KeyIndex.M)
  53. if muteKeyState and lastMuteKeyState ~= muteKeyState then
  54. muteToggle = not muteToggle
  55. if messageState then
  56. addMessage('Sounds off', -1)
  57. messageState = false
  58. else
  59. addMessage('Sounds on', -1)
  60. messageState = true
  61. end
  62. lastMuteKeyState = muteKeyState
  63. elseif not muteKeyState then
  64. lastMuteKeyState = false
  65. end
  66.  
  67. local player = ac.getCarState(1)
  68. if player.engineLifeLeft < 1 then
  69. ac.console('Overtake score: ' .. totalScore)
  70. return
  71. end
  72.  
  73. local comboFadingRate = 0.5 * math.lerp(1, 0.1, math.lerpInvSat(player.speedKmh, 80, 200)) + player.wheelsOutside
  74. comboMeter = math.max(1, comboMeter - dt * comboFadingRate)
  75.  
  76. if player.wheelsOutside > 0 then
  77. dangerouslySlowTimer = dangerouslySlowTimer + dt
  78. if dangerouslySlowTimer > 3 then
  79. ac.console('Overtake score: ' .. totalScore)
  80. comboMeter = 1
  81. totalScore = 0
  82. dangerouslySlowTimer = 0
  83. addMessage('Car is Out Of Zone', -1)
  84. return
  85. elseif dangerouslySlowTimer < 3 and dt > 0 then
  86. addMessage('3 Seconds until score reset!', -1)
  87. end
  88. else
  89. dangerously
  90.  
  91. -- local car = ac.getCarState(1)
  92. -- if car.pos:closerToThan(player.pos,2.5) then
  93.  
  94. -- end
  95.  
  96. for i = 2, ac.getSim().carsCount do
  97. local car = ac.getCarState(i)
  98. local state = carsState[i]
  99.  
  100.  
  101. -- ac.debug(car.collidedWith .. " COLLISION")
  102.  
  103. if car.position:closerToThan(player.position, 7) then
  104. local drivingAlong = math.dot(car.look, player.look) > 0.2
  105. if not drivingAlong then
  106. state.drivingAlong = false
  107.  
  108. if not state.nearMiss and car.position:closerToThan(player.position, 3) then
  109. state.nearMiss = true
  110.  
  111.  
  112. end
  113. end
  114.  
  115. -- if car.collidedWith == 0 and not state.collided then
  116. -- comboMeter = 1
  117. -- totalScore = 0
  118. -- addMessage('WEINER!!!', 1)
  119. -- state.collided = true
  120. -- end
  121.  
  122. if not state.overtaken and not state.collided and state.drivingAlong then
  123. local posDir = (car.position - player.position):normalize()
  124. local posDot = math.dot(posDir, car.look)
  125. state.maxPosDot = math.max(state.maxPosDot, posDot)
  126. if posDot < -0.5 and state.maxPosDot > 0.5 then
  127. totalScore = totalScore + math.ceil(10 * comboMeter)
  128. comboMeter = comboMeter + 1
  129. comboColor = comboColor + 90
  130. if muteToggle then
  131. mediaPlayer3:setSource(noti)
  132. mediaPlayer3:setVolume(1)
  133. mediaPlayer3:play()
  134. else
  135. mediaPlayer3:setSource(noti)
  136. mediaPlayer3:setVolume(0)
  137. mediaPlayer3:pause()
  138. end
  139.  
  140. addMessage('Overtake 1x', comboMeter > 50 and 1 or 0)
  141. state.overtaken = true
  142.  
  143. if car.position:closerToThan(player.position, 3) then
  144. comboMeter = comboMeter + 3
  145. comboColor = comboColor + math.random(1, 90)
  146. comboColor = comboColor + 90
  147. if muteToggle then
  148. mediaPlayer3:setSource(noti)
  149. mediaPlayer3:setVolume(1)
  150. mediaPlayer3:play()
  151. else
  152. mediaPlayer3:setSource(noti)
  153. mediaPlayer3:setVolume(0)
  154. mediaPlayer3:pause()
  155. end
  156.  
  157. addMessage(CloseMessages[math.random(#CloseMessages)], 2)
  158. end
  159.  
  160. end
  161. end
  162.  
  163. else
  164. state.maxPosDot = -1
  165. state.overtaken = false
  166. state.collided = false
  167. state.drivingAlong = true
  168. state.nearMiss = false
  169. end
  170. end
  171. end
  172. local messages = {}
  173.  
  174. function addMessage(text, mood)
  175. for i = math.min(#messages + 1, 4), 2, -1 do
  176. messages[i] = messages[i - 1]
  177. messages[i].targetPos = i
  178. end
  179. messages[1] = { text = text, age = 0, targetPos = 1, currentPos = 1, mood = mood }
  180. end
  181.  
  182. local function updateMessages(dt)
  183. comboColor = comboColor + dt * 10 * comboMeter
  184. if comboColor > 360 then comboColor = comboColor - 360 end
  185. for i = 1, #messages do
  186. local m = messages[i]
  187. m.age = m.age + dt
  188. m.currentPos = math.applyLag(m.currentPos, m.targetPos, 0.8, dt)
  189. end
  190. if comboMeter > 10 and math.random() > 0.98 then
  191. for i = 1, math.floor(comboMeter) do
  192. local dir = vec2(math.random() - 0.5, math.random() - 0.5)
  193. addMessage("Combo Meter: " .. comboMeter, 1)
  194. end
  195. end
  196. end
  197.  
  198. local speedWarning = 0
  199. local UIToggle = true
  200. local LastKeyState = false
  201.  
  202. local function animateUI(uiState)
  203. -- Custom animation code goes here
  204. -- Modify and enhance this function to add cool animation effects to your UI elements
  205. -- For example, you can animate the position, scale, rotation, or opacity of UI elements based on time (uiState.time) or other factors.
  206. end
  207.  
  208. function script.drawUI()
  209. local keyState = ac.isKeyDown(ac.KeyIndex.Control) and ac.isKeyDown(ac.KeyIndex.D)
  210. if keyState and LastKeyState ~= keyState then
  211. UIToggle = not UIToggle
  212. LastKeyState = keyState
  213. elseif not keyState then
  214. LastKeyState = false
  215. end
  216.  
  217. if UIToggle then
  218. local uiState = ac.getUiState()
  219. updateMessages(uiState.dt)
  220.  
  221. local speedRelative = math.saturate(math.floor(ac.getCarState(1).speedKmh) / requiredSpeed)
  222. speedWarning = math.applyLag(speedWarning, speedRelative < 1 and 1 or 0, 0.5, uiState.dt)
  223.  
  224. local colorDark = rgbm(0.4, 0.4, 0.4, 1)
  225. local colorGrey = rgbm(0.7, 0.7, 0.7, 1)
  226. local colorAccent = rgbm.new(hsv(speedRelative * 120, 1, 1):rgb(), 1)
  227. local colorCombo = rgbm.new(hsv(comboColor, math.saturate(comboMeter / 10), 1):rgb(),
  228. math.saturate(comboMeter / 4))
  229.  
  230. local function speedMeter(ref)
  231. ui.drawRectFilled(ref + vec2(0, -4), ref + vec2(180, 5), colorDark, 1)
  232. ui.drawLine(ref + vec2(0, -4), ref + vec2(0, 4), colorGrey, 1)
  233. ui.drawLine(ref + vec2(requiredSpeed, -4), ref + vec2(requiredSpeed, 4), colorGrey, 1)
  234.  
  235. local speed = math.min(ac.getCarState(1).speedKmh, 180)
  236. if speed > 1 then
  237. ui.drawLine(ref + vec2
  238. true)
  239. ui.beginTransparentWindow('overtakeScore', vec2(uiState.windowSize.x * 0.5 - 600, 100), vec2(1400, 1400), true)
  240. ui.beginTransparentWindow('overtakeScore', uiCustomPos, vec2(1400, 1400), true)
  241. ui.beginOutline()
  242.  
  243. ui.pushStyleColor(ui.StyleColor.Text, rgbm(0, 1, 0)) -- Set UI text color to solid green
  244. ui.pushStyleColor(ui.StyleColor.TextDisabled, rgbm(0, 1, 0)) -- Set UI PB color to solid green
  245.  
  246. ui.pushFont(ui.Font.Title)
  247. ui.text('Shmoovin'')
  248. ui.popFont()
  249.  
  250. ui.pushFont(ui.Font.Huge)
  251. ui.textColored('PB:' .. personalBest .. ' pts', colorCombo)
  252. ui.popFont()
  253.  
  254. ui.text(totalScore .. ' pts')
  255. ui.sameLine(0, 40)
  256. ui.beginRotation()
  257. ui.textColored(math.ceil(comboMeter * 10) / 10 .. 'x', colorCombo)
  258. if comboMeter > 20 then
  259. ui.endRotation(math.sin(comboMeter / 180 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
  260. end
  261. if comboMeter > 50 then
  262. ui.endRotation(math.sin(comboMeter / 220 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
  263. end
  264. if comboMeter > 100 then
  265. ui.endRotation(math.sin(comboMeter / 260 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
  266. end
  267. if comboMeter > 250 then
  268. ui.endRotation(math.sin(comboMeter / 360 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
  269. end
  270.  
  271. ui.popFont()
  272. ui.endOutline(rgbm(0, 0, 0, 0.3))
  273.  
  274. ui.offsetCursorY(20)
  275. ui.pushFont(ui.Font.Title)
  276. local startPos = ui.getCursor()
  277. for i = 1, #messages do
  278. local m = messages[i]
  279. local f = math.saturate(4 - m.currentPos) * math.saturate(8 - m.age)
  280. ui.setCursor(startPos + vec2(20 + math.saturate(1 - m.age * 10) ^ 2 * 100, (m.currentPos - 1) * 30))
  281. ui.textColored(m.text, m.mood == 1 and rgbm(0, 1, 0, f)
  282. or m.mood == -1 and rgbm(1, 0, 0, f) or m.mood == 2 and rgbm(100, 84, 0, f) or rgbm(1, 1, 1, f))
  283. end
  284. ui.popFont()
  285. ui.setCursor(startPos + vec2(0, 4 * 30))
  286.  
  287. ui.pushStyleVar(ui.StyleVar.Alpha, speedWarning)
  288. ui.setCursorY(0)
  289. ui.pushFont(ui.Font.Main)
  290. ui.textColored('Keep speed above ' .. requiredSpeed .. ' km/h:', colorAccent)
  291. speedMeter(ui.getCursor() + vec2(-9, 4))
  292. ui.popFont()
  293. ui.popStyleVar()
  294.  
  295. ui.endTransparentWindow()
  296. else
  297. ui.text('')
  298. end
  299.  
  300. calculateProximityMultiplier(distance)
  301. -- Calculate proximity multiplier based on distance
  302. local proximityMultiplier = 1.0
  303. if distance <= 10 then
  304. proximityMultiplier = 2.0
  305. elseif distance <= 20 then
  306. proximityMultiplier = 1.5
  307. elseif distance <= 30 then
  308. proximityMultiplier = 1.2
  309. end
  310. return proximityMultiplier
  311. end
  312.  
  313.  
  314. end
Tags: score
Add Comment
Please, Sign In to add comment