local getgenv = getgenv or function() return shared end
_G.AutoFarmActive = false
getgenv().AutoFarm = false
if getgenv().AutoFarmConn then
pcall(function() getgenv().AutoFarmConn:Disconnect() end)
getgenv().AutoFarmConn = nil
end
task.wait(0.3)
getgenv().AutoFarm = true -- false to stop
local sys = require(game.ReplicatedFirst.AllSideCode.UtilsSystem)
local dat = sys.PlayerData
local cfg = sys.CfgFind
local enm = sys.EnumMgr
local mdl = sys.ModelFind
local plr = game.Players.LocalPlayer
local rf = sys.RemoteFunction.RemoteFunction
local re = sys.RemoteEvent.RemoteEvent
local ev = sys.Event.ToFish
pcall(function()
local path = plr.PlayerScripts.Manager.NetWorkManager.FishAni
local fishAni = require(path)
local old = fishAni.StartPlayFishAni
fishAni.StartPlayFishAni = function(p)
if p and p.player == plr then
p.isWater = true
if p.endPos == nil then
p.endPos = plr.Character and plr.Character.PrimaryPart and plr.Character.PrimaryPart.Position + Vector3.new(0, -3, 5)
end
end
return old(p)
end
end)
local cc = 0
local function getScrapeVal(item)
if not item then return 0 end
if item.scraped ~= nil then return tonumber(item.scraped) or 0 end
if item.isScrape ~= nil then return tonumber(item.isScrape) or 0 end
if type(item.Data) == "table" then
if item.Data.scraped ~= nil then return tonumber(item.Data.scraped) or 0 end
if item.Data.isScrape ~= nil then return tonumber(item.Data.isScrape) or 0 end
end
return 0
end
local function isLocked(item)
return item and type(item.Data) == "table" and tonumber(item.Data.lock) == 1
end
local function getRate(magic)
local v = math.floor(tonumber(magic) or 0)
if v <= 0 then return 1 end
local c = cfg.GetCfgByNameAndID("magic_treasureConf", v)
return c and tonumber(c.ScalesRate) or 1
end
local function getPerfect(fishId)
local c = cfg.FindCfgByID(fishId, enm.ItemType.Fish)
if not c then return 0 end
local m = mdl.GetModelCloneByModelName(c.Model, enm.ItemType.Fish, true)
if not m then return 0 end
local count = 0
local scales = m:FindFirstChild("Scales")
if scales then
for _, desc in ipairs(scales:GetDescendants()) do
if desc:IsA("BasePart") then count = count + 1 end
end
end
m:Destroy()
return count
end
local function getSlots()
local cap = sys.GetData.GetBagSizeByType(plr, enm.BagType.NoScale) or 9999
local count = 0
local pData = dat.GetPlrData(plr)
if pData and pData.Bag then
for _, v in pairs(pData.Bag) do
if tonumber(v.tp) == enm.ItemType.Fish and (v.count and v.count >= 1) and getScrapeVal(v) ~= 0 then
count = count + 1
end
end
end
return math.max(0, cap - count)
end
local function getSlimy()
local pData = dat.GetPlrData(plr)
if not pData or not pData.Bag then return {} end
local list = {}
for _, item in pairs(pData.Bag) do
if tonumber(item.tp) == enm.ItemType.Fish and (item.count and item.count >= 1) then
if getScrapeVal(item) == 0 and not isLocked(item) then
table.insert(list, item)
end
end
end
return list
end
local function getScraped()
local pData = dat.GetPlrData(plr)
if not pData or not pData.Bag then return {} end
local list = {}
for _, item in pairs(pData.Bag) do
if tonumber(item.tp) == enm.ItemType.Fish and (item.count and item.count >= 1) then
if getScrapeVal(item) ~= 0 then
table.insert(list, item)
end
end
end
return list
end
local function closeUI()
local ui = plr.PlayerGui.ScreenGui:FindFirstChild("Fish")
if ui and ui.Visible then
ui.Visible = false
pcall(function() sys.UIMgr.SetMainUIVisible(true) end)
end
end
local function runSell()
local slimy = getSlimy()
if #slimy > 0 then
local slots = getSlots()
if slots > 0 then
local batch = {}
for i = 1, math.min(#slimy, slots) do table.insert(batch, slimy[i]) end
local entries = {}
local total = 0
local cache = {}
for _, item in ipairs(batch) do
local fid = tonumber(item.id)
local magic = item.Data and tonumber(item.Data.magic) or tonumber(item.magic) or 0
local perf = cache[fid] or getPerfect(fid)
cache[fid] = perf
total = total + math.floor(perf * getRate(magic))
table.insert(entries, {
onlyID = item.onlyID,
perfectScrape = perf,
injuredScrape = 0,
magic = magic
})
end
pcall(rf.InvokeServer, rf, "自动刮鱼鳞批量完成", {
entries = entries,
totalScales = total,
requireAutoUnlock = false
})
end
end
local scraped = getScraped()
if #scraped > 0 then
if pcall(rf.InvokeServer, rf, "卖掉全部鱼") then
closeUI()
end
end
end
local function checkRod()
local char = plr.Character
if not char then return false end
for _, child in ipairs(char:GetChildren()) do
if child:IsA("Tool") and (child:GetAttribute("FishingTool") == true or child:GetAttribute("Tp") == enm.ItemType.Rod) then
return true
end
end
local rod
local bp = plr:FindFirstChild("Backpack")
if bp then
for _, child in ipairs(bp:GetChildren()) do
if child:IsA("Tool") and (child:GetAttribute("FishingTool") == true or child:GetAttribute("Tp") == enm.ItemType.Rod) then
rod = child
break
end
end
end
if rod then
char.Humanoid:EquipTool(rod)
task.wait(0.2)
return true
end
return false
end
getgenv().AutoFarmConn = re.OnClientEvent:Connect(function(name, args)
if name == "获得稀有度" and args then
cc = #args[1]
end
end)
task.spawn(function()
pcall(rf.InvokeServer, rf, "领取群组奖励")
local last = 0
while getgenv().AutoFarm do
pcall(rf.InvokeServer, rf, "领取宠物鱼全部")
if tick() - last > 1800 then
pcall(rf.InvokeServer, rf, "领取每日奖励")
last = tick()
end
task.wait(60)
end
end)
task.spawn(function()
while getgenv().AutoFarm do
task.wait(0.1)
local state = plr:FindFirstChild("FishingState")
if state then
local val = state.Value
if val == enm.FishingState.Idle then
runSell()
task.wait(0.1)
closeUI()
if state.Value == enm.FishingState.Idle and checkRod() and getgenv().AutoFarm then
ev:Fire("手机开始钓鱼")
task.wait(0.8)
ev:Fire("手机开始抛竿")
task.wait(1.5)
end
elseif val == enm.FishingState.Fishing then
local idx = plr:FindFirstChild("FishBubbleIndex")
if idx and idx.Value >= 1 and cc > 0 then
while getgenv().AutoFarm and state.Value == enm.FishingState.Fishing and idx.Value <= cc do
re:FireServer("钓鱼充能", true)
task.wait()
end
re:FireServer("钓鱼充能", false)
if getgenv().AutoFarm and idx.Value > cc then
pcall(rf.InvokeServer, rf, "钓鱼拉杆")
task.wait(0.1)
pcall(rf.InvokeServer, rf, "结束钓鱼")
cc = 0
task.wait(0.2)
end
end
elseif val == enm.FishingState.ThrowEnd then
pcall(rf.InvokeServer, rf, "结束钓鱼")
cc = 0
task.wait(0.2)
end
end
end
if getgenv().AutoFarmConn then
pcall(function() getgenv().AutoFarmConn:Disconnect() end)
getgenv().AutoFarmConn = nil
end
pcall(re.FireServer, re, "钓鱼充能", false)
end)