Project Zomboid

Project Zomboid

Food Pickiness
 This topic has been pinned, so it's probably important
Braven  [developer] 19 Oct, 2024 @ 4:34pm
Suggestions
Write your ideas for new mechanics and changes here! :spiffo:
Please keep in mind there is no guarantee I will implement the idea.
You can commission changes by contacting me on Discord[discord.com]! 💖
< >
Showing 1-4 of 4 comments
kav 20 Oct, 2024 @ 12:02am 
can i suggest an idea for a new mod here ?
Deniss_ 25 Oct, 2024 @ 2:07pm 
Originally posted by kav:
can i suggest an idea for a new mod here ?
:TheRooster:
Deniss_ 25 Oct, 2024 @ 2:12pm 
adicionar crianças no pz seria interessante , tanto como zumbis como personagem jogável
Imperior 10 Sep @ 1:38am 
I rewrote part of the script for the food pickiness mod because I noticed that happiness isn't scaled per meal size, and larger meals have more happiness overall. This should prevent an "everything soup" from being super preferable to a chocolate bar or a can of beer. I also considered using calories, since encumbrance is affected by container weight at times.

Inside BB_FoodPickiness_Main.lua:

ISInventoryPaneContextMenu.eatItem = function(item, percentage, playerNumber)

local playerObj = getSpecificPlayer(playerNumber)
local modData = playerObj:getModData()

local playerHunger = playerObj:getStats():getHunger() * SandboxVars.FoodPickiness.HungerMultiplier
local pickiness = modData.BB_FoodPickiness.pickiness
local disgustFactor = pickiness
local repulsivenessLimit = SandboxVars.FoodPickiness.BaseRepulsivenessLimit + playerHunger

-- Determine item encumbrance once (prefer actual weight; fallback to weight; clamp to a small >0 floor).
local encumbrance = 1.0
if item.getActualWeight ~= nil then
encumbrance = item:getActualWeight()
elseif item.getWeight ~= nil then
encumbrance = item:getWeight()
else
encumbrance = 1.0 -- very defensive fallback
end
if encumbrance == nil or encumbrance <= 0 then
encumbrance = 0.01 -- avoid division by zero and extreme amplification
end

-- Incorporate item unhappiness scaled by encumbrance (heavier items dilute the effect).
local unhappyChange = item:getUnhappyChange()
if unhappyChange ~= nil and unhappyChange ~= 0 then
-- CHANGE: encumbrance is now computed outside and reused here.
disgustFactor = disgustFactor + (unhappyChange / encumbrance)
end

if item:isbDangerousUncooked() and not item:isCooked() and not item:isBurnt() then
disgustFactor = disgustFactor + 5
end

if disgustFactor <= repulsivenessLimit then
onEatItem(item, percentage, playerNumber)
-- Rationale: maintain proportionality—heavier (more encumbering) items increased the perceived “consumption impact”.
local pickinessDelta = (disgustFactor / SandboxVars.FoodPickiness.ConsumptionOffset) * encumbrance
modData.BB_FoodPickiness.pickiness = modData.BB_FoodPickiness.pickiness - pickinessDelta
else
local rand = ZombRand(1, 4)
playerObj:Say(getText("IGUI_FoodPickiness_RefuseToEat_" .. rand))
end
end
< >
Showing 1-4 of 4 comments
Per page: 1530 50