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: the Knight gets his control back as he leaves a room or is hit, as Spell Control's Cancel Some and Cancel All give it: after a door (the Ascend to Dirtmouth, the Temple of the Black Egg, the shops) he can slash and look up and down again

Mason363bcfcc7215698
diff --git a/games/hollowknight/src/game.h b/games/hollowknight/src/game.h
index 6a1cbee3..0729afdb 100644
--- a/games/hollowknight/src/game.h
+++ b/games/hollowknight/src/game.h
@@ -408,6 +408,7 @@ bool bench_respawn(const char *name); /* RESPAWN: the Knight asleep on the ben
void spell_reset(void);
void spell_update(void);
void spell_cancel(void);
+void spell_cancel_regain(void); /* (HERO DAMAGED, LEAVING SCENE) */
bool spell_busy(void);
void spell_cast(bool up, bool down);
void fireballs_tick(void);
diff --git a/games/hollowknight/src/hero.c b/games/hollowknight/src/hero.c
index 7211a86d..65f27624 100644
--- a/games/hollowknight/src/hero.c
+++ b/games/hollowknight/src/hero.c
@@ -996,7 +996,7 @@ void fx_dash_burst(float x, float y, bool facing_right, bool on_ground) { (void)
void hero_leave_scene(int gate) {
Hero *h = &g_hero;
- spell_cancel(); /* (LEAVING SCENE) */
+ spell_cancel_regain(); /* (LEAVING SCENE: Spell Control's Cancel Some) */
map_cancel();
dialogue_cancel();
h->accepting_input = false; /* (IgnoreInputWithoutReset) */
@@ -1305,11 +1305,11 @@ void hero_take_damage(int side, int damage, int hazard) {
if (damage <= 0) return;
if (h->parry_t > 0 && hazard == HAZ_NORMAL) return;
if (can_take_damage()) {
- spell_cancel(); /* (HERO DAMAGED) */
+ if (h->damage_mode == DAMAGE_HAZARD_ONLY && hazard == HAZ_NORMAL) return;
+ spell_cancel_regain(); /* (HERO DAMAGED: Spell Control's Cancel All) */
map_cancel();
vm_broadcast(VMEV_HERO_DAMAGED);
inv_damage();
- if (h->damage_mode == DAMAGE_HAZARD_ONLY && hazard == HAZ_NORMAL) return;
cancel_attack();
if (h->cs.recoiling_left || h->cs.recoiling_right) cancel_recoil_horizontal();
if (h->cs.bouncing) cancel_bounce(), h->body.vy = 0;
diff --git a/games/hollowknight/src/spell.c b/games/hollowknight/src/spell.c
index 2275ba13..1f2e5ee1 100644
--- a/games/hollowknight/src/spell.c
+++ b/games/hollowknight/src/spell.c
@@ -202,7 +202,7 @@ void spell_update(void) {
}
}
-/* the FSM's global events: the Knight hit (Cancel All), leaving the room (Cancel Some) */
+/* the FSM's FSM CANCEL (and the Knight's death): its focus or spell stopped */
void spell_cancel(void) {
if (sp.state == SP_INACTIVE) return;
bool focusing = sp.state >= SP_FOCUS_START && sp.state <= SP_FOCUS_CANCEL;
@@ -220,6 +220,16 @@ void spell_cancel(void) {
}
}
+/* its global events as the Knight is hit (Reset Cam Zoom, Cancel All) or leaves the room (Cancel Some): the same, then,
+ * whatever it was doing (their Can Cancel test is switched off), RegainControl, StartAnimationControl and
+ * AffectedByGravity: what a door, a script or anything else took from him, he has again in the next room */
+void spell_cancel_regain(void) {
+ spell_cancel();
+ hero_regain_control();
+ hero_start_anim_control();
+ hero_gravity(true);
+}
+
bool spell_busy(void) { return sp.state != SP_INACTIVE && sp.state != SP_BUTTON_DOWN; }
/* Can Cast?, Spell Choice: up a scream, down a quake (the Knight has neither yet: Has Scream?, Has Quake? go on to),
diff --git a/games/hollowknight/tests/check.py b/games/hollowknight/tests/check.py
index e186c770..3d398dbc 100644
--- a/games/hollowknight/tests/check.py
+++ b/games/hollowknight/tests/check.py
@@ -1,8 +1,8 @@
"""The host build's checks (make test): check.py build/play src/data.bin
- every room's hazard respawn points: ground under them, in the room
-- every gate: the Knight arrives in the next room, in control, on the ground, and can move; and spikes there send him
- back to a good place
+- every gate and door (a door taking his control, as its FSM does): the Knight arrives in the next room, in control, on
+ the ground, and can slash and move; and spikes there send him back to a good place
- every arena won: its fight over and the room's battle gates open, also as the Knight comes back and after a save and
a load
- a long walk of made up keys from every room: the Knight never out of the room, without control, wedged, undrawn or
diff --git a/games/hollowknight/tests/play.c b/games/hollowknight/tests/play.c
index fe2f02b1..125412d1 100644
--- a/games/hollowknight/tests/play.c
+++ b/games/hollowknight/tests/play.c
@@ -289,6 +289,13 @@ static int gates_test(const char *which) {
snprintf(gate_name, sizeof gate_name, "%s", str_at(room_ents(&n)[ways[w].ent].s0));
shielded = true;
run_ticks(5, 0);
+ if (ways[w].kind == GATE_DOOR) {
+ /* (a door, as its Door Control goes through it: Enter takes the Knight's control, Change Scene) */
+ hero_relinquish_control();
+ hero_stop_anim_control();
+ run_ticks(25, 0);
+ hero_start_anim_control();
+ }
game_transition(ways[w].to, ways[w].entry, ways[w].kind, ways[w].delay, false);
run_ticks(400, 0); /* (the fade, the room, the Knight walking, dropping or jumping in, landing) */
total++;
@@ -302,6 +309,13 @@ static int gates_test(const char *which) {
if (h->cs.dead || h->cs.hazard_death) strcat(why, " dead");
if (h->body.x < 0 || h->body.x > g_room.h->w || h->body.y < 0 || h->body.y > g_room.h->h) strcat(why, " out of the room");
if (!h->cs.on_ground) strcat(why, " not on the ground");
+ /* (and he can slash, look up and down: nothing the way in took is kept from him, as a door's control) */
+ if (!why[0]) {
+ if (h->control_relinquished) strcat(why, " control kept");
+ run_ticks(1, K_ATTACK);
+ if (!h->cs.attacking) strcat(why, " can't attack");
+ run_ticks(30, 0);
+ }
float x0 = h->body.x, y0 = h->body.y;
int room0 = g_room.id;
if (getenv("HKGATETRACE")) {
@@ -358,6 +372,7 @@ static int gates_test(const char *which) {
float yj = h->body.y;
if (g_room.id == room0 && fabsf(xr - x0) < 0.05f && fabsf(xl - xr) < 0.05f) strcat(why, " can't walk");
if (g_room.id == room0 && fabsf(yj - y0) < 0.05f && fabsf(xl - x0) < 0.05f) strcat(why, " can't jump");
+
shielded = false;
bool bad = why[0] != 0 && !walled;
fails += bad;
@@ -390,7 +405,7 @@ int main(int argc, char **argv) {
const char *items_out = NULL, *play = NULL, *shots = NULL;
float px = 20, py = 20;
int shot_every = 0, trace = 0;
- const char *gates = NULL;
+ const char *gates = NULL, *gate_in = NULL;
float dx = 0.15f;
for (int i = 2; i < argc; i++) {
if (!strcmp(argv[i], "--room")) room = argv[++i];
@@ -406,6 +421,7 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[i], "--shots")) shots = argv[++i], shot_every = atoi(argv[++i]);
else if (!strcmp(argv[i], "--trace")) trace = 1;
else if (!strcmp(argv[i], "--gates")) gates = argv[++i];
+ else if (!strcmp(argv[i], "--gate")) gate_in = argv[++i]; /* (--play: in through the room's gate so named) */
else if (!strcmp(argv[i], "--list")) { /* (the rooms' names) */
for (int r = 0; r < NUM_ROOMS; r++) printf("%s\n", room_name(r));
return 0;
@@ -460,7 +476,9 @@ int main(int argc, char **argv) {
printf("load failed\n");
return 1;
}
- } else
+ } else if (gate_in)
+ game_enter_gate(id, gate_in);
+ else
game_enter(id, px, py, true);
int tick = 0;
for (const char *p = play; *p;) {