2021-12-25 11:47:22 +01:00
|
|
|
//---
|
|
|
|
// fighter: Component for entities that participate in fights
|
|
|
|
//
|
|
|
|
// This component gives combat statistics and leveling properties to entities.
|
|
|
|
//---
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "comp/entity.h"
|
|
|
|
#include "fixed.h"
|
2021-12-29 12:02:51 +01:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* Hit Points */
|
|
|
|
fixed_t HP;
|
|
|
|
/* Physical attack */
|
|
|
|
fixed_t ATK;
|
|
|
|
/* Magical attack */
|
|
|
|
fixed_t MAG;
|
|
|
|
/* Physical and magical defense */
|
|
|
|
fixed_t DEF;
|
|
|
|
|
|
|
|
} fighter_stat_model_t;
|
2021-12-25 11:47:22 +01:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* Current attack's effect area */
|
|
|
|
entity_t *current_attack;
|
|
|
|
/* Whether attack follows movement */
|
|
|
|
uint8_t attack_follows_movement;
|
2021-12-28 21:10:34 +01:00
|
|
|
/* Pointer to enemy data (NULL if player) */
|
2021-12-29 12:02:51 +01:00
|
|
|
struct enemy const *enemy_data;
|
2021-12-25 11:47:22 +01:00
|
|
|
/* Combat statistics */
|
2021-12-29 12:02:51 +01:00
|
|
|
uint16_t HP, ATK, MAG, DEF, HP_max;
|
2021-12-25 11:47:22 +01:00
|
|
|
|
|
|
|
/* Number of hits in main attack's combo (TODO: Delegate to weapon?) */
|
|
|
|
uint8_t combo_length;
|
|
|
|
/* Next hit to be dealt */
|
|
|
|
uint8_t combo_next;
|
|
|
|
/* Delay until ideal time to start next hit */
|
|
|
|
fixed_t combo_delay;
|
2022-02-04 10:12:00 +01:00
|
|
|
/* Cooldown to apply for each skill/item. 0 is the standard attack, while
|
|
|
|
1..4 correspond to F1...F4. This value is fixed unless the skills/items
|
|
|
|
are rearranged, which is only possible for the player. */
|
2021-12-25 11:47:22 +01:00
|
|
|
fixed_t actions_cooldown_total[5];
|
2022-02-04 10:12:00 +01:00
|
|
|
/* Current cooldown; positive while waiting, zero when the skill or item is
|
|
|
|
ready. */
|
2021-12-25 11:47:22 +01:00
|
|
|
fixed_t actions_cooldown[5];
|
|
|
|
|
|
|
|
} fighter_t;
|
|
|
|
|
2021-12-29 12:02:51 +01:00
|
|
|
/* Initialize fighter's stats by using the provided stat model */
|
|
|
|
void fighter_set_stats(fighter_t *f, fighter_stat_model_t const *model,
|
|
|
|
int level, fixed_t multiplier);
|
|
|
|
|
2021-12-25 11:47:22 +01:00
|
|
|
/* Damage entity for that amount of raw strength. Returns actual damage after
|
|
|
|
DES is subtracted, and randomization. */
|
|
|
|
int fighter_damage(entity_t *e, int base_damage);
|