Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Please do not share this script without permission from the author.
- -- Author: JBoondock
- -- Version: 1.0
- -- Patreon: www.patreon.com/JBoondock
- local requiredSpeed = 95
- local PBlink = 'http' .. 's://www.myinstants.com/media/sounds/holy-shit.mp3'
- local MackMessages = { 'MAAAACK!!!!', 'M A C K S A U C E', 'You Hesitated....', 'bRUH', 'No Shot...',
- 'Ain\'t no way you were makin that.' }
- local CloseMessages = { 'IN THAT!!!!! 3x', 'IN THERE. 3x', 'D I V E 3x', 'SKRRT!!! 3x' }
- local comboMeter = 1
- local dangerouslySlowTimer = 0
- local totalScore = 0
- local personalBest = 0
- local uiCustomPos = vec2(0, 0)
- local uiMoveMode = false
- local lastUiMoveKeyState = false
- local muteToggle = false
- local lastMuteKeyState = false
- local messageState = false
- function script.prepare(dt)
- return ac.getCarState(1).speedKmh > 60
- end
- function script.update(dt)
- local uiMoveKeyState = ac.isKeyDown(ac.KeyIndex.B)
- if uiMoveKeyState and lastUiMoveKeyState ~= uiMoveKeyState then
- uiMoveMode = not uiMoveMode
- lastUiMoveKeyState = uiMoveKeyState
- if messageState then
- addMessage('UI Move mode Disabled', -1)
- messageState = false
- else
- addMessage('UI Move mode Enabled', -1)
- messageState = true
- end
- elseif not uiMoveKeyState then
- lastUiMoveKeyState = false
- end
- if ui.mouseClicked(ui.MouseButton.Left) then
- if uiMoveMode then
- uiCustomPos = ui.mousePos()
- end
- end
- local muteKeyState = ac.isKeyDown(ac.KeyIndex.M)
- if muteKeyState and lastMuteKeyState ~= muteKeyState then
- muteToggle = not muteToggle
- if messageState then
- addMessage('Sounds off', -1)
- messageState = false
- else
- addMessage('Sounds on', -1)
- messageState = true
- end
- lastMuteKeyState = muteKeyState
- elseif not muteKeyState then
- lastMuteKeyState = false
- end
- local player = ac.getCarState(1)
- if player.engineLifeLeft < 1 then
- ac.console('Overtake score: ' .. totalScore)
- return
- end
- local comboFadingRate = 0.5 * math.lerp(1, 0.1, math.lerpInvSat(player.speedKmh, 80, 200)) + player.wheelsOutside
- comboMeter = math.max(1, comboMeter - dt * comboFadingRate)
- if player.wheelsOutside > 0 then
- dangerouslySlowTimer = dangerouslySlowTimer + dt
- if dangerouslySlowTimer > 3 then
- ac.console('Overtake score: ' .. totalScore)
- comboMeter = 1
- totalScore = 0
- dangerouslySlowTimer = 0
- addMessage('Car is Out Of Zone', -1)
- return
- elseif dangerouslySlowTimer < 3 and dt > 0 then
- addMessage('3 Seconds until score reset!', -1)
- end
- else
- dangerously
- -- local car = ac.getCarState(1)
- -- if car.pos:closerToThan(player.pos,2.5) then
- -- end
- for i = 2, ac.getSim().carsCount do
- local car = ac.getCarState(i)
- local state = carsState[i]
- -- ac.debug(car.collidedWith .. " COLLISION")
- if car.position:closerToThan(player.position, 7) then
- local drivingAlong = math.dot(car.look, player.look) > 0.2
- if not drivingAlong then
- state.drivingAlong = false
- if not state.nearMiss and car.position:closerToThan(player.position, 3) then
- state.nearMiss = true
- end
- end
- -- if car.collidedWith == 0 and not state.collided then
- -- comboMeter = 1
- -- totalScore = 0
- -- addMessage('WEINER!!!', 1)
- -- state.collided = true
- -- end
- if not state.overtaken and not state.collided and state.drivingAlong then
- local posDir = (car.position - player.position):normalize()
- local posDot = math.dot(posDir, car.look)
- state.maxPosDot = math.max(state.maxPosDot, posDot)
- if posDot < -0.5 and state.maxPosDot > 0.5 then
- totalScore = totalScore + math.ceil(10 * comboMeter)
- comboMeter = comboMeter + 1
- comboColor = comboColor + 90
- if muteToggle then
- mediaPlayer3:setSource(noti)
- mediaPlayer3:setVolume(1)
- mediaPlayer3:play()
- else
- mediaPlayer3:setSource(noti)
- mediaPlayer3:setVolume(0)
- mediaPlayer3:pause()
- end
- addMessage('Overtake 1x', comboMeter > 50 and 1 or 0)
- state.overtaken = true
- if car.position:closerToThan(player.position, 3) then
- comboMeter = comboMeter + 3
- comboColor = comboColor + math.random(1, 90)
- comboColor = comboColor + 90
- if muteToggle then
- mediaPlayer3:setSource(noti)
- mediaPlayer3:setVolume(1)
- mediaPlayer3:play()
- else
- mediaPlayer3:setSource(noti)
- mediaPlayer3:setVolume(0)
- mediaPlayer3:pause()
- end
- addMessage(CloseMessages[math.random(#CloseMessages)], 2)
- end
- end
- end
- else
- state.maxPosDot = -1
- state.overtaken = false
- state.collided = false
- state.drivingAlong = true
- state.nearMiss = false
- end
- end
- end
- local messages = {}
- function addMessage(text, mood)
- for i = math.min(#messages + 1, 4), 2, -1 do
- messages[i] = messages[i - 1]
- messages[i].targetPos = i
- end
- messages[1] = { text = text, age = 0, targetPos = 1, currentPos = 1, mood = mood }
- end
- local function updateMessages(dt)
- comboColor = comboColor + dt * 10 * comboMeter
- if comboColor > 360 then comboColor = comboColor - 360 end
- for i = 1, #messages do
- local m = messages[i]
- m.age = m.age + dt
- m.currentPos = math.applyLag(m.currentPos, m.targetPos, 0.8, dt)
- end
- if comboMeter > 10 and math.random() > 0.98 then
- for i = 1, math.floor(comboMeter) do
- local dir = vec2(math.random() - 0.5, math.random() - 0.5)
- addMessage("Combo Meter: " .. comboMeter, 1)
- end
- end
- end
- local speedWarning = 0
- local UIToggle = true
- local LastKeyState = false
- local function animateUI(uiState)
- -- Custom animation code goes here
- -- Modify and enhance this function to add cool animation effects to your UI elements
- -- For example, you can animate the position, scale, rotation, or opacity of UI elements based on time (uiState.time) or other factors.
- end
- function script.drawUI()
- local keyState = ac.isKeyDown(ac.KeyIndex.Control) and ac.isKeyDown(ac.KeyIndex.D)
- if keyState and LastKeyState ~= keyState then
- UIToggle = not UIToggle
- LastKeyState = keyState
- elseif not keyState then
- LastKeyState = false
- end
- if UIToggle then
- local uiState = ac.getUiState()
- updateMessages(uiState.dt)
- local speedRelative = math.saturate(math.floor(ac.getCarState(1).speedKmh) / requiredSpeed)
- speedWarning = math.applyLag(speedWarning, speedRelative < 1 and 1 or 0, 0.5, uiState.dt)
- local colorDark = rgbm(0.4, 0.4, 0.4, 1)
- local colorGrey = rgbm(0.7, 0.7, 0.7, 1)
- local colorAccent = rgbm.new(hsv(speedRelative * 120, 1, 1):rgb(), 1)
- local colorCombo = rgbm.new(hsv(comboColor, math.saturate(comboMeter / 10), 1):rgb(),
- math.saturate(comboMeter / 4))
- local function speedMeter(ref)
- ui.drawRectFilled(ref + vec2(0, -4), ref + vec2(180, 5), colorDark, 1)
- ui.drawLine(ref + vec2(0, -4), ref + vec2(0, 4), colorGrey, 1)
- ui.drawLine(ref + vec2(requiredSpeed, -4), ref + vec2(requiredSpeed, 4), colorGrey, 1)
- local speed = math.min(ac.getCarState(1).speedKmh, 180)
- if speed > 1 then
- ui.drawLine(ref + vec2
- true)
- ui.beginTransparentWindow('overtakeScore', vec2(uiState.windowSize.x * 0.5 - 600, 100), vec2(1400, 1400), true)
- ui.beginTransparentWindow('overtakeScore', uiCustomPos, vec2(1400, 1400), true)
- ui.beginOutline()
- ui.pushStyleColor(ui.StyleColor.Text, rgbm(0, 1, 0)) -- Set UI text color to solid green
- ui.pushStyleColor(ui.StyleColor.TextDisabled, rgbm(0, 1, 0)) -- Set UI PB color to solid green
- ui.pushFont(ui.Font.Title)
- ui.text('Shmoovin'')
- ui.popFont()
- ui.pushFont(ui.Font.Huge)
- ui.textColored('PB:' .. personalBest .. ' pts', colorCombo)
- ui.popFont()
- ui.text(totalScore .. ' pts')
- ui.sameLine(0, 40)
- ui.beginRotation()
- ui.textColored(math.ceil(comboMeter * 10) / 10 .. 'x', colorCombo)
- if comboMeter > 20 then
- ui.endRotation(math.sin(comboMeter / 180 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
- end
- if comboMeter > 50 then
- ui.endRotation(math.sin(comboMeter / 220 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
- end
- if comboMeter > 100 then
- ui.endRotation(math.sin(comboMeter / 260 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
- end
- if comboMeter > 250 then
- ui.endRotation(math.sin(comboMeter / 360 * 3141.5) * 3 * math.lerpInvSat(comboMeter, 20, 30) + 90)
- end
- ui.popFont()
- ui.endOutline(rgbm(0, 0, 0, 0.3))
- ui.offsetCursorY(20)
- ui.pushFont(ui.Font.Title)
- local startPos = ui.getCursor()
- for i = 1, #messages do
- local m = messages[i]
- local f = math.saturate(4 - m.currentPos) * math.saturate(8 - m.age)
- ui.setCursor(startPos + vec2(20 + math.saturate(1 - m.age * 10) ^ 2 * 100, (m.currentPos - 1) * 30))
- ui.textColored(m.text, m.mood == 1 and rgbm(0, 1, 0, f)
- 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))
- end
- ui.popFont()
- ui.setCursor(startPos + vec2(0, 4 * 30))
- ui.pushStyleVar(ui.StyleVar.Alpha, speedWarning)
- ui.setCursorY(0)
- ui.pushFont(ui.Font.Main)
- ui.textColored('Keep speed above ' .. requiredSpeed .. ' km/h:', colorAccent)
- speedMeter(ui.getCursor() + vec2(-9, 4))
- ui.popFont()
- ui.popStyleVar()
- ui.endTransparentWindow()
- else
- ui.text('')
- end
- calculateProximityMultiplier(distance)
- -- Calculate proximity multiplier based on distance
- local proximityMultiplier = 1.0
- if distance <= 10 then
- proximityMultiplier = 2.0
- elseif distance <= 20 then
- proximityMultiplier = 1.5
- elseif distance <= 30 then
- proximityMultiplier = 1.2
- end
- return proximityMultiplier
- end
- end
Add Comment
Please, Sign In to add comment