Successfully compile under Wall, better drama story, ability to holster shotgun, other improvements

main
parent d5e669fa83
commit 30b2755186

@ -12,7 +12,8 @@
"file": 1,
"line": 2,
"column": 3,
}
},
"fileLocation": "absolute"
}
}
]

@ -1,44 +1,38 @@
[
{can_hear: [NPC_Daniel, NPC_Raphael]}
{enum: NPC_Devil, dialog: "What's up cracker jack", to: Daniel}
{enum: NPC_Daniel, dialog: "What the hell are you talking about?", to: Devil}
{enum: NPC_Devil, dialog: "Bootylicious", to: Daniel}
{enum: NPC_Daniel, dialog: "I don't know what the hell is going on here, but whatever it is it isn't good. Get off my property or leave promptly.", to: Devil}
{enum: NPC_Raphael, dialog: "Yeah man, what's up with you?", to: Devil}
{enum: NPC_Devil, dialog: "Nunya!", to: Raphael}
{enum: NPC_Raphael, dialog: "What does 'Nunya' mean? A wild critter you are...", to: Devil}
{enum: NPC_Daniel, dialog: "Can we do something about this vermin?", to: Raphael}
{enum: NPC_Raphael, dialog: "I dunno man, he's got some gunpowder", to: Daniel}
{enum: NPC_Daniel, dialog: "Gunpower? Well, that changes things. Keep an eye on him, but don't take any unnecessary risks. We don't need any more trouble around here.", to: Raphael}
{enum: NPC_Devil, dialog: "Lick my nuts!", to: Daniel}
{enum: NPC_Daniel, dialog: "You've got a mouth on you, don't you? I suggest you watch your tongue before you find yourself in a world of hurt.", to: Devil}
{enum: NPC_Raphael, dialog: "Man I could really use a vacation", to: Daniel}
{enum: NPC_Daniel, dialog: "A vacation, huh? I can understand that. Life can be tough out here. But remember, there's work to be done and responsibilities to uphold. We don't have the luxury of vacations around here.", to: Raphael}
{enum: NPC_Devil, dialog: "Bro why you talk like that", to: Daniel}
{enum: NPC_Daniel, dialog: "I talk like this because life has taught me to be cautious and weary. I've seen things that would make your blood run cold. So pardon me if I don't sound all cheery and optimistic like some folks. Now, if you're done with your questions, I suggest you mosey on out of here.", to: Devil}
{enum: NPC_Devil, dialog: "Never! I'll kill you and destroy your farm", to: Daniel}
{enum: NPC_Daniel, dialog: "You're treading on dangerous ground, stranger. Threatening me and my farm won't end well for you. I suggest you turn around and walk away before things escalate.", to: Devil}
{enum: NPC_Devil, dialog: "I'll take my leave them. Until next time!", to: Daniel}
{enum: NPC_Raphael, dialog: "What a psycho...", to: Daniel}
{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}
{enum: Devil, dialog: "Bootylicious?", to: Daniel}
{enum: Daniel, dialog: "You're 'asking too many darned questions! I'll have your body in my barn by sundown!", action: ACT_aim_shotgun, action_argument: "The Devil", to: Devil}
{enum: Raphael, dialog: "Yeah man, what's up with you?", to: Devil}
{enum: Devil, dialog: "Nunya!", to: Raphael}
{enum: Raphael, dialog: "What does 'Nunya' mean? A wild critter you are...", to: Devil}
{enum: Daniel, dialog: "YOU ASKED FOR IT! TAKE THIS!", action: ACT_fire_shotgun, to: Devil}
{enum: Devil, dialog: "Cute! You think your little toys can harm me!", to: Daniel}
{enum: Daniel, dialog: "What the hell??", to: Devil}
{enum: Raphael, dialog: "I don't think we can harm him like that", to: Daniel}
{enum: Daniel, dialog: "You're right, I guess we just gotta 'tolerate this feller's presence.", to: Raphael}
{enum: Devil, dialog: "I'll take my leave. Until next time!", to: Daniel}
{enum: Raphael, dialog: "What a psycho...", to: Daniel}
{can_hear: [NPC_Daniel, NPC_Raphael, NPC_Passerby]}
{enum: NPC_Passerby, dialog: "Yo", to: Raphael}
{enum: NPC_Raphael, dialog: "What's up", to: Passerby}
{enum: NPC_Passerby, dialog: "What do you think of farmers", to: Raphael}
{enum: NPC_Raphael, dialog: "What?", to: Passerby}
{enum: NPC_Daniel, dialog: "Let me 'say somthin here. Farmers are the backbone of this town, so you'd best give them some respect", to: Passerby}
{enum: NPC_Raphael, dialog: "I mean, scientists really are what's most important", to: Daniel}
{enum: NPC_Daniel, dialog: "First of all, what the hell is a scientist? Second of all, whoever they are, if they can't eat they're worthless!", to: Raphael}
{enum: NPC_Raphael, dialog: "FIne fine whatever, no need to get heated...", to: Daniel}
{enum: NPC_Daniel, dialog: "Anyways, sorry about that. What's your name?", to: Passerby}
{enum: NPC_Passerby, dialog: "Nevermind I'll just take my leave, later.", to: Daniel}
{can_hear: [Daniel, Raphael, Passerby]}
{enum: Passerby, dialog: "Yo", to: Raphael}
{enum: Raphael, dialog: "What's up", to: Passerby}
{enum: Passerby, dialog: "What do you think of farmers", to: Raphael}
{enum: Raphael, dialog: "What?", to: Passerby}
{enum: Daniel, dialog: "Let me 'say somthin here. Farmers are the backbone of this town, so you'd best give them some respect", to: Passerby}
{enum: Raphael, dialog: "I mean, scientists really are what's most important", to: Daniel}
{enum: Daniel, dialog: "First of all, what the hell is a scientist? Second of all, whoever they are, if they can't eat they're worthless!", to: Raphael}
{enum: Raphael, dialog: "FIne fine whatever, no need to get heated...", to: Daniel}
{enum: Daniel, dialog: "Anyways, sorry about that. What's your name?", to: Passerby}
{enum: Passerby, dialog: "Nevermind I'll just take my leave, later.", to: Daniel}
/*
{can_hear: [NPC_WellDweller, NPC_Farmer, NPC_ManInBlack]},
{enum: NPC_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: NPC_Farmer, dialog: "Sure as shit I won't!", to: WellDweller, mood: Scared, thoughts: "What a greasy looking feller"},
{enum: NPC_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: NPC_ManInBlack, dialog: "Doomsday's all I know anyways", mood: Indifferent, thoughts: "What's coming... is only a nightmare"},
{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"},
*/
]

@ -5,7 +5,7 @@
if "%1" == "codegen" ( call run_codegen.bat || goto :error ) else ( echo NOT RUNNING CODEGEN )
@REM start /B zig cc -DDEVTOOLS -Igen -Ithirdparty -lDbghelp -lGdi32 -lD3D11 -lOle32 -lwinhttp -gfull -gcodeview -o main_zig.exe main.c
cl /diagnostics:caret /DDEVTOOLS /Igen /Ithirdparty /W3 /Zi /WX Dbghelp.lib winhttp.lib main.c || goto :error
cl /diagnostics:caret /DDEVTOOLS /Igen /Ithirdparty /Wall /FC /Zi /WX Dbghelp.lib winhttp.lib main.c || goto :error
goto :EOF

@ -47,6 +47,11 @@ ActionInfo actions[] = {
.description = "Fires your shotgun at the current target, killing the target.",
NO_ARGUMENT,
},
{
.name = "put_shotgun_away",
.description = "Holsters your shotgun, no longer threatening who you're aiming at.",
NO_ARGUMENT,
},
};
typedef enum
@ -77,7 +82,7 @@ CharacterGen characters[] = {
{
.name = "Daniel",
.enum_name = "Daniel",
.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",
.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.",
},
{
.name = "Raphael",

@ -147,9 +147,10 @@ int main(int argc, char **argv)
fprintf(char_header, top_of_header);
#define GEN_TABLE(arr_elem_type, table_name, arr, str_access) { fprintf(char_header, "char *%s[] = {\n", table_name); ARR_ITER(arr_elem_type, arr) fprintf(char_header, "\"%s\",\n", str_access); fprintf(char_header, "}; // %s\n", table_name); }
#define GEN_ENUM(arr_elem_type, arr, enum_type_name, enum_name_access, fmt_str) { fprintf(char_header, "typedef enum\n{\n"); ARR_ITER(arr_elem_type, arr) fprintf(char_header, fmt_str, enum_name_access); fprintf(char_header, "} %s;\n", enum_type_name); GEN_TABLE(arr_elem_type, enum_type_name "_names", arr, enum_name_access); }
GEN_ENUM(ActionInfo, actions, "ActionKind", it->name, "ACT_%s,\n");
GEN_ENUM(CharacterGen, characters, "NpcKind", it->enum_name, "NPC_%s,\n");
#define GEN_ENUM(arr_elem_type, arr, enum_type_name, table_name, enum_name_access, fmt_str) { fprintf(char_header, "typedef enum\n{\n"); ARR_ITER(arr_elem_type, arr) fprintf(char_header, fmt_str, enum_name_access); fprintf(char_header, "} %s;\n", enum_type_name); GEN_TABLE(arr_elem_type, table_name, arr, enum_name_access); }
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);
fclose(char_header);

@ -1,4 +1,14 @@
#pragma warning(disable : 4820) // don't care about padding
#pragma warning(disable : 4388) // signed/unsigned mismatch probably doesn't matter
//#pragma warning(disable : 4100) // unused local doesn't matter, because sometimes I want to kee
#pragma warning(disable : 4053) // void operands are used for tricks like applying printf linting to non printf function calls
#pragma warning(disable : 4255) // strange no function prototype given thing?
#pragma warning(disable : 4456) // I shadow local declarations often and it's fine
#pragma warning(disable : 4061) // I don't need to *explicitly* handle everything, having a default: case should mean no more warnings
#pragma warning(disable : 4201) // nameless struct/union occurs
#pragma warning(disable : 4366) // I think unaligned memory addresses are fine to ignore
#pragma warning(disable : 4459) // Local function decl hiding global declaration I think is fine
#pragma warning(disable : 5045) // spectre mitigation??
#include "tuning.h"
@ -21,6 +31,7 @@
#ifdef WINDOWS
#pragma warning(push, 3)
#include <Windows.h>
#include <processthreadsapi.h>
#include <dbghelp.h>
@ -39,13 +50,19 @@ __declspec(dllexport) uint32_t AmdPowerXpressRequestHighPerformance = 0x00000001
#include "buff.h"
#include "sokol_app.h"
#pragma warning(push)
#pragma warning(disable : 4191) // unsafe function calling
#include "sokol_gfx.h"
#pragma warning(pop)
#include "sokol_time.h"
#include "sokol_audio.h"
#include "sokol_log.h"
#include "sokol_glue.h"
#define STB_IMAGE_IMPLEMENTATION
#pragma warning(push)
#pragma warning(disable : 4242) // unsafe conversion
#include "stb_image.h"
#pragma warning(pop)
#define STB_TRUETYPE_IMPLEMENTATION
#include "stb_truetype.h"
#define STB_DS_IMPLEMENTATION
@ -54,6 +71,8 @@ __declspec(dllexport) uint32_t AmdPowerXpressRequestHighPerformance = 0x00000001
#define DR_WAV_IMPLEMENTATION
#include "dr_wav.h"
#pragma warning(pop)
// web compatible metadesk
#ifdef WEB
#define __gnu_linux__
@ -143,6 +162,11 @@ void web_arena_set_auto_align(WebArena *arena, size_t align)
#pragma warning(push)
#pragma warning(disable : 4244) // loss of data warning
#pragma warning(disable : 4101) // unreferenced local variable
#pragma warning(disable : 4100) // unreferenced local variable again?
#pragma warning(disable : 4189) // initialized and not referenced
#pragma warning(disable : 4242) // conversion
#pragma warning(disable : 4457) // hiding function variable happens
#pragma warning(disable : 4668) // __GNU_C__ macro undefined, fixing
#define STBSP_ADD_TO_FUNCTIONS no_ubsan
#define MD_FUNCTION no_ubsan
#include "md.h"
@ -360,7 +384,7 @@ bool is_receiving_text_input()
}
#ifdef DESKTOP
char text_input_buffer[MAX_SENTENCE_LENGTH] = {0};
MD_u8 text_input_buffer[MAX_SENTENCE_LENGTH] = {0};
int text_input_buffer_length = 0;
#else
#ifdef WEB
@ -413,8 +437,10 @@ LPCWSTR windows_string(MD_String8 s)
#ifdef DESKTOP
#ifdef WINDOWS
#pragma warning(push, 3)
#include <WinHttp.h>
#include <process.h>
#pragma warning(pop)
typedef struct ChatRequest
{
@ -465,7 +491,7 @@ void generation_thread(void* my_request_voidptr)
if(my_request->should_close) return;
if(!succeeded)
{
Log("Couldn't do the web: %u\n", GetLastError());
Log("Couldn't do the web: %lu\n", GetLastError());
my_request->status = 2;
}
if(succeeded)
@ -475,7 +501,7 @@ void generation_thread(void* my_request_voidptr)
DWORD status_code;
DWORD status_code_size = sizeof(status_code);
WinAssertWithErrorCode(WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &status_code, &status_code_size, WINHTTP_NO_HEADER_INDEX));
Log("Status code: %u\n", status_code);
Log("Status code: %lu\n", status_code);
DWORD dwSize = 0;
MD_String8List received_data_list = {0};
@ -494,7 +520,7 @@ void generation_thread(void* my_request_voidptr)
DWORD dwDownloaded = 0;
WinAssertWithErrorCode(WinHttpReadData(hRequest, (LPVOID)out_buffer, dwSize, &dwDownloaded));
out_buffer[dwDownloaded - 1] = '\0';
Log("Got this from http, size %d: %s\n", dwDownloaded, out_buffer);
Log("Got this from http, size %lu: %s\n", dwDownloaded, out_buffer);
MD_S8ListPush(my_request->arena, &received_data_list, MD_S8(out_buffer, dwDownloaded));
}
} while (dwSize > 0);
@ -1578,7 +1604,7 @@ CanTalkTo get_can_talk_to(Entity *e)
{
if(it != e && (it->is_npc || it->is_character) && LenV2(SubV2(it->pos, e->pos)) < PROPAGATE_ACTIONS_RADIUS)
{
BUFF_APPEND(&to_return, it->npc_kind);
BUFF_APPEND(&to_return, it);
}
}
return to_return;
@ -1631,9 +1657,9 @@ MD_String8 is_action_valid(MD_Arena *arena, Entity *from, Action a)
if(error_message.size == 0 && a.talking_to_kind)
{
bool found = false;
BUFF_ITER(NpcKind, &talk)
BUFF_ITER(Entity*, &talk)
{
if(*it == a.talking_to_kind)
if((*it)->npc_kind == a.talking_to_kind)
{
found = true;
break;
@ -1657,15 +1683,19 @@ MD_String8 is_action_valid(MD_Arena *arena, Entity *from, Action a)
{
error_message = MD_S8Lit("You can't fire your shotgun without aiming it first");
}
if(error_message.size == 0 && a.kind == ACT_put_shotgun_away && gete(from->aiming_shotgun_at) == 0)
{
error_message = MD_S8Lit("You can't put your shotgun away without aiming it first");
}
bool target_is_character = a.kind == ACT_join || a.kind == ACT_aim_shotgun;
if(error_message.size == 0 && target_is_character)
{
bool arg_valid = false;
BUFF_ITER(NpcKind, &talk)
BUFF_ITER(Entity*, &talk)
{
if(*it == a.argument.targeting) arg_valid = true;
if((*it)->npc_kind == a.argument.targeting) arg_valid = true;
}
if(arg_valid == false)
{
@ -1939,7 +1969,6 @@ void dump_nodes(MD_Node *node)
printf(" `%.*s`\n", MD_S8VArg(cur_tovisit->ptr->string));
ToVisit new = {.depth = cur_tovisit->depth + 1};
for(MD_Node *cur = cur_tovisit->ptr->first_child; !MD_NodeIsNil(cur); cur = cur->next)
{
if(!in_arr(visited, cur))
@ -2114,11 +2143,12 @@ void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *leve
MD_String8 enum_str = expect_childnode(scratch.arena, cur, MD_S8Lit("enum"), &drama_errors)->first_child->string;
MD_String8 dialog = expect_childnode(scratch.arena, cur, MD_S8Lit("dialog"), &drama_errors)->first_child->string;
MD_String8 action_str = MD_ChildFromString(cur, MD_S8Lit("action"), 0)->first_child->string;
MD_String8 action_argument_str = MD_ChildFromString(cur, MD_S8Lit("action_argument"), 0)->first_child->string;
MD_String8 to_str = MD_ChildFromString(cur, MD_S8Lit("to"), 0)->first_child->string;
if(to_str.size > 0)
{
NpcKind talking_to = parse_enumstr(scratch.arena, to_str, &drama_errors, NpcKind_names, "NpcKind", "");
NpcKind talking_to = parse_enumstr(scratch.arena, to_str, &drama_errors, NpcKind_enum_names, "NpcKind", "");
if (talking_to == NPC_nobody)
{
PushWithLint(scratch.arena, &drama_errors, "The string provided for the 'to' field, intended to be who the NPC is directing their speech and action at, is invalid and is '%.*s'", MD_S8VArg(to_str));
@ -2130,10 +2160,14 @@ void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *leve
}
}
current_context.author_npc_kind = parse_enumstr(scratch.arena, enum_str, &drama_errors, NpcKind_names, "NpcKind", "NPC_");
current_context.author_npc_kind = parse_enumstr(scratch.arena, enum_str, &drama_errors, NpcKind_enum_names, "NpcKind", "");
if(action_str.size > 0)
{
current_action.kind = parse_enumstr(scratch.arena, action_str, &drama_errors,ActionKind_names, "ActionKind", "ACT_");
current_action.kind = parse_enumstr(scratch.arena, action_str, &drama_errors, ActionKind_names, "ActionKind", "ACT_");
}
if(action_argument_str.size > 0)
{
current_action.argument.targeting = parse_enumstr(scratch.arena, action_argument_str, &drama_errors, NpcKind_names, "NpcKind", "");
}
if(dialog.size >= ARRLEN(current_action.speech.text))
@ -2151,7 +2185,7 @@ void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *leve
{
for(MD_Node *cur_kind_node = can_hear; !MD_NodeIsNil(cur_kind_node); cur_kind_node = cur_kind_node->next)
{
NpcKind want = parse_enumstr(scratch.arena, cur_kind_node->string, &drama_errors, NpcKind_names, "NpcKind", "NPC_");
NpcKind want = parse_enumstr(scratch.arena, cur_kind_node->string, &drama_errors, NpcKind_enum_names, "NpcKind", "");
if(drama_errors.node_count == 0)
{
bool found = false;
@ -2392,11 +2426,11 @@ void ser_GameState(SerState *ser, GameState *gs)
// error_out is allocated onto arena if it fails
MD_String8 save_to_string(MD_Arena *output_bytes_arena, MD_Arena *error_arena, MD_String8 *error_out, GameState *gs)
{
SerState ser = {.version = VMax - 1, .serializing = true};
MD_u8 *serialized_data = 0;
MD_u64 serialized_length = 0;
{
SerState ser = {
.version = VMax - 1,
.serializing = true,
.error_arena = error_arena,
};
@ -2749,7 +2783,7 @@ Animation *get_anim_by_name(Armature *armature, MD_String8 anim_name)
}
// you can pass a time greater than the animation length, it's fmodded to wrap no matter what.
Transform get_animated_bone_transform(AnimationTrack *track, Bone *bone, float time, bool dont_loop)
Transform get_animated_bone_transform(AnimationTrack *track, float time, bool dont_loop)
{
assert(track);
float total_anim_time = track->poses[track->poses_length - 1].time;
@ -2837,7 +2871,6 @@ void audio_stream_callback(float *buffer, int num_frames, int num_channels)
{
assert(num_channels == 1);
const int num_samples = num_frames * num_channels;
double time_to_play = (double)num_frames / (double)SAMPLE_RATE;
double time_per_sample = 1.0 / (double)SAMPLE_RATE;
for (int i = 0; i < num_samples; i++)
{
@ -3109,9 +3142,6 @@ void init(void)
.logger.func = slog_func,
});
typedef BUFF(char, 1024) DialogNode;
DialogNode cur_node = { 0 };
load_assets();
MD_String8 binary_file;
@ -3659,7 +3689,7 @@ StacktraceInfo get_stacktrace()
if(!SymFromAddr(process, (DWORD64) stack[i], 0, symbol))
{
DWORD error_code = GetLastError();
Log("Could not read stack trace: %d\n", error_code);
Log("Could not read stack trace: %lu\n", error_code);
assert(false);
}
@ -4528,7 +4558,6 @@ MD_String8 last_said_sentence(Entity *npc)
MD_String8 to_return = (MD_String8){0};
Memory *cur = npc->memories_last;
for(Memory *cur = npc->memories_last; cur; cur = cur->prev)
{
if(cur->context.author_npc_kind == npc->npc_kind)
@ -4815,7 +4844,6 @@ FrustumVertices get_frustum_vertices(Vec3 cam_pos, Vec3 cam_forward, Vec3 cam_ri
float aspect_ratio = (float)sapp_width() / (float)sapp_height();
const int num_frustum_vertices = sizeof(result.vertices)/sizeof(result.vertices[0]);
const float cascade_distance = FAR_PLANE_DISTANCE;
@ -4920,12 +4948,12 @@ Shadow_Volume_Params calculate_shadow_volume_params(Vec3 light_dir, Vec3 cam_pos
void debug_draw_img(sg_image img, int index) {
draw_quad((DrawParams){quad_at(V2(512.0f*index, 512.0), V2(512.0, 512.0)), IMG(state.shadows.color_img), WHITE, .layer=LAYER_UI});
draw_quad((DrawParams){quad_at(V2(512.0f*index, 512.0), V2(512.0, 512.0)), IMG(img), WHITE, .layer=LAYER_UI});
}
void debug_draw_img_with_border(sg_image img, int index) {
float bs = 50.0;
draw_quad((DrawParams){quad_at(V2(512.0f*index, 512.0), V2(512.0, 512.0)), state.shadows.color_img, (AABB){V2(-bs, -bs), AddV2(img_size(img), V2(bs, bs))}, WHITE, .layer=LAYER_UI});
draw_quad((DrawParams){quad_at(V2(512.0f*index, 512.0), V2(512.0, 512.0)), img, (AABB){V2(-bs, -bs), AddV2(img_size(img), V2(bs, bs))}, WHITE, .layer=LAYER_UI});
}
void debug_draw_shadow_info(Vec3 frustum_tip, Vec3 cam_forward, Vec3 cam_right, Mat4 light_space_matrix) {
@ -4967,7 +4995,7 @@ void debug_draw_shadow_info(Vec3 frustum_tip, Vec3 cam_forward, Vec3 cam_right,
void actually_draw_thing(DrawnThing *it, Mat4 light_space_matrix, bool for_outline)
{
int num_vertices_to_draw;
int num_vertices_to_draw = 0;
if(it->mesh)
{
if(for_outline)
@ -5038,6 +5066,7 @@ void actually_draw_thing(DrawnThing *it, Mat4 light_space_matrix, bool for_outli
}
num_draw_calls += 1;
assert(num_vertices_to_draw > 0);
num_vertices += num_vertices_to_draw;
sg_draw(0, num_vertices_to_draw, 1);
}
@ -5540,7 +5569,7 @@ void frame(void)
{
Transform *output_transform = &cur->anim_blended_poses[i];
Transform from_transform = cur->current_poses[i];
Transform to_transform = get_animated_bone_transform(&to_anim->tracks[i], &cur->bones[i], along_current_animation, cur->currently_playing_isnt_looping);
Transform to_transform = get_animated_bone_transform(&to_anim->tracks[i], along_current_animation, cur->currently_playing_isnt_looping);
*output_transform = lerp_transforms(from_transform, cur->animation_blend_t, to_transform);
}
@ -5550,7 +5579,7 @@ void frame(void)
Animation *cur_anim = get_anim_by_name(cur, cur->currently_playing_animation);
for(MD_u64 i = 0; i < cur->bones_length; i++)
{
cur->anim_blended_poses[i] = get_animated_bone_transform(&cur_anim->tracks[i], &cur->bones[i], along_current_animation, cur->currently_playing_isnt_looping);
cur->anim_blended_poses[i] = get_animated_bone_transform(&cur_anim->tracks[i], along_current_animation, cur->currently_playing_isnt_looping);
}
}
}
@ -6577,7 +6606,6 @@ ISANERROR("Don't know how to do this stuff on this platform.")
float speed = 0.0f;
{
Vec2 target_vel = { 0 };
if(gs.player->killed) gs.player->state = CHARACTER_KILLED;
if(gs.player->state == CHARACTER_WALKING)
@ -6887,8 +6915,6 @@ ISANERROR("Don't know how to do this stuff on this platform.")
mem_idx++;
}
}
break;
}
}
}
@ -6915,7 +6941,6 @@ ISANERROR("Don't know how to do this stuff on this platform.")
{
ARR_ITER_I(RenderingQueue, rendering_queues, i)
{
Layer layer = (Layer)i;
RenderingQueue *rendering_queue = it;
qsort(&rendering_queue->data[0], rendering_queue->cur_index, sizeof(rendering_queue->data[0]), rendering_compare);
@ -7103,7 +7128,7 @@ void event(const sapp_event *e)
text_input_buffer_length = ARRLEN(text_input_buffer) - 1;
}
text_input_buffer[text_input_buffer_length] = '\0';
end_text_input(text_input_buffer);
end_text_input((char*)text_input_buffer);
}
}
#endif

@ -271,10 +271,11 @@ typedef struct Entity
EntityRef talking_to;
} Entity;
typedef BUFF(NpcKind, 32) CanTalkTo;
typedef BUFF(Entity*, 32) CanTalkTo;
float entity_max_damage(Entity *e)
{
(void)e;
return 1.0f;
}
@ -329,6 +330,7 @@ void fill_available_actions(GameState *gs, Entity *it, AvailableActions *a)
{
if(gete_specified(gs, it->aiming_shotgun_at))
{
BUFF_APPEND(a, ACT_put_shotgun_away);
BUFF_APPEND(a, ACT_fire_shotgun);
}
else
@ -387,9 +389,15 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, GameState *gs, Entity *e, Ca
AddFmt("%s\n\n", global_prompt);
AddFmt("%s\n\n", characters[e->npc_kind].prompt);
AddFmt("The characters who are near you, that you can target:\n");
BUFF_ITER(NpcKind, &can_talk_to)
BUFF_ITER(Entity*, &can_talk_to)
{
AddFmt("%s\n", characters[*it].name);
assert((*it)->is_npc || (*it)->is_character);
MD_String8 info = MD_S8Lit("");
if((*it)->killed)
{
info = MD_S8Lit(" - they're currently dead, they were murdered");
}
AddFmt("%s%.*s\n", characters[(*it)->npc_kind].name, MD_S8VArg(info));
}
AddFmt("\n");
@ -526,13 +534,13 @@ MD_String8 parse_chatgpt_response(MD_Arena *arena, Entity *e, MD_String8 action_
MD_String8 speech_str = {0};
MD_String8 action_str = {0};
MD_String8 action_arg_str = {0};
MD_String8 action_argument_str = {0};
MD_String8 target_str = {0};
if(error_message.size == 0)
{
speech_str = get_field(message_obj, MD_S8Lit("speech"));
action_str = get_field(message_obj, MD_S8Lit("action"));
action_arg_str = get_field(message_obj, MD_S8Lit("action_argument"));
action_argument_str = get_field(message_obj, MD_S8Lit("action_argument"));
target_str = get_field(message_obj, MD_S8Lit("target"));
}
if(error_message.size == 0 && action_str.size == 0)
@ -607,7 +615,7 @@ MD_String8 parse_chatgpt_response(MD_Arena *arena, Entity *e, MD_String8 action_
bool found_npc = false;
for(int i = 0; i < ARRLEN(characters); i++)
{
if(MD_S8Match(MD_S8CString(characters[i].name), action_arg_str, 0))
if(MD_S8Match(MD_S8CString(characters[i].name), action_argument_str, 0))
{
found_npc = true;
out->argument.targeting = i;
@ -615,7 +623,7 @@ MD_String8 parse_chatgpt_response(MD_Arena *arena, Entity *e, MD_String8 action_
}
if(!found_npc)
{
error_message = FmtWithLint(arena, "Argument for action `%.*s` you gave is `%.*s`, which doesn't exist in the game so is invalid", MD_S8VArg(action_str), MD_S8VArg(action_arg_str));
error_message = FmtWithLint(arena, "Argument for action `%.*s` you gave is `%.*s`, which doesn't exist in the game so is invalid", MD_S8VArg(action_str), MD_S8VArg(action_argument_str));
}
}
else

Loading…
Cancel
Save