From aeeb9bfb0a1d0982d413c73a72d37fa039d561ae Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sat, 12 Aug 2023 23:31:17 -0700 Subject: [PATCH] Characters need to remember when they've said nothing, so that they later say something, because they realize that they haven't spoken yet. Fix nans in plane equation --- main.c | 28 +++++++++++++++++++++------- tuning.h | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 03d90fd..fcd4f2f 100644 --- a/main.c +++ b/main.c @@ -1597,7 +1597,7 @@ void remember_action(GameState *gs, Entity *to_modify, Action a, MemoryContext c push_memory(gs, to_modify, new_memory); - if(context.i_said_this) + if(context.i_said_this && (a.speech.text_length > 0 || a.kind != ACT_none)) { to_modify->undismissed_action = true; to_modify->undismissed_action_tick = gs->tick; @@ -1799,20 +1799,19 @@ bool perform_action(GameState *gs, Entity *from, Action a) proceed_propagating = false; } - if(a.speech.text_length == 0 && a.kind == ACT_none) - { - proceed_propagating = false; // didn't say anything - } + + Entity *targeted = 0; if(proceed_propagating) { + targeted = get_targeted(from, a.talking_to_kind); if(from->errorlist_first) MD_StackPush(text_chunk_free_list, from->errorlist_first); from->errorlist_first = 0; from->errorlist_last = 0; - Entity *targeted = get_targeted(from, a.talking_to_kind); cause_action_side_effects(from, a); + // self memory if(!from->is_character) { @@ -1821,6 +1820,14 @@ bool perform_action(GameState *gs, Entity *from, Action a) remember_action(gs, from, a, my_context); } + if(a.speech.text_length == 0 && a.kind == ACT_none) + { + proceed_propagating = false; // didn't say anything + } + } + + if(proceed_propagating) + { // memory of target if(targeted) { @@ -3747,6 +3754,12 @@ Vec3 ray_intersect_plane(Vec3 ray_point, Vec3 ray_vector, Vec3 plane_point, Vec3 float t = -(DotV3(plane_normal, ray_point) + d) / DotV3(plane_normal, ray_vector); + if(t <= 1e-4) + { + // means doesn't intersect the plane, I think... + return plane_point; + } + assert(t > 1e-4); return AddV3(ray_point, MulV3F(ray_vector, t)); @@ -6754,7 +6767,8 @@ ISANERROR("Don't know how to do this stuff on this platform.") draw_quad((DrawParams){quad_at(V2(0.0, screen_size().y/2.0f), MulV2F(screen_size(), 0.1f)), IMG(state.outline_pass_image), WHITE, .layer = LAYER_UI_FG}); Vec3 view_cam_pos = MulM4V4(InvGeneralM4(view), V4(0,0,0,1)).xyz; - if(view_cam_pos.y >= 0.050f) // causes nan if not true... not good... + //if(view_cam_pos.y >= 4.900f) // causes nan if not true... not good... + if(true) { Vec3 world_mouse = screenspace_point_to_camera_point(mouse_pos); Vec3 mouse_ray = NormV3(SubV3(world_mouse, view_cam_pos)); diff --git a/tuning.h b/tuning.h index b80c3db..56d8675 100644 --- a/tuning.h +++ b/tuning.h @@ -28,7 +28,7 @@ #ifdef DEVTOOLS // 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