2023-08-19 14:18:41 +02:00
|
|
|
#ifndef NPC_H
|
|
|
|
#define NPC_H
|
|
|
|
|
|
|
|
#include "game.h"
|
|
|
|
#include "memory.h"
|
|
|
|
|
2024-07-29 21:04:23 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2024-07-29 11:36:11 +02:00
|
|
|
enum {
|
2024-07-21 02:42:50 +02:00
|
|
|
|
|
|
|
NPC_NONE = 0,
|
2024-07-29 11:36:11 +02:00
|
|
|
NPC_FRIENDLY = 1, // The player's team
|
|
|
|
NPC_HOSTILE = 2, // to the player
|
2024-07-21 02:42:50 +02:00
|
|
|
NPC_ALL = 3
|
|
|
|
|
2024-07-23 18:17:02 +02:00
|
|
|
};
|
2023-08-19 14:18:41 +02:00
|
|
|
|
2024-07-29 11:36:11 +02:00
|
|
|
// Frees then malloc()s a new path to npc
|
|
|
|
// Useful if you want to safely edit a path
|
2024-07-23 18:06:42 +02:00
|
|
|
int npc_clear_path(NPC *npc);
|
|
|
|
|
2024-07-29 11:36:11 +02:00
|
|
|
// Adds point x,y to the path of npc
|
|
|
|
// Won't work on static NPCs, use npc_clear_path before or make them on the heap
|
2024-07-23 18:06:42 +02:00
|
|
|
int npc_append_path(uint16_t x, uint16_t y, NPC *npc);
|
|
|
|
|
2024-07-29 11:36:11 +02:00
|
|
|
// Clears the NPCs path and creates a new one going to dest,
|
|
|
|
// avoiding non-walkable tiles
|
|
|
|
// Returns non-zero on failure
|
2024-07-27 14:02:04 +02:00
|
|
|
int npc_pathfind(int32_t dest_x, int32_t dest_y, Map *full_map, NPC *npc);
|
|
|
|
|
2024-07-29 11:36:11 +02:00
|
|
|
// realloc()s npcRPG to adequate size and returns a pointer to the new element
|
|
|
|
// Returns NULL on failure
|
2024-07-27 14:02:04 +02:00
|
|
|
NPC *npc_create();
|
|
|
|
|
2024-07-29 11:36:11 +02:00
|
|
|
// Pops the NPC from npcRPG
|
2024-07-27 14:02:04 +02:00
|
|
|
void npc_remove(NPC *npc);
|
2023-08-19 14:18:41 +02:00
|
|
|
|
|
|
|
/* Draws the player player. This function should be called after drawing the
|
|
|
|
* map! */
|
|
|
|
void npc_draw(Game *game);
|
|
|
|
|
2024-07-21 02:42:50 +02:00
|
|
|
void update_npcs(Game *game);
|
|
|
|
|
|
|
|
void update_npc(NPC *npc);
|
2023-08-26 17:13:05 +02:00
|
|
|
|
|
|
|
void reload_npc(Game *game);
|
2023-08-19 14:18:41 +02:00
|
|
|
|
|
|
|
#endif
|