Player's Character Statistics
This PR introduces Player's Character Statistics to the game as a structure ready to expand.
Statistics are saved to savegame mpq as separate statistics file. Thus don't break compatibility with vanilla that will just ignore it.
Ready to expand. Currently only few statistisc are added. But the structure is ready to add as many as you like.
Just implement new ones in the game logic, and add in statistics.cpp in LoadStatisticsFromMap() and SaveStatisticsToMap() - by analogy to the currently added ones. Add to Statistics struct if needed.
Forward and backward compatible. Thanks to saving as key->value map it is totally safe to load savegame originating from newer version of game that introcuded more statistics. If savegame is loaded by older version of game that will not support particular statistics - not supported statistics will survive and just be saved without any changes. Game will modifiy only statistics known to it. The rest will stay untouched.
Currently implemented statistics:
- Player (character) Death Count
- Ingame time
- Monster Kill Count support in MP games.
Only Player Death Count is displayed right now (hover exp bar). For more statistics some statistics panel is needed as UI part - yet to be done. But nothing prevents you from adding statistics that will be gathered and displayed layer. Monster Kill Count is displayed as always - but this time also saved per MP character as well. (small modification by me here is count only kills done by My Player - as bug fix).
I experimented with few only, but as you can imagine sky is the limit. You can count and store everything. some ideas: How many times character asked Farnham for gossip, how many arrows she shooted. How many times he blocked. What was highest damage he dealt, or maybe received. What was his priciest buy. How many stairs he took, or town portals from other players. What was his farthest teleport distance. How many games he created or joined. How many messages he typed in a chat, or maybe used debug commands? How many times he said "#$%^&". What is his favourite spell or gear? Which shrines did he took how many times? Or hit by trap. How many items he too from stash, and how many placed in? How many small yellow potion he quaffed. How many times he killed or resurrected other players. How many meters character walked, swim or jump :wink: This also enables achievments (like kill 6666 goats). Take note that it is possible to use it not only as counters. You can let's say store previous character names as coma separated list in one of map position (when change-name feature will be implemented). And many more. At some point maybe save to txt could be added, to print and plant on a fridge. Or even display on some statistics website hosted on server connected to DevilutionX.
If you want more ideas - go take a look at statistics in World of Warcraft (it's free to play as trial with character level limitations). There are literally hundreds if not thousands. It is even better as you can inspect other player statistics there too (as all is stored on server).
Question: have you considered implementing these as custom metrics using OpenTelemetry?
I'm asking because that is something I wanted to do in my mod later on in C#.
Question: have you considered implementing these as custom metrics using OpenTelemetry?
No. To be honest I wasn't familiar with it before. I tried to implement small and simple yet functional and expandable solution to start gathering some measures now. I considered only some composite structure and serialization before putting into savegame file. (Still achievable by parsing properly named metrics). In future development of this area it may be good to use some standarized metrics like OpenTelemetry. So each metric would have label, description, unit, type (counter, measure, observer) and so on. And that way it would be better to show them to external world (like publish on web server maybe). Oh and logs!. Currently I preferred to keep it low and small save locally - as a start of new area. And working proof with hopes to merge it soon. (We do not even have any proper UI for it yet.)
On behalf of the PVP community, we would like Players kills counter and Player deaths counter with Kill/Death Ratio. Perhaps disable incrementing the counter between players that share the same IP address? (To avoid people cheesing their stats with multiple instances of the game open). And it would be nice if the player kill counter would only increment if the target had player hostile set, and likewise, your player death counter would only increment if someone killed you while you had player hostile set.
On behalf of the PVP community, we would like Players kills counter and Player deaths counter with Kill/Death Ratio. Perhaps disable incrementing the counter between players that share the same IP address? (To avoid people cheesing their stats with multiple instances of the game open). And it would be nice if the player kill counter would only increment if the target had player hostile set, and likewise, your player death counter would only increment if someone killed you while you had player hostile set.
that IP idea is so dumb, what will it achieve? dudes just farming KD with another person derp, don't bother
Considering that we don't even know the IP well enough to display it on the host screen I think we can write off that idea anyway.