Update
This commit is contained in:
1 parent
f316a9bf0c
commit
9fcbd8bc0b
38 files changed
+29208
-4904
No files matched your search
@@ -42,7 +42,7 @@ local function defaultData()
|
||||
rod = "Basic", rods = { Basic = true }, rodLevels = {},
|
||||
bag = "Pouch", bags = { Pouch = true },
|
||||
items = {}, discovered = {}, claimed = {},
|
||||
quests = {}, daily = { last = 0, streak = 0 },
|
||||
chain = { index = 1, step = 1, progress = 0, tier = 0 }, daily = { last = 0, streak = 0 },
|
||||
boostUntil = 0, boostBonus = 0,
|
||||
totalCaught = 0, nextUid = 1, receipts = {},
|
||||
}
|
||||
@@ -169,13 +169,58 @@ local function sendInventory(player)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- цепочки заданий
|
||||
|
||||
local function levelMult(data)
|
||||
return 1 + (data.level - 1) * 0.25
|
||||
end
|
||||
|
||||
local function currentChain(data)
|
||||
local c = data.chain
|
||||
local chain = Config.QuestChains[(c.index - 1) % #Config.QuestChains + 1]
|
||||
return chain, chain.steps[c.step]
|
||||
end
|
||||
|
||||
local function stepGoal(data, step)
|
||||
local kind = Config.QuestKinds[step[1]]
|
||||
local g = step[2] * (1 + Config.QuestTierGrowth * data.chain.tier)
|
||||
if kind.byLevel then
|
||||
g *= levelMult(data)
|
||||
end
|
||||
g = math.ceil(g)
|
||||
return kind.max and math.min(g, kind.max) or g
|
||||
end
|
||||
|
||||
local function stepReward(data, step, goal)
|
||||
local kind = Config.QuestKinds[step[1]]
|
||||
local m = levelMult(data)
|
||||
return math.max(10, math.floor(kind.coins * goal * m)), math.max(10, math.floor(kind.xp * goal * m))
|
||||
end
|
||||
|
||||
local function chainBonus(data)
|
||||
local b = Config.ChainBonus
|
||||
local m = levelMult(data) * (1 + Config.QuestTierGrowth * data.chain.tier)
|
||||
return math.floor(b.coins * m), math.floor(b.xp * m), b.potion and Config.Find(Config.Potions, b.potion)
|
||||
end
|
||||
|
||||
local function sendQuests(player)
|
||||
local data = profiles[player]
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
local chain = currentChain(data)
|
||||
local steps = {}
|
||||
for i, st in ipairs(chain.steps) do
|
||||
local goal = stepGoal(data, st)
|
||||
local coins, xp = stepReward(data, st, goal)
|
||||
steps[i] = { kind = st[1], goal = goal, coins = coins, xp = xp }
|
||||
end
|
||||
local bCoins, bXp, potion = chainBonus(data)
|
||||
local t = today()
|
||||
remote:FireClient(player, "Quests", data.quests, {
|
||||
remote:FireClient(player, "Quests", {
|
||||
name = chain.name, round = data.chain.tier + 1, step = data.chain.step, progress = data.chain.progress,
|
||||
steps = steps, bonus = { coins = bCoins, xp = bXp, potion = potion and potion.name },
|
||||
}, {
|
||||
available = data.daily.last < t,
|
||||
streak = data.daily.streak,
|
||||
nextStreak = (data.daily.last == t - 1) and (data.daily.streak % 7 + 1) or ((data.daily.last < t) and 1 or data.daily.streak),
|
||||
@@ -220,6 +265,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, ","))
|
||||
|
||||
@@ -240,10 +287,10 @@ local function addXp(player, data, amount)
|
||||
leveled = true
|
||||
end
|
||||
if leveled then
|
||||
notify(player, "⭐ Новый уровень: " .. data.level .. "! Удача +" .. math.floor(Config.LuckPerPlayerLevel * 100) .. "%", GOLD)
|
||||
notify(player, "⭐ Уровень " .. data.level .. "!", GOLD)
|
||||
for _, w in ipairs(Config.Worlds) do
|
||||
if w.level == data.level and not w.soon then
|
||||
notify(player, "🌍 Открыт новый мир: " .. w.icon .. " " .. w.name .. "!", w.color)
|
||||
notify(player, "🌍 Открыт: " .. w.icon .. " " .. w.name, w.color)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -254,79 +301,54 @@ local function applyPotion(data, bonus, duration)
|
||||
data.boostUntil = math.max(os.time(), data.boostUntil) + duration
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- задания
|
||||
---------------------------------------------------------------- задания: прогресс цепочки
|
||||
|
||||
local function makeQuest(data, exclude)
|
||||
local pool = {}
|
||||
for _, q in ipairs(Config.Quests) do
|
||||
if not exclude[q.kind] then
|
||||
table.insert(pool, q)
|
||||
end
|
||||
-- у старых сохранений вместо цепочки были три случайных задания
|
||||
local function ensureChain(data)
|
||||
if type(data.chain) ~= "table" then
|
||||
data.chain = { index = 1, step = 1, progress = 0, tier = 0 }
|
||||
end
|
||||
if #pool == 0 then
|
||||
pool = Config.Quests
|
||||
end
|
||||
local t = pool[rng:NextInteger(1, #pool)]
|
||||
local goal = t.goals[rng:NextInteger(1, #t.goals)]
|
||||
local mult = 1 + (data.level - 1) * 0.25
|
||||
return {
|
||||
kind = t.kind, goal = goal, progress = 0,
|
||||
coins = math.max(10, math.floor(t.coins * goal * mult)),
|
||||
xp = math.max(10, math.floor(t.xp * goal * mult)),
|
||||
}
|
||||
data.quests = nil
|
||||
end
|
||||
|
||||
local function ensureQuests(data)
|
||||
local kinds = {}
|
||||
for _, q in ipairs(data.quests) do
|
||||
kinds[q.kind] = true
|
||||
end
|
||||
while #data.quests < Config.QuestSlots do
|
||||
local q = makeQuest(data, kinds)
|
||||
kinds[q.kind] = true
|
||||
table.insert(data.quests, q)
|
||||
end
|
||||
end
|
||||
|
||||
local function questProgress(player, kind, amount)
|
||||
-- absolute = true: amount — текущее значение (серия), а не прибавка
|
||||
local function questProgress(player, kind, amount, absolute)
|
||||
local data = profiles[player]
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
local changed = false
|
||||
for _, q in ipairs(data.quests) do
|
||||
if q.kind == kind and q.progress < q.goal then
|
||||
q.progress = math.min(q.goal, q.progress + amount)
|
||||
changed = true
|
||||
if q.progress >= q.goal then
|
||||
notify(player, "📜 Задание выполнено! Забери награду (клавиша Q)", GOLD)
|
||||
end
|
||||
end
|
||||
end
|
||||
if changed then
|
||||
sendQuests(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function claimQuest(player, index)
|
||||
local data = profiles[player]
|
||||
local q = data and type(index) == "number" and data.quests[index]
|
||||
if not q or q.progress < q.goal then
|
||||
local chain, step = currentChain(data)
|
||||
if step[1] ~= kind then
|
||||
return
|
||||
end
|
||||
data.coins += q.coins
|
||||
addXp(player, data, q.xp)
|
||||
local kinds = {}
|
||||
for i, other in ipairs(data.quests) do
|
||||
if i ~= index then
|
||||
kinds[other.kind] = true
|
||||
local c = data.chain
|
||||
c.progress = absolute and math.max(c.progress, amount) or c.progress + amount
|
||||
local goal = stepGoal(data, step)
|
||||
if c.progress >= goal then
|
||||
-- награда сразу, следующий шаг тоже сразу
|
||||
local coins, xp = stepReward(data, step, goal)
|
||||
data.coins += coins
|
||||
addXp(player, data, xp)
|
||||
remote:FireClient(player, "QuestDone", kind, goal, coins, xp)
|
||||
c.step += 1
|
||||
c.progress = 0
|
||||
if c.step > #chain.steps then
|
||||
local bCoins, bXp, potion = chainBonus(data)
|
||||
data.coins += bCoins
|
||||
addXp(player, data, bXp)
|
||||
if potion then
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
end
|
||||
remote:FireClient(player, "ChainDone", chain.name, bCoins, bXp, potion and potion.name)
|
||||
c.index += 1
|
||||
c.step = 1
|
||||
if (c.index - 1) % #Config.QuestChains == 0 then
|
||||
c.tier += 1
|
||||
end
|
||||
end
|
||||
updateStats(player)
|
||||
end
|
||||
kinds[q.kind] = true
|
||||
data.quests[index] = makeQuest(data, kinds)
|
||||
updateStats(player)
|
||||
sendQuests(player)
|
||||
notify(player, ("📜 Награда: +%d 💰 +%d XP"):format(q.coins, q.xp), GREEN)
|
||||
end
|
||||
|
||||
local function claimDaily(player)
|
||||
@@ -336,7 +358,7 @@ local function claimDaily(player)
|
||||
end
|
||||
local t = today()
|
||||
if data.daily.last >= t then
|
||||
notify(player, "🎁 Сегодня награда уже получена. Приходи завтра!", Color3.fromRGB(255, 200, 120))
|
||||
notify(player, "🎁 Приходи завтра", Color3.fromRGB(255, 200, 120))
|
||||
return
|
||||
end
|
||||
local streak = (data.daily.last == t - 1) and (data.daily.streak % 7 + 1) or 1
|
||||
@@ -372,7 +394,7 @@ local function claimCollection(player, worldId, rarity)
|
||||
end
|
||||
for _, f in ipairs(zone.fish) do
|
||||
if (rarity == "Master" or f.rarity == rarity) and not data.discovered[f.id] then
|
||||
notify(player, "Сначала поймай всех рыб этой группы!", RED)
|
||||
notify(player, "Сначала поймай всех", RED)
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -380,7 +402,7 @@ local function claimCollection(player, worldId, rarity)
|
||||
if rarity == "Master" then
|
||||
local coins = Config.MasteryCoins * world.mult
|
||||
data.coins += coins
|
||||
notify(player, ("🏆 Мир «%s» собран! +%d 💰 и +%d%% удачи навсегда"):format(world.name, coins, math.floor(Config.MasteryLuck * 100 + 0.5)), GOLD)
|
||||
notify(player, ("🏆 «%s» собран! +%d 💰"):format(world.name, coins), GOLD)
|
||||
else
|
||||
local r = Config.CollectionRewards[rarity]
|
||||
if not r then
|
||||
@@ -388,7 +410,7 @@ local function claimCollection(player, worldId, rarity)
|
||||
end
|
||||
data.coins += r.coins * world.mult
|
||||
addXp(player, data, r.xp * world.mult)
|
||||
notify(player, ("📖 Коллекция «%s»: +%d 💰 +%d XP"):format(Config.Rarities[rarity].name, r.coins * world.mult, r.xp * world.mult), GREEN)
|
||||
notify(player, ("📖 +%d 💰 +%d XP"):format(r.coins * world.mult, r.xp * world.mult), GREEN)
|
||||
end
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
@@ -542,6 +564,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 +594,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 +609,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 +629,87 @@ 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)
|
||||
-- серия улова (на время игры, не сохраняется)
|
||||
local combo, comboUntil = {}, {}
|
||||
local function setCombo(player, n)
|
||||
combo[player] = n
|
||||
comboUntil[player] = n > 0 and os.time() + Config.Combo.timeout or nil
|
||||
player:SetAttribute("Combo", n)
|
||||
player:SetAttribute("ComboEnds", n > 0 and workspace:GetServerTimeNow() + Config.Combo.timeout or nil)
|
||||
end
|
||||
local function breakCombo(player)
|
||||
if (combo[player] or 0) >= 2 then
|
||||
remote:FireClient(player, "ComboLost", combo[player])
|
||||
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)
|
||||
setCombo(player, 0)
|
||||
end
|
||||
|
||||
-- босс озера: { world, def, hp, max, dmg = { [player] = урон } }
|
||||
local boss = nil
|
||||
local function bossHit(player, world, dmg)
|
||||
if not boss or boss.hp <= 0 or not world or world.id ~= boss.world.id then
|
||||
return
|
||||
end
|
||||
boss.hp = math.max(0, boss.hp - dmg)
|
||||
boss.dmg[player] = (boss.dmg[player] or 0) + dmg
|
||||
workspace:SetAttribute("BossHP", boss.hp)
|
||||
remote:FireClient(player, "BossHit", dmg)
|
||||
questProgress(player, "boss", dmg)
|
||||
end
|
||||
|
||||
-- ищем воду по карте мира из 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
|
||||
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 +720,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 +734,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 +781,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 +802,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,42 +836,47 @@ local function onCast(player)
|
||||
return
|
||||
end
|
||||
local world = Config.WorldAt(hrp.Position)
|
||||
local target = world and findWater(hrp, world)
|
||||
local can = Config.CanCastFrom(world, hrp.Position)
|
||||
if can ~= true then
|
||||
remote:FireClient(player, "CastFail")
|
||||
notify(player, can, Color3.fromRGB(255, 200, 120))
|
||||
return
|
||||
end
|
||||
local target, dist = findWater(hrp, world, power)
|
||||
if not target then
|
||||
remote:FireClient(player, "CastFail")
|
||||
notify(player, world and "Повернись лицом к воде (или к лунке)!" or "Здесь нет рыбы — иди в один из миров 🌍", Color3.fromRGB(255, 200, 120))
|
||||
notify(player, "🌊 Подойди к воде", Color3.fromRGB(255, 200, 120))
|
||||
return
|
||||
end
|
||||
if #data.items >= bagCapacity(player, data) then
|
||||
remote:FireClient(player, "CastFail")
|
||||
notify(player, "🎒 Сумка полна! Продай рыбу в скупке.", RED)
|
||||
notify(player, "🎒 Сумка полна!", RED)
|
||||
return
|
||||
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 }
|
||||
local s = { stage = "casting", fish = fish, tool = tool, perfect = perfect }
|
||||
fishing[player] = s
|
||||
remote:FireClient(player, "Cast")
|
||||
-- замах игрок уже сделал, пока держал кнопку (у себя на клиенте); здесь только бросок вперёд
|
||||
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
|
||||
@@ -792,7 +923,8 @@ local function onCast(player)
|
||||
if fishing[player] == s and s.stage == "bite" then
|
||||
stopFishing(player, false)
|
||||
remote:FireClient(player, "Escaped")
|
||||
notify(player, "Рыба ушла… не успел вытащить.", RED)
|
||||
notify(player, "🐟 Рыба ушла", RED)
|
||||
breakCombo(player)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -810,19 +942,29 @@ 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)
|
||||
notify(player, "🐟 Сорвалась!", RED)
|
||||
breakCombo(player)
|
||||
return
|
||||
end
|
||||
gripSequence(tool, { { 85, 0.15 }, { REST_ANGLE, 0.45 } })
|
||||
|
||||
-- серия: каждая рыба подряд дороже и даёт больше опыта
|
||||
local fish = s.fish
|
||||
local streak = combo[player] or 0
|
||||
local comboMult = math.min(Config.Combo.max, 1 + Config.Combo.step * streak)
|
||||
fish.value = math.floor(fish.value * comboMult + 0.5)
|
||||
fish.xp = math.floor(fish.xp * comboMult + 0.5)
|
||||
setCombo(player, streak + 1)
|
||||
table.insert(data.items, {
|
||||
uid = data.nextUid, id = fish.id, name = fish.name, rarity = fish.rarity,
|
||||
weight = fish.weight, value = fish.value, mutation = fish.mutation,
|
||||
@@ -848,22 +990,26 @@ local function onCatch(player, success, misses)
|
||||
if fromPos then
|
||||
showFishFlight(player, fish, fromPos)
|
||||
end
|
||||
remote:FireClient(player, "Caught", fish, { new = isNew, record = isRecord })
|
||||
remote:FireClient(player, "Caught", fish, { new = isNew, record = isRecord, combo = comboMult, streak = streak + 1 })
|
||||
|
||||
local rank = Config.Rarities[fish.rarity].rank
|
||||
questProgress(player, "catch", 1)
|
||||
if rank >= 2 then
|
||||
questProgress(player, "uncommon", 1)
|
||||
end
|
||||
if rank >= 3 then
|
||||
questProgress(player, "rare", 1)
|
||||
end
|
||||
if rank >= 4 then
|
||||
questProgress(player, "epic", 1)
|
||||
end
|
||||
if fish.mutation then
|
||||
questProgress(player, "mutation", 1)
|
||||
end
|
||||
if misses == 0 then
|
||||
questProgress(player, "perfect", 1)
|
||||
end
|
||||
if s.perfect then
|
||||
questProgress(player, "perfectCast", 1)
|
||||
end
|
||||
questProgress(player, "combo", streak + 1, true)
|
||||
|
||||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
bossHit(player, hrp and Config.WorldAt(hrp.Position), rank + (misses == 0 and 1 or 0))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- скупка
|
||||
@@ -910,7 +1056,7 @@ local function sellItems(player, filterUid)
|
||||
end
|
||||
if count == 0 then
|
||||
if filterUid == nil then
|
||||
notify(player, "Нечего продавать — сначала поймай рыбу!", Color3.fromRGB(255, 200, 120))
|
||||
notify(player, "🎒 Сумка пуста", Color3.fromRGB(255, 200, 120))
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -919,6 +1065,7 @@ local function sellItems(player, filterUid)
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
remote:FireClient(player, "Sold", total, count)
|
||||
questProgress(player, "sell", count)
|
||||
questProgress(player, "earn", total)
|
||||
end
|
||||
|
||||
@@ -936,12 +1083,12 @@ local function buy(player, kind, id)
|
||||
end
|
||||
local lvl = rodLevel(data, id)
|
||||
if lvl >= Config.RodUpgrade.maxLevel then
|
||||
notify(player, "Удочка уже улучшена до максимума ★★★★★", GOLD)
|
||||
notify(player, "★★★★★ Максимум", GOLD)
|
||||
return
|
||||
end
|
||||
local cost = Config.UpgradeCost(rod, lvl)
|
||||
if data.coins < cost then
|
||||
notify(player, "Не хватает монет: нужно " .. cost .. " 💰", RED)
|
||||
notify(player, "Нужно " .. cost .. " 💰", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= cost
|
||||
@@ -952,6 +1099,7 @@ local function buy(player, kind, id)
|
||||
end
|
||||
updateStats(player)
|
||||
notify(player, ("✨ %s улучшена до +%d!"):format(rod.name, lvl + 1), GOLD)
|
||||
questProgress(player, "buy", 1)
|
||||
return
|
||||
end
|
||||
if kind == "Potion" then
|
||||
@@ -960,17 +1108,18 @@ local function buy(player, kind, id)
|
||||
return
|
||||
end
|
||||
if potion.level and data.level < potion.level then
|
||||
notify(player, "Нужен уровень " .. potion.level .. "!", RED)
|
||||
notify(player, "🔒 Нужен ур. " .. potion.level, RED)
|
||||
return
|
||||
end
|
||||
if data.coins < potion.price then
|
||||
notify(player, "Не хватает монет: нужно " .. potion.price .. " 💰", RED)
|
||||
notify(player, "Нужно " .. potion.price .. " 💰", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= potion.price
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
updateStats(player)
|
||||
notify(player, ("🍀 %s: удача +%d%% на %d мин"):format(potion.name, potion.bonus * 100, potion.duration / 60), GREEN)
|
||||
notify(player, ("🍀 +%d%% удачи, %d мин"):format(potion.bonus * 100, potion.duration / 60), GREEN)
|
||||
questProgress(player, "buy", 1)
|
||||
return
|
||||
end
|
||||
local list, owned
|
||||
@@ -985,18 +1134,20 @@ local function buy(player, kind, id)
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
local bought = false
|
||||
if not owned[id] then
|
||||
if data.level < item.level then
|
||||
notify(player, "Нужен уровень " .. item.level .. "!", RED)
|
||||
notify(player, "🔒 Нужен ур. " .. item.level, RED)
|
||||
return
|
||||
end
|
||||
if data.coins < item.price then
|
||||
notify(player, "Не хватает монет: нужно " .. item.price .. " 💰", RED)
|
||||
notify(player, "Нужно " .. item.price .. " 💰", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= item.price
|
||||
owned[id] = true
|
||||
notify(player, "Куплено: " .. item.name .. "!", GREEN)
|
||||
bought = true
|
||||
notify(player, "✅ " .. item.name, GREEN)
|
||||
end
|
||||
if kind == "Rod" then
|
||||
data.rod = id
|
||||
@@ -1007,10 +1158,19 @@ local function buy(player, kind, id)
|
||||
attachBag(player)
|
||||
end
|
||||
updateStats(player)
|
||||
if bought then
|
||||
questProgress(player, "buy", 1)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- телепорт
|
||||
|
||||
local TELEPORT_FADE = 0.3 -- сколько клиент затемняет экран перед переносом
|
||||
local teleporting = {}
|
||||
Players.PlayerRemoving:Connect(function(p)
|
||||
teleporting[p] = nil
|
||||
end)
|
||||
|
||||
local function teleportTo(player, worldId)
|
||||
local data = profiles[player]
|
||||
local char = player.Character
|
||||
@@ -1026,20 +1186,28 @@ local function teleportTo(player, worldId)
|
||||
return
|
||||
end
|
||||
if world.soon then
|
||||
notify(player, world.icon .. " " .. world.name .. " скоро откроется! Следи за обновлениями.", world.color)
|
||||
notify(player, world.icon .. " " .. world.name .. " — скоро!", world.color)
|
||||
return
|
||||
end
|
||||
if data.level < world.level then
|
||||
notify(player, ("🔒 %s откроется на %d уровне"):format(world.name, world.level), RED)
|
||||
notify(player, ("🔒 %s: ур. %d"):format(world.name, world.level), RED)
|
||||
return
|
||||
end
|
||||
markerName = world.id .. "Spawn"
|
||||
end
|
||||
local map = workspace:FindFirstChild("FishingMap")
|
||||
local m = map and map:FindFirstChild(markerName)
|
||||
if m then
|
||||
local m = map and map:FindFirstChild(markerName, true) -- маркеры могут лежать в папках уровня (World1Map)
|
||||
if m and not teleporting[player] then
|
||||
-- клиент затемняет экран, переносим уже в темноте: свет новой локации ставится до того, как её видно
|
||||
teleporting[player] = true
|
||||
stopFishing(player, true)
|
||||
char:PivotTo(m.CFrame + Vector3.new(0, 3, 0))
|
||||
remote:FireClient(player, "TeleportFade", worldId, TELEPORT_FADE)
|
||||
task.wait(TELEPORT_FADE)
|
||||
teleporting[player] = nil
|
||||
char = player.Character
|
||||
if char and char.Parent then
|
||||
char:PivotTo(m.CFrame + Vector3.new(0, 3, 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1095,7 +1263,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
|
||||
@@ -1109,20 +1285,18 @@ remote.OnServerEvent:Connect(function(player, action, a, b)
|
||||
if nearSeller(player) then
|
||||
sellItems(player, a)
|
||||
else
|
||||
notify(player, "Продавать можно только у скупщика 💰", Color3.fromRGB(255, 200, 120))
|
||||
notify(player, "💰 Только у скупщика", Color3.fromRGB(255, 200, 120))
|
||||
end
|
||||
elseif action == "SellAll" then
|
||||
if nearSeller(player) then
|
||||
sellItems(player, nil)
|
||||
else
|
||||
notify(player, "Продавать можно только у скупщика 💰", Color3.fromRGB(255, 200, 120))
|
||||
notify(player, "💰 Только у скупщика", Color3.fromRGB(255, 200, 120))
|
||||
end
|
||||
elseif action == "Teleport" then
|
||||
teleportTo(player, a)
|
||||
elseif action == "ClaimCollection" then
|
||||
claimCollection(player, a, b)
|
||||
elseif action == "ClaimQuest" then
|
||||
claimQuest(player, a)
|
||||
elseif action == "ClaimDaily" then
|
||||
claimDaily(player)
|
||||
elseif action == "RequestInventory" then
|
||||
@@ -1141,7 +1315,7 @@ MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, passI
|
||||
if gp.id == passId then
|
||||
passes[player] = passes[player] or {}
|
||||
passes[player][gp.key] = true
|
||||
notify(player, "Спасибо за покупку! " .. gp.icon .. " " .. gp.name .. " активирован", GOLD)
|
||||
notify(player, "✅ " .. gp.icon .. " " .. gp.name, GOLD)
|
||||
if gp.key == "VIP" then
|
||||
vipTag(player)
|
||||
end
|
||||
@@ -1177,7 +1351,7 @@ MarketplaceService.ProcessReceipt = function(info)
|
||||
end
|
||||
if product.boost then
|
||||
applyPotion(data, product.boost, product.duration)
|
||||
notify(player, ("Спасибо! Удача +%d%% на %d мин"):format(product.boost * 100, product.duration / 60), GOLD)
|
||||
notify(player, ("🍀 +%d%% удачи, %d мин"):format(product.boost * 100, product.duration / 60), GOLD)
|
||||
end
|
||||
table.insert(data.receipts, info.PurchaseId)
|
||||
if #data.receipts > 50 then
|
||||
@@ -1197,7 +1371,7 @@ task.spawn(function()
|
||||
workspace:SetAttribute("Event", currentEvent.id)
|
||||
workspace:SetAttribute("EventEnds", workspace:GetServerTimeNow() + currentEvent.duration)
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
notify(p, "🎉 Событие: " .. currentEvent.name .. " — " .. currentEvent.desc, GOLD)
|
||||
notify(p, "🎉 " .. currentEvent.name, GOLD)
|
||||
updateStats(p)
|
||||
end
|
||||
task.wait(currentEvent.duration)
|
||||
@@ -1210,6 +1384,105 @@ task.spawn(function()
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------- босс озера
|
||||
|
||||
local function playerWorld(p)
|
||||
local hrp = p.Character and p.Character:FindFirstChild("HumanoidRootPart")
|
||||
return hrp and Config.WorldAt(hrp.Position)
|
||||
end
|
||||
|
||||
local function setBossAttrs()
|
||||
workspace:SetAttribute("BossWorld", boss and boss.world.id or nil)
|
||||
workspace:SetAttribute("BossName", boss and boss.def.name or nil)
|
||||
workspace:SetAttribute("BossHP", boss and boss.hp or nil)
|
||||
workspace:SetAttribute("BossMax", boss and boss.max or nil)
|
||||
workspace:SetAttribute("BossEnds", boss and boss.ends or nil)
|
||||
end
|
||||
|
||||
local function finishBoss(won)
|
||||
local b = boss
|
||||
boss = nil
|
||||
setBossAttrs()
|
||||
local helpers, best, bestDmg = 0, nil, 0
|
||||
for p, d in pairs(b.dmg) do
|
||||
if p.Parent then
|
||||
helpers += 1
|
||||
if d > bestDmg then
|
||||
best, bestDmg = p, d
|
||||
end
|
||||
end
|
||||
end
|
||||
if not won then
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
remote:FireClient(p, "BossDone", false, b.def.name)
|
||||
end
|
||||
return
|
||||
end
|
||||
local R = Config.Boss.reward
|
||||
local fair = b.max / math.max(1, helpers) -- «честная доля» урона на одного
|
||||
local potion = R.potion and Config.Find(Config.Potions, R.potion)
|
||||
for p, d in pairs(b.dmg) do
|
||||
local data = p.Parent and profiles[p]
|
||||
if data then
|
||||
local share = 0.4 + 0.6 * math.min(1, d / fair)
|
||||
local coins = math.floor(R.coins * b.world.mult * share * levelMult(data))
|
||||
local xp = math.floor(R.xp * b.world.mult * share)
|
||||
data.coins += coins
|
||||
addXp(p, data, xp)
|
||||
if potion then
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
end
|
||||
updateStats(p)
|
||||
remote:FireClient(p, "BossReward", coins, xp, potion and potion.name)
|
||||
end
|
||||
end
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
remote:FireClient(p, "BossDone", true, b.def.name, best and best.DisplayName, bestDmg)
|
||||
end
|
||||
end
|
||||
|
||||
task.spawn(function()
|
||||
task.wait(Config.Boss.firstDelay)
|
||||
while true do
|
||||
-- мир, где сейчас больше всего игроков
|
||||
local counts = {}
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
local w = playerWorld(p)
|
||||
if w and Config.Boss.worlds[w.id] then
|
||||
counts[w.id] = (counts[w.id] or 0) + 1
|
||||
end
|
||||
end
|
||||
local bestId, n = nil, 0
|
||||
for id, c in pairs(counts) do
|
||||
if c > n then
|
||||
bestId, n = id, c
|
||||
end
|
||||
end
|
||||
if not bestId then
|
||||
task.wait(30) -- никого нет в мирах: попробуем позже
|
||||
else
|
||||
local world = Config.Find(Config.Worlds, bestId)
|
||||
local max = Config.Boss.hpPerPlayer * n
|
||||
boss = {
|
||||
world = world, def = Config.Boss.worlds[bestId], hp = max, max = max, dmg = {},
|
||||
ends = workspace:GetServerTimeNow() + Config.Boss.duration,
|
||||
}
|
||||
setBossAttrs()
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
remote:FireClient(p, "BossStart", boss.def.name, world.icon .. " " .. world.name)
|
||||
end
|
||||
local t0 = os.clock()
|
||||
while boss and boss.hp > 0 and os.clock() - t0 < Config.Boss.duration do
|
||||
task.wait(0.25)
|
||||
end
|
||||
if boss then
|
||||
finishBoss(boss.hp <= 0)
|
||||
end
|
||||
task.wait(Config.Boss.interval)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------- игроки
|
||||
|
||||
local function onPlayerAdded(player)
|
||||
@@ -1227,7 +1500,7 @@ local function onPlayerAdded(player)
|
||||
return
|
||||
end
|
||||
loadPasses(player)
|
||||
ensureQuests(data)
|
||||
ensureChain(data)
|
||||
profiles[player] = data
|
||||
loadedOk[player] = ok
|
||||
updateStats(player)
|
||||
@@ -1254,6 +1527,7 @@ end
|
||||
|
||||
Players.PlayerRemoving:Connect(function(player)
|
||||
stopFishing(player, false)
|
||||
combo[player], comboUntil[player] = nil, nil
|
||||
saveData(player)
|
||||
profiles[player] = nil
|
||||
loadedOk[player] = nil
|
||||
@@ -1277,6 +1551,10 @@ task.spawn(function()
|
||||
if data and data.boostUntil > os.time() - 2 then
|
||||
updateStats(p)
|
||||
end
|
||||
-- серия сгорает, если долго нет улова (пока рыба на крючке — ждём)
|
||||
if comboUntil[p] and os.time() > comboUntil[p] and not fishing[p] then
|
||||
breakCombo(p)
|
||||
end
|
||||
end
|
||||
if t % 60 == 0 then
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
|
||||
Reference in new issue
Block a user