Jump to content

Specailized Diet for Mod (NEED HELP)


Recommended Posts

So I have this mod I'm making for someone and well... they've got a rather odd diet.

Here's the low down, I need a set of codes that can basically do this:

He can only eat foods that are stale or rotten, like stale berries or slop restore more health and hunger , where eating fresh berries deals damage and drains his hunger

And he can eat monster meat safely without as bad negative effects, like Webber can.

I got the iron stomach part cracked I just can't for the life of me figure out how to make fresh foods be detrimental like how Wickerbottom is to stale or spoiled foods.

If I could get some help on this I would really really appreciate it. This mod is pretty much done save this last part.

Link to comment
Share on other sites

I couldn't exactly tell what you want, all I could understand is you want penalties from eating fresh food, right?

If so then this code will make your character take penalty when the food is fresh & bonus from stale & spoiled

Spoiler

inst:ListenForEvent("oneat", function(inst, data) 
	if data.food.components.perishable:IsFresh() then
		inst.components.sanity:DoDelta(-10)
		inst.components.health:DoDelta(-10)
		inst.components.talker:Say("It burns!")
	elseif data.food.components.perishable:IsStale() then
		inst.components.sanity:DoDelta(5)
		inst.components.health:DoDelta(5)
		inst.components.talker:Say("Tasty!")
	elseif data.food.components.perishable:IsSpoiled() then
		inst.components.sanity:DoDelta(10)
		inst.components.health:DoDelta(10)
		inst.components.talker:Say("So delicious!")
	end
end)

 

if you also want your character to receive no sanity or health bonus from fresh food you can put this code as well

Spoiler

inst.components.eater.Eat_orig = inst.components.eater.Eat

function inst.components.eater:Eat(food)
	if food and food.components.edible and self:CanEat(food) and food.components.perishable:IsFresh() then

		if food.components.edible.sanityvalue > 0 then
			food.components.edible.sanityvalue = 0
		end
		if food.components.edible.healthvalue > 0 then
			food.components.edible.healthvalue = 0
		end

	end
	return inst.components.eater:Eat_orig(food)
end

 

put both of these inside your character's master_postinit area , hopefully this is what you wanted :D!

Edited by SuperDavid
forgot to put a "then" in the code
Link to comment
Share on other sites

9 minutes ago, SuperDavid said:

I couldn't exactly tell what you want, all I could understand is you want penalties from eating fresh food, right?

If so then this code will make your character take penalty when the food is fresh & bonus from stale & spoiled

  Reveal hidden contents


inst:ListenForEvent("oneat", function(inst, data) 
	if data.food.components.perishable:IsFresh() then
		inst.components.sanity:DoDelta(-10)
		inst.components.health:DoDelta(-10)
		inst.components.talker:Say("It burns!")
	elseif data.food.components.perishable:IsStale() then
		inst.components.sanity:DoDelta(5)
		inst.components.health:DoDelta(5)
		inst.components.talker:Say("Tasty!")
	elseif data.food.components.perishable:IsSpoiled() then
		inst.components.sanity:DoDelta(10)
		inst.components.health:DoDelta(10)
		inst.components.talker:Say("So delicious!")
	end
end)

 

if you also want your character to receive no sanity or health bonus from fresh food you can put this code as well

  Reveal hidden contents


inst.components.eater.Eat_orig = inst.components.eater.Eat

function inst.components.eater:Eat(food)
	if food and food.components.edible and self:CanEat(food) and food.components.perishable:IsFresh() then

		if food.components.edible.sanityvalue > 0 then
			food.components.edible.sanityvalue = 0
		end
		if food.components.edible.healthvalue > 0 then
			food.components.edible.healthvalue = 0
		end

	end
	return inst.components.eater:Eat_orig(food)
end

 

put both of these inside your character's master_postinit area , hopefully this is what you wanted :D!

AAAAH!!!!! This is exactly what I needed! It works great! Thank you thank you thank you so much! :wilson_ecstatic:

Link to comment
Share on other sites

2 hours ago, Aileen-Rose said:

He can only eat foods that are stale or rotten, like stale berries or slop restore more health and hunger , where eating fresh berries deals damage and drains his hunger

Should he have it that he starves slower since SOME foods take a while to get into stale? Also, can he eat Powdercakes? (-3 Health Item that takes, uh, over 10000 days to perish)

-

By the way, I would definitely try this mod when it comes out 

Edited by DatShadowJK
Link to comment
Share on other sites

Just now, DatShadowJK said:

Should he have it that he starves slower since SOME foods take a while to get into stale? Also, can he eat Powdercakes? (-3 Health Item that takes, uh, over 10000 days to perish)

Funny you should mention that since that is another perk this character in question has.

Link to comment
Share on other sites

7 minutes ago, Aileen-Rose said:

Funny you should mention that since that is another perk this character in question has.

Heh, awesome:wilson_laugh:.. (If I were to host a server with this guy, people would be offering fresh food to me, oh God..)

Edited by DatShadowJK
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
 Share

×
  • Create New...