Donnervogel Posted February 18, 2015 Share Posted February 18, 2015 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 endend Link to comment https://forums.kleientertainment.com/forums/topic/51120-help-perk-sanity-drain-when-holding-a-weapon/ Share on other sites More sharing options...
ArCraMiCia Posted February 18, 2015 Share Posted February 18, 2015 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 prefabsinst:AddComponent("dapperness") inst.components.dapperness.dapperness = TUNING.CRAZINESS_MED * 3.75 just try it :3 Link to comment https://forums.kleientertainment.com/forums/topic/51120-help-perk-sanity-drain-when-holding-a-weapon/#findComment-614203 Share on other sites More sharing options...
Jjmarco Posted February 18, 2015 Share Posted February 18, 2015 @Donnervogel, Make your character listen to the equip event:inst:ListenForEvent("equip", onequip) -- in master_postinitlocal 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 Link to comment https://forums.kleientertainment.com/forums/topic/51120-help-perk-sanity-drain-when-holding-a-weapon/#findComment-614248 Share on other sites More sharing options...
Donnervogel Posted February 19, 2015 Author Share Posted February 19, 2015 @Jjmarco Thanks so much! Link to comment https://forums.kleientertainment.com/forums/topic/51120-help-perk-sanity-drain-when-holding-a-weapon/#findComment-614719 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