Goregonzola Posted March 23, 2021 Share Posted March 23, 2021 (edited) Hello! As the title says, the perk I would like to apply on my custom survivor is: 1) I would like him to gain 125% more stats from veggies during autumn and spring and 2) 125% more stats from meats during winter and summer. I've found this in Wurt's lua about his veggie boost: Spoiler inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.VEGGIE, 1.33) Now, the problem is, I'm not sure how to add a "function-skeleton" around this inst., to achieve my perk. I don't really know what's the best and most efficient way to trigger this function neither. I would like to ask for a helping hand to solve this puzzle. Noteable: I have other perks with eating. One that provides 2x hunger bonus on every third food, and one that disables negative values on selected foods. I don't really mind if the 125% first or the 200% buff happens first, the only thing I would like to avoid is crashing. Here's the coding for the "every third food perk": Spoiler local function WelnyelOnEat(inst, data) if inst.food_counter == nil then inst.food_counter = 0 --this creates and initializes the food_counter variable if there isn't one already end inst.food_counter = inst.food_counter + 1 --we increase the counter by one cause we just ate (otherwise this function would not have been executed) if inst.food_counter == 2 then -- once we hit 3, we need to apply the bonus inst.components.eater:SetAbsorptionModifiers(1, 2, 1) end if inst.food_counter == 3 then -- once we hit 3, we need to apply the bonus inst.components.eater:SetAbsorptionModifiers(1, 1, 1) inst.food_counter = 0 --we reset the counter afterwards end end Here's the coding for the disable perk: Spoiler local protected_foods = { "monstermeat", "green_cap_cooked", ... } local old_DoFoodEffects = inst.components.eater.DoFoodEffects inst.components.eater.DoFoodEffects = function(self, food_inst) for i, v in ipairs(protected_foods) do if food_inst.prefab == v then return false end end return old_DoFoodEffects(self, food_inst) end Thanks in advance! Have a great day! Edited March 25, 2021 by C_Thun Link to comment Share on other sites More sharing options...
Goregonzola Posted March 24, 2021 Author Share Posted March 24, 2021 EDIT: I came up with the following coding, but it doesn't seem to work in it's current form: Spoiler local function WelnyelSeasonal(inst, season) if season == "spring" or season == "autumn" then inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.VEGGIE, 1.25) inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.MEAT, 1) end if season == "winter" or season == "summer" then inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.VEGGIE, 1) inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.MEAT, 1.25) end end inst:WatchWorldState("season", WelnyelSeasonal) May I ask for a quick tutoring? Link to comment Share on other sites More sharing options...
Goregonzola Posted March 25, 2021 Author Share Posted March 25, 2021 (edited) Problem solved: Spoiler local function WelnyelSeasonal(inst, season) if season == "autumn" then inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.VEGGIE, 1.25) inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.MEAT, 1) elseif season == "spring" then inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.VEGGIE, 1.25) inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.MEAT, 1) elseif season == "winter" then inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.VEGGIE, 1) inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.MEAT, 1.25) elseif season =="summer" then inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.VEGGIE, 1) inst.components.foodaffinity:AddFoodtypeAffinity(FOODTYPE.MEAT, 1.25) end end inst:WatchWorldState("season", WelnyelSeasonal) WelnyelSeasonal(inst, TheWorld.state.season) Edited March 25, 2021 by C_Thun Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now