23
This commit is contained in:
1 parent
58ce572e2d
commit
c3cf9a9bec
6 files changed
+532
-4
No files matched your search
+133
-1
@@ -3130,7 +3130,7 @@ local function onCast(player)
|
||||
end
|
||||
local s = { stage = "casting", fish = fish, tool = tool }
|
||||
fishing[player] = s
|
||||
remote:FireClient(player, "Cast")
|
||||
remote:FireClient(player, "Cast", target + Vector3.new(0, 0.15, 0)) -- клиенту для камеры
|
||||
|
||||
task.spawn(function()
|
||||
-- замах назад и бросок вперёд
|
||||
@@ -4736,10 +4736,141 @@ refreshHud()
|
||||
local state = "idle"
|
||||
local mg = { pos = 0, dir = 1, speed = 1, zoneStart = 0.4, zoneWidth = 0.25, hits = 0, need = 1, misses = 0, maxMisses = 2, deadline = 0, timeout = 10 }
|
||||
|
||||
-- пока удочка заброшена, ходить и прыгать нельзя
|
||||
local controls
|
||||
local function setMovementLocked(locked)
|
||||
if not controls then
|
||||
local pm = player:FindFirstChild("PlayerScripts") and player.PlayerScripts:FindFirstChild("PlayerModule")
|
||||
local ok, mod = pcall(require, pm)
|
||||
controls = ok and mod and mod:GetControls() or nil
|
||||
end
|
||||
if controls then
|
||||
if locked then
|
||||
controls:Disable()
|
||||
else
|
||||
controls:Enable()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- камера при забросе
|
||||
-- замах: камера отъезжает и расширяется обзор; полёт: камера разгоняется за поплавком;
|
||||
-- потом смотрит на поплавок, пока рыбалка не закончится, и плавно возвращается
|
||||
|
||||
local CAST_WINDUP, CAST_FLIGHT = 0.4, 0.55 -- как в GameServer: замах и полёт поплавка
|
||||
local CAM_SETTLE, CAM_RETURN = 0.7, 0.6
|
||||
local UP = Vector3.new(0, 1, 0)
|
||||
local fishCam = nil
|
||||
|
||||
local function easeInOut(a)
|
||||
return a < 0.5 and 4 * a * a * a or 1 - (-2 * a + 2) ^ 3 / 2
|
||||
end
|
||||
local function easeOut(a)
|
||||
return 1 - (1 - a) ^ 3
|
||||
end
|
||||
|
||||
local function fishCamStep()
|
||||
local fc = fishCam
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fc or not cam then
|
||||
return
|
||||
end
|
||||
if fc.returning then
|
||||
local a = math.min(1, (os.clock() - fc.returning) / CAM_RETURN)
|
||||
local e = easeInOut(a)
|
||||
cam.CFrame = fc.leaveCF:Lerp(fc.origCF, e)
|
||||
cam.FieldOfView = fc.leaveFov + (fc.origFov - fc.leaveFov) * e
|
||||
if a >= 1 then
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
cam.CameraType = Enum.CameraType.Custom
|
||||
fishCam = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
local t = os.clock() - fc.t0
|
||||
local cf, fov
|
||||
if t < CAST_WINDUP then
|
||||
local e = easeOut(t / CAST_WINDUP)
|
||||
cf = fc.origCF:Lerp(fc.windupCF, e)
|
||||
fov = fc.origFov + 14 * e
|
||||
elseif t < CAST_WINDUP + CAST_FLIGHT then
|
||||
if not fc.start then
|
||||
fc.start = (fc.tip and fc.tip.Parent and fc.tip.WorldPosition) or fc.fallbackStart
|
||||
end
|
||||
local a = (t - CAST_WINDUP) / CAST_FLIGHT
|
||||
local p = fc.start:Lerp(fc.target, a) + UP * (math.sin(a * math.pi) * 6) -- та же дуга, что у поплавка
|
||||
local chase = CFrame.lookAt(p - fc.flat * 9 + UP * 3.5, p + fc.flat * 4)
|
||||
local e = easeInOut(a)
|
||||
cf = fc.windupCF:Lerp(chase, e)
|
||||
fov = fc.origFov + 14 - 22 * e
|
||||
else
|
||||
local e = easeOut(math.min(1, (t - CAST_WINDUP - CAST_FLIGHT) / CAM_SETTLE))
|
||||
local now = os.clock()
|
||||
local sway = Vector3.new(math.sin(now * 0.7) * 0.5, math.sin(now * 1.1) * 0.25, 0)
|
||||
if state == "bite" then
|
||||
sway += Vector3.new(math.random() - 0.5, math.random() - 0.5, 0) * 0.15
|
||||
end
|
||||
cf = fc.landCF:Lerp(fc.restCF + sway, e)
|
||||
fov = fc.origFov - 8 + 8 * e
|
||||
end
|
||||
cam.CFrame = cf
|
||||
cam.FieldOfView = fov
|
||||
end
|
||||
|
||||
local function startFishCam(target)
|
||||
local cam = workspace.CurrentCamera
|
||||
local char = player.Character
|
||||
local hrp = char and char:FindFirstChild("HumanoidRootPart")
|
||||
if not cam or not hrp or typeof(target) ~= "Vector3" then
|
||||
return
|
||||
end
|
||||
local flat = (target - hrp.Position) * Vector3.new(1, 0, 1)
|
||||
flat = flat.Magnitude > 0.1 and flat.Unit or hrp.CFrame.LookVector
|
||||
local tool = char:FindFirstChildOfClass("Tool")
|
||||
local tip = tool and tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip")
|
||||
fishCam = {
|
||||
t0 = os.clock(), target = target, flat = flat, tip = tip,
|
||||
fallbackStart = hrp.Position + flat * 2 + UP * 4,
|
||||
-- если камера ещё возвращалась с прошлого заброса, возвращаться будем туда же
|
||||
origCF = fishCam and fishCam.origCF or cam.CFrame,
|
||||
origFov = fishCam and fishCam.origFov or cam.FieldOfView,
|
||||
windupCF = CFrame.lookAt(hrp.Position - flat * 13 + UP * 7, hrp.Position:Lerp(target, 0.5)),
|
||||
landCF = CFrame.lookAt(target - flat * 9 + UP * 3.5, target + flat * 4),
|
||||
restCF = CFrame.lookAt(target - flat * 11 + UP * 5.5, target),
|
||||
}
|
||||
cam.CameraType = Enum.CameraType.Scriptable
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
RunService:BindToRenderStep("FishCam", Enum.RenderPriority.Camera.Value + 1, fishCamStep)
|
||||
end
|
||||
|
||||
local function stopFishCam()
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fishCam or fishCam.returning or not cam then
|
||||
return
|
||||
end
|
||||
fishCam.returning = os.clock()
|
||||
fishCam.leaveCF = cam.CFrame
|
||||
fishCam.leaveFov = cam.FieldOfView
|
||||
end
|
||||
|
||||
local reelToken
|
||||
local function setState(s)
|
||||
state = s
|
||||
statusLabel.Visible = (s == "waiting")
|
||||
mgFrame.Visible = (s == "bite")
|
||||
setMovementLocked(s ~= "idle")
|
||||
if s == "idle" then
|
||||
stopFishCam()
|
||||
elseif s == "reeling" then
|
||||
-- на случай, если сервер не ответит на вытаскивание: не оставляем игрока замороженным
|
||||
local token = {}
|
||||
reelToken = token
|
||||
task.delay(4, function()
|
||||
if state == "reeling" and reelToken == token then
|
||||
setState("idle")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
local function updatePips()
|
||||
pipsText.Text = "🎯 " .. string.rep("<font color=\"#7CFF9A\">●</font>", mg.hits) .. string.rep("<font color=\"#5A6480\">●</font>", mg.need - mg.hits)
|
||||
@@ -4925,6 +5056,7 @@ remote.OnClientEvent:Connect(function(action, a, b, c)
|
||||
notify(a, b)
|
||||
elseif action == "Cast" then
|
||||
setState("waiting")
|
||||
startFishCam(a)
|
||||
elseif action == "CastFail" or action == "Cancel" or action == "Escaped" then
|
||||
setState("idle")
|
||||
elseif action == "Bite" then
|
||||
|
||||
@@ -730,7 +730,7 @@ local function onCast(player)
|
||||
end
|
||||
local s = { stage = "casting", fish = fish, tool = tool }
|
||||
fishing[player] = s
|
||||
remote:FireClient(player, "Cast")
|
||||
remote:FireClient(player, "Cast", target + Vector3.new(0, 0.15, 0)) -- клиенту для камеры
|
||||
|
||||
task.spawn(function()
|
||||
-- замах назад и бросок вперёд
|
||||
|
||||
@@ -1046,10 +1046,141 @@ refreshHud()
|
||||
local state = "idle"
|
||||
local mg = { pos = 0, dir = 1, speed = 1, zoneStart = 0.4, zoneWidth = 0.25, hits = 0, need = 1, misses = 0, maxMisses = 2, deadline = 0, timeout = 10 }
|
||||
|
||||
-- пока удочка заброшена, ходить и прыгать нельзя
|
||||
local controls
|
||||
local function setMovementLocked(locked)
|
||||
if not controls then
|
||||
local pm = player:FindFirstChild("PlayerScripts") and player.PlayerScripts:FindFirstChild("PlayerModule")
|
||||
local ok, mod = pcall(require, pm)
|
||||
controls = ok and mod and mod:GetControls() or nil
|
||||
end
|
||||
if controls then
|
||||
if locked then
|
||||
controls:Disable()
|
||||
else
|
||||
controls:Enable()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- камера при забросе
|
||||
-- замах: камера отъезжает и расширяется обзор; полёт: камера разгоняется за поплавком;
|
||||
-- потом смотрит на поплавок, пока рыбалка не закончится, и плавно возвращается
|
||||
|
||||
local CAST_WINDUP, CAST_FLIGHT = 0.4, 0.55 -- как в GameServer: замах и полёт поплавка
|
||||
local CAM_SETTLE, CAM_RETURN = 0.7, 0.6
|
||||
local UP = Vector3.new(0, 1, 0)
|
||||
local fishCam = nil
|
||||
|
||||
local function easeInOut(a)
|
||||
return a < 0.5 and 4 * a * a * a or 1 - (-2 * a + 2) ^ 3 / 2
|
||||
end
|
||||
local function easeOut(a)
|
||||
return 1 - (1 - a) ^ 3
|
||||
end
|
||||
|
||||
local function fishCamStep()
|
||||
local fc = fishCam
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fc or not cam then
|
||||
return
|
||||
end
|
||||
if fc.returning then
|
||||
local a = math.min(1, (os.clock() - fc.returning) / CAM_RETURN)
|
||||
local e = easeInOut(a)
|
||||
cam.CFrame = fc.leaveCF:Lerp(fc.origCF, e)
|
||||
cam.FieldOfView = fc.leaveFov + (fc.origFov - fc.leaveFov) * e
|
||||
if a >= 1 then
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
cam.CameraType = Enum.CameraType.Custom
|
||||
fishCam = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
local t = os.clock() - fc.t0
|
||||
local cf, fov
|
||||
if t < CAST_WINDUP then
|
||||
local e = easeOut(t / CAST_WINDUP)
|
||||
cf = fc.origCF:Lerp(fc.windupCF, e)
|
||||
fov = fc.origFov + 14 * e
|
||||
elseif t < CAST_WINDUP + CAST_FLIGHT then
|
||||
if not fc.start then
|
||||
fc.start = (fc.tip and fc.tip.Parent and fc.tip.WorldPosition) or fc.fallbackStart
|
||||
end
|
||||
local a = (t - CAST_WINDUP) / CAST_FLIGHT
|
||||
local p = fc.start:Lerp(fc.target, a) + UP * (math.sin(a * math.pi) * 6) -- та же дуга, что у поплавка
|
||||
local chase = CFrame.lookAt(p - fc.flat * 9 + UP * 3.5, p + fc.flat * 4)
|
||||
local e = easeInOut(a)
|
||||
cf = fc.windupCF:Lerp(chase, e)
|
||||
fov = fc.origFov + 14 - 22 * e
|
||||
else
|
||||
local e = easeOut(math.min(1, (t - CAST_WINDUP - CAST_FLIGHT) / CAM_SETTLE))
|
||||
local now = os.clock()
|
||||
local sway = Vector3.new(math.sin(now * 0.7) * 0.5, math.sin(now * 1.1) * 0.25, 0)
|
||||
if state == "bite" then
|
||||
sway += Vector3.new(math.random() - 0.5, math.random() - 0.5, 0) * 0.15
|
||||
end
|
||||
cf = fc.landCF:Lerp(fc.restCF + sway, e)
|
||||
fov = fc.origFov - 8 + 8 * e
|
||||
end
|
||||
cam.CFrame = cf
|
||||
cam.FieldOfView = fov
|
||||
end
|
||||
|
||||
local function startFishCam(target)
|
||||
local cam = workspace.CurrentCamera
|
||||
local char = player.Character
|
||||
local hrp = char and char:FindFirstChild("HumanoidRootPart")
|
||||
if not cam or not hrp or typeof(target) ~= "Vector3" then
|
||||
return
|
||||
end
|
||||
local flat = (target - hrp.Position) * Vector3.new(1, 0, 1)
|
||||
flat = flat.Magnitude > 0.1 and flat.Unit or hrp.CFrame.LookVector
|
||||
local tool = char:FindFirstChildOfClass("Tool")
|
||||
local tip = tool and tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip")
|
||||
fishCam = {
|
||||
t0 = os.clock(), target = target, flat = flat, tip = tip,
|
||||
fallbackStart = hrp.Position + flat * 2 + UP * 4,
|
||||
-- если камера ещё возвращалась с прошлого заброса, возвращаться будем туда же
|
||||
origCF = fishCam and fishCam.origCF or cam.CFrame,
|
||||
origFov = fishCam and fishCam.origFov or cam.FieldOfView,
|
||||
windupCF = CFrame.lookAt(hrp.Position - flat * 13 + UP * 7, hrp.Position:Lerp(target, 0.5)),
|
||||
landCF = CFrame.lookAt(target - flat * 9 + UP * 3.5, target + flat * 4),
|
||||
restCF = CFrame.lookAt(target - flat * 11 + UP * 5.5, target),
|
||||
}
|
||||
cam.CameraType = Enum.CameraType.Scriptable
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
RunService:BindToRenderStep("FishCam", Enum.RenderPriority.Camera.Value + 1, fishCamStep)
|
||||
end
|
||||
|
||||
local function stopFishCam()
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fishCam or fishCam.returning or not cam then
|
||||
return
|
||||
end
|
||||
fishCam.returning = os.clock()
|
||||
fishCam.leaveCF = cam.CFrame
|
||||
fishCam.leaveFov = cam.FieldOfView
|
||||
end
|
||||
|
||||
local reelToken
|
||||
local function setState(s)
|
||||
state = s
|
||||
statusLabel.Visible = (s == "waiting")
|
||||
mgFrame.Visible = (s == "bite")
|
||||
setMovementLocked(s ~= "idle")
|
||||
if s == "idle" then
|
||||
stopFishCam()
|
||||
elseif s == "reeling" then
|
||||
-- на случай, если сервер не ответит на вытаскивание: не оставляем игрока замороженным
|
||||
local token = {}
|
||||
reelToken = token
|
||||
task.delay(4, function()
|
||||
if state == "reeling" and reelToken == token then
|
||||
setState("idle")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
local function updatePips()
|
||||
pipsText.Text = "🎯 " .. string.rep("<font color=\"#7CFF9A\">●</font>", mg.hits) .. string.rep("<font color=\"#5A6480\">●</font>", mg.need - mg.hits)
|
||||
@@ -1235,6 +1366,7 @@ remote.OnClientEvent:Connect(function(action, a, b, c)
|
||||
notify(a, b)
|
||||
elseif action == "Cast" then
|
||||
setState("waiting")
|
||||
startFishCam(a)
|
||||
elseif action == "CastFail" or action == "Cancel" or action == "Escaped" then
|
||||
setState("idle")
|
||||
elseif action == "Bite" then
|
||||
|
||||
+133
-1
@@ -3136,7 +3136,7 @@ local function onCast(player)
|
||||
end
|
||||
local s = { stage = "casting", fish = fish, tool = tool }
|
||||
fishing[player] = s
|
||||
remote:FireClient(player, "Cast")
|
||||
remote:FireClient(player, "Cast", target + Vector3.new(0, 0.15, 0)) -- клиенту для камеры
|
||||
|
||||
task.spawn(function()
|
||||
-- замах назад и бросок вперёд
|
||||
@@ -4739,10 +4739,141 @@ refreshHud()
|
||||
local state = "idle"
|
||||
local mg = { pos = 0, dir = 1, speed = 1, zoneStart = 0.4, zoneWidth = 0.25, hits = 0, need = 1, misses = 0, maxMisses = 2, deadline = 0, timeout = 10 }
|
||||
|
||||
-- пока удочка заброшена, ходить и прыгать нельзя
|
||||
local controls
|
||||
local function setMovementLocked(locked)
|
||||
if not controls then
|
||||
local pm = player:FindFirstChild("PlayerScripts") and player.PlayerScripts:FindFirstChild("PlayerModule")
|
||||
local ok, mod = pcall(require, pm)
|
||||
controls = ok and mod and mod:GetControls() or nil
|
||||
end
|
||||
if controls then
|
||||
if locked then
|
||||
controls:Disable()
|
||||
else
|
||||
controls:Enable()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- камера при забросе
|
||||
-- замах: камера отъезжает и расширяется обзор; полёт: камера разгоняется за поплавком;
|
||||
-- потом смотрит на поплавок, пока рыбалка не закончится, и плавно возвращается
|
||||
|
||||
local CAST_WINDUP, CAST_FLIGHT = 0.4, 0.55 -- как в GameServer: замах и полёт поплавка
|
||||
local CAM_SETTLE, CAM_RETURN = 0.7, 0.6
|
||||
local UP = Vector3.new(0, 1, 0)
|
||||
local fishCam = nil
|
||||
|
||||
local function easeInOut(a)
|
||||
return a < 0.5 and 4 * a * a * a or 1 - (-2 * a + 2) ^ 3 / 2
|
||||
end
|
||||
local function easeOut(a)
|
||||
return 1 - (1 - a) ^ 3
|
||||
end
|
||||
|
||||
local function fishCamStep()
|
||||
local fc = fishCam
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fc or not cam then
|
||||
return
|
||||
end
|
||||
if fc.returning then
|
||||
local a = math.min(1, (os.clock() - fc.returning) / CAM_RETURN)
|
||||
local e = easeInOut(a)
|
||||
cam.CFrame = fc.leaveCF:Lerp(fc.origCF, e)
|
||||
cam.FieldOfView = fc.leaveFov + (fc.origFov - fc.leaveFov) * e
|
||||
if a >= 1 then
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
cam.CameraType = Enum.CameraType.Custom
|
||||
fishCam = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
local t = os.clock() - fc.t0
|
||||
local cf, fov
|
||||
if t < CAST_WINDUP then
|
||||
local e = easeOut(t / CAST_WINDUP)
|
||||
cf = fc.origCF:Lerp(fc.windupCF, e)
|
||||
fov = fc.origFov + 14 * e
|
||||
elseif t < CAST_WINDUP + CAST_FLIGHT then
|
||||
if not fc.start then
|
||||
fc.start = (fc.tip and fc.tip.Parent and fc.tip.WorldPosition) or fc.fallbackStart
|
||||
end
|
||||
local a = (t - CAST_WINDUP) / CAST_FLIGHT
|
||||
local p = fc.start:Lerp(fc.target, a) + UP * (math.sin(a * math.pi) * 6) -- та же дуга, что у поплавка
|
||||
local chase = CFrame.lookAt(p - fc.flat * 9 + UP * 3.5, p + fc.flat * 4)
|
||||
local e = easeInOut(a)
|
||||
cf = fc.windupCF:Lerp(chase, e)
|
||||
fov = fc.origFov + 14 - 22 * e
|
||||
else
|
||||
local e = easeOut(math.min(1, (t - CAST_WINDUP - CAST_FLIGHT) / CAM_SETTLE))
|
||||
local now = os.clock()
|
||||
local sway = Vector3.new(math.sin(now * 0.7) * 0.5, math.sin(now * 1.1) * 0.25, 0)
|
||||
if state == "bite" then
|
||||
sway += Vector3.new(math.random() - 0.5, math.random() - 0.5, 0) * 0.15
|
||||
end
|
||||
cf = fc.landCF:Lerp(fc.restCF + sway, e)
|
||||
fov = fc.origFov - 8 + 8 * e
|
||||
end
|
||||
cam.CFrame = cf
|
||||
cam.FieldOfView = fov
|
||||
end
|
||||
|
||||
local function startFishCam(target)
|
||||
local cam = workspace.CurrentCamera
|
||||
local char = player.Character
|
||||
local hrp = char and char:FindFirstChild("HumanoidRootPart")
|
||||
if not cam or not hrp or typeof(target) ~= "Vector3" then
|
||||
return
|
||||
end
|
||||
local flat = (target - hrp.Position) * Vector3.new(1, 0, 1)
|
||||
flat = flat.Magnitude > 0.1 and flat.Unit or hrp.CFrame.LookVector
|
||||
local tool = char:FindFirstChildOfClass("Tool")
|
||||
local tip = tool and tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip")
|
||||
fishCam = {
|
||||
t0 = os.clock(), target = target, flat = flat, tip = tip,
|
||||
fallbackStart = hrp.Position + flat * 2 + UP * 4,
|
||||
-- если камера ещё возвращалась с прошлого заброса, возвращаться будем туда же
|
||||
origCF = fishCam and fishCam.origCF or cam.CFrame,
|
||||
origFov = fishCam and fishCam.origFov or cam.FieldOfView,
|
||||
windupCF = CFrame.lookAt(hrp.Position - flat * 13 + UP * 7, hrp.Position:Lerp(target, 0.5)),
|
||||
landCF = CFrame.lookAt(target - flat * 9 + UP * 3.5, target + flat * 4),
|
||||
restCF = CFrame.lookAt(target - flat * 11 + UP * 5.5, target),
|
||||
}
|
||||
cam.CameraType = Enum.CameraType.Scriptable
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
RunService:BindToRenderStep("FishCam", Enum.RenderPriority.Camera.Value + 1, fishCamStep)
|
||||
end
|
||||
|
||||
local function stopFishCam()
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fishCam or fishCam.returning or not cam then
|
||||
return
|
||||
end
|
||||
fishCam.returning = os.clock()
|
||||
fishCam.leaveCF = cam.CFrame
|
||||
fishCam.leaveFov = cam.FieldOfView
|
||||
end
|
||||
|
||||
local reelToken
|
||||
local function setState(s)
|
||||
state = s
|
||||
statusLabel.Visible = (s == "waiting")
|
||||
mgFrame.Visible = (s == "bite")
|
||||
setMovementLocked(s ~= "idle")
|
||||
if s == "idle" then
|
||||
stopFishCam()
|
||||
elseif s == "reeling" then
|
||||
-- на случай, если сервер не ответит на вытаскивание: не оставляем игрока замороженным
|
||||
local token = {}
|
||||
reelToken = token
|
||||
task.delay(4, function()
|
||||
if state == "reeling" and reelToken == token then
|
||||
setState("idle")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
local function updatePips()
|
||||
pipsText.Text = "🎯 " .. string.rep("<font color=\"#7CFF9A\">●</font>", mg.hits) .. string.rep("<font color=\"#5A6480\">●</font>", mg.need - mg.hits)
|
||||
@@ -4928,6 +5059,7 @@ remote.OnClientEvent:Connect(function(action, a, b, c)
|
||||
notify(a, b)
|
||||
elseif action == "Cast" then
|
||||
setState("waiting")
|
||||
startFishCam(a)
|
||||
elseif action == "CastFail" or action == "Cancel" or action == "Escaped" then
|
||||
setState("idle")
|
||||
elseif action == "Bite" then
|
||||
|
||||
@@ -729,7 +729,7 @@ local function onCast(player)
|
||||
end
|
||||
local s = { stage = "casting", fish = fish, tool = tool }
|
||||
fishing[player] = s
|
||||
remote:FireClient(player, "Cast")
|
||||
remote:FireClient(player, "Cast", target + Vector3.new(0, 0.15, 0)) -- клиенту для камеры
|
||||
|
||||
task.spawn(function()
|
||||
-- замах назад и бросок вперёд
|
||||
|
||||
@@ -1045,10 +1045,141 @@ refreshHud()
|
||||
local state = "idle"
|
||||
local mg = { pos = 0, dir = 1, speed = 1, zoneStart = 0.4, zoneWidth = 0.25, hits = 0, need = 1, misses = 0, maxMisses = 2, deadline = 0, timeout = 10 }
|
||||
|
||||
-- пока удочка заброшена, ходить и прыгать нельзя
|
||||
local controls
|
||||
local function setMovementLocked(locked)
|
||||
if not controls then
|
||||
local pm = player:FindFirstChild("PlayerScripts") and player.PlayerScripts:FindFirstChild("PlayerModule")
|
||||
local ok, mod = pcall(require, pm)
|
||||
controls = ok and mod and mod:GetControls() or nil
|
||||
end
|
||||
if controls then
|
||||
if locked then
|
||||
controls:Disable()
|
||||
else
|
||||
controls:Enable()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- камера при забросе
|
||||
-- замах: камера отъезжает и расширяется обзор; полёт: камера разгоняется за поплавком;
|
||||
-- потом смотрит на поплавок, пока рыбалка не закончится, и плавно возвращается
|
||||
|
||||
local CAST_WINDUP, CAST_FLIGHT = 0.4, 0.55 -- как в GameServer: замах и полёт поплавка
|
||||
local CAM_SETTLE, CAM_RETURN = 0.7, 0.6
|
||||
local UP = Vector3.new(0, 1, 0)
|
||||
local fishCam = nil
|
||||
|
||||
local function easeInOut(a)
|
||||
return a < 0.5 and 4 * a * a * a or 1 - (-2 * a + 2) ^ 3 / 2
|
||||
end
|
||||
local function easeOut(a)
|
||||
return 1 - (1 - a) ^ 3
|
||||
end
|
||||
|
||||
local function fishCamStep()
|
||||
local fc = fishCam
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fc or not cam then
|
||||
return
|
||||
end
|
||||
if fc.returning then
|
||||
local a = math.min(1, (os.clock() - fc.returning) / CAM_RETURN)
|
||||
local e = easeInOut(a)
|
||||
cam.CFrame = fc.leaveCF:Lerp(fc.origCF, e)
|
||||
cam.FieldOfView = fc.leaveFov + (fc.origFov - fc.leaveFov) * e
|
||||
if a >= 1 then
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
cam.CameraType = Enum.CameraType.Custom
|
||||
fishCam = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
local t = os.clock() - fc.t0
|
||||
local cf, fov
|
||||
if t < CAST_WINDUP then
|
||||
local e = easeOut(t / CAST_WINDUP)
|
||||
cf = fc.origCF:Lerp(fc.windupCF, e)
|
||||
fov = fc.origFov + 14 * e
|
||||
elseif t < CAST_WINDUP + CAST_FLIGHT then
|
||||
if not fc.start then
|
||||
fc.start = (fc.tip and fc.tip.Parent and fc.tip.WorldPosition) or fc.fallbackStart
|
||||
end
|
||||
local a = (t - CAST_WINDUP) / CAST_FLIGHT
|
||||
local p = fc.start:Lerp(fc.target, a) + UP * (math.sin(a * math.pi) * 6) -- та же дуга, что у поплавка
|
||||
local chase = CFrame.lookAt(p - fc.flat * 9 + UP * 3.5, p + fc.flat * 4)
|
||||
local e = easeInOut(a)
|
||||
cf = fc.windupCF:Lerp(chase, e)
|
||||
fov = fc.origFov + 14 - 22 * e
|
||||
else
|
||||
local e = easeOut(math.min(1, (t - CAST_WINDUP - CAST_FLIGHT) / CAM_SETTLE))
|
||||
local now = os.clock()
|
||||
local sway = Vector3.new(math.sin(now * 0.7) * 0.5, math.sin(now * 1.1) * 0.25, 0)
|
||||
if state == "bite" then
|
||||
sway += Vector3.new(math.random() - 0.5, math.random() - 0.5, 0) * 0.15
|
||||
end
|
||||
cf = fc.landCF:Lerp(fc.restCF + sway, e)
|
||||
fov = fc.origFov - 8 + 8 * e
|
||||
end
|
||||
cam.CFrame = cf
|
||||
cam.FieldOfView = fov
|
||||
end
|
||||
|
||||
local function startFishCam(target)
|
||||
local cam = workspace.CurrentCamera
|
||||
local char = player.Character
|
||||
local hrp = char and char:FindFirstChild("HumanoidRootPart")
|
||||
if not cam or not hrp or typeof(target) ~= "Vector3" then
|
||||
return
|
||||
end
|
||||
local flat = (target - hrp.Position) * Vector3.new(1, 0, 1)
|
||||
flat = flat.Magnitude > 0.1 and flat.Unit or hrp.CFrame.LookVector
|
||||
local tool = char:FindFirstChildOfClass("Tool")
|
||||
local tip = tool and tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip")
|
||||
fishCam = {
|
||||
t0 = os.clock(), target = target, flat = flat, tip = tip,
|
||||
fallbackStart = hrp.Position + flat * 2 + UP * 4,
|
||||
-- если камера ещё возвращалась с прошлого заброса, возвращаться будем туда же
|
||||
origCF = fishCam and fishCam.origCF or cam.CFrame,
|
||||
origFov = fishCam and fishCam.origFov or cam.FieldOfView,
|
||||
windupCF = CFrame.lookAt(hrp.Position - flat * 13 + UP * 7, hrp.Position:Lerp(target, 0.5)),
|
||||
landCF = CFrame.lookAt(target - flat * 9 + UP * 3.5, target + flat * 4),
|
||||
restCF = CFrame.lookAt(target - flat * 11 + UP * 5.5, target),
|
||||
}
|
||||
cam.CameraType = Enum.CameraType.Scriptable
|
||||
RunService:UnbindFromRenderStep("FishCam")
|
||||
RunService:BindToRenderStep("FishCam", Enum.RenderPriority.Camera.Value + 1, fishCamStep)
|
||||
end
|
||||
|
||||
local function stopFishCam()
|
||||
local cam = workspace.CurrentCamera
|
||||
if not fishCam or fishCam.returning or not cam then
|
||||
return
|
||||
end
|
||||
fishCam.returning = os.clock()
|
||||
fishCam.leaveCF = cam.CFrame
|
||||
fishCam.leaveFov = cam.FieldOfView
|
||||
end
|
||||
|
||||
local reelToken
|
||||
local function setState(s)
|
||||
state = s
|
||||
statusLabel.Visible = (s == "waiting")
|
||||
mgFrame.Visible = (s == "bite")
|
||||
setMovementLocked(s ~= "idle")
|
||||
if s == "idle" then
|
||||
stopFishCam()
|
||||
elseif s == "reeling" then
|
||||
-- на случай, если сервер не ответит на вытаскивание: не оставляем игрока замороженным
|
||||
local token = {}
|
||||
reelToken = token
|
||||
task.delay(4, function()
|
||||
if state == "reeling" and reelToken == token then
|
||||
setState("idle")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
local function updatePips()
|
||||
pipsText.Text = "🎯 " .. string.rep("<font color=\"#7CFF9A\">●</font>", mg.hits) .. string.rep("<font color=\"#5A6480\">●</font>", mg.need - mg.hits)
|
||||
@@ -1234,6 +1365,7 @@ remote.OnClientEvent:Connect(function(action, a, b, c)
|
||||
notify(a, b)
|
||||
elseif action == "Cast" then
|
||||
setState("waiting")
|
||||
startFishCam(a)
|
||||
elseif action == "CastFail" or action == "Cancel" or action == "Escaped" then
|
||||
setState("idle")
|
||||
elseif action == "Bite" then
|
||||
|
||||
Reference in new issue
Block a user