2011-04-26 12:04:45 +02:00
|
|
|
/*
|
|
|
|
* This software is licensed under the terms of the MIT-License
|
2017-02-11 04:52:08 +01:00
|
|
|
* See COPYING for further information.
|
2011-04-26 12:04:45 +02:00
|
|
|
* ---
|
2018-01-04 18:14:31 +01:00
|
|
|
* Copyright (c) 2011-2018, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2018, Andrei Alexeyev <akari@alienslab.net>.
|
2011-04-26 12:04:45 +02:00
|
|
|
*/
|
|
|
|
|
2017-09-27 14:14:53 +02:00
|
|
|
#pragma once
|
2017-11-25 20:45:11 +01:00
|
|
|
#include "taisei.h"
|
2011-05-08 13:48:25 +02:00
|
|
|
|
2017-03-06 01:25:59 +01:00
|
|
|
#include "util.h"
|
|
|
|
#include "projectile.h"
|
2017-12-13 20:05:12 +01:00
|
|
|
#include "objectpool.h"
|
2018-04-13 21:13:48 +02:00
|
|
|
#include "entity.h"
|
2011-04-26 12:04:45 +02:00
|
|
|
|
2017-11-15 07:05:47 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
#define ENEMY_DEBUG
|
|
|
|
#endif
|
|
|
|
|
2011-06-24 12:35:03 +02:00
|
|
|
typedef struct Enemy Enemy;
|
2018-06-01 20:40:18 +02:00
|
|
|
typedef LIST_ANCHOR(Enemy) EnemyList;
|
2011-07-05 15:20:19 +02:00
|
|
|
typedef int (*EnemyLogicRule)(struct Enemy*, int t);
|
2017-11-15 07:05:47 +01:00
|
|
|
typedef void (*EnemyVisualRule)(struct Enemy*, int t, bool render);
|
2011-04-26 12:04:45 +02:00
|
|
|
|
|
|
|
enum {
|
2011-07-05 15:20:19 +02:00
|
|
|
ENEMY_IMMUNE = -9000,
|
2018-06-01 22:56:02 +02:00
|
|
|
ENEMY_BOMB = -9001,
|
|
|
|
ENEMY_KILLED = -9002,
|
2011-04-26 12:04:45 +02:00
|
|
|
};
|
|
|
|
|
2011-06-24 12:35:03 +02:00
|
|
|
struct Enemy {
|
2018-04-13 21:13:48 +02:00
|
|
|
ENTITY_INTERFACE_NAMED(Enemy, ent);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2011-04-26 12:04:45 +02:00
|
|
|
complex pos;
|
|
|
|
complex pos0;
|
2018-06-01 23:55:37 +02:00
|
|
|
complex pos0_visual;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
|
|
|
long birthtime;
|
|
|
|
|
2012-08-03 17:06:25 +02:00
|
|
|
int dir;
|
2017-02-11 04:52:08 +01:00
|
|
|
bool moving;
|
|
|
|
|
2011-04-26 12:04:45 +02:00
|
|
|
EnemyLogicRule logic_rule;
|
2017-11-15 07:05:47 +01:00
|
|
|
EnemyVisualRule visual_rule;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2018-06-12 21:51:32 +02:00
|
|
|
int spawn_hp;
|
2011-04-26 12:04:45 +02:00
|
|
|
int hp;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2011-05-21 15:02:19 +02:00
|
|
|
complex args[RULE_ARGC];
|
2012-07-18 12:33:37 +02:00
|
|
|
float alpha;
|
2017-11-15 07:05:47 +01:00
|
|
|
|
|
|
|
#ifdef ENEMY_DEBUG
|
|
|
|
DebugInfo debug;
|
|
|
|
#endif
|
2011-06-24 12:35:03 +02:00
|
|
|
};
|
2011-04-26 12:04:45 +02:00
|
|
|
|
2011-06-26 13:45:27 +02:00
|
|
|
#define create_enemy4c(p,h,d,l,a1,a2,a3,a4) create_enemy_p(&global.enemies,p,h,d,l,a1,a2,a3,a4)
|
|
|
|
#define create_enemy3c(p,h,d,l,a1,a2,a3) create_enemy_p(&global.enemies,p,h,d,l,a1,a2,a3,0)
|
|
|
|
#define create_enemy2c(p,h,d,l,a1,a2) create_enemy_p(&global.enemies,p,h,d,l,a1,a2,0,0)
|
|
|
|
#define create_enemy1c(p,h,d,l,a1) create_enemy_p(&global.enemies,p,h,d,l,a1,0,0,0)
|
|
|
|
|
2018-01-12 19:26:07 +01:00
|
|
|
Enemy *create_enemy_p(
|
2018-06-01 20:40:18 +02:00
|
|
|
EnemyList *enemies, complex pos, int hp, EnemyVisualRule draw_rule, EnemyLogicRule logic_rule,
|
2018-01-12 19:26:07 +01:00
|
|
|
complex a1, complex a2, complex a3, complex a4
|
|
|
|
);
|
|
|
|
|
2017-11-15 07:05:47 +01:00
|
|
|
#ifdef ENEMY_DEBUG
|
|
|
|
Enemy* _enemy_attach_dbginfo(Enemy *p, DebugInfo *dbg);
|
|
|
|
#define create_enemy_p(...) _enemy_attach_dbginfo(create_enemy_p(__VA_ARGS__), _DEBUG_INFO_PTR_)
|
|
|
|
#endif
|
|
|
|
|
2018-06-01 20:40:18 +02:00
|
|
|
void delete_enemy(EnemyList *enemies, Enemy* enemy);
|
|
|
|
void delete_enemies(EnemyList *enemies);
|
2011-04-26 12:04:45 +02:00
|
|
|
|
2018-06-01 20:40:18 +02:00
|
|
|
void process_enemies(EnemyList *enemies);
|
2011-04-26 12:04:45 +02:00
|
|
|
|
2018-06-01 22:56:02 +02:00
|
|
|
bool enemy_is_vulnerable(Enemy *enemy);
|
|
|
|
bool enemy_in_viewport(Enemy *enemy);
|
|
|
|
void enemy_kill_all(EnemyList *enemies);
|
|
|
|
bool enemy_damage(Enemy *enemy, int damage);
|
2012-07-19 19:48:17 +02:00
|
|
|
|
2017-11-15 07:05:47 +01:00
|
|
|
void Fairy(Enemy*, int t, bool render);
|
|
|
|
void Swirl(Enemy*, int t, bool render);
|
|
|
|
void BigFairy(Enemy*, int t, bool render);
|
2012-04-04 17:19:53 +02:00
|
|
|
|
|
|
|
int enemy_flare(Projectile *p, int t);
|
|
|
|
|
2017-03-11 04:41:57 +01:00
|
|
|
void enemies_preload(void);
|