On reddit and twitch I've seen some confusion about fishing (especially in winter), so I thought I'd investigate.
The wiki states the following:
- Fishing at dawn (04:00-06:00) and dusk (18:00-20:00) increases the chance of catching fish
- Fishing between November and February decreases the chance of catching fish
- Fishing with a spear is harder
- Fishing with live bait is easier
- Fishing with fishing tackle requires higher levels of Fishing skill
The wiki is actually accurate about this, but I wanted to give additional details that are available in the lua code. ISFishingAction.lua has all the relevant information.
First off, you can set the Sandbox Settings to adjust how easy it is to "attract" fish to catch:
o.attractNumber = 100; if SandboxVars.NatureAbundance == 1 then -- very poor o.attractNumber = 140; elseif SandboxVars.NatureAbundance == 2 then -- poor o.attractNumber = 120; elseif SandboxVars.NatureAbundance == 4 then -- abundant o.attractNumber = 80; elseif SandboxVars.NatureAbundance == 5 then -- very abundant o.attractNumber = 60; end
For the purposes of this post, let's just assume you are using default settings, so your attract number is 100 and we more easily talk in percentages.
The attractFish() method gives all the information we need:
-- Depend on what lure you used : -- Living lure is easier but can escape and always removed after getting something -- Plastic lure are for good fisherman, almost never disapear but harder to get something function ISFishingAction:attractFish() local attractNumber = ZombRand(self.attractNumber); -- a bit more chance during dawn and dusk local currentHour = math.floor(math.floor(GameTime:getInstance():getTimeOfDay() * 3600) / 3600); if (currentHour >= 4 and currentHour <= 6) or (currentHour >= 18 and currentHour <= 20) then attractNumber = attractNumber - 10; end if self.usingSpear then -- less chance to catch something with a spear attractNumber = attractNumber + 10; end -- harder chance of getting fish during winter if (getGameTime():getMonth() + 1) >= 11 or (getGameTime():getMonth() + 1) <= 2 then attractNumber = attractNumber + 20; end -- start with plastic lure if self.plasticLure and attractNumber <= (10 + (self.fishingLvl * 2.5)) then return true; elseif not self.plasticLure and attractNumber <= (20 + (self.fishingLvl * 1.5)) then return true; end -- return true; return false; end
So, with the default self.attractNumber of 100, we generate a random number (1-100) and call it attractNumber. If it is low enough, we have attracted fish, and that number is modified in the following ways:
- Fishing at dawn and dusk increases the chance of catching fish by 10%
- Fishing between November and February decreases the chance of catching fish by 20%
- Fishing with a spear is harder by 10%
- Fishing with live bait is easier than fishing tackle by 10% at Level 0
10 + (self.fishingLvl * 2.5) vs 20 + (selffishingLvl * 1.5)
10 + (10 * 2.5) = 20 + (10 * 1.5) = 35
Wait, doesn't Fishing Abundance affect your chance of catching fish?
if fishLeft == 0 then self.character:SetVariable("FishingFinished","true"); -- needed to remove from queue / start next. ISBaseTimedAction.perform(self); return; end end local caughtFish = false; if self:attractFish() then -- caught something !
self:drawTextCentre(getText("IGUI_FishingUI_FishAbundance") .. self.zoneProgress .. "%", self.width/2, barY, 1,1,1,1, UIFont.Small);
if zoneClicked then local currentFish = tonumber(zoneClicked:getName()); local totalFish = tonumber(zoneClicked:getOriginalName()); if not currentFish or not totalFish or currentFish <= 0 or totalFish <= 0 then self.zoneProgress = 0; else self.zoneProgress = math.floor((currentFish / totalFish) * 100); end end
local fishLeft = tonumber(updateZone:getName()); if getGametimeTimestamp() - updateZone:getLastActionTimestamp() > 20000 then fishLeft = math.max(ZombRand(10,25) + self.fishingZoneIncrease, 0); updateZone:setName(tostring(fishLeft)); updateZone:setOriginalName(tostring(fishLeft)); end if fishLeft == 0 then self.character:SetVariable("FishingFinished","true"); -- needed to remove from queue / start next. ISBaseTimedAction.perform(self); return; end
if self:attractFish() then -- caught something ! local fish = self:getFish(); if updateZone then local fishLeft = tonumber(updateZone:getName()); updateZone:setName(tostring(fishLeft - 1)); updateZone:setLastActionTimestamp(getGametimeTimestamp()); if isClient() then updateZone:sendToServer() end end caughtFish = true;
if not updateZone then -- register a new fishing zone local nbrOfFish = math.max(ZombRand(10,25) + self.fishingZoneIncrease, 0); local x,y,z = self.tile:getSquare():getX(), self.tile:getSquare():getY(), self.tile:getSquare():getZ() local updateZone = getWorld():registerZone(tostring(nbrOfFish), "Fishing", x - 20, y - 20, z, 40, 40); updateZone:setOriginalName(tostring(nbrOfFish)); updateZone:setLastActionTimestamp(getGametimeTimestamp()); if isClient() then updateZone:sendToServer() end end
So, what is the deal with what I called "units"?
@LuaMethod(name="getGametimeTimestamp", global=true) public static long getGametimeTimestamp() { return GameTime.instance.getCalender().getTimeInMillis() / 1000L; }
I think it might've been me that asked you to look at this. I did my own testing (without looking at code) and the results were exactly as you have here.
ReplyDeleteThanks for doing that anyway.
This is some quality content
ReplyDeleteI made this a while back. Don't think they changed the logic, since: https://tiaxx.de/zomboid/fishing/
ReplyDeleteThanks for this writeup!
ReplyDeleteOne thing I've noticed though, in my game it takes longer than 5.5 ingame hours for the abundance to update. If I finish fishing after dusk is over (at roughly 8 pm) and then try again at dusk (4 am), that should be 8 hours - but the fish abundance has not increased.
Playing with the public v41 release, on survivor difficulty. Only mod I have is tailoringfix, which I doubt affects fishing.
Hmm, a few meters down the river abundance seems to work normally. Maybe it just doesn't get reset if the player is too close? Or a working generator? The fishing spot that has issues is right next to my base.
ReplyDeleteThis is wrong on at least two points
ReplyDelete(1) ZombRand does not generate 1-100 it generates 0-99 so 0 fishing is enough for a 1% catch rate (remember ZombRand generates an int so round decimals down)
(2) Testing in-game yields results that completely contradict the code - in winter fishing with a spear requires level 4 to get fish, 3 and below return 0 fish even during dusk and dawn - I'm unsure why but we are obviously missing code
Ok a quick investigation yielded the following results
ReplyDelete(1) This is 100% confirmed, Zomboid uses java.util.Random.nextInt() which includes 0 and excludes the given int, so 0-99 0-79 0-59 etc...
(2) self.plasticLure is TRUE for spears. Spears are compared against a value of 10 + fishingLvl * 2.5 and this means that in winter spears require level 8 (not 7) to catch fish, and during dusk or dawn they require level 4 (not 1, not 0) to catch fish.
https://docs.google.com/spreadsheets/d/1iqGiQD8NgkxWfV_gySkG94UuLvzeUjetMb4wC3HOs_0/
ReplyDeleteTrue values are here