Jump to content

Code damage to HP?


Recommended Posts

I can sort of do this already using a negative health regen rate, but it's not ideal.  I want this character to take damage when out in the summer sun, or in general be able to change their health, but at the moment, my code doesn't seem to trigger any kind of damage animation.  I've been poking around the code, and just ca't find a way to activate any sort of effect.

Oh, and I'm guessing reducing health is something like "inst.components.health.current = inst.components.health.current - #" but that seems silly and wrong..

Link to comment
Share on other sites

have you take a look at the overheating/freezing mechanism? 
they add the damage to health with do delta

self.inst.components.health:DoDelta(-self.hurtrate * dt, true, "cold")

self.inst.components.health:DoDelta(-(self.overheathurtrate or self.hurtrate) * dt, true, "hot")

 

for the function 
function Health:DoDelta(amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb)

Link to comment
Share on other sites

I’ll take another look.  I did change the character’s damage via freezing, overheating, and fire, but it wasn’t using code as eligant as what you provided.  Still, I’ll look through the relevant config files and see what I can dig up.

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
 Share

×
×
  • Create New...