Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Among Us: bots remember who was with the dead, the intro and end in the game's colours

Mason36314ea7670a9f4
diff --git a/games/amongus/src/bot.c b/games/amongus/src/bot.c
index f53fb3c6..8f4fd862 100644
--- a/games/amongus/src/bot.c
+++ b/games/amongus/src/bot.c
@@ -209,6 +209,13 @@ void bot_see(int i) {
if (seen) {
B->seen_t[j] = g.t;
B->seen_room[j] = Q->room;
+ /* and who was with them */
+ int with = NONE;
+ float wd = 2.2f * 2.2f;
+ for (int k = 0; k < g.nplayers; k++)
+ if (k != j && k != i && g.p[k].alive && g.p[k].vent == NONE && dist2(g.p[k].pos, Q->pos) < wd && can_see(i, k))
+ wd = dist2(g.p[k].pos, Q->pos), with = k;
+ B->seen_with[j] = (uint8_t)with;
B->with_t[j] += 0.2f;
if (B->with_t[j] > 60) B->with_t[j] = 60;
/* a visual task proves a crewmate */
@@ -558,6 +565,7 @@ static void impostor_tick(int i) {
void bot_init(int i) {
Bot *B = &g.p[i].bot;
memset(B, 0, sizeof *B);
+ memset(B->seen_with, NONE, sizeof B->seen_with);
B->state = B_WAIT;
B->t = 0.5f + rnd_f() * 1.5f;
B->saw_kill = B->saw_vent = B->near_body = B->found_body = NONE;
@@ -727,7 +735,7 @@ void bot_tick(int i) {
enum {
L_BODY_IN, L_NEAR_BODY, L_SAW_KILL, L_SAW_VENT, L_WAS_IN, L_WITH, L_SUS, L_WHO, L_WHERE, L_SKIP, L_NOT_ME,
- L_SCANNED, L_BUTTON
+ L_SCANNED, L_BUTTON, L_SAW_WITH
};
static void say(int who, int kind, int a, int b) {
@@ -825,6 +833,14 @@ void bot_meeting_start(void) {
queue(i, L_SAW_VENT, B->saw_vent, B->saw_vent_room, at);
continue;
}
+ /* the one last seen with the dead */
+ int v = g.reported;
+ if (!g.p[i].imp && v != NONE && B->seen_with[v] != NONE && B->seen_with[v] != i && g.p[B->seen_with[v]].alive &&
+ g.t - B->seen_t[v] < 40) {
+ suspect(B, B->seen_with[v], 25);
+ queue(i, L_SAW_WITH, B->seen_with[v], B->seen_room[v], at);
+ continue;
+ }
int r = rnd_n(10);
if (!g.p[i].imp && B->scanned != NONE && g.p[B->scanned].alive && r < 3) {
queue(i, L_SCANNED, B->scanned, 0, at);
@@ -854,7 +870,7 @@ void bot_meeting_tick(void) {
if (g.p[who].alive) say(who, queue_kind[qnext], queue_a[qnext], queue_b[qnext]);
/* what's said moves the listeners: an accusation weighs by how much the speaker is trusted */
int k = queue_kind[qnext], a = queue_a[qnext];
- if (k == L_SAW_KILL || k == L_SAW_VENT || k == L_SUS || k == L_NEAR_BODY) {
+ if (k == L_SAW_KILL || k == L_SAW_VENT || k == L_SUS || k == L_NEAR_BODY || k == L_SAW_WITH) {
for (int i = 0; i < g.nplayers; i++) {
if (i == who || !is_bot(i) || !g.p[i].alive || g.p[i].imp) continue;
Bot *B = &g.p[i].bot;
@@ -863,7 +879,7 @@ void bot_meeting_tick(void) {
continue;
}
int trust = B->sus[who] < -30 ? 2 : B->sus[who] > 40 ? 0 : 1;
- int w = (k == L_SAW_KILL ? 45 : k == L_SAW_VENT ? 40 : k == L_NEAR_BODY ? 20 : 12) * trust;
+ int w = (k == L_SAW_KILL ? 45 : k == L_SAW_VENT ? 40 : k == L_NEAR_BODY || k == L_SAW_WITH ? 20 : 12) * trust;
suspect(B, a, w);
}
}
diff --git a/games/amongus/src/game.h b/games/amongus/src/game.h
index 1cb85c93..40d00607 100644
--- a/games/amongus/src/game.h
+++ b/games/amongus/src/game.h
@@ -49,6 +49,7 @@ typedef struct {
uint8_t near_body, body_room, found_body, said; /* who it saw near the body it found */
uint8_t claim_room, with, scanned, pad2; /* its alibi */
float with_t[MAXP]; /* time spent with each player lately */
+ uint8_t seen_with[MAXP]; /* who was next to each player when last seen (NONE: alone) */
} Bot;
typedef struct {
diff --git a/games/amongus/src/meeting.c b/games/amongus/src/meeting.c
index e023a351..f1251e35 100644
--- a/games/amongus/src/meeting.c
+++ b/games/amongus/src/meeting.c
@@ -17,7 +17,7 @@ void art_confirm(int x, int y, bool yes);
enum {
L_BODY_IN, L_NEAR_BODY, L_SAW_KILL, L_SAW_VENT, L_WAS_IN, L_WITH, L_SUS, L_WHO, L_WHERE, L_SKIP, L_NOT_ME,
- L_SCANNED, L_BUTTON
+ L_SCANNED, L_BUTTON, L_SAW_WITH
};
const char *line_text(const Line *l, char *b, int n) {
@@ -43,6 +43,10 @@ const char *line_text(const Line *l, char *b, int n) {
case L_NOT_ME: snprintf(b, (size_t)n, "Not me"); break;
case L_SCANNED: snprintf(b, (size_t)n, "%s scanned, they're safe", a); break;
case L_BUTTON: snprintf(b, (size_t)n, "I called it. Anyone sus?"); break;
+ case L_SAW_WITH:
+ if (l->b == R_HALLWAY || g.reported == NONE) snprintf(b, (size_t)n, "%s was with %s", a, COLOR_NAMES[g.p[g.reported < MAXP ? g.reported : 0].color]);
+ else snprintf(b, (size_t)n, "%s was with %s in %s", a, COLOR_NAMES[g.p[g.reported].color], r);
+ break;
default: b[0] = 0;
}
return b;
diff --git a/games/amongus/src/screens.c b/games/amongus/src/screens.c
index 7ebf91e5..4106d8e9 100644
--- a/games/amongus/src/screens.c
+++ b/games/amongus/src/screens.c
@@ -307,9 +307,16 @@ static void intro_draw(void) {
gfx_text(FONT_HUGE, 160, 52, "Crewmate", CREW_BLUE, 0x0000, 2, 1);
int k = 0;
for (int i = 0; i < g.nplayers; i++) k += g.p[i].imp;
- char b[48];
- snprintf(b, sizeof b, "There %s %d Impostor%s among us", k == 1 ? "is" : "are", k, k == 1 ? "" : "s");
- gfx_text(FONT_MID, 160, 74, b, WHITE, 0x0000, 1, 1);
+ /* "There is 1 Impostor among us", the Impostors in red */
+ char a[16], b[16];
+ const char *c = " among us";
+ snprintf(a, sizeof a, "There %s ", k == 1 ? "is" : "are");
+ snprintf(b, sizeof b, "%d Impostor%s", k, k == 1 ? "" : "s");
+ int wa = gfx_text_width(FONT_MID, a), wb = gfx_text_width(FONT_MID, b), wc = gfx_text_width(FONT_MID, c);
+ int x = 160 - (wa + wb + wc) / 2;
+ gfx_text(FONT_MID, x, 74, a, WHITE, 0x0000, 1, 0);
+ gfx_text(FONT_MID, x + wa, 74, b, IMP_RED, 0x0000, 1, 0);
+ gfx_text(FONT_MID, x + wa + wb, 74, c, WHITE, 0x0000, 1, 0);
}
}
@@ -322,7 +329,8 @@ static void end_draw(void) {
for (int i = 0; i < g.nplayers; i++)
if ((g.p[i].imp != 0) == (g.winner == 1)) who[n++] = (uint8_t)i;
art_lineup(who, n, g.screen_t);
- gfx_text(FONT_HUGE, 160, 52, won ? "Victory" : "Defeat", won ? CREW_BLUE : IMP_RED, 0x0000, 2, 1);
+ /* (Victory in the winners' colour: blue for the crew, red for the Impostors) */
+ gfx_text(FONT_HUGE, 160, 52, won ? "Victory" : "Defeat", won && g.winner == 0 ? CREW_BLUE : IMP_RED, 0x0000, 2, 1);
static const char *const WHY[2][4] = {{"Crewmates voted out the Impostors", "", "Crewmates finished their tasks", ""},
{"", "Impostors killed the crew", "", "Impostors sabotaged the ship"}};
const char *why = WHY[g.winner & 1][g.end_reason & 3];