From 5520945022965c78c34c0b61f7da1135748e7569 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 23 Jun 2025 23:33:52 -0500 Subject: [PATCH] NPC full circle. --- src/dusk/entity/npc.c | 47 +++++++++++++++++--------------- tools/mapcompile/entityParser.py | 2 +- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/dusk/entity/npc.c b/src/dusk/entity/npc.c index ccb8ac0..d576077 100644 --- a/src/dusk/entity/npc.c +++ b/src/dusk/entity/npc.c @@ -14,6 +14,8 @@ void npcLoad(entity_t *entity, const entity_t *source) { assertNotNull(entity, "Entity pointer cannot be NULL"); assertNotNull(source, "Source entity pointer cannot be NULL"); assertTrue(source->type == ENTITY_TYPE_NPC, "Source entity type must be NPC"); + + entity->npc = source->npc; } void npcUpdate(entity_t *entity) { @@ -28,6 +30,7 @@ void npcInteract(entity_t *player, entity_t *self) { break; case NPC_INTERACT_TYPE_TEXT: + uiTextboxSetText(languageGet(self->npc.text)); break; case NPC_INTERACT_TYPE_CONVO: @@ -46,29 +49,29 @@ void npcInteract(entity_t *player, entity_t *self) { // "of Darth Plagueis the Wise? He was a dark lord of the Sith, " // "so powerful and so wise he could use the Force to influence the midichlorians" // ); - const char_t *name = "Dom"; - const char_t *key = "name"; - uint16_t len = languageFormat( - "test.npc.text", - NULL, - 0, - (const char_t *[]){ key }, - (const char_t *[]){ name }, - 1 - ); + // const char_t *name = "Dom"; + // const char_t *key = "name"; + // uint16_t len = languageFormat( + // "test.npc.text", + // NULL, + // 0, + // (const char_t *[]){ key }, + // (const char_t *[]){ name }, + // 1 + // ); - char_t *buffer = malloc(sizeof(char_t) + len + 1); - assertNotNull(buffer, "Failed to allocate buffer for NPC text"); + // char_t *buffer = malloc(sizeof(char_t) + len + 1); + // assertNotNull(buffer, "Failed to allocate buffer for NPC text"); - languageFormat( - "test.npc.text", - buffer, - len + 1, - (const char_t *[]){ key }, - (const char_t *[]){ name }, - 1 - ); + // languageFormat( + // "test.npc.text", + // buffer, + // len + 1, + // (const char_t *[]){ key }, + // (const char_t *[]){ name }, + // 1 + // ); - uiTextboxSetText(buffer); - free(buffer); + // uiTextboxSetText(buffer); + // free(buffer); } \ No newline at end of file diff --git a/tools/mapcompile/entityParser.py b/tools/mapcompile/entityParser.py index de83159..b4130b5 100644 --- a/tools/mapcompile/entityParser.py +++ b/tools/mapcompile/entityParser.py @@ -35,6 +35,6 @@ def parseEntity(obj, chunkData): obj['data'] = {} obj['data']['npc'] = {} obj['data']['npc']['interactType'] = 'NPC_INTERACT_TYPE_TEXT' - obj['data']['npc']['text'] = '"test"' + obj['data']['npc']['text'] = '"test.npc.text"' return obj \ No newline at end of file