NPC full circle.
This commit is contained in:
@ -14,6 +14,8 @@ void npcLoad(entity_t *entity, const entity_t *source) {
|
|||||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
assertNotNull(entity, "Entity pointer cannot be NULL");
|
||||||
assertNotNull(source, "Source 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");
|
assertTrue(source->type == ENTITY_TYPE_NPC, "Source entity type must be NPC");
|
||||||
|
|
||||||
|
entity->npc = source->npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void npcUpdate(entity_t *entity) {
|
void npcUpdate(entity_t *entity) {
|
||||||
@ -28,6 +30,7 @@ void npcInteract(entity_t *player, entity_t *self) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NPC_INTERACT_TYPE_TEXT:
|
case NPC_INTERACT_TYPE_TEXT:
|
||||||
|
uiTextboxSetText(languageGet(self->npc.text));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NPC_INTERACT_TYPE_CONVO:
|
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, "
|
// "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"
|
// "so powerful and so wise he could use the Force to influence the midichlorians"
|
||||||
// );
|
// );
|
||||||
const char_t *name = "Dom";
|
// const char_t *name = "Dom";
|
||||||
const char_t *key = "name";
|
// const char_t *key = "name";
|
||||||
uint16_t len = languageFormat(
|
// uint16_t len = languageFormat(
|
||||||
"test.npc.text",
|
// "test.npc.text",
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
(const char_t *[]){ key },
|
// (const char_t *[]){ key },
|
||||||
(const char_t *[]){ name },
|
// (const char_t *[]){ name },
|
||||||
1
|
// 1
|
||||||
);
|
// );
|
||||||
|
|
||||||
char_t *buffer = malloc(sizeof(char_t) + len + 1);
|
// char_t *buffer = malloc(sizeof(char_t) + len + 1);
|
||||||
assertNotNull(buffer, "Failed to allocate buffer for NPC text");
|
// assertNotNull(buffer, "Failed to allocate buffer for NPC text");
|
||||||
|
|
||||||
languageFormat(
|
// languageFormat(
|
||||||
"test.npc.text",
|
// "test.npc.text",
|
||||||
buffer,
|
// buffer,
|
||||||
len + 1,
|
// len + 1,
|
||||||
(const char_t *[]){ key },
|
// (const char_t *[]){ key },
|
||||||
(const char_t *[]){ name },
|
// (const char_t *[]){ name },
|
||||||
1
|
// 1
|
||||||
);
|
// );
|
||||||
|
|
||||||
uiTextboxSetText(buffer);
|
// uiTextboxSetText(buffer);
|
||||||
free(buffer);
|
// free(buffer);
|
||||||
}
|
}
|
@ -35,6 +35,6 @@ def parseEntity(obj, chunkData):
|
|||||||
obj['data'] = {}
|
obj['data'] = {}
|
||||||
obj['data']['npc'] = {}
|
obj['data']['npc'] = {}
|
||||||
obj['data']['npc']['interactType'] = 'NPC_INTERACT_TYPE_TEXT'
|
obj['data']['npc']['interactType'] = 'NPC_INTERACT_TYPE_TEXT'
|
||||||
obj['data']['npc']['text'] = '"test"'
|
obj['data']['npc']['text'] = '"test.npc.text"'
|
||||||
|
|
||||||
return obj
|
return obj
|
Reference in New Issue
Block a user