Jump to content
  • Advertisement
Sign in to follow this  
DennisKluytmans

[LUA] making health and hurt values?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!