npc : ajout des déclarations des nouvelles fonctions, typo

This commit is contained in:
attilavs2 2024-07-23 18:06:42 +02:00
parent b5a5ae2a5a
commit 49303ba6ad
2 changed files with 12 additions and 2 deletions

View file

@ -44,7 +44,6 @@ int npc_clear_path(NPC *npc)
return 0;
}
//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)
{
npc->path_length++;
@ -66,7 +65,7 @@ void as_clean(uint8_t *visited, uint8_t *gscore, uint8_t *fscore)
int as_reconstruct_path(int16_t *came_from, int w, int h, int16_t spos,
int16_t dest, NPC *npc)
{
if(npc_clear_path(npc) goto as_recons_fail;
if(npc_clear_path(npc)) goto as_recons_fail;
int16_t next = came_from[dest];

View file

@ -46,7 +46,18 @@ typedef struct
bool paused;
} 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(int dest_x, int dest_y, Map *full_map, NPC *npc);
/* Draws the player player. This function should be called after drawing the
* map! */