Jump to content

Recommended Posts

Hi!

I'm trying to make my custom character hate wearing any kind of armor and lose sanity while wearing them. But I am having some trouble with it and I'd like some help. I don't know much about programming but I tried my best. Sorry for any English errors, I speak portuguese.

 

 

I started making it listen to the equip event. When he equips the item he starts losing sanity:

inst:ListenForEvent("equip", unequip) -- master_postinit
local function unequip(inst, data)    if data.item and data.item.components.armor then         inst.components.sanity:DoDelta(TUNING.CRAZINESS_SMALL)         endend

But it only makes he loses sanity in the moment he equips the item and not while wearing it. Furthermore, I tried using only equip instead of unequip to see if it works, but it didn't (I didn't even know if that exists).

 

 

So, if someone can help me I would be very thankful.

 

 

local old = inst.components.sanity.custom_rate_fn

local d = 0

inst.components.sanity.custom_rate_fn = function(inst)

if old then

d = old(inst)

end

if inst.components.inventory and inst.components.inventory:IsWearingArmor() then

return -TUNING.DAPPERNESS_LARGE + d

else

return 0 + d

end

end

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