Jump to content

Recommended Posts

I'm trying to set it up so that when a character equips any weapon, they get a small sanity drop. I can't get it to work quite right, this is what I currently have (the underlined portion is what should be the perk):
 
local master_postinit = function(inst)
 
     inst.soundsname = "wolfgang"
 
     inst.components.health:SetMaxHealth(180)
     inst.components.hunger:SetMax(120)
     inst.components.sanity:SetMax(200)
 
     inst.components.temperature.inherentinsulation = 35
 
     local function onequip(inst,object)
          if object:HasTag("weapon") then
               inst.components.sanity:DoDelta(-TUNING.SANITY_TINY)
          end
     end
end

Ah I see this perk is already made in game you should see prefabs of darksword in game data

 

and I got this....in my item prefabs

inst:AddComponent("dapperness")
    inst.components.dapperness.dapperness = TUNING.CRAZINESS_MED * 3.75
  just try it :3
 
     

@Donnervogel, Make your character listen to the equip event:

inst:ListenForEvent("equip", onequip) -- in master_postinit
local function onequip(inst, data) -- above master_postinit    if data.item and data.item.components.weapon then -- if item has weapon component         inst.components.sanity:DoDelta(-TUNING.SANITY_TINY)    endend

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