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.

Celeste: a death on the Summit goes back to the last checkpoint touched

Mason Chence121a537db2
diff --git a/games/celeste/src/entities.c b/games/celeste/src/entities.c
index 9b0eeb6b..9b54c77b 100644
--- a/games/celeste/src/entities.c
+++ b/games/celeste/src/entities.c
@@ -1433,11 +1433,8 @@ bool ent_create(const EData *d) {
if (ents_ch0(d) || ents_ch1(d) || ents_ch2(d) || ents_ch3(d) || ents_ch4(d) || ents_ch5(d) || ents_ch6(d) ||
ents_ch7(d) || ents_ch8(d) || ents_ch9(d))
return true;
- int slot = g_level.room_slot;
switch (d->type) {
- case ET_player:
- if (nspawns[slot] < MAX_SPAWNS) spawns[slot][nspawns[slot]++] = v2(d->x, d->y);
- return true;
+ case ET_player: return true; /* a spawn point: entities_load has it */
case ET_jumpThru: new_jumpthru(d); return true;
case ET_decalSolid: new_dsolid(d); return true;
case ET_spikesUp: new_spikes(d, DIR_UP); return true;
@@ -1533,8 +1530,11 @@ void entities_load(Room *rm, const uint8_t *blob, int slot) {
EData d;
d.room = rm->index;
d.rx = (float)rm->x, d.ry = (float)rm->y;
- for (int pass = 0; pass < 2; pass++) {
- const uint8_t *p = blob + rd16(blob + 2 * (pass ? RB_TRIGS : RB_ENTS));
+ /* pass 0: the spawn points (LevelData.Spawns), all of them before an entity looks for the closest (a summit
+ checkpoint is often listed before its own: 7B's g-00 and g-02); 1: the entities; 2: the triggers */
+ for (int pass = 0; pass < 3; pass++) {
+ bool trig = pass == 2;
+ const uint8_t *p = blob + rd16(blob + 2 * (trig ? RB_TRIGS : RB_ENTS));
int n = rd16(p);
p += 2;
for (int i = 0; i < n; i++) {
@@ -1544,16 +1544,20 @@ void entities_load(Room *rm, const uint8_t *blob, int slot) {
d.x = rm->x + (float)rds16(p + 4);
d.y = rm->y + (float)rds16(p + 6);
d.attrs = p + 8;
- int size = pass ? trig_attr_size(d.type) : ent_attr_size(d.type);
+ int size = trig ? trig_attr_size(d.type) : ent_attr_size(d.type);
d.nodes = d.attrs + size;
- g_new_eid = (uint16_t)d.id;
- d.trig = pass;
- uint32_t id = level_entity_hash(&d);
- if (!level_do_not_load(id) && !leader_has_id(id)) { /* what follows the player is there already */
- if (pass) trig_create(&d);
- else ent_create(&d);
+ if (!pass) {
+ if (d.type == ET_player && nspawns[slot] < MAX_SPAWNS) spawns[slot][nspawns[slot]++] = v2(d.x, d.y);
+ } else {
+ g_new_eid = (uint16_t)d.id;
+ d.trig = trig;
+ uint32_t id = level_entity_hash(&d);
+ if (!level_do_not_load(id) && !leader_has_id(id)) { /* what follows the player is there already */
+ if (trig) trig_create(&d);
+ else ent_create(&d);
+ }
+ g_new_eid = 0xFFFF;
}
- g_new_eid = 0xFFFF;
p = d.nodes + 4 * d.nnodes;
if ((uintptr_t)(p - blob) & 1) p++;
}
diff --git a/games/celeste/tests/check.py b/games/celeste/tests/check.py
index 412e7dcd..f402d613 100644
--- a/games/celeste/tests/check.py
+++ b/games/celeste/tests/check.py
@@ -168,6 +168,14 @@ for room, (above, places) in ASCENTS.items():
check(f"room {above} " in out and " deaths 0 " in out and "state 0 " in out,
f"7A's {room}: the ascent didn't land in {above}: {out[-160:]}")
+# 7B's last climb (g-02): a death goes back to the spawn closest to the last summit checkpoint touched, though each
+# one is listed before its own spawn (the player stood on two in a row, then put on a spinner)
+for (a, b, spinner) in (((896, 1872), (712, 1680), (800, 1760)), ((544, 1504), (1152, 1120), (1088, 1136))):
+ out = run(["--chapter", "20", "--room", "g-02", "--nowipe", "--tp", f"5-30:{a[0]},{a[1]}", "--tp", f"60-90:{b[0]},{b[1]}",
+ "--tp", f"150-152:{spinner[0]},{spinner[1]}"], 400, what="7B's checkpoints")
+ check(f"room g-02 player {12632 + b[0]},{-17504 + b[1]} " in out and " deaths 1 " in out,
+ f"7B's g-02: a death didn't go back to the checkpoint at {b}: {out[-160:]}")
+
# a chapter's end: its screen, then the chapter select
out = run(["--chapter", "1", "--room", "1"], 500, "400-401:o", env={"COMPLETE_AT": "60"}, what="a chapter's end")