Jump to content

Favorite food code is, wrong?


Recommended Posts

I learned pretty quickly how to assign a favorite food, even multiple foods at once, but the results aren't consistent at all.

inst.components.foodaffinity:AddPrefabAffinity("smallmeat", TUNING.AFFINITY_15_CALORIES_LARGE)

A morsel is a common food, providing a small food value and -10 sanity.  I thought it would be interesting if a character with low sanity liked this food the most, but it suddenly posed a huge risk at the same time.  Thing is, the food value is boosted by 5, not 15, and the negative sanity value entirely disappears.
I tried other meats, and most of their values were boosted by 10 instead of 15, but the negative sanity was consistently removed.  Anyone know what might be happening?  I've been looking and looking for the game's code that controls these values, but haven't found it yet.  It's not a terrible outcome, but it wasn't intended.

Link to comment
Share on other sites

The food affinity has 3 parts. AddTagAffinity, AddPrefabAffinity and AddFoodtypeAffinity. Maybe the character has already a affinity that change the food by another value?

To check it, you could print all all the affinitys the character has, so maybe you can see the problem in the data already (inst.components.foodaffinity:FoodAffinity:HasPrefabAffinity(food) or inst.components.foodaffinity:FoodAffinity:GetAffinity(food))

 

another thing to mention is, that the bonus is only a multipier to what the default hunger value will be. 

AFFINITY_15_CALORIES_TINY = 2.6,
AFFINITY_15_CALORIES_SMALL = 2.2,
AFFINITY_15_CALORIES_MED = 1.6,
AFFINITY_15_CALORIES_LARGE = 1.4,
AFFINITY_15_CALORIES_HUGE = 1.2,
AFFINITY_15_CALORIES_SUPERHUGE = 1.1,

 

and then it returns the "multiplier * self.hungervalue". in your example you add the large bonus to the small meat item. 

small meat has a hunger value of 12.5. if you use the correct bonus ( small) you get 12.5 * 2.2 = 27.5 (exact 15 points more).
but if you add the large bonus it is 12.5 * 1.2 = 15  (only 2.5 points more) so quite less as you might expected.

Link to comment
Share on other sites

@krylincy
Thanks!  I got the affinities tuned correctly now.  I've tried adding the "AddFoodtypeAffinity" code using 'meat' and 'meats' but it just doesn't seem to work.  This is what I'd use to make the character benefit from all meats, right?

Also I've seen the Print command in multiple mods and forum discussions, but have never been able to get it to run.  If you know how to make the game display all affinities or components, that would be a big help.  I'm almost done with the mod, but was looking around manually for the components and other characteristics.  I'm still trying to find out how to check the tags on light sources in the character's inventory.

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