59 lines
2.4 KiB
Luau
59 lines
2.4 KiB
Luau
--!strict
|
|
local CollectionService = game:GetService("CollectionService")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local Mobility = {
|
|
BoostMultiplier = 1.48,
|
|
BoostDuration = 2,
|
|
JumpRise = 48,
|
|
JumpRadius = 4.8,
|
|
ProceduralRuneTag = "HunterProceduralRune",
|
|
}
|
|
|
|
function Mobility.watchRunes(add: (Instance, string) -> (), remove: (Instance, string) -> ()): () -> ()
|
|
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
|
|
local tag = Mobility.ProceduralRuneTag
|
|
local closed = false
|
|
local function register(rune: Instance)
|
|
-- Let an atomic rune model finish replicating before reading its origin and art groups.
|
|
task.defer(function()
|
|
if closed then return end
|
|
if rune:IsDescendantOf(workspace) and CollectionService:HasTag(rune, tag) then
|
|
add(rune, Modes.Procedural)
|
|
end
|
|
end)
|
|
end
|
|
local proceduralAdded = CollectionService:GetInstanceAddedSignal(tag):Connect(register)
|
|
local proceduralRemoved = CollectionService:GetInstanceRemovedSignal(tag):Connect(function(rune) remove(rune, Modes.Procedural) end)
|
|
for _, rune in CollectionService:GetTagged(tag) do register(rune) end
|
|
return function()
|
|
closed = true
|
|
proceduralAdded:Disconnect()
|
|
proceduralRemoved:Disconnect()
|
|
end
|
|
end
|
|
|
|
function Mobility.active(character: Model?, key: string, now: number): boolean
|
|
local expires = character and character:GetAttribute("Loot" .. key .. "Until")
|
|
return typeof(expires) == "number" and expires > now
|
|
end
|
|
|
|
function Mobility.walkMultiplier(character: Model, now: number): number
|
|
local rampExpiry = character:GetAttribute("ArenaBoostUntil")
|
|
local ramp = if typeof(rampExpiry) == "number" and rampExpiry > now then Mobility.BoostMultiplier else 1
|
|
local loot = if Mobility.active(character, "Turbo", now) then 1.30 elseif Mobility.active(character, "Team", now) then 1.20 else 1
|
|
return math.max(ramp, loot) * (if Mobility.active(character, "Slow", now) then .65 else 1)
|
|
end
|
|
|
|
function Mobility.groundReach(root: BasePart, humanoid: Humanoid): number
|
|
return math.max(3, humanoid.HipHeight + root.Size.Y * .5) + .85
|
|
end
|
|
|
|
function Mobility.hop(root: BasePart, humanoid: Humanoid)
|
|
local upSpeed = math.sqrt(2 * workspace.Gravity * Mobility.JumpRise)
|
|
local deltaSpeed = upSpeed - root.AssemblyLinearVelocity.Y
|
|
humanoid:ChangeState(Enum.HumanoidStateType.Freefall)
|
|
root:ApplyImpulse(Vector3.yAxis * deltaSpeed * root.AssemblyMass)
|
|
end
|
|
|
|
return table.freeze(Mobility)
|