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: the CORE and Mettaton EX, up to the elevator to the castle
Mason Chen15e8bfa98339
diff --git a/README.md b/README.mdindex 012ea84b..8162cd2c 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, Hotland and the MTT Resort, from the golden flowers to the CORE's door</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, Hotland and the CORE, from the golden flowers to the king's castle</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, Hotland and the MTT Resort are out, the CORE and New Home are next+- [ ] Undertale: the Ruins, Snowdin, Waterfall, Hotland, the MTT Resort and the CORE are out, New Home is next- [ ] The Binding of Isaac- [ ] Plants vs. Zombies- [ ] Doomdiff --git a/docs/play.md b/docs/play.mdindex f2ca4c9b..82a5730a 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, Hotland and the MTT Resort. 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. At the MTT Resort, the desk rents you a room and the hotel's doors want room service. For now the game ends at the door of the CORE.+Name the fallen human, then walk and talk your way through the Ruins, Snowdin, Waterfall, Hotland, the MTT Resort and the CORE. 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. At the MTT Resort, the desk rents you a room and the hotel's doors want room service. On the CORE's laser bridge, walk while the power is off and freeze when it comes back on. Mettaton EX's show is won on its ratings: Boast, Pose, a Heel Turn and his brand's food raise them. For now the game ends at the elevator up to the king's castle.<br clear="right">diff --git a/games/undertale/README.md b/games/undertale/README.mdindex 1d1bd507..98b085da 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, all of Hotland and the MTT Resort, from the bed of golden flowers to the door of the CORE. The rest of the Underground is on the way.+ The Ruins, Snowdin, Waterfall, all of Hotland, the MTT Resort and the CORE, from the bed of golden flowers to the elevator up to the king's castle. New Home is on the way.</p><p align="center">@@ -30,7 +30,8 @@* **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.* **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.* **The MTT Resort:** Sans out front, and dinner with him in the restaurant, where he tells you about the door in the forest; the lobby and its fountain, the MTT-Brand Burger Emporium with Burgerpants behind the counter, Bratty and Catty's shop up the alley, a night in the hotel, room service down the hall (and a dog behind door 4), and the door to the CORE.-* **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.+* **The CORE:** two black shapes backing away inside, its broken elevator, Madjick's ambush, the switch whose lasers Alphys gets backwards, Knight Knight north of the crossroads, the laser bridge where Alphys cuts the power (and it keeps coming back), and the Core Branch: the sage's path and its shooting puzzle, the warrior's path and its three fights, or a force field that a patient one just waits out. Then The End, Mettaton's last show, Alphys's confession in the last hallway, and the elevator up to the castle.+* **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; Final Froggit, Whimsalot, Astigmatism, Madjick and Knight Knight in the CORE, and Mettaton EX, whose show is won on its ratings.* **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.@@ -143,6 +144,14 @@<td align="center"><img src="docs/dinner.png" width="390" alt="Dinner with Sans"><br><sub>Dinner with Sans at the MTT Resort</sub></td><td align="center"><img src="docs/alley.png" width="390" alt="Bratty and Catty's shop"><br><sub>Bratty and Catty's shop, up the alley</sub></td></tr>+ <tr>+ <td align="center"><img src="docs/bridge.png" width="390" alt="The CORE's laser bridge"><br><sub>The laser bridge: freeze when the power's on</sub></td>+ <td align="center"><img src="docs/knight.png" width="390" alt="Knight Knight"><br><sub>Knight Knight, before her lullaby</sub></td>+ </tr>+ <tr>+ <td align="center"><img src="docs/sage.png" width="390" alt="The sage's path"><br><sub>The sage's path, two shots</sub></td>+ <td align="center"><img src="docs/mttex.png" width="390" alt="Mettaton EX"><br><sub>Mettaton EX: keep the ratings up</sub></td>+ </tr></table>## How to play@@ -155,7 +164,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. 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. At the MTT Resort, the front desk rents you a room for the night, and the hotel's doors down the hall want room service: bring what they ask for.+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. At the MTT Resort, the front desk rents you a room for the night, and the hotel's doors down the hall want room service: bring what they ask for. On the CORE's laser bridge, walk while the power is off and freeze the moment it flickers back on. Against Mettaton, turn him round first; then it's a show: Boast, Pose, a Heel Turn, his brand's food and every hit you take make the ratings climb, and once they're high enough the show is over.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.@@ -172,7 +181,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, Hotland and the MTT Resort, for now:** the door of the CORE ends the game, on a screen that says the rest of the Underground is still to come. The CORE and New Home come next, one at a time.+* **Everything up to New Home, for now:** the elevator up to the king's castle ends the game, on a screen that says the rest is still to come. New Home comes next.* **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/bridge.png b/games/undertale/docs/bridge.pngnew file mode 100644index 00000000..f14bc041Binary files /dev/null and b/games/undertale/docs/bridge.png differdiff --git a/games/undertale/docs/knight.png b/games/undertale/docs/knight.pngnew file mode 100644index 00000000..fb0ef7dfBinary files /dev/null and b/games/undertale/docs/knight.png differdiff --git a/games/undertale/docs/mttex.png b/games/undertale/docs/mttex.pngnew file mode 100644index 00000000..17561aa7Binary files /dev/null and b/games/undertale/docs/mttex.png differdiff --git a/games/undertale/docs/sage.png b/games/undertale/docs/sage.pngnew file mode 100644index 00000000..f211b345Binary files /dev/null and b/games/undertale/docs/sage.png differdiff --git a/games/undertale/src/battle.c b/games/undertale/src/battle.cindex 9bfa73b9..b9a1fdfa 100644--- a/games/undertale/src/battle.c+++ b/games/undertale/src/battle.c@@ -444,6 +444,11 @@ void battle_update(uint32_t keys, uint32_t pressed) {if (bt.result == BR_SCRIPTED) battle_end(BR_SCRIPTED);return;}+ /* (a monster's ways may end it at once: Mettaton, his switch flipped or his show a hit) */+ if (bt.result == BR_SCRIPTED) {+ battle_end(BR_SCRIPTED);+ return;+ }for (int i = 0; i < bt.nmon; i++) {Monster *m = &bt.mon[i];if (m->hurt) m->hurt--;diff --git a/games/undertale/src/battle.h b/games/undertale/src/battle.hindex 12a65843..4d4b0eb1 100644--- a/games/undertale/src/battle.h+++ b/games/undertale/src/battle.h@@ -102,6 +102,7 @@ typedef struct {int16_t angle; /* drawn turned (1/256 turns) */uint8_t owner; /* the monster that made it */} Bullet;+#define SPR_RECT 0xFFFF /* a bullet drawn as its box: a plain rectangle (white unless coloured) */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) */diff --git a/games/undertale/src/bullets.c b/games/undertale/src/bullets.cindex 4e21c697..dbc272fd 100644--- a/games/undertale/src/bullets.c+++ b/games/undertale/src/bullets.c@@ -175,6 +175,10 @@ void bullets_draw(void) {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): b->color == BC_YELLOW ? rgb565(0xFFFF00) : 0;+ if (b->spr == SPR_RECT) {+ gfx_rect(b->x / FX - b->w / 2, b->y / FX - b->h / 2, b->w, b->h, color ? color : C_WHITE, b->alpha);+ continue;+ }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/core.c b/games/undertale/src/core.cnew file mode 100644index 00000000..313f8736--- /dev/null+++ b/games/undertale/src/core.c@@ -0,0 +1,559 @@+/* The CORE: its approach (two black shapes back away inside), the lobby and its broken elevator, the fire pit, the+ * doorway's ambush (Madjick), the switch and its lasers (Alphys gets their order backwards), the crossroads and the+ * room north (Knight Knight), the laser bridge (Alphys cuts the power; it keeps coming back), the Core Branch: the+ * sage's path (its puzzle), the warrior's path (three fights, a switch) and the force field east that a patient one+ * waits out; The End's bridge, the Core End, and Mettaton's last show; the hallway, Alphys, and the elevator up to+ * the king's castle, where the game now ends. (As the Undertale Wiki describes them; what they say is ours, in+ * short.) */+#include <stddef.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 *touch(int x, int y, int w, int h, int event, int arg) {+ Obj *o = obj_trigger(x, y, w, h, event, ACTOR_TRIGGER);+ if (o) 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 void field(int x, int y, int w, int h) {+ Obj *o = obj_trigger(x, y, w, h, EV_NONE, ACTOR_FIELD);+ if (o) o->flags = OF_SOLID;+}+static void fields_down(void) {+ for (Obj *o = obj_find(ACTOR_FIELD); o; o = obj_find(ACTOR_FIELD)) gone(o);+}++/* Alphys's calls, one bit each (F_CORE_CALLS, then F_CORE_CALLS2) */+enum { CALL_IN, CALL_LOBBY, CALL_LIFT, CALL_PIT, CALL_AMBUSH, CALL_SWITCH, CALL_ORDER, CALL_EAST, CALL_NORTH,+ CALL_KNIGHT, CALL_POWER, CALL_STOP, CALL_BRANCH };+static bool called(int n) { return flag(n < 8 ? F_CORE_CALLS : F_CORE_CALLS2) >> (n & 7) & 1; }+static void set_called(int n) {+ int f = n < 8 ? F_CORE_CALLS : F_CORE_CALLS2;+ set_flag(f, flag(f) | 1 << (n & 7));+}+static void call_at(int x, int y, int w, int h, int n) {+ if (!called(n)) touch(x, y, w, h, EV_CORE_CALL, n);+}++/* ---------------------------------------------------------------- the lasers */+/* the ambush's: three beams that sweep across from the bridge once the switch is pressed (blue, blue, orange);+ * the bridge's: its emitters, and the wall of blue ones, while the power is on */+#define AMB_Y0 1339+#define AMB_Y1 1486+#define BR_Y0 1300+#define BR_Y1 1402+static int sweep_t = -1; /* frames since the switch, -1 none */+static int power_t; /* the bridge's power: on while power_t % CYCLE < ON */+#define CYCLE 130+#define ON 55+static bool power_on;+static int laser_cool;+static const int16_t bridge_lasers[][2] = { /* x, blue */+ {1267, 1}, {1309, 1}, {1348, 0}, {1388, 1}, {1428, 0}, {1469, 1},+};+#define WALL_X0 1504+#define WALL_X1 2000+#define WALL_STEP 19++static int sweep_x(int i) { return 560 - (sweep_t - i * 60) * 3; }+static bool sweep_blue(int i) { return i < 2; }+static bool laser_hits(int x, bool blue, int y0, int y1) {+ if (pl.x + 3 > x + 1 || pl.x + 17 < x - 1 || pl.y + 29 < y0 || pl.y + 20 > y1) return false;+ return blue ? pl.moving : !pl.moving;+}+static void laser_hit(void) {+ if (laser_cool || event_running()) return;+ event_start(EV_CORE_LASER, NULL);+}+static void lasers_watch(void) {+ if (laser_cool) laser_cool--;+ if (g_room == ROOM_CORE_WEST && sweep_t >= 0) {+ sweep_t++;+ for (int i = 0; i < 3; i++) {+ int x = sweep_x(i);+ if (x < 560 && x > 100 && laser_hits(x, sweep_blue(i), AMB_Y0, AMB_Y1)) laser_hit();+ }+ if (sweep_x(2) < 90) {+ sweep_t = -1;+ if (!called(CALL_ORDER)) event_start(EV_CORE_ORDER, NULL);+ }+ }+ if (g_room == ROOM_CORE_BRIDGE && flag(F_CORE_POWER) == 1 && called(CALL_STOP)) {+ power_t++;+ power_on = power_t % CYCLE < ON;+ if (power_on && power_t % CYCLE > 6) { /* (a moment to stop when it comes back on) */+ for (unsigned i = 0; i < sizeof bridge_lasers / sizeof bridge_lasers[0]; i++)+ if (laser_hits(bridge_lasers[i][0], bridge_lasers[i][1], BR_Y0, BR_Y1)) laser_hit();+ for (int x = WALL_X0; x <= WALL_X1; x += WALL_STEP)+ if (laser_hits(x, true, BR_Y0, BR_Y1)) laser_hit();+ }+ } else power_on = false;+}+static void draw_beam(int x, int y0, int y1, bool blue) {+ uint16_t c = blue ? rgb565(0x14A9FF) : rgb565(0xFCA600);+ gfx_rect(x - 1 - cam_x, y0 - cam_y, 3, y1 - y0, c, (g_frame / 2) % 2 ? 255 : 200);+}++void core_draw(void) {+ if (world_room_info()->area != AREA_CORE) return;+ for (int i = 0; i < MAX_OBJS; i++) {+ const Obj *o = &objs[i];+ if (o->kind == OBJ_NONE || o->name != ACTOR_FIELD) continue;+ uint16_t c = (g_frame / 3) % 2 ? rgb565(0x60FFFF) : rgb565(0x20A0C0);+ gfx_rect(o->x - cam_x, o->y - cam_y, o->bw, o->bh, c, 200);+ }+ if (g_room == ROOM_CORE_WEST && sweep_t >= 0)+ for (int i = 0; i < 3; i++) {+ int x = sweep_x(i);+ if (x < 560 && x > 100) draw_beam(x, AMB_Y0, AMB_Y1, sweep_blue(i));+ }+ /* the bridge's: on until Alphys cuts the power, then on and off */+ bool on = g_room == ROOM_CORE_BRIDGE && (!flag(F_CORE_POWER) || power_on);+ /* (the power flickers a moment before it comes back) */+ bool flicker = g_room == ROOM_CORE_BRIDGE && flag(F_CORE_POWER) == 1 && called(CALL_STOP) && power_t % CYCLE >= CYCLE - 20 &&+ g_frame % 4 < 2;+ if (on || flicker) {+ for (unsigned i = 0; i < sizeof bridge_lasers / sizeof bridge_lasers[0]; i++)+ draw_beam(bridge_lasers[i][0], BR_Y0, BR_Y1, bridge_lasers[i][1]);+ for (int x = WALL_X0; x <= WALL_X1; x += WALL_STEP) draw_beam(x, BR_Y0, BR_Y1, true);+ }+}++/* the force field by the east bridge: the sign says patience (a minute in front of it, and it's gone) */+static int field_wait;+void core_update(void) {+ if (world_room_info()->area != AREA_CORE) return;+ lasers_watch();+ if (g_room == ROOM_CORE_BRANCH && !flag(F_CORE_FIELD)) {+ if (pl.x > 2440 && pl.x < 2530 && pl.y > 830 && pl.y < 880) {+ if (++field_wait >= 60 * 30) {+ set_flag(F_CORE_FIELD, 1);+ fields_down();+ event_start(EV_CORE_FIELD, NULL);+ }+ } else field_wait = 0;+ }+}++/* ---------------------------------------------------------------- the rooms */+void core_setup(int room, int from) {+ (void)from;+ if (room < ROOM_CORE_APPROACH || room > ROOM_CORE_HALL) return;+ sweep_t = -1, power_t = 0, field_wait = 0;+ switch (room) {+ case ROOM_CORE_APPROACH:+ if (!flag(F_CORE_IN)) {+ npc(ACTOR_ITEM, SPR_SAUSAGE, 316, 2560);+ npc(ACTOR_ANY, SPR_SAUSAGE, 326, 2528);+ touch(290, 2650, 60, 20, EV_CORE_APPROACH, 0);+ }+ break;+ case ROOM_CORE_LOBBY:+ call_at(298, 2080, 42, 30, CALL_LOBBY);+ thing(296, 1986, 48, 54, EV_CORE_LIFT, ACTOR_DOOR, 0);+ obj_sign(186, 1980, 28, 26, "* (A screen: CORE, the source of\n the Underground's power.)");+ break;+ case ROOM_CORE_PIT:+ call_at(440, 1800, 79, 20, CALL_PIT);+ obj_sign(440, 1740, 79, 22, "* (A pit of fire, far below.\n You can feel its heat.)");+ break;+ case ROOM_CORE_DOORWAY:+ if (!flag(F_CORE_MADJICK)) touch(100, 1770, 120, 16, EV_CORE_MADJICK, 0);+ break;+ case ROOM_CORE_WEST:+ call_at(119, 1420, 159, 16, CALL_AMBUSH);+ thing(250, 1310, 20, 50, EV_CORE_SWITCH, ACTOR_SWITCH, 0);+ if (!flag(F_CORE_SWITCH)) field(282, 1350, 6, 40);+ call_at(740, 1339, 12, 66, CALL_EAST);+ call_at(880, 1339, 12, 66, CALL_NORTH);+ if (!flag(F_CORE_KNIGHT)) touch(766, 1150, 147, 14, EV_CORE_KNIGHT, 0);+ break;+ case ROOM_CORE_BRIDGE:+ if (flag(F_CORE_POWER) < 2) {+ call_at(1232, 1358, 12, 44, CALL_POWER);+ call_at(1490, 1358, 12, 44, CALL_STOP);+ touch(2062, 1300, 58, 12, EV_CORE_POWER, 0);+ }+ break;+ case ROOM_CORE_BRANCH:+ if (!called(CALL_BRANCH)) touch(2060, 1118, 58, 12, EV_CORE_BRANCH, 0); /* (on the way in) */+ obj_save(2080, 1100, "* (The air smells of ozone. It\n fills you with determination.)");+ obj_sign(2010, 1056, 20, 44, "* (North: the warrior's path.)\n* (West: the sage's path.)\n* (Any path leads to The End.)");+ obj_sign(2150, 1056, 20, 44, "* (East... The End.)");+ obj_sign(1670, 816, 22, 44, "* (Solve this puzzle, and The\n End will open.)");+ obj_sign(1770, 312, 22, 44, "* (Why not stop for a snack?)");+ obj_sign(2170, 816, 22, 44, "* (Get lost... and stay lost.)");+ obj_sign(2010, 576, 22, 44, "* (Cross the room to the north,\n and The End will open.)");+ obj_sign(2330, 816, 22, 44, "* (East! This way is The End.)");+ obj_sign(2470, 816, 22, 44, "* (I can't fight. I can't think.)\n* (But with patience, I'll make\n my way through.)");+ thing(1452, 834, 34, 28, EV_CORE_SAGE, ACTOR_ITEM, 0);+ thing(1758, 372, 22, 20, EV_CORE_TRASH, ACTOR_ITEM, 0);+ thing(2398, 372, 22, 20, EV_CORE_TRASH, ACTOR_ITEM, 1);+ if (!flag(F_CORE_FIELD)) field(2524, 856, 10, 48);+ break;+ case ROOM_CORE_WARRIOR:+ for (int i = flag(F_CORE_WARRIOR); i < 3; i++) touch(2220 + i * 130, 160, 10, 40, EV_CORE_WARRIOR, i);+ thing(2660, 128, 20, 30, EV_CORE_WSWITCH, ACTOR_SWITCH, 0);+ break;+ case ROOM_CORE_END:+ set_flag(F_CORE_END, 1);+ obj_save(3478, 866, "* (The elevator to the king's\n castle must be past this door.)\n* (You're filled with determination.)");+ thing(3418, 806, 40, 50, EV_CORE_LIFT, ACTOR_DOOR, 1);+ break;+ case ROOM_CORE_MTT:+ if (!flag(F_CORE_MTT)) {+ Obj *m = npc(ACTOR_METTATON, SPR_MTT_OW, 3360, 500);+ if (m) m->flags |= OF_ANIM, m->anim_speed = 5;+ touch(3342, 620, 36, 12, EV_CORE_MTT, 0);+ field(3342, 336, 36, 8); /* (the way out north: shut until the show's over) */+ } else {+ Obj *m = npc(ACTOR_METTATON, flag(F_CORE_MTT) == 2 ? SPR_MTT_OW : SPR_MTTEX_OW, 3360, 500);+ (void)m;+ obj_sign(3346, 480, 30, 26, flag(F_CORE_MTT) == 2 ? "* (It's completely trashed.)" : "* (Mettaton. Out of power.)");+ }+ break;+ case ROOM_CORE_HALL:+ if (!flag(F_CORE_HALL)) {+ static const uint16_t s[4] = {SPR_ALPHYS_OW, SPR_ALPHYS_OW, SPR_ALPHYS_OW, SPR_ALPHYS_OW};+ Obj *a = obj_npc(ACTOR_ALPHYS, s, 3370, 230, DIR_UP, 0);+ if (a) a->flags &= (uint16_t)~OF_SOLID;+ touch(4220, 118, 10, 42, EV_CORE_HALL, 0);+ }+ thing(4278, 92, 46, 28, EV_CORE_LIFT, ACTOR_DOOR, 2);+ break;+ }+}++/* ---------------------------------------------------------------- the events */+static int ev_approach(Ev *c) {+ Obj *a = obj_get(ACTOR_ITEM), *b = obj_get(ACTOR_ANY);+ EV_BEGIN;+ if (c->self) gone(c->self);+ /* two shapes, black, back away up the path, and in */+ WALK_TO(b, b->x, 2290, 2);+ WALK(a, a->x, 2300, 2);+ gone(obj_get(ACTOR_ITEM)), gone(obj_get(ACTOR_ANY));+ set_flag(F_CORE_IN, 1);+ SAY(FACE_ALPHYS, "* Ring...|* Th-that's the CORE! We made it!|* ...wait. Were those\n monsters? Nobody's supposed\n to be in there...|* It's fine. Probably.\n* I'll guide you through!");+ EV_END;+}++static int ev_call(Ev *c) {+ EV_BEGIN;+ if (c->self) c->v[0] = c->self->arg;+ if (c->self) gone(c->self);+ if (called(c->v[0])) return 1;+ set_called(c->v[0]);+ switch (c->v[0]) {+ case CALL_LOBBY:+ SAY(FACE_ALPHYS, "* Ring...|* The elevator in the middle\n goes right to the castle!\n* Head for it!");+ break;+ case CALL_PIT:+ SAY(FACE_ALPHYS, "* Ring...|* A pit of fire? That's not on\n my map...|* Um. Go back, and try the\n other way.");+ break;+ case CALL_AMBUSH:+ SAY(FACE_ALPHYS, "* Ring...|* See that switch? It turns off\n the force field...|* ...but it sets off lasers!\n* Orange, orange, then blue.\n* You'll be fine!");+ break;+ case CALL_ORDER:+ SAY(FACE_ALPHYS, "* Ring...|* Wait. That was blue, blue,\n then orange.|* I had it backwards.\n* S-sorry...");+ break;+ case CALL_EAST:+ SAY(FACE_ALPHYS, "* Ring...|* East! Keep going east!");+ break;+ case CALL_NORTH:+ SAY(FACE_ALPHYS, "* Ring...|* N-no, wait! North!\n* Go north first!");+ break;+ case CALL_POWER:+ SAY(FACE_ALPHYS, "* Ring...|* Those lasers... I can't turn\n them off.|* So I'll cut the power to the\n whole room!");+ if (!flag(F_CORE_POWER)) set_flag(F_CORE_POWER, 1);+ NARRATE("* (The lights go out.)");+ field(1228, 1356, 6, 48); /* (back west: a field on its own battery) */+ break;+ case CALL_STOP:+ SAY(FACE_ALPHYS, "* Ring...|* Stop! STOP MOVING!\n* The power's back on!|* I can't keep it off!\n* Move while it's off, and\n freeze when it's on!");+ break;+ }+ EV_END;+}++/* the bridge crossed: its power stays off */+static int ev_power(Ev *c) {+ EV_BEGIN;+ if (c->self) gone(c->self);+ set_flag(F_CORE_POWER, 2);+ fields_down();+ SAY(FACE_ALPHYS, "* Ring...|* Phew... you made it.\n* Everything's under control!\n* Totally!");+ EV_END;+}++static int ev_laser(Ev *c) {+ EV_BEGIN;+ g_exclaim = 20;+ WAIT(15);+ BATTLE(FORM_LASERS);+ laser_cool = 50;+ EV_END;+}++static int ev_switch(Ev *c) {+ EV_BEGIN;+ if (flag(F_CORE_SWITCH)) {+ NARRATE("* (The switch is already pressed.)");+ return 1;+ }+ NARRATE("* (You press the switch.)\n* (The force field shuts off.)");+ set_flag(F_CORE_SWITCH, 1);+ fields_down();+ sweep_t = 0;+ EV_END;+}++static int ev_madjick(Ev *c) {+ EV_BEGIN;+ if (c->self) gone(c->self);+ SAY(FACE_ALPHYS, "* Ring...|* Watch out! Something's\n coming at you!");+ g_exclaim = 20;+ WAIT(15);+ BATTLE(FORM_MADJICK);+ set_flag(F_CORE_MADJICK, bt.mon[0].killed ? 2 : 1);+ SAY(FACE_ALPHYS, "* Ring...|* Are you okay?|* Why are there so many\n monsters in here...?");+ EV_END;+}++static int ev_knight(Ev *c) {+ EV_BEGIN;+ if (c->self) gone(c->self);+ g_exclaim = 20;+ WAIT(15);+ BATTLE(FORM_KNIGHT);+ set_flag(F_CORE_KNIGHT, bt.mon[0].killed ? 2 : 1);+ set_called(CALL_KNIGHT);+ SAY(FACE_ALPHYS, "* Ring...|* Are you all right?!\n* I'm so sorry...|* Okay. East now. Really.");+ EV_END;+}++static int ev_branch(Ev *c) {+ EV_BEGIN;+ if (c->self) gone(c->self);+ set_called(CALL_BRANCH);+ SAY(FACE_ALPHYS, "* Ring...|* Okay, so, from here you go...\n* ...um...|* ...|* I don't know. My map's all\n wrong.|* I'm sorry. I'll... stop\n calling.");+ EV_END;+}++static int ev_sage(Ev *c) {+ EV_BEGIN;+ if (flag(F_CORE_SAGE)) {+ NARRATE("* (The puzzle is solved.)");+ return 1;+ }+ shoot_open(SHOOT_SAGE);+ WAIT_UNTIL(g_mode == MODE_WORLD);+ if (shoot_result()) {+ set_flag(F_CORE_SAGE, 1);+ set_flag(F_CORE_FIELD, 1);+ fields_down(); /* (the force field east, in this same room) */+ NARRATE("* (Far to the east, something\n hums, then goes quiet.)");+ }+ EV_END;+}++static int ev_warrior(Ev *c) {+ static const uint8_t forms[3] = {FORM_WHIM_FROG, FORM_KNIGHT_MADJICK, FORM_FROG_ASTIG_WHIM};+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ if (c->self) gone(c->self);+ if (flag(F_CORE_WARRIOR) > c->v[0]) return 1;+ g_exclaim = 20;+ WAIT(15);+ BATTLE(forms[c->v[0]]);+ if (battle_result() != BR_FLED && battle_result() != BR_DIED) set_flag(F_CORE_WARRIOR, c->v[0] + 1);+ EV_END;+}++static int ev_wswitch(Ev *c) {+ EV_BEGIN;+ if (flag(F_CORE_WARRIOR) >= 4) {+ NARRATE("* (The switch is already flipped.)");+ return 1;+ }+ NARRATE("* (You flip the switch.)\n* (Far away, something hums,\n then goes quiet.)");+ set_flag(F_CORE_WARRIOR, 4);+ set_flag(F_CORE_FIELD, 1);+ EV_END;+}++static int ev_field(Ev *c) {+ EV_BEGIN;+ NARRATE("* (The force field flickers...\n and fades away.)");+ EV_END;+}++static int ev_trash(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ if (flag(c->v[0] ? F_CORE_TRASH2 : F_CORE_TRASH1)) {+ NARRATE("* (It's an empty trash can.)");+ return 1;+ }+ if (c->v[0]) {+ NARRATE("* (There's 100G inside the\n trash can.)");+ sv.gold = (uint16_t)min_i(sv.gold + 100, 9999);+ set_flag(F_CORE_TRASH2, 1);+ } else if (item_add(ITEM_GLAMBURGER)) {+ NARRATE("* (There's a Glamburger in the\n trash can. You take it.)");+ set_flag(F_CORE_TRASH1, 1);+ } else NARRATE("* (There's a Glamburger inside.)\n* (You're carrying too much.)");+ EV_END;+}++/* the elevators: the lobby's (it works once the far side's reached), the Core End's back to it; the last one, up+ * to the castle */+static int ev_lift(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ if (c->v[0] == 2) {+ if (!flag(F_CORE_HALL)) {+ NARRATE("* (The elevator to the king's\n castle.)");+ return 1;+ }+ NARRATE("* (Take the elevator up to the\n castle?)@Yes@No");+ if (CHOICE() == 1) return 1;+ set_flag(F_CORE_DONE, 1);+ sv.room = (int16_t)g_room, sv.x = 4285, sv.y = 125;+ save_write_auto();+ menu_end_open();+ return 1;+ }+ if (c->v[0] == 0 && !flag(F_CORE_END)) {+ NARRATE("* (The elevator doesn't work.)");+ if (!called(CALL_LIFT)) {+ set_called(CALL_LIFT);+ SAY(FACE_ALPHYS, "* Ring...|* It's not working?\n* B-but my map says...|* Okay. Um. Go left!\n* No, right! ...Either!");+ }+ return 1;+ }+ NARRATE(c->v[0] ? "* (Take the elevator down to\n the lobby?)@Yes@No" : "* (Take the elevator to the\n Core End?)@Yes@No");+ if (CHOICE() == 1) return 1;+ if (c->v[0]) FADE_TO(ROOM_CORE_LOBBY, 310, 2045, DIR_DOWN);+ else FADE_TO(ROOM_CORE_END, 3428, 862, DIR_DOWN);+ EV_END;+}++/* Mettaton's room: the door locks; he tells Frisk the truth; his box, his switch, his new body */+static int ev_mtt(Ev *c) {+ Obj *m = obj_get(ACTOR_METTATON);+ EV_BEGIN;+ if (c->self) gone(c->self);+ NARRATE("* (The door locks behind you.)");+ WAIT_UNTIL(cam_pan(3200, 420, 4)); /* (up to him) */+ text_set_top(0);+ NARRATE("* OH YES. IT WAS ME.\n* THE MONSTERS. THE ELEVATOR.\n THE MAZE.|* AND ALL THOSE PUZZLES?\n* ALPHYS PLANNED THEM, SO SHE\n COULD SAVE YOU FROM ME.|* SHE WANTED TO BE YOUR HERO.\n* BUT I GOT BORED, DARLING.");+ NARRATE("* WITH YOUR SOUL, I'LL CROSS THE\n BARRIER...|* ...AND BE A STAR UP THERE!\n* NOW... FOR THE GRAND FINALE!");+ text_set_top(-1);+ BATTLE(FORM_MTT_BOX);+ if (battle_result() == BR_DIED) {+ cam_free();+ return 1;+ }+ text_set_top(0);+ g_shake = 10;+ NARRATE("* (Smoke pours out of Mettaton.)\n* OHHH MY...|* YOU FLIPPED MY SWITCH?\n* SO YOU'RE DYING TO SEE MY NEW\n BODY. HOW RUDE...|* LUCKY FOR YOU, I'VE BEEN\n ACHING TO SHOW IT OFF!");+ text_set_top(-1);+ mttex_reset();+ BATTLE(FORM_MTT_EX);+ if (battle_result() == BR_DIED) {+ cam_free();+ return 1;+ }+ text_set_top(0);+ m = obj_get(ACTOR_METTATON);+ if (bt.mon[0].killed) {+ set_flag(F_CORE_MTT, 2);+ NARRATE("* (Mettaton falls back into his\n box. It's completely trashed.)");+ } else {+ set_flag(F_CORE_MTT, 1);+ m->spr[0] = m->spr[1] = m->spr[2] = m->spr[3] = SPR_MTTEX_OW, m->flags &= (uint16_t)~OF_ANIM;+ NARRATE("* THESE RATINGS... THE BEST\n I'VE EVER HAD!|* AND... WE'RE GETTING CALLS?\n* GO AHEAD, CALLER!");+ NARRATE("* (A small, sad voice.)\n* oh... hi mettaton...|* i just... wanted to say...\n* your show is all i watch...|* please don't leave...");+ NARRATE("* MORE CALLS... ALL SAYING THE\n SAME THING.|* ...SO THE UNDERGROUND NEEDS\n ME MORE THAN I THOUGHT.|* THEN I'LL STAY.\n* AND YOU, DARLING...\n YOU CAN STAND UP TO ASGORE.");+ NARRATE("* ...THOUGH THIS BODY EATS\n BATTERY LIKE...|* (Mettaton runs out of power.)");+ }+ text_set_top(-1);+ fields_down();+ /* Alphys, in through the door */+ {+ static const uint16_t s[4] = {SPR_ALPHYS_OW, SPR_ALPHYS_OW, SPR_ALPHYS_OW, SPR_ALPHYS_OW};+ Obj *a = obj_npc(ACTOR_ALPHYS, s, 3360, 760, DIR_UP, 0);+ if (a) a->flags &= (uint16_t)~OF_SOLID;+ }+ WALK(obj_get(ACTOR_ALPHYS), 3360, 600, 3);+ if (flag(F_CORE_MTT) == 2) SAY(FACE_ALPHYS, "* I-I got the door open...\n* ...oh.|* Mettaton...|* ...let's just go.");+ else SAY(FACE_ALPHYS, "* I-I got the door open! Are\n you okay?! Is Mettaton...|* ...he's just out of power.\n* Oh, thank goodness...|* Come on. The elevator's\n this way.");+ gone(obj_get(ACTOR_ALPHYS));+ cam_free();+ EV_END;+}++/* the hallway: by the elevator, Alphys tells Frisk the truth about the way home */+static int ev_hall(Ev *c) {+ Obj *a = obj_get(ACTOR_ALPHYS);+ EV_BEGIN;+ if (c->self) gone(c->self);+ WALK(a, pl.x - 30, pl.y + 10, 3);+ SAY(FACE_ALPHYS, "* W-wait! Before you go...|* There's something I didn't\n tell you.|* To leave, you need a human\n SOUL, and a monster's...");+ SAY(FACE_ALPHYS, "* ASGORE's the only one who\n can help you through...|* ...but he needs your SOUL\n for the barrier.|* To go home, you'll have to\n fight him. And...");+ SAY(FACE_ALPHYS, "* ...one of you won't come\n back.|* I'm sorry. I made it all up,\n so I'd seem like a hero.|* Good luck. You deserve a\n better friend than me.");+ set_flag(F_CORE_HALL, 1);+ a = obj_get(ACTOR_ALPHYS);+ WALK(a, 3360, a->y, 3);+ gone(obj_get(ACTOR_ALPHYS));+ EV_END;+}++int core_event(Ev *c) {+ switch (c->id) {+ case EV_CORE_APPROACH: return ev_approach(c);+ case EV_CORE_CALL: return ev_call(c);+ case EV_CORE_ORDER:+ if (!c->at) c->v[0] = CALL_ORDER;+ return ev_call(c);+ case EV_CORE_BRANCH: return ev_branch(c);+ case EV_CORE_POWER: return ev_power(c);+ case EV_CORE_LASER: return ev_laser(c);+ case EV_CORE_SWITCH: return ev_switch(c);+ case EV_CORE_MADJICK: return ev_madjick(c);+ case EV_CORE_KNIGHT: return ev_knight(c);+ case EV_CORE_SAGE: return ev_sage(c);+ case EV_CORE_WARRIOR: return ev_warrior(c);+ case EV_CORE_WSWITCH: return ev_wswitch(c);+ case EV_CORE_FIELD: return ev_field(c);+ case EV_CORE_TRASH: return ev_trash(c);+ case EV_CORE_LIFT: return ev_lift(c);+ case EV_CORE_MTT: return ev_mtt(c);+ case EV_CORE_HALL: return ev_hall(c);+ }+ return -1;+}diff --git a/games/undertale/src/coremon.c b/games/undertale/src/coremon.cnew file mode 100644index 00000000..beee6b4d--- /dev/null+++ b/games/undertale/src/coremon.c@@ -0,0 +1,762 @@+/* The CORE's monsters: Final Froggit, Whimsalot, Astigmatism, Madjick and Knight Knight (stats, ACTs and how they're+ * spared from the Undertale Wiki's records of the game); then Mettaton's last show: his box until Frisk turns him+ * round and flips his switch, and Mettaton EX with the show's ratings. Their words are short ones of our own. */+#include <stdio.h>+#include "battle.h"+#include "game.h"+#include "gfx.h"+#include "items.h"+#include "monsters.h"+#include "res.h"+#include "world.h"++/* ---------------------------------------------------------------- Final Froggit: mystify it, or two compliments+ * or threats (a compliment lowers its ATTACK, a threat its DEFENSE) */+static void act_ffroggit(Battle *b, Monster *m, int act, char *t, int cap) {+ (void)b;+ if (act == 0) {+ snprintf(t, (size_t)cap, "* You compliment Final Froggit.\n* It understood. Its ATTACK dropped.");+ m->at = (int16_t)max_i(1, m->at - 2);+ if (++m->state >= 2) m->spare = true;+ } else if (act == 1) {+ snprintf(t, (size_t)cap, "* You threaten Final Froggit.\n* It understood. Its DEFENSE dropped.");+ m->df = (int16_t)(m->df - 2);+ if (++m->state >= 2) m->spare = true;+ } else if (!m->state2) {+ snprintf(t, (size_t)cap, "* You do something mysterious.\n* Final Froggit sees it still has\n much to learn.");+ m->state2 = 1, m->spare = true;+ } else snprintf(t, (size_t)cap, "* You do something mysterious.\n* Nothing happens.");+}+static const char *talk_ffroggit(Battle *b, Monster *m) {+ (void)b;+ if (m->state2) return "(A thoughtful\ncroak.)";+ static const char *const lines[] = {"Skip, hop.", "Ribbit.", "Creak.", "Woof."};+ return lines[rnd_n(4)];+}+static int attack_ffroggit(Battle *b, Monster *m) { (void)b, (void)m; return rnd_n(2) ? ATK_FROG_FLIES : ATK_FROG_JUMP; }++/* ---------------------------------------------------------------- Whimsalot: console it, or pray twice */+static void act_whimsalot(Battle *b, Monster *m, int act, char *t, int cap) {+ (void)b;+ if (act == 0) {+ snprintf(t, (size_t)cap, "* You tell Whimsalot what it's\n doing is all right.");+ m->spare = true, m->state = 1;+ } else if (act == 1) {+ snprintf(t, (size_t)cap, "* You leap at Whimsalot,\n threateningly.");+ m->state = 2;+ } else {+ snprintf(t, (size_t)cap, "* You kneel and pray for safety.\n* Whimsalot remembers its\n conscience.");+ if (++m->state2 >= 2) m->spare = true;+ m->state = 3;+ }+}+static const char *talk_whimsalot(Battle *b, Monster *m) {+ (void)b;+ if (m->state == 1) return "I'm at\npeace now.";+ if (m->state == 2) return "You don't\nscare me.";+ if (m->state == 3) return "There's\nstill hope.";+ static const char *const lines[] = {"My mind is\nmade up.", "Not this\ntime.", "No\nregrets.", "(Shine.)"};+ return lines[rnd_n(4)];+}+static int attack_whimsalot(Battle *b, Monster *m) { (void)b, (void)m; return rnd_n(2) ? ATK_WHIM_RING : ATK_WHIM_COLS; }++/* ---------------------------------------------------------------- Astigmatism: it says what it wants (pick on it, or+ * don't); do as it says, and it's done. Challenging it makes the others with it want to stop */+static void act_astig(Battle *b, Monster *m, int act, char *t, int cap) {+ if (act == 2) {+ bool others = false;+ for (int i = 0; i < b->nmon; i++) {+ Monster *o = &b->mon[i];+ if (o != m && o->alive && !o->gone) o->spare = true, others = true;+ }+ snprintf(t, (size_t)cap, others ? "* You stand up to Astigmatism.\n* The others are impressed." : "* You stand up to Astigmatism.");+ m->state2 = 3;+ return;+ }+ snprintf(t, (size_t)cap, act == 0 ? "* You pick on Astigmatism." : "* You don't pick on Astigmatism.");+ if (m->state && act == m->state - 1) m->spare = true, m->state2 = 1;+ else if (m->state) m->state2 = 2;+}+static const char *talk_astig(Battle *b, Monster *m) {+ (void)b;+ if (m->state2 == 1) return m->state == 1 ? "That's\nright!" : "Finally.\nSomeone\ngets it.";+ if (m->state2 == 2) return m->state == 1 ? "Scared?" : "How\ndare you.";+ if (m->state2 == 3) return "You dare\ndefy me?";+ if (!m->state) {+ /* what it wants: 1 to be picked on, 2 not */+ m->state = (int16_t)(1 + rnd_n(2));+ return m->state == 1 ? "... Pick\non me." : "... Don't\npick on me.";+ }+ static const char *const lines[] = {"You've seen\nenough.", "Take a last\nlook.", "...", "... ..."};+ return lines[rnd_n(4)];+}+static const char *flavor_astig(Battle *b, Monster *m) {+ (void)b;+ if (m->state2) m->state2 = 0;+ return m->spare ? "* Astigmatism doesn't care about\n fighting anymore." : NULL;+}+static int attack_astig(Battle *b, Monster *m) { (void)b, (void)m; return rnd_n(2) ? ATK_LOOX_BOUNCE : ATK_LOOX_WORM; }++/* ---------------------------------------------------------------- Madjick: clear your mind, then talk; or raise the+ * Stick, a magic wand to it. Talking first dizzies Frisk (DEFENSE down) */+static void act_madjick(Battle *b, Monster *m, int act, char *t, int cap) {+ if (act == 0) {+ if (m->state) {+ snprintf(t, (size_t)cap, "* Madjick talks over you, to\n itself. It seems satisfied.");+ m->spare = true;+ } else {+ snprintf(t, (size_t)cap, "* Madjick talks over you.\n* Its gibberish dizzies you...\n* Your DEFENSE drops.");+ b->df_loss += 1;+ }+ } else if (act == 1) {+ snprintf(t, (size_t)cap, "* You glare at its orbs.\n* They waver a little.");+ if (++m->state2 >= 2) m->spare = true;+ } else {+ snprintf(t, (size_t)cap, "* You think of pollen and sunshine.\n* Your DEFENSE goes up.");+ m->state = 1, b->df_loss -= 1;+ }+}+static bool item_madjick(Battle *b, Monster *m, int item, char *t, int cap) {+ (void)b;+ if (item != ITEM_STICK) return false;+ snprintf(t, (size_t)cap, "* You raise the Stick.\n* Madjick takes it for a wand!");+ m->spare = true, m->state = 2;+ return true;+}+static const char *talk_madjick(Battle *b, Monster *m) {+ (void)b;+ if (m->state == 2) return "Ah! A fellow\nwizard!";+ static const char *const lines[] = {"Abracadabra.", "Alakazam!", "Hocus\npocus.", "Please and\nthank you."};+ return lines[rnd_n(4)];+}+static const char *flavor_madjick(Battle *b, Monster *m) {+ (void)b;+ return m->spare ? "* Madjick believes you're a\n fellow wizard." : NULL;+}+static int attack_madjick(Battle *b, Monster *m) { (void)b, (void)m; return rnd_n(2) ? ATK_MADJICK_CHASER : ATK_MADJICK_CORNER; }++/* ---------------------------------------------------------------- Knight Knight: three lullabies put her to sleep */+static void act_knight(Battle *b, Monster *m, int act, char *t, int cap) {+ (void)b;+ if (act == 0) {+ if (m->spare) snprintf(t, (size_t)cap, "* You talk to Knight Knight.\n* She hums in her sleep...");+ else snprintf(t, (size_t)cap, "* You ask Knight Knight about her\n day. There's no answer.");+ m->state2++;+ } else {+ m->state++;+ if (m->state == 1) snprintf(t, (size_t)cap, "* You sing an old lullaby.\n* Knight Knight looks sleepy...");+ else if (m->state == 2) snprintf(t, (size_t)cap, "* You keep singing.\n* Her eyes start to close...");+ else if (m->state == 3) snprintf(t, (size_t)cap, "* You keep singing.\n* Knight Knight falls asleep."), m->spare = true;+ else snprintf(t, (size_t)cap, "* You keep singing.\n* Nothing happens.");+ }+}+static const char *talk_knight(Battle *b, Monster *m) {+ (void)b;+ if (m->spare) return "Zzzz...";+ if (m->state2 == 3) return "...... ......\n...... It's\nokay.";+ static const char *const lines[] = {"Good knight.", "Farewell.", "Adieu.", "Close your\neyes...", "Goodbye."};+ return lines[rnd_n(5)];+}+static const char *flavor_knight(Battle *b, Monster *m) {+ (void)b;+ return m->spare ? "* Knight Knight is snoring." : NULL;+}+static int attack_knight(Battle *b, Monster *m) {+ (void)b;+ if (m->spare) return ATK_NONE;+ static const uint8_t pick[3] = {ATK_KNIGHT_MOON, ATK_KNIGHT_SUN, ATK_KNIGHT_STAR};+ return pick[rnd_n(3)];+}++/* ---------------------------------------------------------------- Mettaton, in his box: no hurting him. Alphys calls+ * about the switch on his back; Turn (a mirror behind him!) and Frisk flips it */+static void act_mttbox(Battle *b, Monster *m, int act, char *t, int cap) {+ (void)m;+ if (act == 0 && b->state[0]) {+ snprintf(t, (size_t)cap, "* You point behind Mettaton:\n \"Look! A mirror!\"|* He turns to look...\n* ...and you flip his switch!");+ b->state[1] = 1;+ } else snprintf(t, (size_t)cap, "* You look for a way around him.\n* There isn't one.");+}+static const char *talk_mttbox(Battle *b, Monster *m) {+ (void)m;+ if (b->state[1]) return "A MIRROR?\nWHERE?\n...OH NO.";+ if (b->turn <= 1) return "NO MORE\nGAMES,\nDARLING.";+ static const char *const lines[] = {"YOUR SOUL\nWILL MAKE ME\nA STAR!", "THE CROWD\nIS WAITING!", "STAY STILL,\nWON'T YOU?"};+ return lines[rnd_n(3)];+}+static const char *flavor_mttbox(Battle *b, Monster *m) {+ (void)m;+ if (b->turn == 2 && !b->state[0]) {+ b->state[0] = 1;+ return "* Alphys calls: \"The switch on his\n back! Get him to turn around!\"";+ }+ return b->state[0] ? "* Mettaton blocks the way.\n* (Try turning him around.)" : "* Mettaton blocks the way.";+}+static bool hit_mttbox(Battle *b, Monster *m, int dmg) {+ (void)b, (void)dmg;+ m->dmg_shown = 0;+ return true;+}+static int attack_mttbox(Battle *b, Monster *m) { (void)m; return b->state[1] ? -1 : ATK_MTT_BOXES; }+static bool ends_mttbox(Battle *b, Monster *m) {+ (void)m;+ if (b->state[1]) b->result = BR_SCRIPTED; /* (the battle ends here: the switch is flipped) */+ return false;+}++/* ---------------------------------------------------------------- Mettaton EX: the show's ratings. They start at 4000+ * and fall while Frisk dawdles; Boast raises them through his turn (unless he lands a hit), Pose by how hurt Frisk+ * is, Heel Turn has the crowd cheering every hit on Frisk; his brand's food, the Stick, a fight, a hit taken add+ * more (Junk Food takes some away). Past 12000 (10000 once his legs are gone) his show is a hit, and it ends. His+ * arms fall off after turn 11, his legs after turn 17; from then on, ratings count double */+enum { EXR_START = 4000, EXR_MAX = 30000 };+static struct {+ int ratings, boast, heel, hits, fights, brand, glam, stick, steak, body, last_hp, popup, popup_t, done;+ uint32_t last_frame;+} ex;+void mttex_reset(void) {+ ex.ratings = EXR_START, ex.boast = ex.heel = ex.hits = ex.fights = ex.brand = ex.glam = ex.stick = ex.steak = 0;+ ex.body = 0, ex.last_hp = sv.hp, ex.popup = 0, ex.popup_t = 0, ex.done = 0;+}+int mttex_ratings(void) { return ex.ratings; }+static int ex_target(void) { return ex.body >= 2 ? 10000 : 12000; }+static void ratings_add(int n) {+ if (n > 0 && ex.body >= 2) n *= 2;+ ex.ratings = min_i(EXR_MAX, max_i(0, ex.ratings + n));+ ex.popup = n, ex.popup_t = 45;+}+/* a hit on Frisk in his turn: Boast lost (the crowd's disappointed), or the crowd cheers */+static void ex_hit_taken(void) {+ if (ex.boast) {+ ex.boast = 0;+ ratings_add(-100);+ return;+ }+ static const int16_t violence[5] = {50, 25, 20, 15, 10};+ ratings_add(violence[min_i(ex.hits, 4)] + (ex.heel ? 100 : 0));+ ex.hits++;+}+static void act_mttex(Battle *b, Monster *m, int act, char *t, int cap) {+ (void)b, (void)m;+ if (act == 0) {+ snprintf(t, (size_t)cap, "* You say you won't get hit even\n once.\n* Ratings climb through his turn.");+ ex.boast = 1;+ } else if (act == 1) {+ int n = sv.hp == 1 ? 600 : sv.hp < 4 ? 500 : sv.hp * 4 < sv.maxhp ? 400 : sv.hp * 2 < sv.maxhp ? 250 : sv.hp * 3 < sv.maxhp * 2 ? 150 : 100;+ const char *how = n >= 500 ? "With the last of your strength,\n you pose. The audience screams." :+ n >= 400 ? "Wounded as you are, you pose.\n The audience gasps." :+ n >= 150 ? "Hurt as you are, you pose.\n The audience applauds." : "You pose dramatically.\n The audience nods.";+ snprintf(t, (size_t)cap, "* %s", how);+ ratings_add(n);+ } else {+ snprintf(t, (size_t)cap, "* You turn and sneer at the\n audience.\n* They want to see you hit!");+ ex.heel = 1;+ }+}+static bool item_mttex(Battle *b, Monster *m, int item, char *t, int cap) {+ (void)b, (void)m, (void)t, (void)cap;+ switch (item) {+ case ITEM_STICK:+ snprintf(t, (size_t)cap, "* You throw the Stick.\n* Mettaton catches it in his teeth,\n and winks.");+ ratings_add(ex.stick++ ? 1 : 700);+ return true;+ case ITEM_MYSTERY_KEY:+ snprintf(t, (size_t)cap, "* You hold up the Mystery Key.\n* Mettaton pretends not to see it.");+ return true;+ case ITEM_GLAMBURGER: ratings_add(ex.glam++ ? 300 : 500); break;+ case ITEM_STARFAIT: case ITEM_LEGENDARY_HERO: ratings_add(ex.brand++ ? 200 : 300); break;+ case ITEM_STEAK: ratings_add(700); break;+ case ITEM_JUNK_FOOD: ratings_add(-50); break;+ }+ return false; /* (eaten as ever) */+}+static bool hit_mttex(Battle *b, Monster *m, int dmg) {+ (void)b, (void)m, (void)dmg;+ static const int16_t action[5] = {300, 200, 150, 100, 50};+ ratings_add(action[min_i(ex.fights++, 4)]);+ return false;+}+static const char *talk_mttex(Battle *b, Monster *m) {+ (void)m;+ if (ex.ratings >= ex_target()) {+ ex.done = 1;+ return "OOH! THESE\nRATINGS!\nTHEY'RE\nINCREDIBLE!";+ }+ if (b->turn == 11) return "OH MY! MY\nARMS!\nSTILL... THE\nSHOW GOES ON!";+ if (b->turn == 17) return "MY LEGS?!\n...FINE.\nTHE FINALE,\nTHEN!";+ if (b->turn == 10) return "A UNION\nBREAK,\nDARLING.\nENJOY IT.";+ if (b->turn <= 1) return "LIGHTS!\nCAMERA!\nAND...\nGO!";+ static const char *const lines[] = {"ISN'T THIS\nBODY JUST\nDIVINE?", "SMILE FOR\nTHE CAMERA!", "THE CROWD\nLOVES YOU...\nFOR NOW!",+ "RATINGS!\nRATINGS!", "LET'S MAKE\nTHIS\nBEAUTIFUL!", "ONE MORE\nTIME, WITH\nFEELING!"};+ return lines[rnd_n(6)];+}+static const char *flavor_mttex(Battle *b, Monster *m) {+ (void)m;+ /* his limbs, after their turns */+ if (b->turn == 12 && ex.body < 1) ex.body = 1;+ if (b->turn == 18 && ex.body < 2) ex.body = 2;+ if (b->turn <= 1) return "* Mettaton EX makes his premiere!";+ if (ex.body == 2) return "* Mettaton's legs are gone.\n* He keeps on smiling.";+ if (ex.body == 1) return "* Mettaton's arms are gone.\n* The show must go on.";+ static const char *const lines[] = {"* Mettaton strikes a pose.", "* The audience watches, breathless.",+ "* Smells like a premiere.", "* The spotlight is on you both."};+ return lines[rnd_n(4)];+}+/* his turns, as the wiki lists them, shortened; from turn 18, the last two in turn */+static int attack_mttex(Battle *b, Monster *m) {+ (void)m;+ static const uint8_t seq[] = {ATK_EX_LEGS, ATK_EX_BOMBS, ATK_EX_ARMS, ATK_EX_HEART, ATK_EX_BOTS, ATK_EX_DISCO,+ ATK_EX_DISCO, ATK_EX_PAIRS, ATK_EX_PAIRS, ATK_EX_BREAK, ATK_EX_HEART, ATK_EX_REWIND,+ ATK_EX_REWIND, ATK_EX_LEGS, ATK_EX_BOTS, ATK_EX_PAIRS, ATK_EX_HEART, ATK_EX_LASER,+ ATK_EX_BOTS};+ int n = (int)sizeof seq;+ int i = b->turn - 1;+ if (i >= n) i = n - 2 + (i - n) % 2;+ ex.last_hp = sv.hp;+ return seq[max_i(0, i)];+}+static bool ends_mttex(Battle *b, Monster *m) {+ (void)m;+ if (ex.done) b->result = BR_SCRIPTED;+ return false;+}+static void draw_mttex(Battle *b, Monster *m, int x, int y) {+ (void)b;+ /* (the ratings fall while Frisk takes their time) */+ if (g_frame != ex.last_frame) {+ ex.last_frame = g_frame;+ if (battle_ui() != BUI_NONE && g_frame % 6 == 0) ex.ratings = max_i(0, ex.ratings - 1);+ if (ex.popup_t) ex.popup_t--;+ }+ uint16_t s = m->hurt ? SPR_MTTEX_HURT : ex.body == 2 ? SPR_MTTEX_TOP : ex.body == 1 ? SPR_MTTEX_ARMLESS : SPR_MTTEX_B;+ int fr = m->hurt || ex.body ? 0 : (int)(g_frame / 3);+ if (m->dust) {+ int a = 255 - m->dust * 4;+ if (a > 0) gfx_sprite_color(s, 0, x, y, 0, C_WHITE, (uint8_t)a);+ return;+ }+ gfx_sprite(s, fr, x, y - (s == SPR_MTTEX_TOP ? 50 : 0), 0, m->fade ? (uint8_t)max_i(0, 128 - m->fade * 4) : 255);+ char r[32];+ snprintf(r, sizeof r, "RATINGS %d", ex.ratings);+ gfx_text(FONT_SMALL, 226, 6, r, C_WHITE, 255);+ if (ex.popup_t) {+ snprintf(r, sizeof r, "%+d", ex.popup);+ gfx_text(FONT_SMALL, 262, 16, r, ex.popup < 0 ? C_RED : C_YELLOW, 255);+ }+}++/* ---------------------------------------------------------------- the definitions */+static const MonDef core_defs[MON_COUNT - MON_HT_COUNT] = {+ [MON_FFROGGIT - MON_HT_COUNT] = {+ .name = "Final Froggit", .spare_gold = 50, .hp = 100, .at = 8, .df = 0, .exp = 120, .gold = 80,+ .spr_idle = SPR_FFROGGIT_B, .spr_hurt = SPR_FFROGGIT_HURT, .idle_speed = 6, .check = "Its future looks brighter and brighter.",+ .acts = {"Compliment", "Threaten", "Mystify"}, .nacts = 3,+ .neutral = {"* Final Froggit knows exactly why it's here.", "* Smells like mustard seed.",+ "* Final Froggit hops up and down, ominously."},+ .low_hp = "* Final Froggit stands its ground.", .spareable = "* Final Froggit seems reluctant to fight you.",+ .act = act_ffroggit, .talk = talk_ffroggit, .attack = attack_ffroggit},+ [MON_WHIMSALOT - MON_HT_COUNT] = {+ .name = "Whimsalot", .spare_gold = 50, .hp = 95, .at = 8, .df = 0, .exp = 110, .gold = 80,+ .spr_idle = SPR_WHIMSALOT_B, .spr_hurt = SPR_WHIMSALOT_HURT, .idle_speed = 6, .check = "It finally stopped worrying.",+ .acts = {"Console", "Terrorize", "Pray"}, .nacts = 3,+ .neutral = {"* Whimsalot spins its weapon around.", "* Smells like nightshade and bleach.",+ "* Whimsalot flutters silently.", "* Whimsalot locks eyes with you."},+ .low_hp = "* Whimsalot's flying stutters.", .spareable = "* Whimsalot doesn't want to fight anymore.",+ .act = act_whimsalot, .talk = talk_whimsalot, .attack = attack_whimsalot},+ [MON_ASTIG - MON_HT_COUNT] = {+ .name = "Astigmatism", .spare_gold = 50, .hp = 120, .at = 8, .df = 0, .exp = 130, .gold = 85,+ .spr_idle = SPR_ASTIG_B, .spr_hurt = SPR_ASTIG_HURT, .idle_speed = 8, .check = "This bully ALWAYS gets its way.",+ .acts = {"Pick On", "Don't Pick", "Challenge"}, .nacts = 3,+ .neutral = {"* Astigmatism gazes through your SOUL.", "* Astigmatism clicks its teeth.", "* Smells like glasses.",+ "* Astigmatism gives you a hypnotic glare."},+ .low_hp = "* Astigmatism is watering.",+ .act = act_astig, .talk = talk_astig, .attack = attack_astig, .flavor = flavor_astig},+ [MON_MADJICK - MON_HT_COUNT] = {+ .name = "Madjick", .spare_gold = 60, .hp = 190, .at = 8, .df = 0, .exp = 150, .gold = 120,+ .spr_idle = SPR_MADJICK_B, .spr_hurt = SPR_MADJICK_HURT, .idle_speed = 6, .check = "This magic mercenary only says magic words.",+ .acts = {"Talk", "Stare", "Clear Mind"}, .nacts = 3,+ .neutral = {"* Madjick does a mysterious jig.", "* Madjick flaunts its orbs.", "* Smells like magic.",+ "* Madjick whispers arcane swear words."},+ .act = act_madjick, .talk = talk_madjick, .attack = attack_madjick, .flavor = flavor_madjick, .on_item = item_madjick},+ [MON_KNIGHT - MON_HT_COUNT] = {+ .name = "Knight Knight", .spare_gold = 70, .hp = 230, .at = 8, .df = 2, .exp = 180, .gold = 150, .dy = 6,+ .spr_idle = SPR_KNIGHT_B, .spr_hurt = SPR_KNIGHT_HURT, .idle_speed = 8, .check = "This mercenary swings the Good Morningstar.",+ .acts = {"Talk", "Sing"}, .nacts = 2,+ .neutral = {"* Knight Knight smashes her morningstar.", "* Knight Knight breathes deeply.", "* Smells like stardust.",+ "* Knight Knight watches quietly."},+ .act = act_knight, .talk = talk_knight, .attack = attack_knight, .flavor = flavor_knight},+ [MON_MTT_BOX - MON_HT_COUNT] = {+ .name = "Mettaton", .hp = 9999, .at = 6, .df = 0, .spr_idle = SPR_MTT_B, .spr_hurt = SPR_MTT_B, .idle_speed = 6,+ .check = "His metal body makes him invincible.", .acts = {"Turn"}, .nacts = 1,+ .flags = MF_BOSS | MF_NOT_KILLABLE, .act = act_mttbox, .talk = talk_mttbox, .attack = attack_mttbox,+ .flavor = flavor_mttbox, .on_hit = hit_mttbox, .ends = ends_mttbox},+ [MON_MTT_EX - MON_HT_COUNT] = {+ .name = "Mettaton EX", .hp = 1600, .at = 6, .df = 1, .exp = 800, .gold = 0, .spr_idle = SPR_MTTEX_B,+ .spr_hurt = SPR_MTTEX_HURT, .idle_speed = 3, .check = "His weak point is his heart-shaped core.",+ .acts = {"Boast", "Pose", "Heel Turn"}, .nacts = 3,+ .flags = MF_BOSS, .act = act_mttex, .talk = talk_mttex, .attack = attack_mttex, .flavor = flavor_mttex,+ .on_hit = hit_mttex, .draw = draw_mttex, .ends = ends_mttex, .on_item = item_mttex},+};+const MonDef *core_mon_def(int id) { return &core_defs[id - MON_HT_COUNT]; }++static const Form core_forms[FORM_COUNT - FORM_HT_COUNT] = {+ [FORM_ASTIG - FORM_HT_COUNT] = {{MON_ASTIG}, 1, "* Astigmatism draws near."},+ [FORM_WHIM_FROG - FORM_HT_COUNT] = {{MON_WHIMSALOT, MON_FFROGGIT}, 2, "* Whimsalot and Final Froggit appear."},+ [FORM_WHIM_ASTIG - FORM_HT_COUNT] = {{MON_WHIMSALOT, MON_ASTIG}, 2, "* Whimsalot and Astigmatism appear."},+ [FORM_FROG_ASTIG - FORM_HT_COUNT] = {{MON_FFROGGIT, MON_ASTIG}, 2, "* Final Froggit and Astigmatism appear."},+ [FORM_KNIGHT_MADJICK - FORM_HT_COUNT] = {{MON_KNIGHT, MON_MADJICK}, 2, "* Mercenaries step out of the\n shadows."},+ [FORM_FROG_ASTIG_WHIM - FORM_HT_COUNT] = {{MON_FFROGGIT, MON_ASTIG, MON_WHIMSALOT}, 3, "* What a nightmare!"},+ [FORM_KNIGHT - FORM_HT_COUNT] = {{MON_KNIGHT}, 1, "* Knight Knight blocks the way!"},+ [FORM_MADJICK - FORM_HT_COUNT] = {{MON_MADJICK}, 1, "* Madjick pops out of its hat!"},+ [FORM_MTT_BOX - FORM_HT_COUNT] = {{MON_MTT_BOX}, 1, "* Mettaton attacks!"},+ [FORM_MTT_EX - FORM_HT_COUNT] = {{MON_MTT_EX}, 1, "* Mettaton EX makes his premiere!"},+};+const Form *core_form(int form) { return &core_forms[form - FORM_HT_COUNT]; }++/* random encounters in the Core Branch (Astigmatism alone just once) */+int core_encounter(int room) {+ if (room != ROOM_CORE_BRANCH) return -1;+ static const uint8_t pool[] = {FORM_WHIM_FROG, FORM_WHIM_ASTIG, FORM_FROG_ASTIG, FORM_KNIGHT_MADJICK,+ FORM_FROG_ASTIG_WHIM, FORM_KNIGHT, FORM_MADJICK};+ if (!flag(F_CORE_ASTIG)) {+ set_flag(F_CORE_ASTIG, 1);+ return FORM_ASTIG;+ }+ return pool[rnd_n((int)sizeof pool)];+}++/* ---------------------------------------------------------------- the attacks */+static int bx0(void) { return bt.x0 + 3; }+static int bx1(void) { return bt.x1 - 3; }+static int by0(void) { return bt.y0 + 3; }+static int by1(void) { return bt.y1 - 3; }+#define P(v) ((v) * FX)+static Bullet *shot(uint16_t spr, int x, int y, int vx, int vy) {+ Bullet *b = bullet_new(spr, P(x), P(y), vx, vy);+ if (b) b->owner = (uint8_t)bt.atk_owner;+ return b;+}+static Bullet *rect(int x, int y, int w, int h, int vx, int vy) {+ Bullet *b = shot(SPR_RECT, x, y, vx, vy);+ if (b) b->flags |= BF_BOX, b->w = (int16_t)w, b->h = (int16_t)h;+ return b;+}+/* a shot of the yellow SOUL's within (rx, ry) of b: it's spent */+static bool shot_at(const Bullet *b, int rx, int ry) {+ 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 - b->x) < P(rx) && abs_i(s->y - b->y) < P(ry)) {+ s->kind = BK_NONE;+ return true;+ }+ }+ return false;+}+static int count_spr(uint16_t spr) {+ int n = 0;+ for (int i = 0; i < MAX_BULLETS; i++) n += bullets[i].kind != BK_NONE && bullets[i].spr == spr;+ return n;+}++/* Madjick: a chaser orb that leaves crosses behind; a corner orb, where the SOUL heads, firing crosses at it */+static void atk_madjick_chaser(int t) {+ static Bullet *orb;+ if (t == 0) {+ orb = shot(SPR_ORB, bx1() - 8, by0() + 8, 0, 0);+ if (orb) orb->kind = BK_HOMING, orb->a = 3, orb->b = P(2), orb->r = 5;+ }+ if (orb && orb->kind == BK_HOMING && t % 14 == 7 && t < 150) {+ Bullet *c = shot(SPR_STAR, orb->x / FX, orb->y / FX, 0, 0);+ if (c) c->r = 3, c->life = 70;+ }+}+static void atk_madjick_corner(int t) {+ static Bullet *orb;+ static int corner;+ if (t == 0) corner = 0, orb = shot(SPR_ORB, bx1() - 6, by0() + 6, 0, 0);+ if (!orb || orb->spr != SPR_ORB) return;+ orb->flags |= BF_HARMLESS;+ /* (it moves to the corner of the way the SOUL went last) */+ int c = soul_x() < board_cx() ? (soul_y() < board_cy() ? 1 : 2) : (soul_y() < board_cy() ? 0 : 3);+ if (t % 30 == 0) corner = c;+ int tx = corner == 1 || corner == 2 ? bx0() + 6 : bx1() - 6, ty = corner == 0 || corner == 1 ? by0() + 6 : by1() - 6;+ orb->x += (P(tx) - orb->x) / 6, orb->y += (P(ty) - orb->y) / 6;+ if (t % 12 == 6 && t < 150) {+ int dx = soul_x() - orb->x / FX, dy = soul_y() - orb->y / FX, d = abs_i(dx) + abs_i(dy);+ if (d) {+ Bullet *s = shot(SPR_STAR, orb->x / FX, orb->y / FX, dx * P(3) / d, dy * P(3) / d);+ if (s) s->r = 3;+ }+ }+}+/* Knight Knight: the Moon's meteors from the top left; the Sun's flares, spiralling out; her morningstars' slams */+static void atk_knight_moon(int t) {+ if (t % 6 == 0 && t < 150) {+ int x = bx0() - 30 + rnd_n(bx1() - bx0()), y = by0() - 10;+ Bullet *s = shot(SPR_STAR, x, y, P(2), P(3));+ if (s) s->r = 3;+ }+}+static void atk_knight_sun(int t) {+ static Bullet *sun;+ if (t == 0) {+ sun = shot(SPR_ORB, board_cx(), board_cy(), 0, 0);+ if (sun) sun->r = 5;+ }+ if (t % 4 == 0 && t < 150) {+ int a = t * 5;+ for (int k = 0; k < 2; k++) {+ int aa = a + k * 128;+ Bullet *s = shot(SPR_STAR, board_cx(), board_cy(), gfx_cos(aa) * 2 * FX / 1024, gfx_sin(aa) * 2 * FX / 1024);+ if (s) s->r = 3;+ }+ }+ if (sun && t == 150) sun->kind = BK_NONE;+}+static void atk_knight_star(int t) {+ /* five heads, at the top or the bottom; they shine a moment, then slam across */+ static int8_t top;+ int k = t % 50;+ if (k == 0 && t < 150) {+ top = (int8_t)rnd_n(2);+ int w = bx1() - bx0();+ for (int i = 0; i < 5; i++) {+ if (i == rnd_n(5)) continue;+ Bullet *s = shot(SPR_ORB, bx0() + w * (2 * i + 1) / 10, top ? by0() + 4 : by1() - 4, 0, 0);+ if (s) s->r = 6, s->flags |= BF_HARMLESS, s->life = 50, s->alpha = 120;+ }+ }+ if (k == 15)+ for (int i = 0; i < MAX_BULLETS; i++)+ if (bullets[i].kind != BK_NONE && bullets[i].spr == SPR_ORB && (bullets[i].flags & BF_HARMLESS))+ bullets[i].flags &= (uint8_t)~BF_HARMLESS, bullets[i].alpha = 255, bullets[i].vy = top ? P(5) : -P(5);+}++/* Mettaton EX's. Shooting what he sends (the yellow SOUL) is good for the ratings, as his heart is */+static void ex_watch_hits(void) {+ if (sv.hp < ex.last_hp) ex_hit_taken();+ ex.last_hp = sv.hp;+ if (ex.boast && bt.atk_t % 9 == 0) ratings_add(3 + (bt.atk_t / 9) % 2);+}+static void atk_ex_legs(int t) {+ if (t % 26 == 0 && t < 130) {+ bool left = rnd_n(2);+ int y = by0() + 6 + rnd_n(by1() - by0() - 12);+ Bullet *w = rect(left ? bx0() + 2 : bx1() - 2, y, 3, 9, 0, 0); /* the warning: where it comes */+ if (w) w->flags |= BF_HARMLESS, w->color = BC_ORANGE, w->life = 12;+ Bullet *l = shot(SPR_EXLEG, left ? bx0() - 40 : bx1() + 40, y, left ? P(7) : -P(7), 0);+ if (l) l->flags |= BF_BOX, l->w = 56, l->h = 7, l->angle = 64, l->c = 12, l->kind = BK_SCRIPT;+ }+ /* (after their warning, they kick across) */+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *l = &bullets[i];+ if (l->kind != BK_SCRIPT || l->spr != SPR_EXLEG) continue;+ if (l->c) l->c--;+ else l->x += l->vx;+ if (l->x < P(bx0() - 70) || l->x > P(bx1() + 70)) l->kind = BK_NONE;+ }+}+/* rows of bombs and blocks; a shot bomb blows up its row and its column; with `rewind`, back up they come */+static void ex_blast(int x, int y) {+ Bullet *h = rect(board_cx(), y, bx1() - bx0(), 6, 0, 0);+ if (h) h->life = 8, h->color = BC_WHITE;+ Bullet *v = rect(x, board_cy(), 6, by1() - by0(), 0, 0);+ if (v) v->life = 8;+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind == BK_NONE || (b->spr != SPR_EXBLOCK && b->spr != SPR_BOMB)) continue;+ if (abs_i(b->y / FX - y) < 6 || abs_i(b->x / FX - x) < 6) b->kind = BK_NONE;+ }+}+static void ex_rows(int t, bool rewind, int cells) {+ int w = bx1() - bx0(), cw = w / cells;+ if (t % 34 == 0 && t < (rewind ? 100 : 136)) {+ int bomb = rnd_n(cells);+ for (int k = 0; k < cells; k++) {+ bool is_bomb = rewind ? k == bomb : k != bomb;+ Bullet *b = shot(is_bomb ? SPR_BOMB : SPR_EXBLOCK, bx0() + cw * k + cw / 2, by0() - 8, 0, P(1));+ if (b) b->r = 6, b->flags |= BF_NOCLIP, b->kind = BK_SCRIPT, b->vy = P(1);+ }+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || (b->spr != SPR_EXBLOCK && b->spr != SPR_BOMB)) continue;+ if (rewind && t == 110) b->vy = -P(1);+ b->y += b->vy;+ if (shot_at(b, 7, 7)) {+ ratings_add(20);+ b->kind = BK_NONE;+ if (b->spr == SPR_BOMB) ex_blast(b->x / FX, b->y / FX);+ }+ if (b->y > P(by1() + 30) || b->y < P(by0() - 40)) b->kind = BK_NONE;+ }+}+/* pairs: a bomb beside a block; only the bomb's blast breaks the block */+static void atk_ex_pairs(int t) {+ int w = bx1() - bx0();+ if (t % 36 == 0 && t < 144) {+ int side = rnd_n(2);+ for (int k = 0; k < 2; k++) {+ Bullet *b = shot(k == side ? SPR_BOMB : SPR_EXBLOCK, bx0() + w / 4 + k * w / 2, by0() - 8, 0, 0);+ if (b) b->r = 6, b->flags |= BF_NOCLIP, b->kind = BK_SCRIPT, b->vy = P(1) + P(1) / 4;+ }+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || (b->spr != SPR_EXBLOCK && b->spr != SPR_BOMB)) continue;+ b->y += b->vy;+ if (b->spr == SPR_BOMB && shot_at(b, 7, 7)) {+ ratings_add(20);+ int x = b->x / FX, y = b->y / FX;+ b->kind = BK_NONE;+ for (int j = 0; j < MAX_BULLETS; j++) /* its block, beside it */+ if (bullets[j].kind == BK_SCRIPT && bullets[j].spr == SPR_EXBLOCK && abs_i(bullets[j].y / FX - y) < 6) bullets[j].kind = BK_NONE;+ Bullet *v = rect(x, board_cy(), 6, by1() - by0(), 0, 0); /* (and its column, up and down) */+ if (v) v->life = 8;+ } else if (b->spr == SPR_EXBLOCK) shot_at(b, 7, 7); /* (a block just stops a shot) */+ if (b->y > P(by1() + 30)) b->kind = BK_NONE;+ }+}+/* his long arms come down; shooting the box on one sends it back up */+static void atk_ex_arms(int t) {+ if (t % 40 == 0 && t < 120) {+ int w = bx1() - bx0();+ for (int k = 0; k < 3; k++) {+ int x = bx0() + w * (2 * k + 1) / 6 + (t / 40 % 2 ? 8 : -8);+ Bullet *a = rect(x, by0() - 40, 4, 70, 0, 0);+ if (!a) continue;+ a->kind = BK_SCRIPT, a->vy = P(1), a->flags |= BF_NOCLIP, a->a = 1;+ Bullet *box = shot(SPR_EXARM, x, by0() - 5, 0, 0);+ if (box) box->kind = BK_SCRIPT, box->vy = P(1), box->flags |= BF_NOCLIP | BF_HARMLESS, box->a = 2, box->b = (int16_t)(a - bullets);+ }+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || (b->a != 1 && b->a != 2)) continue;+ b->y += b->vy;+ if (b->a == 2 && b->vy > 0 && shot_at(b, 7, 8)) {+ ratings_add(20);+ b->vy = -P(3);+ Bullet *arm = &bullets[b->b];+ if (arm->kind == BK_SCRIPT && arm->a == 1) arm->vy = -P(3);+ }+ if (b->y < P(by0() - 80) || b->y > P(by1() + 60)) b->kind = BK_NONE;+ }+}+/* his heart, out of his waist: sparks in a ring, again and again; enough shots at it and his turn is over */+static Bullet *heart;+static int heart_hp;+static void atk_ex_heart(int t, bool laser) {+ if (t == 0) {+ heart = shot(SPR_MTTHEART, board_cx(), by0() + 12, laser ? P(2) : P(1), 0);+ if (heart) heart->kind = BK_SCRIPT, heart->flags |= BF_HARMLESS | BF_NOCLIP;+ heart_hp = laser ? 25 : 20;+ }+ Bullet *h = heart;+ if (!h || h->kind != BK_SCRIPT || h->spr != SPR_MTTHEART) return;+ h->x += h->vx;+ if (h->x < P(bx0() + 8) || h->x > P(bx1() - 8)) h->vx = -h->vx;+ if (h->c) h->c--, h->alpha = h->c % 2 ? 90 : 255;+ if (shot_at(h, 9, 8)) heart_hp--, h->c = 6, ratings_add(20);+ if (t % 30 == 29) heart_hp--; /* (it runs down by itself, too) */+ if (heart_hp <= 0) {+ h->kind = BK_NONE;+ bt.atk_len = min_i(bt.atk_len, t + 20);+ return;+ }+ if (!laser && t % 28 == 14) {+ for (int k = 0; k < 8; k++) {+ int a = k * 32 + t;+ Bullet *s = shot(SPR_BOLT, h->x / FX, h->y / FX, gfx_cos(a) * 3 * FX / 2048, gfx_sin(a) * 3 * FX / 2048);+ if (s) s->r = 3;+ }+ }+ if (laser && t % 20 == 10) { /* three lines of sparks, at where the SOUL is */+ int dx = soul_x() - h->x / FX, dy = soul_y() - h->y / FX, d = abs_i(dx) + abs_i(dy);+ if (d)+ for (int k = -1; k <= 1; k++) {+ Bullet *s = shot(SPR_BOLT, h->x / FX, h->y / FX, (dx + k * 12) * P(3) / d, dy * P(3) / d);+ if (s) s->r = 3;+ }+ }+}+/* his bots: a swarm coming down; all shot, and his turn is over */+static void atk_ex_bots(int t) {+ if (t == 0) {+ int w = bx1() - bx0();+ for (int k = 0; k < 9; k++) {+ Bullet *b = shot(SPR_MTTMINI, bx0() + w * (k % 3 * 2 + 1) / 6, by0() - 14 - (k / 3) * 26, 0, 0);+ if (b) b->kind = BK_SCRIPT, b->r = 7, b->flags |= BF_NOCLIP, b->vy = P(1) / 2, b->a = (int16_t)rnd_n(256);+ }+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || b->spr != SPR_MTTMINI) continue;+ b->y += b->vy, b->a = (int16_t)(b->a + 4);+ b->x += gfx_sin(b->a) * FX / 1024;+ if (shot_at(b, 8, 10)) b->kind = BK_NONE, ratings_add(20);+ if (b->y > P(by1() + 20)) b->kind = BK_NONE;+ }+ if (t > 10 && !count_spr(SPR_MTTMINI)) bt.atk_len = min_i(bt.atk_len, t + 10);+}+/* the disco ball: its beams sweep across the board, blue or white; a shot at the ball turns them */+static void atk_ex_disco(int t, bool fast) {+ static Bullet *ball;+ static uint8_t col;+ if (t == 0) {+ ball = shot(SPR_DISCO, board_cx(), by0() + 8, 0, 0);+ if (ball) ball->kind = BK_SCRIPT, ball->flags |= BF_HARMLESS | BF_NOCLIP;+ col = BC_BLUE;+ }+ if (ball && ball->kind == BK_SCRIPT && ball->spr == SPR_DISCO && shot_at(ball, 9, 9)) {+ col = col == BC_BLUE ? BC_WHITE : BC_BLUE;+ ratings_add(5);+ for (int i = 0; i < MAX_BULLETS; i++)+ if (bullets[i].kind != BK_NONE && bullets[i].spr == SPR_RECT && bullets[i].a == 3) bullets[i].color = col;+ }+ int every = fast ? 22 : 34;+ if (t > (fast ? 10 : 40) && t % every == 0 && t < 140) {+ bool left = (t / every) % 2;+ Bullet *b = rect(left ? bx0() : bx1(), board_cy(), 3, by1() - by0(), left ? P(fast ? 3 : 2) : -P(fast ? 3 : 2), 0);+ if (b) b->color = col, b->a = 3, b->life = 120;+ }+}++int core_attack_length(int atk) {+ switch (atk) {+ case ATK_EX_BREAK: return 90;+ case ATK_EX_REWIND: return 200;+ default: return 165;+ }+}++void core_attack_run(Battle *b, int atk, int t) {+ (void)b;+ bool ex_atk = atk >= ATK_EX_LEGS;+ if (t < 0) {+ int w = atk == ATK_EX_BOMBS || atk == ATK_EX_REWIND ? 76 : atk == ATK_EX_PAIRS ? 44 : ex_atk ? 120 : 130;+ board_set(w, ex_atk ? 110 : 100);+ soul_set_mode(atk == ATK_EX_LEGS || atk == ATK_EX_BREAK || !ex_atk ? SOUL_RED : SOUL_YELLOW);+ heart = NULL;+ return;+ }+ if (ex_atk) ex_watch_hits();+ switch (atk) {+ case ATK_MADJICK_CHASER: atk_madjick_chaser(t); break;+ case ATK_MADJICK_CORNER: atk_madjick_corner(t); break;+ case ATK_KNIGHT_MOON: atk_knight_moon(t); break;+ case ATK_KNIGHT_SUN: atk_knight_sun(t); break;+ case ATK_KNIGHT_STAR: atk_knight_star(t); break;+ case ATK_EX_LEGS: atk_ex_legs(t); break;+ case ATK_EX_BOMBS: ex_rows(t, false, 4); break;+ case ATK_EX_REWIND: ex_rows(t, true, 4); break;+ case ATK_EX_ARMS: atk_ex_arms(t); break;+ case ATK_EX_HEART: atk_ex_heart(t, false); break;+ case ATK_EX_LASER: atk_ex_heart(t, true); break;+ case ATK_EX_BOTS: atk_ex_bots(t); break;+ case ATK_EX_DISCO: atk_ex_disco(t, ex.hits < 2 && bt.turn >= 7); break;+ case ATK_EX_PAIRS: atk_ex_pairs(t); break;+ case ATK_EX_BREAK: break;+ }+}diff --git a/games/undertale/src/data.bin b/games/undertale/src/data.binindex 7e7f61b6..aa5c826d 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 14cfa729..54edd254 100644--- a/games/undertale/src/data.h+++ b/games/undertale/src/data.h@@ -208,117 +208,139 @@#define SPR_BURGERPANTS 194#define SPR_SHOP_BRATTY 195#define SPR_BRATTY_CATTY 196-#define SPR_BIRD 197-#define SPR_TUTU 198-#define SPR_ARTIFACT 199-#define SPR_ECHO_OW 200-#define SPR_ALPHYS_OW 201-#define SPR_MTT_OW 202-#define SPR_MTT_B 203-#define SPR_RGUARDS_OW 204-#define SPR_VENT_D 205-#define SPR_VENT_U 206-#define SPR_VENT_L 207-#define SPR_VENT_R 208-#define SPR_BURNTPAN 209-#define SPR_VULKIN_B 210-#define SPR_VULKIN_HURT 211-#define SPR_TSUNDER_B 212-#define SPR_PYROPE_B 213-#define SPR_PYROPE_HURT 214-#define SPR_RG01_OW 215-#define SPR_RG02_OW 216-#define SPR_RG01_B 217-#define SPR_RG02_B 218-#define SPR_MTT_NEWS 219-#define SPR_BOMB_BALL 220-#define SPR_BOMB_DOG 221-#define SPR_BOMB_PRESENT 222-#define SPR_BOMB_WATER 223-#define SPR_BOMB_SCRIPT 224-#define SPR_BOMB_GAME 225-#define SPR_NEWS_SCRIPT 226-#define SPR_APRON 227-#define SPR_MUFFET_OW 228-#define SPR_MUFFET_B 229-#define SPR_MUFFET_HURT 230-#define SPR_MUFFET_PET 231-#define SPR_SPIDER_B 232-#define SPR_DIAMOND1 233-#define SPR_DIAMOND2 234-#define SPR_BOMB_B 235-#define SPR_DOGBOMB_B 236-#define SPR_WATER_B 237-#define SPR_UNDYNE_FALLEN 238-#define SPR_SPEAR 239-#define SPR_ARROW 240-#define SPR_PLANE 241-#define SPR_BOMB 242-#define SPR_CLOUD 243-#define SPR_BOLT 244-#define SPR_UNDYNE_B 245-#define SPR_NOTE 246-#define SPR_DROP 247-#define SPR_ARM 248-#define SPR_DEBRIS 249-#define SPR_STAR 250-#define SPR_CROISSANT 251-#define SPR_DONUT 252-#define SPR_MTTMINI 253-#define SPR_AARON_B 254-#define SPR_AARON_HURT 255-#define SPR_WOSHUA_B 256-#define SPR_WOSHUA_HURT 257-#define SPR_MOLDBYGG_B 258-#define SPR_SHYREN_B 259-#define SPR_SHYREN_TURNED 260-#define SPR_INTROIMAGE 261-#define SPR_INTROLAST 262-#define SPR_UNDERTALETITLE 263-#define SPR_GAMEOVERBG 264-#define SPR_FACE_TORIELTALK 265-#define SPR_FACE_TORIELTALKSIDE 266-#define SPR_FACE_TORIELHAPPYTALK 267-#define SPR_FACE_TORIELWHAT 268-#define SPR_FACE_TORIELWHATSIDE 269-#define SPR_FACE_TORIELMAD 270-#define SPR_FACE_TORIELCOLD 271-#define SPR_FACE_TORIELSURPRISED 272-#define SPR_FACE_TORIELEMBARRASSED 273-#define SPR_FACE_TORIELGLASSES 274-#define SPR_FACE_TORIELREVENGETALK 275-#define SPR_FACE_TORIELSCARED 276-#define SPR_FACE_TORIELBLINK 277-#define SPR_FACE_TORIELHAPPYBLINK 278-#define SPR_FACE_TORIELBODY 279-#define SPR_FACE_SANS 280-#define SPR_FACE_SANSCHUCKLE 281-#define SPR_FACE_SANSWINK 282-#define SPR_FACE_PAPYRUS 283-#define SPR_FACE_PAPYRUSEVIL 284-#define SPR_FACE_PAPYRUSLAUGH 285-#define SPR_FACE_PAPYRUSMAD 286-#define SPR_FACE_PAPYRUSSIDE 287-#define SPR_FACE_ALPHYS 288-#define SPR_FLOWEYNICE 289-#define SPR_FLOWEYNICESIDE 290-#define SPR_FLOWEYSASSY 291-#define SPR_FLOWEYEVIL 292-#define SPR_FLOWEYGRIN 293-#define SPR_FLOWEYPLAIN 294-#define SPR_FLOWEYPISSED 295-#define SPR_FLOWEYWINK 296-#define SPR_FLOWEYLAUGH 297-#define SPR_FLOWEYHURT 298-#define SPR_FLOWEYTORIEL 299-#define SPR_FLOWEYTORIEL2 300-#define SPR_FLOWEYSIDESHOCK 301+#define SPR_FFROGGIT_B 197+#define SPR_FFROGGIT_HURT 198+#define SPR_WHIMSALOT_B 199+#define SPR_WHIMSALOT_HURT 200+#define SPR_ASTIG_B 201+#define SPR_ASTIG_HURT 202+#define SPR_MADJICK_B 203+#define SPR_MADJICK_HURT 204+#define SPR_KNIGHT_B 205+#define SPR_KNIGHT_HURT 206+#define SPR_MTTEX_B 207+#define SPR_MTTEX_HURT 208+#define SPR_MTTEX_ARMLESS 209+#define SPR_MTTEX_TOP 210+#define SPR_MTTEX_OW 211+#define SPR_SAUSAGE 212+#define SPR_EXBLOCK 213+#define SPR_EXLEG 214+#define SPR_MTTHEART 215+#define SPR_DISCO 216+#define SPR_EXARM 217+#define SPR_BIRD 218+#define SPR_TUTU 219+#define SPR_ARTIFACT 220+#define SPR_ECHO_OW 221+#define SPR_ALPHYS_OW 222+#define SPR_MTT_OW 223+#define SPR_MTT_B 224+#define SPR_RGUARDS_OW 225+#define SPR_VENT_D 226+#define SPR_VENT_U 227+#define SPR_VENT_L 228+#define SPR_VENT_R 229+#define SPR_BURNTPAN 230+#define SPR_VULKIN_B 231+#define SPR_VULKIN_HURT 232+#define SPR_TSUNDER_B 233+#define SPR_PYROPE_B 234+#define SPR_PYROPE_HURT 235+#define SPR_RG01_OW 236+#define SPR_RG02_OW 237+#define SPR_RG01_B 238+#define SPR_RG02_B 239+#define SPR_MTT_NEWS 240+#define SPR_BOMB_BALL 241+#define SPR_BOMB_DOG 242+#define SPR_BOMB_PRESENT 243+#define SPR_BOMB_WATER 244+#define SPR_BOMB_SCRIPT 245+#define SPR_BOMB_GAME 246+#define SPR_NEWS_SCRIPT 247+#define SPR_APRON 248+#define SPR_MUFFET_OW 249+#define SPR_MUFFET_B 250+#define SPR_MUFFET_HURT 251+#define SPR_MUFFET_PET 252+#define SPR_SPIDER_B 253+#define SPR_DIAMOND1 254+#define SPR_DIAMOND2 255+#define SPR_BOMB_B 256+#define SPR_DOGBOMB_B 257+#define SPR_WATER_B 258+#define SPR_UNDYNE_FALLEN 259+#define SPR_SPEAR 260+#define SPR_ARROW 261+#define SPR_PLANE 262+#define SPR_BOMB 263+#define SPR_CLOUD 264+#define SPR_BOLT 265+#define SPR_UNDYNE_B 266+#define SPR_NOTE 267+#define SPR_DROP 268+#define SPR_ARM 269+#define SPR_DEBRIS 270+#define SPR_STAR 271+#define SPR_CROISSANT 272+#define SPR_DONUT 273+#define SPR_MTTMINI 274+#define SPR_AARON_B 275+#define SPR_AARON_HURT 276+#define SPR_WOSHUA_B 277+#define SPR_WOSHUA_HURT 278+#define SPR_MOLDBYGG_B 279+#define SPR_SHYREN_B 280+#define SPR_SHYREN_TURNED 281+#define SPR_INTROIMAGE 282+#define SPR_INTROLAST 283+#define SPR_UNDERTALETITLE 284+#define SPR_GAMEOVERBG 285+#define SPR_FACE_TORIELTALK 286+#define SPR_FACE_TORIELTALKSIDE 287+#define SPR_FACE_TORIELHAPPYTALK 288+#define SPR_FACE_TORIELWHAT 289+#define SPR_FACE_TORIELWHATSIDE 290+#define SPR_FACE_TORIELMAD 291+#define SPR_FACE_TORIELCOLD 292+#define SPR_FACE_TORIELSURPRISED 293+#define SPR_FACE_TORIELEMBARRASSED 294+#define SPR_FACE_TORIELGLASSES 295+#define SPR_FACE_TORIELREVENGETALK 296+#define SPR_FACE_TORIELSCARED 297+#define SPR_FACE_TORIELBLINK 298+#define SPR_FACE_TORIELHAPPYBLINK 299+#define SPR_FACE_TORIELBODY 300+#define SPR_FACE_SANS 301+#define SPR_FACE_SANSCHUCKLE 302+#define SPR_FACE_SANSWINK 303+#define SPR_FACE_PAPYRUS 304+#define SPR_FACE_PAPYRUSEVIL 305+#define SPR_FACE_PAPYRUSLAUGH 306+#define SPR_FACE_PAPYRUSMAD 307+#define SPR_FACE_PAPYRUSSIDE 308+#define SPR_FACE_ALPHYS 309+#define SPR_FLOWEYNICE 310+#define SPR_FLOWEYNICESIDE 311+#define SPR_FLOWEYSASSY 312+#define SPR_FLOWEYEVIL 313+#define SPR_FLOWEYGRIN 314+#define SPR_FLOWEYPLAIN 315+#define SPR_FLOWEYPISSED 316+#define SPR_FLOWEYWINK 317+#define SPR_FLOWEYLAUGH 318+#define SPR_FLOWEYHURT 319+#define SPR_FLOWEYTORIEL 320+#define SPR_FLOWEYTORIEL2 321+#define SPR_FLOWEYSIDESHOCK 322#define AREA_RUINS 0#define AREA_SNOWDIN 1#define AREA_SNOWTOWN 2#define AREA_WATERFALL 3#define AREA_HOTLAND 4#define AREA_RESORT 5+#define AREA_CORE 6#define ROOM_AREA1 0#define ROOM_AREA1_2 1#define ROOM_RUINS1 2@@ -484,10 +506,21 @@#define ROOM_RES_DINER 162#define ROOM_RES_HALL 163#define ROOM_RES_ROOM 164+#define ROOM_CORE_APPROACH 165+#define ROOM_CORE_LOBBY 166+#define ROOM_CORE_DOORWAY 167+#define ROOM_CORE_PIT 168+#define ROOM_CORE_WEST 169+#define ROOM_CORE_BRIDGE 170+#define ROOM_CORE_BRANCH 171+#define ROOM_CORE_WARRIOR 172+#define ROOM_CORE_END 173+#define ROOM_CORE_MTT 174+#define ROOM_CORE_HALL 175#define FONT_MAIN 0#define FONT_MENU 1#define FONT_SMALL 2-#define NUM_SPRITES 302-#define NUM_ROOMS 165+#define NUM_SPRITES 323+#define NUM_ROOMS 176#define NUM_FONTS 3#endifdiff --git a/games/undertale/src/events.c b/games/undertale/src/events.cindex fc610da4..f1103511 100644--- a/games/undertale/src/events.c+++ b/games/undertale/src/events.c@@ -126,5 +126,7 @@ int event_run(Ev *c) {if (r >= 0) return r;r = res_event(c);if (r >= 0) return r;+ r = core_event(c);+ if (r >= 0) return r;return 1;}diff --git a/games/undertale/src/events.h b/games/undertale/src/events.hindex 521971a4..efa20028 100644--- a/games/undertale/src/events.h+++ b/games/undertale/src/events.h@@ -54,7 +54,11 @@ enum {EV_BAKESALE3, EV_SHOOT3, EV_HT3_CALL, EV_MUFFET, EV_MUSICAL, EV_TILE, EV_TILES3, EV_HEATS3, EV_HT3_ELEVATOR,EV_NICECREAM3,/* resort.c */- EV_RES_SANS, EV_RES_SHOP, EV_RES_DOOR, EV_RES_DESK, EV_RES_CORE,+ EV_RES_SANS, EV_RES_SHOP, EV_RES_DOOR, EV_RES_DESK,+ /* core.c */+ EV_CORE_APPROACH, EV_CORE_CALL, EV_CORE_ORDER, EV_CORE_BRANCH, EV_CORE_POWER, EV_CORE_LASER, EV_CORE_SWITCH,+ EV_CORE_MADJICK, EV_CORE_KNIGHT, EV_CORE_SAGE, EV_CORE_WARRIOR, EV_CORE_WSWITCH, EV_CORE_FIELD, EV_CORE_TRASH,+ EV_CORE_LIFT, EV_CORE_MTT, EV_CORE_HALL,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 fd3f3c39..331b36df 100644--- a/games/undertale/src/flags.h+++ b/games/undertale/src/flags.h@@ -161,7 +161,23 @@ enum {F_RES_BUN,F_RES_ROOM, /* the hotel's room: 1 paid for, 2 slept in */F_RES_DOG, /* the Hot Dog slid under door 4 (for a Hush Puppy) */- F_RES_CORE, /* the CORE's door reached (where the game now ends) */+ F_CORE_IN, /* the CORE's approach: the black shapes seen backing away inside */+ F_CORE_CALLS, /* Alphys's calls in the CORE, a bit each (core.c's CALL_*), then the rest */+ F_CORE_CALLS2,+ F_CORE_MADJICK, /* the doorway's ambush, the room north of the crossroads: 1 spared, 2 killed */+ F_CORE_KNIGHT,+ F_CORE_SWITCH, /* the switch by the laser ambush pressed */+ F_CORE_POWER, /* the laser bridge: 1 its power cut, 2 crossed */+ F_CORE_SAGE, /* the sage's path's puzzle solved */+ F_CORE_WARRIOR, /* the warrior's path: its fights won (1 to 3), 4 its switch flipped */+ F_CORE_FIELD, /* the force field before The End down */+ F_CORE_TRASH1, /* the trash cans: the Glamburger, the 100G */+ F_CORE_TRASH2,+ F_CORE_ASTIG, /* Astigmatism met on its own (just once) */+ F_CORE_END, /* the Core End reached (the lobby's elevator works) */+ F_CORE_MTT, /* Mettaton EX: 1 his show a hit, 2 killed */+ F_CORE_HALL, /* Alphys's talk by the last elevator */+ F_CORE_DONE, /* the elevator up to the castle taken (where the game now ends) */FLAG_COUNT = 256};#endifdiff --git a/games/undertale/src/hotland.h b/games/undertale/src/hotland.hindex f10d2af9..e0a70eb4 100644--- a/games/undertale/src/hotland.h+++ b/games/undertale/src/hotland.h@@ -20,4 +20,8 @@ void ht3_draw_top(void); /* over everything: the tile puzzle's clock */int ht3_speed(int x, int y);void res_setup(int room, int from);int res_event(Ev *c);+void core_setup(int room, int from); /* core.c: the CORE */+int core_event(Ev *c);+void core_update(void); /* its lasers, the force field's patience */+void core_draw(void); /* under everything: the lasers, the force fields */#endifdiff --git a/games/undertale/src/htmon.c b/games/undertale/src/htmon.cindex 41fc0a91..556c97f1 100644--- a/games/undertale/src/htmon.c+++ b/games/undertale/src/htmon.c@@ -346,7 +346,7 @@ static const Form bomb_forms[BOMB_COUNT] = {[BOMB_GAME] = {{MON_BOMB}, 1, "* Defuse the game!"},};-static const MonDef ht_defs[MON_COUNT - MON_WF_COUNT] = {+static const MonDef ht_defs[MON_HT_COUNT - MON_WF_COUNT] = {[MON_VULKIN - MON_WF_COUNT] = {.name = "Vulkin", .spare_gold = 40, .hp = 20, .at = 8, .df = 0, .exp = 70, .gold = 40, .spr_idle = SPR_VULKIN_B,.spr_hurt = SPR_VULKIN_HURT, .idle_speed = 6, .check = "Thinks its lava makes people feel better.",@@ -399,9 +399,12 @@ static const MonDef ht_defs[MON_COUNT - MON_WF_COUNT] = {.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]; }+const MonDef *ht_mon_def(int id) {+ if (id >= MON_HT_COUNT) return core_mon_def(id);+ return id == MON_BOMB ? &bomb_defs[g_bomb_kind] : &ht_defs[id - MON_WF_COUNT];+}-static const Form ht_forms[FORM_COUNT - FORM_WF_COUNT] = {+static const Form ht_forms[FORM_HT_COUNT - FORM_WF_COUNT] = {[FORM_VULKIN - FORM_WF_COUNT] = {{MON_VULKIN}, 1, "* Vulkin strolls in, happy as can be."},[FORM_TSUNDERPLANE - FORM_WF_COUNT] = {{MON_TSUNDERPLANE}, 1, "* Tsunderplane gets in the way!\n* Not on purpose or anything."},[FORM_TSUNDER_VULKIN - FORM_WF_COUNT] = {{MON_VULKIN, MON_TSUNDERPLANE}, 2,@@ -416,7 +419,10 @@ static const Form ht_forms[FORM_COUNT - FORM_WF_COUNT] = {[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]; }+const Form *ht_form(int form) {+ if (form >= FORM_HT_COUNT) return core_form(form);+ return form == FORM_BOMB ? &bomb_forms[g_bomb_kind] : &ht_forms[form - FORM_WF_COUNT];+}/* random encounters: past the Lab (the belts and the Magma Chamber); on the second floor, the crossroads and the* Bad Opinion Zone */@@ -431,7 +437,7 @@ int ht_encounter(int room) {return pool[rnd_n(4)];}}- return -1;+ return core_encounter(room);}/* ---------------------------------------------------------------- the attacks */@@ -678,10 +684,13 @@ static void atk_mtt_yellow(int t) {}}-int ht_attack_length(int atk) { return atk == ATK_MUFFET_PET ? 150 : 160; }+int ht_attack_length(int atk) { return atk >= ATK_HT_COUNT ? core_attack_length(atk) : atk == ATK_MUFFET_PET ? 150 : 160; }void ht_attack_run(Battle *b, int atk, int t) {- (void)b;+ if (atk >= ATK_HT_COUNT) {+ core_attack_run(b, atk, t);+ return;+ }if (t < 0) {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,diff --git a/games/undertale/src/menu.c b/games/undertale/src/menu.cindex 33e7d578..3ecb2917 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 to the door of the CORE,\npast the MTT Resort...|The rest of the underground\nis still to come...", 40, 90, FONT_MAIN);+ writer_start(&w, "Up to the king's castle,\nthrough the CORE...|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 32198797..c8660e7f 100644--- a/games/undertale/src/monsters.c+++ b/games/undertale/src/monsters.c@@ -320,7 +320,8 @@ 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_MUFFET || form == FORM_MTT_TILES)+ form == FORM_RGUARDS || form == FORM_BOMB || form == FORM_MUFFET || form == FORM_MTT_TILES || form == FORM_MTT_BOX ||+ form == FORM_MTT_EX)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 71abbc63..1562888a 100644--- a/games/undertale/src/monsters.h+++ b/games/undertale/src/monsters.h@@ -13,7 +13,9 @@ enum {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_MUFFET,- MON_MTT_TILES, MON_COUNT+ MON_MTT_TILES, MON_HT_COUNT,+ /* the CORE */+ MON_FFROGGIT = MON_HT_COUNT, MON_WHIMSALOT, MON_ASTIG, MON_MADJICK, MON_KNIGHT, MON_MTT_BOX, MON_MTT_EX, MON_COUNT};/* formations: who is fought */@@ -30,7 +32,10 @@ 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_MUFFET, FORM_MTT_TILES, FORM_COUNT+ FORM_MTT_COOK, FORM_LASERS, FORM_RGUARDS, FORM_BOMB, FORM_MUFFET, FORM_MTT_TILES, FORM_HT_COUNT,+ /* the CORE */+ FORM_ASTIG = FORM_HT_COUNT, FORM_WHIM_FROG, FORM_WHIM_ASTIG, FORM_FROG_ASTIG, FORM_KNIGHT_MADJICK, FORM_FROG_ASTIG_WHIM,+ FORM_KNIGHT, FORM_MADJICK, FORM_MTT_BOX, FORM_MTT_EX, FORM_COUNT};enum {@@ -49,7 +54,12 @@ enum {/* 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_MUFFET_SPIDERS, ATK_MUFFET_CROISSANTS, ATK_MUFFET_DONUTS, ATK_MUFFET_PET,- ATK_MTT_BOXES, ATK_MTT_YELLOW, ATK_COUNT+ ATK_MTT_BOXES, ATK_MTT_YELLOW, ATK_HT_COUNT,+ /* the CORE */+ ATK_MADJICK_CHASER = ATK_HT_COUNT, ATK_MADJICK_CORNER, ATK_KNIGHT_MOON, ATK_KNIGHT_SUN, ATK_KNIGHT_STAR,+ /* (Mettaton EX's from here on) */+ ATK_EX_LEGS, ATK_EX_BOMBS, ATK_EX_REWIND, ATK_EX_ARMS, ATK_EX_HEART, ATK_EX_LASER, ATK_EX_BOTS, ATK_EX_DISCO,+ ATK_EX_PAIRS, ATK_EX_BREAK, ATK_COUNT};/* a formation: up to three monsters, and what the first turn says */@@ -75,6 +85,13 @@ const struct MonDef *ht_mon_def(int id);void ht_attack_run(struct Battle *b, int atk, int t);int ht_attack_length(int atk);int ht_encounter(int room);+const Form *core_form(int form); /* coremon.c */+const struct MonDef *core_mon_def(int id);+void core_attack_run(struct Battle *b, int atk, int t);+int core_attack_length(int atk);+int core_encounter(int room);+void mttex_reset(void); /* before Mettaton EX's battle: the show's ratings back to the start */+int mttex_ratings(void);extern int g_bomb_kind; /* the bomb fought next (BOMB_*: htmon.c) */enum { BOMB_DOG, BOMB_WATER, BOMB_SCRIPT, BOMB_BALL, BOMB_PRESENT, BOMB_GAME, BOMB_COUNT };#endifdiff --git a/games/undertale/src/resort.c b/games/undertale/src/resort.cindex d4432141..d96c13bd 100644--- a/games/undertale/src/resort.c+++ b/games/undertale/src/resort.c@@ -1,5 +1,5 @@/* The MTT Resort: the street outside (Sans, and dinner with him in the restaurant), the lobby (its fountain, the- * MTT-Brand Burger Emporium, the elevator that's out of order, the door north to the CORE), the hotel's hallway and+ * MTT-Brand Burger Emporium, the elevator that's out of order, the door north to the CORE: core.c), the hotel's hallway and* its room service. (As the Undertale Wiki describes them; what they say is ours, in short.) */#include <stddef.h>#include "event.h"@@ -49,7 +49,6 @@ void res_setup(int room, int from) {obj_sign(1432, 284, 22, 34, "* Out of order?! The ONE\n elevator to the capital?!");obj_sign(1394, 320, 52, 34, "* The elevator's broken, so\n we're trying to fit in all\n the guests going up.");obj_sign(1290, 510, 22, 22, "* (A box. It's locked tight.)");- thing(1182, 84, 76, 56, EV_RES_CORE, ACTOR_DOOR, 0);break;case ROOM_RES_DINER:obj_sign(820, 330, 60, 52, "* Welcome to the restaurant!|* ...you needed a reservation,\n darling. Sorry.");@@ -169,24 +168,12 @@ static int ev_door(Ev *c) {EV_END;}-static int ev_core(Ev *c) {- EV_BEGIN;- NARRATE("* (The door to the CORE.)\n* (Go through?)@Yes@No");- if (CHOICE() == 1) return 1;- set_flag(F_RES_CORE, 1);- sv.room = (int16_t)g_room, sv.x = 1205, sv.y = 150;- save_write_auto();- menu_end_open();- EV_END;-}-int res_event(Ev *c) {switch (c->id) {case EV_RES_SANS: return ev_sans(c);case EV_RES_SHOP: return ev_shop(c);case EV_RES_DOOR: return ev_door(c);case EV_RES_DESK: return ev_desk(c);- case EV_RES_CORE: return ev_core(c);}return -1;}diff --git a/games/undertale/src/rooms.c b/games/undertale/src/rooms.cindex d8f9c12c..cec9cc11 100644--- a/games/undertale/src/rooms.c+++ b/games/undertale/src/rooms.c@@ -25,6 +25,7 @@ void room_setup(int room, int from) {ht2_setup(room, from);ht3_setup(room, from);res_setup(room, from);+ core_setup(room, from);}/* each frame Frisk can walk: what a room watches (a rock on its switch, a cracked floor) */@@ -37,6 +38,7 @@ void room_update(void) {ht1_update();ht2_update();ht3_update();+ core_update();}/* what a room draws on its floor, under everything (world.c) */@@ -46,6 +48,7 @@ void room_draw_floor(void) {ht1_draw();ht2_draw();ht3_draw();+ core_draw();}/* what a room draws over everything (a clock) */diff --git a/games/undertale/src/shoot.c b/games/undertale/src/shoot.cindex 7e74cad3..5ff1e098 100644--- a/games/undertale/src/shoot.c+++ b/games/undertale/src/shoot.c@@ -3,7 +3,7 @@* 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 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+ * the first floor and in the CORE, 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"@@ -21,6 +21,7 @@ static const Puzzle puzzles[SHOOT_COUNT] = {[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#"}},+ [SHOOT_SAGE] = {5, 5, 2, 2, {"## # ", " #o# ", " oooo", " #o# ", " # ##"}}, /* (up, up, left, down, left, down, left) */};#define CELL 24diff --git a/games/undertale/src/shoot.h b/games/undertale/src/shoot.hindex 5aedca33..fcfa2786 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_NORTH, SHOOT_SOUTH, SHOOT_COUNT }; /* (the first floor's, then the third's) */+enum { SHOOT_RIGHT, SHOOT_LEFT, SHOOT_NORTH, SHOOT_SOUTH, SHOOT_SAGE, SHOOT_COUNT }; /* (the first floor's, the third's, the CORE'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/tests/check.py b/games/undertale/tests/check.pyindex cccd6655..d67949bd 100644--- a/games/undertale/tests/check.py+++ b/games/undertale/tests/check.py@@ -38,7 +38,7 @@ FORM_SNOWDRAKE, FORM_PAPYRUS = 19, 31ITEM_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, 31ITEM_NICE_CREAM = 13-ITEM_STARFAIT = 32+ITEM_STARFAIT, ITEM_GLAMBURGER = 32, 33def run(args, frames, saves=None, what=""):@@ -277,17 +277,32 @@ if not QUICK:check(ITEM_NICE_CREAM in s["items"], f"Hotland's third floor: no Nice Cream: {s['items']}")# the MTT Resort: dinner with Sans, a Starfait from Burgerpants, a night in the hotel (200G), room service and the-# dog's door (nothing to give), up to the CORE's door+# dog's door (nothing to give), through the door north into the COREif not QUICK:s = run(["--name", "Frisk", "--noenc", "--god", "--gold", "400", "--room", str(ROOMS["HT_CROSS3"]), "--at", "7550,420","--path-file", os.path.join(HERE, "resort.path")], 5000, what="the MTT Resort")- check(s and s["mode"] == MODE_END and s["room"] == ROOMS["RES_LOBBY"], f"the MTT Resort did not end at the CORE: {s}")+ check(s and s["mode"] == MODE_WORLD and s["room"] == ROOMS["CORE_APPROACH"], f"the MTT Resort did not end in the CORE: {s}")if s:- for name, v in (("HT_FLOOR3", 1), ("RES_SANS", 1), ("RES_ROOM", 2), ("RES_CORE", 1), ("RES_TEA", 0), ("RES_DOG", 0)):+ for name, v in (("HT_FLOOR3", 1), ("RES_SANS", 1), ("RES_ROOM", 2), ("RES_TEA", 0), ("RES_DOG", 0)):check(flag(s, name) == v, f"the MTT Resort: F_{name} is {flag(s, name)}, not {v}")check(s["gold"] == 140, f"the MTT Resort: the Starfait or the room went wrong: {s['gold']}")check(ITEM_STARFAIT in s["items"], f"the MTT Resort: no Starfait: {s['items']}")+# the CORE: Madjick and Knight Knight spared, the switch's lasers, the bridge's power, the sage's puzzle, a Glamburger,+# Mettaton turned round and his show a hit, Alphys by the last elevator, up to the castle+if not QUICK:+ s = run(["--name", "Frisk", "--noenc", "--god", "--room", str(ROOMS["RES_LOBBY"]), "--at", "1210,160",+ "--path-file", os.path.join(HERE, "core.path")], 24000, what="the CORE")+ check(s and s["mode"] == MODE_END and s["room"] == ROOMS["CORE_HALL"], f"the CORE did not end at the castle's elevator: {s}")+ if s:+ for name, v in (("CORE_IN", 1), ("CORE_MADJICK", 1), ("CORE_KNIGHT", 1), ("CORE_SWITCH", 1), ("CORE_POWER", 2),+ ("CORE_SAGE", 1), ("CORE_FIELD", 1), ("CORE_TRASH1", 1), ("CORE_END", 1), ("CORE_MTT", 1),+ ("CORE_HALL", 1), ("CORE_DONE", 1)):+ check(flag(s, name) == v, f"the CORE: F_{name} is {flag(s, name)}, not {v}")+ check(s["kills"] == 0, f"the CORE: {s['kills']} killed on the friendly way")+ check(s["gold"] == 130, f"the CORE: Madjick's and Knight Knight's gold went wrong: {s['gold']}")+ check(ITEM_GLAMBURGER in s["items"], f"the CORE: no Glamburger from the trash can: {s['items']}")+if failures:print("\n".join("FAIL " + f for f in failures))sys.exit(1)diff --git a/games/undertale/tests/core.path b/games/undertale/tests/core.pathnew file mode 100644index 00000000..2f52d7a9--- /dev/null+++ b/games/undertale/tests/core.path@@ -0,0 +1,113 @@+# The CORE, from the MTT Resort's lobby (play it with --room 161 --at 1210,160 --name Frisk --noenc --god): its+# approach, the lobby (the elevator's out of order), the doorway's Madjick (clear mind, then talk), the switch and its+# lasers, the crossroads and Knight Knight north (three lullabies), the laser bridge and its power cut, the Core+# Branch: the sage's puzzle (up, up, left, down, left, down, left, two shots) and a Glamburger from a trash can; The+# End, Mettaton (turned round; then his show, boasting every turn until the ratings are high enough), the hallway+# and Alphys, the elevator up to the castle+w5+1210,120+1210,110+w30+go:310,2640+310,2620+talk+w20+go:310,2300+310,2280+talk+w20+go:310,2080+310,2070+talk+go:320,2022+u+z+talk+go:200,1985+200,1960+w20+go:150,1740+seq:3,1+talk+w20+go:160,1520+160,1490+w20+go:160,1440+go:255,1345+u+z+talk+w200+talk+go:530,1370+go:830,1300+go:830,1140+seq:2,2,2+talk+go:830,1370+go:1180,1370+1236,1370+talk+w20+go:1470,1370+1500,1370+talk+go:2080,1370+go:2080,1320+talk+go:2080,1160+2080,1120+talk+w10+go:1760,1110+go:1760,374+u+z+talk+go:1760,860+go:1470,844+u+z+w10+u+w4+u+w4+l+w4+d+w4+l+w4+d+w4+l+w4+z+w20+z+w60+talk+go:2400,870+go:2580,870+2700,870+w20+go:3348,872+3348,836+w20+go:3348,600+act:1+talk+w30+go:3352,345+3352,320+w20+go:4200,130+4240,130+talk+go:4288,100+u+z+pick:0+w60diff --git a/games/undertale/tests/resort.path b/games/undertale/tests/resort.pathindex 3dd02a82..c9ddbf29 100644--- a/games/undertale/tests/resort.path+++ b/games/undertale/tests/resort.path@@ -1,6 +1,6 @@# the MTT Resort, up the crossroads' stairs (play it with --room 159 --at 7550,420 --name Frisk --noenc --god# --gold 400): Sans out front, dinner with him; the lobby, a Starfait from Burgerpants; a room at the desk, door 2-# and its bed; doors 1 and 4 (nothing to give); the CORE's door+# and its bed; doors 1 and 4 (nothing to give); through the door north, into the COREw57550,4107550,276@@ -58,7 +58,5 @@ go:1500,3961470,396w10go:1210,122-u-z-pick:0+1210,100w60diff --git a/games/undertale/tools/rooms.py b/games/undertale/tools/rooms.pyindex 24ebbfc8..7223e3af 100644--- a/games/undertale/tools/rooms.py+++ b/games/undertale/tools/rooms.py@@ -197,6 +197,22 @@ AREAS.append(dict(name="hotland", map="Hotland_map.png", floor=HT_FLOOR, margin=AREAS.append(dict(name="resort", map="MTT_Resort_map.png", floor=RES_FLOOR, margin=0, close=True,patches=[("copy", 1289, 818, 26, 36, 1131, 818)])) # Sans out front (a sprite here)+# the CORE: blue steel, mesh and purple bridges; the floors are cut by their rectangles (its walls are drawn in the+# same blues). The black sausages (only there on the way to the true ending), Mettaton in his room and Alphys in the+# last hallway are the map's: off it (Mettaton and Alphys are objects here)+CORE_FLOOR = [(33, 81, 164), (31, 130, 228), (34, 105, 164), (36, 62, 141), (71, 154, 204), (85, 121, 151),+ (67, 97, 107), (51, 70, 62), (71, 101, 103), (54, 52, 156), (78, 77, 189), (29, 28, 90), (69, 102, 153),+ (32, 29, 112), (30, 74, 218), (15, 62, 216), (22, 101, 221), (85, 116, 138), (131, 44, 66), (70, 32, 58),+ (225, 148, 55), (169, 132, 94), (145, 96, 11), (166, 165, 237), (18, 14, 53), (244, 254, 190),+ (59, 58, 138)]+AREAS.append(dict(name="core", map="CORE_map.png", floor=CORE_FLOOR, margin=0, close=True, patches=[+ ("erase", 117, 1653, 30, 50, "ring"), ("erase", 462, 1759, 32, 50, "ring"), ("erase", 826, 1088, 28, 54, "ring"),+ ("erase", 2096, 832, 28, 50, "ring"), ("erase", 2646, 164, 34, 48, "ring"), ("erase", 3344, 466, 34, 36, "ring", []),+ ("copy", 3624, 112, 36, 52, 3560, 112), # (Alphys, in the last hallway: the hallway further on, over her)+ # the force field before The End (an object here, drawn while it's up): the bridge 32 pixels on, over it+ ("copy", 2551, 836, 22, 84, 2519, 836),+]))+ROOMS = [# the landing: the bed of golden flowers, a hallway, the Delta Rune archdict(name="area1", area="ruins", rect=(0, 5900, 680, 260), title="Ruins", margin=0,@@ -610,7 +626,7 @@ ROOMS = [floor_rects=[(1080, 278, 380, 162), (1080, 440, 280, 98), (1060, 380, 20, 60), (1460, 380, 20, 60),(1200, 136, 40, 142), (1200, 538, 40, 72)],doors=[((1195, 600, 50, 6), "res_outside", (1205, 840), "down"), ((1060, 380, 6, 60), "res_diner", (1030, 396), "left"),- ((1474, 380, 6, 60), "res_hall", (1488, 396), "right")]),+ ((1474, 380, 6, 60), "res_hall", (1488, 396), "right"), ((1200, 132, 40, 8), "core_approach", (310, 2700), "up")]),dict(name="res_diner", area="resort", rect=(60, 220, 1000, 300), title="MTT Resort", floor_colors=RES_DINER + RES_FLOOR,floor_rects=[(82, 342, 698, 156), (780, 382, 280, 56)],doors=[((1054, 380, 6, 60), "res_lobby", (1068, 396), "right")]),@@ -620,6 +636,51 @@ ROOMS = [dict(name="res_room", area="resort", rect=(1640, 0, 200, 250), title="MTT Resort",floor_rects=[(1644, 84, 192, 116), (1720, 200, 40, 50)],doors=[((1720, 232, 40, 8), "res_hall", (1735, 364), "down")]),+ # the CORE: its approach up from the Resort, the lobby (its elevator out of order) and the two rooms north of it+ dict(name="core_approach", area="core", rect=(160, 2200, 330, 560), title="CORE",+ floor_rects=[(300, 2290, 40, 470), (270, 2690, 100, 70)],+ fix=[("walk", 300, 2290, 40, 170)], # (the way in, lit blue)+ doors=[((300, 2752, 40, 8), "res_lobby", (1210, 150), "down"), ((304, 2292, 32, 8), "core_lobby", (310, 2090), "up")]),+ dict(name="core_lobby", area="core", rect=(160, 1930, 330, 210), title="CORE",+ floor_rects=[(177, 2040, 305, 75), (177, 1977, 63, 63), (402, 1977, 59, 63), (298, 2115, 42, 25)],+ doors=[((300, 2134, 40, 6), "core_approach", (310, 2302), "down"), ((180, 1972, 40, 6), "core_doorway", (150, 1860), "up"),+ ((420, 1972, 44, 6), "core_pit", (470, 1860), "up")]),+ dict(name="core_doorway", area="core", rect=(95, 1490, 130, 410), title="CORE",+ floor_rects=[(100, 1582, 120, 238), (140, 1819, 40, 80), (142, 1492, 38, 92)],+ fix=[("walk", 142, 1492, 38, 92)], # (its doorway, north)+ doors=[((140, 1892, 40, 8), "core_lobby", (190, 1985), "down"), ((142, 1492, 38, 8), "core_west", (150, 1460), "up")]),+ dict(name="core_pit", area="core", rect=(430, 1680, 100, 220), title="CORE",+ floor_rects=[(440, 1761, 79, 75), (461, 1836, 37, 62)],+ doors=[((461, 1892, 37, 8), "core_lobby", (432, 1985), "down")]),+ # the laser ambush (its switch), the crossroads and the room north of it+ dict(name="core_west", area="core", rect=(100, 990, 1140, 540), title="CORE",+ floor_rects=[(119, 1339, 159, 147), (125, 1486, 77, 34), (278, 1356, 265, 32), (543, 1339, 694, 66),+ (796, 1236, 65, 105), (819, 1196, 53, 42), (766, 1068, 147, 130)],+ doors=[((125, 1512, 77, 8), "core_doorway", (150, 1505), "down"), ((1228, 1360, 12, 40), "core_bridge", (1236, 1362), "right")]),+ # the laser bridge (the power cut), up to the Core Branch+ dict(name="core_bridge", area="core", rect=(1220, 1140, 920, 340), title="CORE",+ floor_rects=[(1220, 1358, 845, 44), (2062, 1145, 58, 270)],+ doors=[((1220, 1360, 6, 40), "core_west", (1200, 1362), "left"), ((2062, 1145, 58, 8), "core_branch", (2080, 1098), "up")]),+ # the Core Branch: three columns, three bridges; west the sage's path (its puzzle), east the force field to The End+ dict(name="core_branch", area="core", rect=(1390, 280, 1220, 870), title="Core Branch",+ floor_rects=[(1740, 357, 60, 785), (2060, 282, 58, 860), (2379, 357, 60, 785), (1710, 357, 120, 83),+ (2340, 357, 120, 83), (1740, 620, 700, 42), (1400, 862, 1210, 38), (1620, 1102, 820, 40)],+ doors=[((2060, 1142, 58, 8), "core_bridge", (2080, 1160), "down"), ((2060, 282, 58, 8), "core_warrior", (2080, 255), "up"),+ ((2602, 862, 8, 38), "core_end", (2670, 860), "right")]),+ # the warrior's path: its three fights, its switch+ dict(name="core_warrior", area="core", rect=(2050, 60, 700, 240), title="CORE",+ floor_rects=[(2060, 160, 100, 60), (2060, 218, 60, 72), (2160, 160, 460, 40), (2620, 160, 80, 60)],+ doors=[((2060, 290, 60, 8), "core_branch", (2080, 300), "down")]),+ # The End: the bridge, the Core End (a SAVE, the elevator to the lobby, the door to Mettaton)+ dict(name="core_end", area="core", rect=(2650, 750, 880, 260), title="Core End",+ floor_rects=[(2660, 852, 600, 46), (3260, 852, 240, 66)],+ doors=[((2660, 852, 6, 46), "core_branch", (2580, 862), "left"), ((3342, 856, 36, 8), "core_mtt", (3348, 740), "up")]),+ dict(name="core_mtt", area="core", rect=(3250, 230, 280, 550), title="CORE", open=True,+ floor_rects=[(3342, 330, 36, 450), (3282, 460, 156, 120), (3302, 440, 116, 160), (3322, 420, 76, 200)],+ doors=[((3342, 772, 36, 8), "core_end", (3348, 862), "down"), ((3342, 330, 36, 8), "core_hall", (3355, 212), "up")]),+ dict(name="core_hall", area="core", rect=(3320, 60, 1100, 190), title="CORE",+ floor_rects=[(3340, 118, 1022, 42), (3340, 158, 60, 92)],+ doors=[((3340, 242, 60, 8), "core_mtt", (3348, 345), "down")]),]# 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 c5b1fc90..fc5e3f3f 100644--- a/games/undertale/tools/sprites.py+++ b/games/undertale/tools/sprites.py@@ -237,12 +237,61 @@ def gen_star():return [im]+def gen_exblock():+ # Mettaton EX's blocks: a white square, a black ring in it (only the bomb beside it breaks it)+ im = _img(14, 14)+ d = ImageDraw.Draw(im)+ d.rectangle([0, 0, 13, 13], fill=(255, 255, 255, 255))+ d.ellipse([3, 3, 10, 10], fill=(0, 0, 0, 255))+ d.ellipse([5, 5, 8, 8], fill=(255, 255, 255, 255))+ return [im]+++def gen_exleg():+ # one of his legs, kicking in from the side: black, long, a pink boot+ im = _img(9, 60)+ d = ImageDraw.Draw(im)+ d.rectangle([1, 0, 7, 46], fill=(40, 40, 40, 255), outline=(255, 255, 255, 255))+ d.polygon([(0, 46), (8, 46), (8, 56), (4, 59), (0, 59)], fill=(255, 90, 170, 255))+ return [im]+++def gen_mttheart():+ # his heart, out of the box on his waist: pink, a white rim+ im = _img(16, 14)+ d = ImageDraw.Draw(im)+ d.polygon([(0, 3), (3, 0), (8, 3), (12, 0), (15, 3), (15, 6), (8, 13), (0, 6)], fill=(255, 255, 255, 255))+ d.polygon([(2, 3), (4, 2), (8, 5), (11, 2), (13, 3), (13, 6), (8, 11), (2, 6)], fill=(255, 60, 140, 255))+ return [im]+++def gen_disco():+ # the disco ball: a grey ball of little squares+ im = _img(16, 16)+ d = ImageDraw.Draw(im)+ d.ellipse([0, 0, 15, 15], fill=(190, 190, 200, 255))+ for k in range(3, 15, 4):+ d.line([(k, 1), (k, 14)], fill=(110, 110, 130, 255))+ d.line([(1, k), (14, k)], fill=(110, 110, 130, 255))+ return [im]+++def gen_exarm():+ # a piece of his long arms, coming down: a segment, a box on it to shoot+ im = _img(10, 12)+ d = ImageDraw.Draw(im)+ d.rectangle([3, 0, 6, 11], fill=(255, 255, 255, 255))+ d.rectangle([0, 3, 9, 8], fill=(255, 190, 40, 255), outline=(255, 255, 255, 255))+ return [im]++GEN = {"otile": gen_otile, "snowball": gen_snowball, "bone": gen_bone, "orb": gen_orb, "snowflake": gen_snowflake,"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, "croissant": gen_croissant, "donut": gen_donut,- "mttmini": gen_mttmini}+ "mttmini": gen_mttmini, "exblock": gen_exblock, "exleg": gen_exleg, "mttheart": gen_mttheart,+ "disco": gen_disco, "exarm": gen_exarm}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:"@@ -405,6 +454,26 @@ SPRITES = [# Bratty and Catty's alley: its trash cans and door, the two of them in front("shop_bratty", "wiki:Bratty_and_Catty_sprite_shop.png", {"keep": True, "box": (0, 0, 320, 120)}),("bratty_catty", "wiki:Bratty_and_Catty_sprite.png", {"feet": True}),+ # the CORE: its monsters (their idle animations thinned out), Mettaton EX (whole, without arms, then just his+ # top: the armless one cut at the waist), his box, a black sausage cut from the map, the shapes of his attacks+ ("ffroggit_b", "wiki:Final_Froggit_battle_idle.gif", {"feet": True, "clear_bg": True, "dedupe": True, "every": 4}),+ ("ffroggit_hurt", "wiki:Final_Froggit_battle_hurt.png", {"feet": True, "clear_bg": True}),+ ("whimsalot_b", "wiki:Whimsalot_battle_idle.gif", {"feet": True, "clear_bg": True, "dedupe": True, "every": 4}),+ ("whimsalot_hurt", "wiki:Whimsalot_battle_hurt.png", {"feet": True, "clear_bg": True}),+ ("astig_b", "wiki:Astigmatism_battle_idle.gif", {"feet": True, "clear_bg": True, "dedupe": True, "every": 27}),+ ("astig_hurt", "wiki:Astigmatism_battle_hurt.png", {"feet": True, "clear_bg": True}),+ ("madjick_b", "wiki:Madjick_battle_idle.gif", {"feet": True, "clear_bg": True, "dedupe": True, "every": 4}),+ ("madjick_hurt", "wiki:Madjick_battle_hurt.png", {"feet": True, "clear_bg": True}),+ ("knight_b", "wiki:Knight_Knight_battle_idle.gif", {"feet": True, "clear_bg": True, "dedupe": True, "every": 50}),+ ("knight_hurt", "wiki:Knight_Knight_battle_hurt.png", {"feet": True, "clear_bg": True}),+ ("mttex_b", "wiki:Mettaton_EX_battle.gif", {"feet": True, "clear_bg": True, "dedupe": True, "every": 3}),+ ("mttex_hurt", "wiki:Mettaton_EX_battle_hurt.png", {"feet": True, "clear_bg": True}),+ ("mttex_armless", "wiki:Mettaton_EX_battle_armless.png", {"feet": True, "clear_bg": True}),+ ("mttex_top", "wiki:Mettaton_EX_battle_armless.png", {"feet": True, "clear_bg": True, "box": (0, 0, 106, 70)}),+ ("mttex_ow", "wiki:Mettaton_EX_overworld_limbless.png", {"feet": True}),+ ("sausage", "map:CORE_map.png:117,1653,30,50", {"keep": True, "clear": [(33, 81, 164), (31, 130, 228), (34, 105, 164),+ (36, 62, 141), (71, 154, 204)]}),+ *[(n, "gen:" + n, {"center": True}) for n in ["exblock", "exleg", "mttheart", "disco", "exarm"]],("bird", "map:Waterfall_map.png:8466,578,15,19", {"keep": True, "clear": [(27, 33, 90), (27, 21, 72), (23, 13, 43)]}),("tutu", "map:Waterfall_map.png:1240,1240,22,10", {"keep": True, "clear": [(23, 13, 43), (27, 21, 72), (27, 33, 90)]}),("artifact", "map:Waterfall_map.png:10156,150,12,11",