Lumina Posted November 28, 2016 Share Posted November 28, 2016 Hello, I want to add a custom food as a food that bunnyman will accept for becoming friend, like they accept carrot. For pig it seems easy, they accept meat, for bunnyman i'm a little lost since the code seems more specific and i don't know how to change it properly. Thanks for any help you can give Link to comment https://forums.kleientertainment.com/forums/topic/72097-adding-food-for-befriend-bunnyman/ Share on other sites More sharing options...
Aquaterion Posted November 28, 2016 Share Posted November 28, 2016 The only line I see different is if item.prefab == "carrot" or item.prefab == "carrot_cooked" then --to if item.components.edible.foodtype == FOODTYPE.MEAT or item.components.edible.foodtype == FOODTYPE.HORRIBLE then 1 uses specific prefabs, and 1 uses foodtypes. You can literally just paste the pigman part over the bunnyman part, and change it to FOODTYPE.VEGGIE for example Link to comment https://forums.kleientertainment.com/forums/topic/72097-adding-food-for-befriend-bunnyman/#findComment-842750 Share on other sites More sharing options...
Lumina Posted November 28, 2016 Author Share Posted November 28, 2016 @Aquaterion Thanks So i should just change both lines in those functions ? How do i do the change ? I copy the changed functions in " AddPrefabPostInit" of bunnyman ? local function ShouldAcceptItem(inst, item) return ( --accept all hats! item.components.equippable ~= nil and item.components.equippable.equipslot == EQUIPSLOTS.HEAD ) or ( --accept food, but not too many carrots for loyalty! item.components.edible ~= nil and ( (item.prefab ~= "carrot" and item.prefab ~= "carrot_cooked") or inst.components.follower.leader == nil or inst.components.follower:GetLoyaltyPercent() <= .9 ) ) end local function OnGetItemFromPlayer(inst, giver, item) --I eat food if item.components.edible ~= nil then if item.prefab == "carrot" or item.prefab == "carrot_cooked" then if inst.components.combat:TargetIs(giver) then inst.components.combat:SetTarget(nil) elseif giver.components.leader ~= nil then giver:PushEvent("makefriend") giver.components.leader:AddFollower(inst) inst.components.follower:AddLoyaltyTime( giver:HasTag("polite") and TUNING.RABBIT_CARROT_LOYALTY + TUNING.RABBIT_POLITENESS_LOYALTY_BONUS or TUNING.RABBIT_CARROT_LOYALTY ) end end if inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end end Link to comment https://forums.kleientertainment.com/forums/topic/72097-adding-food-for-befriend-bunnyman/#findComment-842766 Share on other sites More sharing options...
DarkXero Posted November 30, 2016 Share Posted November 30, 2016 local mybunnyfoods = { berries = { loyalty_time = 240, polite_bonus = 120, }, berries_cooked = { loyalty_time = 240, polite_bonus = 120, }, } AddPrefabPostInit("bunnyman", function(inst) if inst.components.trader then local _ShouldAcceptItem = inst.components.trader.test inst.components.trader.test = function(inst, item) return ( _ShouldAcceptItem(inst, item) ) or ( item.components.edible ~= nil and ( (mybunnyfoods[item.prefab] ~= nil) or inst.components.follower.leader == nil or inst.components.follower:GetLoyaltyPercent() <= 0.9 ) ) end local _OnGetItemFromPlayer = inst.components.trader.onaccept inst.components.trader.onaccept = function(inst, giver, item) _OnGetItemFromPlayer(inst, giver, item) if item.components.edible ~= nil then local validfood = mybunnyfoods[item.prefab] if validfood then if inst.components.combat:TargetIs(giver) then inst.components.combat:SetTarget(nil) elseif giver.components.leader ~= nil then giver:PushEvent("makefriend") giver.components.leader:AddFollower(inst) inst.components.follower:AddLoyaltyTime( giver:HasTag("polite") and validfood.loyalty_time + validfood.polite_bonus or validfood.loyalty_time ) end end if inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end end end end end) You could also copypaste everything. Link to comment https://forums.kleientertainment.com/forums/topic/72097-adding-food-for-befriend-bunnyman/#findComment-843297 Share on other sites More sharing options...
Lumina Posted November 30, 2016 Author Share Posted November 30, 2016 Thanks, @DarkXero, you are amazing as ever ! Will try it soon. Link to comment https://forums.kleientertainment.com/forums/topic/72097-adding-food-for-befriend-bunnyman/#findComment-843385 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