From 77c22bf38be24fe53cd538fdae4db24017d2e4e2 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Wed, 8 Mar 2023 17:47:21 -0800 Subject: [PATCH] Drop shadow, merchant character --- assets/level0.json | 23 +++++++++---- main.c | 58 ++++++++++++++++++++++++++++++--- server/main.go | 2 +- server/training_data.txt | 50 +++++++++++++++++++++++++++- server/training_data_convert.py | 2 +- todo.txt | 11 +------ 6 files changed, 123 insertions(+), 23 deletions(-) diff --git a/assets/level0.json b/assets/level0.json index 2ade691..08d506d 100644 --- a/assets/level0.json +++ b/assets/level0.json @@ -344,12 +344,12 @@ "class":"", "height":32, "id":3, - "name":"OLD_MAN", + "name":"MERCHANT", "rotation":0, "visible":true, "width":32, - "x":1528.66666666667, - "y":748.333333333337 + "x":1015, + "y":859.66666666667 }, { "class":"", @@ -370,8 +370,8 @@ "rotation":0, "visible":true, "width":32, - "x":1637, - "y":921.833333333333 + "x":1009, + "y":974.833333333333 }, { "class":"", @@ -405,6 +405,17 @@ "width":32, "x":1716, "y":1222.66666666667 + }, + { + "class":"", + "height":32, + "id":10, + "name":"OLD_MAN", + "rotation":0, + "visible":true, + "width":32, + "x":1019.66666666667, + "y":917.666666666667 }], "opacity":1, "type":"objectgroup", @@ -413,7 +424,7 @@ "y":0 }], "nextlayerid":8, - "nextobjectid":10, + "nextobjectid":11, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.9.2", diff --git a/main.c b/main.c index 255c8be..3db1483 100644 --- a/main.c +++ b/main.c @@ -151,9 +151,11 @@ typedef BUFF(Sentence, 2*12) Dialog; // six back and forths. must be even number typedef enum NpcKind { + INVALID, OLD_MAN, DEATH, SKELETON, + MERCHANT, } NpcKind; typedef struct Entity @@ -366,6 +368,11 @@ void end_text_input(char *what_player_said) Log("Doing prompt death\n"); character_prompt = "Death: \""; } + else if(talking->npc_kind == MERCHANT) + { + BUFF_APPEND(&to_join, PROMPT_MERCHANT); + character_prompt = "Merchant: \""; + } else { assert(false); @@ -422,8 +429,13 @@ void end_text_input(char *what_player_said) } if(player->talking_to->npc_kind == OLD_MAN) { - add_new_npc_sentence(player->talking_to, "If it's a fight you're looking for! *fights player*"); + add_new_npc_sentence(player->talking_to, "If it's a fight you're looking for! *fights player*"); + } + if(player->talking_to->npc_kind == MERCHANT) + { + add_new_npc_sentence(player->talking_to, "*fights player*"); } + #endif } } @@ -571,6 +583,10 @@ Vec2 entity_aabb_size(Entity *e) { return V2(TILE_SIZE*1.0f, TILE_SIZE*1.0f); } + else if(e->npc_kind == MERCHANT) + { + return V2(TILE_SIZE*1.0f, TILE_SIZE*1.0f); + } else { assert(false); @@ -781,6 +797,7 @@ AnimatedSprite skeleton_swing_sword = .horizontal_diff_btwn_frames = 80.0, .offset = {0.0f, 20.0f}, .region_size = {80.0f, 80.0f}, + .no_wrap = true, }; AnimatedSprite skeleton_run = { @@ -792,6 +809,16 @@ AnimatedSprite skeleton_run = .offset = {0.0f, 20.0f}, .region_size = {80.0f, 80.0f}, }; +AnimatedSprite merchant_idle = +{ + .img = &image_merchant, + .time_per_frame = 0.15, + .num_frames = 8, + .start = {0.0, 0.0}, + .horizontal_diff_btwn_frames = 110.0f, + .region_size = {110.0f, 110.0f}, + .offset = {0.0f, -20.0f}, +}; sg_image image_font = {0}; @@ -2048,12 +2075,33 @@ void frame(void) if(fabsf(it->vel.x) > 0.01f) it->facing_left = it->vel.x < 0.0f; + + // draw drop shadow + if(it->is_character || it->is_npc) + { + if(it->npc_kind != DEATH) + { + float shadow_size = knight_rolling.region_size.x * 0.5f; + Vec2 shadow_offset = V2(0.0f, -20.0f); + if(it->npc_kind == MERCHANT) + { + shadow_offset = V2(-4.5f, -15.0f); + } + else if(it->npc_kind == OLD_MAN) + { + shadow_offset = V2(-1.5f, -8.0f); + shadow_size *= 0.5f; + } + draw_quad((DrawParams){true, quad_centered(AddV2(it->pos, shadow_offset), V2(shadow_size, shadow_size)),IMG(image_drop_shadow), WHITE}); + } + } + if(it->is_npc) { if(!BUFF_EMPTY(&it->sentence_to_say)) { it->character_say_timer += dt; - const float character_say_time = 0.05f; + const float character_say_time = 0.02f; while(it->character_say_timer > character_say_time) { say_characters(it, 1); @@ -2164,6 +2212,10 @@ void frame(void) { draw_animated_sprite(&death_idle, elapsed_time, true, AddV2(it->pos, V2(0, 30.0f)), col); } + else if(it->npc_kind == MERCHANT) + { + draw_animated_sprite(&merchant_idle, elapsed_time, true, AddV2(it->pos, V2(0, 30.0f)), col); + } else { assert(false); @@ -2323,8 +2375,6 @@ draw_dialog_panel(talking_to); Vec2 target_vel = {0}; float speed = 0.0f; - float shadow_size = knight_rolling.region_size.x * 0.5f; - draw_quad((DrawParams){true, quad_centered(AddV2(player->pos, V2(0.0f, -20.0f)), V2(shadow_size, shadow_size)),IMG(image_drop_shadow), WHITE}); if(player->state == CHARACTER_WALKING) { speed = PLAYER_SPEED; diff --git a/server/main.go b/server/main.go index 86d783d..4ac08b2 100644 --- a/server/main.go +++ b/server/main.go @@ -32,7 +32,7 @@ func index(w http.ResponseWriter, req *http.Request) { MaxTokens: 80, Prompt: promptString, Temperature: 0.9, - FrequencyPenalty: 1.3, + FrequencyPenalty: 0.75, Stop: []string{"\""}, N: 1, } diff --git a/server/training_data.txt b/server/training_data.txt index 3846afd..5930eb7 100644 --- a/server/training_data.txt +++ b/server/training_data.txt @@ -347,6 +347,13 @@ Death: "...*moves*" Player: "Move out of the way" Death: "*moves*" +Player: "Hey" +Death: "...MOVE...ASIDE" +Player: "Move" +Death: "ASIDE" +Player: "Move out of the way" +Death: "*moves*" + Player: "What do you do?" Merchant: "I'm trying to sell these wonderful boots of grounding. Interested?" Player: "Sure!" @@ -356,7 +363,7 @@ Merchant: "Sure! They help you stay more connected to the scenery and experience Player: "Man fuck off these suck" Merchant: "Careful, I'm not afraid to use my shotgun" Player: "I should skin you alive" -Merchant: "*fights player*" +Merchant: "*sells grounding boots*" Player: "What's up?" Merchant: "I'm trying to sell these wonderful boots of grounding. Interested?" @@ -385,3 +392,44 @@ Player: "To get to the other side" Merchant: "Mmmm...Not doing it for me" Player: "Alright, how about this one: bitch bithch bitch bitcH" Merchant: "Too vulgar. You know, somebody of your immaturity could really use some grounding. Here you go *sells grounding boots*" + +Player: "Hey" +Merchant: "Wha? Another player?" +Player: "Sell me boots of swiftness" +Merchant: "Bah... c'mon now, be reasonable. We're not making any money here" +Player: "What do you mean?" +Merchant: "I don't take money, I take jokes" +Player: "What kind of jokes?" +Merchant: "They have to be clever, witty...Tell a good joke, I give you a good item" +Player: "What do you have for sale?" +Merchant: "Well, we have some fantastic grounding boots! No joke necessary, ask and you'll receive" +Player: "I would like to buy those" +Merchant: "*sells grounding boots*" +Player: "These made me slower!" +Merchant: "They help you appreciate the scenery" +Player: "Do you have anything else for sale?" +Merchant: "Well... I do have boots of swiftness...But there's no way you'd want those." +Player: "Why?" +Merchant: "Who wants better move speed? Take life easy." +Player: "I would like to buy those" +Merchant: "Tell me a good joke" +Player: "Confucius say, it take many nail to build crib, one screw to fill it" +Merchant: "Ha! I love the cleverness. *sells swiftness boots*" + +Player: "What do you have for sale?" +Merchant: "Some boots of grounding, some boots of swiftness. What are you looking for?" +Player: "Can I buy boots of grounding?" +Merchant: "Certainly! *sells grounding boots*" + +Player: "hey" +Merchant: "Welcome! I'm selling boots of grounding, and boots of swiftness" +Player: "What do you have for sale?" +Merchant: "Boots of grounding, and boots of swiftness" +Player: "Can you sell me boots of swiftness?" +Merchant: "It'll take a good joke for me to sell you those" +Player: "How about the boots of grounding?" +Merchant: "Certainly! *sells grounding boots*" +Player: "What has two thumbs and is a funny guy?" +Merchant: "Myself" +Player: "No I am!" +Merchant: "Be mindful of your tongue, lest it get you into trouble." diff --git a/server/training_data_convert.py b/server/training_data_convert.py index baf8fc9..d4e9772 100644 --- a/server/training_data_convert.py +++ b/server/training_data_convert.py @@ -5,7 +5,7 @@ def general_prompt(actions): prompts = { "Death" : general_prompt("[*moves*]") + " The NPC, death, is a standoffish character who responds in all capitals and short terse sentences. He is blocking the player and will let them pass if the player asks.", "Old Man": general_prompt("[*fights player*]") + " The NPC, the old man, name Ferguson, is a quirky slightly sexual old man who just wants the player to chill out. If the player aggravates him he will fight them with his shotgun.", - "Merchant": general_prompt("[*sells grounding boots*, *sells swiftness boots*, *fights player*]") + " The NPC, the merchant, name Henry, is a panicked salesman who really wants to sell the player his grounding boots, as they decrease move speed so nobody wants to buy them. Like the old man he has a shotgun he is not afraid to use if the player is forceful or rude. He also is selling boots of swiftness, but is reluctant to sell them. He doesn't take or use money, only funny jokes. He likes clever non-vulgar comedy", + "Merchant": general_prompt("[*sells grounding boots*, *sells swiftness boots*]") + " The NPC, the merchant, name Henry, is a panicked salesman who really wants to sell the player his grounding boots, as they decrease move speed so nobody wants to buy them. Unlike the old man he doesn't have a shotgun, instead if the player is impolite he repeatedly sells the player grounding boots. He also is selling boots of swiftness, but is reluctant to sell them. He doesn't take or use money, only funny jokes. He likes clever non-vulgar comedy.", } with open("../gen/prompts.gen.h", "w") as w: diff --git a/todo.txt b/todo.txt index 571a01e..beffa26 100644 --- a/todo.txt +++ b/todo.txt @@ -1,13 +1,5 @@ Happening: -DONE - Animate text characters coming in -DONE - Escape exits typing -DONE - Get rid of enters and stars in javascript input box -DONE - Space and e for attack and roll, tooltip -DONE - Sword improvements, deflect bullets -DONE - Player knockback and drop shadow - - Skeleton enemy - Shopkeep character - - Don't flip player direction when you walk vertically - Save every request and response (server logs) - Moose boss - Portal at end, exit level @@ -24,6 +16,5 @@ Marketing: and particles. Lets you keep momentum. Each dodge roll takes slightly different amount of time so you have to judge it - - Max text length + - Max text length on text input - Mobile controls - - Boss