RogueLife/src/comp/fighter.h

59 lines
1.7 KiB
C
Raw Normal View History

//---
// 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"
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;
typedef struct
{
/* Current attack's effect area */
entity_t *current_attack;
/* Whether attack follows movement */
uint8_t attack_follows_movement;
/* Pointer to enemy data (NULL if player) */
struct enemy const *enemy_data;
/* Combat statistics */
uint16_t HP, ATK, MAG, DEF, HP_max;
/* 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;
/* 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. */
fixed_t actions_cooldown_total[5];
/* Current cooldown; positive while waiting, zero when the skill or item is
ready. */
fixed_t actions_cooldown[5];
} fighter_t;
/* 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);
/* 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);