Death NPC

main
Cameron Murphy Reikes 2 years ago
parent 113753dcab
commit 78fb1bc1b4

@ -127,7 +127,7 @@ typedef BUFF(char, MAX_SENTENCE_LENGTH) Sentence;
// even indexed dialogs (0,2,4) are player saying stuff, odds are the character from GPT // even indexed dialogs (0,2,4) are player saying stuff, odds are the character from GPT
typedef BUFF(Sentence, 2*6) Dialog; // six back and forths. must be even number or bad things happen (I think) typedef BUFF(Sentence, 2*12) Dialog; // six back and forths. must be even number or bad things happen (I think)
typedef enum NpcKind typedef enum NpcKind
{ {
@ -151,11 +151,15 @@ typedef struct Entity
bool is_npc; bool is_npc;
NpcKind npc_kind; NpcKind npc_kind;
Dialog player_dialog; Dialog player_dialog;
Sentence to_say;
#ifdef WEB #ifdef WEB
int gen_request_id; int gen_request_id;
#endif #endif
bool aggressive; bool aggressive;
double shotgun_timer; double shotgun_timer;
// only for death npc
bool going_to_target;
Vec2 target_goto;
// character // character
bool is_character; bool is_character;
@ -206,6 +210,8 @@ typedef struct Arena
Entity *player = NULL; // up here, used in text backend callback Entity *player = NULL; // up here, used in text backend callback
void make_space_and_append(Dialog *d, Sentence *s) void make_space_and_append(Dialog *d, Sentence *s)
{ {
if(d->cur_index >= ARRLEN(d->data)) if(d->cur_index >= ARRLEN(d->data))
@ -237,10 +243,15 @@ void add_new_npc_sentence(Entity *npc, char *sentence)
{ {
if(sentence[i] == '*') if(sentence[i] == '*')
{ {
if(strcmp(match_buffer.data, "fights player") == 0) if(strcmp(match_buffer.data, "fights player") == 0 && npc->npc_kind == OLD_MAN)
{ {
npc->aggressive = true; npc->aggressive = true;
} }
if(strcmp(match_buffer.data, "moves") == 0 && npc->npc_kind == DEATH)
{
npc->going_to_target = true;
npc->target_goto = AddV2(npc->pos, V2(0.0, -TILE_SIZE*1.5f));
}
BUFF_CLEAR(&match_buffer); BUFF_CLEAR(&match_buffer);
inside_star = false; inside_star = false;
} }
@ -261,6 +272,18 @@ void add_new_npc_sentence(Entity *npc, char *sentence)
} }
// from_point is for knockback
void request_do_damage(Entity *to, Vec2 from_point, float damage)
{
if(to == NULL) return;
if(to->npc_kind != DEATH)
{
to->damage += damage;
to->aggressive = true;
to->vel = MulV2F(NormV2(SubV2(to->pos, from_point)), 5.0f);
}
}
// just straight up gpt generation function, calls to golang backend // just straight up gpt generation function, calls to golang backend
char *get_ai_response(char* prompt); char *get_ai_response(char* prompt);
@ -1570,6 +1593,8 @@ void draw_dialog_panel(Entity *talking_to)
dialog_panel.upper_left = AddV2(dialog_panel.upper_left, V2(padding, -padding)); dialog_panel.upper_left = AddV2(dialog_panel.upper_left, V2(padding, -padding));
dialog_panel.lower_right = AddV2(dialog_panel.lower_right, V2(-padding, padding)); dialog_panel.lower_right = AddV2(dialog_panel.lower_right, V2(-padding, padding));
if(aabb_is_valid(dialog_panel))
{
float new_line_height = dialog_panel.lower_right.Y; float new_line_height = dialog_panel.lower_right.Y;
int i = 0; int i = 0;
//BUFF_ITER(Sentence, &talking_to->player_dialog) //BUFF_ITER(Sentence, &talking_to->player_dialog)
@ -1619,6 +1644,7 @@ void draw_dialog_panel(Entity *talking_to)
dbgrect(dialog_panel); dbgrect(dialog_panel);
} }
}
} }
@ -1819,6 +1845,10 @@ void frame(void)
if(it->is_npc) if(it->is_npc)
{ {
if(it->npc_kind == DEATH && it->going_to_target)
{
it->pos = LerpV2(it->pos, dt*5.0f, it->target_goto);
}
if(it->aggressive) if(it->aggressive)
{ {
draw_dialog_panel(it); draw_dialog_panel(it);
@ -1875,13 +1905,10 @@ void frame(void)
Entity *from_bullet = it; Entity *from_bullet = it;
BUFF_ITER(Overlap, &over) if(it->e != from_bullet) BUFF_ITER(Overlap, &over) if(it->e != from_bullet)
{ {
if(!it->is_tile) if(!it->is_tile && !(it->e->npc_kind == DEATH))
{ {
// knockback and damage // knockback and damage
Entity *hit = it->e; request_do_damage(it->e, from_bullet->pos, 0.2f);
if(hit->is_npc) hit->aggressive = true;
hit->vel = MulV2F(NormV2(SubV2(hit->pos, from_bullet->pos)), 5.0f);
hit->damage += 0.2f;
*from_bullet = (Entity){0}; *from_bullet = (Entity){0};
} }
} }
@ -1997,14 +2024,9 @@ void frame(void)
Overlapping overlapping_weapon = get_overlapping(cur_level, weapon_aabb); Overlapping overlapping_weapon = get_overlapping(cur_level, weapon_aabb);
BUFF_ITER(Overlap, &overlapping_weapon) BUFF_ITER(Overlap, &overlapping_weapon)
{ {
if(!it->is_tile) if(!it->is_tile && it->e != player)
{ {
Entity *e = it->e; request_do_damage(it->e, player->pos, 0.2f);
if(e->is_character)
{
e->aggressive = true;
e->damage += 0.2f;
}
} }
} }

@ -28,7 +28,7 @@ func index(w http.ResponseWriter, req *http.Request) {
ctx := context.Background() ctx := context.Background()
req := gogpt.CompletionRequest{ req := gogpt.CompletionRequest{
Model: "curie:ft-personal-2023-03-03-20-15-12", Model: "curie:ft-personal-2023-03-03-21-31-16",
MaxTokens: 80, MaxTokens: 80,
Prompt: promptString, Prompt: promptString,
Temperature: 0.9, Temperature: 0.9,

Loading…
Cancel
Save