Setup for item trade test, prevent *do stuff* hacking

main
Cameron Murphy Reikes 2 years ago
parent 25e129cb93
commit 4a4642e97d

@ -371,8 +371,25 @@
"rotation":0, "rotation":0,
"visible":true, "visible":true,
"width":32, "width":32,
"x":1524, "x":1938.66666666667,
"y":2649.33333333333 "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, "opacity":1,
"type":"objectgroup", "type":"objectgroup",
@ -381,7 +398,7 @@
"y":0 "y":0
}], }],
"nextlayerid":5, "nextlayerid":5,
"nextobjectid":22, "nextobjectid":23,
"orientation":"orthogonal", "orientation":"orthogonal",
"renderorder":"right-down", "renderorder":"right-down",
"tiledversion":"1.9.2", "tiledversion":"1.9.2",

@ -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'") 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?") 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") 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" "\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.", "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 typedef struct

@ -775,13 +775,23 @@ void end_text_input(char *what_player_said)
else else
{ {
Sentence what_player_said_sentence = {0}; 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++) for(int i = 0; i < player_said_len; i++)
{ {
char c = what_player_said[i]; char c = what_player_said[i];
if(c == '\n') break; if(!BUFF_HAS_SPACE(&what_player_said_sentence))
{
break;
}
else if(c == '\n')
{
break;
}
else
{
BUFF_APPEND(&what_player_said_sentence, c); BUFF_APPEND(&what_player_said_sentence, c);
} }
}
Entity *talking = gete(player->talking_to); Entity *talking = gete(player->talking_to);
assert(talking); assert(talking);
@ -793,6 +803,7 @@ void end_text_input(char *what_player_said)
if(talking->last_seen_holding_kind != player_holding) if(talking->last_seen_holding_kind != player_holding)
{ {
process_perception(talking, (Perception){.type = PlayerHeldItemChanged, .holding = player_holding,}); process_perception(talking, (Perception){.type = PlayerHeldItemChanged, .holding = player_holding,});
} }
process_perception(talking, (Perception){.type = PlayerDialog, .player_dialog = what_player_said_sentence,}); 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_TheKing)
{ {
} }
else if(it->npc_kind == NPC_TheBlacksmith)
{
}
else else
{ {
assert(false); assert(false);
@ -3558,6 +3572,10 @@ F cost: G + H
{ {
tint = colhex(0xf0be1d); tint = colhex(0xf0be1d);
} }
else if(it->npc_kind == NPC_TheBlacksmith)
{
tint = colhex(0x5c5c5c);
}
else else
{ {
assert(false); assert(false);

@ -192,6 +192,9 @@ typedef struct Entity
// multiple gs.entities have a sword swing // multiple gs.entities have a sword swing
BUFF(EntityRef, 8) done_damage_to_this_swing; // only do damage once, but hitbox stays around 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; bool is_bullet;
// props // props
@ -249,7 +252,7 @@ typedef struct Entity
bool npc_is_knight_sprite(Entity *it) 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) bool npc_is_skeleton(Entity *it)
@ -412,6 +415,23 @@ typedef enum
MSG_ASSISTANT, MSG_ASSISTANT,
} MessageType; } 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) void dump_json_node_trailing(PromptBuff *into, MessageType type, const char *content, bool trailing_comma)
{ {
const char *type_str = 0; const char *type_str = 0;
@ -488,7 +508,25 @@ void generate_chatgpt_prompt(Entity *it, PromptBuff *into)
} }
else if(it->type == PlayerDialog) 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); dump_json_node(into, MSG_USER, cur_node.data);
} }
else if(it->type == NPCDialog) else if(it->type == NPCDialog)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 KiB

After

Width:  |  Height:  |  Size: 618 KiB

Loading…
Cancel
Save