Using Calculations for Mana and HP

I have not been storing any data like HP/MP in my system. My current system is a bit overkill for the purposes of this lecture but ill drop a simplified method here as an example of a way to calc stats instead of storing them.

2 notes on it:
the 2x and the /100 are just a different way of forcing floats into ints. i like it a bit better than mathf rounding for long calcs as its easier for me to wrap my head around exactly which part of the calc we are rounding at …but you could also cast or mathf(your preferred float to int).

also the reason i added the _startingBonusHP variable is because a 1:1 scale didn’t make huge sense at low levels. my reasoning was basically based on DND. you always max your first hit die when making a character. if we did a paladin without this adjustment in dnd, it would have 6hitdie hp for level 1 instead of 12. its a big delta at low levels so i added that for early game playability.

public int CalculateLevelsBaseMaxHP()
         {
            int maxHealth = ((2 * _characterHPPerLevel) * _level / 100) + _startingBonusHP;
                
      
            return maxHealth;
            
         }

Privacy & Terms