Jump to content

Recommended Posts

Hi!
I'm quite new to modding, but I wanted to make my own character. The problem that I've run into is that I want him to lose a bit of sanity when killing any insect creatures (butterflies, bees, Glommer, etc). I also want him to reject eating fish, or any dish that requires fish, much like Wigfrid will only eat meaty foods and will reject anything without meat. I've tried poking around Wigfrid's files for anything relating to restrictive diets, but even then I'm not sure how I'd implement that in a way that accomplishes my goal. How might I go about this?
Thank you very much!

On 1.12.2019 at 8:08 PM, DandyDee said:

I want him to lose a bit of sanity when killing any insect creatures (butterflies, bees, Glommer, etc).

Here's an example with just insects and Glommer:

inst:ListenForEvent("killed", function(inst, data)
	local victim = data.victim
	if not victim then
		return
	end
	if victim:HasTag("insect") or victim:HasTag("glommer") then
		inst.components.sanity:DoDelta(-5)
	end
end)

Now,

On 1.12.2019 at 8:08 PM, DandyDee said:

I also want him to reject eating fish, or any dish that requires fish, much like Wigfrid will only eat meaty foods and will reject anything without meat. I've tried poking around Wigfrid's files for anything relating to restrictive diets, but even then I'm not sure how I'd implement that in a way that accomplishes my goal. How might I go about this?

this poses a problem. There is no separate FOODTYPE for foods with fish in them. They are part of the FOODTYPE.MEAT group. This is curious, as in the preparedfoods.lua we can clearly see which recipies require an ingredient to have the tag "fish", but sadly the values you can read and change are for the food product itself and not the ingredients. I would love to tell you that there was an algorithmic way of determining recipes which were made from fish, but it's just not possible with the current system. All you can do, is write an extension to the CanEat function of your character, manually barring them from eating certain prefabs. This will be good enough for any original content, but you will manually have to add any modded recipes, as well, if you want your character to not eat those.

To see how to do this, go to this forum post and search the page (CTRL-F) for: Making Specific Foods Inedible

Edited by Ultroman

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...