Nimbin[12]?Games / Entropie / entropie/src/people/talk.h

Entropie git · main

Entropie festival game; first steps

sdl c game entropie cmake · first commit 2026-10-10 · last commit 2026-11-02 (18 hours ago) · synced 10 hours ago

C 88.5% Markdown 9.1% GLSL 2.3%
git clone https://git.christianimmanuel.de/games/Entropie.gitwget https://git.christianimmanuel.de/games/Entropie/archive/Entropie.tar.gz
entropie/src/people/talk.h 2.7 KB · 55 lines raw
#ifndef PEOPLE_TALK_H
#define PEOPLE_TALK_H

/*
 * Conversations between the player and the others.
 *
 * Someone says a line (a speech bubble), the player picks an answer (keys
 * 1-4), they react. What they offer and ask depends on what they're doing
 * and what they know: somebody who never made firewood asks to be shown
 * how, somebody who doesn't know where the woodpile is asks where the
 * firewood should go and follows you there to be shown.
 *
 * Talks start when the player clicks on someone in front, or when someone
 * walks up to the player (see ai.h, topics). Asked to do a job, people may
 * say no: it depends on who they are, how they feel and whether it's needed.
 */

#include <stdbool.h>

#include "world/world.h"

#define TALK_CHOICES 5
#define TALK_PILE_AHEAD 1.3f  /* a new woodpile goes this far in front of the player */

/* The shopping list: asked of whoever has the car keys (talk.c), then the run (game/game_shop.c). */
#define SHOP_ITEMS 4
enum { SHOP_BOARDS, SHOP_FIXINGS, SHOP_PAINT, SHOP_FOOD };
static const int SHOP_PRICE[SHOP_ITEMS] = { 25, 20, 35, 90 }; /* € each: a bundle of 8 boards; a box of nails and one of screws; a bucket of paint; food and drink for the crew */
static const int SHOP_MAX[SHOP_ITEMS]   = { 8, 4, 4, 2 };

typedef struct {
    Object     *with;          /* NULL = no conversation */
    int         node;          /* where in the conversation (talk.c) */
    float       closing;       /* > 0: the last reply is showing, then it ends */
    char        player_line[AI_SPEECH_MAX];
    float       player_time;   /* the player's answer shows this long */
    float       waited;        /* seconds they've been waiting for an answer ... */
    bool        nudged;        /* ... and asked again once */
    int         shop[SHOP_ITEMS]; /* the shopping list being made (how many of each) ... */
    Object     *errand;        /* ... agreed: they're off with it (the game takes it from here and clears this) */
} Talk;

/* Starts talking with someone: what they say first depends on what they're
   doing (topic: what they came to talk about, or TOPIC_NONE). */
void Talk_begin(Talk *talk, World *world, Object *player, Object *with, Topic topic);
/* choice: 1..4 picked this frame, 0 none; leave: the player walked off or cancelled. */
void Talk_update(Talk *talk, World *world, Object *player, int choice, bool leave, float dt);
bool Talk_active(const Talk *talk);
/* Someone following the player to be shown where the firewood goes: "here",
   in front of the player. */
void Talk_showHere(World *world, Object *player, Object *npc);
/* The answers the player can give right now; returns how many. */
int  Talk_choices(const Talk *talk, const char *out[TALK_CHOICES]);

#endif /* PEOPLE_TALK_H */