Files
Hunter/scripts/CitadelCaptureService.luau
T
2026-11-29 15:49:17 +03:00

15 lines
637 B
Luau

--!strict
local Capture = {}
export type Status = "Idle" | "Capturing" | "Contested" | "Decaying" | "Captured"
function Capture.advance(progress: number, dt: number, attack: boolean, defense: boolean, seconds: number, decay: number): (number, Status)
local grows = attack and not defense
local nextProgress = math.clamp(progress + dt * (if grows then 1 else -decay) / seconds, 0, 1)
if nextProgress >= 1 - 1e-9 then return 1, "Captured" end
if defense then return nextProgress, "Contested" end
if grows then return nextProgress, "Capturing" end
return nextProgress, if progress > 0 then "Decaying" else "Idle"
end
return Capture