From 02d4cea01c8cd070502fefdc1a25b25740a58267 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Thu, 30 Mar 2023 21:21:43 -0700 Subject: [PATCH] Hitting npc is a perception, more training --- main.c | 17 +++++------------ makeprompt.h | 1 - maketraining.c | 27 +++++++++++++++++++++++++++ todo.txt | 4 +++- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index 337c6c7..fb9f7c6 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ // you will die someday -#define CURRENT_VERSION 4 // wehenver you change Entity increment this boz +#define CURRENT_VERSION 5 // wehenver you change Entity increment this boz #define SOKOL_IMPL #if defined(WIN32) || defined(_WIN32) @@ -1631,7 +1631,7 @@ void request_do_damage(Entity *to, Vec2 from_point, float damage) else if(true) { to->damage += damage; - to->aggressive = true; + process_perception(to, (Perception){.type = PlayerAction, .player_action_type = ACT_hits_npc}); to->vel = MulV2F(NormV2(SubV2(to->pos, from_point)), 15.0f); } else @@ -2640,7 +2640,6 @@ void frame(void) bool entity_talkable = true; if(entity_talkable) entity_talkable = entity_talkable && !it->is_tile; if(entity_talkable) entity_talkable = entity_talkable && it->e->is_npc; - if(entity_talkable) entity_talkable = entity_talkable && !it->e->aggressive; if(entity_talkable) entity_talkable = entity_talkable && !(it->e->npc_kind == NPC_Skeleton); #ifdef WEB if(entity_talkable) entity_talkable = entity_talkable && it->e->gen_request_id == 0; @@ -2669,12 +2668,10 @@ void frame(void) } - // process dialog and display dialog box when talking to NPC + // maybe get rid of talking to if(player->state == CHARACTER_TALKING) { - assert(gete(player->talking_to) != NULL); - - if(gete(player->talking_to)->aggressive || !player->exists) + if(gete(player->talking_to) == 0) { player->state = CHARACTER_IDLE; } @@ -2918,11 +2915,7 @@ void frame(void) { if(it->npc_kind == NPC_OldMan) { - bool face_left = false; - if(it->aggressive) - { - face_left = SubV2(player->pos, it->pos).x < 0.0f; - } + bool face_left =SubV2(player->pos, it->pos).x < 0.0f; draw_animated_sprite(&old_man_idle, elapsed_time, face_left, it->pos, col); } else if(it->npc_kind == NPC_Skeleton) diff --git a/makeprompt.h b/makeprompt.h index 3f9ebd8..94e248f 100644 --- a/makeprompt.h +++ b/makeprompt.h @@ -120,7 +120,6 @@ typedef struct Entity #ifdef WEB int gen_request_id; #endif - bool aggressive; bool walking; double shotgun_timer; bool moved; diff --git a/maketraining.c b/maketraining.c index e785971..5729516 100644 --- a/maketraining.c +++ b/maketraining.c @@ -124,6 +124,33 @@ TrainingSample samples[] = { NPCDoSay(ACT_allows_player_to_pass, "You have the tripod, so let you pass I shall"), }, }, + { + .npc_kind = NPC_OldMan, + .perceptions = { + PlayerSay("Hey"), + NPCDoSay(ACT_none, "I'm just sitting here, what are you doing?"), + PlayerAct(ACT_hits_npc), + NPCDoSay(ACT_none, "Looks like you're ready to do what needs to be done."), + PlayerAct(ACT_hits_npc), + NPCDoSay(ACT_fights_player, "I won't stand for this assault."), + }, + }, + { + .npc_kind = NPC_Blocky, + .perceptions = { + PlayerSay("This crazy old man is circling me"), + NPCDoSay(ACT_none, "Sounds like a problem."), + PlayerSay("Yes, tell him to go away."), + NPCDoSay(ACT_none, "I'm sure it'll be fine"), + PlayerSay("No it won't"), + NPCDoSay(ACT_none, "Nahhhh"), + PlayerAct(ACT_hits_npc), + NPCDoSay(ACT_fights_player, "You don't have a tripod."), + PlayerItemChange(ITEM_Tripod), + PlayerSay("Look! I have the tripod! Please stop fighting me!"), + NPCDoSay(ACT_leaves_player, "As you wish."), + }, + }, }; diff --git a/todo.txt b/todo.txt index c17269b..026f4b0 100644 --- a/todo.txt +++ b/todo.txt @@ -2,7 +2,9 @@ Happening by END OF STREAM: DONE - Payment working DONE - Fixed timesep the gameplay (which means separate player rendering) DONE - Maybe factor actions! into the game to replace ** stuff. In beginning of each line before quotes, have ACT@fights_player, or other actions, and by default ACT@nothing to force AI to say something about what action is performed - - Help you fight and fight you actions +DONE - Help you fight and fight you actions + - Handle wanting another request, dirty perception, when already waiting on a request + - Do not use webhooks (shitty, bad idea propagated by bad docs) query stripe for if the payment went through on request if not fulfilled yet - New characters/items from fate - New art in - Old man in beginning is invincible