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.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Undertale: Hotland's third floor, up to the MTT Resort's stairs
Mason Chen19d257d038df
diff --git a/README.md b/README.mdindex 6197bb02..fbfabac2 100644--- a/README.md+++ b/README.md@@ -79,7 +79,7 @@ These are too big to fit next to NumPlay, so each one is its own app. Install it<tr><td align="center"><a href="games/celeste/README.md"><img src="docs/media/thumb_celeste.png" width="200" alt="Celeste"><br><b>Celeste</b></a><br><sub>The whole climb, with every B-side and C-side</sub><br><a href="https://github.com/Mason363/NumPlay/releases/latest/download/Celeste.nwa">Download</a></td><td align="center"><a href="games/championisland/README.md"><img src="docs/media/thumb_championisland.png" width="200" alt="Champion Island"><br><b>Champion Island</b></a><br><sub>The whole island and its seven sports</sub><br><a href="https://github.com/Mason363/NumPlay/releases/latest/download/ChampionIsland.nwa">Download</a></td>- <td align="center"><a href="games/undertale/README.md"><img src="docs/media/thumb_undertale.png" width="200" alt="Undertale"><br><b>Undertale</b></a><br><sub>The Ruins, Snowdin, Waterfall and Hotland's first two floors, from the golden flowers to Mettaton's news report</sub><br><a href="https://github.com/Mason363/NumPlay/releases/latest/download/Undertale.nwa">Download</a></td>+ <td align="center"><a href="games/undertale/README.md"><img src="docs/media/thumb_undertale.png" width="200" alt="Undertale"><br><b>Undertale</b></a><br><sub>The Ruins, Snowdin, Waterfall and Hotland, from the golden flowers to the MTT Resort's door</sub><br><a href="https://github.com/Mason363/NumPlay/releases/latest/download/Undertale.nwa">Download</a></td></tr><tr><td align="center"><a href="#roadmap"><b>More on the way</b></a><br><sub>The rest of Undertale, The Binding of Isaac, Plants vs. Zombies, Doom and more: see the roadmap</sub></td>@@ -174,7 +174,7 @@ Filmed on my own calculator, no emulator.- [x] The Final Earth 2- [x] The Powder Toy (NumPowder)- [x] Block Blast-- [ ] Undertale: the Ruins, Snowdin, Waterfall and Hotland's first two floors are out, the rest of Hotland, the CORE and New Home are next+- [ ] Undertale: the Ruins, Snowdin, Waterfall and Hotland are out, the MTT Resort, the CORE and New Home are next- [ ] The Binding of Isaac- [ ] Plants vs. Zombies- [ ] Doomdiff --git a/docs/play.md b/docs/play.mdindex 4e5f6393..954a89ca 100644--- a/docs/play.md+++ b/docs/play.md@@ -268,7 +268,7 @@ Undertale comes as its own app, `Undertale.nwa`: it is too big to share the calc| **toolbox**, **shift** or **var** | The menu: ITEM, STAT, CELL (C in the game) || **Home** | Keep the moment and quit |-Name the fallen human, then walk and talk your way through the Ruins, Snowdin, Waterfall and Hotland. In a battle, FIGHT attacks (press **OK** when the bar crosses the middle), ACT checks a monster or does something to it, ITEM eats, and MERCY spares a monster that no longer wants to fight, or flees. Then move your SOUL to dodge; when it turns blue, it falls, and **Up** jumps; when it turns green, it stays put, and the arrows turn its shield to block. On ice you slide until something stops you. In Snowdin Town, walk into the shop to buy, and into the inn to rest. In Waterfall, walk into a bridge seed to push it into the water, where it blooms into a flower you can walk on; the bell calls the seeds back. A green bullet heals you. Walk up to a star and press **OK** to SAVE. Home keeps the moment you were at, and the next start is back there. Your save is also copied into `undertale_saves.py`, so installing the app again doesn't erase it. The Tem Shop in Temmie Village also buys what you carry. In Hotland, steam vents throw you over the lava, orange lasers hit you if you stand still and blue ones if you move, and in a shooting puzzle the arrows push the dark blocks and Z shoots. On the second floor, press the switches as the top conveyor belt carries you past them, and in Mettaton's news report, touch each bomb and defuse it while it's in the DEFUSE ZONE. For now the game ends at the elevator past the news report.+Name the fallen human, then walk and talk your way through the Ruins, Snowdin, Waterfall and Hotland. In a battle, FIGHT attacks (press **OK** when the bar crosses the middle), ACT checks a monster or does something to it, ITEM eats, and MERCY spares a monster that no longer wants to fight, or flees. Then move your SOUL to dodge; when it turns blue, it falls, and **Up** jumps; when it turns green, it stays put, and the arrows turn its shield to block. On ice you slide until something stops you. In Snowdin Town, walk into the shop to buy, and into the inn to rest. In Waterfall, walk into a bridge seed to push it into the water, where it blooms into a flower you can walk on; the bell calls the seeds back. A green bullet heals you. Walk up to a star and press **OK** to SAVE. Home keeps the moment you were at, and the next start is back there. Your save is also copied into `undertale_saves.py`, so installing the app again doesn't erase it. The Tem Shop in Temmie Village also buys what you carry. In Hotland, steam vents throw you over the lava, orange lasers hit you if you stand still and blue ones if you move, and in a shooting puzzle the arrows push the dark blocks and Z shoots. On the second floor, press the switches as the top conveyor belt carries you past them, and in Mettaton's news report, touch each bomb and defuse it while it's in the DEFUSE ZONE. When Muffet turns your SOUL purple, it keeps to three strings: **Up** and **Down** hop between them. In the tile puzzle, red tiles are walls, yellow ones shock you back, orange makes you smell of oranges (and blue water's piranhas bite then), and purple soap slides you on and smells of lemons. When your SOUL turns yellow, **OK** shoots. For now the game ends on the stairs up to the MTT Resort.<br clear="right">diff --git a/games/undertale/README.md b/games/undertale/README.mdindex 2194c430..2bae6095 100644--- a/games/undertale/README.md+++ b/games/undertale/README.md@@ -8,7 +8,7 @@<p align="center"><b>Fall into the Underground as a human child, on the NumWorks calculator.</b><br>- The Ruins, Snowdin, Waterfall and Hotland's first two floors, from the bed of golden flowers to the elevator past Mettaton's news report. The rest of the Underground is on the way.+ The Ruins, Snowdin, Waterfall and all of Hotland, from the bed of golden flowers to the stairs up to the MTT Resort. The rest of the Underground is on the way.</p><p align="center">@@ -28,7 +28,8 @@* **Waterfall:** Monster Kid, Grillby's with Sans, the echo flowers, the bridge seeds (and the secret bridge to the quiche), the wishing room, Undyne chasing you with her spears, Sans's telescope, the marsh where the land is black and the water glows, Onionsan, the piano's secret song, the statue in the rain and Monster Kid under your umbrella. Then the fall into the garbage dump, Mad Dummy, Napstablook's house and snail farm, the small bird back over the gap, Gerson's shop, the mushroom maze and Temmie Village with its Tem Shop. And at the end of Waterfall: the lantern maze, Undyne at the dead end (and Monster Kid in her way), the echo flowers' path, Monster Kid on the chasm's bridge, Undyne on her crag, her fight and her chase, and Hotland's edge, where the heat gets her and the water cooler helps.* **Hotland's first floor:** Alphys's Lab, where Mettaton bursts in with his quiz show, the conveyor belts, the Magma Chamber's steam vents and the burnt pan, the laser walkway, the two shooting puzzles that open the door, the vents over the lava and Mettaton's cooking show, with your phone's jetpack, up to the elevator. Alphys calls you as you go.* **Hotland's second floor:** Sans's hot dog stand and Heats Flamesman, the invisible path to the Art Club's room, the Stained Apron, the conveyor belt puzzle and its three switches, the vent puzzle, the Bad Opinion Zone, the Royal Guards, and Mettaton's news report, where everything is a bomb and the clock is running.-* **Battles like in the game:** FIGHT with the timing bar, ACT, ITEM and MERCY, and your SOUL dodging each monster's own attacks in the box: Froggit, Whimsun, Moldsmal, Loox, Vegetoid, Migosp, Napstablook and Toriel in the Ruins; Snowdrake, Ice Cap, Gyftrot, Jerry, Chilldrake, Glyde, Doggo, Lesser Dog, Dogamy and Dogaressa, Greater Dog and Papyrus, whose blue attack makes your SOUL fall, in Snowdin; Aaron, Woshua, Moldbygg, Shyren, Temmie, Mad Dummy, who can't be hurt, and Undyne, who turns your SOUL green, in Waterfall; Vulkin, Tsunderplane, Pyrope and the Royal Guards in Hotland, and the news report's bombs, defused in the DEFUSE ZONE.+* **Hotland's third floor:** the spiders' bake sale, the vent islands and their two shooting puzzles (the Diamond Boys, and Alphys asking you to watch anime), the conveyor belts past the laser drones, the spider entrance and Muffet's sticky lair, Mettaton's musical and the trapdoor to his tile puzzle against the clock, and the crossroads with the Nice Cream guy and Heats Flamesman, by the stairs up to the MTT Resort.+* **Battles like in the game:** FIGHT with the timing bar, ACT, ITEM and MERCY, and your SOUL dodging each monster's own attacks in the box: Froggit, Whimsun, Moldsmal, Loox, Vegetoid, Migosp, Napstablook and Toriel in the Ruins; Snowdrake, Ice Cap, Gyftrot, Jerry, Chilldrake, Glyde, Doggo, Lesser Dog, Dogamy and Dogaressa, Greater Dog and Papyrus, whose blue attack makes your SOUL fall, in Snowdin; Aaron, Woshua, Moldbygg, Shyren, Temmie, Mad Dummy, who can't be hurt, and Undyne, who turns your SOUL green, in Waterfall; Vulkin, Tsunderplane, Pyrope and the Royal Guards in Hotland, the news report's bombs, defused in the DEFUSE ZONE, Muffet, whose purple SOUL keeps to her strings, and Mettaton, worn down by the yellow SOUL's shots.* **Spare or fight:** every monster can be spared, and Flowey at the door remembers what you did. Lose to Papyrus and he only locks you in his shed.* **Saved like in the game:** SAVE at the stars, with the room and the time played. The C menu has your ITEM, STAT and CELL. Home keeps the moment you were at, and your save is also copied into `undertale_saves.py`, so installing the app again doesn't erase it.@@ -125,6 +126,18 @@<td align="center"><img src="docs/news.png" width="390" alt="Mettaton's news report"><br><sub>MTT News: two minutes to go</sub></td><td align="center"><img src="docs/defuse.png" width="390" alt="Defusing a bomb"><br><sub>Defuse it in the DEFUSE ZONE</sub></td></tr>+ <tr>+ <td align="center"><img src="docs/shoot3.png" width="390" alt="The third floor's shooting puzzle"><br><sub>One shot to clear the way</sub></td>+ <td align="center"><img src="docs/muffet.png" width="390" alt="Muffet's battle"><br><sub>Muffet's strings, the purple SOUL</sub></td>+ </tr>+ <tr>+ <td align="center"><img src="docs/musical.png" width="390" alt="Mettaton's musical"><br><sub>Mettaton's musical</sub></td>+ <td align="center"><img src="docs/tiles.png" width="390" alt="The tile puzzle"><br><sub>The tile puzzle, against the clock</sub></td>+ </tr>+ <tr>+ <td align="center"><img src="docs/yellow.png" width="390" alt="The yellow SOUL"><br><sub>The yellow button</sub></td>+ <td align="center"><img src="docs/crossroads.png" width="390" alt="The crossroads"><br><sub>Nice Cream, by the MTT Resort</sub></td>+ </tr></table>## How to play@@ -137,7 +150,7 @@ Snowdin brings new things: when Papyrus turns your SOUL blue, it falls to the boIn Waterfall, walk into a bridge seed to push it: in the water it blooms into a flower you can walk on, and the bell calls the seeds back. A green bullet heals you instead of hurting. Talk to the piano to play it, and keep an umbrella for the rain. The Tem Shop is the one shop that buys what you carry. When Undyne turns your SOUL green, it can't move: turn its shield with the arrows to block her spears. She can't be spared: run, and she'll chase you.-In Hotland, conveyor belts carry you and steam vents throw you over the lava (the one in the middle of the puzzle hub turns each time). Keep moving through orange lasers and stand still for blue ones. In a shooting puzzle, the arrows push every dark block one cell and Z shoots: break your way to the target in two shots. In Mettaton's quiz, move your SOUL onto an answer and press OK; Alphys signals the right one. Alphys's upgrade puts the Dimensional Box in your phone's CELL. On the second floor, the top conveyor belt carries you past three switches: press them one after another as you go by. In the vent puzzle, every panel you land on turns all the vents around, and the one at the top turns them back. To spare the Royal Guards, clean 02's armor, catch its green stars, then whisper to 01. In the news report, touch a bomb to face it, and Defuse it (or FIGHT it) while it's in the DEFUSE ZONE.+In Hotland, conveyor belts carry you and steam vents throw you over the lava (the one in the middle of the puzzle hub turns each time). Keep moving through orange lasers and stand still for blue ones. In a shooting puzzle, the arrows push every dark block one cell and Z shoots: break your way to the target in two shots. In Mettaton's quiz, move your SOUL onto an answer and press OK; Alphys signals the right one. Alphys's upgrade puts the Dimensional Box in your phone's CELL. On the second floor, the top conveyor belt carries you past three switches: press them one after another as you go by. In the vent puzzle, every panel you land on turns all the vents around, and the one at the top turns them back. To spare the Royal Guards, clean 02's armor, catch its green stars, then whisper to 01. In the news report, touch a bomb to face it, and Defuse it (or FIGHT it) while it's in the DEFUSE ZONE. On the third floor, ride the belt past the blue drones without a step. When Muffet turns your SOUL purple, it keeps to three strings: Up and Down hop between them, Left and Right move along. In the tile puzzle, red tiles are walls, yellow ones shock you back, orange ones make you smell of oranges (and the blue water's piranhas bite then), purple soap slides you on and makes you smell of lemons, and blue next to yellow is electrified. After it, ACT and press the yellow button: your SOUL turns yellow, and OK shoots.Walk up to a star and press OK to SAVE and fill your HP. The C menu (toolbox) shows your items, your STAT and the phone numbers you have.@@ -154,7 +167,7 @@ Walk up to a star and press OK to SAVE and fill your HP. The C menu (toolbox) sh## Good to know* **One app at a time:** Undertale is too big to sit next to NumPlay or the other big games. Installing it from the NumWorks website swaps them out, and installing them again swaps it out. Your saves in each one are kept.-* **The Ruins, Snowdin, Waterfall and Hotland's first two floors, for now:** the elevator past Mettaton's news report ends the game, on a screen that says the rest of the Underground is still to come. The rest of Hotland, the CORE and New Home come next, one at a time.+* **The Ruins, Snowdin, Waterfall and Hotland, for now:** the stairs up to the MTT Resort end the game, on a screen that says the rest of the Underground is still to come. The MTT Resort, the CORE and New Home come next, one at a time.* **No music or sound:** the calculator has no speaker.* **The same Underground:** the rooms and pictures are the game's, everyone says what they say in the game (the longer speeches in shorter words of our own), and the puzzles and battles follow how the game plays them, at its 30 frames a second.diff --git a/games/undertale/docs/crossroads.png b/games/undertale/docs/crossroads.pngnew file mode 100644index 00000000..3542031cBinary files /dev/null and b/games/undertale/docs/crossroads.png differdiff --git a/games/undertale/docs/muffet.png b/games/undertale/docs/muffet.pngnew file mode 100644index 00000000..a185f25fBinary files /dev/null and b/games/undertale/docs/muffet.png differdiff --git a/games/undertale/docs/musical.png b/games/undertale/docs/musical.pngnew file mode 100644index 00000000..5ddf1c90Binary files /dev/null and b/games/undertale/docs/musical.png differdiff --git a/games/undertale/docs/shoot3.png b/games/undertale/docs/shoot3.pngnew file mode 100644index 00000000..565e46b0Binary files /dev/null and b/games/undertale/docs/shoot3.png differdiff --git a/games/undertale/docs/tiles.png b/games/undertale/docs/tiles.pngnew file mode 100644index 00000000..9521c175Binary files /dev/null and b/games/undertale/docs/tiles.png differdiff --git a/games/undertale/docs/yellow.png b/games/undertale/docs/yellow.pngnew file mode 100644index 00000000..152b397aBinary files /dev/null and b/games/undertale/docs/yellow.png differdiff --git a/games/undertale/src/battle.c b/games/undertale/src/battle.cindex bacd3aab..9bfa73b9 100644--- a/games/undertale/src/battle.c+++ b/games/undertale/src/battle.c@@ -768,6 +768,8 @@ void battle_draw(void) {gfx_clip(bt.x0 + 2, bt.y0 + 2, bt.x1 - bt.x0 - 4, bt.y1 - bt.y0 - 4);draw_box_contents();if (bt.phase == P_ATTACK) {+ if (bt.soul_mode == SOUL_PURPLE)+ for (int i = 0; i < NSTRINGS; i++) gfx_rect(bt.x0 + 2, soul_string_y(i), bt.x1 - bt.x0 - 4, 1, rgb565(0xD535D9), 255);attack_draw(&bt, bt.atk, bt.atk_t);bullets_draw();if (!bt.inv || (bt.inv / 2) % 2) gfx_sprite(SPR_HEART, bt.soul_mode, soul_x(), soul_y(), 0, 255);diff --git a/games/undertale/src/battle.h b/games/undertale/src/battle.hindex 006f93a9..12a65843 100644--- a/games/undertale/src/battle.h+++ b/games/undertale/src/battle.h@@ -88,7 +88,7 @@ typedef struct Monster {/* the bullets: a pool, moved by kind each frame; the attack's code makes them and steers them */enum { BK_NONE, BK_LINEAR, BK_GRAVITY, BK_HOMING, BK_ORBIT, BK_SCRIPT };-enum { BC_WHITE, BC_BLUE, BC_ORANGE, BC_GREEN };+enum { BC_WHITE, BC_BLUE, BC_ORANGE, BC_GREEN, BC_YELLOW };typedef struct {uint8_t kind, color, frame, flags;uint16_t spr;@@ -102,7 +102,8 @@ typedef struct {int16_t angle; /* drawn turned (1/256 turns) */uint8_t owner; /* the monster that made it */} Bullet;-enum { BF_NOCLIP = 1, BF_ONCE = 2, BF_HIDDEN = 4, BF_BOX = 8, BF_FRONT = 16, BF_HARMLESS = 32, BF_SHIELD = 64 }; /* (shield: the green SOUL's blocks it) */+enum { BF_NOCLIP = 1, BF_ONCE = 2, BF_HIDDEN = 4, BF_BOX = 8, BF_FRONT = 16, BF_HARMLESS = 32, BF_SHIELD = 64,+ BF_PLAYER = 128 }; /* (shield: the green SOUL's blocks it; player: the yellow SOUL's own shot) */typedef struct Battle {int form;@@ -159,7 +160,12 @@ void bullets_update(void);void bullets_draw(void);bool soul_hit_test(void); /* bullets touching the SOUL hurt it */void soul_update(uint32_t keys);-enum { SOUL_RED, SOUL_BLUE, SOUL_GREEN }; /* (the heart's frame too): green stays put, its shield turns */+/* (the heart's frame too): green stays put, its shield turns; purple keeps to three strings across the board+ * (up and down hop between them); yellow shoots up (Z) */+enum { SOUL_RED, SOUL_BLUE, SOUL_GREEN, SOUL_PURPLE, SOUL_YELLOW };+#define NSTRINGS 3+int soul_string_y(int i); /* the purple SOUL's strings: where string i is now (pixels) */+extern int32_t soul_strings_shift; /* how far they've been pulled down (1/16 px; they come round from the top) */void soul_set_mode(int mode); /* blue: it falls, up jumps */void gfx_bone(int cx, int cy, int w, int h, uint16_t col, uint8_t a);void soul_hurt(int dmg, int color);diff --git a/games/undertale/src/bullets.c b/games/undertale/src/bullets.cindex 93af0b39..4e21c697 100644--- a/games/undertale/src/bullets.c+++ b/games/undertale/src/bullets.c@@ -33,15 +33,53 @@ int soul_y(void) { return bt.sy / FX; }static int32_t soul_vy;#define BLUE_JUMP (3 * FX)#define BLUE_GRAVITY 3 /* 1/16 px a frame, each frame */+/* the purple SOUL: the string it's on; the strings, evenly down the board (pulled down, they come round again) */+static int string_on;+int32_t soul_strings_shift;+int soul_string_y(int i) {+ int h = bt.y1 - bt.y0 - 8, gap = h / NSTRINGS;+ return bt.y0 + 4 + (gap / 2 + gap * i + (int)(soul_strings_shift / FX)) % h;+}+static uint32_t keys_before;void soul_set_mode(int mode) {bt.soul_mode = mode;soul_vy = 0;+ string_on = NSTRINGS / 2, soul_strings_shift = 0;+ if (mode == SOUL_PURPLE) bt.sy = soul_string_y(string_on) * FX;}void soul_update(uint32_t keys) {int sp = bt.speed;if (keys & K_X) sp /= 2;int dx = ((keys & K_RIGHT) != 0) - ((keys & K_LEFT) != 0), dy = ((keys & K_DOWN) != 0) - ((keys & K_UP) != 0);int x0 = (bt.x0 + 2 + 4) * FX, x1 = (bt.x1 - 2 - 4) * FX, y0 = (bt.y0 + 2 + 4) * FX, y1 = (bt.y1 - 2 - 4) * FX;+ uint32_t pressed = keys & ~keys_before;+ keys_before = keys;+ if (bt.soul_mode == SOUL_PURPLE) {+ /* up or down: the next string that way (the nearest above, or below); along it, the arrows */+ int y = soul_string_y(string_on);+ if (pressed & (K_UP | K_DOWN)) {+ int best = -1;+ for (int i = 0; i < NSTRINGS; i++) {+ int yi = soul_string_y(i);+ if ((pressed & K_UP) ? yi < y - 2 && (best < 0 || yi > soul_string_y(best))+ : yi > y + 2 && (best < 0 || yi < soul_string_y(best)))+ best = i;+ }+ if (best >= 0) string_on = best, y = soul_string_y(best);+ }+ int ty = y * FX;+ bt.sy += clamp_i(ty - bt.sy, -5 * FX, 5 * FX);+ bt.sx = clamp_i(bt.sx + dx * sp, x0, x1);+ return;+ }+ static int shot_cool;+ if (shot_cool) shot_cool--;+ if (bt.soul_mode == SOUL_YELLOW && (pressed & K_Z) && !shot_cool) {+ /* a shot, straight up (a few frames apart) */+ Bullet *b = bullet_new(SPR_ORB, bt.sx, bt.sy - 6 * FX, 0, -6 * FX);+ if (b) b->flags |= BF_PLAYER | BF_HARMLESS, b->color = BC_YELLOW, b->r = 2, b->life = 50;+ shot_cool = 6;+ }if (bt.soul_mode == SOUL_GREEN) {/* it stays in the middle; the arrows turn its shield */static const uint32_t bit[4] = {K_DOWN, K_UP, K_LEFT, K_RIGHT};@@ -135,7 +173,8 @@ void bullets_draw(void) {for (int i = 0; i < MAX_BULLETS; i++) {const Bullet *b = &bullets[i];if (b->kind == BK_NONE || (b->flags & BF_HIDDEN)) continue;- uint16_t color = b->color == BC_BLUE ? rgb565(0x14A9FF) : b->color == BC_ORANGE ? rgb565(0xFCA600) : b->color == BC_GREEN ? rgb565(0x00C000) : 0;+ uint16_t color = b->color == BC_BLUE ? rgb565(0x14A9FF) : b->color == BC_ORANGE ? rgb565(0xFCA600) : b->color == BC_GREEN ? rgb565(0x00C000)+ : b->color == BC_YELLOW ? rgb565(0xFFFF00) : 0;if (b->spr == SPR_BONE) {gfx_bone(b->x / FX, b->y / FX, b->w, b->h, color ? color : C_WHITE, b->alpha);continue;diff --git a/games/undertale/src/data.bin b/games/undertale/src/data.binindex 3c55236c..b72db20c 100644Binary files a/games/undertale/src/data.bin and b/games/undertale/src/data.bin differdiff --git a/games/undertale/src/data.h b/games/undertale/src/data.hindex cd95eb3e..a1dd5217 100644--- a/games/undertale/src/data.h+++ b/games/undertale/src/data.h@@ -235,70 +235,80 @@#define SPR_BOMB_GAME 221#define SPR_NEWS_SCRIPT 222#define SPR_APRON 223-#define SPR_BOMB_B 224-#define SPR_DOGBOMB_B 225-#define SPR_WATER_B 226-#define SPR_UNDYNE_FALLEN 227-#define SPR_SPEAR 228-#define SPR_ARROW 229-#define SPR_PLANE 230-#define SPR_BOMB 231-#define SPR_CLOUD 232-#define SPR_BOLT 233-#define SPR_UNDYNE_B 234-#define SPR_NOTE 235-#define SPR_DROP 236-#define SPR_ARM 237-#define SPR_DEBRIS 238-#define SPR_STAR 239-#define SPR_AARON_B 240-#define SPR_AARON_HURT 241-#define SPR_WOSHUA_B 242-#define SPR_WOSHUA_HURT 243-#define SPR_MOLDBYGG_B 244-#define SPR_SHYREN_B 245-#define SPR_SHYREN_TURNED 246-#define SPR_INTROIMAGE 247-#define SPR_INTROLAST 248-#define SPR_UNDERTALETITLE 249-#define SPR_GAMEOVERBG 250-#define SPR_FACE_TORIELTALK 251-#define SPR_FACE_TORIELTALKSIDE 252-#define SPR_FACE_TORIELHAPPYTALK 253-#define SPR_FACE_TORIELWHAT 254-#define SPR_FACE_TORIELWHATSIDE 255-#define SPR_FACE_TORIELMAD 256-#define SPR_FACE_TORIELCOLD 257-#define SPR_FACE_TORIELSURPRISED 258-#define SPR_FACE_TORIELEMBARRASSED 259-#define SPR_FACE_TORIELGLASSES 260-#define SPR_FACE_TORIELREVENGETALK 261-#define SPR_FACE_TORIELSCARED 262-#define SPR_FACE_TORIELBLINK 263-#define SPR_FACE_TORIELHAPPYBLINK 264-#define SPR_FACE_TORIELBODY 265-#define SPR_FACE_SANS 266-#define SPR_FACE_SANSCHUCKLE 267-#define SPR_FACE_SANSWINK 268-#define SPR_FACE_PAPYRUS 269-#define SPR_FACE_PAPYRUSEVIL 270-#define SPR_FACE_PAPYRUSLAUGH 271-#define SPR_FACE_PAPYRUSMAD 272-#define SPR_FACE_PAPYRUSSIDE 273-#define SPR_FACE_ALPHYS 274-#define SPR_FLOWEYNICE 275-#define SPR_FLOWEYNICESIDE 276-#define SPR_FLOWEYSASSY 277-#define SPR_FLOWEYEVIL 278-#define SPR_FLOWEYGRIN 279-#define SPR_FLOWEYPLAIN 280-#define SPR_FLOWEYPISSED 281-#define SPR_FLOWEYWINK 282-#define SPR_FLOWEYLAUGH 283-#define SPR_FLOWEYHURT 284-#define SPR_FLOWEYTORIEL 285-#define SPR_FLOWEYTORIEL2 286-#define SPR_FLOWEYSIDESHOCK 287+#define SPR_MUFFET_OW 224+#define SPR_MUFFET_B 225+#define SPR_MUFFET_HURT 226+#define SPR_MUFFET_PET 227+#define SPR_SPIDER_B 228+#define SPR_DIAMOND1 229+#define SPR_DIAMOND2 230+#define SPR_BOMB_B 231+#define SPR_DOGBOMB_B 232+#define SPR_WATER_B 233+#define SPR_UNDYNE_FALLEN 234+#define SPR_SPEAR 235+#define SPR_ARROW 236+#define SPR_PLANE 237+#define SPR_BOMB 238+#define SPR_CLOUD 239+#define SPR_BOLT 240+#define SPR_UNDYNE_B 241+#define SPR_NOTE 242+#define SPR_DROP 243+#define SPR_ARM 244+#define SPR_DEBRIS 245+#define SPR_STAR 246+#define SPR_CROISSANT 247+#define SPR_DONUT 248+#define SPR_MTTMINI 249+#define SPR_AARON_B 250+#define SPR_AARON_HURT 251+#define SPR_WOSHUA_B 252+#define SPR_WOSHUA_HURT 253+#define SPR_MOLDBYGG_B 254+#define SPR_SHYREN_B 255+#define SPR_SHYREN_TURNED 256+#define SPR_INTROIMAGE 257+#define SPR_INTROLAST 258+#define SPR_UNDERTALETITLE 259+#define SPR_GAMEOVERBG 260+#define SPR_FACE_TORIELTALK 261+#define SPR_FACE_TORIELTALKSIDE 262+#define SPR_FACE_TORIELHAPPYTALK 263+#define SPR_FACE_TORIELWHAT 264+#define SPR_FACE_TORIELWHATSIDE 265+#define SPR_FACE_TORIELMAD 266+#define SPR_FACE_TORIELCOLD 267+#define SPR_FACE_TORIELSURPRISED 268+#define SPR_FACE_TORIELEMBARRASSED 269+#define SPR_FACE_TORIELGLASSES 270+#define SPR_FACE_TORIELREVENGETALK 271+#define SPR_FACE_TORIELSCARED 272+#define SPR_FACE_TORIELBLINK 273+#define SPR_FACE_TORIELHAPPYBLINK 274+#define SPR_FACE_TORIELBODY 275+#define SPR_FACE_SANS 276+#define SPR_FACE_SANSCHUCKLE 277+#define SPR_FACE_SANSWINK 278+#define SPR_FACE_PAPYRUS 279+#define SPR_FACE_PAPYRUSEVIL 280+#define SPR_FACE_PAPYRUSLAUGH 281+#define SPR_FACE_PAPYRUSMAD 282+#define SPR_FACE_PAPYRUSSIDE 283+#define SPR_FACE_ALPHYS 284+#define SPR_FLOWEYNICE 285+#define SPR_FLOWEYNICESIDE 286+#define SPR_FLOWEYSASSY 287+#define SPR_FLOWEYEVIL 288+#define SPR_FLOWEYGRIN 289+#define SPR_FLOWEYPLAIN 290+#define SPR_FLOWEYPISSED 291+#define SPR_FLOWEYWINK 292+#define SPR_FLOWEYLAUGH 293+#define SPR_FLOWEYHURT 294+#define SPR_FLOWEYTORIEL 295+#define SPR_FLOWEYTORIEL2 296+#define SPR_FLOWEYSIDESHOCK 297#define AREA_RUINS 0#define AREA_SNOWDIN 1#define AREA_SNOWTOWN 2@@ -454,10 +464,20 @@#define ROOM_HT_GUARDS 147#define ROOM_HT_NEWS 148#define ROOM_HT_COREVIEW2 149+#define ROOM_HT_L3 150+#define ROOM_HT_HUB3 151+#define ROOM_HT_NORTH3 152+#define ROOM_HT_BELTS3 153+#define ROOM_HT_SOUTH3 154+#define ROOM_HT_SPIDERENT 155+#define ROOM_HT_LAIR 156+#define ROOM_HT_STAGE 157+#define ROOM_HT_TILES 158+#define ROOM_HT_CROSS3 159#define FONT_MAIN 0#define FONT_MENU 1#define FONT_SMALL 2-#define NUM_SPRITES 288-#define NUM_ROOMS 150+#define NUM_SPRITES 298+#define NUM_ROOMS 160#define NUM_FONTS 3#endifdiff --git a/games/undertale/src/events.c b/games/undertale/src/events.cindex 8a326c3f..8b64b1f1 100644--- a/games/undertale/src/events.c+++ b/games/undertale/src/events.c@@ -122,5 +122,7 @@ int event_run(Ev *c) {if (r >= 0) return r;r = ht2_event(c);if (r >= 0) return r;+ r = ht3_event(c);+ if (r >= 0) return r;return 1;}diff --git a/games/undertale/src/events.h b/games/undertale/src/events.hindex e25ae925..4a6c39d4 100644--- a/games/undertale/src/events.h+++ b/games/undertale/src/events.h@@ -13,7 +13,8 @@ enum {ACTOR_MK, ACTOR_UNDYNE, ACTOR_SEED, ACTOR_BLOOM, ACTOR_SPEAR, ACTOR_ONION, ACTOR_DEBRIS, ACTOR_SHYREN,ACTOR_MADDUMMY, ACTOR_BIRD, ACTOR_TEMMIE,/* Hotland */- ACTOR_ALPHYS, ACTOR_METTATON, ACTOR_GUARDS, ACTOR_VENT, ACTOR_LASER, ACTOR_RG01, ACTOR_RG02, ACTOR_BOMB, ACTOR_FIELD+ ACTOR_ALPHYS, ACTOR_METTATON, ACTOR_GUARDS, ACTOR_VENT, ACTOR_LASER, ACTOR_RG01, ACTOR_RG02, ACTOR_BOMB, ACTOR_FIELD,+ ACTOR_MUFFET};enum {@@ -49,6 +50,9 @@ enum {EV_HT_LAB, EV_HT_FRIDGE, EV_VENT, EV_HT_CALL, EV_SHOOT, EV_HT_COOK, EV_HT_ELEVATOR, EV_LASER_HIT, EV_HT_ITEM,/* ht2.c */EV_HOTDOG, EV_HEATS, EV_APRON, EV_BELT_SWITCH, EV_HT2_CALL, EV_VENTPUZ, EV_GUARDS, EV_NEWS, EV_BOMB, EV_HT2_ELEVATOR,+ /* ht3.c */+ EV_BAKESALE3, EV_SHOOT3, EV_HT3_CALL, EV_MUFFET, EV_MUSICAL, EV_TILE, EV_TILES3, EV_HEATS3, EV_HT3_ELEVATOR,+ EV_NICECREAM3, EV_HT3_END,EV_COUNT};/* Toriel's calls on the way (EV_CALL's v[0]) */diff --git a/games/undertale/src/flags.h b/games/undertale/src/flags.hindex fc129954..97569494 100644--- a/games/undertale/src/flags.h+++ b/games/undertale/src/flags.h@@ -146,7 +146,16 @@ enum {F_HT_VENTPUZ, /* the vent puzzle crossed */F_HT_GUARDS, /* the Royal Guards: 1 spared, 2 killed */F_HT_NEWS, /* Mettaton's news report: 1 every bomb defused, 2 out of time */- F_HT_FLOOR2, /* the elevator up from the second floor reached (where the game now ends) */+ F_HT_FLOOR2, /* the elevator up from the second floor taken */+ F_HT_CALL_HUB3, /* Alphys's call by the third floor's vents */+ F_HT3_PUZ_N, /* the third floor's shooting puzzles: north, south */+ F_HT3_PUZ_S,+ F_HT_ANIME, /* Alphys asked Frisk to watch anime with her: 1 yes, 2 no */+ F_HT_MUFFET, /* Muffet: 1 spared, 2 killed */+ F_HT_MUSICAL, /* Mettaton's musical seen (and the trapdoor) */+ F_HT_TILES3, /* the tile puzzle under the stage: 1 solved, 2 out of time; then Mettaton fought */+ F_HT_HEATS3, /* Heats Flamesman asked about his name */+ F_HT_FLOOR3, /* the way to the MTT Resort reached (where the game now ends) */FLAG_COUNT = 256};#endifdiff --git a/games/undertale/src/hotland.h b/games/undertale/src/hotland.hindex 546d273a..35707a70 100644--- a/games/undertale/src/hotland.h+++ b/games/undertale/src/hotland.h@@ -1,4 +1,4 @@-/* Undertale: Hotland (ht1.c, ht2.c: its first and second floors), its monsters (htmon.c), Mettaton's shows+/* Undertale: Hotland (ht1.c, ht2.c, ht3.c: its three floors), its monsters (htmon.c), Mettaton's shows* (htshows.c). */#ifndef UT_HOTLAND_H#define UT_HOTLAND_H@@ -12,4 +12,10 @@ int ht2_event(Ev *c);void ht2_update(void); /* the belt puzzle's switches, the news report's bombs and clock */void ht2_draw(void); /* under everything: force fields, the switches, the vent puzzle's arrows */void ht2_draw_top(void); /* over everything: the news report's clock */+void ht3_setup(int room, int from);+int ht3_event(Ev *c);+void ht3_update(void); /* the webs' hold, the tile puzzle, its flames and clock */+void ht3_draw(void); /* under everything: the flames, the turned-off force fields */+void ht3_draw_top(void); /* over everything: the tile puzzle's clock */+int ht3_speed(int x, int y);#endifdiff --git a/games/undertale/src/ht1.c b/games/undertale/src/ht1.cindex a7c6d3a6..559e0f68 100644--- a/games/undertale/src/ht1.c+++ b/games/undertale/src/ht1.c@@ -52,6 +52,10 @@ static const Belt belts[] = {{ROOM_HT_VENTPUZ, 4420, 2310, 60, 290, 0, 3}, {ROOM_HT_VENTPUZ, 4420, 2560, 360, 40, 3, 0},{ROOM_HT_VENTPUZ, 4720, 2430, 60, 170, 0, -3},{ROOM_HT_NEWS, 4300, 1790, 100, 160, 0, -2},+ /* the third floor's, on the way to the south puzzle: down the left side, along the bottom (past the drones), up the+ * right; back along the top */+ {ROOM_HT_BELTS3, 4800, 1400, 60, 130, 0, 3}, {ROOM_HT_BELTS3, 4800, 1520, 600, 60, 3, 0},+ {ROOM_HT_BELTS3, 5380, 1430, 60, 150, 0, -3}, {ROOM_HT_BELTS3, 4850, 1320, 520, 60, -3, 0},};static void belts_update(void) {if (event_running()) return;@@ -91,6 +95,46 @@ static const Vent vents[] = {/* the news room's: up to the top room's corner, and from there over to the rest of it */{ROOM_HT_NEWS, 4350, 1722, DIR_UP, {[DIR_UP] = {4350, 1600}}},{ROOM_HT_NEWS, 4320, 1600, DIR_LEFT, {[DIR_LEFT] = {4200, 1590}}},+ /* the third floor's islands: each grate blows the way its arrow points, to the next island that way (off the+ * edges: the corridor back west, the walkways north and south, the platform east to the door) */+ {ROOM_HT_HUB3, 4740, 740, DIR_DOWN, {[DIR_DOWN] = {4740, 786}}},+ {ROOM_HT_HUB3, 4820, 700, DIR_UP, {[DIR_UP] = {4820, 590}}},+ {ROOM_HT_HUB3, 4820, 740, DIR_DOWN, {[DIR_DOWN] = {4820, 786}}},+ {ROOM_HT_HUB3, 4880, 720, DIR_LEFT, {[DIR_LEFT] = {4820, 706}}},+ {ROOM_HT_HUB3, 4680, 800, DIR_RIGHT, {[DIR_RIGHT] = {4740, 786}}},+ {ROOM_HT_HUB3, 4740, 780, DIR_UP, {[DIR_UP] = {4740, 706}}},+ {ROOM_HT_HUB3, 4740, 820, DIR_DOWN, {[DIR_DOWN] = {4740, 866}}},+ {ROOM_HT_HUB3, 4820, 820, DIR_DOWN, {[DIR_DOWN] = {4820, 866}}},+ {ROOM_HT_HUB3, 4800, 800, DIR_LEFT, {[DIR_LEFT] = {4740, 786}}},+ {ROOM_HT_HUB3, 4900, 780, DIR_UP, {[DIR_UP] = {4900, 706}}},+ {ROOM_HT_HUB3, 4880, 800, DIR_LEFT, {[DIR_LEFT] = {4820, 786}}},+ {ROOM_HT_HUB3, 4960, 800, DIR_LEFT, {[DIR_LEFT] = {4900, 786}}},+ {ROOM_HT_HUB3, 4660, 860, DIR_UP, {[DIR_UP] = {4660, 786}}},+ {ROOM_HT_HUB3, 4640, 880, DIR_LEFT, {[DIR_LEFT] = {4572, 866}}},+ {ROOM_HT_HUB3, 4740, 900, DIR_DOWN, {[DIR_DOWN] = {4740, 946}}},+ {ROOM_HT_HUB3, 4840, 880, DIR_RIGHT, {[DIR_RIGHT] = {4900, 866}}},+ {ROOM_HT_HUB3, 4900, 860, DIR_UP, {[DIR_UP] = {4900, 786}}},+ {ROOM_HT_HUB3, 4980, 860, DIR_UP, {[DIR_UP] = {4980, 786}}},+ {ROOM_HT_HUB3, 4980, 900, DIR_DOWN, {[DIR_DOWN] = {4980, 946}}},+ {ROOM_HT_HUB3, 4960, 880, DIR_LEFT, {[DIR_LEFT] = {4900, 866}}},+ {ROOM_HT_HUB3, 5000, 880, DIR_RIGHT, {[DIR_RIGHT] = {5070, 866}}},+ {ROOM_HT_HUB3, 4660, 940, DIR_UP, {[DIR_UP] = {4660, 866}}},+ {ROOM_HT_HUB3, 4720, 960, DIR_LEFT, {[DIR_LEFT] = {4660, 946}}},+ {ROOM_HT_HUB3, 4760, 960, DIR_RIGHT, {[DIR_RIGHT] = {4820, 946}}},+ {ROOM_HT_HUB3, 4820, 940, DIR_UP, {[DIR_UP] = {4820, 866}}},+ {ROOM_HT_HUB3, 4840, 960, DIR_RIGHT, {[DIR_RIGHT] = {4900, 946}}},+ {ROOM_HT_HUB3, 4900, 940, DIR_UP, {[DIR_UP] = {4900, 866}}},+ {ROOM_HT_HUB3, 4900, 980, DIR_DOWN, {[DIR_DOWN] = {4900, 1026}}},+ {ROOM_HT_HUB3, 4920, 960, DIR_RIGHT, {[DIR_RIGHT] = {4980, 946}}},+ {ROOM_HT_HUB3, 4980, 940, DIR_UP, {[DIR_UP] = {4980, 866}}},+ {ROOM_HT_HUB3, 4740, 1020, DIR_UP, {[DIR_UP] = {4740, 946}}},+ {ROOM_HT_HUB3, 4820, 1060, DIR_DOWN, {[DIR_DOWN] = {4820, 1130}}},+ {ROOM_HT_HUB3, 4800, 1040, DIR_LEFT, {[DIR_LEFT] = {4740, 1026}}},+ {ROOM_HT_HUB3, 4880, 1040, DIR_LEFT, {[DIR_LEFT] = {4820, 1026}}},+ {ROOM_HT_HUB3, 4600, 880, DIR_RIGHT, {[DIR_RIGHT] = {4660, 866}}},+ {ROOM_HT_HUB3, 4820, 660, DIR_DOWN, {[DIR_DOWN] = {4820, 706}}},+ {ROOM_HT_HUB3, 4820, 1100, DIR_UP, {[DIR_UP] = {4820, 1026}}},+ {ROOM_HT_HUB3, 5040, 880, DIR_LEFT, {[DIR_LEFT] = {4980, 866}}},};#define NVENTS ((int)(sizeof vents / sizeof vents[0]))/* the way a vent blows now */@@ -122,6 +166,8 @@ static const Laser lasers[] = {{ROOM_HT_LASERS, 3840, 3796, 62, 30, 0}, {ROOM_HT_LASERS, 3958, 3796, 62, 40, 1},/* the news room's bottom: blue, orange, blue */{ROOM_HT_NEWS, 3965, 1946, 56, 16, 1}, {ROOM_HT_NEWS, 4025, 1946, 56, 16, 0}, {ROOM_HT_NEWS, 4085, 1946, 56, 16, 1},+ /* the third floor's drones over the bottom belt, blue: ride it without a step */+ {ROOM_HT_BELTS3, 4967, 1496, 84, 0, 1}, {ROOM_HT_BELTS3, 5149, 1496, 84, 0, 1}, {ROOM_HT_BELTS3, 5249, 1496, 84, 0, 1},};static int laser_cool;static int laser_x(int i) {diff --git a/games/undertale/src/ht2.c b/games/undertale/src/ht2.cindex a4744fe2..06186543 100644--- a/games/undertale/src/ht2.c+++ b/games/undertale/src/ht2.c@@ -1,7 +1,7 @@/* Hotland, its second floor: out of the elevator, Sans's hot dog stand and Heats Flamesman; the crossroads (the* invisible path up to the Art Club's room, the Stained Apron down south); the conveyor belt puzzle and the vent* puzzle; the Bad Opinion Zone; the Royal Guards at the bend; Mettaton's news report and its six bombs; the CORE- * again, and the elevator up. (As the Undertale Wiki describes them; what they say is ours, in short.) */+ * again, and the elevator up to the third floor. (As the Undertale Wiki describes them; what they say is ours, in short.) */#include <stddef.h>#include <stdio.h>#include "battle.h"@@ -478,9 +478,7 @@ static int ev_elevator(Ev *c) {NARRATE("* (The elevator up.)\n* (Get in?)@Yes@No");if (CHOICE() == 1) return 1;set_flag(F_HT_FLOOR2, 1);- sv.room = (int16_t)g_room, sv.x = 3760, sv.y = 1340;- save_write_auto();- menu_end_open();+ FADE_TO(ROOM_HT_L3, 3770, 842, DIR_DOWN);EV_END;}diff --git a/games/undertale/src/ht3.c b/games/undertale/src/ht3.cnew file mode 100644index 00000000..df3bb559--- /dev/null+++ b/games/undertale/src/ht3.c@@ -0,0 +1,445 @@+/* Hotland, its third floor: out of the elevator, the spiders' bake sale; the vent islands, the shooting puzzles north+ * (the Diamond Boys) and south (over the belts, past the drones); the spider entrance and Muffet's lair, its webs;+ * Mettaton's musical, the trapdoor down to the tile puzzle and his fight; the crossroads, where the way north leads to+ * the MTT Resort. (As the Undertale Wiki describes them; what they say is ours, in short.) */+#include <stddef.h>+#include <stdio.h>+#include "battle.h"+#include "event.h"+#include "events.h"+#include "game.h"+#include "gfx.h"+#include "hotland.h"+#include "items.h"+#include "menu.h"+#include "monsters.h"+#include "res.h"+#include "save.h"+#include "shoot.h"+#include "snowdin.h"+#include "world.h"++static void gone(Obj *o) { o->kind = OBJ_NONE; }+static Obj *thing(int x, int y, int w, int h, int event, int name, int arg) {+ Obj *o = obj_trigger(x, y, w, h, event, name);+ if (o) o->flags = OF_TALK | OF_SOLID, o->arg = (int16_t)arg;+ return o;+}+static Obj *npc(int name, uint16_t spr, int x, int y) {+ const uint16_t s[4] = {spr, spr, spr, spr};+ Obj *o = obj_npc(name, s, x, y, DIR_DOWN, 0);+ if (o) o->flags &= (uint16_t)~OF_SOLID;+ return o;+}+static Obj *obj_mtt(int x, int y) {+ Obj *o = npc(ACTOR_METTATON, SPR_MTT_OW, x, y);+ if (o) o->flags |= OF_ANIM, o->anim_speed = 5;+ return o;+}++/* ---------------------------------------------------------------- Muffet's lair: its webs hold Frisk back */+typedef struct {+ int16_t x, y, w, h;+ uint8_t speed;+} Web;+static const Web webs[] = {+ {5800, 466, 60, 32, 2}, {5880, 466, 60, 32, 2}, {5975, 466, 60, 32, 2}, /* the small ones */+ {6083, 454, 400, 46, 1}, /* the big one, Muffet's */+ {6540, 466, 60, 32, 2},+};+static bool muffet_holds;+int ht3_speed(int x, int y) {+ if (g_room != ROOM_HT_LAIR) return 3;+ if (muffet_holds) return 0;+ for (unsigned i = 0; i < sizeof webs / sizeof webs[0]; i++)+ if (x >= webs[i].x && x < webs[i].x + webs[i].w && y >= webs[i].y && y < webs[i].y + webs[i].h) return webs[i].speed;+ return 3;+}++/* ---------------------------------------------------------------- the tile puzzle (under the stage) */+/* the map's tiles: R red (a wall: the room's collision leaves it out), Y yellow (a shock: back to the last tile+ * stepped on), O orange (Frisk smells of oranges), U purple (soap: lemons, and a slide on to the next tile), B blue+ * (water: the piranhas bite if Frisk smells of oranges; next to yellow, it shocks), P pink and G green (nothing) */+#define TX 6640+#define TY 620+#define TW 39+#define TH 4+static const char tiles[TH][TW + 1] = {+ "BGYPGUPYGRYPRGPOYRRORYPYYGGBYBOGGGRGGGR",+ "GOUBORRBYRRBBBRRRPPRBPGRUOBOUUPBRGRGRGR",+ "PRPPBBRORPBURPYGUOUYUURRPOBUUBYPRGRGRGR",+ "GYBYRPGOUUOPROPORBBPOBGOPBUOYBPPGGGGRGG",+};+#define TILES_TIME (30 * 30)+enum { TILES_OFF, TILES_ON, TILES_DONE };+static int tiles_state, tiles_t, tiles_why, flavor, last_r = -99, last_c = -99, safe_x, safe_y, tile_act, flames_in;+static char tile_at(int r, int c) { return r < 0 || c < 0 || r >= TH || c >= TW ? 0 : tiles[r][c]; }+static bool tile_bad(int r, int c) {+ char t = tile_at(r, c);+ if (t == 'Y') return true;+ if (t != 'B') return false;+ if (flavor == 'O') return true;+ return tile_at(r - 1, c) == 'Y' || tile_at(r + 1, c) == 'Y' || tile_at(r, c - 1) == 'Y' || tile_at(r, c + 1) == 'Y';+}+static void tiles_watch(void) {+ if (tiles_state != TILES_ON) return;+ if (flames_in) {+ /* out of time: the flames close in, then Alphys */+ if (++flames_in > 40) tiles_why = 2, event_start(EV_TILES3, NULL);+ return;+ }+ if (--tiles_t <= 0) {+ flames_in = 1;+ return;+ }+ int fx = pl.x + 10, fy = pl.y + 24;+ if (fx >= TX + TW * 20) {+ tiles_why = 1, event_start(EV_TILES3, NULL);+ return;+ }+ int c = fx >= TX ? (fx - TX) / 20 : -1, r = fy >= TY ? (fy - TY) / 20 : -1;+ if (c < 0 || r < 0 || r >= TH) {+ last_r = last_c = -99, safe_x = pl.x, safe_y = pl.y;+ return;+ }+ if (r != last_r || c != last_c) {+ last_r = r, last_c = c;+ if (tile_bad(r, c)) {+ tile_act = 1, event_start(EV_TILE, NULL);+ return;+ }+ if (tile_at(r, c) == 'O') flavor = 'O';+ if (tile_at(r, c) == 'U') {+ flavor = 'L', tile_act = 2, event_start(EV_TILE, NULL);+ return;+ }+ }+ if (tile_at(r, c) != 'U') safe_x = pl.x, safe_y = pl.y;+}++/* ---------------------------------------------------------------- drawn, and watched */+static void draw_flame_wall(int x) {+ for (int k = 0; k < 6; k++)+ gfx_sprite_color(SPR_FIREBULLET, (int)(g_frame / 4 + (uint32_t)k) % 2, x - cam_x, TY - 10 + k * 18 - cam_y, 0,+ (g_frame / 3 + (uint32_t)k) % 2 ? rgb565(0xFF8000) : rgb565(0xFFC000), 255);+}+void ht3_draw(void) {+ if (g_room != ROOM_HT_TILES || tiles_state != TILES_ON) return;+ int in = flames_in * 6;+ draw_flame_wall(TX - 14 + in);+ draw_flame_wall(TX + TW * 20 + 170 - in);+}+void ht3_draw_top(void) {+ if (g_room != ROOM_HT_TILES || tiles_state != TILES_ON) return;+ char s[16];+ int secs = (tiles_t + 29) / 30;+ snprintf(s, sizeof s, "0:%02d", secs);+ gfx_rect(4, 4, 52, 18, C_BLACK, 200);+ gfx_text(FONT_MAIN, 10, 6, s, secs <= 10 ? C_RED : C_WHITE, 255);+}+void ht3_update(void) {+ if (g_room == ROOM_HT_TILES) tiles_watch();+}++/* ---------------------------------------------------------------- the rooms */+static void diamond_boys(void) {+ Obj *a = npc(ACTOR_ITEM, SPR_DIAMOND1, 4750, 452);+ if (a) a->flags |= OF_SOLID;+ Obj *b = npc(ACTOR_ITEM, SPR_DIAMOND2, 4905, 454);+ if (b) b->flags |= OF_SOLID;+ obj_sign(4736, 424, 30, 32, "* Did you see Mettaton's last\n show? He was AMAZING!|* When he strikes a pose, the\n ratings go through the roof!");+ obj_sign(4890, 420, 30, 38, "* My mom says never touch the\n switch on his back.|* I wonder what it does...");+}++void ht3_setup(int room, int from) {+ (void)from;+ if (room < ROOM_HT_L3 || room > ROOM_HT_CROSS3) return;+ if (room != ROOM_HT_TILES && tiles_state == TILES_ON) tiles_state = TILES_OFF; /* (a SAVE loaded mid-puzzle) */+ switch (room) {+ case ROOM_HT_L3:+ thing(3740, 800, 80, 56, EV_HT3_ELEVATOR, ACTOR_DOOR, 1);+ thing(4128, 846, 74, 36, EV_BAKESALE3, ACTOR_ITEM, 0);+ obj_sign(4276, 892, 44, 40, "* I didn't even want a donut...|* The spiders scared me into\n buying one.\n* There goes all my money.");+ break;+ case ROOM_HT_HUB3:+ if (!flag(F_HT_CALL_HUB3)) {+ Obj *t = obj_trigger(4566, 856, 10, 70, EV_HT3_CALL, ACTOR_TRIGGER);+ if (t) t->arg = 0;+ }+ if (!(flag(F_HT3_PUZ_N) && flag(F_HT3_PUZ_S))) {+ Obj *d = obj_trigger(5200, 700, 60, 12, EV_NONE, ACTOR_DOOR);+ if (d) d->flags = OF_SOLID;+ obj_sign(5200, 712, 60, 16, "* (The door is locked.)\n* (Both puzzles have to be solved.)");+ }+ break;+ case ROOM_HT_NORTH3:+ thing(4812, 154, 36, 30, EV_SHOOT3, ACTOR_ITEM, SHOOT_NORTH);+ if (flag(F_HT3_PUZ_N)) diamond_boys();+ break;+ case ROOM_HT_BELTS3:+ obj_sign(5118, 1286, 30, 34, "* (A cactus, all on its own.)\n* (You stop to look at it.)");+ break;+ case ROOM_HT_SOUTH3:+ thing(5524, 1144, 36, 30, EV_SHOOT3, ACTOR_ITEM, SHOOT_SOUTH);+ break;+ case ROOM_HT_SPIDERENT:+ obj_save(5300, 420, "* (The smell of cobwebs fills you with determination.)");+ break;+ case ROOM_HT_LAIR:+ if (!flag(F_HT_MUFFET)) obj_trigger(6240, 455, 8, 50, EV_MUFFET, ACTOR_TRIGGER);+ break;+ case ROOM_HT_STAGE:+ if (!flag(F_HT_MUSICAL)) obj_trigger(6760, 440, 8, 66, EV_MUSICAL, ACTOR_TRIGGER);+ break;+ case ROOM_HT_TILES:+ if (!flag(F_HT_TILES3) && tiles_state != TILES_ON) obj_mtt(6430, 626);+ break;+ case ROOM_HT_CROSS3:+ thing(7444, 360, 70, 58, EV_NICECREAM3, ACTOR_ITEM, 0);+ if (flag(F_HT_GUARDS) == 1) {+ static const uint16_t s1[4] = {SPR_RG01_OW, SPR_RG01_OW, SPR_RG01_OW, SPR_RG01_OW};+ static const uint16_t s2[4] = {SPR_RG02_OW, SPR_RG02_OW, SPR_RG02_OW, SPR_RG02_OW};+ obj_npc(ACTOR_RG01, s1, 7600, 412, DIR_DOWN, 0);+ obj_npc(ACTOR_RG02, s2, 7642, 412, DIR_DOWN, 0);+ obj_sign(7580, 374, 84, 40, "* Dude, this ice cream is, like,\n the best.|* ... ...yeah.");+ }+ thing(8054, 430, 24, 30, EV_HEATS3, ACTOR_ITEM, 0);+ thing(7934, 340, 80, 80, EV_HT3_ELEVATOR, ACTOR_DOOR, 0);+ obj_trigger(7522, 296, 56, 10, EV_HT3_END, ACTOR_TRIGGER);+ break;+ }+}++/* ---------------------------------------------------------------- the events */+static int ev_bakesale(Ev *c) {+ static const char *const opts[] = {"Spider Donut - 9999G", "Spider Cider - 9999G"};+ EV_BEGIN;+ NARRATE("* (A spider bake sale.)\n* (All proceeds go to real spiders.)");+ CHOOSE(opts, 2);+ if (CHOSEN() < 0) return 1;+ if (sv.gold < 9999) {+ NARRATE("* (You don't have enough gold.)");+ return 1;+ }+ if (!item_add(CHOSEN() ? ITEM_SPIDER_CIDER : ITEM_SPIDER_DONUT)) {+ NARRATE("* (You're carrying too much.)");+ return 1;+ }+ sv.gold = (uint16_t)(sv.gold - 9999);+ NARRATE("* (The spiders take your money.)");+ EV_END;+}++/* Alphys's calls: 0 by the vents; after the south puzzle, the anime (in ev_shoot) */+static int ev_call(Ev *c) {+ EV_BEGIN;+ if (c->self) gone(c->self);+ set_flag(F_HT_CALL_HUB3, 1);+ SAY(FACE_ALPHYS, "* Ring...|* Hi! It's Alphys.|* The door on the right opens\n once both puzzles are done.|* One's up north, one's down\n south. Good luck!");+ EV_END;+}++static int ev_shoot(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : SHOOT_NORTH;+ c->v[1] = c->v[0] == SHOOT_NORTH ? F_HT3_PUZ_N : F_HT3_PUZ_S;+ if (flag(c->v[1])) {+ NARRATE("* (This puzzle is solved.)");+ return 1;+ }+ shoot_open(c->v[0]);+ WAIT_UNTIL(g_mode == MODE_WORLD);+ if (!shoot_result()) return 1;+ set_flag(c->v[1], 1);+ if (flag(F_HT3_PUZ_N) && flag(F_HT3_PUZ_S)) {+ NARRATE("* (Somewhere, a door unlocks.)");+ } else {+ NARRATE("* (One down.)");+ }+ if (c->v[0] == SHOOT_NORTH) {+ diamond_boys();+ return 1;+ }+ /* the south one: Alphys calls, about anime */+ SAY(FACE_ALPHYS, "* Ring...|* H-hey! Um... when all this\n is over...|* want to watch anime with me?@Yes@No");+ if (CHOICE() == 0) {+ set_flag(F_HT_ANIME, 1);+ SAY(FACE_ALPHYS, "* R-really?! Okay!|* There's this show about a\n magical girl, and she...");+ NARRATE("* (Alphys talks about it for a\n long, long time.)");+ SAY(FACE_ALPHYS, "* ...oh! Sorry! Bye!");+ } else {+ set_flag(F_HT_ANIME, 2);+ SAY(FACE_ALPHYS, "* Oh. Okay. That's... fine.\n* Bye!");+ }+ EV_END;+}++static int ev_muffet(Ev *c) {+ static const uint16_t s[4] = {SPR_MUFFET_OW, SPR_MUFFET_OW, SPR_MUFFET_OW, SPR_MUFFET_OW};+ Obj *m = obj_get(ACTOR_MUFFET);+ EV_BEGIN;+ if (c->self) gone(c->self);+ /* the web holds Frisk fast, and down comes Muffet */+ muffet_holds = true;+ NARRATE("* (The web holds you fast.)\n* (You can't move!)");+ m = obj_npc(ACTOR_MUFFET, s, pl.x + 60, pl.y - 30, DIR_LEFT, 0);+ if (m) m->flags &= (uint16_t)~OF_SOLID;+ m = obj_get(ACTOR_MUFFET);+ WALK(m, pl.x + 60, pl.y + 29, 2);+ NARRATE("* Ahuhuhu~|* Did you think you could just\n walk through my lair, deary?|* Someone pays very well for\n human SOULs, you know~|* And you didn't buy a single\n donut. How stingy~");+ BATTLE(FORM_MUFFET);+ muffet_holds = false;+ if (bt.mon[0].killed) {+ set_flag(F_HT_MUFFET, 2);+ gone(obj_get(ACTOR_MUFFET));+ return 1;+ }+ set_flag(F_HT_MUFFET, 1);+ NARRATE("* Ahuhu... no hard feelings,\n deary~|* Do come back to our bake sale!");+ m = obj_get(ACTOR_MUFFET);+ WALK(m, m->x + 200, m->y, 3);+ gone(obj_get(ACTOR_MUFFET));+ EV_END;+}++static int ev_musical(Ev *c) {+ Obj *m = obj_get(ACTOR_METTATON);+ EV_BEGIN;+ if (c->self) gone(c->self);+ NARRATE("* (The lights go down.)\n* (A spotlight finds you.)");+ /* (the view: up to his balcony, and back) */+ WAIT_UNTIL(cam_pan(7000, 214, 6));+ text_set_top(0); /* (the box below, out of his way) */+ NARRATE("* OHHH! WHO IS THIS, BENEATH MY\n BALCONY?|* A HUMAN, COME TO SAVE ME FROM\n MY TOWER?|* ALAS! A ROBOT AND A HUMAN...\n* IT COULD NEVER BE!|* SO, MY LOVE... YOU'LL JUST HAVE\n TO DROP IN!");+ text_set_top(-1);+ WAIT_UNTIL(cam_pan(pl.x - 150, pl.y - 105, 6));+ cam_free();+ g_shake = 6;+ NARRATE("* (The floor opens up under you!)");+ set_flag(F_HT_MUSICAL, 1);+ FADE_TO(ROOM_HT_TILES, 6420, 680, DIR_RIGHT);+ /* below: Mettaton, the tiles, thirty seconds */+ m = obj_get(ACTOR_METTATON);+ NARRATE("* OH, HELLO AGAIN, DARLING!|* REMEMBER THIS PUZZLE? FROM\n WAY BACK IN SNOWDIN?|* THEN YOU KNOW THE RULES.\n* THIRTY SECONDS! GO!");+ tiles_state = TILES_ON, tiles_t = TILES_TIME, flavor = 0, flames_in = 0, last_r = last_c = -99;+ safe_x = pl.x, safe_y = pl.y;+ (void)m;+ EV_END;+}++static const int8_t ddx[4] = {0, 0, -1, 1}, ddy[4] = {1, -1, 0, 0};+static int ev_tile(Ev *c) {+ EV_BEGIN;+ c->v[0] = tile_act;+ if (c->v[0] == 1) {+ /* a shock (or the piranhas): back to the last tile stepped on */+ g_shake = 4;+ PL_WALK(safe_x, safe_y, 4);+ last_r = last_c = -99;+ return 1;+ }+ /* the soap: on to the next tile that way, unless a wall's there */+ c->v[1] = last_r + ddy[pl.dir], c->v[2] = last_c + ddx[pl.dir];+ c->v[3] = TX + c->v[2] * 20, c->v[4] = TY + c->v[1] * 20 - 14;+ if (!world_walkable(c->v[3] + 3, c->v[4] + 20, 14, 9, -1)) return 1;+ PL_WALK(c->v[3], c->v[4], 4);+ EV_END;+}++static int ev_tiles_end(Ev *c) {+ Obj *m = obj_get(ACTOR_METTATON);+ EV_BEGIN;+ c->v[0] = tiles_why;+ tiles_state = TILES_DONE;+ if (c->v[0] == 1) {+ NARRATE("* OH! YOU MADE IT ACROSS.\n* HOW... ANTICLIMACTIC.|* NO MATTER! I'LL BE THE MONSTER\n YOU MEET AT THE END!");+ } else {+ NARRATE("* (The flames close in...!)");+ SAY(FACE_ALPHYS, "* Ring...|* H-hang on! Turning off the\n firewall!");+ NARRATE("* (The flames die down.)");+ NARRATE("* TSK! FINE. THEN I'LL BE THE\n MONSTER YOU MEET!");+ }+ m = obj_get(ACTOR_METTATON);+ if (m->kind == OBJ_NONE) obj_mtt(pl.x + 60, pl.y + 29);+ else WALK(m, pl.x + 60, pl.y + 29, 6);+ BATTLE(FORM_MTT_TILES);+ set_flag(F_HT_TILES3, c->v[0]);+ NARRATE("* OHHH... I'M ALL OUT OF POWER.|* UNTIL NEXT TIME, DARLING!\n* STAY TUNED!");+ m = obj_get(ACTOR_METTATON);+ WALK(m, m->x, m->y - 220, 6);+ gone(obj_get(ACTOR_METTATON));+ EV_END;+}++static int ev_heats(Ev *c) {+ EV_BEGIN;+ if (flag(F_HT_HEATS3)) {+ NARRATE("* I'LL GET YOU NEXT TIME!!!");+ return 1;+ }+ NARRATE("* HEY!!! YOU!!!|* DO YOU REMEMBER MY NAME???@Yes@No");+ set_flag(F_HT_HEATS3, 1);+ NARRATE("* WHAT?!|* HOW COULD I LOSE SO EASILY?!\n* GRRR...!!!");+ EV_END;+}++static int ev_nicecream(Ev *c) {+ EV_BEGIN;+ if (flag(F_HT_GUARDS) == 1) {+ NARRATE("* Sorry, I'm all sold out!|* Those two guards bought every\n last one!");+ return 1;+ }+ NARRATE("* Nice Cream! Just 12G!\n* Want one?@Yes@No");+ if (CHOICE() == 1) return 1;+ if (sv.gold < 12) {+ NARRATE("* Oh... you're short on gold.");+ return 1;+ }+ if (!item_add(ITEM_NICE_CREAM)) {+ NARRATE("* Your hands are full!");+ return 1;+ }+ sv.gold = (uint16_t)(sv.gold - 12);+ NARRATE("* Here you go! Have a super day!");+ EV_END;+}++static int ev_elevator(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ NARRATE("* (The elevator down.)\n* (Get in?)@Yes@No");+ if (CHOICE() == 1) return 1;+ if (c->v[0]) {+ FADE_TO(ROOM_HT_COREVIEW2, 3770, 1348, DIR_DOWN);+ } else {+ FADE_TO(ROOM_HT_HOTDOG, 6966, 2380, DIR_DOWN);+ }+ EV_END;+}++static int ev_end(Ev *c) {+ EV_BEGIN;+ NARRATE("* (The MTT Resort is just up\n these stairs.)");+ set_flag(F_HT_FLOOR3, 1);+ sv.room = (int16_t)g_room, sv.x = 7530, sv.y = 420;+ save_write_auto();+ menu_end_open();+ EV_END;+}++int ht3_event(Ev *c) {+ switch (c->id) {+ case EV_BAKESALE3: return ev_bakesale(c);+ case EV_SHOOT3: return ev_shoot(c);+ case EV_HT3_CALL: return ev_call(c);+ case EV_MUFFET: return ev_muffet(c);+ case EV_MUSICAL: return ev_musical(c);+ case EV_TILE: return ev_tile(c);+ case EV_TILES3: return ev_tiles_end(c);+ case EV_HEATS3: return ev_heats(c);+ case EV_NICECREAM3: return ev_nicecream(c);+ case EV_HT3_ELEVATOR: return ev_elevator(c);+ case EV_HT3_END: return ev_end(c);+ }+ return -1;+}diff --git a/games/undertale/src/htmon.c b/games/undertale/src/htmon.cindex f2b1b060..41fc0a91 100644--- a/games/undertale/src/htmon.c+++ b/games/undertale/src/htmon.c@@ -3,6 +3,7 @@#include <stdio.h>#include "battle.h"#include "game.h"+#include "items.h"#include "gfx.h"#include "monsters.h"#include "res.h"@@ -233,6 +234,98 @@ static void draw_bomb(Battle *b, Monster *m, int x0, int y0) {uint8_t alpha = m->fade ? (uint8_t)max_i(0, 128 - m->fade * 4) : 255;gfx_sprite(s, (int)(g_frame / 8), x, y + half, 0, alpha);}+/* ---------------------------------------------------------------- Muffet: purple strings, spiders, pastries, her+ * pet. She lets Frisk go once her spiders send word (at turn 17), or at once if Frisk eats one of their treats.+ * Paying her makes her hits weaker (a hit less each time, and the price doubles); struggling three times halves it */+enum { MF_PRICE, MF_STRUGGLE, MF_TREAT }; /* (b->state[]) */+static void act_muffet(Battle *b, Monster *m, int act, char *t, int cap) {+ if (!b->state[MF_PRICE]) b->state[MF_PRICE] = 100;+ if (act == 0) { /* Pay */+ if (sv.gold >= b->state[MF_PRICE]) {+ sv.gold = (uint16_t)(sv.gold - b->state[MF_PRICE]);+ snprintf(t, (size_t)cap, "* You pay Muffet %dG.\n* Her attacks soften a little.", b->state[MF_PRICE]);+ m->at = (int16_t)max_i(1, m->at - 1);+ b->state[MF_PRICE] = (int16_t)min_i(b->state[MF_PRICE] * 2, 9000);+ } else {+ snprintf(t, (size_t)cap, "* You don't have %dG.\n* Muffet sighs, and lowers her price.", b->state[MF_PRICE]);+ b->state[MF_PRICE] = (int16_t)max_i(10, b->state[MF_PRICE] / 2);+ }+ } else { /* Struggle */+ if (++b->state[MF_STRUGGLE] == 3) {+ snprintf(t, (size_t)cap, "* You struggle with all your might.\n* Muffet halves her price, laughing.");+ b->state[MF_PRICE] = (int16_t)max_i(10, b->state[MF_PRICE] / 2);+ } else snprintf(t, (size_t)cap, "* You struggle against the web.\n* It's too sticky to get free.");+ }+}+static const char *talk_muffet(Battle *b, Monster *m) {+ if (b->state[MF_TREAT] == 1) {+ b->state[MF_TREAT] = 2;+ return "Oh? You\'ve had\none of our\ntreats~";+ }+ if (m->spare) return "My mistake,\ndeary~\nRun along\nnow~";+ if (b->turn == 1) return "Purple\nsuits you\nmuch better,\ndeary~";+ if (b->turn == 3 || b->turn == 7 || b->turn == 11) {+ static const char *const meal[3] = {"Time for\nbreakfast,\nmy pet~", "Time for\nlunch,\nmy pet~", "Time for\ndinner,\nmy pet~"};+ return meal[b->turn / 4];+ }+ static const char *const lines[] = {"Ahuhuhu~", "Someone paid\nme well for\nyour SOUL~", "The spiders\ntold me all\nabout you~",+ "Too stingy\nto buy a\ndonut~?", "Pay up, and\nI might go\neasy~"};+ return lines[rnd_n(5)];+}+static const char *flavor_muffet(Battle *b, Monster *m) {+ if (!m->spare && b->turn >= 17) {+ m->spare = true;+ return "* A spider brings Muffet a note.\n* She reads it... and smiles.";+ }+ if (m->spare) return "* Muffet isn't going to fight anymore.";+ return NULL;+}+static bool item_muffet(Battle *b, Monster *m, int item, char *t, int cap) {+ (void)t, (void)cap;+ /* a treat from the spiders' bake sale: it's eaten as ever, and she lets Frisk go */+ if (item == ITEM_SPIDER_DONUT || item == ITEM_SPIDER_CIDER) m->spare = true, b->state[MF_TREAT] = 1;+ return false;+}+static int attack_muffet(Battle *b, Monster *m) {+ if (m->spare) return ATK_NONE;+ if (b->turn == 3 || b->turn == 7 || b->turn == 11) return ATK_MUFFET_PET;+ static const uint8_t seq[3] = {ATK_MUFFET_SPIDERS, ATK_MUFFET_CROISSANTS, ATK_MUFFET_DONUTS};+ return seq[(b->turn - 1) % 3];+}++/* ---------------------------------------------------------------- Mettaton, after the tile puzzle: no hurting him;+ * Alphys's yellow button (ACT) turns the SOUL yellow, and its shots wear him down */+enum { MT_YELLOW, MT_HITS }; /* (b->state[]) */+static void act_mtt_tiles(Battle *b, Monster *m, int act, char *t, int cap) {+ (void)m;+ if (act == 0) snprintf(t, (size_t)cap, "* You yell...\n* Nothing happens.");+ else {+ snprintf(t, (size_t)cap, "* You press the yellow button.\n* The phone hums near Mettaton...!");+ b->state[MT_YELLOW] = 1;+ }+}+static const char *talk_mtt_tiles(Battle *b, Monster *m) {+ (void)m;+ if (b->state[MT_HITS] >= 6) return "OH NO...\nI\'M OUT OF\nPOWER?!";+ if (b->state[MT_YELLOW] && b->state[MT_HITS]) return "THAT\nBUTTON IS\nCHEATING!";+ if (b->turn <= 1) return "NOW FOR\nTHE GRAND\nFINALE!";+ static const char *const lines[] = {"NO MORE\nPUZZLES,\nDARLING!", "STAY\nTUNED!", "THE\nRATINGS\nARE GREAT!"};+ return lines[rnd_n(3)];+}+static const char *flavor_mtt_tiles(Battle *b, Monster *m) {+ (void)m;+ if (b->turn == 2 && !b->state[MT_YELLOW]) return "* Alphys calls: \"The yellow button!\n It's in your ACT menu!\"";+ if (b->turn >= 2 && !b->state[MT_YELLOW]) return "* Your phone's ACT menu is glowing.";+ return NULL;+}+static bool hit_mtt_tiles(Battle *b, Monster *m, int dmg) {+ (void)b, (void)dmg;+ m->dmg_shown = 0; /* (MISS: metal) */+ return true;+}+static int attack_mtt_tiles(Battle *b, Monster *m) { (void)m; return b->state[MT_YELLOW] ? ATK_MTT_YELLOW : ATK_MTT_BOXES; }+static bool ends_mtt_tiles(Battle *b, Monster *m) { (void)m; return b->state[MT_HITS] >= 6; }+#define BOMB(nm, chk) {.name = nm, .hp = 1, .idle_speed = 8, .check = chk, .acts = {"Defuse"}, .nacts = 1, \.flags = MF_BOSS | MF_NOT_KILLABLE, .act = act_bomb, .talk = talk_bomb, .attack = attack_bomb, \.flavor = flavor_bomb, .on_hit = hit_bomb, .draw = draw_bomb}@@ -291,6 +384,20 @@ static const MonDef ht_defs[MON_COUNT - MON_WF_COUNT] = {.neutral = {"* Sweat drips from 02's armor.", "* 02 is clenching his fists.", "* Smells like a locker room."},.flags = MF_BOSS, .act = act_rg, .talk = talk_rg, .attack = attack_rg, .flavor = flavor_rg},[MON_BOMB - MON_WF_COUNT] = BOMB("Bomb", ""),+ [MON_MUFFET - MON_WF_COUNT] = {+ .name = "Muffet", .spare_gold = 100, .hp = 1250, .at = 8, .df = 0, .exp = 300, .gold = 100, .spr_idle = SPR_MUFFET_B,+ .spr_hurt = SPR_MUFFET_HURT, .idle_speed = 5, .check = "If she asks you up to her parlor, say no thanks.",+ .acts = {"Pay", "Struggle"}, .nacts = 2,+ .neutral = {"* Muffet pours herself a cup of tea.", "* Muffet counts her money, twice.",+ "* Smells like cobwebs and fresh pastry."},+ .flags = MF_BOSS, .act = act_muffet, .talk = talk_muffet, .attack = attack_muffet, .flavor = flavor_muffet,+ .on_item = item_muffet},+ [MON_MTT_TILES - MON_WF_COUNT] = {+ .name = "Mettaton", .hp = 9999, .at = 8, .df = 0, .spr_idle = SPR_MTT_B, .spr_hurt = SPR_MTT_B, .idle_speed = 6,+ .check = "Still made of metal. Still can't be hurt.", .acts = {"Yell", "Yellow"}, .nacts = 2,+ .neutral = {"* Mettaton.", "* Mettaton strikes a pose."},+ .flags = MF_BOSS | MF_NOT_KILLABLE, .act = act_mtt_tiles, .talk = talk_mtt_tiles, .attack = attack_mtt_tiles,+ .flavor = flavor_mtt_tiles, .on_hit = hit_mtt_tiles, .ends = ends_mtt_tiles},};const MonDef *ht_mon_def(int id) { return id == MON_BOMB ? &bomb_defs[g_bomb_kind] : &ht_defs[id - MON_WF_COUNT]; }@@ -306,6 +413,8 @@ static const Form ht_forms[FORM_COUNT - FORM_WF_COUNT] = {[FORM_LASERS - FORM_WF_COUNT] = {{MON_METTATON}, 1, ""},[FORM_RGUARDS - FORM_WF_COUNT] = {{MON_RG01, MON_RG02}, 2, "* The Royal Guards attack!"},[FORM_BOMB - FORM_WF_COUNT] = {{MON_BOMB}, 1, ""},+ [FORM_MUFFET - FORM_WF_COUNT] = {{MON_MUFFET}, 1, "* Muffet blocks the way!"},+ [FORM_MTT_TILES - FORM_WF_COUNT] = {{MON_MTT_TILES}, 1, "* Mettaton attacks!"},};const Form *ht_form(int form) { return form == FORM_BOMB ? &bomb_forms[g_bomb_kind] : &ht_forms[form - FORM_WF_COUNT]; }@@ -476,13 +585,108 @@ static void atk_rg_team(int t) {}}-int ht_attack_length(int atk) { (void)atk; return 160; }+/* Muffet's: spiders crawl along the strings (riding them when they're pulled); croissants thrown along one come+ * back; donuts bounce about the board; and at mealtimes her pet waits at the bottom while the strings are pulled down+ * to it */+static void spider_on(int string, bool left, int speed) {+ Bullet *b = shot(SPR_SPIDER_B, left ? bx0() - 6 : bx1() + 6, soul_string_y(string), (left ? 1 : -1) * speed, 0);+ if (b) b->kind = BK_SCRIPT, b->a = (int16_t)string, b->flags |= BF_NOCLIP, b->r = 3, b->life = 260;+}+static void spiders_ride(void) {+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || b->spr != SPR_SPIDER_B) continue;+ b->x += b->vx, b->y = soul_string_y(b->a) * FX;+ if (++b->t >= b->life) b->kind = BK_NONE;+ }+}+static void atk_muffet_spiders(int t) {+ if (t < 130 && t % 14 == 0) spider_on(rnd_n(NSTRINGS), rnd_n(2), P(2));+ spiders_ride();+}+static void atk_muffet_croissants(int t) {+ if (t < 110 && t % 26 == 0) {+ bool left = rnd_n(2);+ Bullet *b = shot(SPR_CROISSANT, left ? bx0() - 6 : bx1() + 6, soul_string_y(rnd_n(NSTRINGS)), (left ? 1 : -1) * P(4), 0);+ if (b) b->ax = left ? -1 : 1, b->r = 4, b->flags |= BF_NOCLIP, b->life = 140, b->angle = left ? 128 : 0;+ }+}+static void atk_muffet_donuts(int t) {+ if (t < 110 && t % 20 == 0) {+ bool left = (t / 20) % 2;+ Bullet *b = shot(SPR_DONUT, left ? bx0() + 4 : bx1() - 4, by0() + 4, (left ? 1 : -1) * P(2), P(2));+ if (b) b->kind = BK_SCRIPT, b->a = 3, b->r = 4, b->flags |= BF_NOCLIP;+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || b->spr != SPR_DONUT) continue;+ b->x += b->vx, b->y += b->vy, b->t++;+ bool hx = b->x < P(bx0() + 2) || b->x > P(bx1() - 2), hy = b->y < P(by0() + 2) || b->y > P(by1() - 2);+ if (b->t > 6 && (hx || hy)) {+ if (--b->a <= 0) b->kind = BK_NONE;+ if (hx) b->vx = -b->vx;+ if (hy) b->vy = -b->vy;+ }+ }+}+static void atk_muffet_pet(int t) {+ if (t == 0) {+ Bullet *p = shot(SPR_MUFFET_PET, board_cx(), by1() + 8, 0, 0);+ if (p) p->flags |= BF_BOX | BF_NOCLIP, p->w = 90, p->h = 26, p->anim = 6, p->life = 150, p->dmg = 4;+ }+ /* the strings, down towards it (round again from the top) */+ soul_strings_shift += P(1) / 2;+ if (t < 130 && t % 30 == 0) spider_on(rnd_n(NSTRINGS), rnd_n(2), P(1));+ spiders_ride();+}++/* Mettaton's: rows of boxes falling, a gap in each; turned yellow, the SOUL shoots at him as he glides about over+ * the board (six hits, and he's out of power), a few boxes still falling */+static void atk_mtt_boxes(int t) {+ if (t < 130 && t % 26 == 0) {+ static const uint8_t gaps[6] = {1, 4, 2, 5, 0, 3};+ int n = (bx1() - bx0()) / 16, gap = gaps[(t / 26) % 6] % n;+ for (int k = 0; k < n; k++) {+ if (k == gap || k == gap + 1) continue;+ Bullet *b = shot(SPR_PRESENT, bx0() + 8 + k * 16, by0() - 8, 0, P(2));+ if (b) b->r = 5, b->flags |= BF_NOCLIP, b->life = 90;+ }+ }+}+static Bullet *mtt_target;+static void atk_mtt_yellow(int t) {+ if (t == 0) {+ mtt_target = shot(SPR_MTTMINI, board_cx(), by0() + 12, P(3) / 2, 0);+ if (mtt_target) mtt_target->kind = BK_SCRIPT, mtt_target->flags |= BF_HARMLESS;+ }+ Bullet *m = mtt_target;+ if (!m || m->kind != BK_SCRIPT || m->spr != SPR_MTTMINI) return;+ m->x += m->vx;+ if (m->x < P(bx0() + 10) || m->x > P(bx1() - 10)) m->vx = -m->vx;+ if (m->c) m->c--, m->alpha = m->c % 2 ? 90 : 255;+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *s = &bullets[i];+ if (s->kind == BK_NONE || !(s->flags & BF_PLAYER)) continue;+ if (abs_i(s->x - m->x) < P(9) && abs_i(s->y - m->y) < P(11)) {+ s->kind = BK_NONE;+ bt.state[MT_HITS]++, m->c = 10;+ }+ }+ if (t < 130 && t % 40 == 20) {+ Bullet *b = shot(SPR_PRESENT, m->x / FX, m->y / FX + 10, 0, P(2));+ if (b) b->r = 5, b->flags |= BF_NOCLIP, b->life = 80;+ }+}++int ht_attack_length(int atk) { return atk == ATK_MUFFET_PET ? 150 : 160; }void ht_attack_run(Battle *b, int atk, int t) {(void)b;if (t < 0) {- board_set(atk == ATK_TSUNDER_BOMBS || atk == ATK_PYROPE_ROPE ? 150 : 120, 100);- soul_set_mode(SOUL_RED);+ bool muffet = atk >= ATK_MUFFET_SPIDERS && atk <= ATK_MUFFET_PET;+ board_set(muffet ? 190 : atk == ATK_TSUNDER_BOMBS || atk == ATK_PYROPE_ROPE ? 150 : atk == ATK_MTT_BOXES ? 140 : 120,+ muffet ? 90 : 100);+ soul_set_mode(muffet ? SOUL_PURPLE : atk == ATK_MTT_YELLOW ? SOUL_YELLOW : SOUL_RED);return;}switch (atk) {@@ -493,5 +697,11 @@ void ht_attack_run(Battle *b, int atk, int t) {case ATK_PYROPE_BOMBS: atk_pyrope_bombs(t); break;case ATK_PYROPE_ROPE: atk_pyrope_rope(t); break;case ATK_RG_TEAM: atk_rg_team(t); break;+ case ATK_MUFFET_SPIDERS: atk_muffet_spiders(t); break;+ case ATK_MUFFET_CROISSANTS: atk_muffet_croissants(t); break;+ case ATK_MUFFET_DONUTS: atk_muffet_donuts(t); break;+ case ATK_MUFFET_PET: atk_muffet_pet(t); break;+ case ATK_MTT_BOXES: atk_mtt_boxes(t); break;+ case ATK_MTT_YELLOW: atk_mtt_yellow(t); break;}}diff --git a/games/undertale/src/menu.c b/games/undertale/src/menu.cindex 4d4507dd..d4668a4a 100644--- a/games/undertale/src/menu.c+++ b/games/undertale/src/menu.c@@ -383,7 +383,7 @@ void menu_gameover_open(void) {void menu_end_open(void) {g_mode = MODE_END;t = 0;- writer_start(&w, "Up the elevator, past the news\nand all its bombs...|The rest of the underground\nis still to come...", 40, 90, FONT_MAIN);+ writer_start(&w, "Up to the MTT Resort, past\nMuffet and the musical...|The rest of the underground\nis still to come...", 40, 90, FONT_MAIN);w.speed = 2;}diff --git a/games/undertale/src/monsters.c b/games/undertale/src/monsters.cindex 66c0dec1..32198797 100644--- a/games/undertale/src/monsters.c+++ b/games/undertale/src/monsters.c@@ -320,7 +320,7 @@ int form_setup(int form, Battle *b) {}/* Toriel and Flowey can't be fled from; Napstablook can */if (form == FORM_TORIEL || form == FORM_FLOWEY || form == FORM_PAPYRUS || form == FORM_MAD_DUMMY ||- form == FORM_RGUARDS || form == FORM_BOMB)+ form == FORM_RGUARDS || form == FORM_BOMB || form == FORM_MUFFET || form == FORM_MTT_TILES)b->no_flee = true;b->captures = form == FORM_PAPYRUS;return 0;diff --git a/games/undertale/src/monsters.h b/games/undertale/src/monsters.hindex ddec76ac..71abbc63 100644--- a/games/undertale/src/monsters.h+++ b/games/undertale/src/monsters.h@@ -12,7 +12,8 @@ enum {/* Waterfall (wfmon.c) */MON_AARON = MON_SNOW_COUNT, MON_WOSHUA, MON_MOLDBYGG, MON_SHYREN, MON_MAD_DUMMY, MON_TEMMIE, MON_UNDYNE, MON_WF_COUNT,/* Hotland (htmon.c) */- MON_VULKIN = MON_WF_COUNT, MON_TSUNDERPLANE, MON_PYROPE, MON_METTATON, MON_RG01, MON_RG02, MON_BOMB, MON_COUNT+ MON_VULKIN = MON_WF_COUNT, MON_TSUNDERPLANE, MON_PYROPE, MON_METTATON, MON_RG01, MON_RG02, MON_BOMB, MON_MUFFET,+ MON_MTT_TILES, MON_COUNT};/* formations: who is fought */@@ -29,7 +30,7 @@ enum {FORM_MOLDBYGG_WOSHUA, FORM_SHYREN, FORM_MAD_DUMMY, FORM_TEMMIE, FORM_TEMMIE_MOLDBYGG, FORM_UNDYNE, FORM_WF_COUNT,/* Hotland (Mettaton's shows and a laser's alarm play their own way: htshows.c) */FORM_VULKIN = FORM_WF_COUNT, FORM_TSUNDERPLANE, FORM_TSUNDER_VULKIN, FORM_PYROPE, FORM_PYROPE2, FORM_MTT_QUIZ,- FORM_MTT_COOK, FORM_LASERS, FORM_RGUARDS, FORM_BOMB, FORM_COUNT+ FORM_MTT_COOK, FORM_LASERS, FORM_RGUARDS, FORM_BOMB, FORM_MUFFET, FORM_MTT_TILES, FORM_COUNT};enum {@@ -47,7 +48,8 @@ enum {ATK_UNDYNE_ARROWS, ATK_UNDYNE_SPEARS, ATK_WF_COUNT,/* Hotland */ATK_VULKIN_THUNDER = ATK_WF_COUNT, ATK_VULKIN_FIRE, ATK_TSUNDER_BOMBS, ATK_TSUNDER_DIVE, ATK_PYROPE_BOMBS,- ATK_PYROPE_ROPE, ATK_RG_TEAM, ATK_COUNT+ ATK_PYROPE_ROPE, ATK_RG_TEAM, ATK_MUFFET_SPIDERS, ATK_MUFFET_CROISSANTS, ATK_MUFFET_DONUTS, ATK_MUFFET_PET,+ ATK_MTT_BOXES, ATK_MTT_YELLOW, ATK_COUNT};/* a formation: up to three monsters, and what the first turn says */diff --git a/games/undertale/src/rooms.c b/games/undertale/src/rooms.cindex 669b137c..980eab3b 100644--- a/games/undertale/src/rooms.c+++ b/games/undertale/src/rooms.c@@ -23,6 +23,7 @@ void room_setup(int room, int from) {wf3_setup(room, from);ht1_setup(room, from);ht2_setup(room, from);+ ht3_setup(room, from);}/* each frame Frisk can walk: what a room watches (a rock on its switch, a cracked floor) */@@ -34,6 +35,7 @@ void room_update(void) {wf3_update();ht1_update();ht2_update();+ ht3_update();}/* what a room draws on its floor, under everything (world.c) */@@ -42,15 +44,21 @@ void room_draw_floor(void) {snow2_draw();ht1_draw();ht2_draw();+ ht3_draw();}/* what a room draws over everything (a clock) */-void room_draw_top(void) { ht2_draw_top(); }+void room_draw_top(void) {+ ht2_draw_top();+ ht3_draw_top();+}/* a pushed rock that may go where Frisk can't (a bridge seed into the water), and what happens once it has */bool room_rock_enters(Obj *o, int x, int y) { return wf_seed_enters(o, x, y); }void room_rock_moved(Obj *o) { wf_seed_moved(o); }+int room_speed(int x, int y) { return ht3_speed(x, y); }+bool room_ice(int x, int y) {const RoomInfo *ri = world_room_info();if (!ri || !ri->ice) return false;diff --git a/games/undertale/src/shoot.c b/games/undertale/src/shoot.cindex 1a336f0b..7e74cad3 100644--- a/games/undertale/src/shoot.c+++ b/games/undertale/src/shoot.c@@ -2,8 +2,8 @@** A grid of blocks stands between Frisk's ship, below, and the target, above. Each arrow pushes every dark block one* cell that way, where there's room inside the grid; the light blocks never move. Z shoots straight up: a shot- * breaks the first dark block it meets, a light one stops it, and a clear way hits the target. Two shots a try:- * out of them, it starts over. (The rules are worked out from the solutions the Undertale Wiki gives for them; the+ * breaks the first dark block it meets, a light one stops it, and a clear way hits the target. Two shots a try on+ * the first floor, one on the third: out of them, it starts over. (The rules are worked out from the solutions the Undertale Wiki gives for them; the* grids are the game's, as its screenshots show them.) */#include <string.h>#include "game.h"@@ -13,15 +13,16 @@#include "shoot.h"typedef struct {- uint8_t w, h, ship;+ uint8_t w, h, ship, shots;const char *rows[6]; /* '#' a light block, 'o' a dark one, ' ' nothing */} Puzzle;static const Puzzle puzzles[SHOOT_COUNT] = {- [SHOOT_RIGHT] = {3, 3, 1, {"#o#", " ", "#o#"}},- [SHOOT_LEFT] = {4, 4, 2, {"# #", "ooo ", " #o#", "#oo "}},+ [SHOOT_RIGHT] = {3, 3, 1, 2, {"#o#", " ", "#o#"}},+ [SHOOT_LEFT] = {4, 4, 2, 2, {"# #", "ooo ", " #o#", "#oo "}},+ [SHOOT_NORTH] = {5, 5, 2, 1, {"## o#", " o # ", " #o o", " o o#", "## ##"}},+ [SHOOT_SOUTH] = {5, 4, 3, 1, {"###o ", " o#", "###o ", "###o#"}},};#define CELL 24-#define SHOTS 2static int id, shots, result, t, shot_y, fail_t;static char grid[6][6];@@ -31,7 +32,7 @@ static void reset(void) {const Puzzle *p = &puzzles[id];for (int y = 0; y < p->h; y++)for (int x = 0; x < p->w; x++) grid[y][x] = p->rows[y][x];- shots = SHOTS, shot_y = -1, fail_t = 0, won = false;+ shots = p->shots, shot_y = -1, fail_t = 0, won = false;}void shoot_open(int which) {diff --git a/games/undertale/src/shoot.h b/games/undertale/src/shoot.hindex 87256481..5aedca33 100644--- a/games/undertale/src/shoot.h+++ b/games/undertale/src/shoot.h@@ -2,7 +2,7 @@#ifndef UT_SHOOT_H#define UT_SHOOT_H#include <stdint.h>-enum { SHOOT_RIGHT, SHOOT_LEFT, SHOOT_COUNT };+enum { SHOOT_RIGHT, SHOOT_LEFT, SHOOT_NORTH, SHOOT_SOUTH, SHOOT_COUNT }; /* (the first floor's, then the third's) */void shoot_open(int id); /* MODE_SHOOT until solved or left */int shoot_result(void); /* 1 solved, 0 left */void shoot_update(uint32_t keys, uint32_t pressed);diff --git a/games/undertale/src/world.c b/games/undertale/src/world.cindex 6af7e448..ebc45f4d 100644--- a/games/undertale/src/world.c+++ b/games/undertale/src/world.c@@ -286,7 +286,8 @@ static void player_move(uint32_t keys, uint32_t pressed) {slide_dx = slide_dy = 0;}bool moved = false;- for (int i = 0; i < SPEED; i++) {+ int sp = room_speed(pl.x + PBX + PBW / 2, pl.y + PBY + PBH / 2);+ for (int i = 0; i < sp; i++) {if (dx) moved |= step(dx, 0, !dy);if (dy) moved |= step(0, dy, !dx);}diff --git a/games/undertale/src/world.h b/games/undertale/src/world.hindex a217bfd3..84eb9595 100644--- a/games/undertale/src/world.h+++ b/games/undertale/src/world.h@@ -86,6 +86,7 @@ Obj *obj_rock(int x, int y, int name, int event); /* pushed by walking into itvoid obj_set_box(Obj *o, int bx, int by, int bw, int bh);bool near_frisk(const Obj *o, int d); /* within d pixels (their feet) */bool room_ice(int x, int y); /* rooms.c: ice there (Frisk slides) */+int room_speed(int x, int y); /* rooms.c: Frisk's steps a frame there (3; webs slow him) *//* rooms.c: a pushed rock that the floor stops (it may go into water, a bridge seed), then where it went */bool room_rock_enters(Obj *o, int x, int y);void room_rock_moved(Obj *o);diff --git a/games/undertale/tests/check.py b/games/undertale/tests/check.pyindex e72f39c3..06340696 100644--- a/games/undertale/tests/check.py+++ b/games/undertale/tests/check.py@@ -34,9 +34,10 @@ FORM_SNOWDRAKE, FORM_PAPYRUS = 19, 31(FORM_AARON, FORM_WOSHUA, FORM_WOSHUA_AARON, FORM_MOLDBYGG, FORM_MOLDBYGG_MOLDSMAL, FORM_MOLDBYGG_WOSHUA, FORM_SHYREN,FORM_MAD_DUMMY, FORM_TEMMIE, FORM_TEMMIE_MOLDBYGG, FORM_UNDYNE) = range(32, 43)(FORM_VULKIN, FORM_TSUNDERPLANE, FORM_TSUNDER_VULKIN, FORM_PYROPE, FORM_PYROPE2, FORM_MTT_QUIZ, FORM_MTT_COOK,- FORM_LASERS, FORM_RGUARDS, FORM_BOMB) = range(43, 53)+ FORM_LASERS, FORM_RGUARDS, FORM_BOMB, FORM_MUFFET, FORM_MTT_TILES) = range(43, 55)ITEM_OLD_TUTU, ITEM_BALLET_SHOES, ITEM_QUICHE, ITEM_PUNCH_CARD, ITEM_ARTIFACT, ITEM_ASTRONAUT_FOOD = range(17, 23)ITEM_BURNT_PAN, ITEM_INSTANT_NOODLES, ITEM_HOT_DOG, ITEM_STAINED_APRON = 28, 29, 30, 31+ITEM_NICE_CREAM = 13def run(args, frames, saves=None, what=""):@@ -148,6 +149,12 @@ check(s and s["mode"] == MODE_WORLD and s["kills"] == 0 and s["gold"] == 100,for how in ("act:1", "fight"):s = run(["--god", "--battle", str(FORM_BOMB), "--path", how], 9000, what=f"a bomb, {how}")check(s and s["mode"] == MODE_WORLD and s["kills"] == 0, f"a bomb: {how} did not defuse it: {s}")+# Muffet (no running from her): spared once her spiders send word, her 100G; Mettaton after the tile puzzle: ACT+# Yellow, and the yellow SOUL's shots drain his power+s = run(["--god", "--battle", str(FORM_MUFFET), "--path", "spare"], 9000, what="Muffet, spared")+check(s and s["mode"] == MODE_WORLD and s["kills"] == 0 and s["gold"] == 100, f"Muffet was not spared: {s}")+s = run(["--god", "--battle", str(FORM_MTT_TILES), "--path", "act:2"], 4000, what="Mettaton's yellow button")+check(s and s["mode"] == MODE_WORLD and s["kills"] == 0, f"Mettaton's fight did not end with the yellow button: {s}")# the shop in Snowdin: a Cinnamon Bunny for 25G; Papyrus's date: his phone numbers = run(["--name", "Frisk", "--noenc", "--room", str(ROOMS["SNOWTOWN"]), "--at", "446,1092", "--gold", "100", "--keys",@@ -237,12 +244,12 @@ if not QUICK:check(ITEM_INSTANT_NOODLES in s["items"], f"Hotland: the noodles not taken: {s['items']}")# Hotland's second floor: Heats Flamesman, Sans's hot dog, the apron, the Art Club's room, the belt and vent puzzles,-# the Bad Opinion Zone, the Royal Guards spared, Mettaton's news report, up to the elevator+# the Bad Opinion Zone, the Royal Guards spared, Mettaton's news report, up the elevator to the third floorif not QUICK:s = run(["--name", "Frisk", "--noenc", "--god", "--gold", "100", "--room", str(ROOMS["HT_HOTDOG"]), "--at", "6966,2380","--path-file", os.path.join(HERE, "hotland2.path")], 13000, what="Hotland's second floor")- check(s and s["mode"] == MODE_END and s["room"] == ROOMS["HT_COREVIEW2"],- f"Hotland's second floor did not end at the elevator: {s}")+ check(s and s["mode"] == MODE_WORLD and s["room"] == ROOMS["HT_L3"],+ f"Hotland's second floor did not end up the elevator, on the third floor: {s}")if s:for name, v in (("HT_HEATS", 1), ("HT_APRON", 1), ("HT_CALL_BELT", 1), ("HT_BELT", 1), ("HT_VENTPUZ", 1),("HT_CALL_BOZ", 1), ("HT_GUARDS", 1), ("HT_NEWS", 2), ("HT_CALL_CORE2", 1), ("HT_FLOOR2", 1)):@@ -252,6 +259,22 @@ if not QUICK:for item in (ITEM_HOT_DOG, ITEM_STAINED_APRON):check(item in s["items"], f"Hotland's second floor: item {item} not picked up: {s['items']}")+# Hotland's third floor: the bake sale, the vent islands, both shooting puzzles (the Diamond Boys, Alphys's anime),+# the belts past the drones, Muffet spared, Mettaton's musical, the tile puzzle and his fight, the crossroads (a Nice+# Cream, Heats Flamesman), up to the MTT Resort+if not QUICK:+ s = run(["--name", "Frisk", "--noenc", "--god", "--gold", "100", "--room", str(ROOMS["HT_L3"]), "--at", "3770,842",+ "--path-file", os.path.join(HERE, "hotland3.path")], 14000, what="Hotland's third floor")+ check(s and s["mode"] == MODE_END and s["room"] == ROOMS["HT_CROSS3"],+ f"Hotland's third floor did not end by the MTT Resort: {s}")+ if s:+ for name, v in (("HT_CALL_HUB3", 1), ("HT3_PUZ_N", 1), ("HT3_PUZ_S", 1), ("HT_ANIME", 1), ("HT_MUFFET", 1),+ ("HT_MUSICAL", 1), ("HT_TILES3", 1), ("HT_HEATS3", 1), ("HT_FLOOR3", 1)):+ check(flag(s, name) == v, f"Hotland's third floor: F_{name} is {flag(s, name)}, not {v}")+ check(s["kills"] == 0, f"Hotland's third floor: {s['kills']} killed on the friendly way")+ check(s["gold"] == 188, f"Hotland's third floor: Muffet's gold or the Nice Cream went wrong: {s['gold']}")+ check(ITEM_NICE_CREAM in s["items"], f"Hotland's third floor: no Nice Cream: {s['items']}")+if failures:print("\n".join("FAIL " + f for f in failures))sys.exit(1)diff --git a/games/undertale/tests/hotland2.path b/games/undertale/tests/hotland2.pathindex 6ff35c60..545bdc7a 100644--- a/games/undertale/tests/hotland2.path+++ b/games/undertale/tests/hotland2.path@@ -100,7 +100,7 @@ act:1talkw3700talk-# up past the news to the CORE again (Alphys's call), and the elevator up, where the game now ends+# up past the news to the CORE again (Alphys's call), and the elevator up to the third floorgo:4590,1770go:4600,15604600,1500diff --git a/games/undertale/tests/hotland3.path b/games/undertale/tests/hotland3.pathnew file mode 100644index 00000000..3f1360ea--- /dev/null+++ b/games/undertale/tests/hotland3.path@@ -0,0 +1,222 @@+# Hotland's third floor, out of the elevator (play it with --room 150 --at 3770,842 --name Frisk --noenc --god+# --gold 100): the spiders' bake sale (too dear for Frisk), Alphys's call by the vent islands+w30+go:4150,870+u+z+talk+pick:0+talk+go:4555,870+4575,870+talk+# the islands' vents to the north walkway: right, up, right, down, down, right, up, right, up, up, left, up+vent:4600,870+w20+vent:4660,850+w20+vent:4676,786+w20+vent:4740,806+w20+vent:4740,886+w20+vent:4756,946+w20+vent:4820,930+w20+vent:4836,866+w20+vent:4900,850+w20+vent:4900,770+w20+vent:4884,706+w20+vent:4820,690+w30+# the north puzzle (left, right, then shoot), and the Diamond Boys+go:4820,175+u+z+w10+l+w4+r+w4+z+w60+talk+w30+# back down; the vents to the south walkway: down, left, down, down, right, right, down, left, down+go:4820,600+4820,650+w30+vent:4820,726+w20+vent:4804,786+w20+vent:4740,806+w20+vent:4740,886+w20+vent:4756,946+w20+vent:4836,946+w20+vent:4900,966+w20+vent:4884,1026+w20+vent:4820,1046+w30+# the belts round the south, ridden without a step past the drones' blue lasers; the south puzzle (left, up, left,+# left, right, shoot), and Alphys asks about anime+go:4830,1385+4830,1400+w340+go:5520,1400+go:5530,1148+u+z+w10+l+w4+u+w4+l+w4+l+w4+r+w4+z+w60+talk+pick:0+talk+w30+# back along the top belt, up to the islands; east: left, up, right, right, right, up, right; through the door+go:5520,1400+5480,1400+w10+go:5400,1335+w200+go:4830,1200+4830,1090+w30+vent:4804,1026+w20+vent:4740,1010+w20+vent:4756,946+w20+vent:4836,946+w20+vent:4916,946+w20+vent:4980,930+w20+vent:4996,866+w30+go:5230,712+5230,690+w30+go:5400,462+5440,462+w20+# Muffet's lair: the webs, Muffet (spared once the spiders send word)+go:5650,455+go:6230,455+spare+talk+# Mettaton's musical, the trapdoor; the tile puzzle against the clock (each purple slides Frisk on, so the steps+# aim where the slides end); Mettaton's fight, his power drained with the yellow button+go:6630,455+6660,455+w20+go:6740,455+6790,455+talk+w30+talk+go:6620,646+6640,646+6640,626+6660,626+6700,626+6700,646+6720,646+6740,646+6740,666+6760,666+6780,666+6840,666+6860,666+6860,626+6880,626+6900,626+6900,646+6900,666+6920,666+6940,666+6940,646+6980,646+6980,626+7000,626+7000,666+7020,666+7040,666+7040,626+7060,626+7060,666+7080,666+7100,666+7120,666+7120,646+7140,646+7140,626+7120,626+7120,646+7120,666+7140,666+7180,666+7180,626+7240,626+7260,626+7260,646+7260,666+7280,666+7300,666+7320,666+7340,666+7340,646+7340,626+7340,606+7360,606+7380,606+7380,626+7380,646+7380,666+7400,666+7430,666+act:2+talk+w30+# the crossroads: a Nice Cream, Heats Flamesman's name, and the stairs north to the MTT Resort, where the game+# now ends+go:7550,560+7550,530+w30+go:7470,408+u+z+talk+go:8030,430+r+z+pick:0+talk+go:7550,420+7550,276+w60diff --git a/games/undertale/tools/rooms.py b/games/undertale/tools/rooms.pyindex 5bf6745e..3baa84f4 100644--- a/games/undertale/tools/rooms.py+++ b/games/undertale/tools/rooms.py@@ -152,6 +152,15 @@ HT_KITCHEN = []HT_VENTS_MAGMA = [(3120, 4000), (3362, 4000), (3503, 4060), (3420, 4180), (3225, 4240), (3325, 4240), (3525, 4240)]HT_VENTS_HUB = [(4820, 3620), (4820, 3560), (4740, 3620), (4900, 3620)]HT_VENTS_ISLE = [(4940, 3120), (5060, 3120), (5180, 3120)]+# the third floor: the vent islands (their top-left; the grates' arrows point the way each blows), the grates off+# them (the corridor's end, the walkways north and south, the platform east), the stage's purples, the tiles' colours+# (red left out: its tiles are walls)+HT3_ISLES = [(4720, 700), (4800, 700), (4880, 700), (4640, 780), (4720, 780), (4800, 780), (4880, 780), (4960, 780),+ (4640, 860), (4720, 860), (4800, 860), (4880, 860), (4960, 860), (4640, 940), (4720, 940), (4800, 940),+ (4880, 940), (4960, 940), (4720, 1020), (4800, 1020), (4880, 1020)]+HT3_GRATES = [(4600, 880), (4820, 660), (4820, 1100), (5040, 880)]+HT_STAGE = [(163, 73, 164), (132, 53, 125), (55, 44, 103)]+HT_TILES = [(64, 64, 255), (255, 255, 128), (255, 192, 192), (156, 255, 121), (255, 193, 74), (192, 0, 192)]# the vent puzzle's platforms (their top-left)HT_VENTPUZ = [(4620, 2160), (4520, 2260), (4620, 2260), (4720, 2260), (4520, 2360), (4620, 2360), (4520, 2460),(4620, 2460)]@@ -171,6 +180,10 @@ AREAS.append(dict(name="hotland", map="Hotland_map.png", floor=HT_FLOOR, margin=# the news report's bombs that move: the script on the belt (the belt repeats every 5 pixels), the basketball, the# glass of water (in front of a rock: the same rock, a row up)("copy", 4318, 1850, 24, 26, 4318, 1875), ("erase", 3999, 1565, 21, 20, "ring"), ("copy", 4118, 1576, 26, 24, 4118, 1616),+ # the third floor: the Diamond Boys (there once the north puzzle's done), Muffet in her web (the web repeats every+ # 60 pixels), Mettaton over the tiles, the Royal Guards by the Nice Cream (there if they were spared)+ ("erase", 4736, 414, 30, 40, "ring"), ("erase", 4890, 412, 30, 50, "ring"), ("copy", 6332, 452, 32, 50, 6272, 452),+ ("erase", 6400, 540, 50, 64, [(0, 0, 0)]), ("erase", 7578, 352, 84, 58, "ring"),# Undyne, fallen on the bridge in the heat (an object here, there only if she chased Frisk): the planks repeat# every 40 pixels("copy", 454, 6219, 50, 21, 534, 6219),@@ -554,6 +567,30 @@ ROOMS = [dict(name="ht_news", area="hotland", rect=(3760, 1540, 880, 500), title="Hotland", floor_colors=HT_STRIPE + HT_BELT,doors=[((3760, 1760, 6, 40), "ht_guards", (3670, 2030), "left")]),dict(name="ht_coreview2", area="hotland", rect=(3680, 1200, 960, 340), title="Hotland", floor_colors=HT_STRIPE),+ # the third floor: out of the elevator, the spider bake sale; the vent islands (both puzzles open the door east);+ # north to the Diamond Boys and a shooting puzzle; south over the belts, past the laser drones, to the other;+ # through the door, the spider entrance and Muffet's lair; Mettaton's musical, the tile puzzle below its stage;+ # the crossroads by the elevator R3, the MTT Resort north+ dict(name="ht_l3", area="hotland", rect=(3660, 740, 900, 240), title="Hotland", floor_colors=HT_HUB,+ fix=[("walk", 4556, 876, 28, 28)]),+ dict(name="ht_hub3", area="hotland", rect=(4560, 620, 740, 500), title="Hotland", floor_colors=HT_HUB,+ fix=[("walk", x, y, 60, 60) for x, y in HT3_ISLES] + [("walk", x - 4, y - 4, 28, 28) for x, y in HT3_GRATES],+ doors=[((5205, 700, 50, 6), "ht_spiderent", (5220, 525), "up")]),+ dict(name="ht_north3", area="hotland", rect=(4700, 140, 300, 480), title="Hotland", floor_colors=HT_HUB,+ fix=[("walk", 4808, 236, 44, 108)]),+ dict(name="ht_belts3", area="hotland", rect=(4780, 1120, 680, 500), title="Hotland", floor_colors=HT_HUB + HT_BELT),+ dict(name="ht_south3", area="hotland", rect=(5460, 940, 200, 680), title="Hotland", floor_colors=HT_HUB + HT_BELT,+ fix=[("walk", 5518, 1216, 44, 104)]),+ dict(name="ht_spiderent", area="hotland", rect=(5180, 400, 240, 170), title="Hotland", floor_colors=HT_HUB,+ doors=[((5205, 560, 50, 6), "ht_hub3", (5220, 704), "down")]),+ dict(name="ht_lair", area="hotland", rect=(5420, 300, 1220, 240), title="Hotland", open=True,+ floor_rects=[(5420, 461, 1220, 38)]),+ dict(name="ht_stage", area="hotland", rect=(6640, 180, 680, 360), title="Hotland", floor_colors=HT_STAGE,+ fix=[("walk", 6640, 461, 140, 38)]),+ dict(name="ht_tiles", area="hotland", rect=(6340, 540, 1280, 260), title="Hotland",+ floor_colors=HT_FLOOR + HT_BELT + HT_HUB + HT_TILES, fix=[("walk", 7522, 540, 56, 84)]),+ dict(name="ht_cross3", area="hotland", rect=(7320, 280, 820, 260), title="Hotland",+ fix=[("walk", 7522, 290, 56, 124), ("walk", 7522, 470, 56, 70)]),]# rooms one above the other through a dark doorway (tools/pack.py: apply_links); ("h", left, right, y, h): sidediff --git a/games/undertale/tools/sprites.py b/games/undertale/tools/sprites.pyindex e936c35b..3a9ce557 100644--- a/games/undertale/tools/sprites.py+++ b/games/undertale/tools/sprites.py@@ -198,6 +198,37 @@ def gen_debris():return [im]+def gen_croissant():+ # Muffet's croissants: a crescent, its horns to the left+ im = _img(14, 11)+ d = ImageDraw.Draw(im)+ d.ellipse([0, 0, 13, 10], fill=(255, 255, 255, 255))+ d.ellipse([-5, 2, 7, 8], fill=(0, 0, 0, 0))+ return [im]+++def gen_donut():+ im = _img(11, 11)+ d = ImageDraw.Draw(im)+ d.ellipse([0, 0, 10, 10], fill=(255, 255, 255, 255))+ d.ellipse([3, 3, 7, 7], fill=(0, 0, 0, 0))+ return [im]+++def gen_mttmini():+ # a small Mettaton for the yellow SOUL to shoot at: his box, its screen's grid, his wheel+ im = _img(16, 22)+ d = ImageDraw.Draw(im)+ d.rectangle([0, 0, 15, 15], fill=(170, 170, 170, 255), outline=(255, 255, 255, 255))+ d.rectangle([3, 3, 12, 10], fill=(255, 220, 40, 255))+ for k in range(4, 12, 2):+ d.line([(k, 3), (k, 10)], fill=(40, 40, 40, 255))+ d.line([(3, 7), (12, 7)], fill=(40, 40, 40, 255))+ d.rectangle([7, 16, 8, 18], fill=(200, 200, 200, 255))+ d.ellipse([4, 17, 11, 21], fill=(200, 30, 30, 255))+ return [im]++def gen_star():# the Royal Guards' stars: four pointsim = _img(9, 9)@@ -210,7 +241,8 @@ GEN = {"otile": gen_otile, "snowball": gen_snowball, "bone": gen_bone, "orb": ge"iceshard": gen_iceshard, "present": gen_present, "knife": gen_knife, "dogpaw": gen_dogpaw,"heartbullet": gen_heartbullet, "spear": gen_spear, "note": gen_note, "drop": gen_drop, "arm": gen_arm,"debris": gen_debris, "arrow": gen_arrow, "plane": gen_plane, "bomb": gen_bomb, "cloud": gen_cloud,- "bolt": gen_bolt, "star": gen_star}+ "bolt": gen_bolt, "star": gen_star, "croissant": gen_croissant, "donut": gen_donut,+ "mttmini": gen_mttmini}SNOW_CLEAR = [(133, 163, 216), (114, 129, 177), (139, 163, 186), (180, 192, 201), (195, 207, 216)]PAP_GIF = "move:Papyrus_screenshot_back_and_forth.gif:0,280,640,450:"@@ -228,7 +260,8 @@ SPRITES = [("savepoint", "demo:spr_savepoint", {"origin": (0, 0), "keep": True}),("flowey", "demo:spr_flowey", {"origin": (0, 0), "keep": True}),# the SOUL, 8 x 8 as the game's 16 x 16 halved; frame 1: blue- ("heart", "demo2:spr_heart", {"center": True, "keep": True, "tints": [(0, 60, 255), (0, 192, 0)]}), # red, blue, green+ ("heart", "demo2:spr_heart", {"center": True, "keep": True,+ "tints": [(0, 60, 255), (0, 192, 0), (213, 53, 217), (255, 255, 0)]}), # red, blue, green, purple, yellow] + [# the battle: its buttons (orange, then yellow when chosen), the FIGHT target and its bar, the slash, the HP label(n, "demo2:spr_" + n, {"keep": True}) for n in [@@ -400,6 +433,14 @@ SPRITES = [# the news report's script before it's shown to be a bomb, and the Stained Apron (cut from the map)("news_script", "map:Hotland_map.png:4322,1880,16,16", {"keep": True, "feet": True, "clear": [(112, 83, 71), (52, 50, 78), (107, 67, 78)]}),("apron", "map:Hotland_map.png:5836,2618,22,18", {"keep": True, "clear": [(181, 85, 21)]}),+ # the third floor: Muffet (in her lair, in battle, her pet cupcake), her spiders, the Diamond Boys+ ("muffet_ow", "wiki:Muffet_overworld.png", {"feet": True}),+ ("muffet_b", "wiki:Muffet_battle_idle.gif", {"feet": True, "dedupe": True, "every": 4}),+ ("muffet_hurt", "wiki:Muffet_battle_hurt.png", {"feet": True}),+ ("muffet_pet", "wiki:Muffet's_Pet_battle_chasing.gif", {"center": True, "dedupe": True}),+ ("spider_b", "wiki:Bullet_Spider_battle.png", {"center": True}),+ ("diamond1", "wiki:Diamond_Boy_overworld.png", {"feet": True}),+ ("diamond2", "wiki:Tall_Diamond_Boy_overworld.png", {"feet": True}),# in battle, the bombs share one look (the dog and the glass of water keep their own)("bomb_b", "wiki:Bomb_battle_idle.gif", {"feet": True, "dedupe": True}),("dogbomb_b", "wiki:Annoying_Dog_battle_bomb.gif", {"feet": True, "dedupe": True}),@@ -420,6 +461,9 @@ SPRITES = [("arm", "gen:arm", {"center": True}),("debris", "gen:debris", {"center": True}),("star", "gen:star", {"center": True}),+ ("croissant", "gen:croissant", {"center": True}),+ ("donut", "gen:donut", {"center": True}),+ ("mttmini", "gen:mttmini", {"center": True}),# Waterfall's monsters("aaron_b", "wiki:Aaron_battle_static.png", {"feet": True, "clear_bg": True}),("aaron_hurt", "wiki:Aaron_battle_hurt.png", {"feet": True, "clear_bg": True}),