--!strict local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local StarterPlayer = game:GetService("StarterPlayer") local Mobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript) local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) local round = ReplicatedStorage:WaitForChild("ArenaRound") local hopUsed = Instance.new("RemoteEvent") hopUsed.Name = "JumpRuneUsed" hopUsed.Parent = round type Pad = { model: Model, frame: CFrame, halfWidth: number, halfLength: number, forward: Vector3, searchRadius: number, } type Boost = {character: Model, humanoid: Humanoid, untilTime: number} type JumpPad = {origin: BasePart, mode: string} local pads: {[string]: {[Instance]: Pad}} = {[Modes.Procedural] = {}} local jumpOrigins: {[Instance]: JumpPad} = {} local lastHop: {[Player]: number} = {} local boosts: {[Player]: Boost} = {} local standing: {[Player]: Pad} = {} local horizontalMask = Vector3.new(1, 0, 1) local stopWatching = Mobility.watchRunes(function(model, mode) if not model:IsA("Model") or not model.PrimaryPart then return end local kind = model:GetAttribute("Kind") if kind == "Jump" then jumpOrigins[model] = {origin = model.PrimaryPart, mode = mode} return end if kind ~= "Boost" then return end local frame = model.PrimaryPart.CFrame local halfWidth = (model:GetAttribute("HalfWidth") :: number?) or 4.8 local halfLength = (model:GetAttribute("HalfLength") :: number?) or 4.8 pads[mode][model] = { model = model, frame = frame, halfWidth = halfWidth, halfLength = halfLength, forward = (frame.LookVector * horizontalMask).Unit, searchRadius = math.sqrt(halfWidth ^ 2 + halfLength ^ 2) + 6, } end, function(model, mode) pads[mode][model] = nil jumpOrigins[model] = nil end) local function baseSpeed(): number return (workspace:GetAttribute("HunterWalkSpeed") :: number?) or StarterPlayer.CharacterWalkSpeed end local function clearBoost(player: Player) local boost = boosts[player] if not boost then return end boosts[player] = nil boost.character:SetAttribute("ArenaBoostUntil", nil) if boost.humanoid.Parent and boost.humanoid.Health > 0 then boost.humanoid.WalkSpeed = baseSpeed() * Mobility.walkMultiplier(boost.character, workspace:GetServerTimeNow()) end end local function contains(pad: Pad, x: number, z: number): boolean return math.abs(x) < pad.halfWidth and math.abs(z) < pad.halfLength end local function padAt(root: BasePart, humanoid: Humanoid, speed: number, mode: string): Pad? local floor: RaycastResult? = nil local reach = Mobility.groundReach(root, humanoid) for _, pad in pads[mode] do if (root.Position - pad.frame.Position).Magnitude > pad.searchRadius then continue end if not floor then floor = workspace:Raycast(root.Position, -Vector3.yAxis * reach, Modes.collision(mode)) if not floor then return nil end end local delta = pad.frame:PointToObjectSpace(floor.Position) if math.abs(delta.Y) > .45 or not contains(pad, delta.X, delta.Z) then continue end -- Reject characters just beginning to jump or still falling toward the ramp. local normalSpeed = root.AssemblyLinearVelocity:Dot(floor.Normal) if math.abs(normalSpeed) <= math.max(11, speed * .15) then return pad end end return nil end local onHop = hopUsed.OnServerEvent:Connect(function(player: Player, model: unknown) if typeof(model) ~= "Instance" then return end local pad = jumpOrigins[model] if not pad or Modes.of(player) ~= pad.mode then return end local origin = pad.origin local now = workspace:GetServerTimeNow() if now - (lastHop[player] or 0) < .45 or player:GetAttribute("InArena") ~= true or not Modes.open(round, pad.mode, now) then return end local character = player.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") local root = character and character:FindFirstChild("HumanoidRootPart") if not humanoid or humanoid.Health <= 0 or humanoid.Sit or not root or not root:IsA("BasePart") or root.Anchored then return end local offset = root.Position - origin.Position local isOwner = root:GetNetworkOwner() == player local allowedDistance = Mobility.JumpRadius + (if isOwner then 10 else 1) if (offset * horizontalMask).Magnitude > allowedDistance or offset.Y < .5 or offset.Y > Mobility.JumpRise + Mobility.groundReach(root, humanoid) then return end if not isOwner then local reach = Mobility.groundReach(root, humanoid) local floor = workspace:Raycast(root.Position, -Vector3.yAxis * reach, Modes.collision(pad.mode)) local velocity = root.AssemblyLinearVelocity if not floor or math.abs(floor.Position.Y - origin.Position.Y) > .45 or math.abs(velocity.Y) > 11 or (velocity * horizontalMask).Magnitude < .6 then return end Mobility.hop(root, humanoid) end lastHop[player] = now model:SetAttribute("PulseAt", now) end) local accumulator = 0 local step = RunService.Heartbeat:Connect(function(dt) accumulator += dt if accumulator < 1 / 30 then return end accumulator %= 1 / 30 local now = workspace:GetServerTimeNow() local active = Modes.open(round, Modes.Procedural, now) for _, player in Players:GetPlayers() do local mode = Modes.of(player) local character = player.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") local root = character and character:FindFirstChild("HumanoidRootPart") if not active or player:GetAttribute("InArena") ~= true or not character or not humanoid or humanoid.Health <= 0 or not root or not root:IsA("BasePart") or root.Anchored or humanoid.Sit then standing[player] = nil clearBoost(player) continue end local boost = boosts[player] if boost and (now >= boost.untilTime or boost.character ~= character) then clearBoost(player) end local velocity = root.AssemblyLinearVelocity local horizontal = velocity * horizontalMask local speed = horizontal.Magnitude local previous = standing[player] if previous and pads[mode][previous.model] == previous then -- Project vertically onto the slope so crossing just above it still counts as one pass. local relative = root.Position - previous.frame.Position local normal = previous.frame.UpVector local point = root.Position - Vector3.yAxis * (relative:Dot(normal) / normal.Y) local delta = previous.frame:PointToObjectSpace(point) if contains(previous, delta.X, delta.Z) then continue end end standing[player] = nil if speed < .6 then continue end local pad = padAt(root, humanoid, speed, mode) if not pad or horizontal:Dot(pad.forward) < speed * .35 then continue end local expiry = now + Mobility.BoostDuration boosts[player] = {character = character, humanoid = humanoid, untilTime = expiry} character:SetAttribute("ArenaBoostUntil", expiry) humanoid.WalkSpeed = baseSpeed() * Mobility.walkMultiplier(character, now) standing[player] = pad pad.model:SetAttribute("PulseAt", now) end end) local removing = Players.PlayerRemoving:Connect(function(player) standing[player], lastHop[player] = nil, nil clearBoost(player) end) script.Destroying:Once(function() step:Disconnect() onHop:Disconnect() removing:Disconnect() stopWatching() end)