Skip to content

Battles ~ Move Changes Design Document

nicholaswlee edited this page May 10, 2022 · 17 revisions

Currently, this is what our current move_t struct looks like

typedef struct move {

battle_item_t *item;

int id;

// NOTE: functions to create move_new do not take into account a name

char* name;

char* info;

bool attack;

int damage;

int defense;

struct move *next;

struct move *prev;

} move_t;

Here are the changes we would like to add/change

This defines what type of damage if any the move would do. We will do this to specify attack.

typedef enum damage_type {

 PHYS, //A move that would inflict physical damage on the opponent.

 MAG; //A move that would inflict magical damage on the opponent. 

 NONE; //A move that does not inflict damage.

} damage_type_t;

This defines who the target is for the move. This would be used for moves that do not do damage, i.e. stat changing ones as well as status effects ones.

typedef enum target_type {

 USER, //A move that targets the user.

 TARGET; //A move that would target the target.

 BOTH; //A move that targets both the user and target. How it affects both can be different.

 NONE; //A move that does not target the opponent nor the user that is not an attacking move.

} target_type_t;

This defines how many targets the move hits.

typedef enum target_count {

 SINGLE, //A move that hits a single target

 MULTI; //A move that hits multiple targets

} target_count_t;

This is the new move_t struct. It will be able to support physical attacking moves, magical attacking moves, status changing moves, and eventually effect inflicting moves. We will not be implementing effects for this pull request.

typedef struct move_t {

 int id; //the unique identifier of the move

 char* name; //the name of the move

 char* info; //a description of what the move does

 damage_type_t dmg_type; //whether a move does physical damage, magical damage, or no damage

 target_type_t stat_mods; //whether a move changes a user's stats, the opponent's stats, both, or neither

 target_type_t effects; //whether a move has an effect that targets the user, opponent, both, or neither

 target_count_t count; 

 int sp_cost; //the amount of sp required to use a move

 battle_item_t* req_item; //an item required to use the move or NULL for none

 int damage; //the damage the move will do

 int accuracy; //the accuracy of the move

 stat_change_t* user_mods; //stat changes for the user

 stat_change_t* opponent_mods; //stat changes for the opponent

 move_t* prev; //the previous move in the list, or NULL for no move

 move_t* next; //the next move in the list, or NULL for no move

} move_t;

Modules and Functions that need to be changed for this implementation

battle_flow.c

We will need to move calculate_crit() to this file.

battle_flow_move()

This function would need to change to accommodate different types of moves. We would have to filter the types using if statements kind of like this after the accuracy check. This also raises some questions as to how battle_print_move.c will have to change. Needs to also account for sp change:

if(move->dmg_type != NONE){

//call the damage function and inflict damage on opponent.

}

if(move->stat_mods != NONE){

//calls a function that would inflict stat changes on opponent and user

}

if(move->effects != NONE){

//calls a function that would inflict affects. Not implemented in the PR

}

enemy_make_move()

See above implementation of enemy_make_move(). It will be very similar.

calculate_accuracy()

We must now think about how to account for the move's accuracy too. This might not be a change to the actual function, but instead the function takes one argument and it is the product of the move's accuracy with the user's accuracy.

battle_print.c

print_battle_move()

This will now need to print messages for stat changes and effect inflictions. Also needs to accommodate for critical hit.

print_battle_miss()

This will need to make sure that it is clear that everything has missed and that damage isn't 0 for a non damaging move.

battle_ai.c

damage()

Needs to accommodate if the move is physical or magical damage.

battle_default_object.c

get_random_default_move.c

Needs to change to accommodate new fields of move_t.

battle_moves.c

move_init

Needs to change to accommodate new fields of move_t.

move_new

Needs to change to accommodate new fields of move_t.

move_free

Freeing move_t may have to become a bit different now that there are different fields.

(example moves)

These need to be updated to accommodate new move_t

Functions to be added

inflict_stat_change(stat_changes_t changes, combatant *target)

This will inflict the stat changes of a move on a user. This will be located in battle_logic.c

Clone this wiki locally