shadedareas Posted May 22, 2015 Share Posted May 22, 2015 I thought I'd be able to find this in Woodie's code but it's not making itself clear to me.I can see how to affect Sanity ... but not how to make it a response to chopping a tree down.Any help? Link to comment https://forums.kleientertainment.com/forums/topic/54279-how-can-i-make-a-character-suffer-psych-damage-upon-cutting-down-a-tree/ Share on other sites More sharing options...
DarkXero Posted May 22, 2015 Share Posted May 22, 2015 inst:ListenForEvent("finishedwork", function(inst, data) if data.action == ACTIONS.CHOP then if data.target:HasTag("tree") then if inst.components.sanity then inst.components.sanity:DoDelta(-5) end end end end) Link to comment https://forums.kleientertainment.com/forums/topic/54279-how-can-i-make-a-character-suffer-psych-damage-upon-cutting-down-a-tree/#findComment-639704 Share on other sites More sharing options...
Fancy_Fox_Pers Posted May 22, 2015 Share Posted May 22, 2015 (edited) I don't know if DarkXero's code will only apply when the tree is cut down but in case it does, here's code I got from Wallflower to do it per hit.local function onworked(inst, data) if data.target.components.workable.action == ACTIONS.CHOP then inst.components.sanity:DoDelta(-.5)if inst.components.talker ~= nil theninst.components.talker:Say(GetString(inst.prefab, "ANNOUNCE_KILLED_TREE")) -- Hurt a friendly tree, you should feel bad!end endendAnd make sure toinst:ListenForEvent("working", onworked) Edit: Might as well do the exact same, I'm not sure Edited May 22, 2015 by Thibooms Link to comment https://forums.kleientertainment.com/forums/topic/54279-how-can-i-make-a-character-suffer-psych-damage-upon-cutting-down-a-tree/#findComment-639705 Share on other sites More sharing options...
shadedareas Posted May 22, 2015 Author Share Posted May 22, 2015 THANK YOU! These are perfect. Link to comment https://forums.kleientertainment.com/forums/topic/54279-how-can-i-make-a-character-suffer-psych-damage-upon-cutting-down-a-tree/#findComment-639728 Share on other sites More sharing options...
KawaiiYumiko Posted July 3, 2015 Share Posted July 3, 2015 It's unrelated but I'm curious why do you need this line? What does this do? if inst.components.talker ~= nil then Link to comment https://forums.kleientertainment.com/forums/topic/54279-how-can-i-make-a-character-suffer-psych-damage-upon-cutting-down-a-tree/#findComment-651670 Share on other sites More sharing options...
DarkXero Posted July 3, 2015 Share Posted July 3, 2015 why do you need this line? What does this do? It's not really needed since the player gets the talker component in both human and ghost form.No instance of RemoveComponent("talker") either. It checks that the talker component exists.If you try to index the function Say, and there is no talker component, game crashes.You can't do that to a nil value. Better to check than to run into a once-in-a-lifetime error. Link to comment https://forums.kleientertainment.com/forums/topic/54279-how-can-i-make-a-character-suffer-psych-damage-upon-cutting-down-a-tree/#findComment-651739 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