Jump to content

How do I make my character change depending on how his stats are?

Recommended Posts

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

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
	if data.newpercent > 0.5 then
		-- do something if the new sanity percentage is higher than 0.5 (50%)
		-- do something else

-- Put this in your character's initialization function
inst:ListenForEvent("sanitydelta", onsanitydeltachange)


Edited by Ultroman
Link to comment
Share on other sites

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