85 lines
2.5 KiB
C
85 lines
2.5 KiB
C
//---
|
|
// 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 */
|
|
int HP;
|
|
/* Physical attack */
|
|
int ATK;
|
|
/* Magical attack */
|
|
int MAG;
|
|
/* Physical and magical defense */
|
|
int DEF;
|
|
|
|
} fighter_stats_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_data *enemy;
|
|
/* Pointer to player data (NULL if enemy) */
|
|
struct player_data *player;
|
|
/* 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;
|
|
/* List of skills or equipped items. The first entry (skills[0]) usually
|
|
means the normal attack and might be handled separately because of the
|
|
combo system */
|
|
int skills[6];
|
|
/* Cooldown; positive while waiting, zero when the skill/item is ready */
|
|
fixed_t actions_cooldown[6];
|
|
|
|
/* Current status effects */
|
|
fixed_t stun_delay;
|
|
fixed_t invulnerability_delay;
|
|
fixed_t speed_delay;
|
|
|
|
} fighter_t;
|
|
|
|
/* Add equipment stat modifiers */
|
|
fighter_stats_t fighter_stats_add(int amount, ...);
|
|
|
|
/* Instantiate a statistics model at any level */
|
|
fighter_stats_t fighter_stats_instantiate(fighter_stats_t const *base,fighter_stats_t const *slope, int level);
|
|
|
|
/* Initialize fighter's stats by using the instantiated stat model */
|
|
void fighter_set_stats(fighter_t *f, fighter_stats_t const *instance);
|
|
|
|
/* Increase fighter's stats by specified amount */
|
|
void fighter_increase_stats(fighter_t *f, fighter_stats_t const *growth);
|
|
|
|
/* 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);
|
|
|
|
/* Stun the fighter for a specified duration. */
|
|
void fighter_effect_stun(entity_t *e, fixed_t duration);
|
|
|
|
/* Make the fighter invulnerable for a specified duration. */
|
|
void fighter_effect_invulnerability(entity_t *e, fixed_t duration);
|
|
|
|
/* Give the fighter a speed boost for a specified duration. */
|
|
void fighter_effect_speed(entity_t *e, fixed_t duration);
|
|
|
|
/* Free dynamic data (enemy info). */
|
|
void fighter_destroy(entity_t *e);
|