Public Group

# [LUA] making health and hurt values?

This topic is 2837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,
I am new to LUA coding and I like to know a few things.
How can I make a health function with certain hurtvalues,
Such as drouwning and fall damage?
And the best question, where is the best place to learn LUA?

I hope someone can help me,
Regards,

##### Share on other sites
You could start here for learning LUA

##### Share on other sites
Programming in Lua is a fantastic book and there's an online version available. Lua's a great language to learn and I can't stress enough the importance of grokking it.

As for calculating damage, that's one I've struggled with for some time. I have the "solution" I'm currently using and if anyone has any better ideas, I'd love to hear it. I calculate the amount of damage in a collision as an exponential function of velocity. Then, the damage is distributed between the two colliding objects based on a ratio of the two masses. So, if we collide and I'm %20 heavier than you, you take %60 of the damage and I take %40. The damage would be calculated as Ax[sup]2[/sup] where A is some configurable multiplier (you want to make this value adjustable for balancing later on) and x is the combined velocity (accumulative if the objects are heading toward eachother, subtractive if one rear-ends the other). Each object will likely have a damage threshold as well so that they are not taking damage on every little bump.

Drowning isn't something I've given any thought to but it would probably suffice to simply begin subtracting a set amount per sec from health after the player has been under water for some set amount of time (all configurable, of course).

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 11
• 9
• 24
• 44