Lobby
This commit is contained in:
1 parent
73a2db8bb8
commit
44cf31ce6b
231 files changed
+3396887
-1109081
No files matched your search
@@ -14,11 +14,57 @@ local Debris = game:GetService("Debris")
|
||||
|
||||
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
|
||||
local Models = require(ReplicatedStorage:WaitForChild("GameModels"))
|
||||
local Guild = require(script.Parent:WaitForChild("Guild"))
|
||||
|
||||
local remote = ReplicatedStorage:FindFirstChild("GameEvent") or Instance.new("RemoteEvent")
|
||||
remote.Name = "GameEvent"
|
||||
remote.Parent = ReplicatedStorage
|
||||
|
||||
---------------------------------------------------------------- лента активности
|
||||
-- события для всех игроков (FishingClient показывает их в ленте и крупным баннером для редкого улова);
|
||||
-- самые редкие уловы уходят и на другие серверы игры через MessagingService (Config.Feed)
|
||||
local MessagingService = game:GetService("MessagingService")
|
||||
local FEED_TOPIC = "FishFeed"
|
||||
|
||||
local function feed(kind, info)
|
||||
remote:FireAllClients("Feed", kind, info)
|
||||
end
|
||||
|
||||
-- подписка — в фоне: SubscribeAsync ждёт ответа сервиса (в неопубликованном плейсе — долго),
|
||||
-- а скрипт должен сразу дойти до загрузки игроков, телепортов и остального
|
||||
task.spawn(function()
|
||||
pcall(function()
|
||||
MessagingService:SubscribeAsync(FEED_TOPIC, function(msg)
|
||||
local d = msg.Data
|
||||
if type(d) == "table" and d.jobId ~= game.JobId then
|
||||
d.remote = true -- улов на другом сервере
|
||||
feed("catch", d)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
-- улов в ленту; big — крупный баннер со звуком у всех, global — ещё и на другие серверы
|
||||
local function feedCatch(player, fish, world)
|
||||
local r = Config.Rarities[fish.rarity]
|
||||
local F = Config.Feed
|
||||
local info = {
|
||||
name = player.DisplayName, userId = player.UserId,
|
||||
fish = fish.name, rarity = fish.rarity, mutation = fish.mutation, value = fish.value,
|
||||
world = world and (world.icon .. " " .. world.name) or nil,
|
||||
big = r.rank >= F.announceRank or F.announceMutations[fish.mutation or ""] == true,
|
||||
}
|
||||
feed("catch", info)
|
||||
if r.rank >= F.globalRank or F.globalMutations[fish.mutation or ""] then
|
||||
info.jobId = game.JobId
|
||||
task.spawn(function()
|
||||
pcall(function()
|
||||
MessagingService:PublishAsync(FEED_TOPIC, info)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local rng = Random.new()
|
||||
local GOLD = Color3.fromRGB(255, 220, 80)
|
||||
local RED = Color3.fromRGB(255, 120, 120)
|
||||
@@ -45,6 +91,11 @@ local function defaultData()
|
||||
chain = { index = 1, step = 1, progress = 0, tier = 0 }, daily = { last = 0, streak = 0 },
|
||||
boostUntil = 0, boostBonus = 0,
|
||||
totalCaught = 0, nextUid = 1, receipts = {},
|
||||
passes = {}, -- купленные пропуска (Developer Products): [key] = true
|
||||
coinsEarned = 0, robuxSpent = 0, -- для досок лидеров: всего выручено за рыбу и потрачено Robux
|
||||
settings = { music = Config.DefaultVolume.music, sfx = Config.DefaultVolume.sfx },
|
||||
-- гильдия: жемчуг, печати, отдых (ранг, заказы, наживку, ловушки дополняет Guild.defaults)
|
||||
pearls = 0, seals = 0, rest = 0,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -87,16 +138,12 @@ local function hasPass(player, key)
|
||||
return passes[player] ~= nil and passes[player][key] == true
|
||||
end
|
||||
|
||||
local function loadPasses(player)
|
||||
-- пропуска продаются как Developer Products, поэтому владение хранится в данных игрока, а не в Roblox
|
||||
local function loadPasses(player, data)
|
||||
passes[player] = {}
|
||||
for _, gp in ipairs(Config.GamePasses) do
|
||||
if gp.id and gp.id > 0 then
|
||||
local ok, owns = pcall(function()
|
||||
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gp.id)
|
||||
end)
|
||||
if ok and owns then
|
||||
passes[player][gp.key] = true
|
||||
end
|
||||
if data.passes[gp.key] then
|
||||
passes[player][gp.key] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -106,6 +153,17 @@ local function ev(field, default)
|
||||
return (currentEvent and currentEvent[field]) or default
|
||||
end
|
||||
|
||||
-- погода и время суток (их ведёт WeatherServer через атрибуты workspace)
|
||||
local function weather()
|
||||
return Config.WeatherById(workspace:GetAttribute("Weather"))
|
||||
end
|
||||
local function isNight()
|
||||
if not Config.DayNight.enabled then
|
||||
return false
|
||||
end
|
||||
return Config.IsNight(Config.ClockAt(workspace:GetServerTimeNow(), workspace:GetAttribute("DayStart")))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- расчёты
|
||||
|
||||
local function rodLevel(data, rodId)
|
||||
@@ -135,7 +193,7 @@ local function totalLuck(player, data)
|
||||
if hasPass(player, "LuckyCharm") then
|
||||
l += 0.5
|
||||
end
|
||||
return l + ev("luck", 0)
|
||||
return l + ev("luck", 0) + (weather().luck or 0) + (isNight() and Config.DayNight.nightLuck or 0)
|
||||
end
|
||||
|
||||
local function bagCapacity(player, data)
|
||||
@@ -265,14 +323,20 @@ 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("CoinsEarned", data.coinsEarned)
|
||||
-- когда откроется следующая ежедневная награда (0 — уже доступна); по ней сундук в лобби прыгает только для тех,
|
||||
-- кому есть что забрать
|
||||
player:SetAttribute("DailyNextAt", data.daily.last >= today() and (data.daily.last + 1) * 86400 or 0)
|
||||
player:SetAttribute("RobuxSpent", data.robuxSpent)
|
||||
-- шаг обучения (линия-подсказка); у старых игроков без поля, уже ловивших рыбу, обучение пройдено
|
||||
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, ","))
|
||||
Guild.attrs(player, data)
|
||||
|
||||
local ls = player:FindFirstChild("leaderstats")
|
||||
if ls then
|
||||
ls["Монеты"].Value = data.coins
|
||||
ls["Серебро"].Value = data.coins
|
||||
ls["Уровень"].Value = data.level
|
||||
ls["Улов"].Value = data.totalCaught
|
||||
end
|
||||
@@ -288,6 +352,7 @@ local function addXp(player, data, amount)
|
||||
end
|
||||
if leveled then
|
||||
notify(player, "⭐ Уровень " .. data.level .. "!", GOLD)
|
||||
feed("level", { name = player.DisplayName, userId = player.UserId, level = data.level })
|
||||
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)
|
||||
@@ -296,6 +361,11 @@ local function addXp(player, data, amount)
|
||||
end
|
||||
end
|
||||
|
||||
Guild.init({
|
||||
profiles = profiles, notify = notify, updateStats = updateStats, addXp = addXp, sendInventory = sendInventory,
|
||||
bagCapacity = bagCapacity, isNight = isNight, weather = weather, remote = remote,
|
||||
})
|
||||
|
||||
local function applyPotion(data, bonus, duration)
|
||||
data.boostBonus = math.max(boostActive(data), bonus)
|
||||
data.boostUntil = math.max(os.time(), data.boostUntil) + duration
|
||||
@@ -374,9 +444,13 @@ local function claimDaily(player)
|
||||
end
|
||||
end
|
||||
data.daily = { last = t, streak = streak }
|
||||
if streak == 7 then
|
||||
data.pearls += Config.Pearls.daily7
|
||||
extra ..= (" + %d 🦪"):format(Config.Pearls.daily7)
|
||||
end
|
||||
updateStats(player)
|
||||
sendQuests(player)
|
||||
notify(player, ("🎁 День %d: +%d 💰%s"):format(streak, coins, extra), GOLD)
|
||||
notify(player, ("🎁 День %d: +%d ⚪%s"):format(streak, coins, extra), GOLD)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- коллекция
|
||||
@@ -402,7 +476,7 @@ local function claimCollection(player, worldId, rarity)
|
||||
if rarity == "Master" then
|
||||
local coins = Config.MasteryCoins * world.mult
|
||||
data.coins += coins
|
||||
notify(player, ("🏆 «%s» собран! +%d 💰"):format(world.name, coins), GOLD)
|
||||
notify(player, ("🏆 «%s» собран! +%d ⚪"):format(world.name, coins), GOLD)
|
||||
else
|
||||
local r = Config.CollectionRewards[rarity]
|
||||
if not r then
|
||||
@@ -410,7 +484,7 @@ local function claimCollection(player, worldId, rarity)
|
||||
end
|
||||
data.coins += r.coins * world.mult
|
||||
addXp(player, data, r.xp * world.mult)
|
||||
notify(player, ("📖 +%d 💰 +%d XP"):format(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)
|
||||
@@ -418,7 +492,7 @@ end
|
||||
|
||||
---------------------------------------------------------------- удочка, сумка, VIP на персонаже
|
||||
|
||||
local REST_ANGLE = 30
|
||||
local REST_ANGLE = 42 -- удочка в покое: рукоять под ~42° вверх-вперёд, кончик провисает до ~30°
|
||||
local function gripCF(angle)
|
||||
return (CFrame.Angles(math.rad(angle), 0, 0) * CFrame.new(0, 0, -0.3)):Inverse()
|
||||
end
|
||||
@@ -472,6 +546,7 @@ local function giveRodTool(player)
|
||||
local tool = Instance.new("Tool")
|
||||
tool.Name = rod.name .. (lvl > 0 and (" +" .. lvl) or "")
|
||||
tool.ToolTip = "Кликни у воды, чтобы закинуть"
|
||||
tool.TextureId = rod.icon or ""
|
||||
tool.CanBeDropped = false
|
||||
tool.Grip = gripCF(REST_ANGLE)
|
||||
tool:SetAttribute("IsRod", true)
|
||||
@@ -734,12 +809,19 @@ local function stopFishing(player, tellClient)
|
||||
end
|
||||
end
|
||||
|
||||
local function rollFish(player, data, worldId, luckMult)
|
||||
-- mods: { bait = наживка из Config.Baits, maxRank = потолок редкости (автоловля) }
|
||||
local function rollFish(player, data, worldId, luckMult, mods)
|
||||
local zone = Config.Zones[worldId]
|
||||
if not zone then
|
||||
return nil
|
||||
end
|
||||
local luck = totalLuck(player, data) * (luckMult or 1)
|
||||
mods = mods or {}
|
||||
local bait = mods.bait
|
||||
local base = totalLuck(player, data) + (bait and bait.luck or 0)
|
||||
if bait and bait.nightLuck and isNight() then
|
||||
base += bait.nightLuck - Config.DayNight.nightLuck -- светлячок: ночью +30% вместо обычных +10%
|
||||
end
|
||||
local luck = base * (luckMult or 1)
|
||||
local bonus = luck - 1
|
||||
local weights, total = {}, 0
|
||||
for i, f in ipairs(zone.fish) do
|
||||
@@ -748,6 +830,12 @@ local function rollFish(player, data, worldId, luckMult)
|
||||
if r.rank == 1 then
|
||||
w = r.weight / math.max(1, luck)
|
||||
end
|
||||
if bait and bait.rareWeight and r.rank >= 3 then
|
||||
w *= bait.rareWeight
|
||||
end
|
||||
if mods.maxRank and r.rank > mods.maxRank then
|
||||
w = 0
|
||||
end
|
||||
weights[i] = w
|
||||
total += w
|
||||
end
|
||||
@@ -762,7 +850,7 @@ local function rollFish(player, data, worldId, luckMult)
|
||||
end
|
||||
local mutation = nil
|
||||
for _, m in ipairs(Config.Mutations) do
|
||||
if rng:NextNumber() < m.chance * luck * ev("mutation", 1) then
|
||||
if rng:NextNumber() < m.chance * luck * ev("mutation", 1) * (weather().mutation or 1) * (bait and bait.mutation or 1) then
|
||||
mutation = m
|
||||
break
|
||||
end
|
||||
@@ -818,12 +906,21 @@ local function flyBobber(s, tool, target, dur, arc)
|
||||
end
|
||||
end
|
||||
|
||||
local autoFishing = {} -- [player] = токен работающей автоловли
|
||||
local setAutoFish, grantFish -- объявлены ниже
|
||||
|
||||
local function onCast(player, power)
|
||||
power = math.clamp(tonumber(power) or 0.6, 0, 1)
|
||||
local data = profiles[player]
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
if autoFishing[player] then
|
||||
-- клик удочкой во время автоловли — выключить её
|
||||
setAutoFish(player, false)
|
||||
remote:FireClient(player, "CastFail")
|
||||
return
|
||||
end
|
||||
if fishing[player] then
|
||||
stopFishing(player, true)
|
||||
return
|
||||
@@ -856,7 +953,8 @@ local function onCast(player, power)
|
||||
|
||||
local stats = Config.RodStats(data.rod, rodLevel(data))
|
||||
local perfect = power >= Config.CastPerfect[1] and power <= Config.CastPerfect[2]
|
||||
local fish = rollFish(player, data, world.id, perfect and Config.CastPerfectLuck or 1)
|
||||
local bait = Guild.useBait(player, data) -- 1 штука наживки на заброс
|
||||
local fish = rollFish(player, data, world.id, perfect and Config.CastPerfectLuck or 1, { bait = bait })
|
||||
if not fish then
|
||||
remote:FireClient(player, "CastFail")
|
||||
return
|
||||
@@ -886,7 +984,7 @@ local function onCast(player, power)
|
||||
end
|
||||
s.stage = "waiting"
|
||||
|
||||
local waitTime = rng:NextNumber(Config.BiteTimeMin, Config.BiteTimeMax) * stats.speed * ev("speed", 1)
|
||||
local waitTime = rng:NextNumber(Config.BiteTimeMin, Config.BiteTimeMax) * stats.speed * ev("speed", 1) * (weather().speed or 1) * (bait and bait.speed or 1)
|
||||
task.wait(waitTime)
|
||||
if fishing[player] ~= s then
|
||||
return
|
||||
@@ -957,14 +1055,22 @@ local function onCatch(player, success, misses)
|
||||
return
|
||||
end
|
||||
gripSequence(tool, { { 85, 0.15 }, { REST_ANGLE, 0.45 } })
|
||||
grantFish(player, data, s.fish, { perfect = s.perfect, misses = misses, fromPos = fromPos })
|
||||
end
|
||||
|
||||
-- серия: каждая рыба подряд дороже и даёт больше опыта
|
||||
local fish = s.fish
|
||||
-- рыба поймана (руками или автоловлей): в сумку, опыт, коллекция, задания, гильдия, босс.
|
||||
-- ctx: { perfect, misses, fromPos, auto }; у автоловли нет серии и бонусов за точность
|
||||
grantFish = function(player, data, fish, ctx)
|
||||
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)
|
||||
local comboMult = 1
|
||||
if not ctx.auto then
|
||||
-- серия: каждая рыба подряд дороже и даёт больше опыта
|
||||
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)
|
||||
end
|
||||
fish.xp = math.floor(fish.xp * Guild.xpMult(data)) -- бонус отдыха: двойной опыт
|
||||
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,
|
||||
@@ -987,10 +1093,14 @@ local function onCatch(player, success, misses)
|
||||
addXp(player, data, fish.xp * (isNew and 2 or 1))
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
if fromPos then
|
||||
showFishFlight(player, fish, fromPos)
|
||||
if ctx.fromPos then
|
||||
showFishFlight(player, fish, ctx.fromPos)
|
||||
end
|
||||
remote:FireClient(player, "Caught", fish, { new = isNew, record = isRecord, combo = comboMult, streak = ctx.auto and 0 or streak + 1, auto = ctx.auto })
|
||||
do
|
||||
local h = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
feedCatch(player, fish, h and Config.WorldAt(h.Position))
|
||||
end
|
||||
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)
|
||||
@@ -1000,16 +1110,160 @@ local function onCatch(player, success, misses)
|
||||
if rank >= 3 then
|
||||
questProgress(player, "rare", 1)
|
||||
end
|
||||
if misses == 0 then
|
||||
questProgress(player, "perfect", 1)
|
||||
if not ctx.auto then
|
||||
if ctx.misses == 0 then
|
||||
questProgress(player, "perfect", 1)
|
||||
end
|
||||
if ctx.perfect then
|
||||
questProgress(player, "perfectCast", 1)
|
||||
end
|
||||
questProgress(player, "combo", streak + 1, true)
|
||||
end
|
||||
if s.perfect then
|
||||
questProgress(player, "perfectCast", 1)
|
||||
end
|
||||
questProgress(player, "combo", streak + 1, true)
|
||||
Guild.onCatch(player, data, fish, {
|
||||
weather = workspace:GetAttribute("Weather"), night = isNight(),
|
||||
perfect = ctx.perfect and not ctx.auto, streak = (not ctx.auto) and streak + 1 or 0,
|
||||
})
|
||||
|
||||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
bossHit(player, hrp and Config.WorldAt(hrp.Position), rank + (misses == 0 and 1 or 0))
|
||||
bossHit(player, hrp and Config.WorldAt(hrp.Position), rank + (ctx.misses == 0 and 1 or 0))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- автоловля (с ранга E)
|
||||
-- сервер сам забрасывает и вытаскивает: удача ×0.6, не выше «Редкой», без серии и бонуса заброса,
|
||||
-- каждая поимка на 50% дольше. Стоп — полная сумка, отошёл от места, сменил мир, убрал удочку
|
||||
|
||||
local function autoFishLoop(player, token)
|
||||
local A = Config.AutoFish
|
||||
local home = nil -- где включили: отошёл дальше 10 studs или сменил мир — стоп
|
||||
local function stop(reason)
|
||||
if autoFishing[player] == token then
|
||||
setAutoFish(player, false, reason)
|
||||
end
|
||||
end
|
||||
while autoFishing[player] == token do
|
||||
local data = profiles[player]
|
||||
local char = player.Character
|
||||
local hrp = char and char:FindFirstChild("HumanoidRootPart")
|
||||
local tool = char and char:FindFirstChildOfClass("Tool")
|
||||
if not data or not hrp then
|
||||
return stop(nil)
|
||||
end
|
||||
if not tool or not tool:GetAttribute("IsRod") then
|
||||
return stop("🎣 Автоловля: возьми удочку в руки")
|
||||
end
|
||||
local world = Config.WorldAt(hrp.Position)
|
||||
if not world or Config.CanCastFrom(world, hrp.Position) ~= true then
|
||||
return stop("🌊 Автоловля: встань у воды")
|
||||
end
|
||||
home = home or { pos = hrp.Position, world = world.id }
|
||||
if world.id ~= home.world or (hrp.Position - home.pos).Magnitude > 10 then
|
||||
return stop("🎣 Автоловля остановлена: ты отошёл")
|
||||
end
|
||||
if #data.items >= bagCapacity(player, data) then
|
||||
return stop("🎒 Сумка полна — автоловля остановлена")
|
||||
end
|
||||
local target, dist = findWater(hrp, world, 0.6)
|
||||
if not target then
|
||||
return stop("🌊 Автоловля: встань у воды")
|
||||
end
|
||||
if fishing[player] then
|
||||
task.wait(0.5)
|
||||
continue
|
||||
end
|
||||
|
||||
local bait = Guild.useBait(player, data)
|
||||
local fish = rollFish(player, data, world.id, A.luck, { bait = bait, maxRank = (not Guild.rank(data).autoNoCap) and A.maxRarity or nil })
|
||||
local s = { stage = "casting", fish = fish, tool = tool, auto = true }
|
||||
fishing[player] = s
|
||||
local splashAt = target + Vector3.new(0, 0.15, 0)
|
||||
local tw = tweenGrip(tool, 8, 0.15)
|
||||
if tw then
|
||||
tw.Completed:Wait()
|
||||
end
|
||||
if fishing[player] == s then
|
||||
flyBobber(s, tool, splashAt, 0.35 + dist * 0.018, 2 + dist * 0.3)
|
||||
tweenGrip(tool, REST_ANGLE - 5, 0.4)
|
||||
end
|
||||
if fishing[player] ~= s then
|
||||
if s.bobber then
|
||||
s.bobber:Destroy()
|
||||
end
|
||||
continue
|
||||
end
|
||||
s.stage = "waiting"
|
||||
local stats = Config.RodStats(data.rod, rodLevel(data))
|
||||
local waitTime = rng:NextNumber(Config.BiteTimeMin, Config.BiteTimeMax) * stats.speed * ev("speed", 1)
|
||||
* (weather().speed or 1) * (bait and bait.speed or 1) * A.slower
|
||||
local t0, bit = os.clock(), false
|
||||
while fishing[player] == s and autoFishing[player] == token and os.clock() - t0 < waitTime + A.reel do
|
||||
local h = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
if not h or (h.Position - home.pos).Magnitude > 10 then
|
||||
break
|
||||
end
|
||||
if not bit and os.clock() - t0 >= waitTime then
|
||||
-- клюёт: всплеск и удочка дёргается до конца «вываживания»
|
||||
bit = true
|
||||
if s.bobber and s.bobber.PrimaryPart then
|
||||
splash(s.bobber.PrimaryPart, 25)
|
||||
playSound(s.bobber.PrimaryPart, SPLASH_SOUND, 0.35)
|
||||
end
|
||||
end
|
||||
if bit then
|
||||
tweenGrip(tool, (math.floor(os.clock() * 8) % 2 == 0) and 38 or 18, 0.12)
|
||||
end
|
||||
task.wait(0.13)
|
||||
end
|
||||
if fishing[player] ~= s or autoFishing[player] ~= token or not bit or os.clock() - t0 < waitTime + A.reel - 0.05 then
|
||||
if fishing[player] == s then
|
||||
stopFishing(player, false)
|
||||
end
|
||||
continue -- наверху цикла проверим, почему прервались (отошёл, выключил)
|
||||
end
|
||||
fishing[player] = nil
|
||||
local fromPos = s.bobber and s.bobber.PrimaryPart and s.bobber.PrimaryPart.Position
|
||||
if s.bobber then
|
||||
s.bobber:Destroy()
|
||||
end
|
||||
gripSequence(tool, { { 85, 0.15 }, { REST_ANGLE, 0.45 } })
|
||||
grantFish(player, data, fish, { auto = true, fromPos = fromPos })
|
||||
task.wait(1.2)
|
||||
end
|
||||
end
|
||||
|
||||
setAutoFish = function(player, on, reason)
|
||||
local data = profiles[player]
|
||||
if on then
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
if not Guild.rank(data).auto then
|
||||
notify(player, "🔒 Автоловля — с ранга гильдии E", RED)
|
||||
player:SetAttribute("AutoFish", false)
|
||||
return
|
||||
end
|
||||
if autoFishing[player] then
|
||||
return
|
||||
end
|
||||
if fishing[player] then
|
||||
stopFishing(player, true)
|
||||
end
|
||||
local token = {}
|
||||
autoFishing[player] = token
|
||||
player:SetAttribute("AutoFish", true)
|
||||
notify(player, "🎣 Автоловля включена", GREEN)
|
||||
task.spawn(autoFishLoop, player, token)
|
||||
else
|
||||
player:SetAttribute("AutoFish", false)
|
||||
if not autoFishing[player] then
|
||||
return
|
||||
end
|
||||
autoFishing[player] = nil
|
||||
local s = fishing[player]
|
||||
if s and s.auto then
|
||||
stopFishing(player, false)
|
||||
end
|
||||
notify(player, reason or "🎣 Автоловля выключена", Color3.fromRGB(255, 200, 120))
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- скупка
|
||||
@@ -1062,6 +1316,7 @@ local function sellItems(player, filterUid)
|
||||
end
|
||||
data.items = keep
|
||||
data.coins += total
|
||||
data.coinsEarned += total
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
remote:FireClient(player, "Sold", total, count)
|
||||
@@ -1086,9 +1341,9 @@ local function buy(player, kind, id)
|
||||
notify(player, "★★★★★ Максимум", GOLD)
|
||||
return
|
||||
end
|
||||
local cost = Config.UpgradeCost(rod, lvl)
|
||||
local cost = Guild.price(data, Config.UpgradeCost(rod, lvl)) -- скидка ранга гильдии
|
||||
if data.coins < cost then
|
||||
notify(player, "Нужно " .. cost .. " 💰", RED)
|
||||
notify(player, "Нужно " .. cost .. " ⚪", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= cost
|
||||
@@ -1111,11 +1366,12 @@ local function buy(player, kind, id)
|
||||
notify(player, "🔒 Нужен ур. " .. potion.level, RED)
|
||||
return
|
||||
end
|
||||
if data.coins < potion.price then
|
||||
notify(player, "Нужно " .. potion.price .. " 💰", RED)
|
||||
local price = Guild.price(data, potion.price)
|
||||
if data.coins < price then
|
||||
notify(player, "Нужно " .. price .. " ⚪", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= potion.price
|
||||
data.coins -= price
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
updateStats(player)
|
||||
notify(player, ("🍀 +%d%% удачи, %d мин"):format(potion.bonus * 100, potion.duration / 60), GREEN)
|
||||
@@ -1140,11 +1396,12 @@ local function buy(player, kind, id)
|
||||
notify(player, "🔒 Нужен ур. " .. item.level, RED)
|
||||
return
|
||||
end
|
||||
if data.coins < item.price then
|
||||
notify(player, "Нужно " .. item.price .. " 💰", RED)
|
||||
local price = Guild.price(data, item.price)
|
||||
if data.coins < price then
|
||||
notify(player, "Нужно " .. price .. " ⚪", RED)
|
||||
return
|
||||
end
|
||||
data.coins -= item.price
|
||||
data.coins -= price
|
||||
owned[id] = true
|
||||
bought = true
|
||||
notify(player, "✅ " .. item.name, GREEN)
|
||||
@@ -1193,6 +1450,11 @@ local function teleportTo(player, worldId)
|
||||
notify(player, ("🔒 %s: ур. %d"):format(world.name, world.level), RED)
|
||||
return
|
||||
end
|
||||
local okRank, why = Guild.canEnter(data, world.id)
|
||||
if not okRank then
|
||||
notify(player, why, RED)
|
||||
return
|
||||
end
|
||||
markerName = world.id .. "Spawn"
|
||||
end
|
||||
local map = workspace:FindFirstChild("FishingMap")
|
||||
@@ -1256,6 +1518,10 @@ ProximityPromptService.PromptTriggered:Connect(function(prompt, player)
|
||||
remote:FireClient(player, "OpenRobux", "passes")
|
||||
elseif action == "RobuxProducts" then
|
||||
remote:FireClient(player, "OpenRobux", "products")
|
||||
elseif action == "Guild" or action == "Orders" or action == "Bait" or action == "Traps" then
|
||||
-- Старейшина, доска заказов, лавка наживки: окно гильдии на нужной вкладке
|
||||
Guild.sendState(player)
|
||||
remote:FireClient(player, "OpenGuild", ({ Guild = "rank", Orders = "orders", Bait = "bait", Traps = "traps" })[action])
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -1285,13 +1551,13 @@ 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)
|
||||
@@ -1302,27 +1568,38 @@ remote.OnServerEvent:Connect(function(player, action, a, b)
|
||||
elseif action == "RequestInventory" then
|
||||
sendInventory(player)
|
||||
sendQuests(player)
|
||||
elseif action == "Settings" then
|
||||
-- громкость музыки и эффектов (0..1), сохраняется вместе с прогрессом
|
||||
local data = profiles[player]
|
||||
local music, sfx = tonumber(a), tonumber(b)
|
||||
if data and music and sfx then
|
||||
data.settings = { music = math.clamp(music, 0, 1), sfx = math.clamp(sfx, 0, 1) }
|
||||
player:SetAttribute("VolMusic", data.settings.music)
|
||||
player:SetAttribute("VolSfx", data.settings.sfx)
|
||||
end
|
||||
elseif action == "AutoFish" then
|
||||
setAutoFish(player, a == true)
|
||||
else
|
||||
Guild.onAction(player, action, a, b)
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------- донат
|
||||
|
||||
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, passId, purchased)
|
||||
if not purchased then
|
||||
return
|
||||
end
|
||||
for _, gp in ipairs(Config.GamePasses) do
|
||||
if gp.id == passId then
|
||||
passes[player] = passes[player] or {}
|
||||
passes[player][gp.key] = true
|
||||
notify(player, "✅ " .. gp.icon .. " " .. gp.name, GOLD)
|
||||
if gp.key == "VIP" then
|
||||
vipTag(player)
|
||||
end
|
||||
updateStats(player)
|
||||
-- все покупки — Developer Products: и наборы (Config.Products), и пропуска навсегда (Config.GamePasses)
|
||||
local function findProduct(productId)
|
||||
for _, p in ipairs(Config.Products) do
|
||||
if p.id == productId then
|
||||
return p, false
|
||||
end
|
||||
end
|
||||
end)
|
||||
for _, gp in ipairs(Config.GamePasses) do
|
||||
if gp.id == productId then
|
||||
return gp, true
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
MarketplaceService.ProcessReceipt = function(info)
|
||||
local player = Players:GetPlayerByUserId(info.PlayerId)
|
||||
@@ -1335,19 +1612,26 @@ MarketplaceService.ProcessReceipt = function(info)
|
||||
return Enum.ProductPurchaseDecision.PurchaseGranted
|
||||
end
|
||||
end
|
||||
local product
|
||||
for _, p in ipairs(Config.Products) do
|
||||
if p.id == info.ProductId then
|
||||
product = p
|
||||
end
|
||||
end
|
||||
local product, isPass = findProduct(info.ProductId)
|
||||
if not product then
|
||||
warn("ProcessReceipt: неизвестный товар " .. tostring(info.ProductId))
|
||||
return Enum.ProductPurchaseDecision.NotProcessedYet
|
||||
end
|
||||
data.robuxSpent += info.CurrencySpent or product.robux or 0
|
||||
feed("buy", { name = player.DisplayName, userId = player.UserId, item = product.icon .. " " .. product.name })
|
||||
if isPass then
|
||||
data.passes[product.key] = true
|
||||
passes[player] = passes[player] or {}
|
||||
passes[player][product.key] = true
|
||||
notify(player, "✅ " .. product.icon .. " " .. product.name .. " — навсегда!", GOLD)
|
||||
if product.key == "VIP" then
|
||||
vipTag(player)
|
||||
end
|
||||
end
|
||||
if product.coins then
|
||||
local coins = math.floor(product.coins * (1 + (data.level - 1) * 0.15))
|
||||
data.coins += coins
|
||||
notify(player, ("Спасибо! +%d 💰"):format(coins), GOLD)
|
||||
notify(player, ("Спасибо! +%d ⚪"):format(coins), GOLD)
|
||||
end
|
||||
if product.boost then
|
||||
applyPotion(data, product.boost, product.duration)
|
||||
@@ -1432,6 +1716,7 @@ local function finishBoss(won)
|
||||
if potion then
|
||||
applyPotion(data, potion.bonus, potion.duration)
|
||||
end
|
||||
Guild.onBossWin(p, data)
|
||||
updateStats(p)
|
||||
remote:FireClient(p, "BossReward", coins, xp, potion and potion.name)
|
||||
end
|
||||
@@ -1486,10 +1771,13 @@ end)
|
||||
---------------------------------------------------------------- игроки
|
||||
|
||||
local function onPlayerAdded(player)
|
||||
-- камеру нельзя отвести так далеко, чтобы заглянуть за скалы и край карты
|
||||
player.CameraMinZoomDistance = Config.Camera.minZoom
|
||||
player.CameraMaxZoomDistance = Config.Camera.maxZoom
|
||||
local ls = Instance.new("Folder")
|
||||
ls.Name = "leaderstats"
|
||||
ls.Parent = player
|
||||
for _, name in ipairs({ "Монеты", "Уровень", "Улов" }) do
|
||||
for _, name in ipairs({ "Серебро", "Уровень", "Улов" }) do
|
||||
local v = Instance.new("IntValue")
|
||||
v.Name = name
|
||||
v.Parent = ls
|
||||
@@ -1499,13 +1787,19 @@ local function onPlayerAdded(player)
|
||||
if not player.Parent then
|
||||
return
|
||||
end
|
||||
loadPasses(player)
|
||||
loadPasses(player, data)
|
||||
ensureChain(data)
|
||||
Guild.defaults(data)
|
||||
Guild.onJoin(player, data)
|
||||
profiles[player] = data
|
||||
loadedOk[player] = ok
|
||||
local settings = type(data.settings) == "table" and data.settings or {}
|
||||
player:SetAttribute("VolMusic", tonumber(settings.music) or Config.DefaultVolume.music)
|
||||
player:SetAttribute("VolSfx", tonumber(settings.sfx) or Config.DefaultVolume.sfx)
|
||||
updateStats(player)
|
||||
sendInventory(player)
|
||||
sendQuests(player)
|
||||
Guild.sendState(player)
|
||||
|
||||
local function onCharacter()
|
||||
stopFishing(player, false)
|
||||
@@ -1513,6 +1807,7 @@ local function onPlayerAdded(player)
|
||||
giveRodTool(player)
|
||||
attachBag(player)
|
||||
vipTag(player)
|
||||
Guild.badge(player)
|
||||
end
|
||||
player.CharacterAdded:Connect(onCharacter)
|
||||
if player.Character then
|
||||
@@ -1528,6 +1823,10 @@ end
|
||||
Players.PlayerRemoving:Connect(function(player)
|
||||
stopFishing(player, false)
|
||||
combo[player], comboUntil[player] = nil, nil
|
||||
autoFishing[player] = nil
|
||||
if profiles[player] then
|
||||
Guild.onLeave(profiles[player])
|
||||
end
|
||||
saveData(player)
|
||||
profiles[player] = nil
|
||||
loadedOk[player] = nil
|
||||
@@ -1536,21 +1835,42 @@ end)
|
||||
|
||||
game:BindToClose(function()
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
if profiles[p] then
|
||||
Guild.onLeave(profiles[p])
|
||||
end
|
||||
saveData(p)
|
||||
end
|
||||
end)
|
||||
|
||||
-- погода и ночь меняют удачу: пересчитываем её у всех, когда они меняются
|
||||
local function refreshAllStats()
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
updateStats(p)
|
||||
end
|
||||
end
|
||||
workspace:GetAttributeChangedSignal("Weather"):Connect(refreshAllStats)
|
||||
|
||||
-- таймер зелий + автосохранение
|
||||
task.spawn(function()
|
||||
local t = 0
|
||||
local wasNight = isNight()
|
||||
while true do
|
||||
task.wait(1)
|
||||
t += 1
|
||||
local night = isNight()
|
||||
if night ~= wasNight then
|
||||
wasNight = night
|
||||
refreshAllStats()
|
||||
end
|
||||
for _, p in ipairs(Players:GetPlayers()) do
|
||||
local data = profiles[p]
|
||||
if data and data.boostUntil > os.time() - 2 then
|
||||
updateStats(p)
|
||||
end
|
||||
-- бонус отдыха тратится, пока игрок рыбачит
|
||||
if data and (fishing[p] or autoFishing[p]) then
|
||||
Guild.spendRest(p, data, 1)
|
||||
end
|
||||
-- серия сгорает, если долго нет улова (пока рыба на крючке — ждём)
|
||||
if comboUntil[p] and os.time() > comboUntil[p] and not fishing[p] then
|
||||
breakCombo(p)
|
||||
|
||||
Reference in new issue
Block a user