Jump to content

Custom fresh food value

Recommended Posts

Hi, i've been trying to change values of fresh food for my character. I have no idea how to do that though. Like stale and spoiled food have their own value for this (inst.components.eater.stale/spoiled_hunger/health), there is no such thing for fresh food or at least I cant find one. So i've tried this

	if inst.components.eater ~= nil then
		if inst.components.eater:HasTag("fresh") then
		inst.components.eater.ignoresspoilage = true
		inst.components.eater.SetCanEatHorrible = true
        inst.components.eater.stale_hunger = 0.5
        inst.components.eater.stale_health = 0.5
        inst.components.eater.spoiled_hunger = 1
        inst.components.eater.spoiled_health = 1

I know for sure this part is wrong (game is stuck in endless loading,no crash, no lag, just loading) but I believe im on a right track with that one, I just don't know how to check if food have fresh tag.


If there is easier or better way to do that, that's awesome.

Also if there is a way to make alter stale/spoiled food sanity values (just like hunger/health) that would be helpful (I've added 'ignoresspoilage' but i haven't tested it yet so i don't know if it works as i intended it to work; but i want other values for stale and spoiled anyways if it is possible).

Link to comment
Share on other sites

this is what I had in my mod for Wyrdelyn, 

if inst.components.eater ~= nil then
        inst.components.eater:SetAbsorptionModifiers(0, TUNING.WYRDELYN_FOOD_MULT, 1)
        inst.components.eater:SetDiet({FOODGROUP.OMNI, FOODTYPE.BLOOD})

        -- Manual hunger, health, and sanity values (divided by food multiplier to compensate for food multiplier)
        inst.components.eater.Eat_orig = inst.components.eater.Eat
        function inst.components.eater:Eat(food)
            local _edible = food.components.edible
            if food and _edible and self:CanEat(food) then
                if food.prefab == "garlic" then
                    _edible.healthvalue = 0
                    _edible.hungervalue = 12 / TUNING.WYRDELYN_FOOD_MULT
                    _edible.sanityvalue = 1
                elseif food.prefab == "garlic_cooked" then
                    _edible.healthvalue = 0
                    _edible.hungervalue = 12 / TUNING.WYRDELYN_FOOD_MULT
                    _edible.sanityvalue = 3
                elseif _edible.foodtype == "BLOOD" then
                    _edible.healthvalue = _edible.healthvalue
                    _edible.hungervalue = _edible.hungervalue / TUNING.WYRDELYN_FOOD_MULT -- wait why am i doing this?
                    _edible.sanityvalue = _edible.sanityvalue
                    _edible.healthvalue = 0
                    _edible.sanityvalue = 0
                    inst.components.talker:Say("It doesn't taste like much of anything.") -- add more lines
        return inst.components.eater:Eat_orig(food)

you can ignore the setdiet part entirely aswell as the vamprism and talker things i have, and I am dividing something because iirc this overrides absorptionmodifiers

(i kept this in my characters master_postinit)

Edited by TemporarySolutn
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...