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.

Hollow Knight: say where charms are changed, and keep them on Home (#138)

Mason3632f7ad57058c7
diff --git a/docs/play.md b/docs/play.md
index 1673ab5b..67a1d2a9 100644
--- a/docs/play.md
+++ b/docs/play.md
@@ -95,7 +95,7 @@ Hollow Knight comes as its own app, `HollowKnight.nwa`: it is too big to share t
| **⌫** | Pause |
| **Home** | Save and quit |
-Choose Start Game, then a save. Rest at benches to save and to change charms. In menus, **OK** or **EXE** confirms and **Back** goes back. In the inventory, left and right at the edges change pages; on the map page, **OK** places markers once you have them, and **shift** shows or hides the key and the pins. Home saves and quits, as Quit to Menu does. Your saves are also copied into `hollowknight_saves.py`, so installing the app again doesn't erase them.
+Choose Start Game, then a save. Rest at benches to save and to change charms: **toolbox**, right to Charms, then **OK** on a charm. In menus, **OK** or **EXE** confirms and **Back** goes back. In the inventory, left and right at the edges change pages; on the map page, **OK** places markers once you have them, and **shift** shows or hides the key and the pins. Home saves and quits, as Quit to Menu does. Your saves are also copied into `hollowknight_saves.py`, so installing the app again doesn't erase them.
<br clear="right">
diff --git a/games/hollowknight/README.md b/games/hollowknight/README.md
index bb32dd9b..d2b4b4ff 100644
--- a/games/hollowknight/README.md
+++ b/games/hollowknight/README.md
@@ -48,7 +48,7 @@
Choose Start Game, then a save. A new game first shows how to play: which key does what, then the basics. You can see them again with How to Play, on the title screen and in the pause menu. Then the Knight falls into King's Pass. Walk on to Dirtmouth and down the well into the Forgotten Crossroads.
-Hit enemies with the nail to fill your soul, then hold the spell key to focus it into health. Rest at benches to save and to change charms. When you die you lose your geo and leave a shade behind: defeat it to get them back.
+Hit enemies with the nail to fill your soul, then hold the spell key to focus it into health. Rest at benches to save and to change charms: Toolbox, right to Charms, then OK on a charm. When you die you lose your geo and leave a shade behind: defeat it to get them back.
⌫ pauses: from there you can go on or quit to the title screen, which saves.
diff --git a/games/hollowknight/src/data.bin b/games/hollowknight/src/data.bin
index f8a4e9fa..53a2deb0 100644
Binary files a/games/hollowknight/src/data.bin and b/games/hollowknight/src/data.bin differ
diff --git a/games/hollowknight/src/data.h b/games/hollowknight/src/data.h
index 2f9b972a..8a305d57 100644
--- a/games/hollowknight/src/data.h
+++ b/games/hollowknight/src/data.h
@@ -1137,6 +1137,7 @@
#define TXT_CHARM_NAMES_INV {-1, 260, 261, 262, 263, -1, 264, 265, 266, -1, -1, -1, -1, -1, 267, -1, -1, -1, 268, 269, 270, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
#define TXT_CHARM_DESCS {-1, 271, 272, 273, 274, -1, 275, 276, 277, -1, -1, -1, -1, -1, 278, -1, -1, -1, 279, 280, 281, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
#define TXT_KEY_OK 282
+#define TXT_CHARM_BENCH 439
#define INV_FIXED {{2935, -7.1600f, -3.8300f, 1.0000f, 1.0000f}, {2936, -3.2500f, -4.2100f, 1.0000f, 1.0000f}, {2937, -7.2900f, -9.4400f, 1.0000f, 1.0000f}, {2938, -4.7200f, -6.2100f, 1.0000f, 1.0000f}, {2939, -3.2700f, -7.4600f, 1.0000f, 1.0000f}, {2940, -5.7200f, -13.3200f, 1.0000f, 1.0000f}}
#define INV_FIXED_BG {{-1, 0, 0, 0, 0}, {-1, 0, 0, 0, 0}, {-1, 0, 0, 0, 0}, {2941, -4.6374f, -6.2413f, 1.0000f, 1.0000f}, {2942, -3.2774f, -7.4713f, 1.0000f, 1.0000f}, {-1, 0, 0, 0, 0}}
#define INV_FIXED_BOX {{1.9363f, 2.9287f, -0.0651f, 0.0923f}, {1.4420f, 1.4140f, -0.0546f, 0.0682f}, {1.6244f, 5.3245f, 0.0126f, 0.1884f}, {1.7500f, 1.7500f, 0.0000f, 0.0000f}, {1.8505f, 1.8756f, -0.0503f, 0.0629f}, {7.8215f, 1.4409f, 1.7816f, -0.0205f}}
diff --git a/games/hollowknight/src/game.h b/games/hollowknight/src/game.h
index 572e8a8f..952f9c68 100644
--- a/games/hollowknight/src/game.h
+++ b/games/hollowknight/src/game.h
@@ -469,6 +469,7 @@ void inv_reset(void);
uint32_t inv_tick(uint32_t keys); /* -> the keys the game has (none while it is open) */
void inv_damage(void); /* (HERO DAMAGED: it closes) */
bool inv_open(void);
+bool inv_settle(void); /* (Home: a charm on its way put in place) -> whether a save may be made */
float inv_behind(void); /* (what of the world behind it shows: 1 closed) */
void inv_open_map(void); /* (OPEN INVENTORY MAP: the map tapped twice) */
void inv_cursor_arrow(int which); /* (the map pane's: on the left arrow -1, the right -2; else not shown) */
diff --git a/games/hollowknight/src/inv.c b/games/hollowknight/src/inv.c
index edd40fc1..a8e3c779 100644
--- a/games/hollowknight/src/inv.c
+++ b/games/hollowknight/src/inv.c
@@ -54,7 +54,8 @@ static const uint8_t notch_full_rgb[3] = CH_NOTCH_FULL_RGB, notch_over_rgb[3] =
#define EQ_Y (-3.86f)
#define EQ_SCALE 1.15f
#define DETAIL_SCALE 1.5f
-/* (a description's bottom, from the panes' top: over the border; over the Equip key at a bench; under the cost) */
+/* (a description's bottom, from the panes' top: over the border; for a charm, over Equip and its key at a bench, or
+ * where charms are changed away from one; under the cost) */
#define DESC_BOTTOM (-13.7f)
#define DESC_BOTTOM_BENCH (-12.35f)
#define CH_DESC_GAP 0.3f
@@ -393,7 +394,7 @@ static void tween_done(void) {
/* Check Points */
g_pd.charm_slots_filled = (uint8_t)(g_pd.charm_slots_filled + costs[id]);
if (g_pd.charm_slots_filled > g_pd.charm_slots) {
- /* Overcharm Check: the sixth try breaks through (canOvercharm after) */
+ /* Overcharm Check: the fifth try breaks through (canOvercharm after) */
if (!pd_flag(PDF_CAN_OVERCHARM) && ++iv.oc_attempts < 5) {
iv.tween = TW_FAIL, iv.tw_t = 0; /* (Fail: 0.5 s shaking, then back) */
return;
@@ -426,6 +427,13 @@ static void tween_done(void) {
charms_cursor();
}
+/* (Home as it is open: a charm on its way put in its place) -> whether the game may be saved, as with it closed */
+bool inv_settle(void) {
+ if (iv.st != IV_OPEN) return false;
+ while (iv.tween != TW_NONE) tween_done();
+ return true;
+}
+
static void charms_move(uint32_t p) {
if (iv.tween != TW_NONE) return;
int eq_items = equipped_count() + (g_pd.charm_slots_filled < g_pd.charm_slots);
@@ -716,7 +724,7 @@ static void charms_draw(float ox, float oy, float a, uint8_t white) {
/* (its picture under its cost where its description still fits under that, in the message's size or the smaller;
* else the description up in the picture's place) */
float down = name_below(ch_name.top, ch_cost_text.top); /* (all under the name lower by as much as it is bigger) */
- float bottom = detail && pd_flag(PDF_AT_BENCH) ? DESC_BOTTOM_BENCH : DESC_BOTTOM, top = ch_desc.top - down;
+ float bottom = detail ? DESC_BOTTOM_BENCH : DESC_BOTTOM, top = ch_desc.top - down;
int style = text_box(desc, STYLE_MSG, 0, 0, ch_desc.w, 0, 0) <= top - bottom ? STYLE_MSG : STYLE_MSG_S;
bool picture = !detail || text_box(desc, style, 0, 0, ch_desc.w, 0, 0) <= top - bottom;
if (!picture) {
@@ -745,6 +753,9 @@ static void charms_draw(float ox, float oy, float a, uint8_t white) {
gfx_text(STYLE_MSG_S, VIEW_W / 2 + cx * HUD_PX - w / 2,
VIEW_H / 2 - (oy + ch_key.y) * HUD_PX + (font_asc(st) - font_desc(st)) / 2, text_get(TXT_KEY_OK), 2,
(uint32_t)(a * 255 + 0.5f) << 24 | 0xFFFFFF, 0);
+ } else if (detail) {
+ /* (away from a bench, in their place: where charms are changed) */
+ ui_text_at(TXT_CHARM_BENCH, STYLE_MSG_S, &ch_confirm, ox, oy, 2, a);
}
if (iv.cursor_set) cursor_draw(ox, oy, white);
}
diff --git a/games/hollowknight/src/main.c b/games/hollowknight/src/main.c
index 59f332c8..97d55bc1 100644
--- a/games/hollowknight/src/main.c
+++ b/games/hollowknight/src/main.c
@@ -117,8 +117,8 @@ static int run(void) {
for (;;) {
uint32_t keys = plat_keys();
if (keys & K_HOME) {
- /* (as Quit to Menu: saved, when the pause menu could be opened) */
- if (menu_in_game() && !g_pd.disable_pause && !game_changing_room()) save_game();
+ /* (as Quit to Menu: saved, when the pause menu could be opened, or in the inventory: charms just changed kept) */
+ if (menu_in_game() && (!g_pd.disable_pause || inv_settle()) && !game_changing_room()) save_game();
break;
}
if (menu_quit()) break;
diff --git a/games/hollowknight/tests/check.py b/games/hollowknight/tests/check.py
index ed394bd5..4fe72e7f 100644
--- a/games/hollowknight/tests/check.py
+++ b/games/hollowknight/tests/check.py
@@ -12,6 +12,8 @@
- a long walk of made up keys from every room: the Knight never out of the room, without control, wedged, undrawn or
out of the view, and the view never jumping
- a bench: sat on, the inventory opened, a charm equipped, then up again (atBench off)
+- the charms: OK changes none away from a bench; at one, equipped (its effect on), none past the notches, unequipped,
+ overcharmed on the fifth try and off again, kept by Home in the inventory and a load
- every room played with its enemies hit, in a new game and after the bosses, drawn whole and fast (as a slow
calculator draws it): the sanitizers stop on any fault
"""
@@ -68,6 +70,9 @@ def main():
pd = pd[:next((i for i, t in enumerate(pd) if not t.isdigit()), len(pd))]
bench = "77" in pd and "0" not in pd
results.append(report("bench: a charm equipped", rc, out if bench else out + "\nFAIL bools on: " + " ".join(pd), ("FAIL",)))
+ with tempfile.TemporaryDirectory() as saves:
+ rc, out = play("--gates", "charms", env={"HKSAVES": saves})
+ results.append(report("charms: changed at a bench only", rc, out, ("FAIL",)))
with ThreadPoolExecutor(JOBS) as pool:
walks = list(pool.map(lambda w: play("--gates", "wander:all:%d:%d" % w, env={"HKFAST": "1"} if w[0] % 2 else None), WALKS))
for (seed, ticks), (rc, out) in zip(WALKS, walks):
diff --git a/games/hollowknight/tests/play.c b/games/hollowknight/tests/play.c
index 2be26c93..bd073cdc 100644
--- a/games/hollowknight/tests/play.c
+++ b/games/hollowknight/tests/play.c
@@ -250,6 +250,82 @@ static int arenas_test(void) {
return fails || !total ? 1 : 0;
}
+/* the charms (issue #138): OK changes nothing away from a bench. Resting at one: a charm equipped (its effect on:
+ * Lifeblood Heart's lifeblood), none past the notches, one unequipped, one overcharmed on the fifth try and taken off
+ * again; Home as one moves (inv_settle) saves it in its place, and a load brings them back */
+static int charm_fails;
+static void charm_check(bool ok, const char *what) {
+ printf("%s charms: %s (equipped %d %d %d, notches %d of %d)\n", ok ? "ok " : "FAIL", what, g_pd.equipped[0],
+ g_pd.equipped[1], g_pd.equipped[2], g_pd.charm_slots_filled, g_pd.charm_slots);
+ charm_fails += !ok;
+}
+/* (keys as --play has them, without drawing: L R U D, O OK, I the inventory) */
+static void charm_keys(const char *keys) {
+ for (const char *p = keys; *p; p++) {
+ uint32_t k = *p == 'L' ? K_LEFT : *p == 'R' ? K_RIGHT : *p == 'U' ? K_UP : *p == 'D' ? K_DOWN : *p == 'O' ? K_OK | K_JUMP
+ : *p == 'I' ? K_INV : 0;
+ run_ticks(2, k);
+ run_ticks(*p == 'O' ? 60 : *p == 'I' ? 40 : 12, 0); /* (a charm's move, a failed one there and back; the panes) */
+ }
+}
+static int charms_test(void) {
+ if (getenv("HKSAVES")) {
+ extern void host_save_dir(const char *d);
+ host_save_dir(getenv("HKSAVES"));
+ }
+ /* (Gathering Swarm 1, Wayward Compass 2, Quick Focus 7, Lifeblood Heart 8: in the collection's second, first,
+ * 26th and 28th places; the inventory opening on its Charms pane, the cursor on the second place) */
+ game_new();
+ pd_set_flag(PDF_HAS_CHARM, true);
+ static const int got[] = {1, 2, 7, 8};
+ for (int i = 0; i < 4; i++) pd_set_flag(PDF_GOT_CHARM_1 + got[i] - 1, true);
+ g_pd.current_inv_pane = 1;
+ save_select(0);
+ game_enter(ROOM_TOWN, 120, 12, true);
+ run_ticks(60, 0);
+ charm_keys("IO");
+ charm_check(inv_open() && !charm_on(1) && !g_pd.charm_slots_filled, "away from a bench, OK equips nothing");
+ charm_keys("I");
+ /* (Dirtmouth's bench: sat on) */
+ game_enter(ROOM_TOWN, 132.4f, 12, true);
+ run_ticks(60, 0);
+ run_ticks(3, K_UP);
+ run_ticks(150, 0);
+ charm_check(pd_flag(PDF_AT_BENCH), "resting at the bench");
+ charm_keys("IO");
+ charm_check(charm_on(1) && g_pd.charm_slots_filled == 1 && g_pd.equipped[0] == 1, "Gathering Swarm equipped");
+ charm_keys("DDRRRRRRO");
+ charm_check(charm_on(8) && g_pd.charm_slots_filled == 3 && g_pd.health_blue == 2, "Lifeblood Heart equipped, its lifeblood on");
+ charm_keys("UULLLLLLLO");
+ charm_check(!charm_on(2) && g_pd.charm_slots_filled == 3, "no notch left: Wayward Compass not equipped");
+ charm_keys("RO");
+ charm_check(!charm_on(1) && g_pd.charm_slots_filled == 2 && g_pd.equipped[0] == 8 && !g_pd.equipped[1],
+ "Gathering Swarm unequipped");
+ charm_keys("DDRRRRO");
+ charm_keys("OOO");
+ charm_check(!charm_on(7) && g_pd.charm_slots_filled == 2 && !pd_flag(PDF_OVERCHARMED), "Quick Focus refused four times");
+ charm_keys("O");
+ charm_check(charm_on(7) && g_pd.charm_slots_filled == 5 && pd_flag(PDF_OVERCHARMED) && pd_flag(PDF_CAN_OVERCHARM),
+ "the fifth try overcharms");
+ charm_keys("O");
+ charm_check(!charm_on(7) && g_pd.charm_slots_filled == 2 && !pd_flag(PDF_OVERCHARMED), "Quick Focus off, overcharming over");
+ /* (Home as Gathering Swarm moves up: put in its place, then saved; a new game; the save loaded) */
+ charm_keys("UULLLL");
+ run_ticks(2, K_OK);
+ run_ticks(3, 0);
+ bool settled = g_pd.disable_pause && inv_settle();
+ charm_check(settled && charm_on(1) && g_pd.charm_slots_filled == 3, "Home in the inventory: Gathering Swarm in place");
+ charm_check(save_game(), "saved");
+ game_new();
+ charm_check(save_load(0) && game_respawn(), "loaded");
+ run_ticks(10, 0);
+ charm_check(charm_on(1) && charm_on(8) && !charm_on(7) && g_pd.charm_slots_filled == 3 && g_pd.equipped[0] == 8 &&
+ g_pd.equipped[1] == 1 && g_pd.health_blue == 2 && pd_flag(PDF_AT_BENCH),
+ "loaded at the bench with Lifeblood Heart and Gathering Swarm on");
+ printf("charms: %d failing\n", charm_fails);
+ return charm_fails ? 1 : 0;
+}
+
/* the ground's seams, as the calculator rounds: from many places in every room the Knight lands on the ground, then is
* put a few float steps lower (as near as rounding leaves him), and must walk both ways where no wall stops him; and
* jumping at a wall, put a few steps nearer it, he must fall back down, not hang on it */
@@ -506,6 +582,7 @@ static int gates_test(const char *which) {
if (!strcmp(which, "seams")) return seams_test();
if (!strcmp(which, "markers")) return markers_test();
if (!strcmp(which, "arenas")) return arenas_test();
+ if (!strcmp(which, "charms")) return charms_test();
if (!strncmp(which, "wander:", 7)) { /* (wander:ROOM|all:seed:ticks) */
char room[64];
int seed = 1, ticks = 6000;
diff --git a/games/hollowknight/tools/inv.py b/games/hollowknight/tools/inv.py
index 869c7aa3..80a823e8 100644
--- a/games/hollowknight/tools/inv.py
+++ b/games/hollowknight/tools/inv.py
@@ -188,6 +188,8 @@ def build(sprites, texts, res, charms, charm_icon):
out["TXT_CHARM_DESCS"] = "{%s}" % ", ".join(
str(txt("UI", "CHARM_DESC_%d" % i, "MSG")) if i in charms else "-1" for i in range(41))
out["TXT_KEY_OK"] = texts.add("OK", "MSG")
+ # (away from a bench, where Equip and its key would be)
+ out["TXT_CHARM_BENCH"] = texts.add("Rest at a bench", "MSG")
# ---------------------------------------------------------------- the Inventory pane
ip = by[ROOT + "Inv"]
diff --git a/games/hollowknight/tools/menu.py b/games/hollowknight/tools/menu.py
index adb2be19..6a039a55 100644
--- a/games/hollowknight/tools/menu.py
+++ b/games/hollowknight/tools/menu.py
@@ -211,7 +211,7 @@ def build(sprites, texts):
out["TXT_NEXT"] = texts.add("Next", "MENU")
out["TXT_HELP_LINES"] = texts.add("Strike enemies with your nail to gather Soul.\n"
"Hold alpha to focus Soul and heal your masks.\n"
- "Rest at a bench to heal and to save your game.\n"
+ "Rest at a bench to heal, save and change charms.\n"
"If you fall, your shade keeps your geo:\n"
"strike it down to win them back.\n"
"Spend geo in Dirtmouth's shops, and find\n"