From c3cf9a9bec8f6e8d9eec95ea6c7e53a341e86e18 Mon Sep 17 00:00:00 2001 From: listik Date: Mon, 2 Nov 2026 21:35:45 +0300 Subject: [PATCH] 23 --- Fishing.rbxlx | 134 +++++++++++++++++- .../4_GameServer_ServerScriptService.rbxmx | 2 +- ...5_FishingClient_StarterPlayerScripts.rbxmx | 132 +++++++++++++++++ install/INSTALL.lua | 134 +++++++++++++++++- src/ServerScriptService/GameServer.server.lua | 2 +- .../FishingClient.client.lua | 132 +++++++++++++++++ 6 files changed, 532 insertions(+), 4 deletions(-) diff --git a/Fishing.rbxlx b/Fishing.rbxlx index 2f55896..94fda93 100644 --- a/Fishing.rbxlx +++ b/Fishing.rbxlx @@ -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("●", mg.hits) .. string.rep("●", 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 diff --git a/install/4_GameServer_ServerScriptService.rbxmx b/install/4_GameServer_ServerScriptService.rbxmx index 9914731..7fbfa3b 100644 --- a/install/4_GameServer_ServerScriptService.rbxmx +++ b/install/4_GameServer_ServerScriptService.rbxmx @@ -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() -- замах назад и бросок вперёд diff --git a/install/5_FishingClient_StarterPlayerScripts.rbxmx b/install/5_FishingClient_StarterPlayerScripts.rbxmx index af7e5da..5b648fc 100644 --- a/install/5_FishingClient_StarterPlayerScripts.rbxmx +++ b/install/5_FishingClient_StarterPlayerScripts.rbxmx @@ -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("●", mg.hits) .. string.rep("●", 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 diff --git a/install/INSTALL.lua b/install/INSTALL.lua index 7248e81..b6b0f65 100644 --- a/install/INSTALL.lua +++ b/install/INSTALL.lua @@ -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("●", mg.hits) .. string.rep("●", 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 diff --git a/src/ServerScriptService/GameServer.server.lua b/src/ServerScriptService/GameServer.server.lua index 49b933f..a38b49b 100644 --- a/src/ServerScriptService/GameServer.server.lua +++ b/src/ServerScriptService/GameServer.server.lua @@ -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() -- замах назад и бросок вперёд diff --git a/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua b/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua index 6cb3cc0..6961083 100644 --- a/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua +++ b/src/StarterPlayer/StarterPlayerScripts/FishingClient.client.lua @@ -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("●", mg.hits) .. string.rep("●", 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