2021-06-15 17:27:30 +02:00
|
|
|
//---
|
|
|
|
// enemies: List of enemies and their properties
|
|
|
|
//---
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-12-25 11:47:22 +01:00
|
|
|
#include "comp/entity.h"
|
|
|
|
#include "comp/mechanical.h"
|
2021-12-29 12:02:51 +01:00
|
|
|
#include "comp/fighter.h"
|
2022-02-03 17:39:57 +01:00
|
|
|
#include "game.h"
|
2021-06-15 17:27:30 +02:00
|
|
|
#include "geometry.h"
|
|
|
|
#include "anim.h"
|
|
|
|
|
|
|
|
/* enemy_t: Static enemy information */
|
2022-02-08 22:48:08 +01:00
|
|
|
typedef struct
|
2021-12-25 11:47:22 +01:00
|
|
|
{
|
|
|
|
/* Enemy name (shown in wave information) */
|
2021-06-15 17:27:30 +02:00
|
|
|
char const *name;
|
|
|
|
/* Map hitbox (represents ground size, collides with walls) */
|
2021-10-24 21:54:37 +02:00
|
|
|
rect hitbox;
|
2021-08-15 11:05:04 +02:00
|
|
|
/* Idle animation, death animation, damage animation */
|
2021-12-25 18:21:31 +01:00
|
|
|
anim_t *anim_idle, *anim_walking, *anim_attack, *anim_hit, *anim_death;
|
2021-06-15 17:27:30 +02:00
|
|
|
/* Movement parameters */
|
2021-12-25 11:47:22 +01:00
|
|
|
mechanical_limits_t limits;
|
2021-06-25 11:44:29 +02:00
|
|
|
/* Statistics model */
|
2022-05-31 21:42:43 +02:00
|
|
|
fighter_stats_t stats_base, stats_growth;
|
2021-12-28 21:10:34 +01:00
|
|
|
/* Level */
|
|
|
|
uint8_t level;
|
2021-12-25 11:47:22 +01:00
|
|
|
/* Shadow size */
|
|
|
|
uint8_t shadow_size;
|
2022-01-17 18:29:05 +01:00
|
|
|
/* XP points attributed on death */
|
|
|
|
uint16_t xp;
|
2021-12-25 11:47:22 +01:00
|
|
|
/* Rendering elevation */
|
|
|
|
fixed_t z;
|
2022-02-13 17:07:24 +01:00
|
|
|
/* Size of the monster-specific data structure for IA */
|
|
|
|
size_t ai_data_size;
|
2021-06-25 11:44:29 +02:00
|
|
|
|
2021-06-15 17:27:30 +02:00
|
|
|
} enemy_t;
|
|
|
|
|
|
|
|
/* List of enemies */
|
|
|
|
enum {
|
|
|
|
/* ID 0 is used for the player! */
|
2023-01-16 10:37:48 +01:00
|
|
|
ENEMY_SLIME_1 = 1,
|
|
|
|
ENEMY_BAT_2 = 2,
|
|
|
|
ENEMY_FIRE_SLIME_4 = 3,
|
|
|
|
ENEMY_ALBINOS_BAT_6 = 4,
|
|
|
|
ENEMY_GUNSLINGER_8 = 5,
|
|
|
|
ENEMY_WATER_SLIME_8 = 6,
|
|
|
|
ENEMY_CHEMICAL_SLIME_10 = 7,
|
2021-06-15 17:27:30 +02:00
|
|
|
};
|
|
|
|
|
2022-02-08 22:48:08 +01:00
|
|
|
/* Dynamic enemy information. */
|
|
|
|
typedef struct enemy_data {
|
|
|
|
enemy_t const *id;
|
|
|
|
/* Current pathfinding direction */
|
|
|
|
vec2 pathfind_dir;
|
|
|
|
/* Number of frames left until next pathfinding cycle */
|
|
|
|
uint8_t pathfind_cycles;
|
2022-02-13 17:07:24 +01:00
|
|
|
/* Pointer to AI-specific data */
|
|
|
|
void *ai_data;
|
2022-02-08 22:48:08 +01:00
|
|
|
|
|
|
|
} enemy_data_t;
|
|
|
|
|
2021-12-28 22:23:09 +01:00
|
|
|
/* Get enemy data by ID. */
|
|
|
|
enemy_t const *enemy_data(int enemy_id);
|
|
|
|
|
2021-06-15 17:27:30 +02:00
|
|
|
/* Create a new enemy of the given type. */
|
2021-12-28 21:10:34 +01:00
|
|
|
entity_t *enemy_make(int enemy_id);
|
2022-02-03 17:39:57 +01:00
|
|
|
|
|
|
|
/* Run enemy AI for an entity */
|
|
|
|
void enemy_ai(game_t *g, entity_t *e, fixed_t dt);
|