Sign in to follow this  
GalloViking

Bonus/Malus to cookpot food based on ingedients

Recommended Posts

GalloViking    204

Greetings you wonderful people, I am making a new character, but I haven't done any modding in a long time now, so I'm a bit rusty and need some help.

Basically, this character should get a hunger boost from eating cookpot food made using a sweetener (honey/honeycomb) and a malus to everything else. While I could change every food item in the game in the modmain file (PostInit), that seems like a last ditch solution. I was wondering if there wasn't a much better way to do that as a function in the character prefab instead?

Additionally, I would like to know if it was possible to allow that character to make Warly's fresh fruits crepes (not the other recipes) with the regular cookpot.

Edited by GalloViking

Share this post


Link to post
Share on other sites

1. Hunger boost from honeyed food

local function OnEat(inst, food)
  local foodhunger = food.components.edible:GetHunger(food)
  if food:HasTag("honeyed") then
    inst.components.hunger:DoDelta(foodhunger * 0.7) -- 80% + 70% = 150% of original hunger
  end
end
==============================
inst.components.eater:SetAbsorptionModifiers(1, 0.8, 1) -- middle one is hunger, 80% from everything
inst.components.eater:SetOnEatFn(OnEat)

This stuff is kinda easy because bearger finds "honeyed" foods, so already related tag is available.

 

2. Fresh Fruits Crepes

This one is tricky, since warly exclusive food is, actually portable crock pot's exclusive food.

If you're cooking on regular crock pot, even warly can not cook exclusive foods.

This means, you should make everyone can cook crepes, or make unique crock pot (that could cook regular foods and crepes) to your character.

local freshfruitcrepes =
    {
        test = function(cooker, names, tags) return tags.fruit and tags.fruit >= 1.5 and names.butter and names.honey end,
        priority = 29,	--changed priority from 30
        foodtype = FOODTYPE.VEGGIE,
        health = TUNING.HEALING_HUGE,
        hunger = TUNING.CALORIES_SUPERHUGE,
        perishtime = TUNING.PERISH_MED,
        sanity = TUNING.SANITY_MED,
        cooktime = 2,
        potlevel = "high",
        --floater = nil,
    },

AddCookerPostInit("cookpot", freshfruitcrepes)

This is Crepes-for-all method.

but I'm not sure it would work... since there are original crepes still in base game, it may crash when cooking on portable crockpot.

Share this post


Link to post
Share on other sites
GalloViking    204

Hi!! Thank a lot for your answer, you're a chad. I had no idea about the honeyed tag, so that saves me a lot of troubles. I'll have to give that a try and maybe find a workaround for the crepes if it indeed does cause a crash to Warly players.

 

Edit: The honeyed tag doesn't apply to food items in Hamlet (tea, iced tea, gummy cake) so I did it another way by manually adding the "sweetened" tag to eligible foods and changing your code accordingly.

 

Edit 2: small error in your freshfruitcrepe code (was it for DST instead of DS?). I have changed

foodtype = FOODTYPE.VEGGIE, --and
AddCookerPostInit("cookpot", freshfruitcrepes)

to

foodtype = "VEGGIE", --and
AddCookerRecipe("cookpot", freshfruitcrepes)

instead and that fixed it, but the crepes are now invisible in the pot.

Edited by GalloViking

Share this post


Link to post
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
Sign in to follow this