Player Health - UQdeco2800/2021-studio-6 GitHub Wiki
Descriptions
Health constitues the major stat element of the player and is essential for combat interactions. In order to create a more dynamic system, the player's health will be made up of two connected elements that together reflect the player's state; their Wound State and State Health. Each of these elements changes in different capacities but rely on each other.
Wounded States
The player's wounded state represents their character's current physical shape on a more broad sense and how close the character is to death. Each state, starting from Healthy, shows the characters progressively worsening health until they reach the final state, Dead. At the moment, the states are as follows:
Healthy (State 3) -> Wounded -> On Death's Door -> Dead (State 0)
Additionally, the player's current wounded state confers debuffs on other player statistics to reflect their current physical state (See Player Statistics).
Wound Change
The player's state only goes down (gets worse) if that state's health level is depleted (discussed below). Additionally, the player's state only improves under 2 circumstances; the player picks up a health item (improves state by one level) or the player starts/restarts the level (the state is reset to 3, the maximium state).
Methods:
int getWoundedState(): Returns the integer value of the players current wound state.
- Healthy = 3
- Wounded = 2
- On Death's Door = 1
- Dead = 0
void setWoundedState(int state): Takes an integer value to set the player's current state to. Will check against maximium (3) and minimium (0). Will set at max or min if over those values. Also changes and sets player state health max.
Boolean isDead(): Returns true if the player's wound state is 'Dead'.
Boolean atMax(): Returns true if the player's wound state is at max i.e. Healthy/3
Design Justification:
The idea behind the wound state system is to twofold. First is to create a hierarchal approach that allows appropriate interaction with other player elements, specifically statistics and appearance, to more accurately and immersively reflect the player. This includes modifying player stats and changing the player sprite to a wounded appearance to reflect injuries. The second reason is for more dynamic combat that rewards good player performance without punishing players that are losing. This is discussed in further detail in the state health justification.
State Health
Alongside the wounded state of the player, each wound state will have a specific health points, similar to most traditional games. However, each wound state has a differing hp. In the current iteration, the highest wound state (Healthy) will have the least amount of hp while the lowest non-dead state (On Death's Door) will have the highest. At the moment, the state hp is as follows:
Healthy = 3 hp -> Wounded = 4 hp -> On Death's Door = 5 hp -> Dead (State 0)
State Health Change
A player's state hp only goes down when they receive damage. Once they run out of hp for their current state, their wound state will decrease. However, the player's state hp can passively regenerate to the state's maximium after an amount of time passes without the player taking another hit.
Methods:
int getHealth(): Returns the integer value of the players current state hp.
int getStateMax(): Returns the integer value of the players current state hp maximium.
void setStateMax(int newMax): Sets the integer value of the players current state hp maximium.
void setHealth(int state): Override Takes an integer value to set the player's current state health. Will check against current maximium, setting to the bounds if over. Handles changing wound state if state hp is reduced completely.
void increaseStateMax(int increaseLevel): Takes an integer value to increase the player's state hp maximium with. Should increase the maximium of each state simultaneously. Designed to allow for stat improvement later on when upgrading is introduced.
Design Justification:
The state health point system is designed to compliment the wound states by creating a more forgiving experience without proving too easy. The idea was to always provide the player with a health buffer regardless of their state, which is why the worse wound states have more state hp. That way, a player should realistically never be in a situation where they are always one hit away from dying. Even if a player gets to the final wound state (On Death's Door), they still have a large buffer of health between them and death. At this point, it would either take reckless behaviour (not waiting for health to regen) or a challenge by enemies to kill the player. Additionally, having increasing state hp with decreasing wound states reflects how easy it is to get scratched or cut but how hard it is to actually die. Separating the wound state and state hp also allows for easier stat improvements, as increasing the maximium wound states would adversly interect with player appearance and stats while state hp max is just a value that can be adjusted.
Additional Feature Methods
void hit(CombatStatsComponent attacker): Takes in a attacker component to get an attack value from. Calculates the hp that the player will loss based on enemy attack value and player defence stat. The player will always take a minimium of 1 hp from any attack regardless of defence. Will interupt any in-progress health regen timers and will start a new timer through regenStart. Also sets a small invincibility timer that prevents damage for a short time (0.5 seconds).
void regenStart(): Function to handle passive state health regen. Creates and schedules a timer to mange it. Will heal one point of health each tick (5 seconds) and if the player's health is at maximium, will cancel the timer.
void invincibleStart(): Function to handle small invincibility period after being hit. Creates a timer that prevents damage for a small period of time.
Design Justification:
The intention behind the limited health regeneration is to ensure that the player always has a decent buffer before dying, reducing player frustration with unintended/unexpected deaths while still maintaining a sense of difficulty. The inclusiong and implementation of the invincibility frames is similarily there to reduce player frustration, specifically in situation that they cannot control or get overwhelmed in. Sometimes, games can unintentionally create very difficult situations for players. For instance, unlucky enemy spawning can create a scenario in which the player can not realistically expect to survive, as all the enemies might be able to attack the player simultaneously, thus creating an unfair interaction. As such, invincibility frames would drastically increase the player's likelihood of survival without negatively impacting the gameplay or the difficulty.
Ideation
The maximium number of wounded states was originally 5 (Health -> Scratched -> Wounded -> Badly Wounded -> On Death's Door) but this was cut down to the current 3 (Healthy -> Wounded -> On Death's Door). At the time, this was done for 2 reasons. Firstly, it overcomplicated the changing player states, as having the attack damage and speed modified on every state with that many states would have created balance issues, even more so when considering further developments in later sprints (i.e. the introduction of abilities and their interplay with player stats). The secondary reason was to reduce confusion and overall simplfy the experience for users. As it stands, the wound system still takes time to get used to so it benefited greatly from being reduced in complexitity, both on a visual and technical level. Additionally, incorporating 3 states still allows for the original intention of the system.