Zer000 Posted January 8, 2017 Share Posted January 8, 2017 (edited) I can't figure out how to make a special sanity regen bonus only for cpecific character?For example, i wear bearger vest and gain +10 sanity/minute. I tried this, but it doesnt seem to work: Spoiler AddPrefabPostInit("beargervest", function(inst) local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_body", "torso_bearger", "swap_body") if owner.components.hunger then owner.components.hunger.burnrate = TUNING.ARMORBEARGER_SLOW_HUNGER end inst.components.fueled:StartConsuming() if owner:HasTag("nikmikwrithe") then inst.components.equippable.dapperness = TUNING.DAPPERNESS_HUGE * 3.5 --owner.components.sanity.dapperness = TUNING.DAPPERNESS_HUGE * 2.5 end end --inst.components.equippable:SetOnEquip( onequip ) end) Edited January 8, 2017 by Zer000 Link to comment https://forums.kleientertainment.com/forums/topic/73203-sanity-regen-from-clothes-for-custom-character/ Share on other sites More sharing options...
zUsername Posted January 8, 2017 Share Posted January 8, 2017 (edited) AddPrefabPostInit("beargervest", function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end local _onequipfn = inst.components.equippable.onequipfn inst.components.equippable.onequipfn = function (inst, owner) _onequipfn(inst, owner) if owner:HasTag("nikmikwrithe") then inst.components.equippable.dapperness = GLOBAL.TUNING.DAPPERNESS_HUGE * 3.5 end end end) Try this. Make sure your character already have "nikmiwrithe" tag. Edited January 8, 2017 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/73203-sanity-regen-from-clothes-for-custom-character/#findComment-856445 Share on other sites More sharing options...
Zer000 Posted March 25, 2017 Author Share Posted March 25, 2017 Sorry, i forgot to reply here Thank you dude, that really helped me so i used it in my mods. Link to comment https://forums.kleientertainment.com/forums/topic/73203-sanity-regen-from-clothes-for-custom-character/#findComment-890901 Share on other sites More sharing options...
CarlZalph Posted March 25, 2017 Share Posted March 25, 2017 15 minutes ago, Zer000 said: Sorry, i forgot to reply here Thank you dude, that really helped me so i used it in my mods. Problem with the code snippet there is that it doesn't reset its value for other classes, so if you equip it with the custom character and then give it to someone else it'll be buffed. A better approach is to edit the GetDapperness function instead: AddPrefabPostInit( "beargervest", function(inst) if not GLOBAL.TheWorld.ismastersim then return end local GetDapperness_old = inst.components.equippable.GetDapperness inst.components.equippable.GetDapperness = function(self, owner, ...) local original_dapperness = GetDapperness_old(self, owner, ...) if owner.prefab=="wilson" then return original_dapperness - inst.components.equippable.dapperness + GLOBAL.TUNING.DAPPERNESS_HUGE * 3.5 end return original_dapperness end end ) Using prefab name instead of a tag for server-side optimization (HasTag is more expensive than a string check, but it works on both client/server). Since this edit is server-side only the method isn't used. If you have multiple characters sharing the same tag then go for the tag usage. Link to comment https://forums.kleientertainment.com/forums/topic/73203-sanity-regen-from-clothes-for-custom-character/#findComment-890912 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