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
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
{
@ -151,11 +151,15 @@ typedef struct Entity
bool is_npc;
NpcKind npc_kind;
Dialog player_dialog;
Sentence to_say;
#ifdef WEB
int gen_request_id;
#endif
bool aggressive;
double shotgun_timer;
// only for death npc
bool going_to_target;
Vec2 target_goto;
// character
bool is_character;
@ -206,6 +210,8 @@ typedef struct Arena
Entity *player = NULL; // up here, used in text backend callback
void make_space_and_append(Dialog *d, Sentence *s)
{
if(d->cur_index >= ARRLEN(d->data))
@ -237,10 +243,15 @@ void add_new_npc_sentence(Entity *npc, char *sentence)
{
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;
}
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);
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
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.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;
int i = 0;
//BUFF_ITER(Sentence, &talking_to->player_dialog)
@ -1619,6 +1644,7 @@ void draw_dialog_panel(Entity *talking_to)
dbgrect(dialog_panel);
}
}
}
@ -1819,6 +1845,10 @@ void frame(void)
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)
{
draw_dialog_panel(it);
@ -1875,13 +1905,10 @@ void frame(void)
Entity *from_bullet = it;
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
Entity *hit = it->e;
if(hit->is_npc) hit->aggressive = true;
hit->vel = MulV2F(NormV2(SubV2(hit->pos, from_bullet->pos)), 5.0f);
hit->damage += 0.2f;
request_do_damage(it->e, from_bullet->pos, 0.2f);
*from_bullet = (Entity){0};
}
}
@ -1997,14 +2024,9 @@ void frame(void)
Overlapping overlapping_weapon = get_overlapping(cur_level, weapon_aabb);
BUFF_ITER(Overlap, &overlapping_weapon)
{
if(!it->is_tile)
if(!it->is_tile && it->e != player)
{
Entity *e = it->e;
if(e->is_character)
{
e->aggressive = true;
e->damage += 0.2f;
}
request_do_damage(it->e, player->pos, 0.2f);
}
}

@ -28,7 +28,7 @@ func index(w http.ResponseWriter, req *http.Request) {
ctx := context.Background()
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,
Prompt: promptString,
Temperature: 0.9,

Loading…
Cancel
Save