From 5d8a977e9b17333c87a4eedba9249e19b723cb30 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sun, 18 Jun 2023 23:22:12 -0700 Subject: [PATCH] Add an arrow that insults you, and traps you in a fight until you refute the insult --- assets.mdesk | 4 ++ assets/new_level.json | 47 ++++++++++------- character_info.h | 16 +++++- main.c | 119 +++++++++++++++++++++++++++++++++++------- tuning.h | 1 + 5 files changed, 147 insertions(+), 40 deletions(-) diff --git a/assets.mdesk b/assets.mdesk index 3369a1c..91a25bc 100644 --- a/assets.mdesk +++ b/assets.mdesk @@ -126,6 +126,10 @@ { filepath: "scroll.png", } +@image arrow: +{ + filepath: "arrow.png", +} @image swipe: { filepath: "swipe.png", diff --git a/assets/new_level.json b/assets/new_level.json index fdeaab2..b517c5c 100644 --- a/assets/new_level.json +++ b/assets/new_level.json @@ -304,18 +304,18 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -359,8 +359,8 @@ "rotation":0, "visible":true, "width":32, - "x":1530.91836734694, - "y":2583.40136054421 + "x":1528.58503401361, + "y":2542.40136054421 }, { "class":"", @@ -450,12 +450,12 @@ "class":"", "height":32, "id":29, - "name":"Bill", + "name":"Arrow", "rotation":0, "visible":true, "width":32, - "x":1511.66666666667, - "y":2492.33333333333 + "x":1451, + "y":2652.33333333333 }, { "class":"", @@ -495,6 +495,17 @@ "width":32, "x":1523.33333333333, "y":1500.16666666667 + }, + { + "class":"", + "height":32, + "id":33, + "name":"Bill", + "rotation":0, + "visible":true, + "width":32, + "x":1505.33333333333, + "y":2401.33333333333 }], "opacity":1, "type":"objectgroup", @@ -503,7 +514,7 @@ "y":0 }], "nextlayerid":5, - "nextobjectid":33, + "nextobjectid":34, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.9.2", diff --git a/character_info.h b/character_info.h index aa827a3..eb90350 100644 --- a/character_info.h +++ b/character_info.h @@ -18,6 +18,12 @@ const char *bravado_thought = "For some reason, suddenly I feel a yearning for a #define Scroll2_Secret "temperance" #define Scroll3_Secret "magenta" +const char *arrow_insults[] = { + "You aren't good enough for anybody.", + "Your personality is embarrassing.", + "Your armor is weak and silly.", +}; + const char *top_of_header = "" "#pragma once\n" "\n"; @@ -242,10 +248,16 @@ CharacterGen characters[] = { }, { #undef NPC_NAME -#define NPC_NAME "Arrow" +#define NPC_NAME "Offensive Arrow" .name = NPC_NAME, .enum_name = "Arrow", - .prompt = "He is a calm, honorable ruler, who does the best he can to do good by his people, even if they can be a little crazy at times.", + .prompt = "It is a spiked arrow designd to insult and deride the player, with a specific insult. It will fight them until the player denies and rejects the insult, at which point it stops fighting.", + .writing_style = { + "You are quite the stinker!", + "I won't back down until you deny the allegations.", + "Quite an odd stance, you have.", + "Refute my insult, or stay perpetually in battle.", + }, }, { #undef NPC_NAME diff --git a/main.c b/main.c index 0968aa8..66c05b9 100644 --- a/main.c +++ b/main.c @@ -655,6 +655,10 @@ Vec2 entity_aabb_size(Entity *e) { return V2(TILE_SIZE*2.0f, TILE_SIZE*2.0f); } + else if (e->npc_kind == NPC_Arrow) + { + return V2(TILE_SIZE*2.0f, TILE_SIZE*2.0f); + } else { assert(false); @@ -1272,6 +1276,10 @@ void cause_action_side_effects(Entity *from, Action a) player->state = CHARACTER_TALKING; assert(is_fighting(player)); } + if(a.kind == ACT_stops_fighting_player && from->npc_kind == NPC_Arrow) + { + from->destroy = true; + } if(a.kind == ACT_stops_fighting_player || a.kind == ACT_leaves_player) { from->standing = STANDING_INDIFFERENT; @@ -2936,6 +2944,7 @@ typedef struct CollisionInfo { bool happened; Vec2 normal; + BUFF(Entity*, 8) with; }CollisionInfo; typedef struct MoveSlideParams @@ -2959,9 +2968,12 @@ Vec2 move_and_slide(MoveSlideParams p) assert(collision_aabb_size.x > 0.0f); assert(collision_aabb_size.y > 0.0f); AABB at_new = aabb_centered(new_pos, collision_aabb_size); - BUFF(AABB, 256) to_check = { 0 }; - - + typedef struct + { + AABB aabb; + Entity *e; // optional + } CollisionObj; + BUFF(CollisionObj, 256) to_check = { 0 }; // add tilemap boxes { @@ -2980,7 +2992,7 @@ Vec2 move_and_slide(MoveSlideParams p) if (is_tile_solid(get_tile_layer(&level_level0, 2, tilecoord_to_check))) { AABB t = tile_aabb(tilecoord_to_check); - BUFF_APPEND(&to_check, t); + BUFF_APPEND(&to_check, ((CollisionObj){t, 0})); } } } @@ -2993,7 +3005,7 @@ Vec2 move_and_slide(MoveSlideParams p) { if (!(it->is_character && it->is_rolling) && it != p.from && !(it->is_npc && it->dead) && !it->is_item && !(it->is_npc && it->npc_kind == NPC_Door && it->opened)) { - BUFF_APPEND(&to_check, aabb_centered(it->pos, entity_aabb_size(it))); + BUFF_APPEND(&to_check, ((CollisionObj){aabb_centered(it->pos, entity_aabb_size(it)), it})); } } } @@ -3002,12 +3014,12 @@ Vec2 move_and_slide(MoveSlideParams p) // box first, because doing so is a simple heuristic to avoid depenetrating and losing // sideways velocity. It's visual and I can't put diagrams in code so uh oh! - typedef BUFF(AABB, 32) OverlapBuff; + typedef BUFF(CollisionObj, 32) OverlapBuff; OverlapBuff actually_overlapping = { 0 }; - BUFF_ITER(AABB, &to_check) + BUFF_ITER(CollisionObj, &to_check) { - if (overlapping(at_new, *it)) + if (overlapping(at_new, it->aabb)) { BUFF_APPEND(&actually_overlapping, *it); } @@ -3017,9 +3029,9 @@ Vec2 move_and_slide(MoveSlideParams p) float smallest_distance = FLT_MAX; int smallest_aabb_index = 0; int i = 0; - BUFF_ITER(AABB, &actually_overlapping) + BUFF_ITER(CollisionObj, &actually_overlapping) { - float cur_dist = LenV2(SubV2(aabb_center(at_new), aabb_center(*it))); + float cur_dist = LenV2(SubV2(aabb_center(at_new), aabb_center(it->aabb))); if (cur_dist < smallest_distance) { smallest_distance = cur_dist; smallest_aabb_index = i; @@ -3033,7 +3045,7 @@ Vec2 move_and_slide(MoveSlideParams p) { BUFF_APPEND(&overlapping_smallest_first, actually_overlapping.data[smallest_aabb_index]); } - BUFF_ITER_I(AABB, &actually_overlapping, i) + BUFF_ITER_I(CollisionObj, &actually_overlapping, i) { if (i == smallest_aabb_index) { @@ -3045,33 +3057,35 @@ Vec2 move_and_slide(MoveSlideParams p) } // overlapping - BUFF_ITER(AABB, &overlapping_smallest_first) + BUFF_ITER(CollisionObj, &overlapping_smallest_first) { dbgcol(GREEN) { - dbgrect(*it); + dbgrect(it->aabb); } } //overlapping_smallest_first = actually_overlapping; - BUFF_ITER(AABB, &actually_overlapping) + BUFF_ITER(CollisionObj, &actually_overlapping) dbgcol(WHITE) - dbgrect(*it); + dbgrect(it->aabb); - BUFF_ITER(AABB, &overlapping_smallest_first) + BUFF_ITER(CollisionObj, &overlapping_smallest_first) dbgcol(WHITE) - dbgsquare(aabb_center(*it)); + dbgsquare(aabb_center(it->aabb)); CollisionInfo info = { 0 }; for (int col_iter_i = 0; col_iter_i < 1; col_iter_i++) - BUFF_ITER(AABB, &overlapping_smallest_first) + BUFF_ITER(CollisionObj, &overlapping_smallest_first) { - AABB to_depenetrate_from = *it; + AABB to_depenetrate_from = it->aabb; int iters_tried_to_push_apart = 0; + bool happened_with_this_one = false; while (overlapping(to_depenetrate_from, at_new) && iters_tried_to_push_apart < 500) { + happened_with_this_one = true; const float move_dist = 0.1f; info.happened = true; @@ -3103,6 +3117,32 @@ Vec2 move_and_slide(MoveSlideParams p) at_new.lower_right = AddV2(at_new.lower_right, move); iters_tried_to_push_apart++; } + if(happened_with_this_one) + { + bool already_in_happened = false; + Entity *e = it->e; + if(e) + { + BUFF_ITER(Entity *, &info.with) + { + if(e == *it) + { + already_in_happened = true; + } + } + if(!already_in_happened) + { + if(!BUFF_HAS_SPACE(&info.with)) + { + Log("WARNING not enough space in collision info out\n"); + } + else + { + BUFF_APPEND(&info.with, e); + } + } + } + } } if (p.col_info_out) *p.col_info_out = info; @@ -3919,7 +3959,6 @@ void frame(void) it->being_hovered = false; if (player->in_conversation_mode) { - if (has_point(entity_aabb(it), screen_to_world(mouse_pos))) { it->being_hovered = true; @@ -4290,6 +4329,40 @@ void frame(void) } // skelton combat and movement } // @Place(NPC processing) + else if(it->npc_kind == NPC_Arrow) + { + if(it->standing == STANDING_INDIFFERENT) + { + CollisionInfo info = {0}; + Vec2 movement = V2(ARROW_SPEED * dt, 0); + it->pos = move_and_slide((MoveSlideParams){it, it->pos, movement, .col_info_out = &info}); + if(info.happened) + { + Entity *from = it; + BUFF_ITER(Entity *, &info.with) + { + if((*it)->is_character || ((*it)->is_npc && (*it)->standing == STANDING_JOINED)) + { + Action fighting_action = {0}; + fighting_action.kind = ACT_fights_player; + MD_String8 insult = MD_S8Fmt(frame_arena, "Ahaha! %s", arrow_insults[rand() % ARRLEN(arrow_insults)]); + memcpy(fighting_action.speech, insult.str, insult.size); + fighting_action.speech_length = (int)insult.size; + fighting_action.talking_to_somebody = true; + fighting_action.talking_to_kind = NPC_Player; + perform_action(from, fighting_action); + break; + } + } + + if(from->standing != STANDING_FIGHTING) + { + // hit something, but didn't hit a fightable thing, or couldn't fight a fightable thing it hit + from->destroy = true; + } + } + } + } else if(it->npc_kind == NPC_Door) { if(it->opened) it->opened_amount = Lerp(it->opened_amount, dt*5.0f, 1.0f); @@ -4850,6 +4923,12 @@ void frame(void) draw_shadow_for(d); draw_quad(d); } + else if(it->npc_kind == NPC_Arrow) + { + DrawParams d = { true, quad_centered(it->pos, entity_aabb_size(it)), IMG(image_arrow), WHITE, }; + draw_shadow_for(d); + draw_quad(d); + } else { assert(false); diff --git a/tuning.h b/tuning.h index 6e1a9a0..e451feb 100644 --- a/tuning.h +++ b/tuning.h @@ -11,6 +11,7 @@ #define CHARACTERS_PER_SEC 45.0f #define PROPAGATE_ACTIONS_RADIUS (TILE_SIZE*4.0f) #define SWORD_SWIPE_RADIUS (TILE_SIZE*3.0f) +#define ARROW_SPEED 100.0f #define ARENA_SIZE (1024*1024)