mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-28 04:23:42 +01:00
NPCs nearly working
This commit is contained in:
parent
dfb61f18fe
commit
6ab37ee4fb
2 changed files with 3 additions and 71 deletions
|
@ -152,7 +152,7 @@ def convert_map(input, output, params, target):
|
||||||
# Get the NPCs
|
# Get the NPCs
|
||||||
for object in ed_objgroup.objects:
|
for object in ed_objgroup.objects:
|
||||||
if object.get_data_type() == "point" and object.type == "NPC":
|
if object.get_data_type() == "point" and object.type == "NPC":
|
||||||
path = object.get_data()
|
path = [0, 0]
|
||||||
if int(object.get_property("hasPath")):
|
if int(object.get_property("hasPath")):
|
||||||
if object.get_property("path") in npc_paths:
|
if object.get_property("path") in npc_paths:
|
||||||
path = npc_paths[object.get_property("path")]
|
path = npc_paths[object.get_property("path")]
|
||||||
|
@ -211,8 +211,8 @@ def convert_map(input, output, params, target):
|
||||||
map_struct += fxconv.u32(len(npcs))
|
map_struct += fxconv.u32(len(npcs))
|
||||||
npc_struct = fxconv.Structure()
|
npc_struct = fxconv.Structure()
|
||||||
for i in npcs.values():
|
for i in npcs.values():
|
||||||
npc_struct += fxconv.u32(i["path"][0])
|
npc_struct += fxconv.u32(i["position"][0]+i["path"][0])
|
||||||
npc_struct += fxconv.u32(i["path"][1])
|
npc_struct += fxconv.u32(i["position"][1]+i["path"][1])
|
||||||
npc_struct += fxconv.u32(i["position"][0])
|
npc_struct += fxconv.u32(i["position"][0])
|
||||||
npc_struct += fxconv.u32(i["position"][1])
|
npc_struct += fxconv.u32(i["position"][1])
|
||||||
npc_struct += fxconv.u16(i["face"])
|
npc_struct += fxconv.u16(i["face"])
|
||||||
|
|
68
src/npc.c
68
src/npc.c
|
@ -201,30 +201,6 @@ int npc_pathfind(int32_t dest_x, int32_t dest_y, Map *full_map, NPC *npc) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*NPC *npc_create() {
|
|
||||||
// Use temp pointer to avoid breaking the whole npcRPG on failure
|
|
||||||
void *temp = realloc(npcRPG, (nbNPC + 1) * sizeof(NPC));
|
|
||||||
if(temp == NULL)
|
|
||||||
return NULL;
|
|
||||||
npcRPG = temp;
|
|
||||||
nbNPC++;
|
|
||||||
NPC *npc = &npcRPG[nbNPC - 1];
|
|
||||||
npc->xpath = malloc(2);
|
|
||||||
npc->ypath = malloc(2);
|
|
||||||
return npc;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*void npc_remove(NPC *npc) {
|
|
||||||
uint32_t pos = ((uint32_t)npc - (uint32_t)npcRPG) / sizeof(NPC);
|
|
||||||
if(pos > nbNPC - 1)
|
|
||||||
return;
|
|
||||||
if(pos == nbNPC - 1) {
|
|
||||||
nbNPC--;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
memmove(npc, &npc[1], (nbNPC - pos - 1) * sizeof(NPC));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Refactoring to make adding complexity cleaner
|
// Refactoring to make adding complexity cleaner
|
||||||
void update_npcs([[maybe_unused]] Game *game) {
|
void update_npcs([[maybe_unused]] Game *game) {
|
||||||
for(uint32_t u = 0; u < game->map_level->nbNPC; u++) {
|
for(uint32_t u = 0; u < game->map_level->nbNPC; u++) {
|
||||||
|
@ -253,50 +229,6 @@ void update_npc(NPC *npc) {
|
||||||
npc->cury += vecY;
|
npc->cury += vecY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void reload_npc(Game *game) {
|
|
||||||
if(npcRPG != NULL) {
|
|
||||||
free(npcRPG);
|
|
||||||
npcRPG = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
nbNPC = 0;
|
|
||||||
|
|
||||||
for(uint32_t u = 0; u < game->map_level->nbextradata; u++) {
|
|
||||||
ExtraData *Data = &game->map_level->extradata[u];
|
|
||||||
|
|
||||||
if(strcmp(Data->type, "NPC") == 0)
|
|
||||||
{
|
|
||||||
nbNPC++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
npcRPG = (NPC *)malloc(nbNPC * sizeof(NPC));
|
|
||||||
if(npcRPG == NULL)
|
|
||||||
return;
|
|
||||||
int currentNPC = 0;
|
|
||||||
|
|
||||||
for(uint32_t u = 0; u < game->map_level->nbextradata; u++) {
|
|
||||||
ExtraData *Data = &game->map_level->extradata[u];
|
|
||||||
|
|
||||||
if(strcmp(Data->type, "NPC") == 0)
|
|
||||||
{
|
|
||||||
npcRPG[currentNPC].curx = (float)Data->x;
|
|
||||||
npcRPG[currentNPC].cury = (float)Data->y;
|
|
||||||
npcRPG[currentNPC].x = Data->x;
|
|
||||||
npcRPG[currentNPC].y = Data->y;
|
|
||||||
npcRPG[currentNPC].dialogID = Data->dialogID;
|
|
||||||
npcRPG[currentNPC].currentPoint = 1;
|
|
||||||
npcRPG[currentNPC].hasPath = Data->hasPath;
|
|
||||||
npcRPG[currentNPC].path_length = Data->path_length;
|
|
||||||
npcRPG[currentNPC].xpath = Data->xpath;
|
|
||||||
npcRPG[currentNPC].ypath = Data->ypath;
|
|
||||||
npcRPG[currentNPC].paused = false;
|
|
||||||
npcRPG[currentNPC].face = Data->face;
|
|
||||||
currentNPC++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void npc_draw(Game *game) {
|
void npc_draw(Game *game) {
|
||||||
Player *pl = &game->player;
|
Player *pl = &game->player;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
Loading…
Reference in a new issue