Health and Defense

Pages: 12
I don't understand the point of having health that is outside the range [0.0, 1.0] when you also involve defense. You can display any number to the user and implement health upgrades as increased defense. Of course, there are different kinds of defense in some games, e.g. percentage-based defense vs hitpoint-based defense, but the latter is only useful in a health system where 1.0 is not max health.

I assume developers simply use strange health values because it's easier to think about - the value presented to the user is the same as the value being worked on in the code - however to me that makes many calculations more difficult as you now need to track the maximum health instead of always knowing that it is 1.0.

This has manifested in Minecraft - the entity health system was changed from integers to floats and yet to be somewhat compatible 1.0 still represented half a heart. Then they added support for altering max health via attributes as well as potion effects, and weird things started happening when mods and plugins expected player's max health to be 20 or 20.0

What are your thoughts on this subject?
Last edited on
I don't understand the point of having health that is outside the range [0.0, 1.0] when you also involve defense.


Different kinds of attacks can draw from different kinds of defense. IE, a magic attack might hurt a mage less, but would hurt a warrior more. Whereas physical attacks might be the opposite.

Likewise, it can alter the behavior of health recovery. Something that recovers 10 HP is going to be less effective on an armorless guy with high HP than it will on a heavily armored guy with low HP.

It all makes perfect sense to me.
What you just said only reinforces the idea that health should be between 0.0 and 1.0. By the way, healing is just negative damage, and can be affected by different kinds of defense just like damage. Rather, I like to think of damage as negative healing. I suppose defense is a bad word to use, but "health delta dampeners" is a bit of a mouthful.
Last edited on
What you just said only reinforces the idea that health should be between 0.0 and 1.0


How so?

Specifically the health recovery. Drinking a potion that recovers 10 HP. You wouldn't be able to have something like that with a normalized health unless you add another "recovery effectiveness" stat. Which is just confusing.
You don't need to add any other stat or effect or modifier. The existing one for increased defense will naturally apply to health restoration too without any modification. Negative numbers aren't a different data type or something.
Last edited on
That makes sense for like a magic spell where you could apply ?inverted? magic defense. But what about a non-magical potion/medkit? Which defense do you use for that?

And does that mean that you could make a potion more/less effective by equipping different armor before drinking?

Not only does that not make sense conceptually, it's also more complicated.
Armor defense will only modify deltas that decrease health. Health increase defense will not care what kind of damage delta or how much.
Last edited on
You don't need to add any other stat or effect or modifier. The existing one for increased defense will naturally apply to health restoration too without any modification.
[snip]
Armor defense will only modify deltas that decrease health.


?? Which is it?
"The existing one for increased defense" refers to "Health increase defense" - sorry for the ambiguity.
Last edited on
Oooohh... okay.

So conceptually... everything is the same... except when health is displayed to the user it is normalized first?

Or you do additional computations at runtime to keep it normalized?


I don't see how that's any better.
Last edited on
I have 2 guys.
One has 430 max health, has armor which prevents 20% of damage and after that decreases damage by addditional 10 points. Additionally he receives 50% more health from medkits.
Second has 210 health, his armor prevents 55% + 12 damage. He receives 5 hp more from medkits.
All damage will deal at least 1 hp of damage no matter what armor is. Also there is kinds of medkits: 10 and 25 hp.

I have troubles to adequately represent it in your system
I'm kind of confused as to what LB is arguing. You think health systems should just be [0.0, 1.0]. I think the issue with that is how do increase health? Do casters have .7 max HP while tanks have .9 max HP? Doesn't leave much room to grow. And defense is more than just increasing your effective life, unless there is only one type of defense that blocks all damage equally. But in something like DotA, you have magic resist and armor which reduces magical damage and physical damage respectively. And then you also have composite damage, which is both, and pure damage which is neither. This would not work in your proposed system.
@Disch: The health values are always in the range [0.0, 1.0] and are only displayed to the player in a better range. If the health is a bar or anything that isn't a readable number then you don't need to worry about it at all.

@MiiNiPaa: Like I said, the math in some cases can be conceptually easier to think about in the hitpoint health system, but it is perfectly possible in my suggested system too.

Assuming that the reference max health for UI is 100 hp:
Guy 1: health upgrade defense of 4.30, armor defense of 0.20, health-upgrade-aware armor defense of 0.10
Guy 2: health upgrade defense of 2.10, armor defense of 0.55, health-upgrade-aware armor defense of 0.12, health-upgrade-aware medkit defense of 0.05
In all cases (ignore the entity involved) health-upgrade-aware minimum-effect defense of 0.01 with highest priority

Obviously the numbers would be dependent on the UI scale, but I did not transform them so that it would be easier to see the correlation.

EDIT: @ResidentBiscuit: as I said in my first post, maximum health changes are represented by defense.
Last edited on
From what i understand LB is proposing having an HPDEF stat. Since its purpose is to represent increased health it gets applied to any damage received.
I can write the code for MiiNiPaa's scenario if required, but I am pretty sure my explanation will clear up confusion.
In all cases (ignore the entity involved) health-upgrade-aware minimum-effect defense of 0.01
If I give them temporary buff which soaks 100% of damage both would be able to withstand only 100 hits. Not accurate representation.

I do not get how your medkit upgrades work. Remember: there are two medkits 10 and 25 health. First guy will get 15 and 37 hp, second will get 15 and 30 hp. And there is theoretical third which gets only 10 and 25.

And I would like formulas - how those numbers would change damage.
Last edited on
MiiNiPaa wrote:
If I give them temporary buff which soaks 100% of damage both would be able to withstand only 100 hits. Not accurate representation.
Then you give that a higher priority than the minimum effect defense.
MiiNiPaa wrote:
And I would like formulas - how those numbers would change damage.
I will write the code, it's easier. But it will take me some time.
Last edited on
You seem to not understand: first guy should take 430 hits before dying even with 100% shield. Second should only withstand 210 hits.

Also note that even though first guy receives more heaklth from medkits, it still takes more medkits to heal him completely than second guy
I think I understand LB's idea. Though it's a little convoluted, so maybe I don't.

Think of it this way:

- Everyone has the same amount of health [0,1]
- "High health" characters have high "resilience" rather than high health.
- If originally you had 100 max HP... you would instead have 100 "resilience".
- If you would lose 10 HP, you would instead lose 10/resilience health (0.1)



So it's essentially the same thing. The only difference is he's keeping health normalized.

But again I don't see how it's any simpler. It just seems more complicated to me.
I posted example where it is too much work to use this system.

I do not think this idea is bad, I just do not think it is a silver bullet. For some types of games it might be fine, even better than standard approach.
For others... not so much.

Good thing would be to allow access and manipulation of health as fraction of max value. Something like .get_health_level() which returns normalized health.

LB, what time zone you are? I always see your threads after midnight when I sleepy and in the morning there always like 3 pages of messages.
Last edited on
Pages: 12