213
This commit is contained in:
1 parent
8434f61030
commit
ec69c6c8d7
10 files changed
+2268
-336
No files matched your search
@@ -219,6 +219,8 @@ local function updateStats(player)
|
||||
player:SetAttribute("BoostBonus", boostActive(data))
|
||||
player:SetAttribute("BoostLeft", math.max(0, data.boostUntil - os.time()))
|
||||
player:SetAttribute("TotalCaught", data.totalCaught)
|
||||
-- шаг обучения (линия-подсказка); у старых игроков без поля, уже ловивших рыбу, обучение пройдено
|
||||
player:SetAttribute("Tutorial", data.tutorial or (data.totalCaught > 0 and Config.TutorialDone or 0))
|
||||
player:SetAttribute("Mastery", masteryCount(data))
|
||||
player:SetAttribute("Passes", table.concat(ps, ","))
|
||||
|
||||
@@ -541,6 +543,28 @@ local function splash(part, count)
|
||||
end
|
||||
|
||||
-- рыба вылетает из воды, летит к игроку и показывается над головой
|
||||
-- шлейф за летящим предметом — эффект быстрого движения (ширина — расстояние между точками крепления)
|
||||
local TRAIL_COLOR = Color3.fromRGB(215, 245, 255)
|
||||
local function addTrail(part, width)
|
||||
local a0 = Instance.new("Attachment")
|
||||
a0.Position = Vector3.new(0, width / 2, 0)
|
||||
a0.Parent = part
|
||||
local a1 = Instance.new("Attachment")
|
||||
a1.Position = Vector3.new(0, -width / 2, 0)
|
||||
a1.Parent = part
|
||||
local trail = Instance.new("Trail")
|
||||
trail.Attachment0, trail.Attachment1 = a0, a1
|
||||
trail.FaceCamera = true
|
||||
trail.Lifetime = 0.35
|
||||
trail.MinLength = 0.05
|
||||
trail.LightEmission = 0.7
|
||||
trail.Color = ColorSequence.new(TRAIL_COLOR)
|
||||
trail.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.1), NumberSequenceKeypoint.new(1, 1) })
|
||||
trail.WidthScale = NumberSequence.new({ NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(1, 0) })
|
||||
trail.Parent = part
|
||||
return trail
|
||||
end
|
||||
|
||||
local function showFishFlight(player, fish, fromPos)
|
||||
local head = player.Character and player.Character:FindFirstChild("Head")
|
||||
if not head then
|
||||
@@ -549,6 +573,14 @@ local function showFishFlight(player, fish, fromPos)
|
||||
local model = Models.buildFish(fish.id, fish.mutation, 0.9, true)
|
||||
model:PivotTo(CFrame.new(fromPos))
|
||||
model.Parent = workspace
|
||||
-- шлейф на отдельной невидимой детали: рыба крутится, а шлейф должен оставаться ровным
|
||||
local carrier = Instance.new("Part")
|
||||
carrier.Anchored, carrier.CanCollide, carrier.CanQuery, carrier.CanTouch = true, false, false, false
|
||||
carrier.Transparency = 1
|
||||
carrier.Size = Vector3.new(0.2, 0.2, 0.2)
|
||||
carrier.CFrame = CFrame.new(fromPos)
|
||||
carrier.Parent = model
|
||||
local trail = addTrail(carrier, 1.8)
|
||||
task.spawn(function()
|
||||
local t0, dur = os.clock(), 0.55
|
||||
while head.Parent do
|
||||
@@ -556,11 +588,13 @@ local function showFishFlight(player, fish, fromPos)
|
||||
local target = head.Position + Vector3.new(0, 2.8, 0)
|
||||
local p = fromPos:Lerp(target, a) + Vector3.new(0, math.sin(a * math.pi) * 8, 0)
|
||||
model:PivotTo(CFrame.new(p) * CFrame.Angles(0, 0, a * math.pi * 2))
|
||||
carrier.CFrame = CFrame.new(p)
|
||||
if a >= 1 then
|
||||
break
|
||||
end
|
||||
RunService.Heartbeat:Wait()
|
||||
end
|
||||
trail.Enabled = false
|
||||
local t1 = os.clock()
|
||||
while head.Parent and os.clock() - t1 < 1.8 do
|
||||
model:PivotTo(CFrame.new(head.Position + Vector3.new(0, 2.8, 0)) * CFrame.Angles(0, os.clock() * 3, math.rad(-15)))
|
||||
@@ -574,22 +608,59 @@ end
|
||||
|
||||
local fishing = {}
|
||||
|
||||
-- ищем воду перед игроком по карте мира из FishConfig (не зависит от террейна)
|
||||
local function findWater(hrp, world)
|
||||
local look = hrp.CFrame.LookVector * Vector3.new(1, 0, 1)
|
||||
if look.Magnitude < 0.01 then
|
||||
look = Vector3.new(0, 0, -1)
|
||||
-- ищем воду по карте мира из FishConfig (не зависит от террейна) в сторону центра ближайшего озера:
|
||||
-- сначала на дальности, которую задала сила заброса, потом всё дальше от неё
|
||||
local function findWater(hrp, world, power)
|
||||
local look = Config.CastDirection(world, hrp.Position)
|
||||
if not look then
|
||||
look = hrp.CFrame.LookVector * Vector3.new(1, 0, 1)
|
||||
look = look.Magnitude > 0.01 and look.Unit or Vector3.new(0, 0, -1)
|
||||
end
|
||||
look = look.Unit
|
||||
for _, d in ipairs({ 14, 11, 17, 8, 20, 6, 24, 4 }) do
|
||||
local p = hrp.Position + look * d
|
||||
if Config.IsWater(world, p) then
|
||||
return Vector3.new(p.X, world.waterY or 0, p.Z)
|
||||
local want = Config.CastMinDist + (Config.CastMaxDist - Config.CastMinDist) * power
|
||||
for off = 0, 26, 2 do
|
||||
for _, d in ipairs({ want - off, want + off }) do
|
||||
if d >= 4 and d <= Config.CastMaxDist + 2 then
|
||||
local p = hrp.Position + look * d
|
||||
if Config.IsWater(world, p) then
|
||||
return Vector3.new(p.X, world.waterY or 0, p.Z), d
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- вытягивание пустого поплавка: быстро летит к кончику удочки со шлейфом и исчезает
|
||||
local function reelBobber(bobber, tool)
|
||||
local root = bobber and bobber.PrimaryPart
|
||||
local tip = tool and tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip")
|
||||
if not root or not tip then
|
||||
if bobber then
|
||||
bobber:Destroy()
|
||||
end
|
||||
return
|
||||
end
|
||||
local trail = bobber:FindFirstChildWhichIsA("Trail", true)
|
||||
if trail then
|
||||
trail.Enabled = true
|
||||
else
|
||||
addTrail(root, 1.2)
|
||||
end
|
||||
local from = root.Position
|
||||
task.spawn(function()
|
||||
local t0, dur = os.clock(), 0.3
|
||||
while bobber.Parent and tip.Parent do
|
||||
local a = math.min(1, (os.clock() - t0) / dur)
|
||||
bobber:PivotTo(CFrame.new(from:Lerp(tip.WorldPosition, a) + Vector3.new(0, math.sin(a * math.pi) * 2.5, 0)))
|
||||
if a >= 1 then
|
||||
break
|
||||
end
|
||||
RunService.Heartbeat:Wait()
|
||||
end
|
||||
bobber:Destroy()
|
||||
end)
|
||||
end
|
||||
|
||||
local function stopFishing(player, tellClient)
|
||||
local s = fishing[player]
|
||||
if not s then
|
||||
@@ -600,7 +671,11 @@ local function stopFishing(player, tellClient)
|
||||
s.tween:Cancel()
|
||||
end
|
||||
if s.bobber then
|
||||
s.bobber:Destroy()
|
||||
if s.stage == "casting" then
|
||||
s.bobber:Destroy() -- ещё летит: его двигает flyBobber
|
||||
else
|
||||
reelBobber(s.bobber, s.tool)
|
||||
end
|
||||
end
|
||||
if s.tool then
|
||||
tweenGrip(s.tool, REST_ANGLE, 0.3)
|
||||
@@ -610,12 +685,12 @@ local function stopFishing(player, tellClient)
|
||||
end
|
||||
end
|
||||
|
||||
local function rollFish(player, data, worldId)
|
||||
local function rollFish(player, data, worldId, luckMult)
|
||||
local zone = Config.Zones[worldId]
|
||||
if not zone then
|
||||
return nil
|
||||
end
|
||||
local luck = totalLuck(player, data)
|
||||
local luck = totalLuck(player, data) * (luckMult or 1)
|
||||
local bonus = luck - 1
|
||||
local weights, total = {}, 0
|
||||
for i, f in ipairs(zone.fish) do
|
||||
@@ -657,13 +732,14 @@ local function rollFish(player, data, worldId)
|
||||
}
|
||||
end
|
||||
|
||||
local function flyBobber(s, tool, target)
|
||||
local function flyBobber(s, tool, target, dur, arc)
|
||||
local tip = tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip")
|
||||
local start = tip and tip.WorldPosition or (target + Vector3.new(0, 6, 0))
|
||||
local bobber = Models.buildBobber()
|
||||
bobber:PivotTo(CFrame.new(start))
|
||||
bobber.Parent = workspace
|
||||
s.bobber = bobber
|
||||
local trail = addTrail(bobber.PrimaryPart, 1.2)
|
||||
if tip then
|
||||
local a1 = Instance.new("Attachment")
|
||||
a1.Position = Vector3.new(0, 0.9, 0)
|
||||
@@ -677,22 +753,24 @@ local function flyBobber(s, tool, target)
|
||||
line.Color = ColorSequence.new(Color3.fromRGB(245, 245, 245))
|
||||
line.Parent = bobber
|
||||
end
|
||||
local t0, dur = os.clock(), 0.55
|
||||
local t0 = os.clock()
|
||||
while bobber.Parent do
|
||||
local a = math.min(1, (os.clock() - t0) / dur)
|
||||
bobber:PivotTo(CFrame.new(start:Lerp(target, a) + Vector3.new(0, math.sin(a * math.pi) * 6, 0)))
|
||||
bobber:PivotTo(CFrame.new(start:Lerp(target, a) + Vector3.new(0, math.sin(a * math.pi) * arc, 0)))
|
||||
if a >= 1 then
|
||||
break
|
||||
end
|
||||
RunService.Heartbeat:Wait()
|
||||
end
|
||||
trail.Enabled = false -- на воде поплавок качается, шлейф уже не нужен
|
||||
if bobber.Parent then
|
||||
splash(bobber.PrimaryPart, 18)
|
||||
playSound(bobber.PrimaryPart, SPLASH_SOUND, 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
local function onCast(player)
|
||||
local function onCast(player, power)
|
||||
power = math.clamp(tonumber(power) or 0.6, 0, 1)
|
||||
local data = profiles[player]
|
||||
if not data then
|
||||
return
|
||||
@@ -709,10 +787,13 @@ local function onCast(player)
|
||||
return
|
||||
end
|
||||
local world = Config.WorldAt(hrp.Position)
|
||||
local target = world and findWater(hrp, world)
|
||||
local target, dist = nil, 0
|
||||
if world then
|
||||
target, dist = findWater(hrp, world, power)
|
||||
end
|
||||
if not target then
|
||||
remote:FireClient(player, "CastFail")
|
||||
notify(player, world and "Повернись лицом к воде (или к лунке)!" or "Здесь нет рыбы — иди в один из миров 🌍", Color3.fromRGB(255, 200, 120))
|
||||
notify(player, world and "Подойди ближе к воде (или к лунке)!" or "Здесь нет рыбы — иди в один из миров 🌍", Color3.fromRGB(255, 200, 120))
|
||||
return
|
||||
end
|
||||
if #data.items >= bagCapacity(player, data) then
|
||||
@@ -722,29 +803,28 @@ local function onCast(player)
|
||||
end
|
||||
|
||||
local stats = Config.RodStats(data.rod, rodLevel(data))
|
||||
local fish = rollFish(player, data, world.id)
|
||||
local perfect = power >= Config.CastPerfect[1] and power <= Config.CastPerfect[2]
|
||||
local fish = rollFish(player, data, world.id, perfect and Config.CastPerfectLuck or 1)
|
||||
if not fish then
|
||||
remote:FireClient(player, "CastFail")
|
||||
return
|
||||
end
|
||||
local s = { stage = "casting", fish = fish, tool = tool }
|
||||
fishing[player] = s
|
||||
remote:FireClient(player, "Cast", target + Vector3.new(0, 0.15, 0)) -- клиенту для камеры
|
||||
-- замах игрок уже сделал, пока держал кнопку (у себя на клиенте); здесь только бросок вперёд
|
||||
local throw = { windup = 0.15, flight = 0.35 + dist * 0.018, arc = 2 + dist * 0.3, perfect = perfect }
|
||||
local splashAt = target + Vector3.new(0, 0.15, 0)
|
||||
remote:FireClient(player, "Cast", splashAt, throw) -- клиенту для камеры
|
||||
|
||||
task.spawn(function()
|
||||
-- замах назад и бросок вперёд
|
||||
local tw = tweenGrip(tool, 100, 0.25)
|
||||
if tw then
|
||||
tw.Completed:Wait()
|
||||
end
|
||||
tw = tweenGrip(tool, 8, 0.15)
|
||||
local tw = tweenGrip(tool, 8, throw.windup)
|
||||
if tw then
|
||||
tw.Completed:Wait()
|
||||
end
|
||||
if fishing[player] ~= s then
|
||||
return
|
||||
end
|
||||
flyBobber(s, tool, target + Vector3.new(0, 0.15, 0))
|
||||
flyBobber(s, tool, splashAt, throw.flight, throw.arc)
|
||||
tweenGrip(tool, REST_ANGLE - 5, 0.4)
|
||||
if fishing[player] ~= s then
|
||||
if s.bobber then
|
||||
@@ -809,11 +889,14 @@ local function onCatch(player, success, misses)
|
||||
if s.tween then
|
||||
s.tween:Cancel()
|
||||
end
|
||||
if s.bobber then
|
||||
s.bobber:Destroy()
|
||||
local failed = success ~= true or os.clock() - s.biteAt > Config.BiteTimeout + 1
|
||||
if failed then
|
||||
reelBobber(s.bobber, tool)
|
||||
elseif s.bobber then
|
||||
s.bobber:Destroy() -- вместо поплавка к игроку летит рыба
|
||||
end
|
||||
|
||||
if success ~= true or os.clock() - s.biteAt > Config.BiteTimeout + 1 then
|
||||
if failed then
|
||||
gripSequence(tool, { { REST_ANGLE, 0.3 } })
|
||||
remote:FireClient(player, "Escaped")
|
||||
notify(player, "Рыба сорвалась!", RED)
|
||||
@@ -1094,7 +1177,15 @@ end)
|
||||
|
||||
remote.OnServerEvent:Connect(function(player, action, a, b)
|
||||
if action == "Cast" then
|
||||
onCast(player)
|
||||
onCast(player, a)
|
||||
elseif action == "Tutorial" then
|
||||
-- шаги обучения идут только вперёд
|
||||
local data = profiles[player]
|
||||
local step = math.floor(tonumber(a) or 0)
|
||||
if data and step > (player:GetAttribute("Tutorial") or 0) and step <= Config.TutorialDone then
|
||||
data.tutorial = step
|
||||
player:SetAttribute("Tutorial", step)
|
||||
end
|
||||
elseif action == "Catch" then
|
||||
onCatch(player, a, b)
|
||||
elseif action == "Cancel" then
|
||||
|
||||
@@ -677,6 +677,9 @@ for i, w in ipairs(Config.Worlds) do
|
||||
local a = math.rad(90 - (i - 1) * 90) -- 90° = сторона спавна (+Z)
|
||||
local pos = V(math.cos(a) * PORTAL_R, FLOOR, math.sin(a) * PORTAL_R)
|
||||
portal(CFrame.lookAt(pos, V(pos.X * 2, FLOOR, pos.Z * 2)), title, w.color, w.id, w.soon)
|
||||
if i == 1 then
|
||||
marker("GuidePortal", CFrame.new(pos.X * 1.3, FLOOR, pos.Z * 1.3)) -- точка перед порталом для линии-подсказки
|
||||
end
|
||||
end
|
||||
|
||||
-- невидимая стена по кругу: из лобби не уйти
|
||||
@@ -761,12 +764,13 @@ do
|
||||
local pos = V(-12, FLOOR, 48)
|
||||
local cf = CFrame.lookAt(pos, V(0, FLOOR, 64))
|
||||
lamp((cf * CFrame.new(0, 0, 2.5)).Position)
|
||||
marker("GuideBoard", cf * CFrame.new(0, 0, -6)) -- перед табличкой, для линии-подсказки
|
||||
for _, x in ipairs({ -6.5, 6.5 }) do
|
||||
P({ Size = V(0.8, 9, 0.8), CFrame = cf * CFrame.new(x, 4.5, 0.3), Material = Enum.Material.Wood, Color = Color3.fromRGB(90, 60, 40) })
|
||||
end
|
||||
local board = P({ Size = V(14, 8, 0.5), CFrame = cf * CFrame.new(0, 6, 0), Material = Enum.Material.WoodPlanks, Color = Color3.fromRGB(70, 48, 32) })
|
||||
surfaceText(board, Enum.NormalId.Front,
|
||||
"<font color=\"#FFD866\">КАК ИГРАТЬ</font>\n1. Портал «Мир 1» или кнопка 🌍 Миры\n2. Удочка — клавиша 1, клик у воды\n3. Клюёт → кликай в зелёную зону\n4. 🎒 Сумка — B, 📜 Задания — Q\n5. Собирай коллекцию — получай награды!",
|
||||
"<font color=\"#FFD866\">КАК ИГРАТЬ</font>\n1. Портал «Мир 1» или кнопка 🌍 Миры\n2. Удочка — клавиша 1, у воды зажми ЛКМ и отпусти\n3. Клюёт → кликай в зелёную зону\n4. 🎒 Сумка — B, 📜 Задания — Q\n5. Собирай коллекцию — получай награды!",
|
||||
Color3.fromRGB(255, 245, 225), { TextXAlignment = Enum.TextXAlignment.Left })
|
||||
end
|
||||
|
||||
@@ -787,6 +791,9 @@ local arrive = W + V(0, GROUND_Y, 94)
|
||||
marker("World1Spawn", CFrame.lookAt(arrive + V(0, 1, 0), arrive + V(0, 1, -10)))
|
||||
arch(CFrame.new(W + V(0, GROUND_Y, 82)), 14, 11, "🌊 ТИХОЕ ОЗЕРО", Color3.fromRGB(80, 200, 255))
|
||||
portal(CFrame.lookAt(W + V(-22, GROUND_Y, 96), arrive), "🏠 В лобби", Color3.fromRGB(255, 200, 80), "Lobby")
|
||||
-- точки для линии-подсказки: конец главного причала и место перед скупкой
|
||||
marker("GuideFishSpot", CFrame.new(W + V(0, GROUND_Y + 0.5, 42)))
|
||||
marker("GuideSell", CFrame.lookAt(W + V(26, GROUND_Y, 98), arrive) * CFrame.new(0, 0, -10))
|
||||
stall(CFrame.lookAt(W + V(26, GROUND_Y, 98), arrive), {
|
||||
title = "💰 СКУПКА",
|
||||
titleColor = Color3.fromRGB(150, 255, 160),
|
||||
|
||||
Reference in new issue
Block a user