The time has come when I have to implement stats for players and non-playing entities. This is a subject I've been avoiding for some time but I've had some thoughts about how to model/implement the concept.
Here are my notes so far - input is appreciated: Do you see weaknesses in the approach, have you tried something similar, or have you perhaps solved the problem in a totally different ways?
Stats layers:
Contains: max Walk/run speed,damage for weapontypes, attack speed, maxhealth, maxmana, health/mana regen. str/dex/wis/con etc.
Layer 0 - base stats for entity types / character classes. From Config files (Using prototype pattern - no need to read config files more than once)
http://gameprogrammingpatterns.com/prototype.html
- players draw base stats from class-based config. What happens to existing players if config changes? See Layer 1
Layer 1 - personal base stats. Only for players?. Saved in DB (Recalculate functionality useful for bug-fixing or respeccing)
could be the value the player sees in the stat window
= Layer 0 + level gains and chosen Stat allocations
= Layer 0 + individual modifications for monsters? Perhaps some monsters are "elite" but share Layer 0 with non-elite.
Layer 2 - stats with equipment and buffs/debuffs. (Can be shown in paranthesis in stat window - perhaps separate eq and buff/debuff?)
recalculate a Layer 2 member for each use? or recalculate entire layer 2 when equipment and buffs/debuffs change?
Considerations:
Ease of implementation
Added complexity - this is especially bad if the rest of the system is affected. Black-box preferred
Performance
Note:
Some stats may influence others (more str = more damage etc.) - some stats may not exist in lower layers but instead be a result of more basic stats?
Stats may also have a volatile character - health is constrained by max health and affected by health regen. But at the same time it should perhaps still be saved in DB so you can't log out just to regen