#ifndef NPC_H #define NPC_H #include "game.h" #include "memory.h" #include #include enum { NPC_NONE = 0, NPC_FRIENDLY = 1, // The player's team NPC_HOSTILE = 2, // to the player NPC_ALL = 3 }; /* /!\ Warning /!\ * Do not keep hard references to non-static NPCs, as they will likely move * in the stack */ /* Creates a new NPC in the NPC stack (Needs to be set to valid values !) * Returns NULL on failure */ NPC *npc_create(); /* Pops the NPC from the NPC stack * Consider this as a free */ void npc_remove(NPC *npc); /* Frees then malloc()s a new path to npc * Useful if you want to safely edit a path */ int npc_clear_path(NPC *npc); /* 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 */ int npc_append_path(uint16_t x, uint16_t y, NPC *npc); /* Clears the NPCs path and creates a new one going to dest, * avoiding non-walkable tiles * Returns non-zero on failure */ int npc_pathfind(int32_t dest_x, int32_t dest_y, Map *full_map, NPC *npc); /* Draws the player player. This function should be called after drawing the * map! */ void npc_draw(Game *game); /* Updates the static NPCs and the NPC stack */ void update_npcs(Game *game); /* Updates the singular NPC npc. Be careful with it ! */ void update_npc(NPC *npc); /* Inits/Clears the NPC stack*/ void npc_reload(Game *game); #endif