devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Refactor CreatePlayer()

Open kphoenix137 opened this issue 2 years ago • 0 comments

Cleans up CreatePlayer() and changes how a new player's life and mana are constructed in order to avoid a situation in modding where if a class's life/mana gain on level up are increased from current could result in problems if a player in game manages to decrease their base vitality/magic enough. For example, a modder decides Warrior gets 3 life points per base vitality, and then uses shrines to lose all 25 base vitality down to 0. The Warrior would lose 75 base life, but only has 70, and the game will not allow a negative base life, resulting in cheese where the base life can exceed what it should be later on. I also need this PR for life and mana validation in UnpackNetPlayer() (see https://github.com/diasurgical/devilutionX/pull/6289).

The starting life and mana values were added to PlayersData[] with new member variables. The data was obtained by starting new characters at level 1, and reducing all their base stats to 0 to observe life and mana. The new method for constructing these variables grabs the starting life, then applies the base Vitality to result in vanilla-exact values.

kphoenix137 avatar Jun 29 '23 20:06 kphoenix137