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: lifeblood cocoons grow back after a rest, as in the game

Mason363e34619869914
diff --git a/games/hollowknight/src/data.h b/games/hollowknight/src/data.h
index 98d6b7ac..f9c6c114 100644
--- a/games/hollowknight/src/data.h
+++ b/games/hollowknight/src/data.h
@@ -1308,4 +1308,4 @@
#define ROOM_ZONES {2, 4, 5, 4, 4, 5, 5, 5, 5, 5, 5, 5, 22, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6}
#define MSG_FIREBALL 0
#define MSG_DASH 1
-#define SEMI_PERSIST {259, 260, 261, 272, 273, 274}
+#define SEMI_PERSIST {3, 59, 198, 259, 260, 261, 272, 273, 274}
diff --git a/games/hollowknight/src/game.h b/games/hollowknight/src/game.h
index 00c828c2..3e87bbe9 100644
--- a/games/hollowknight/src/game.h
+++ b/games/hollowknight/src/game.h
@@ -178,6 +178,7 @@ void persist_clear(int bit);
void obj_enter(void);
void obj_tick(void);
void obj_draw(void);
+void obj_keep_cocoons(void);
void obj_swing_start(void); /* a slash's hit shape on: what it hits, once */
int obj_nail(const float *pts, int npts, float direction); /* -> HB_* of what it touches */
float rand_range(float lo, float hi); /* Random.Range (floats) */
diff --git a/games/hollowknight/src/npc.c b/games/hollowknight/src/npc.c
index af3ecb73..2f8d4347 100644
--- a/games/hollowknight/src/npc.c
+++ b/games/hollowknight/src/npc.c
@@ -275,6 +275,7 @@ bool bench_respawn(const char *name) {
hero_gravity(false);
hero_max_health();
pd_set_flag(PDF_AT_BENCH, true);
+ persist_reset_semi(); /* (Init Resting: ResetSemiPersistentItems) */
anim_play(&h->anim, CLIP_KNIGHT_SIT_FALL_ASLEEP);
h->body.vx = h->body.vy = 0;
b->sleeping = false, b->get_off_wake = false; /* (sleeping: here, once moved up) */
diff --git a/games/hollowknight/src/obj.c b/games/hollowknight/src/obj.c
index de69f89a..a6df6f0f 100644
--- a/games/hollowknight/src/obj.c
+++ b/games/hollowknight/src/obj.c
@@ -704,6 +704,13 @@ static void cocoon_tick(Obj *o, const Ent *e) {
}
}
+/* (ResetSemiPersistentItems: a cocoon broken in the room the Knight is in saves its own state again with the room's
+ * save, so it stays broken) */
+void obj_keep_cocoons(void) {
+ for (int k = 0; k < nobjs; k++)
+ if (objs[k].kind == OK_COCOON && objs[k].state == CO_BROKEN) persist_set(ent_at(objs[k].ent)->persist);
+}
+
static void cocoon_draw(const Obj *o, const Ent *e) {
Inst in;
const Ent *sp = cocoon_splat(e);
diff --git a/games/hollowknight/src/world.c b/games/hollowknight/src/world.c
index 32ba1c5a..0310e56d 100644
--- a/games/hollowknight/src/world.c
+++ b/games/hollowknight/src/world.c
@@ -52,6 +52,7 @@ bool persist_get(int i) { return i != NO_PERSIST && (g_pd.persist[i >> 3] >> (i
void persist_reset_semi(void) {
static const uint16_t semi[] = SEMI_PERSIST;
for (unsigned k = 0; k < sizeof semi / sizeof semi[0]; k++) persist_clear(semi[k]);
+ obj_keep_cocoons();
vm_reset_semi();
}
diff --git a/games/hollowknight/tools/ents.py b/games/hollowknight/tools/ents.py
index a9f80bcc..69469569 100644
--- a/games/hollowknight/tools/ents.py
+++ b/games/hollowknight/tools/ents.py
@@ -999,10 +999,12 @@ def room(d, rooms, strings, persist, name, sprites=None, owners=None, rec_base=0
lib = _ref_file(d, ean["library"])
eclip = CLIP_INDEX.get(actors.clip_id("fx", unity.S(tk2d.animation(*lib)["clips"][ean["defaultClipId"]]["name"])), -1)
layer, order = _sorting(splat) if splat else (0, 0)
- persistent = any(c.get("class") == "PersistentBoolItem" for c in o["c"])
+ pbi = next((c.get("v") or {} for c in o["c"] if c.get("class") == "PersistentBoolItem"), None)
+ # (semi persistent: whole again once the Knight rests at a bench or dies, unless in its room then)
recs.append(rec(ENT_OBJ, OK_COCOON, (o["pos"][0], o["pos"][1], o["pos"][2], 0),
(hc.get("waitMin", 2), hc.get("waitMax", 6), 0, 0), a=c0, group=cn, group2=g_hide,
- persist=persist.id(name, o["path"]) if persistent else NO_PERSIST, s0=len(pieces), s1=len(hits)))
+ persist=persist.id(name, o["path"], semi=bool(pbi.get("semiPersistent"))) if pbi is not None
+ else NO_PERSIST, s0=len(pieces), s1=len(hits)))
recs += [rec(ENT_BOX, fl, box=b) for b, fl in hits]
recs += pieces
recs.append(rec(ENT_BOX, 0, (splat["lpos"][0] if splat else 0, splat["lpos"][1] if splat else 0,