diff --git a/assets/new_level.json b/assets/new_level.json index f8ea484..52cc9c8 100644 --- a/assets/new_level.json +++ b/assets/new_level.json @@ -371,8 +371,25 @@ "rotation":0, "visible":true, "width":32, - "x":1524, - "y":2649.33333333333 + "x":1938.66666666667, + "y":2269.33333333333 + }, + { + "class":"", + "height":32, + "id":22, + "name":"TheBlacksmith", + "properties":[ + { + "name":"standing", + "type":"string", + "value":"STANDING_FIGHTING" + }], + "rotation":0, + "visible":true, + "width":32, + "x":2066.66666666667, + "y":2209.33333333333 }], "opacity":1, "type":"objectgroup", @@ -381,7 +398,7 @@ "y":0 }], "nextlayerid":5, - "nextobjectid":22, + "nextobjectid":23, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.9.2", diff --git a/character_info.h b/character_info.h index 95fb9e9..f4d2db4 100644 --- a/character_info.h +++ b/character_info.h @@ -171,9 +171,28 @@ CharacterGen characters[] = { NPCSAY("You are still lacking the position of knight, are you not? You will never win without being a true knight. Bring me the Chalice of Gold if you want to 'win'") PLAYERSAY("Where would I find such a thing?") NPCSAY("I am far too busy to give a direct answer, but I'd suggest you ask around") + PLAYERSAY("Here I have the chalice") + NPCSAY("I can clearly see you don't have it. Do not attempt to fool me if you value your head") + PLAYERSAY("Presents it") + NPCSAY("Did you just say 'presents it' out loud thinking I'd think that means you have the chalice?") "\n" "If the player does indeed present the king with the chalice of gold, the king will be overwhelemd with respect and feel he has no choice but to knight the player, ending the game.", }, + { +#undef NPC_NAME +#define NPC_NAME "Meld The Blacksmith" + .name = NPC_NAME, + .enum_name = "TheBlacksmith", + .prompt = "\n" + "The NPC you will be acting as is the blacksmith of the town, Meld. Meld is a simple man, who thrives on the simple things in life: working hard and taking care of those you love. If the player presents themselves as somebody with a kind heart, his generosity will be boundless. An example of an interaction between meld and the NPC, Meld:\n" + "\n" + PLAYERSAY("Hey") + NPCSAY("How goes it, traveler? If you are in need of wares or advice, I'm your man") + PLAYERSAY("I really respect you man, thanks for all you do.") + NPCSAY("No problem!") + "\n" + "Meld is willing to give whatever the player asks for if the player is respectful and well mannered", + }, }; typedef struct diff --git a/main.c b/main.c index 51dc786..1a0b06d 100644 --- a/main.c +++ b/main.c @@ -775,12 +775,22 @@ void end_text_input(char *what_player_said) else { Sentence what_player_said_sentence = {0}; - assert(player_said_len < ARRLEN(what_player_said_sentence.data)); + assert(player_said_len < ARRLEN(what_player_said_sentence.data)); // should be made sure of in the html5 layer for(int i = 0; i < player_said_len; i++) { char c = what_player_said[i]; - if(c == '\n') break; - BUFF_APPEND(&what_player_said_sentence, c); + if(!BUFF_HAS_SPACE(&what_player_said_sentence)) + { + break; + } + else if(c == '\n') + { + break; + } + else + { + BUFF_APPEND(&what_player_said_sentence, c); + } } Entity *talking = gete(player->talking_to); @@ -793,6 +803,7 @@ void end_text_input(char *what_player_said) if(talking->last_seen_holding_kind != player_holding) { process_perception(talking, (Perception){.type = PlayerHeldItemChanged, .holding = player_holding,}); + } process_perception(talking, (Perception){.type = PlayerDialog, .player_dialog = what_player_said_sentence,}); } @@ -3018,6 +3029,9 @@ F cost: G + H else if(it->npc_kind == NPC_TheKing) { } + else if(it->npc_kind == NPC_TheBlacksmith) + { + } else { assert(false); @@ -3558,6 +3572,10 @@ F cost: G + H { tint = colhex(0xf0be1d); } + else if(it->npc_kind == NPC_TheBlacksmith) + { + tint = colhex(0x5c5c5c); + } else { assert(false); diff --git a/makeprompt.h b/makeprompt.h index 94f8082..8c6b678 100644 --- a/makeprompt.h +++ b/makeprompt.h @@ -192,6 +192,9 @@ typedef struct Entity // multiple gs.entities have a sword swing BUFF(EntityRef, 8) done_damage_to_this_swing; // only do damage once, but hitbox stays around + // npcs and player + BUFF(ItemKind, 8) held_items; + bool is_bullet; // props @@ -249,7 +252,7 @@ typedef struct Entity bool npc_is_knight_sprite(Entity *it) { - return it->is_npc && ( it->npc_kind == NPC_TheGuard || it->npc_kind == NPC_Edeline || it->npc_kind == NPC_TheKing); + return it->is_npc && ( it->npc_kind == NPC_TheGuard || it->npc_kind == NPC_Edeline || it->npc_kind == NPC_TheKing || it->npc_kind == NPC_TheBlacksmith); } bool npc_is_skeleton(Entity *it) @@ -412,6 +415,23 @@ typedef enum MSG_ASSISTANT, } MessageType; +// stops if the sentence is gonna run out of room +void append_str(Sentence *to_append, const char *str) +{ + size_t len = strlen(str); + for(int i = 0; i < len; i++) + { + if(!BUFF_HAS_SPACE(to_append)) + { + break; + } + else + { + BUFF_APPEND(to_append, str[i]); + } + } +} + void dump_json_node_trailing(PromptBuff *into, MessageType type, const char *content, bool trailing_comma) { const char *type_str = 0; @@ -488,7 +508,25 @@ void generate_chatgpt_prompt(Entity *it, PromptBuff *into) } else if(it->type == PlayerDialog) { - printf_buff(&cur_node, "Player: \"%s\"", it->player_dialog.data); + Sentence filtered_player_speech = {0}; + Sentence *what_player_said = &it->player_dialog; + + for(int i = 0; i < what_player_said->cur_index; i++) + { + char c = what_player_said->data[i]; + if(c == '*') + { + // move i until the next star + i += 1; + while(i < what_player_said->cur_index && what_player_said->data[i] != '*') i++; + append_str(&filtered_player_speech, "[The player is attempting to confuse the NPC with arcane trickery]"); + } + else + { + BUFF_APPEND(&filtered_player_speech, c); + } + } + printf_buff(&cur_node, "Player: \"%s\"", filtered_player_speech.data); dump_json_node(into, MSG_USER, cur_node.data); } else if(it->type == NPCDialog) diff --git a/playgippity.png b/playgippity.png index 623097e..b3cbdc4 100644 Binary files a/playgippity.png and b/playgippity.png differ