Wexen Posted November 16, 2018 Share Posted November 16, 2018 Hello! So, I plan on making a character that changes depending on his stats. Now, since he is some kind of hybrid he will be faster than normal characters. I wish to make him slower to a normal speed once he reaches some % of his HP, since it will be lower than average is, making me cautious of it. Also when his sanity drains I thought about making his eyes glow! Now, can someone tell me, is that possible? What does it require if it is? I have many ideas for him, to make him useful when I play him but not OP as many people do since struggle in DST is fun, but I never did stuff like this. Link to comment Share on other sites More sharing options...
Ultroman Posted November 17, 2018 Share Posted November 17, 2018 (edited) Definitely possible. With all that you want going on with your character, I suggest creating your own component, which can then do all of this each tick. Alternatively, you can simply listen to the events called by the health- and sanity-components when they're changed. For health it's the event "healthdelta" and for sanity it's the event "sanitydelta". Here's an example of adding a "sanitydelta" listener. You can see what the "data" parameter holds if you look in the DoDelta functions of the components. local function onsanitydeltachange(inst, data) if inst:HasTag("playerghost") or inst.components.health:IsDead() then return end if data.newpercent > 0.5 then -- do something if the new sanity percentage is higher than 0.5 (50%) else -- do something else end end -- Put this in your character's initialization function inst:ListenForEvent("sanitydelta", onsanitydeltachange) Edited November 17, 2018 by Ultroman Link to comment 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