Skip to content

Battles ~ Stat Changes Design Document

corian-jal edited this page May 1, 2022 · 6 revisions

Stat Changes Design Document

As currently defined in battle_structs.h and described in the general battle design document:

typedef struct stat {

 int speed; //The combatant's speed. Used to determine who goes first in battle.

 int defense; //The defense value of the player. Used in damage calculations.

 int strength; //No description given; presumably the offensive value of the player used for damage calculation.

 int dexterity; //The dexterity of the player. Not implemented yet.

 int hp; //The current HP of the combatant.

 int max_hp; //The max HP of the combatant.

 int xp; //The current XP of the combatant.

 int level; //The current level of the combatant.

} stat_t;

My team had quite a few questions after examining this declaration of player statistics, including

  • What is dexterity? How is it used in battles? Does it not include speed?
  • What stats are used in damage calculation for magic users? A mage may be strong offensively and defensively in terms of magic but not in terms of physicality, so how would this be represented with singular strength and defense stats?

We also wanted to include features from the wishlist and of our own design, such as

  • a limit on move usage by having certain moves expend a resource (e.g. mana)
  • critical hit chance or the odds of randomly getting bonus damage
  • accuracy or the odds of missing, potentially factored on both the side of the player and move

Thus, we would like to change the stat struct to

typedef struct stat {

int max_hp; //The maximum amount of health this unit can currently have.

int hp; //The current health of the unit; the battle ends when this hits 0.

int max_sp; //The maximum amount of skill/special points this unit can currently have.

int sp; //The current amount of skill/special points of the player; magic and skills deplete this resource.

int phys_atk; //The physical damage capacity of the unit; used in damage calculation against phys_def.

int mag_atk; //The magical damage capacity of the unit; used in damage calculation against mag_def.

int phys_def; //The physical damage resistance of the unit; calculated against phys_atk.

int mag_def; //The magical damage resistance of the unit; calculated against mag_atk;

int speed; //How quickly the unit moves; used to determine turn order, with faster units going first.

int crit; //The default odds of this unit getting bonus damage; the value is out of 100.

int accuracy; //The default odds of any move used by this unit hitting the target; the value is out of 100.

int xp; //The current amount of experience points gained by this unit.

int level; //The current level of the unit.

} stat_t;

For the crit and accuracy fields, the default values would be 0 (no chance of a critical hit) and 100 (all moves always hit) respectively, allowing developers to choose if they want the functionality of either for their game. We can use the randnum function in battle_default_objects.h for implementation.

This is the basic set of stats we foresee needing or wanting to include as basic functionality for battles. For any developers interested in further customization, including perhaps non-battle stats for roleplay (e.g. speech, intelligence, etc.), they should feel free to make modifications and take advantage of the global stat functionality in game-state's stats.h

To implement this change, we need to

  • update the NPC, Player Class, and Skill Tree teams on what stats characters will have
  • inform the Skill Tree team of the special point system and discuss adding a cost to skills, if necessary
  • update stat_t and stat_changes_t in battle_structs.h
  • update damage in battle_ai.c
  • update get_random_default_weapon, get_random_default_consumable, and get_random_stat in battle_default_objects.c
  • update consume_battle_item and stat_changes_add_item_node in battle_logic.c
  • update stat_changes_init and stat_changes_undo in battle_state.c
Clone this wiki locally