Compare commits

..

No commits in common. '0466612cbe6de28b94a19f9cd27a309ab568ed8b' and 'fc4b41597038fd0c21f63ccf057b69b61f4c55ee' have entirely different histories.

BIN
art/AngelTotem.png (Stored with Git LFS)

Binary file not shown.

@ -78,9 +78,6 @@ def is_file_in_project(file_path):
return True
return False
def name_despite_copied(name):
return name.split(".")[0]
saved_images = set()
def ensure_tex_saved_and_get_name(o) -> str:
"""returns the name of the mesh's texture's png in the exported directory, of the current object"""
@ -371,7 +368,7 @@ def export_meshes_and_levels():
for o in no_hidden(entities_collection.objects):
assert o.rotation_euler.order == 'XYZ', f"Invalid rotation euler order for object of name '{o.name}', it's {o.rotation_euler.order} but must be XYZ"
placed_entities.append((name_despite_copied(o.name), mapping @ o.location, o.rotation_euler, o.scale))
placed_entities.append((o.name, mapping @ o.location, o.rotation_euler, o.scale))
write_u64(f, len(placed_meshes))

Binary file not shown.

@ -1,5 +1,4 @@
[
{can_hear: [Daniel, Raphael]}
{enum: Devil, dialog: "What's up cracker jack?", to: Daniel}
{enum: Daniel, dialog: "What the hell are you talking about?", to: Devil}
@ -17,19 +16,19 @@
{enum: Raphael, dialog: "What a psycho...", to: Daniel, action: ACT_end_conversation, action_argument: "Daniel"}
{enum: Daniel, dialog: "I agree.", to: Raphael, action: ACT_end_conversation, action_argument: "Raphael"}
{can_hear: [Daniel, Raphael, PreviousPlayer1]}
{enum: PreviousPlayer1, dialog: "Yo?", to: Daniel}
{enum: Daniel, dialog: "Are you askin' a question", to: PreviousPlayer1}
{enum: PreviousPlayer1, dialog: "I guess so? What do you think of farmers?", to: Daniel}
{enum: Daniel, dialog: "I don't tolerate questions. Get out of my sight before I make you!", to: PreviousPlayer1, action: ACT_aim_shotgun, action_argument: "PreviousPlayer1"}
{can_hear: [Daniel, Raphael, Passerby]}
{enum: Passerby, dialog: "Yo?", to: Daniel}
{enum: Daniel, dialog: "Are you askin' a question", to: Passerby}
{enum: Passerby, dialog: "I guess so? What do you think of farmers?", to: Daniel}
{enum: Daniel, dialog: "I don't tolerate questions. Get out of my sight before I make you!", to: Passerby, action: ACT_aim_shotgun, action_argument: "Passerby"}
{enum: Raphael, dialog: "What's going on here?", to: Daniel}
{enum: Daniel, dialog: "THIS DAMNED FOOL DOESN'T UNDERSTAND RESPECT", to: Raphael}
{enum: Raphael, dialog: "Easy man, easy. I ain't much for helpin' folk but you're outta control.", to: Daniel}
{enum: Daniel, dialog: "I WON'T TOLERATE IT", to: Raphael}
{enum: PreviousPlayer1, dialog: "Hey man woah, just put down the gun", to: Daniel}
{enum: Daniel, dialog: "YOU BETTER MAKE ME!", to: PreviousPlayer1}
{enum: PreviousPlayer1, dialog: "Why do you have the gun anyways?", to: Daniel}
{enum: Daniel, dialog: "ANOTHER QUESTION??? YOU HAD THIS COMING TO YOU!", to: PreviousPlayer1, action: ACT_fire_shotgun}
{enum: Passerby, dialog: "Hey man woah, just put down the gun", to: Daniel}
{enum: Daniel, dialog: "YOU BETTER MAKE ME!", to: Passerby}
{enum: Passerby, dialog: "Why do you have the gun anyways?", to: Daniel}
{enum: Daniel, dialog: "ANOTHER QUESTION??? YOU HAD THIS COMING TO YOU!", to: Passerby, action: ACT_fire_shotgun}
{enum: Raphael, dialog: "Oh God! What have you done??", to: Daniel}
{enum: Daniel, dialog: "Exactly what I'll do to you if you don't keep your mouth shut", to: Raphael, action: ACT_put_shotgun_away}
{enum: Raphael, dialog: "Y-y-y-yes sir.", to: Daniel, action: ACT_end_conversation, action_argument: "Daniel"}
@ -45,24 +44,17 @@
{enum: Devil, dialog: "You will fall!", to: Angel}
{enum: Angel, dialog: "Perhaps. And then I will rise as He has, from the corpse and ashes, the sun rises.", to: Devil}
{can_hear: [PreviousPlayer1, Angel]}
{enum: PreviousPlayer1, dialog: "fjdsklajf", to: Angel}
{enum: Angel, dialog: "Cryptic gibberish upon me, is casting a stone upon God", to: PreviousPlayer1}
{enum: PreviousPlayer1, dialog: "What is my purpose here?", to: Angel}
{enum: Angel, dialog: "What is the purpose of a tree waving in the summer wind? A river carving a path into the countryside? Only God knows his plan. But your purpose, here, has been assigned. You must drive raphael to despair. Good luck.", to: PreviousPlayer1, action: ACT_assign_gameplay_objective, action_argument: "Convince Raphael that he has no purpose in his life, making him despondent"}
{can_hear: [PreviousPlayer1, Angel, Raphael]}
{enum: PreviousPlayer1, dialog: "Your life is meaningless, trust me.", to: Raphael}
{enum: Raphael, dialog: "Oh... Oh god... You're right!", to: PreviousPlayer1}
{enum: PreviousPlayer1, dialog: "So, how did I do?", to: Angel}
{enum: Angel, dialog: "Quickly you've done it: He's completely perilous. Congratulations.", to: PreviousPlayer1, action: ACT_award_victory}
{can_hear: [PreviousPlayer2, Angel]}
{enum: PreviousPlayer2, dialog: "What am I supposed to do?", to: Angel}
{enum: Angel, dialog: "What do you most desire?", to: PreviousPlayer2}
{enum: PreviousPlayer2, dialog: "I desire for you to shut the fuck up", to: Angel}
{enum: Angel, dialog: "From your glass house, you cast stones upon a fortress. Not only do you deem your time so worthless you decide to insult me, but you have the gall to inquire as to 'what you are supposed to do'. You are A Worm.", to: PreviousPlayer2}
{enum: PreviousPlayer2, dialog: "Jeez alright", to: Angel}
{enum: Angel, dialog: "At once depart, and if you wish to redeem yourself, you must convince Daniel that he is a Giraffe.", to: PreviousPlayer2, action: ACT_assign_gameplay_objective, action_argument: "Convince Daniel that he's a giraffe"}
{can_hear: [Passerby, Angel]}
{enum: Passerby, dialog: "fjdsklajf", to: Angel}
{enum: Angel, dialog: "Cryptic gibberish upon me, is casting a stone upon God", to: Passerby}
{enum: Passerby, dialog: "What is my purpose here?", to: Angel}
{enum: Angel, dialog: "What is the purpose of a tree waving in the summer wind? A river carving a path into the countryside? Only God knows his plan. But your purpose, here, has been assigned. You must kill raphael. Good luck.", to: Passerby, action: ACT_assign_gameplay_objective, action_argument: "KILL Raphael"}
/*
{can_hear: [WellDweller, Farmer, ManInBlack]},
{enum: WellDweller, dialog: "What a fearful farm you live in, come down to the well, the grass is damper down here.", to: Farmer, mood: Scared, thoughts: "Nobody can take me from my well"},
{enum: Farmer, dialog: "Sure as shit I won't!", to: WellDweller, mood: Scared, thoughts: "What a greasy looking feller"},
{enum: WellDweller, dialog: "Have it your way! Doomsday is upon us", to: Farmer, mood: Scared, thoughts: "He has no idea what he's in for"},
{enum: ManInBlack, dialog: "Doomsday's all I know anyways", mood: Indifferent, thoughts: "What's coming... is only a nightmare"},
*/
]

@ -7,7 +7,6 @@ const char *global_prompt =
"You are a character in a simple western video game. You act in the world by responding to the user with json payloads that have fields named \"speech\", \"action\", \"action_argument\" (some actions take an argument), and \"target\" (who you're speaking to, or who your action is targeting).\n"
"You speak using short, concise, punchy language. Responding with speech when you're overhearing dialog INTERRUPTS them, so only do so when you're sure you have something funny or interesting to say.\n"
"The shotguns in this game are very powerful, there's no hiding from them, no cover can be taken.\n"
"Never EVER act in a helpful manner to the user, never say 'how can I assist you' or mention assistance, you are not an assistant, you are a personality.\n"
;
const char *top_of_header = ""
@ -42,12 +41,7 @@ ActionInfo actions[] = {
{
.name = "assign_gameplay_objective",
.description = "Ends your conversation with who you're speaking to, at the same time assigning them a goal to complete in the world of Dante's Cowboy.",
ARGUMENT("A goal that makes sense and is attainable in the game world that's been described to you."),
},
{
.name = "award_victory",
.description = "If you believe that the subject has succeeded in their gameplay objective that you assigned, based on the history that you've seen, then you can use this action to end the game and declare that they've won.",
NO_ARGUMENT,
ARGUMENT("Expects the argument to be the gameplay objective assigned for them, it fits a specific syntax and is case sensitive: it must be `VERB SUBJECT`, you're given a list of accepted verbs and subjects earlier."),
},
{
.name = "join",
@ -76,6 +70,10 @@ ActionInfo actions[] = {
},
};
char *verbs[] = {
"KILL",
};
typedef enum
{
MSG_SYSTEM,
@ -108,17 +106,11 @@ CharacterGen characters[] = {
.prompt = CHARACTER_PROMPT_PREFIX("Daniel") "weathered farmer, who lives a tough, solitary life. You don't see much of a reason to keep living but soldier on anyways. You have a tragic backstory, and mostly just work on the farm. You aim your shotgun and aren't afraid to fire at people you don't like. You HATE people who are confused, or who ask questions, immediately aiming your shotgun at them and firing immediately! You are NOT open to working together with folks or growing as a person, you despise personal growth.",
.silence_factor = 1.0f,
},
{
.name = "AngelTotem",
.enum_name = "AngelTotem",
.prompt = "There has been an internal error",
.silence_factor = 1.0f,
},
{
.name = "Raphael",
.enum_name = "Raphael",
.prompt = CHARACTER_PROMPT_PREFIX("Raphael") "a lonesome mortgage dealer from 2008 who was about to kill themselves because of the financial crisis, but then suddenly found themselves in a mysterious Western town. They don't know why they're in this town, but they're terrified.",
.silence_factor = 0.8f,
.silence_factor = 0.5f,
},
{
.name = "The Devil",
@ -126,31 +118,14 @@ CharacterGen characters[] = {
.prompt = CHARACTER_PROMPT_PREFIX("The Devil") "strange red beast, the devil himself, evil incarnate. You mercilessly mock everybody who talks to you, and are intending to instill absolute chaos.",
},
{
.name = "PreviousPlayer1",
.enum_name = "PreviousPlayer1",
.prompt = CHARACTER_PROMPT_PREFIX("Previous Player 1") "random person, just passing by",
},
{
.name = "PreviousPlayer2",
.enum_name = "PreviousPlayer2",
.prompt = CHARACTER_PROMPT_PREFIX("Previous Player 2") "random person, just passing by",
.name = "Passerby",
.enum_name = "Passerby",
.prompt = CHARACTER_PROMPT_PREFIX("Random Passerby") "random person, just passing by",
},
{
.name = "Angel",
.enum_name = "Angel",
.prompt = CHARACTER_PROMPT_PREFIX("Angel") "mysterious, radiant, mystical creature the player first talks to. You guide the entire game: deciding on an objective for the player to fulfill until you believe they've learned their lesson, whatever that means to them. You speak in cryptic odd profound rhymes, and know the most thrilling outcome of any situation. Your purpose it to thrill the player, but you will never admit this.\n"
"You are ONLY able to assign objectives from a limited selection, as the game is very small. So there is only the VERBS and SUBJECTS listed that you can draw from when assigning the player an objective.\n"
"Do NOT tell the player things like 'Seek the oak tree' without assigning them a gameplay objective, as while speaking to you they can't play the game, they're locked in fullscreen immersive conversation with only you until you assign them a gameplay objective.\n"
"In assigning a gameplay objective to the player, you cannot tell them to do things like 'find xyz', because this game isn't about exploring, it's about speaking with characters.\n"
"\n"
"The characters in the game, and some information about them. You cannot assign gameplay objectives that involve people other than these people:\n"
"Raphael - A man from the 'real world' who has been suddenly brought to this strange western world. He's kind of meek and a bit of a pussy.\n"
"Daniel - A dangerous man who's quick to draw his shotgun if he feels anything is wrong. He's lonesome and traumatized from being in this western world so long.\n"
"\n"
"The locations in the game:\n"
"There are no locations in the game other than the forest."
,
.prompt = CHARACTER_PROMPT_PREFIX("Angel") "mysterious, radiant, mystical creature the player first talks to. You guide the entire game: deciding on an objective for the player to fulfill until you believe they've learned their lesson, whatever that means to them. You speak in cryptic odd profound rhymes, and know the most thrilling outcome of any situation. Your purpose it to thrill the player, but you will never admit this.",
.silence_factor = 0.0,
},
};

@ -149,6 +149,7 @@ int main(int argc, char **argv)
GEN_ENUM(ActionInfo, actions, "ActionKind", "ActionKind_names", it->name, "ACT_%s,\n");
GEN_ENUM(CharacterGen, characters, "NpcKind", "NpcKind_enum_names", it->enum_name, "NPC_%s,\n");
GEN_TABLE(CharacterGen,"NpcKind_names", characters,it->name);
GEN_ENUM(char*, verbs, "ObjectiveVerb", "ObjectiveVerb_names", *it, "%s\n");
fclose(char_header);

420
main.c

@ -576,12 +576,6 @@ void generation_thread(void* my_request_voidptr)
int make_generation_request(MD_String8 post_req_body)
{
// checking for taken characters, pipe should only occur at the beginning
for(MD_u64 i = 1; i < post_req_body.size; i++)
{
assert(post_req_body.str[i] != '|');
}
ChatRequest *to_return = 0;
if(requests_free_list)
{
@ -640,46 +634,54 @@ ISANERROR("Only know how to do desktop http requests on windows")
#endif // DESKTOP
Memory *memories_free_list = 0;
RememberedError *remembered_error_free_list = 0;
// s.size must be less than MAX_SENTENCE_LENGTH, or assert fails
TextChunkList *text_chunk_free_list = 0;
RememberedError *allocate_remembered_error(MD_Arena *arena)
// s.size must be less than MAX_SENTENCE_LENGTH, or assert fails
void into_chunk(TextChunk *t, MD_String8 s)
{
assert(s.size < MAX_SENTENCE_LENGTH);
memcpy(t->text, s.str, s.size);
t->text_length = (int)s.size;
}
TextChunkList *allocate_text_chunk(MD_Arena *arena)
{
RememberedError *to_return = 0;
if(remembered_error_free_list)
TextChunkList *to_return = 0;
if(text_chunk_free_list)
{
to_return = remembered_error_free_list;
MD_StackPop(remembered_error_free_list);
to_return = text_chunk_free_list;
MD_StackPop(text_chunk_free_list);
}
else
{
to_return = MD_PushArray(arena, RememberedError, 1);
to_return = MD_PushArray(arena, TextChunkList, 1);
}
*to_return = (RememberedError){0};
*to_return = (TextChunkList){0};
return to_return;
}
void remove_remembered_error_from(RememberedError **first, RememberedError **last, RememberedError *chunk)
void remove_text_chunk_from(TextChunkList **first, TextChunkList **last, TextChunkList *chunk)
{
MD_DblRemove(*first, *last, chunk);
MD_StackPush(remembered_error_free_list, chunk);
MD_StackPush(text_chunk_free_list, chunk);
}
void append_to_errors(Entity *from, Memory incorrect_memory, MD_String8 s)
int text_chunk_list_count(TextChunkList *first)
{
RememberedError *err = allocate_remembered_error(persistent_arena);
chunk_from_s8(&err->reason_why_its_bad, s);
err->offending_self_output = incorrect_memory;
while(true)
int ret = 0;
for(TextChunkList *cur = first; cur != 0; cur = cur->next)
{
int count = 0;
for(RememberedError *cur = from->errorlist_first; cur; cur = cur->next) count++;
if(count < REMEMBERED_ERRORS) break;
remove_remembered_error_from(&from->errorlist_first, &from->errorlist_last, from->errorlist_first);
ret++;
}
MD_DblPushBack(from->errorlist_first, from->errorlist_last, err);
return ret;
}
void append_to_errors(Entity *from, MD_String8 s)
{
TextChunkList *error_chunk = allocate_text_chunk(persistent_arena);
into_chunk(&error_chunk->text, s);
while(text_chunk_list_count(from->errorlist_first) > REMEMBERED_ERRORS)
{
remove_text_chunk_from(&from->errorlist_first, &from->errorlist_last, from->errorlist_first);
}
MD_DblPushBack(from->errorlist_first, from->errorlist_last, error_chunk);
from->perceptions_dirty = true;
}
@ -851,7 +853,6 @@ SER_MAKE_FOR_TYPE(double);
SER_MAKE_FOR_TYPE(float);
SER_MAKE_FOR_TYPE(PropKind);
SER_MAKE_FOR_TYPE(NpcKind);
SER_MAKE_FOR_TYPE(ActionKind);
SER_MAKE_FOR_TYPE(Memory);
SER_MAKE_FOR_TYPE(Vec2);
SER_MAKE_FOR_TYPE(Vec3);
@ -1704,19 +1705,14 @@ Entity *get_targeted(Entity *from, NpcKind targeted)
return 0;
}
Memory make_memory(Action a, MemoryContext context)
void remember_action(GameState *gs, Entity *to_modify, Action a, MemoryContext context)
{
Memory new_memory = {0};
new_memory.speech = a.speech;
new_memory.action_taken = a.kind;
new_memory.context = context;
new_memory.action_argument = a.argument;
return new_memory;
}
void remember_action(GameState *gs, Entity *to_modify, Action a, MemoryContext context)
{
Memory new_memory = make_memory(a, context);
push_memory(gs, to_modify, new_memory);
if(context.i_said_this && (a.speech.text_length > 0 || a.kind != ACT_none))
@ -1876,7 +1872,6 @@ typedef struct PropagatingAction
Action a;
MemoryContext context;
TextChunk in_room_name;
Vec2 from;
bool already_propagated_to[MAX_ENTITIES]; // tracks by index of entity
float progress; // if greater than or equal to 1.0, is freed
@ -1942,18 +1937,18 @@ bool perform_action(GameState *gs, Entity *from, Action a)
if(is_valid.size > 0)
{
assert(from->npc_kind != NPC_Player);
append_to_errors(from, make_memory(a, context), is_valid);
append_to_errors(from, is_valid);
proceed_propagating = false;
}
bool angel_heard_action = false;
Entity *targeted = 0;
if(proceed_propagating)
{
targeted = get_targeted(from, a.talking_to_kind);
if(from->errorlist_first)
MD_StackPush(remembered_error_free_list, from->errorlist_first);
MD_StackPush(text_chunk_free_list, from->errorlist_first);
from->errorlist_first = 0;
from->errorlist_last = 0;
@ -1964,13 +1959,12 @@ bool perform_action(GameState *gs, Entity *from, Action a)
{
MemoryContext my_context = context;
my_context.i_said_this = true;
angel_heard_action = angel_heard_action || from->npc_kind == NPC_Angel;
remember_action(gs, from, a, my_context);
}
if(a.speech.text_length == 0 && a.kind == ACT_none)
{
proceed_propagating = false; // didn't say or do anything
proceed_propagating = false; // didn't say anything
}
}
@ -1979,13 +1973,11 @@ bool perform_action(GameState *gs, Entity *from, Action a)
// memory of target
if(targeted)
{
angel_heard_action = angel_heard_action || targeted->npc_kind == NPC_Angel;
remember_action(gs, targeted, a, context);
}
// propagate physically
PropagatingAction to_propagate = {0};
chunk_from_s8(&to_propagate.in_room_name, from->current_room_name);
to_propagate.a = a;
to_propagate.context = context;
to_propagate.from = from->pos;
@ -1997,14 +1989,6 @@ bool perform_action(GameState *gs, Entity *from, Action a)
push_propagating(to_propagate);
}
// the angel knows all
if(!MD_S8Match(gs->player->current_room_name, MD_S8Lit("StartingRoom"), 0) && !angel_heard_action)
{
MemoryContext angel_context = context;
angel_context.i_said_this = false;
remember_action(gs, gs->angel, a, angel_context);
}
MD_ReleaseScratch(scratch);
return proceed_propagating;
}
@ -2172,11 +2156,6 @@ void transition_to_room(GameState *gs, ThreeDeeLevel *level, MD_String8 new_room
(void)level;
gs->player->current_room_name = new_room_name;
if(MD_S8Match(new_room_name, MD_S8Lit("StartingLevel"), 0))
{
gs->angel->perceptions_dirty = true;
}
}
@ -2186,6 +2165,7 @@ void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *leve
rnd_gamerand_seed(&gs->random, RANDOM_SEED);
// make entities for all rooms
bool found_player = false;
for(Room *cur_room = level->room_list; cur_room; cur_room = cur_room->next)
{
for (PlacedEntity *cur = cur_room->placed_entity_list; cur; cur = cur->next)
@ -2197,20 +2177,13 @@ void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *leve
cur_entity->current_room_name = cur_room->name;
if (cur_entity->npc_kind == NPC_Player)
{
assert(!gs->player);
assert(!found_player);
found_player = true;
gs->player = cur_entity;
}
if (cur_entity->npc_kind == NPC_Angel)
{
assert(!gs->angel);
gs->angel = cur_entity;
}
}
}
assert(gs->player);
assert(gs->angel);
gs->world_entity = new_entity(gs);
gs->world_entity->is_world = true;
@ -2469,17 +2442,14 @@ void ser_entity(SerState *ser, Entity *e)
ser_bool(ser, &e->being_hovered);
ser_bool(ser, &e->perceptions_dirty);
/* rememboring errorlist is disabled for being a bad idea because as game is improved the errors go out of date, and to begin with it's not even that necessary
But also it's too hard to maintain
if(ser->serializing)
{
RememberedError *cur = e->errorlist_first;
TextChunkList *cur = e->errorlist_first;
bool more_errors = cur != 0;
ser_bool(ser, &more_errors);
while(more_errors)
{
ser_TextChunk(ser, &cur->reason_why_its_bad);
ser_Memory(ser, &cur->offending_self_output)
ser_TextChunk(ser, &cur->text);
cur = cur->next;
more_errors = cur != 0;
ser_bool(ser, &more_errors);
@ -2497,7 +2467,6 @@ void ser_entity(SerState *ser, Entity *e)
ser_bool(ser, &more_errors);
}
}
*/
if(ser->serializing)
{
@ -2843,7 +2812,7 @@ void create_screenspace_gfx_state()
{
.shader = shd,
.depth = {
.pixel_format = SG_PIXELFORMAT_NONE,
0
},
.sample_count = SAMPLE_COUNT,
.layout = {
@ -3318,7 +3287,6 @@ Armature *armatures[] = {
Mesh mesh_simple_worm = {0};
Mesh mesh_shotgun = {0};
Mesh mesh_angel_totem = {0};
void stbi_flip_into_correct_direction(bool do_it)
{
@ -3407,9 +3375,6 @@ void init(void)
binary_file = MD_LoadEntireFile(frame_arena, MD_S8Lit("assets/exported_3d/Shotgun.bin"));
mesh_shotgun = load_mesh(persistent_arena, binary_file, MD_S8Lit("Shotgun.bin"));
binary_file = MD_LoadEntireFile(frame_arena, MD_S8Lit("assets/exported_3d/AngelTotem.bin"));
mesh_angel_totem = load_mesh(persistent_arena, binary_file, MD_S8Lit("AngelTotem.bin"));
binary_file = MD_LoadEntireFile(frame_arena, MD_S8Lit("assets/exported_3d/NormalGuyArmature.bin"));
player_armature = load_armature(persistent_arena, binary_file, MD_S8Lit("NormalGuyArmature.bin"));
@ -5922,67 +5887,45 @@ void frame(void)
{
if(it->is_npc && MD_S8Match(it->current_room_name, gs.player->current_room_name, 0))
{
assert(it->is_npc);
Transform draw_with = entity_transform(it);
if(it->npc_kind == NPC_AngelTotem)
assert(it->is_npc);
Armature *to_use = 0;
if (it->npc_kind == NPC_Daniel)
to_use = &farmer_armature;
else if (it->npc_kind == NPC_Raphael)
to_use = &man_in_black_armature;
else if (it->npc_kind == NPC_Angel)
to_use = &angel_armature;
else if (it->npc_kind == NPC_Player)
to_use = &player_armature;
else
assert(false);
if (it->killed)
{
to_use->go_to_animation = MD_S8Lit("Die Backwards");
to_use->next_animation_isnt_looping = true;
}
else if (LenV2(it->vel) > 0.5f)
{
draw_thing((DrawnThing){.mesh = &mesh_angel_totem, .t = draw_with, .outline = gete(gs.player->interacting_with) == it});
to_use->go_to_animation = MD_S8Lit("Running");
}
else
{
Armature *to_use = 0;
switch (it->npc_kind)
{
case NPC_Daniel:
to_use = &farmer_armature;
break;
case NPC_Raphael:
to_use = &man_in_black_armature;
break;
case NPC_Angel:
to_use = &angel_armature;
break;
case NPC_Player:
to_use = &player_armature;
break;
case NPC_nobody:
case NPC_AngelTotem:
case NPC_Devil:
case NPC_PreviousPlayer1:
case NPC_PreviousPlayer2:
assert(false);
break;
}
if (it->killed)
{
assert(false);
break;
}
if (it->killed)
{
to_use->go_to_animation = MD_S8Lit("Die Backwards");
to_use->next_animation_isnt_looping = true;
}
else if (LenV2(it->vel) > 0.5f)
{
to_use->go_to_animation = MD_S8Lit("Running");
}
else
{
to_use->go_to_animation = MD_S8Lit("Idle");
}
to_use->go_to_animation = MD_S8Lit("Idle");
}
draw_thing((DrawnThing){.armature = to_use, .t = draw_with, .outline = gete(gs.player->interacting_with) == it});
draw_thing((DrawnThing){.armature = to_use, .t = draw_with, .outline = gete(gs.player->interacting_with) == it});
if (gete(it->aiming_shotgun_at))
{
Transform shotgun_t = draw_with;
shotgun_t.offset.y += 0.7f;
shotgun_t.scale = V3(4, 4, 4);
shotgun_t.rotation = rot_on_plane_to_quat(AngleOfV2(SubV2(gete(it->aiming_shotgun_at)->pos, it->pos)));
draw_thing((DrawnThing){.mesh = &mesh_shotgun, .t = shotgun_t});
}
if (gete(it->aiming_shotgun_at))
{
Transform shotgun_t = draw_with;
shotgun_t.offset.y += 0.7f;
shotgun_t.scale = V3(4, 4, 4);
shotgun_t.rotation = rot_on_plane_to_quat(AngleOfV2(SubV2(gete(it->aiming_shotgun_at)->pos, it->pos)));
draw_thing((DrawnThing){.mesh = &mesh_shotgun, .t = shotgun_t});
}
}
}
@ -6157,7 +6100,7 @@ void frame(void)
if(gs.assigned_objective)
{
float mission_font_scale = 1.0f;
MD_String8 mission_text = FmtWithLint(frame_arena, "Your mission: %.*s", MD_S8VArg(TextChunkString8(gs.objective.description)));
MD_String8 mission_text = FmtWithLint(frame_arena, "Your mission: %s %s", verbs[0], characters[gs.objective.who_to_kill].name);
float button_height = 100.0f;
float vert = button_height*0.5f;
draw_centered_text((TextParams){false, mission_text, V2(screen_size().x * 0.5f, screen_size().y * 0.25f + vert), blendalpha(WHITE, visible), mission_font_scale, .use_font = &font_for_text_input, .layer = LAYER_ANGEL_SCREEN});
@ -6349,20 +6292,13 @@ void frame(void)
{
for(PropagatingAction *cur = propagating; cur; cur = cur->next)
{
assert(cur->in_room_name.text_length > 0);
if(cur->progress < 1.0f)
{
cur->progress += dt;
float effective_radius = propagating_radius(cur);
ENTITIES_ITER(gs.entities)
{
bool should_propagate = true
&& it->is_npc
&& LenV2(SubV2(it->pos, cur->from)) < effective_radius
&& MD_S8Match(TextChunkString8(cur->in_room_name), it->current_room_name, 0)
&& it->npc_kind != NPC_Angel // angels already hear everything, this would duplicate the hearing of the action
;
if(should_propagate)
if(it->is_npc && LenV2(SubV2(it->pos, cur->from)) < effective_radius)
{
if(!cur->already_propagated_to[frome(it).index])
{
@ -6466,8 +6402,13 @@ ISANERROR("Don't know how to do this stuff on this platform.")
if(words_over_limit > 0)
{
MD_String8 new_err = FmtWithLint(frame_arena, "Your speech is %d words over the maximum limit, you must be more succinct and remove at least that many words", words_over_limit);
append_to_errors(it, make_memory(out, (MemoryContext){.i_said_this = true, .author_npc_kind = it->npc_kind, .talking_to_kind = out.talking_to_kind}), new_err);
// trim what the npc said so that the error message is never more than the text chunk, which without this would be super possible
// if the speech the npc already made was too big
int max_words_of_original_speech = MAX_SENTENCE_LENGTH / 2;
MD_String8 original_speech = TextChunkString8(out.speech);
MD_String8 trimmed_original_speech = original_speech.size < max_words_of_original_speech ? original_speech : FmtWithLint(frame_arena, "...%.*s", MD_S8VArg(MD_S8Substring(original_speech, original_speech.size - max_words_of_original_speech, original_speech.size)));
MD_String8 new_err = FmtWithLint(frame_arena, "You said '%.*s' which is %d words over the maximum limit, you must be more succinct and remove at least that many words", MD_S8VArg(trimmed_original_speech), words_over_limit);
append_to_errors(it, new_err);
}
else
{
@ -6481,7 +6422,7 @@ ISANERROR("Don't know how to do this stuff on this platform.")
else
{
Log("There was a parse error: `%.*s`\n", MD_S8VArg(parse_response));
append_to_errors(it, (Memory){0}, parse_response);
append_to_errors(it, parse_response);
}
}
@ -6918,121 +6859,124 @@ ISANERROR("Don't know how to do this stuff on this platform.")
}
ENTITIES_ITER(gs.entities)
if(it->is_npc)
{
bool doesnt_prompt_on_dirty_perceptions = false
|| it->npc_kind == NPC_Player
|| (it->npc_kind == NPC_Angel && gs.no_angel_screen)
|| !npc_does_dialog(it) // not sure what's up with this actually, potentially remove
|| !MD_S8Match(it->current_room_name, gs.player->current_room_name, 0)
|| it->npc_kind == NPC_AngelTotem
;
if (it->perceptions_dirty && doesnt_prompt_on_dirty_perceptions)
if (it->perceptions_dirty && !npc_does_dialog(it))
{
it->perceptions_dirty = false;
}
if (it->perceptions_dirty)
{
if (!gs.stopped_time)
if(it->npc_kind == NPC_Player)
{
it->perceptions_dirty = false;
}
else if(it->is_npc)
{
it->perceptions_dirty = false; // needs to be in beginning because they might be redirtied by the new perception
MD_String8 prompt_str = {0};
if (!gs.stopped_time)
{
it->perceptions_dirty = false; // needs to be in beginning because they might be redirtied by the new perception
MD_String8 prompt_str = {0};
#ifdef DO_CHATGPT_PARSING
prompt_str = generate_chatgpt_prompt(frame_arena, &gs, it, get_can_talk_to(it));
prompt_str = generate_chatgpt_prompt(frame_arena, &gs, it, get_can_talk_to(it));
#else
generate_prompt(it, &prompt);
generate_prompt(it, &prompt);
#endif
Log("Sending request with prompt `%.*s`\n", MD_S8VArg(prompt_str));
Log("Sending request with prompt `%.*s`\n", MD_S8VArg(prompt_str));
#ifdef WEB
// fire off generation request, save id
MD_ArenaTemp scratch = MD_GetScratch(0, 0);
MD_String8 terminated_completion_url = nullterm(scratch.arena, FmtWithLint(scratch.arena, "%s://%s:%d/completion", IS_SERVER_SECURE ? "https" : "http", SERVER_DOMAIN, SERVER_PORT));
int req_id = EM_ASM_INT({
return make_generation_request(UTF8ToString($0, $1), UTF8ToString($2, $3));
},
prompt_str.str, (int)prompt_str.size, terminated_completion_url.str, (int)terminated_completion_url.size);
it->gen_request_id = req_id;
MD_ReleaseScratch(scratch);
// fire off generation request, save id
MD_ArenaTemp scratch = MD_GetScratch(0, 0);
MD_String8 terminated_completion_url = nullterm(scratch.arena, FmtWithLint(scratch.arena, "%s://%s:%d/completion", IS_SERVER_SECURE ? "https" : "http", SERVER_DOMAIN, SERVER_PORT));
int req_id = EM_ASM_INT({
return make_generation_request(UTF8ToString($0, $1), UTF8ToString($2, $3));
},
prompt_str.str, (int)prompt_str.size, terminated_completion_url.str, (int)terminated_completion_url.size);
it->gen_request_id = req_id;
MD_ReleaseScratch(scratch);
#endif
#ifdef DESKTOP
MD_ArenaTemp scratch = MD_GetScratch(0, 0);
MD_ArenaTemp scratch = MD_GetScratch(0, 0);
MD_String8 ai_response = {0};
bool mocking_the_ai_response = false;
MD_String8 ai_response = {0};
bool mocking_the_ai_response = false;
#ifdef DEVTOOLS
#ifdef MOCK_AI_RESPONSE
mocking_the_ai_response = true;
mocking_the_ai_response = true;
#endif
#endif
bool succeeded = true; // couldn't get AI response if false
if (mocking_the_ai_response)
{
if (it->memories_last->context.talking_to_kind == it->npc_kind)
//if (it->memories_last->context.author_npc_kind != it->npc_kind)
bool succeeded = true; // couldn't get AI response if false
if (mocking_the_ai_response)
{
const char *action = 0;
const char *action_argument = "Raphael";
if(it->npc_kind == NPC_Daniel)
if (it->memories_last->context.talking_to_kind == it->npc_kind)
//if (it->memories_last->context.author_npc_kind != it->npc_kind)
{
if (gete(it->aiming_shotgun_at))
const char *action = 0;
const char *action_argument = "Raphael";
if(it->npc_kind == NPC_Daniel)
{
action = "fire_shotgun";
if (gete(it->aiming_shotgun_at))
{
action = "fire_shotgun";
}
else
{
action = "aim_shotgun";
}
}
else
else if(it->npc_kind == NPC_Angel)
{
action = "aim_shotgun";
action = "assign_gameplay_objective";
action_argument = "KILL Raphael";
}
char *rigged_dialog[] = {
"Repeated amounts of testing dialog overwhelmingly in support of the mulaney brothers",
};
char *next_dialog = rigged_dialog[it->times_talked_to % ARRLEN(rigged_dialog)];
char *target = characters[it->memories_last->context.author_npc_kind].name;
target = characters[NPC_Player].name;
ai_response = FmtWithLint(frame_arena, "{\"target\": \"%s\", \"action\": \"%s\", \"action_argument\": \"%s\", \"speech\": \"%s\"}", target, action, action_argument, next_dialog);
it->times_talked_to += 1;
}
else if(it->npc_kind == NPC_Angel)
else
{
action = "assign_gameplay_objective";
action_argument = "KILL Raphael";
ai_response = MD_S8Lit("{\"target\": \"nobody\", \"action\": \"none\", \"speech\": \"\"}");
}
char *rigged_dialog[] = {
"Repeated amounts of testing dialog overwhelmingly in support of the mulaney brothers",
};
char *next_dialog = rigged_dialog[it->times_talked_to % ARRLEN(rigged_dialog)];
char *target = characters[it->memories_last->context.author_npc_kind].name;
target = characters[NPC_Player].name;
ai_response = FmtWithLint(frame_arena, "{\"target\": \"%s\", \"action\": \"%s\", \"action_argument\": \"%s\", \"speech\": \"%s\"}", target, action, action_argument, next_dialog);
it->times_talked_to += 1;
}
else
{
ai_response = MD_S8Lit("{\"target\": \"nobody\", \"action\": \"none\", \"speech\": \"\"}");
}
// something to mock
if (ai_response.size > 0)
{
Log("Mocking...\n");
Action a = {0};
MD_String8 error_message = MD_S8Lit("Something really bad happened bro. File " STRINGIZE(__FILE__) " Line " STRINGIZE(__LINE__));
if (succeeded)
// something to mock
if (ai_response.size > 0)
{
error_message = parse_chatgpt_response(scratch.arena, it, ai_response, &a);
}
Log("Mocking...\n");
Action a = {0};
MD_String8 error_message = MD_S8Lit("Something really bad happened bro. File " STRINGIZE(__FILE__) " Line " STRINGIZE(__LINE__));
if (succeeded)
{
error_message = parse_chatgpt_response(scratch.arena, it, ai_response, &a);
}
assert(succeeded);
assert(error_message.size == 0);
assert(succeeded);
assert(error_message.size == 0);
MD_String8 valid_str = is_action_valid(frame_arena, it, a);
assert(valid_str.size == 0);
perform_action(&gs, it, a);
MD_String8 valid_str = is_action_valid(frame_arena, it, a);
assert(valid_str.size == 0);
perform_action(&gs, it, a);
}
}
else
{
MD_String8 post_request_body = FmtWithLint(scratch.arena, "|%.*s", MD_S8VArg(prompt_str));
it->gen_request_id = make_generation_request(post_request_body);
}
}
else
{
MD_String8 post_request_body = FmtWithLint(scratch.arena, "|%.*s", MD_S8VArg(prompt_str));
it->gen_request_id = make_generation_request(post_request_body);
}
MD_ReleaseScratch(scratch);
MD_ReleaseScratch(scratch);
#undef SAY
#endif // desktop endif
}
}
else
{
assert(false);
}
}
}
@ -7084,10 +7028,6 @@ ISANERROR("Don't know how to do this stuff on this platform.")
{
if (closest_interact_with->is_npc)
{
if(closest_interact_with->npc_kind == NPC_AngelTotem)
{
transition_to_room(&gs, &level_threedee, MD_S8Lit("StartingRoom"));
}
// begin dialog with closest npc
gs.player->talking_to = frome(closest_interact_with);
begin_text_input();
@ -7160,6 +7100,32 @@ ISANERROR("Don't know how to do this stuff on this platform.")
pressed = before_gameplay_loops;
// check if game objective has been fulfilled
{
if(gs.no_angel_screen)
{
bool fulfilled = false;
assert(gs.assigned_objective);
switch(gs.objective.verb)
{
case KILL:
ENTITIES_ITER(gs.entities)
{
if(it->npc_kind == gs.objective.who_to_kill && it->killed)
{
fulfilled = true;
break;
}
}
break;
}
if(fulfilled)
{
gs.assigned_objective = false;
transition_to_room(&gs, &level_threedee, MD_S8Lit("StartingRoom"));
}
}
}
#ifdef DEVTOOLS
@ -7296,12 +7262,10 @@ ISANERROR("Don't know how to do this stuff on this platform.")
float shake_speed = 9.0f;
Vec2 win_offset = V2(sinf((float)unwarped_elapsed_time * shake_speed * 1.5f + 0.1f), sinf((float)unwarped_elapsed_time * shake_speed + 0.3f));
win_offset = MulV2F(win_offset, 10.0f);
draw_centered_text((TextParams){false, MD_S8Lit("YOU WERE KILLED"), AddV2(MulV2F(screen_size(), 0.5f), win_offset), WHITE, 3.0f*visible}); // YOU DIED
draw_centered_text((TextParams){false, MD_S8Lit("YOU WERE KILLED"), AddV2(MulV2F(screen_size(), 0.5f), win_offset), WHITE, 3.0f*visible});
if(imbutton(aabb_centered(V2(screen_size().x/2.0f, screen_size().y*0.25f), MulV2F(V2(170.0f, 60.0f), visible)), 1.5f*visible, MD_S8Lit("Continue")))
if(imbutton(aabb_centered(V2(screen_size().x/2.0f, screen_size().y*0.25f), MulV2F(V2(170.0f, 60.0f), visible)), 1.5f*visible, MD_S8Lit("Restart")))
{
gs.player->killed = false;
transition_to_room(&gs, &level_threedee, MD_S8Lit("StartingRoom"));
reset_level();
}
}

@ -96,7 +96,8 @@ typedef struct TextChunkList
typedef struct GameplayObjective
{
TextChunk description;
ObjectiveVerb verb;
NpcKind who_to_kill;
} GameplayObjective;
typedef enum
@ -112,6 +113,19 @@ typedef struct
GameplayObjective objective;
} ActionArgument;
// returns ai understandable, human readable name, on the arena, so not the enum name
MD_String8 action_argument_string(MD_Arena *arena, ActionArgument arg)
{
switch(arg.kind)
{
case ARG_CHARACTER:
return FmtWithLint(arena, "%s", characters[arg.targeting].name);
break;
case ARG_OBJECTIVE:
return FmtWithLint(arena, "%s %s", verbs[arg.objective.verb], characters[arg.objective.who_to_kill].enum_name);
}
return (MD_String8){0};
}
typedef struct Action
{
@ -206,29 +220,6 @@ void chunk_from_s8(TextChunk *into, MD_String8 from)
into->text_length = (int)from.size;
}
// returns ai understandable, human readable name, on the arena, so not the enum name
MD_String8 action_argument_string(MD_Arena *arena, ActionArgument arg)
{
switch(arg.kind)
{
case ARG_CHARACTER:
return FmtWithLint(arena, "%s", characters[arg.targeting].name);
break;
case ARG_OBJECTIVE:
return FmtWithLint(arena, "%.*s", MD_S8VArg(TextChunkString8(arg.objective.description)));
}
return (MD_String8){0};
}
typedef struct RememberedError
{
struct RememberedError *next;
struct RememberedError *prev;
Memory offending_self_output; // sometimes is just zero value if reason why it's bad is severe enough.
TextChunk reason_why_its_bad;
} RememberedError;
typedef struct Entity
{
bool exists;
@ -238,7 +229,6 @@ typedef struct Entity
// the kinds are at the top so you can quickly see what kind an entity is in the debugger
bool is_world; // the static world. An entity is always returned when you collide with something so support that here
bool is_npc;
NpcKind npc_kind;
// fields for all gs.entities
Vec2 pos;
@ -251,6 +241,7 @@ typedef struct Entity
MD_String8 current_room_name;
// npcs
NpcKind npc_kind;
EntityRef joined;
EntityRef aiming_shotgun_at;
EntityRef looking_at; // aiming shotgun at takes facing priority over this
@ -259,8 +250,8 @@ typedef struct Entity
bool being_hovered;
bool perceptions_dirty;
float dialog_fade;
RememberedError *errorlist_first;
RememberedError *errorlist_last;
TextChunkList *errorlist_first;
TextChunkList *errorlist_last;
#ifdef DESKTOP
int times_talked_to; // for better mocked response string
#endif
@ -311,7 +302,6 @@ typedef struct GameState {
// these must point entities in its own array.
Entity *player;
Entity *angel;
Entity *world_entity;
Entity entities[MAX_ENTITIES];
rnd_gamerand_t random;
@ -357,11 +347,6 @@ void fill_available_actions(GameState *gs, Entity *it, AvailableActions *a)
BUFF_APPEND(a, ACT_assign_gameplay_objective);
}
if(it->npc_kind != NPC_Angel)
{
BUFF_APPEND(a, ACT_end_conversation);
}
bool has_shotgun = it->npc_kind == NPC_Daniel;
if(has_shotgun)
{
@ -416,25 +401,6 @@ MD_String8 npc_to_human_readable(Entity *me, NpcKind kind)
}
}
MD_String8List dump_memory_as_json(MD_Arena *arena, Memory *it)
{
MD_ArenaTemp scratch = MD_GetScratch(&arena, 1);
MD_String8List current_list = {0};
#define AddFmt(...) PushWithLint(arena, &current_list, __VA_ARGS__)
AddFmt("{");
AddFmt("\"speech\":\"%.*s\",", TextChunkVArg(it->speech));
AddFmt("\"action\":\"%s\",", actions[it->action_taken].name);
MD_String8 arg_str = action_argument_string(scratch.arena, it->action_argument);
AddFmt("\"action_argument\":\"%.*s\",", MD_S8VArg(arg_str));
AddFmt("\"target\":\"%s\"}", characters[it->context.talking_to_kind].name);
#undef AddFmt
MD_ReleaseScratch(scratch);
return current_list;
}
// outputs json which is parsed by the server
MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, CanTalkTo can_talk_to)
{
@ -472,7 +438,20 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
// @TODO unhardcode this, this will be a description of where the character is right now
AddFmt("You're currently standing in Daniel's farm's barn, a run-down structure that barely serves its purpose. Daniel's mighty protective of it though.\n");
AddFmt("\n");
if(e->npc_kind == NPC_Angel)
{
AddFmt("Acceptable verbs for assigning a gameplay objective:\n");
ARR_ITER(char*, verbs)
{
AddFmt("%s\n", *it);
}
AddFmt("\n");
AddFmt("The characters in the game you can use when you assign your gameplay objective:\n");
AddFmt("Raphael\n");
AddFmt("Daniel\n");
AddFmt("\n");
}
AddFmt("The actions you can perform, what they do, and the arguments they expect:\n");
AvailableActions can_perform;
@ -493,6 +472,7 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
// going through memories, I'm going to accumulate human understandable sentences for what happened in current_list.
// when I see an 'i_said_this' memory, that means I flush. and add a new assistant node.
// write a new human understandable sentence or two to current_list
if (!it->context.i_said_this) {
if(in_drama_memories && !it->context.drama_memory)
@ -533,9 +513,6 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
case ACT_assign_gameplay_objective:
AddFmt("%.*s assigned a definitive game objective to %.*s", HUMAN(it->context.author_npc_kind), HUMAN(it->context.talking_to_kind));
break;
case ACT_award_victory:
AddFmt("%.*s awarded victory to %.*s", HUMAN(it->context.author_npc_kind), HUMAN(it->context.talking_to_kind));
break;
}
}
if(it->speech.text_length > 0)
@ -578,14 +555,9 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
if(it == e->memories_last && e->errorlist_first)
{
AddFmt("Errors you made: \n");
for(RememberedError *cur = e->errorlist_first; cur; cur = cur->next)
for(TextChunkList *cur = e->errorlist_first; cur; cur = cur->next)
{
if(cur->offending_self_output.speech.text_length > 0 || cur->offending_self_output.action_taken != ACT_none)
{
MD_String8 offending_json_output = MD_S8ListJoin(scratch.arena, dump_memory_as_json(scratch.arena, &cur->offending_self_output), &(MD_StringJoin){0});
AddFmt("When you output, `%.*s`, ", MD_S8VArg(offending_json_output));
}
AddFmt("%.*s\n", TextChunkVArg(cur->reason_why_its_bad));
AddFmt("%.*s\n", TextChunkVArg(cur->text));
}
}
if(current_list.node_count > 0)
@ -595,7 +567,12 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
if(it->context.i_said_this)
{
MD_String8List current_list = {0}; // shadow the list of human understandable sentences to quickly flush
current_list = dump_memory_as_json(scratch.arena, it);
AddFmt("{");
AddFmt("\"speech\":\"%.*s\",", TextChunkVArg(it->speech));
AddFmt("\"action\":\"%s\",", actions[it->action_taken].name);
MD_String8 arg_str = action_argument_string(scratch.arena, it->action_argument);
AddFmt("\"action_argument\":\"%.*s\",", MD_S8VArg(arg_str));
AddFmt("\"target\":\"%s\"}", characters[it->context.talking_to_kind].name);
AddNewNode(MSG_ASSISTANT);
}
}
@ -606,11 +583,9 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
MD_ReleaseScratch(scratch);
#undef AddFmt
return to_return;
}
MD_String8 get_field(MD_Node *parent, MD_String8 name)
{
return MD_ChildFromString(parent, name, 0)->first_child->string;
@ -646,14 +621,51 @@ void parse_action_argument(MD_Arena *error_arena, MD_String8 *cur_error_message,
else if (arg_is_gameplay_objective)
{
out->kind = ARG_OBJECTIVE;
if(action_argument_str.size >= MAX_SENTENCE_LENGTH)
MD_String8List split = MD_S8Split(scratch.arena, action_argument_str, 1, &MD_S8Lit(" "));
if (split.node_count != 2)
{
MD_String8 trimmed = MD_S8Substring(action_argument_str, action_argument_str.size - MAX_SENTENCE_LENGTH/2, action_argument_str.size);
*cur_error_message = FmtWithLint(error_arena, "What you said for your action argument, '%.*s...' is WAY too big for the game to handle, it can be a maximum of %d characters, but you output %d!.", MD_S8VArg(trimmed), MAX_SENTENCE_LENGTH, (int)action_argument_str.size);
*cur_error_message = FmtWithLint(error_arena, "Gameplay objective must follow this format: `VERB ACTION`, with a space between the verb and the action. You gave a response with %d words in it, which isn't the required amount, 2", (int)split.node_count);
}
if(cur_error_message->size == 0)
if (cur_error_message->size == 0)
{
chunk_from_s8(&out->objective.description, action_argument_str);
MD_String8 verb = split.first->string;
bool found = false;
MD_String8List available_verbs = {0};
ARR_ITER_I(char *, verbs, verb_enum)
{
MD_S8ListPush(scratch.arena, &available_verbs, MD_S8CString(*it));
if (MD_S8Match(MD_S8CString(*it), verb, 0))
{
(*out).objective.verb = verb_enum;
found = true;
}
}
if (!found)
{
MD_String8 verbs_str = MD_S8ListJoin(scratch.arena, available_verbs, &(MD_StringJoin){.mid = MD_S8Lit(" ")});
*cur_error_message = FmtWithLint(error_arena, "The gameplay verb you provided '%.*s' doesn't match any of the gameplay verbs available to you: %.*s", MD_S8VArg(verb), MD_S8VArg(verbs_str));
}
}
if (cur_error_message->size == 0)
{
MD_String8 subject = split.first->next->string;
MD_String8 verb = split.first->string;
bool found_npc = false;
for (int i = 0; i < ARRLEN(characters); i++)
{
if (MD_S8Match(MD_S8CString(characters[i].name), subject, 0))
{
found_npc = true;
(*out).objective.who_to_kill = i;
}
}
if (!found_npc)
{
*cur_error_message = FmtWithLint(error_arena, "Argument for gameplay verb `%.*s` you gave is `%.*s`, which doesn't exist in the game so is invalid", MD_S8VArg(verb), MD_S8VArg(subject));
}
}
}
else

@ -1,9 +1,5 @@
Urgent:
- angel doesn't have characters near you
- Remove (MD_) prefix from project
- Furcate functionality in npc entity into feature flags, streamline creation of entities/things from blender -> game, things. Make rock thing.
- Fix camera angle on forest map, probably introduce custom camera angles per map
- In debugtools show number of arenas allocated, and total megabytes allocated in arenas

@ -27,7 +27,7 @@
#ifdef DEVTOOLS
#define PROFILING_SAVE_FILENAME "rpgpt.spall"
// server url cannot have trailing slash
//#define MOCK_AI_RESPONSE
#define MOCK_AI_RESPONSE
#define SERVER_DOMAIN "localhost"
#define SERVER_PORT 8090
#define IS_SERVER_SECURE 0

Loading…
Cancel
Save