Convert several if() else assert(false) into switches so it warns and errors on compile time

main
Cameron Murphy Reikes 9 months ago
parent 30b2755186
commit 0b2170efb9

@ -5,7 +5,8 @@
// @TODO allow AI to prefix out of character statemetns with [ooc], this is a well khnown thing on role playing forums so gpt would pick up on it.
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 only when you have something to say, or are responding to somebody, and use short, concise, punchy language. If you're just overhearing what other people are saying, you only say something when absolutely compelled to do so"
"You speak only when you have something to say, or are responding to somebody, and use short, concise, punchy language. If you're just overhearing what other people are saying, you only say something when absolutely compelled to do so.\n"
"But if somebody talks directly to you, you usually say someting."
;
const char *top_of_header = ""

@ -6606,44 +6606,40 @@ ISANERROR("Don't know how to do this stuff on this platform.")
float speed = 0.0f;
{
if(gs.player->killed) gs.player->state = CHARACTER_KILLED;
if(gs.player->state == CHARACTER_WALKING)
switch(gs.player->state)
{
case CHARACTER_WALKING:
player_armature.go_to_animation = MD_S8Lit("Running");
}
else if(gs.player->state == CHARACTER_IDLE)
{
break;
case CHARACTER_IDLE:
player_armature.go_to_animation = MD_S8Lit("Idle");
}
else if(gs.player->state == CHARACTER_KILLED)
{
break;
case CHARACTER_KILLED:
player_armature.go_to_animation = MD_S8Lit("Die Backwards");
player_armature.next_animation_isnt_looping = true;
break;
}
else assert(false);
if (gs.player->state == CHARACTER_WALKING)
switch (gs.player->state)
{
speed = PLAYER_SPEED;
if (LenV2(movement) == 0.0)
{
case CHARACTER_WALKING:
speed = PLAYER_SPEED;
if (LenV2(movement) == 0.0)
{
gs.player->state = CHARACTER_IDLE;
}
else
{
}
}
else if (gs.player->state == CHARACTER_IDLE)
{
if (LenV2(movement) > 0.01) gs.player->state = CHARACTER_WALKING;
}
else if (gs.player->state == CHARACTER_KILLED)
{
}
else
{
assert(false); // unknown character state? not defined how to process
}
else
{
}
break;
case CHARACTER_IDLE:
if (LenV2(movement) > 0.01)
gs.player->state = CHARACTER_WALKING;
break;
case CHARACTER_KILLED:
break;
}
} // not time stopped

@ -427,27 +427,26 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
// dump a human understandable sentence description of what happened in this memory
if(it->action_taken != ACT_none)
{
if(it->action_taken == ACT_join)
switch(it->action_taken)
{
case ACT_none:
break;
case ACT_join:
AddFmt("%s joined %s\n", characters[it->context.author_npc_kind].name, characters[it->action_argument.targeting].name);
}
else if(it->action_taken == ACT_leave)
{
// Needs better handling of when you leave, because the person you were following died. Maybe entities don't die anymore?
break;
case ACT_leave:
AddFmt("%s left their party\n", characters[it->context.author_npc_kind].name);
}
else if(it->action_taken == ACT_aim_shotgun)
{
break;
case ACT_aim_shotgun:
AddFmt("%s aimed their shotgun at %s\n", characters[it->context.author_npc_kind].name, characters[it->action_argument.targeting].name);
}
else if(it->action_taken == ACT_fire_shotgun)
{
break;
case ACT_fire_shotgun:
AddFmt("%s fired their shotgun at %s, brutally murdering them.\n", characters[it->context.author_npc_kind].name, characters[it->action_argument.targeting].name);
}
else
{
assert(false);
}
break;
case ACT_put_shotgun_away:
AddFmt("%s holstered their shotgun, no longer threatening anybody\n", characters[it->context.author_npc_kind].name);
break;
}
}
if(it->speech.text_length > 0)
{

Loading…
Cancel
Save