213
This commit is contained in:
1 parent
8434f61030
commit
ec69c6c8d7
10 files changed
+2268
-336
No files matched your search
@@ -220,6 +220,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, ","))
|
||||
|
||||
@@ -542,6 +544,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
|
||||
@@ -550,6 +574,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
|
||||
@@ -557,11 +589,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)))
|
||||
@@ -575,22 +609,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
|
||||
@@ -601,7 +672,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)
|
||||
@@ -611,12 +686,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
|
||||
@@ -658,13 +733,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)
|
||||
@@ -678,22 +754,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
|
||||
@@ -710,10 +788,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
|
||||
@@ -723,29 +804,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
|
||||
@@ -810,11 +890,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)
|
||||
@@ -1095,7 +1178,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
|
||||
|
||||
Reference in new issue
Block a user