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: New Home, Asgore, Omega Flowey and the neutral ending
Mason Chenad70fbc229b5
diff --git a/README.md b/README.mdindex 8162cd2c..7c23fe8f 100644--- a/README.md+++ b/README.md@@ -79,10 +79,10 @@ 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 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>+ <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 whole Underground, from the golden flowers to the barrier and the neutral ending</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>+ <td align="center"><a href="#roadmap"><b>More on the way</b></a><br><sub>The Binding of Isaac, Plants vs. Zombies, Doom and more: see the roadmap</sub></td></tr></table>@@ -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, the MTT Resort and the CORE are out, New Home is next+- [x] Undertale: the whole Underground, from the Ruins to New Home and the neutral ending- [ ] The Binding of Isaac- [ ] Plants vs. Zombies- [ ] Doomdiff --git a/docs/play.md b/docs/play.mdindex 82a5730a..202aa867 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, 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.+Name the fallen human, then walk and talk your way through the Ruins, Snowdin, Waterfall, Hotland, the MTT Resort, the CORE and New Home. 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. In New Home, find both keys to unchain the stairs. Asgore breaks MERCY, so you'll have to fight him. Against Omega Flowey, dodge, and reach the ACT button that comes down among a SOUL's attack; once all six SOULs are on your side, reach FIGHT. The game ends at the neutral ending.<br clear="right">diff --git a/games/undertale/README.md b/games/undertale/README.mdindex 98b085da..589adcd2 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, 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.+ The whole Underground, from the bed of golden flowers to the barrier: the Ruins, Snowdin, Waterfall, Hotland, the MTT Resort, the CORE and New Home, to the neutral ending.</p><p align="center">@@ -31,7 +31,8 @@* **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.* **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.+* **New Home:** the grey city, Asgore's home (two keys for the chained stairs, two presents in the children's room), the story of Asriel and the first human told down its basement's corridors, the Last Corridor where Sans judges you, Asgore among the flowers of his throne room, the coffins below, and the barrier: Asgore, your choice, Flowey and the six SOULs, and the way out.+* **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; Asgore, who breaks MERCY, and Omega Flowey with the six human SOULs in New Home.* **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.@@ -152,6 +153,18 @@<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>+ <tr>+ <td align="center"><img src="docs/asgorehome.png" width="390" alt="Asgore's home"><br><sub>Asgore's home, the stairs chained shut</sub></td>+ <td align="center"><img src="docs/lastcorridor.png" width="390" alt="The Last Corridor"><br><sub>The Last Corridor: Sans's judgment</sub></td>+ </tr>+ <tr>+ <td align="center"><img src="docs/throne.png" width="390" alt="The throne room"><br><sub>Asgore among his flowers</sub></td>+ <td align="center"><img src="docs/asgore.png" width="390" alt="Asgore's battle"><br><sub>Asgore at the barrier, MERCY broken</sub></td>+ </tr>+ <tr>+ <td align="center"><img src="docs/omega.png" width="390" alt="Omega Flowey"><br><sub>Omega Flowey and the six SOULs</sub></td>+ <td></td>+ </tr></table>## How to play@@ -164,7 +177,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. 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.+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. In New Home, find both keys to unchain the stairs down. Asgore breaks MERCY: you'll have to fight him, and then choose. Against Omega Flowey there are no turns: dodge, and when a SOUL fights for him, reach the ACT button that comes down among its attack to call for help. Once all six are on your side, reach FIGHT.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.@@ -181,7 +194,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.-* **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.+* **The neutral ending:** the game plays from the start to the barrier and the neutral ending, with Sans's call after. The true pacifist ending (the True Lab, Asriel) and the genocide route aren't in it.* **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/asgore.png b/games/undertale/docs/asgore.pngnew file mode 100644index 00000000..91a53273Binary files /dev/null and b/games/undertale/docs/asgore.png differdiff --git a/games/undertale/docs/asgorehome.png b/games/undertale/docs/asgorehome.pngnew file mode 100644index 00000000..8d330ca9Binary files /dev/null and b/games/undertale/docs/asgorehome.png differdiff --git a/games/undertale/docs/lastcorridor.png b/games/undertale/docs/lastcorridor.pngnew file mode 100644index 00000000..7f1c9092Binary files /dev/null and b/games/undertale/docs/lastcorridor.png differdiff --git a/games/undertale/docs/omega.png b/games/undertale/docs/omega.pngnew file mode 100644index 00000000..69c7b5f8Binary files /dev/null and b/games/undertale/docs/omega.png differdiff --git a/games/undertale/docs/throne.png b/games/undertale/docs/throne.pngnew file mode 100644index 00000000..6e1bd43aBinary files /dev/null and b/games/undertale/docs/throne.png differdiff --git a/games/undertale/src/battle.c b/games/undertale/src/battle.cindex b9a1fdfa..72d0e310 100644--- a/games/undertale/src/battle.c+++ b/games/undertale/src/battle.c@@ -12,7 +12,8 @@#include "monsters.h"#include "world.h"-/* the battles that play their own way: Flowey's first (flowey.c), Mettaton's shows and a laser's alarm (htshows.c) */+/* the battles that play their own way: Flowey's first (flowey.c), Mettaton's shows and a laser's alarm (htshows.c),+ * Omega Flowey's (nhmon.c) */typedef struct {int form;void (*start)(void);@@ -24,6 +25,7 @@ static const Script scripts[] = {{FORM_MTT_QUIZ, quiz_start, quiz_update, quiz_draw},{FORM_MTT_COOK, cook_start, cook_update, cook_draw},{FORM_LASERS, lasers_start, lasers_update, lasers_draw},+ {FORM_OMEGA, omega_start, omega_update, omega_draw},};static const Script *script;@@ -345,6 +347,7 @@ static void menu_input(uint32_t pressed) {case P_MENU:if (pressed & K_LEFT) bt.button = (bt.button + 3) & 3;if (pressed & K_RIGHT) bt.button = (bt.button + 1) & 3;+ if (bt.no_mercy && bt.button == 3) bt.button = pressed & K_LEFT ? 2 : 0;if (pressed & K_Z) {bt.target = 0, bt.act = 0, bt.item = 0, bt.mercy = 0, bt.page = 0;if (bt.button == B_FIGHT || bt.button == B_ACT) bt.phase = P_TARGET;@@ -620,6 +623,10 @@ void battle_draw_buttons(void) {static const uint16_t spr[4] = {SPR_FIGHTBT, SPR_TALKBT, SPR_ITEMBT, SPR_SPAREBT};bool menu = bt.phase >= P_MENU && bt.phase <= P_MERCY;for (int i = 0; i < 4; i++) {+ if (i == 3 && bt.no_mercy) { /* (its pieces, where it was) */+ for (int k = 0; k < 4; k++) gfx_rect(button_x[3] + 6 + k * 14, BUTTON_Y + 14 + (k % 2) * 6, 6, 3, rgb565(0xFF8020), 160);+ continue;+ }bool on = menu && bt.button == i;gfx_sprite(spr[i], on ? 1 : 0, button_x[i], BUTTON_Y, 0, 255);if (on && bt.phase == P_MENU) gfx_sprite(SPR_HEART, 0, button_x[i] + 8, BUTTON_Y + 11, 0, 255);diff --git a/games/undertale/src/battle.h b/games/undertale/src/battle.hindex 4d4b0eb1..d6c4047d 100644--- a/games/undertale/src/battle.h+++ b/games/undertale/src/battle.h@@ -130,6 +130,7 @@ typedef struct Battle {int bar_x, bar_dir; /* FIGHT: the bar, 1/16 px */int strike_t, strike_dmg;bool flee_ok, scripted, no_flee, no_buttons;+ bool no_mercy; /* MERCY broken (Asgore's): only FIGHT, ACT and ITEM */bool captures; /* no death: at 0 HP the battle ends, HP 1 (Papyrus captures you) */int result;int exp_won, gold_won;@@ -193,6 +194,9 @@ int cook_won(void); /* the substitute reached in time */void lasers_start(void);void lasers_update(uint32_t keys, uint32_t pressed);void lasers_draw(void);+void omega_start(void); /* nhmon.c: Omega Flowey */+void omega_update(uint32_t keys, uint32_t pressed);+void omega_draw(void);/* the monsters and formations (monsters.c) */const MonDef *mon_def(int id);diff --git a/games/undertale/src/core.c b/games/undertale/src/core.cindex 313f8736..fda6263c 100644--- a/games/undertale/src/core.c+++ b/games/undertale/src/core.c@@ -3,7 +3,7 @@* 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+ * the king's castle (newhome.c). (As the Undertale Wiki describes them; what they say is ours, in* short.) */#include <stddef.h>#include "battle.h"@@ -442,9 +442,7 @@ static int ev_lift(Ev *c) {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();+ FADE_TO(ROOM_NH_TOWN, 90, 4545, DIR_DOWN);return 1;}if (c->v[0] == 0 && !flag(F_CORE_END)) {@@ -480,7 +478,7 @@ static int ev_mtt(Ev *c) {}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!");+ NARRATE("* (Smoke pours out of Mettaton.)\n* WELL, WELL...|* MY SWITCH, DARLING? COULDN'T\n WAIT FOR MY NEW LOOK?|* NAUGHTY. BUT FINE...\n* IT'S TIME FOR MY PREMIERE!");text_set_top(-1);mttex_reset();BATTLE(FORM_MTT_EX);diff --git a/games/undertale/src/coremon.c b/games/undertale/src/coremon.cindex beee6b4d..6973ba00 100644--- a/games/undertale/src/coremon.c+++ b/games/undertale/src/coremon.c@@ -346,7 +346,7 @@ static void draw_mttex(Battle *b, Monster *m, int x, int y) {}/* ---------------------------------------------------------------- the definitions */-static const MonDef core_defs[MON_COUNT - MON_HT_COUNT] = {+static const MonDef core_defs[MON_CORE_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.",@@ -397,9 +397,9 @@ static const MonDef core_defs[MON_COUNT - MON_HT_COUNT] = {.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]; }+const MonDef *core_mon_def(int id) { return id >= MON_CORE_COUNT ? nh_mon_def(id) : &core_defs[id - MON_HT_COUNT]; }-static const Form core_forms[FORM_COUNT - FORM_HT_COUNT] = {+static const Form core_forms[FORM_CORE_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."},@@ -411,7 +411,7 @@ static const Form core_forms[FORM_COUNT - FORM_HT_COUNT] = {[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]; }+const Form *core_form(int form) { return form >= FORM_CORE_COUNT ? nh_form(form) : &core_forms[form - FORM_HT_COUNT]; }/* random encounters in the Core Branch (Astigmatism alone just once) */int core_encounter(int room) {@@ -724,6 +724,7 @@ static void atk_ex_disco(int t, bool fast) {}int core_attack_length(int atk) {+ if (atk >= ATK_CORE_COUNT) return nh_attack_length(atk);switch (atk) {case ATK_EX_BREAK: return 90;case ATK_EX_REWIND: return 200;@@ -732,7 +733,10 @@ int core_attack_length(int atk) {}void core_attack_run(Battle *b, int atk, int t) {- (void)b;+ if (atk >= ATK_CORE_COUNT) {+ nh_attack_run(b, atk, t);+ return;+ }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;diff --git a/games/undertale/src/data.bin b/games/undertale/src/data.binindex aa5c826d..61ae5ba8 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 54edd254..90721e02 100644--- a/games/undertale/src/data.h+++ b/games/undertale/src/data.h@@ -229,111 +229,129 @@#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 SPR_ASGORE_OW 218+#define SPR_ASGORE_B 219+#define SPR_ASGORE_HURT 220+#define SPR_ASGORE_KNEEL 221+#define SPR_FACE_ASGORE 222+#define SPR_OMEGA 223+#define SPR_OMEGA_LAUGH 224+#define SPR_SOUL_LIGHT_BLUE 225+#define SPR_SOUL_ORANGE 226+#define SPR_SOUL_BLUE 227+#define SPR_SOUL_PURPLE 228+#define SPR_SOUL_GREEN 229+#define SPR_SOUL_YELLOW 230+#define SPR_XSHOT 231+#define SPR_PAN 232+#define SPR_SHOE 233+#define SPR_BOOK 234+#define SPR_ACTBUTTON 235+#define SPR_BIRD 236+#define SPR_TUTU 237+#define SPR_ARTIFACT 238+#define SPR_ECHO_OW 239+#define SPR_ALPHYS_OW 240+#define SPR_MTT_OW 241+#define SPR_MTT_B 242+#define SPR_RGUARDS_OW 243+#define SPR_VENT_D 244+#define SPR_VENT_U 245+#define SPR_VENT_L 246+#define SPR_VENT_R 247+#define SPR_BURNTPAN 248+#define SPR_VULKIN_B 249+#define SPR_VULKIN_HURT 250+#define SPR_TSUNDER_B 251+#define SPR_PYROPE_B 252+#define SPR_PYROPE_HURT 253+#define SPR_RG01_OW 254+#define SPR_RG02_OW 255+#define SPR_RG01_B 256+#define SPR_RG02_B 257+#define SPR_MTT_NEWS 258+#define SPR_BOMB_BALL 259+#define SPR_BOMB_DOG 260+#define SPR_BOMB_PRESENT 261+#define SPR_BOMB_WATER 262+#define SPR_BOMB_SCRIPT 263+#define SPR_BOMB_GAME 264+#define SPR_NEWS_SCRIPT 265+#define SPR_APRON 266+#define SPR_MUFFET_OW 267+#define SPR_MUFFET_B 268+#define SPR_MUFFET_HURT 269+#define SPR_MUFFET_PET 270+#define SPR_SPIDER_B 271+#define SPR_DIAMOND1 272+#define SPR_DIAMOND2 273+#define SPR_BOMB_B 274+#define SPR_DOGBOMB_B 275+#define SPR_WATER_B 276+#define SPR_UNDYNE_FALLEN 277+#define SPR_SPEAR 278+#define SPR_ARROW 279+#define SPR_PLANE 280+#define SPR_BOMB 281+#define SPR_CLOUD 282+#define SPR_BOLT 283+#define SPR_UNDYNE_B 284+#define SPR_NOTE 285+#define SPR_DROP 286+#define SPR_ARM 287+#define SPR_DEBRIS 288+#define SPR_STAR 289+#define SPR_CROISSANT 290+#define SPR_DONUT 291+#define SPR_MTTMINI 292+#define SPR_AARON_B 293+#define SPR_AARON_HURT 294+#define SPR_WOSHUA_B 295+#define SPR_WOSHUA_HURT 296+#define SPR_MOLDBYGG_B 297+#define SPR_SHYREN_B 298+#define SPR_SHYREN_TURNED 299+#define SPR_INTROIMAGE 300+#define SPR_INTROLAST 301+#define SPR_UNDERTALETITLE 302+#define SPR_GAMEOVERBG 303+#define SPR_FACE_TORIELTALK 304+#define SPR_FACE_TORIELTALKSIDE 305+#define SPR_FACE_TORIELHAPPYTALK 306+#define SPR_FACE_TORIELWHAT 307+#define SPR_FACE_TORIELWHATSIDE 308+#define SPR_FACE_TORIELMAD 309+#define SPR_FACE_TORIELCOLD 310+#define SPR_FACE_TORIELSURPRISED 311+#define SPR_FACE_TORIELEMBARRASSED 312+#define SPR_FACE_TORIELGLASSES 313+#define SPR_FACE_TORIELREVENGETALK 314+#define SPR_FACE_TORIELSCARED 315+#define SPR_FACE_TORIELBLINK 316+#define SPR_FACE_TORIELHAPPYBLINK 317+#define SPR_FACE_TORIELBODY 318+#define SPR_FACE_SANS 319+#define SPR_FACE_SANSCHUCKLE 320+#define SPR_FACE_SANSWINK 321+#define SPR_FACE_PAPYRUS 322+#define SPR_FACE_PAPYRUSEVIL 323+#define SPR_FACE_PAPYRUSLAUGH 324+#define SPR_FACE_PAPYRUSMAD 325+#define SPR_FACE_PAPYRUSSIDE 326+#define SPR_FACE_ALPHYS 327+#define SPR_FLOWEYNICE 328+#define SPR_FLOWEYNICESIDE 329+#define SPR_FLOWEYSASSY 330+#define SPR_FLOWEYEVIL 331+#define SPR_FLOWEYGRIN 332+#define SPR_FLOWEYPLAIN 333+#define SPR_FLOWEYPISSED 334+#define SPR_FLOWEYWINK 335+#define SPR_FLOWEYLAUGH 336+#define SPR_FLOWEYHURT 337+#define SPR_FLOWEYTORIEL 338+#define SPR_FLOWEYTORIEL2 339+#define SPR_FLOWEYSIDESHOCK 340#define AREA_RUINS 0#define AREA_SNOWDIN 1#define AREA_SNOWTOWN 2@@ -341,6 +359,7 @@#define AREA_HOTLAND 4#define AREA_RESORT 5#define AREA_CORE 6+#define AREA_NEWHOME 7#define ROOM_AREA1 0#define ROOM_AREA1_2 1#define ROOM_RUINS1 2@@ -517,10 +536,19 @@#define ROOM_CORE_END 173#define ROOM_CORE_MTT 174#define ROOM_CORE_HALL 175+#define ROOM_NH_TOWN 176+#define ROOM_NH_HOUSE 177+#define ROOM_NH_BASEMENT 178+#define ROOM_NH_LAST 179+#define ROOM_NH_THALL 180+#define ROOM_NH_THRONE 181+#define ROOM_NH_COFFINS 182+#define ROOM_NH_BARRIER 183+#define ROOM_NH_WALL 184#define FONT_MAIN 0#define FONT_MENU 1#define FONT_SMALL 2-#define NUM_SPRITES 323-#define NUM_ROOMS 176+#define NUM_SPRITES 341+#define NUM_ROOMS 185#define NUM_FONTS 3#endifdiff --git a/games/undertale/src/events.c b/games/undertale/src/events.cindex f1103511..6a46d51f 100644--- a/games/undertale/src/events.c+++ b/games/undertale/src/events.c@@ -6,6 +6,7 @@#include "battle.h"#include "game.h"#include "hotland.h"+#include "newhome.h"#include "menu.h"#include "ruins.h"#include "snowdin.h"@@ -128,5 +129,7 @@ int event_run(Ev *c) {if (r >= 0) return r;r = core_event(c);if (r >= 0) return r;+ r = nh_event(c);+ if (r >= 0) return r;return 1;}diff --git a/games/undertale/src/events.h b/games/undertale/src/events.hindex efa20028..cbfbf5a2 100644--- a/games/undertale/src/events.h+++ b/games/undertale/src/events.h@@ -59,6 +59,9 @@ enum {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,+ /* newhome.c */+ EV_NH_LIFT, EV_NH_KEY, EV_NH_CHAIN, EV_NH_UP, EV_NH_GIFT, EV_NH_STORY, EV_NH_SANS, EV_NH_THRONE, EV_NH_COFFIN,+ EV_NH_BARRIER, EV_NH_CALL,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 331b36df..26a1fad6 100644--- a/games/undertale/src/flags.h+++ b/games/undertale/src/flags.h@@ -177,7 +177,20 @@ enum {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) */+ F_CORE_DONE, /* the elevator up to the castle taken */+ F_NH_IN, /* New Home reached */+ F_NH_KEY1, /* Asgore's home: the kitchen's key, the hallway's */+ F_NH_KEY2,+ F_NH_CHAIN, /* the chain on the stairs down unlocked */+ F_NH_DAGGER, /* the presents opened: the Worn Dagger, the Heart Locket */+ F_NH_LOCKET,+ F_NH_STORY, /* the basement's story: how many parts told */+ F_NH_LIFT, /* the basement's far end reached (the street's elevator works) */+ F_NH_SANS, /* Sans's judgment heard */+ F_NH_THRONE, /* Asgore met in the throne room */+ F_NH_ASGORE, /* Asgore, beaten: 1 spared (Flowey killed him), 2 killed */+ F_NH_FLOWEY, /* Omega Flowey, beaten: 1 spared, 2 killed */+ F_NH_DONE, /* through the barrier: the end */FLAG_COUNT = 256};#endifdiff --git a/games/undertale/src/items.c b/games/undertale/src/items.cindex 9909283f..c3df682a 100644--- a/games/undertale/src/items.c+++ b/games/undertale/src/items.c@@ -75,6 +75,8 @@ static const ItemInfo items[ITEM_COUNT] = {[ITEM_MYSTERY_KEY] = {"Mystery Key", "MystryKey", IT_SPECIAL, 0, 0, 0, "A key, too bent to go on\n your keychain.", "", 500},[ITEM_HUSH_PUPPY] = {"Hush Puppy", "HushPupy", IT_FOOD, 65, 0, 0, "A spell that keeps a dog\n from casting magic.","* You eat the Hush Puppy.\n* Dog-magic is neutralized.", 150},+ [ITEM_WORN_DAGGER] = {"Worn Dagger", "WornDG", IT_WEAPON, 0, 15, 0, "Good for cutting plants and\n vines.", "", 250},+ [ITEM_HEART_LOCKET] = {"Heart Locket", "H.Locket", IT_ARMOR, 0, 0, 15, "It says \"Best Friends\n Forever.\"", "", 250},};const ItemInfo *item_info(int id) { return &items[id >= 0 && id < ITEM_COUNT ? id : 0]; }diff --git a/games/undertale/src/items.h b/games/undertale/src/items.hindex 3c9a96e3..bbf04478 100644--- a/games/undertale/src/items.h+++ b/games/undertale/src/items.h@@ -49,6 +49,9 @@ enum {ITEM_COWBOY_HAT,ITEM_MYSTERY_KEY,ITEM_HUSH_PUPPY,+ /* New Home */+ ITEM_WORN_DAGGER,+ ITEM_HEART_LOCKET,ITEM_COUNT};enum { IT_FOOD, IT_WEAPON, IT_ARMOR, IT_SPECIAL };diff --git a/games/undertale/src/menu.c b/games/undertale/src/menu.cindex 3ecb2917..d65379c7 100644--- a/games/undertale/src/menu.c+++ b/games/undertale/src/menu.c@@ -380,10 +380,10 @@ void menu_gameover_open(void) {}/* ---------------------------------------------------------------- the end of what there is */-void menu_end_open(void) {+void menu_end_open(const char *text) {g_mode = MODE_END;t = 0;- 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);+ writer_start(&w, text, 40, 90, FONT_MAIN);w.speed = 2;}diff --git a/games/undertale/src/menu.h b/games/undertale/src/menu.hindex 8e2ecbf5..2da2a526 100644--- a/games/undertale/src/menu.h+++ b/games/undertale/src/menu.h@@ -6,7 +6,7 @@ void menu_title_open(void);void menu_open(void);void menu_save_open(void);void menu_gameover_open(void);-void menu_end_open(void); /* at Hotland's edge: what comes next isn't made yet */+void menu_end_open(const char *text); /* the end: its words, a page at a time */void menu_update(uint32_t keys, uint32_t pressed);void menu_draw(void);void game_new(const char *name);diff --git a/games/undertale/src/monsters.c b/games/undertale/src/monsters.cindex c8660e7f..313b9358 100644--- a/games/undertale/src/monsters.c+++ b/games/undertale/src/monsters.c@@ -321,9 +321,10 @@ 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_MTT_BOX ||- form == FORM_MTT_EX)+ form == FORM_MTT_EX || form == FORM_ASGORE)b->no_flee = true;b->captures = form == FORM_PAPYRUS;+ b->no_mercy = form == FORM_ASGORE;return 0;}const char *form_text(int form) { return form >= FORM_RUINS_COUNT ? snow_form(form)->text : forms[form].text; }diff --git a/games/undertale/src/monsters.h b/games/undertale/src/monsters.hindex 1562888a..8c610dfc 100644--- a/games/undertale/src/monsters.h+++ b/games/undertale/src/monsters.h@@ -15,7 +15,9 @@ enum {MON_VULKIN = MON_WF_COUNT, MON_TSUNDERPLANE, MON_PYROPE, MON_METTATON, MON_RG01, MON_RG02, MON_BOMB, MON_MUFFET,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+ MON_FFROGGIT = MON_HT_COUNT, MON_WHIMSALOT, MON_ASTIG, MON_MADJICK, MON_KNIGHT, MON_MTT_BOX, MON_MTT_EX, MON_CORE_COUNT,+ /* New Home */+ MON_ASGORE = MON_CORE_COUNT, MON_OMEGA, MON_COUNT};/* formations: who is fought */@@ -35,7 +37,9 @@ enum {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+ FORM_KNIGHT, FORM_MADJICK, FORM_MTT_BOX, FORM_MTT_EX, FORM_CORE_COUNT,+ /* New Home */+ FORM_ASGORE = FORM_CORE_COUNT, FORM_OMEGA, FORM_COUNT};enum {@@ -59,7 +63,9 @@ enum {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+ ATK_EX_PAIRS, ATK_EX_BREAK, ATK_CORE_COUNT,+ /* New Home */+ ATK_ASG_HELIX = ATK_CORE_COUNT, ATK_ASG_RAIN, ATK_ASG_RINGS, ATK_ASG_HANDS, ATK_ASG_TRIDENT, ATK_COUNT};/* a formation: up to three monsters, and what the first turn says */@@ -90,6 +96,10 @@ 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);+const Form *nh_form(int form); /* nhmon.c */+const struct MonDef *nh_mon_def(int id);+void nh_attack_run(struct Battle *b, int atk, int t);+int nh_attack_length(int atk);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) */diff --git a/games/undertale/src/newhome.c b/games/undertale/src/newhome.cnew file mode 100644index 00000000..e8b34260--- /dev/null+++ b/games/undertale/src/newhome.c@@ -0,0 +1,342 @@+/* New Home, the capital: the elevator up from the CORE, the grey street to Asgore's home; his home (the stairs down+ * chained shut, a key in the kitchen and one in the hallway, two presents in the children's room); the basement's+ * corridors, where the story of Asriel and the first human is told as Frisk walks; the Last Corridor and Sans's+ * judgment; the throne room, Asgore among his flowers; the coffins below; the barrier, Asgore's battle and Frisk's+ * choice; Flowey, the six SOULs and Omega Flowey; the way out, and Sans's call after. (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 "newhome.h"+#include "res.h"+#include "save.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, int dir) {+ const uint16_t s[4] = {spr, spr, spr, spr};+ Obj *o = obj_npc(name, s, x, y, dir, 0);+ if (o) o->flags &= (uint16_t)~OF_SOLID;+ return o;+}++/* the story, told in the basement as Frisk walks (in short, in our words): corridor 1, then 2 */+#define NSTORY 11+static const int16_t story_x[NSTORY] = {1650, 1850, 2050, 2250, 2450, 2800, 3200, 3600, 4000, 4350, 4650};+static const char *const story[NSTORY] = {+ "* Long ago, a human child fell\n into the RUINS, hurt, and cried\n out for help.",+ "* The king's son, ASRIEL, found\n the child and brought it back\n to the castle.",+ "* The two became like brother and\n sister. The king and queen\n raised the child as their own.|* Down here, there was hope\n again.",+ "* But one day, the child became\n gravely ill.",+ "* Its one wish was to see the\n flowers of its home village.\n* There was no way to grant it.|* The next day, the child was\n gone.",+ "* Grieving, ASRIEL took the\n child's SOUL into himself, and\n grew powerful.|* He passed through the barrier,\n bearing the child home.",+ "* In the village, he found a bed\n of golden flowers, and laid the\n child there.|* The villagers saw him beside\n their dead child, and believed\n he had killed it.",+ "* They attacked him with all\n their strength. He could have\n wiped them out.|* Instead, he held back. He only\n smiled, and left.",+ "* Badly hurt, ASRIEL came home\n and collapsed. His dust settled\n over the garden.",+ "* In one night, the king and\n queen had lost both children.|* So the king made a decree: any\n human who fell here would die.|* With enough SOULs, the barrier\n could be broken.",+ "* Soon, now. King ASGORE will\n free us all.|* ...why aren't you smiling?\n* Aren't you glad?\n* Soon, you'll be free.",+};++void nh_setup(int room, int from) {+ (void)from;+ if (room < ROOM_NH_TOWN || room > ROOM_NH_WALL) return;+ set_flag(F_NH_IN, 1);+ switch (room) {+ case ROOM_NH_TOWN:+ thing(76, 4490, 48, 46, EV_NH_LIFT, ACTOR_DOOR, 0);+ thing(280, 4272, 44, 38, EV_NH_LIFT, ACTOR_DOOR, 1);+ obj_save(416, 4546, "* (The city's quiet. It fills you\n with determination.)");+ obj_save(1670, 3175, "* (Home, sweet home... someone's.\n You're filled with determination.)");+ obj_sign(1735, 3140, 20, 20, "* (A box. Its lid won't budge.)");+ break;+ case ROOM_NH_HOUSE:+ thing(1640, 2815, 60, 30, EV_NH_CHAIN, ACTOR_ITEM, 0);+ obj_sign(1765, 2800, 22, 44, "* (A note, hung on the chain.)|* (\"Howdy! I'm in the garden.\n If you need to talk, come by.\")|* (\"The keys are in the kitchen\n and the hallway.\")");+ thing(1290, 2575, 50, 24, EV_NH_KEY, ACTOR_ITEM, 0);+ thing(2374, 2808, 20, 32, EV_NH_KEY, ACTOR_ITEM, 1);+ obj_sign(2198, 2808, 22, 32, "* (\"Room under renovations.\")");+ thing(1906, 2618, 24, 22, EV_NH_GIFT, ACTOR_ITEM, 0);+ thing(1994, 2604, 24, 22, EV_NH_GIFT, ACTOR_ITEM, 1);+ obj_sign(1290, 2735, 80, 45, "* (A fireplace. It's warm, but\n not too hot to touch.)");+ obj_sign(2300, 2560, 60, 40, "* (A huge bed. A flowered\n blanket hangs over its end.)");+ break;+ case ROOM_NH_BASEMENT:+ touch(1533, 2293, 8, 94, EV_NH_UP, 0);+ for (int i = flag(F_NH_STORY); i < NSTORY; i++)+ touch(story_x[i], i < 5 ? 2293 : 2143, 10, i < 5 ? 94 : 67, EV_NH_STORY, i);+ thing(4805, 2108, 50, 35, EV_NH_LIFT, ACTOR_DOOR, 2);+ break;+ case ROOM_NH_LAST:+ obj_save(4690, 2370, "* (Golden light pours in. You're\n filled with determination.)");+ if (!flag(F_NH_SANS)) touch(5300, 2335, 10, 75, EV_NH_SANS, 0);+ break;+ case ROOM_NH_THALL:+ obj_save(6100, 1787, "* (The throne room is just ahead.\n You're filled with determination.)");+ obj_sign(5910, 1750, 22, 40, "* (Throne Room.)");+ break;+ case ROOM_NH_THRONE:+ if (!flag(F_NH_THRONE)) {+ npc(ACTOR_ITEM, SPR_ASGORE_OW, 6018, 1357, DIR_UP);+ touch(5903, 1500, 215, 10, EV_NH_THRONE, 0);+ }+ obj_sign(5963, 1110, 60, 50, "* (A big throne. Beside it, a\n second one under a sheet.)");+ break;+ case ROOM_NH_COFFINS:+ thing(6360, 2897, 34, 50, EV_NH_COFFIN, ACTOR_ITEM, 0);+ for (int i = 1; i < 6; i++) obj_sign(6360 + i * 46, 2897, 34, 50, "* (A coffin for a human. It's\n empty... it's been opened.)");+ break;+ case ROOM_NH_BARRIER:+ obj_save(6340, 962, "* (The end is close. It fills\n you with determination.)");+ break;+ case ROOM_NH_WALL:+ if (!flag(F_NH_ASGORE)) {+ npc(ACTOR_ITEM, SPR_ASGORE_OW, 6342, 760, DIR_DOWN);+ touch(6190, 795, 320, 20, EV_NH_BARRIER, 0);+ } else obj_sign(6250, 620, 160, 120, "* (The barrier. Past it, there's\n nothing left to stop you.)");+ break;+ }+}++/* ---------------------------------------------------------------- the events */+/* the elevators: down to the CORE; the street's to the far end of the basement (once it's been reached); back */+static int ev_lift(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ if (c->v[0] == 1 && !flag(F_NH_LIFT)) {+ NARRATE("* (The elevator isn't working\n yet.)");+ return 1;+ }+ NARRATE(c->v[0] == 0 ? "* (Take the elevator back down\n to the CORE?)@Yes@No" : "* (Take the elevator?)@Yes@No");+ if (CHOICE() == 1) return 1;+ if (c->v[0] == 0) FADE_TO(ROOM_CORE_HALL, 4285, 125, DIR_DOWN);+ else if (c->v[0] == 1) FADE_TO(ROOM_NH_BASEMENT, 4740, 2150, DIR_DOWN);+ else FADE_TO(ROOM_NH_TOWN, 292, 4325, DIR_DOWN);+ EV_END;+}++static int ev_key(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ if (flag(c->v[0] ? F_NH_KEY2 : F_NH_KEY1)) {+ NARRATE(c->v[0] ? "* (Nothing else here.)" : "* (A note: \"Help yourself to\n anything you want!\")");+ return 1;+ }+ if (!c->v[0]) NARRATE("* (A note: \"Help yourself to\n anything you want!\")");+ set_flag(c->v[0] ? F_NH_KEY2 : F_NH_KEY1, 1);+ NARRATE("* (You found a key.)");+ EV_END;+}++static int ev_chain(Ev *c) {+ EV_BEGIN;+ if (!flag(F_NH_CHAIN)) {+ if (!flag(F_NH_KEY1) || !flag(F_NH_KEY2)) {+ NARRATE(flag(F_NH_KEY1) || flag(F_NH_KEY2) ? "* (The stairs are chained shut.\n One lock is still closed.)"+ : "* (The stairs down are chained\n shut. Two locks.)");+ return 1;+ }+ NARRATE("* (You unlock the chain.)");+ set_flag(F_NH_CHAIN, 1);+ }+ FADE_TO(ROOM_NH_BASEMENT, 1560, 2320, DIR_RIGHT);+ EV_END;+}++static int ev_up(Ev *c) {+ EV_BEGIN;+ FADE_TO(ROOM_NH_HOUSE, 1660, 2856, DIR_DOWN);+ EV_END;+}++static int ev_gift(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ if (flag(c->v[0] ? F_NH_LOCKET : F_NH_DAGGER)) {+ NARRATE("* (An empty box.)");+ return 1;+ }+ NARRATE("* (A present, wrapped up.)\n* (Open it?)@Yes@No");+ if (CHOICE() == 1) return 1;+ if (!item_add(c->v[0] ? ITEM_HEART_LOCKET : ITEM_WORN_DAGGER)) {+ NARRATE("* (You're carrying too much.)");+ return 1;+ }+ set_flag(c->v[0] ? F_NH_LOCKET : F_NH_DAGGER, 1);+ NARRATE(c->v[0] ? "* (Inside, a heart-shaped locket.)\n* (You take it.)" : "* (Inside, an old dagger.)\n* (You take it.)");+ EV_END;+}++static int ev_story(Ev *c) {+ EV_BEGIN;+ c->v[0] = c->self ? c->self->arg : 0;+ if (c->self) gone(c->self);+ if (flag(F_NH_STORY) > c->v[0]) return 1;+ set_flag(F_NH_STORY, c->v[0] + 1);+ NARRATE(story[c->v[0]]);+ if (c->v[0] == NSTORY - 1) set_flag(F_NH_LIFT, 1);+ EV_END;+}++/* the Last Corridor: Sans, and what EXP and LOVE are */+static int ev_sans(Ev *c) {+ Obj *s = obj_get(ACTOR_SANS);+ EV_BEGIN;+ if (c->self) gone(c->self);+ s = obj_sans(pl.x + 110, pl.y + 29, DIR_LEFT);+ (void)s;+ SAY(FACE_SANS, "* so, you've made it this far.\n* soon you'll meet the king.|* together, you'll decide the\n future of this world.|* so now, you'll be judged.\n* for every bit of EXP you've\n earned.");+ SAY(FACE_SANS, "* what's EXP? \"execution\n points.\" a measure of how\n much you've hurt others.|* the more you kill, the easier\n it gets to stop caring.|* that's your LOVE: your \"level\n of violence.\"");+ if (flag(F_PAPYRUS) == 2) SAY(FACE_SANS, "* ...and you killed my brother.\n* i hope it was worth it.");+ if (sv.exp == 0)+ SAY(FACE_SANS, "* but you never gained any LOVE.\n* you stayed... you.|* heh. no LOVE... but lots of\n love. know what i mean?|* ...or not. that's ok.");+ else SAYF(FACE_SANS, "* you've got some LOVE now.\n* LV %d.|* but there's still good in you.\n* i can tell.", sv.lv);+ SAY(FACE_SANS, "* anyway. what happens next...\n* we leave up to you.");+ set_flag(F_NH_SANS, 1);+ gone(obj_get(ACTOR_SANS));+ EV_END;+}++/* the throne room: Asgore and his flowers */+static int ev_throne(Ev *c) {+ Obj *a = obj_get(ACTOR_ITEM);+ EV_BEGIN;+ if (c->self) gone(c->self);+ SAY(FACE_ASGORE, "* Dum dum dum...|* Oh? Is someone there?\n* Just a moment! I have to\n finish watering these.|* Howdy! How can I...");+ a = obj_get(ACTOR_ITEM);+ a->dir = DIR_DOWN;+ SAY(FACE_ASGORE, "* ...oh.|* I so wish we could have tea,\n like any other afternoon.|* But... you know how this must\n be.|* When you are ready, come to\n the next room.");+ a = obj_get(ACTOR_ITEM);+ WALK(a, 5968, a->y, 2);+ a = obj_get(ACTOR_ITEM);+ WALK(a, 5968, 1110, 2);+ gone(obj_get(ACTOR_ITEM));+ set_flag(F_NH_THRONE, 1);+ EV_END;+}++static int ev_coffin(Ev *c) {+ EV_BEGIN;+ SAYF(FACE_NONE, "* (A coffin. The name on it is\n \"%s\".)|* (It's been opened.)", sv.name);+ EV_END;+}++/* Sans's call, after: how things turned out (what Frisk did decides it) */+static int ev_call_after(Ev *c) {+ EV_BEGIN;+ SAY(FACE_SANS, "* ring...|* heya. it's me, sans.\n* figured you'd want to know\n how it went down here.");+ if (flag(F_TORIEL_FIGHT) == 1) SAY(FACE_SANS, "* the lady from the ruins came\n back. she runs things now.|* she teaches at the school,\n too. guess she always\n wanted to.");+ else if (flag(F_PAPYRUS) != 2 && flag(F_UNDYNE) != 2) SAY(FACE_SANS, "* undyne's in charge now, and\n papyrus is her right hand.|* they're keeping everyone safe.");+ else SAY(FACE_SANS, "* nobody's really in charge.\n* it's... not great.");+ if (flag(F_CORE_MTT) == 1) SAY(FACE_SANS, "* mettaton's back on tv.\n* the ratings are through the\n roof.");+ if (flag(F_CORE_MTT) == 2) SAY(FACE_SANS, "* no more of mettaton's shows,\n though. folks miss him.");+ SAY(FACE_SANS, "* the king's gone. and the barrier\n is still up.|* but we're getting by.|* so don't worry about us, kid.\n* live your life up there.|* see ya.");+ EV_END;+}++/* the barrier: Asgore, his battle, Frisk's choice; Flowey and the six SOULs; out */+static int ev_barrier(Ev *c) {+ Obj *a = obj_get(ACTOR_ITEM);+ EV_BEGIN;+ if (c->self) gone(c->self);+ (void)a;+ SAY(FACE_ASGORE, "* Here it is: the barrier.\n* The wall that holds us all\n underground.|* Anything left to do?\n* Go and do it first.@Ready@Not yet");+ if (CHOICE() == 1) {+ SAY(FACE_ASGORE, "* I see. Take your time.");+ FADE_TO(ROOM_NH_BARRIER, 6415, 985, DIR_DOWN);+ return 1;+ }+ SAY(FACE_ASGORE, "* ...Then let us begin.|* Human... I am glad we met.|* Farewell.");+ NARRATE("* (Asgore swings his trident.)\n* (Your MERCY button breaks.)");+ BATTLE(FORM_ASGORE);+ if (battle_result() == BR_DIED) return 1;+ NARRATE("* (Asgore is on his knees.)\n* (What will you do?)@Kill@Spare");+ c->v[0] = CHOICE();+ if (c->v[0] == 0) {+ set_flag(F_NH_ASGORE, 2);+ sv.kills++;+ NARRATE("* (Asgore turns to dust.)");+ } else {+ set_flag(F_NH_ASGORE, 1);+ SAY(FACE_ASGORE, "* ...after everything I've done,\n you would spare me?|* I declared war the day my\n son died. I swore to take\n every human SOUL...|* ...but I never wanted any\n of it. I only wanted hope\n back.");+ SAY(FACE_ASGORE, "* Human... I am so sorry.|* Could you... stay with me? We\n could be like a family...");+ g_shake = 10;+ NARRATE("* (White pellets rain down on\n Asgore.)\n* (He turns to dust.)");+ }+ gone(obj_get(ACTOR_ITEM));+ /* Flowey, where Asgore was */+ {+ static const uint16_t s[4] = {SPR_FLOWEY, SPR_FLOWEY, SPR_FLOWEY, SPR_FLOWEY};+ Obj *f = obj_npc(ACTOR_FLOWEY, s, 6336, 740, DIR_DOWN, 0);+ if (f) f->flags &= (uint16_t)~OF_SOLID;+ }+ SAY(FACE_FLOWEY, "* Heh. You fool.|* Still haven't figured it out?|* Down here, you kill, or you\n get killed.");+ SAY(FACE_FLOWEY, "* And now... his six SOULs are\n MINE.");+ g_shake = 16;+ NARRATE("* (The six SOULs rise from their\n jars, and gather around\n Flowey.)");+ BATTLE(FORM_OMEGA);+ set_flag(F_NH_FLOWEY, 3); /* (beaten: spared or killed below) */+ SAY(FACE_FLOWEY, "* ...|* Why...?|* Why are you being so... nice\n to me?|* I can't understand.\n* I just can't understand...");+ NARRATE("* (Flowey is beaten.)\n* (What will you do?)@Spare@Kill");+ if (CHOICE() == 0) {+ set_flag(F_NH_FLOWEY, 1);+ SAY(FACE_FLOWEY, "* ...you're letting me go? I'll\n just come back, you know.|* ...|* ...you make no sense.");+ NARRATE("* (Flowey sinks into the ground.)");+ } else {+ set_flag(F_NH_FLOWEY, 2);+ NARRATE("* (Flowey is gone.)");+ }+ gone(obj_get(ACTOR_FLOWEY));+ NARRATE("* (With the six SOULs' power, you\n cross the barrier.)|* (The sun is rising.)");+ set_flag(F_NH_DONE, 1);+ sv.room = (int16_t)ROOM_NH_BARRIER, sv.x = 6400, sv.y = 985;+ save_write_auto();+ /* Sans's call, then the end */+ c->v[1] = 1;+ EV_END;+}++int nh_event(Ev *c) {+ switch (c->id) {+ case EV_NH_LIFT: return ev_lift(c);+ case EV_NH_KEY: return ev_key(c);+ case EV_NH_CHAIN: return ev_chain(c);+ case EV_NH_UP: return ev_up(c);+ case EV_NH_GIFT: return ev_gift(c);+ case EV_NH_STORY: return ev_story(c);+ case EV_NH_SANS: return ev_sans(c);+ case EV_NH_THRONE: return ev_throne(c);+ case EV_NH_COFFIN: return ev_coffin(c);+ case EV_NH_BARRIER: {+ int r = ev_barrier(c);+ if (r && flag(F_NH_DONE) && c->v[1] == 1) { /* (on to the call) */+ c->id = EV_NH_CALL, c->at = NULL, c->v[1] = 0;+ return 0;+ }+ return r;+ }+ case EV_NH_CALL: {+ int r = ev_call_after(c);+ if (r) menu_end_open("THE END|You went home. The monsters\nstayed underground.|(A neutral ending.)");+ return r;+ }+ }+ return -1;+}diff --git a/games/undertale/src/newhome.h b/games/undertale/src/newhome.hnew file mode 100644index 00000000..21c76a16--- /dev/null+++ b/games/undertale/src/newhome.h@@ -0,0 +1,7 @@+/* Undertale: New Home (newhome.c), its battles (nhmon.c: Asgore, Omega Flowey). */+#ifndef UT_NEWHOME_H+#define UT_NEWHOME_H+#include "event.h"+void nh_setup(int room, int from);+int nh_event(Ev *c);+#endifdiff --git a/games/undertale/src/nhmon.c b/games/undertale/src/nhmon.cnew file mode 100644index 00000000..e0b1edce--- /dev/null+++ b/games/undertale/src/nhmon.c@@ -0,0 +1,452 @@+/* New Home's battles: Asgore at the barrier (the Undertale Wiki's records of the game: his HP, his ACT, how his+ * guard drops, his fire and his trident; he breaks MERCY before it starts), and Omega Flowey with the six SOULs he+ * took: not turn by turn, his attacks one after another; now and then a SOUL fights for him, until Frisk reaches the+ * ACT that appears among its attack and calls for help; all six helped, they turn on him, and FIGHT can reach him.+ * 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"++/* ---------------------------------------------------------------- Asgore */+enum { AS_DOWN, AS_TALKS }; /* (b->state[]) */+static void act_asgore(Battle *b, Monster *m, int act, char *t, int cap) {+ (void)act;+ int n = ++b->state[AS_TALKS];+ if (n < 3 || sv.exp > 0) snprintf(t, (size_t)cap, "* You tell Asgore you don't want\n to fight him.\n* He doesn't answer.");+ else if (n == 3) {+ snprintf(t, (size_t)cap, "* You tell Asgore you don't want\n to fight. His hands tremble.\n* His ATTACK and DEFENSE drop.");+ m->at = (int16_t)max_i(1, m->at - 1), m->df = (int16_t)(m->df - 10);+ } else snprintf(t, (size_t)cap, "* Asgore's hands are shaking.");+}+static bool item_asgore(Battle *b, Monster *m, int item, char *t, int cap) {+ (void)b, (void)t, (void)cap;+ /* her pie: its smell reminds him of someone */+ if (item == ITEM_BUTTERSCOTCH_PIE) m->at = (int16_t)max_i(1, m->at - 1), m->df = (int16_t)(m->df - 5);+ return false;+}+static const char *talk_asgore(Battle *b, Monster *m) {+ (void)m;+ if (b->state[AS_DOWN]) return "Ah...";+ return NULL; /* (he says nothing: he looks away) */+}+static const char *flavor_asgore(Battle *b, Monster *m) {+ /* after turn 20 his guard falls, turn by turn */+ if (b->turn >= 20 && m->df > -120) m->df = (int16_t)(m->df - 10);+ if (b->turn <= 1) return "* ASGORE attacks!";+ if (b->state[AS_TALKS] == 3 && sv.exp == 0) return "* Asgore's hands are shaking.";+ static const char *const lines[] = {"* Asgore looks away.", "* Asgore's trident glints.", "* You feel the heat of his fire.",+ "* The barrier hums behind him.", "* Seems like no one can save you now."};+ return lines[rnd_n(5)];+}+static bool hit_asgore(Battle *b, Monster *m, int dmg) {+ if (m->hp - dmg > 0) return false;+ /* down on his knees: what's next is Frisk's choice, not the battle's */+ m->hp = 1, m->hurt = 30, m->shake = 8;+ b->state[AS_DOWN] = 1;+ return true;+}+static int attack_asgore(Battle *b, Monster *m) {+ (void)m;+ if (b->state[AS_DOWN]) return -1;+ static const uint8_t seq[6] = {ATK_ASG_HELIX, ATK_ASG_TRIDENT, ATK_ASG_RINGS, ATK_ASG_RAIN, ATK_ASG_HANDS, ATK_ASG_TRIDENT};+ return seq[(b->turn - 1) % 6];+}+static bool ends_asgore(Battle *b, Monster *m) {+ (void)m;+ if (b->state[AS_DOWN]) b->result = BR_SCRIPTED;+ return false;+}+static void draw_asgore(Battle *b, Monster *m, int x, int y) {+ uint16_t s = b->state[AS_DOWN] ? SPR_ASGORE_KNEEL : m->hurt ? SPR_ASGORE_HURT : SPR_ASGORE_B;+ int fr = m->hurt || b->state[AS_DOWN] ? 0 : (int)(g_frame / 8);+ gfx_sprite(s, fr, x, y + 4, 0, 255);+}++static const MonDef nh_defs[MON_COUNT - MON_CORE_COUNT] = {+ [MON_ASGORE - MON_CORE_COUNT] = {+ .name = "ASGORE", .hp = 3500, .at = 8, .df = -30, .spr_idle = SPR_ASGORE_B, .spr_hurt = SPR_ASGORE_HURT,+ .idle_speed = 8, .check = "The king of the monsters.", .acts = {"Talk"}, .nacts = 1, .flags = MF_BOSS,+ .act = act_asgore, .talk = talk_asgore, .attack = attack_asgore, .flavor = flavor_asgore, .on_hit = hit_asgore,+ .ends = ends_asgore, .draw = draw_asgore, .on_item = item_asgore},+ [MON_OMEGA - MON_CORE_COUNT] = {.name = "Flowey", .hp = 9999, .flags = MF_BOSS | MF_NOT_KILLABLE},+};+const MonDef *nh_mon_def(int id) { return &nh_defs[id - MON_CORE_COUNT]; }+static const Form nh_forms[FORM_COUNT - FORM_CORE_COUNT] = {+ [FORM_ASGORE - FORM_CORE_COUNT] = {{MON_ASGORE}, 1, "* (Twilight shines through the\n barrier.)\n* (You're filled with DETERMINATION.)"},+ [FORM_OMEGA - FORM_CORE_COUNT] = {{MON_OMEGA}, 1, ""},+};+const Form *nh_form(int form) { return &nh_forms[form - FORM_CORE_COUNT]; }++/* ---------------------------------------------------------------- Asgore's 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 *fire(int x, int y, int vx, int vy) {+ Bullet *b = shot(SPR_FIREBULLET, x, y, vx, vy);+ if (b) b->r = 3, b->flags |= BF_NOCLIP;+ return b;+}+/* four waves of fire, curling down in a double helix */+static void atk_helix(int t) {+ if (t % 4 || t > 140) return;+ int cx = board_cx(), a = gfx_sin(t * 6) * ((bx1() - bx0()) / 2 - 6) / 1024;+ fire(cx + a, by0() - 6, 0, P(2));+ fire(cx - a, by0() - 6, 0, P(2));+}+/* a stream down the middle, and a cloud of fire over one side, then the other */+static void atk_rain(int t) {+ if (t % 5 == 0 && t < 150) fire(board_cx() - 6 + rnd_n(13), by0() - 6, 0, P(2));+ if (t % 3 == 0 && t < 150) {+ bool left = (t / 50) % 2;+ int w = (bx1() - bx0()) / 2 - 16;+ fire(left ? bx0() + rnd_n(w) : bx1() - rnd_n(w), by0() - 6, 0, P(3));+ }+}+/* rings of fire, a gap in each, closing in round the SOUL */+static void atk_rings(int t) {+ if (t % 45 || t > 120) return;+ int gap = rnd_n(12);+ for (int k = 0; k < 12; k++) {+ if (k == gap || k == (gap + 1) % 12) continue;+ Bullet *b = fire(board_cx(), board_cy(), 0, 0);+ if (!b) continue;+ b->kind = BK_ORBIT, b->a = (int16_t)board_cx(), b->b = (int16_t)board_cy(), b->c = (int16_t)P(80);+ b->d = (int16_t)(k * 256 / 12 * 16), b->vx = 12 + t / 10, b->vy = -P(1) / 2, b->life = 150;+ }+}+/* his hands sweep down the sides, leaving fire; then it all flies at where the SOUL was */+static int aim_x, aim_y;+static void atk_hands(int t) {+ if (t < 80 && t % 8 == 0) {+ for (int side = 0; side < 2; side++) {+ Bullet *b = fire(side ? bx1() - 4 : bx0() + 4, by0() + 4 + t * (by1() - by0() - 8) / 80, 0, 0);+ if (b) b->kind = BK_SCRIPT, b->a = 1;+ }+ }+ if (t == 85) aim_x = soul_x(), aim_y = soul_y();+ if (t >= 85)+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || b->a != 1) continue;+ int dx = aim_x - b->x / FX, dy = aim_y - b->y / FX, d = abs_i(dx) + abs_i(dy);+ b->kind = BK_LINEAR;+ if (d) b->vx = dx * P(3) / d, b->vy = dy * P(3) / d;+ }+}+/* his eyes flash blue or orange, then his trident sweeps the whole board in that colour */+static uint8_t trident[3];+static void atk_trident(int t) {+ if (t == 0)+ for (int k = 0; k < 3; k++) trident[k] = (uint8_t)(rnd_n(2) ? BC_BLUE : BC_ORANGE);+ int k = (t - 20) / 45, ph = (t - 20) % 45;+ if (t < 20 || k >= 3) return;+ if (ph == 0) { /* the warning: a flash of the colour along the top */+ Bullet *w = shot(SPR_RECT, board_cx(), by0() + 2, 0, 0);+ if (w) w->flags |= BF_BOX | BF_HARMLESS, w->w = (int16_t)(bx1() - bx0()), w->h = 3, w->color = trident[k], w->life = 18;+ }+ if (ph == 20) {+ bool left = k % 2;+ Bullet *s = shot(SPR_RECT, left ? bx0() - 4 : bx1() + 4, board_cy(), left ? P(9) : -P(9), 0);+ if (s) s->flags |= BF_BOX | BF_NOCLIP, s->w = 8, s->h = (int16_t)(by1() - by0()), s->color = trident[k], s->life = 30;+ }+}++int nh_attack_length(int atk) { return atk == ATK_ASG_TRIDENT ? 160 : 165; }+void nh_attack_run(Battle *b, int atk, int t) {+ (void)b;+ if (t < 0) {+ board_set(atk == ATK_ASG_RINGS ? 110 : 150, 100);+ soul_set_mode(SOUL_RED);+ return;+ }+ switch (atk) {+ case ATK_ASG_HELIX: atk_helix(t); break;+ case ATK_ASG_RAIN: atk_rain(t); break;+ case ATK_ASG_RINGS: atk_rings(t); break;+ case ATK_ASG_HANDS: atk_hands(t); break;+ case ATK_ASG_TRIDENT: atk_trident(t); break;+ }+}++/* ---------------------------------------------------------------- Omega Flowey */+enum { OF_ATTACK, OF_WARNING, OF_SOUL, OF_REBEL, OF_DONE };+enum { OA_EYES, OA_FLAME, OA_PELLETS, OA_VINES, OA_BOMBS, OA_FINGERS, OA_COUNT };+static struct {+ int st, t, atk, n, souls, helped, hits, msg_t, refused;+ const char *msg;+ Bullet *act;+} om;+static const uint16_t soul_spr[6] = {SPR_SOUL_LIGHT_BLUE, SPR_SOUL_ORANGE, SPR_SOUL_BLUE, SPR_SOUL_PURPLE, SPR_SOUL_GREEN,+ SPR_SOUL_YELLOW};+static const uint32_t soul_rgb[6] = {0x42FCFF, 0xFCA600, 0x003CFF, 0xD535D9, 0x00C000, 0xFFFF00};+#define OM_HITS 6+static void say_top(const char *s) { om.msg = s, om.msg_t = 110; }++void omega_start(void) {+ bt.scripted = true;+ board_set_rect(65, 120, 255, 194);+ bt.x0 = bt.tx0, bt.y0 = bt.ty0, bt.x1 = bt.tx1, bt.y1 = bt.ty1;+ bt.sx = P(board_cx()), bt.sy = P(board_cy());+ soul_set_mode(SOUL_RED);+ om.st = OF_ATTACK, om.t = 0, om.atk = 0, om.n = 0, om.souls = 0, om.helped = 0, om.hits = 0, om.refused = 0, om.act = NULL;+ say_top("* Flowey holds the six SOULs.");+}++/* his own: the eyes' X shots, the flamethrowers, a ring of pellets closing in, vines along flashing lines, bombs,+ * finger guns from both sides */+static void omega_attack(int a, int t) {+ int cx = board_cx();+ switch (a) {+ case OA_EYES:+ if (t % 18 == 0 && t < 140)+ for (int k = -3; k <= 3; k++) {+ Bullet *b = shot(SPR_XSHOT, cx + (t / 18 % 2 ? 40 : -40), by0() - 10, k * P(1) / 2, P(2));+ if (b) b->r = 3, b->flags |= BF_NOCLIP, b->dmg = 6;+ }+ break;+ case OA_FLAME:+ if (t % 30 == 10 && t < 140)+ for (int side = 0; side < 2; side++) {+ int y = by0() + 10 + rnd_n(by1() - by0() - 20);+ Bullet *b = shot(SPR_RECT, side ? bx1() : bx0(), y, side ? -P(3) : P(3), 0);+ if (b) b->flags |= BF_BOX | BF_NOCLIP, b->w = 40, b->h = 8, b->color = BC_WHITE, b->life = 40, b->dmg = 6;+ }+ break;+ case OA_PELLETS:+ if (t % 60 == 0 && t < 130)+ for (int k = 0; k < 10; k++) {+ int an = k * 256 / 10;+ Bullet *b = shot(SPR_SPINBULLET, soul_x() + gfx_cos(an) * 40 / 1024, soul_y() + gfx_sin(an) * 40 / 1024, 0, 0);+ if (b) b->kind = BK_SCRIPT, b->a = 30, b->r = 3, b->anim = 3, b->dmg = 6, b->flags |= BF_NOCLIP;+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || b->spr != SPR_SPINBULLET) continue;+ if (b->a) { /* (still, a moment: the warning) */+ b->a--;+ b->alpha = b->a % 4 < 2 ? 120 : 255, b->flags |= BF_HARMLESS;+ if (!b->a) {+ int dx = soul_x() - b->x / FX, dy = soul_y() - b->y / FX, d = abs_i(dx) + abs_i(dy);+ b->kind = BK_LINEAR, b->alpha = 255, b->flags &= (uint8_t)~BF_HARMLESS;+ if (d) b->vx = dx * P(2) / d, b->vy = dy * P(2) / d;+ }+ }+ }+ break;+ case OA_VINES:+ if (t % 40 == 0 && t < 130)+ for (int k = 0; k < 3; k++) {+ int x = soul_x() + (k - 1) * 22;+ Bullet *w = shot(SPR_RECT, x, board_cy(), 0, 0);+ if (w) w->flags |= BF_BOX | BF_HARMLESS, w->w = 1, w->h = (int16_t)(by1() - by0()), w->color = BC_ORANGE, w->life = 20;+ Bullet *v = shot(SPR_RECT, x, by0() - 60, 0, 0);+ if (v) v->kind = BK_SCRIPT, v->a = 20, v->flags |= BF_BOX | BF_NOCLIP, v->w = 5, v->h = 100, v->dmg = 6;+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *v = &bullets[i];+ if (v->kind != BK_SCRIPT || v->spr != SPR_RECT) continue;+ if (v->a) v->a--;+ else v->y += P(8);+ if (v->y > P(by1() + 70)) v->kind = BK_NONE;+ }+ break;+ case OA_BOMBS:+ if (t % 20 == 0 && t < 130) {+ Bullet *b = shot(SPR_BOMB, bx0() + 8 + rnd_n(bx1() - bx0() - 16), by0() - 8, 0, P(2));+ if (b) b->kind = BK_SCRIPT, b->r = 5, b->dmg = 6, b->flags |= BF_NOCLIP;+ }+ for (int i = 0; i < MAX_BULLETS; i++) {+ Bullet *b = &bullets[i];+ if (b->kind != BK_SCRIPT || b->spr != SPR_BOMB) continue;+ b->y += b->vy;+ if (b->y >= P(by1() - 4)) { /* it hits the floor: a burst */+ int x = b->x / FX, y = b->y / FX;+ b->kind = BK_NONE;+ for (int k = 0; k < 8; k++) {+ Bullet *s = shot(SPR_SPINBULLET, x, y, gfx_cos(k * 32) * 2 * FX / 1024, gfx_sin(k * 32) * 2 * FX / 1024);+ if (s) s->r = 3, s->dmg = 6, s->life = 50;+ }+ }+ }+ break;+ case OA_FINGERS:+ if (t % 16 == 0 && t < 140) {+ bool left = (t / 16) % 2;+ Bullet *b = shot(SPR_ORB, left ? bx0() - 6 : bx1() + 6, soul_y(), left ? P(3) : -P(3), 0);+ if (b) b->r = 4, b->dmg = 6, b->flags |= BF_NOCLIP;+ }+ break;+ }+}++/* a SOUL's: the light blue's knives, the orange's fists, the blue's stars and shoes, the purple's words, the+ * green's pans and their fire, the yellow's gun; once called on, what they throw heals instead */+static void soul_attack(int s, int t) {+ int cx = board_cx(), cy = board_cy();+ uint8_t col = om.helped ? BC_GREEN : BC_WHITE;+ Bullet *b = NULL;+ switch (s) {+ case 0:+ if (t % 12 == 0) b = shot(SPR_KNIFE, bx0() - 4, by0() + rnd_n(by1() - by0()), P(3), (t / 60 % 2 ? 1 : -1) * P(1));+ break;+ case 1:+ if (t % 50 == 0)+ for (int k = 0; k < 8; k++) {+ b = shot(SPR_DOGPAW, cx, cy, 0, 0);+ if (b) b->kind = BK_ORBIT, b->a = (int16_t)cx, b->b = (int16_t)cy, b->c = (int16_t)P(70), b->d = (int16_t)(k * 32 * 16),+ b->vx = 30, b->vy = -P(1) / 2, b->life = 130, b->r = 4, b->color = col, b->dmg = om.helped ? 2 : 6;+ b = NULL;+ }+ break;+ case 2:+ if (t % 14 == 0) {+ b = shot(SPR_SHOE, bx1() + 6, cy + gfx_sin(t * 8) * 30 / 1024, -P(2), 0);+ if (b) b->color = col, b->r = 4, b->dmg = om.helped ? 2 : 6;+ b = shot(SPR_STAR, bx0() + rnd_n(bx1() - bx0()), by0() - 4, 0, P(1));+ }+ break;+ case 3:+ if (t % 10 == 0) {+ bool left = (t / 10) % 2;+ b = shot(SPR_RECT, left ? bx0() : bx1(), by0() + 8 + rnd_n(by1() - by0() - 16), left ? P(2) : -P(2), 0);+ if (b) b->flags |= BF_BOX, b->w = 22, b->h = 6;+ }+ break;+ case 4:+ if (t % 9 == 0) b = shot(SPR_FIREBULLET, cx + (rnd_n(3) - 1) * 40, cy - 10, (rnd_n(3) - 1) * P(1) / 2, -P(3));+ if (b) b->ay = P(1) / 8;+ break;+ case 5:+ if (t % 15 == 0) {+ int dx = soul_x() - cx, dy = soul_y() - by0(), d = abs_i(dx) + abs_i(dy);+ b = shot(SPR_ORB, cx, by0() + 4, d ? dx * P(3) / d : 0, d ? dy * P(3) / d : P(3));+ }+ break;+ }+ if (b) b->color = col, b->r = b->r ? b->r : 4, b->dmg = om.helped ? 2 : 6, b->flags |= BF_NOCLIP;+}+static void clear_bullets(void) {+ for (int i = 0; i < MAX_BULLETS; i++) bullets[i].kind = BK_NONE;+}+/* a button among the bullets (ACT, then FIGHT): it drifts to the SOUL; touched, it's pressed */+static Bullet *button_new(uint16_t spr) {+ Bullet *b = bullet_new(spr, P(board_cx()), P(bt.y0 + 6), 0, 0);+ if (b) b->kind = BK_SCRIPT, b->flags |= BF_HARMLESS | BF_NOCLIP, b->a = 7;+ return b;+}+static bool is_button(const Bullet *b) {+ return b && b->kind == BK_SCRIPT && b->a == 7 && (b->spr == SPR_ACTBUTTON || b->spr == SPR_FIGHTBT);+}+static bool button_step(Bullet *b) {+ if (!is_button(b)) return false;+ int dx = soul_x() - b->x / FX, dy = soul_y() - b->y / FX;+ b->x += dx > 0 ? FX * 3 / 4 : dx < 0 ? -FX * 3 / 4 : 0, b->y += dy > 0 ? FX * 3 / 4 : dy < 0 ? -FX * 3 / 4 : 0;+ if (abs_i(dx) < 9 && abs_i(dy) < 7) {+ b->kind = BK_NONE;+ return true;+ }+ return false;+}++void omega_update(uint32_t keys, uint32_t pressed) {+ (void)pressed;+ if (bt.inv) bt.inv--;+ soul_update(keys);+ bullets_update();+ soul_hit_test();+ if (om.msg_t) om.msg_t--;+ /* at 0 HP: but it refused (the SOULs won't let Frisk go) */+ if (sv.hp < 1) {+ sv.hp = sv.maxhp, om.refused++;+ say_top("* Your SOUL won't give up.");+ }+ om.t++;+ switch (om.st) {+ case OF_ATTACK:+ omega_attack(om.atk, om.t);+ if (om.t >= 160) {+ om.t = 0, om.n++;+ om.atk = (om.atk + 1 + rnd_n(OA_COUNT - 1)) % OA_COUNT;+ if (om.souls < 6 && om.n % 2 == 0) om.st = OF_WARNING, clear_bullets(), say_top("* WARNING!");+ }+ break;+ case OF_WARNING:+ if (om.t >= 45) om.st = OF_SOUL, om.t = 0, om.helped = 0, om.act = NULL;+ break;+ case OF_SOUL:+ soul_attack(om.souls, om.t);+ if (om.t == 70) om.act = button_new(SPR_ACTBUTTON);+ if (!om.helped && button_step(om.act)) {+ om.helped = 1, om.t = 200;+ say_top("* You called for help...");+ for (int i = 0; i < MAX_BULLETS; i++)+ if (bullets[i].kind != BK_NONE) bullets[i].color = BC_GREEN, bullets[i].dmg = 2;+ }+ if (om.t >= 300) {+ clear_bullets();+ om.t = 0;+ if (om.helped) {+ om.souls++;+ say_top(om.souls < 6 ? "* A SOUL is on your side." : "* The SOULs turn on him! DEFENSE 0!");+ }+ om.st = om.souls >= 6 ? OF_REBEL : OF_ATTACK;+ }+ break;+ case OF_REBEL:+ /* his attacks, slower now; FIGHT comes down among them */+ if (om.t % 2 == 0) omega_attack(om.atk, om.t / 2);+ if (om.t >= 320) om.t = 0, om.atk = (om.atk + 1) % OA_COUNT;+ if (!is_button(om.act)) {+ if (om.t % 120 == 60) om.act = button_new(SPR_FIGHTBT);+ } else if (button_step(om.act)) {+ om.hits++, om.act = NULL;+ g_shake = 8;+ say_top(om.hits < OM_HITS ? "* You hit Flowey!" : "* Flowey falls apart.");+ if (om.hits >= OM_HITS) om.st = OF_DONE, om.t = 0, clear_bullets();+ }+ break;+ case OF_DONE:+ if (om.t >= 90) bt.result = BR_SCRIPTED;+ break;+ }+}++void omega_draw(void) {+ gfx_rect(0, 0, SCREEN_W, SCREEN_H, C_BLACK, 255);+ /* his screen: his face, laughing while he wins; the SOUL he's using, beside it */+ bool hurt = om.st == OF_REBEL || om.st == OF_DONE;+ if (om.st != OF_DONE || om.t % 6 < 3) {+ if (hurt && g_frame % 30 < 15) gfx_sprite(SPR_OMEGA, 0, 160 + (g_frame % 4 < 2 ? 2 : -2), 56, 0, 255);+ else if (om.st == OF_ATTACK) gfx_sprite(SPR_OMEGA_LAUGH, (int)(g_frame / 6), 160, 56, 0, 255);+ else gfx_sprite(SPR_OMEGA, 0, 160, 56, 0, 255);+ }+ for (int k = 0; k < 6; k++) { /* the six SOULs: dim once they've sided with Frisk */+ int x = k < 3 ? 46 + k * 16 : 242 + (k - 3) * 16;+ gfx_sprite(soul_spr[k], 0, x, 20, 0, k < om.souls ? 90 : 255);+ }+ if (om.st == OF_WARNING && om.t % 10 < 6) {+ gfx_rect(120, 92, 80, 14, rgb565(soul_rgb[om.souls]), 255);+ gfx_text(FONT_SMALL, 134, 94, "WARNING", C_BLACK, 255);+ }+ /* the board */+ gfx_rect(bt.x0, bt.y0, bt.x1 - bt.x0, bt.y1 - bt.y0, C_WHITE, 255);+ gfx_rect(bt.x0 + 2, bt.y0 + 2, bt.x1 - bt.x0 - 4, bt.y1 - bt.y0 - 4, C_BLACK, 255);+ gfx_clip(bt.x0 + 2, bt.y0 + 2, bt.x1 - bt.x0 - 4, bt.y1 - bt.y0 - 4);+ bullets_draw();+ gfx_clip(0, 0, SCREEN_W, SCREEN_H);+ if (!bt.inv || (bt.inv / 2) % 2) gfx_sprite(SPR_HEART, 0, soul_x(), soul_y(), 0, 255);+ if (om.msg_t && om.msg) gfx_text(FONT_SMALL, 70, 107, om.msg, C_WHITE, 255);+ battle_draw_hud();+}diff --git a/games/undertale/src/rooms.c b/games/undertale/src/rooms.cindex cec9cc11..52b9e7b7 100644--- a/games/undertale/src/rooms.c+++ b/games/undertale/src/rooms.c@@ -6,6 +6,7 @@#include "game.h"#include "hotland.h"#include "monsters.h"+#include "newhome.h"#include "ruins.h"#include "snowdin.h"#include "waterfall.h"@@ -26,6 +27,7 @@ void room_setup(int room, int from) {ht3_setup(room, from);res_setup(room, from);core_setup(room, from);+ nh_setup(room, from);}/* each frame Frisk can walk: what a room watches (a rock on its switch, a cracked floor) */diff --git a/games/undertale/src/text.c b/games/undertale/src/text.cindex 983664d8..227cbf65 100644--- a/games/undertale/src/text.c+++ b/games/undertale/src/text.c@@ -31,6 +31,7 @@ static const Expr flowey_faces[] = {};static const Expr sans_faces[] = {{SPR_FACE_SANS, 4, 0}, {SPR_FACE_SANSCHUCKLE, 4, 0}, {SPR_FACE_SANSWINK, 4, 0}};static const Expr alphys_faces[] = {{SPR_FACE_ALPHYS, 4, 0}};+static const Expr asgore_faces[] = {{SPR_FACE_ASGORE, 4, -4}};static const Expr papyrus_faces[] = {{SPR_FACE_PAPYRUS, 4, -4}, {SPR_FACE_PAPYRUSEVIL, 4, -4}, {SPR_FACE_PAPYRUSLAUGH, 4, -4},{SPR_FACE_PAPYRUSMAD, 4, -4}, {SPR_FACE_PAPYRUSSIDE, 4, -4},@@ -44,6 +45,7 @@ static const struct {[FACE_SANS] = {sans_faces, sizeof sans_faces / sizeof sans_faces[0]},[FACE_PAPYRUS] = {papyrus_faces, sizeof papyrus_faces / sizeof papyrus_faces[0]},[FACE_ALPHYS] = {alphys_faces, 1},+ [FACE_ASGORE] = {asgore_faces, 1},};/* ---------------------------------------------------------------- the writer */diff --git a/games/undertale/tests/check.py b/games/undertale/tests/check.pyindex d67949bd..67356fd5 100644--- a/games/undertale/tests/check.py+++ b/games/undertale/tests/check.py@@ -39,6 +39,7 @@ ITEM_OLD_TUTU, ITEM_BALLET_SHOES, ITEM_QUICHE, ITEM_PUNCH_CARD, ITEM_ARTIFACT, IITEM_BURNT_PAN, ITEM_INSTANT_NOODLES, ITEM_HOT_DOG, ITEM_STAINED_APRON = 28, 29, 30, 31ITEM_NICE_CREAM = 13ITEM_STARFAIT, ITEM_GLAMBURGER = 32, 33+ITEM_WORN_DAGGER, ITEM_HEART_LOCKET = 41, 42def run(args, frames, saves=None, what=""):@@ -289,11 +290,11 @@ if not QUICK: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+# Mettaton turned round and his show a hit, Alphys by the last elevator, up to New Homeif 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}")+ check(s and s["mode"] == MODE_WORLD and s["room"] == ROOMS["NH_TOWN"], f"the CORE did not end up in New Home: {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),@@ -303,6 +304,21 @@ if not QUICK: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']}")+# New Home: the keys and the chain, the presents, the story, Sans's judgment, Asgore in the throne room; at the+# barrier, Asgore beaten (FIGHT) and spared; Omega Flowey (the six SOULs called on); Flowey spared; the end+if not QUICK:+ s = run(["--name", "Frisk", "--noenc", "--god", "--room", str(ROOMS["NH_TOWN"]), "--at", "90,4545",+ "--path-file", os.path.join(HERE, "newhome.path")], 26000, what="New Home")+ check(s and s["mode"] == MODE_END, f"New Home did not reach the end: {s}")+ if s:+ for name, v in (("NH_KEY1", 1), ("NH_KEY2", 1), ("NH_CHAIN", 1), ("NH_DAGGER", 1), ("NH_LOCKET", 1),+ ("NH_STORY", 11), ("NH_SANS", 1), ("NH_THRONE", 1), ("NH_ASGORE", 1), ("NH_FLOWEY", 1),+ ("NH_DONE", 1)):+ check(flag(s, name) == v, f"New Home: F_{name} is {flag(s, name)}, not {v}")+ check(s["kills"] == 0, f"New Home: {s['kills']} killed on the friendly way")+ for item in (ITEM_WORN_DAGGER, ITEM_HEART_LOCKET):+ check(item in s["items"], f"New Home: item {item} not found: {s['items']}")+if failures:print("\n".join("FAIL " + f for f in failures))sys.exit(1)diff --git a/games/undertale/tests/newhome.path b/games/undertale/tests/newhome.pathnew file mode 100644index 00000000..e52df92b--- /dev/null+++ b/games/undertale/tests/newhome.path@@ -0,0 +1,70 @@+# New Home, from the elevator up from the CORE (play it with --room 176 --at 90,4545 --name Frisk --noenc --god): the+# street to Asgore's home; its two keys (the kitchen's, the hallway's), the presents (the Worn Dagger, the Heart+# Locket), the chain; the basement and its story; the Last Corridor and Sans; the throne room and Asgore; the+# barrier: Asgore fought (FIGHT), then spared; Flowey and his six SOULs; Flowey spared; Sans's call, the end+w5+go:340,4545+go:340,4330+go:1670,4330+go:1670,3130+1670,3100+w20+go:1300,2580+u+z+talk+go:2380,2822+u+z+talk+go:1990,2846+1990,2812+w20+go:1915,2621+u+z+pick:0+talk+go:2000,2607+u+z+pick:0+talk+go:2040,2655+2040,2700+w20+go:1660,2826+u+z+talk+w30+go:2550,2320+go:2550,2160+go:4720,2160+4720,2230+w20+go:5300,2350+talk+go:5830,2350+5830,2200+w20+go:6020,1810+6020,1780+w20+go:6010,1490+talk+go:5960,1120+5960,1090+w20+go:5960,990+go:6420,990+6420,938+talk+pick:0+talk+fight+pick:1+talk+pick:0+talk+w60diff --git a/games/undertale/tests/play.c b/games/undertale/tests/play.cindex ac74cd90..29e10ea2 100644--- a/games/undertale/tests/play.c+++ b/games/undertale/tests/play.c@@ -224,6 +224,10 @@ static uint32_t path_keys(int f) {return 0;}if (!strcmp(tok, "talk")) {+ if (g_mode == MODE_END) { /* (the end: nothing left to read on) */+ path_at = next;+ return 0;+ }if (!text_active() && !event_blocking() && g_mode == MODE_WORLD && !world_fading()) {path_at = next;return 0;diff --git a/games/undertale/tools/fetch.py b/games/undertale/tools/fetch.pyindex a865132b..142a570e 100644--- a/games/undertale/tools/fetch.py+++ b/games/undertale/tools/fetch.py@@ -63,7 +63,10 @@ PAGES = ["Ruins", "Ruins/Puzzles", "Toriel", "Toriel/In_battle", "Toriel's_Home""Madjick", "Knight_Knight", "Final_Froggit", "Whimsalot", "Astigmatism", "CORE", "MTT_Resort", "Burgerpants","Heats_Flamesman", "Bratty_and_Catty", "Spider_Bake_Sale", "Elevator", "Sans/Hotland", "Hot_Dog...?","Cell_Phone/Alphys", "Steam_Vent", "Conveyor_belt", "Mettaton_quiz_show", "Laser", "Royal_Guards", "Bomb",- "Stained_Apron", "Hot_Dog_Harpy", "Art_Club_room", "Spider_Entrance", "Multicolor_Tile_Puzzle", "Lab"]+ "Stained_Apron", "Hot_Dog_Harpy", "Art_Club_room", "Spider_Entrance", "Multicolor_Tile_Puzzle", "Lab",+ # New Home+ "New_Home", "Asgore", "Asgore/In_battle", "Asgore's_Home", "Last_Corridor", "Throne_Room", "Barrier",+ "Photoshop_Flowey", "Neutral_Route", "Worn_Dagger", "Heart_Locket"]# files the categories leave out, as their wiki namesFILES = ["QC sprite.png", "QC screenshot shop.png", "Gerson screenshot shop.png", "Tem Shop screenshot Temmie Armor.png"]DEMO = {diff --git a/games/undertale/tools/rooms.py b/games/undertale/tools/rooms.pyindex 7223e3af..71e55e75 100644--- a/games/undertale/tools/rooms.py+++ b/games/undertale/tools/rooms.py@@ -213,6 +213,16 @@ AREAS.append(dict(name="core", map="CORE_map.png", floor=CORE_FLOOR, margin=0, c("copy", 2551, 836, 22, 84, 2519, 836),]))+# New Home: grey streets, Asgore's home, the basement's corridors, the Last Corridor, the throne room, the coffins,+# the barrier. Its floors are cut by their rectangles alone (many colours: carpets, planks, flowers). Asgore (in the+# throne room, at the barrier) is an object here, and the friends of the true ending are off the map+AREAS.append(dict(name="newhome", map="New_Home_map.png", floor=[], margin=0, close=False, patches=[+ ("erase", 5988, 1270, 62, 92, "ring", []), ("erase", 6310, 717, 64, 72, "ring", []),+ ("erase", 5868, 906, 36, 54, "ring", []), ("erase", 5906, 921, 32, 42, "ring", []),+ ("erase", 5944, 889, 36, 64, "ring", []), ("erase", 5976, 886, 38, 70, "ring", []),+ ("erase", 6014, 921, 30, 42, "ring", []), ("erase", 6036, 911, 58, 64, "ring", []),+]))+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,@@ -681,6 +691,44 @@ ROOMS = [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")]),+ # New Home: the elevator up from the CORE, the city's street and the way to Asgore's home, its front yard+ dict(name="nh_town", area="newhome", rect=(0, 2930, 1900, 1710), title="New Home", open=True,+ floor_rects=[(40, 4536, 430, 44), (310, 4310, 100, 230), (250, 4310, 1450, 60), (1661, 3410, 34, 960),+ (1517, 3122, 311, 300)],+ doors=[((1663, 3118, 34, 8), "nh_house", (1670, 2900), "up")]),+ # Asgore's home: the hall (its chained stairs), the living room, the kitchen, the hallway and its two bedrooms+ dict(name="nh_house", area="newhome", rect=(1190, 2440, 1460, 500), title="Asgore's Home", open=True,+ floor_rects=[(1522, 2845, 316, 95), (1197, 2712, 325, 228), (1197, 2560, 200, 140), (1238, 2690, 42, 25),+ (1838, 2840, 734, 80), (1890, 2575, 200, 120), (2280, 2545, 220, 150)],+ fix=[("wall", 1248, 2830, 90, 40), ("wall", 1290, 2735, 80, 45)], # the dining table, the fireplace+ doors=[((1663, 2934, 34, 6), "nh_town", (1670, 3125), "down"),+ ((1978, 2836, 26, 6), "nh_house", (2040, 2658), "up"), ((2030, 2690, 42, 6), "nh_house", (1981, 2846), "down"),+ ((2402, 2836, 26, 6), "nh_house", (2410, 2658), "up"), ((2397, 2690, 50, 6), "nh_house", (2405, 2846), "down")]),+ # the basement: two long corridors (the story told on the way), the elevator back up at the end+ dict(name="nh_basement", area="newhome", rect=(1520, 2040, 3460, 420), title="New Home", open=True,+ floor_rects=[(1533, 2293, 1100, 94), (2517, 2143, 216, 250), (2633, 2143, 2200, 67), (4683, 2143, 117, 80)],+ doors=[((4683, 2216, 117, 8), "nh_last", (4720, 2240), "down")]),+ dict(name="nh_last", area="newhome", rect=(4580, 2210, 1400, 250), title="Last Corridor", open=True,+ floor_rects=[(4585, 2335, 1300, 75), (4683, 2222, 117, 113), (5797, 2222, 88, 113)],+ doors=[((4683, 2216, 117, 8), "nh_basement", (4720, 2180), "up"), ((5797, 2216, 88, 8), "nh_thall", (5790, 2180), "up")]),+ # the throne room's entrance (its SAVE), the throne room, the stairs down to the coffins+ dict(name="nh_thall", area="newhome", rect=(5640, 1700, 830, 530), title="Throne Entrance", open=True,+ floor_rects=[(5760, 1797, 588, 75), (5760, 1872, 88, 350), (6260, 1872, 88, 350), (6005, 1785, 50, 12)],+ doors=[((5760, 2216, 88, 8), "nh_last", (5820, 2240), "down"), ((6005, 1786, 50, 8), "nh_throne", (6010, 1600), "up"),+ ((6260, 2216, 88, 8), "nh_coffins", (6300, 2240), "down")]),+ dict(name="nh_throne", area="newhome", rect=(5880, 1080, 260, 600), title="Throne Room", open=True,+ floor_rects=[(5903, 1238, 215, 381), (5963, 1110, 119, 128), (5940, 1096, 56, 20), (5998, 1619, 48, 60)],+ doors=[((5998, 1662, 48, 8), "nh_thall", (6015, 1805), "down"), ((5940, 1096, 56, 8), "nh_barrier", (5955, 1040), "up")]),+ dict(name="nh_coffins", area="newhome", rect=(6210, 2215, 500, 800), title="New Home", open=True,+ floor_rects=[(6280, 2222, 60, 610), (6230, 2830, 460, 115)],+ doors=[((6280, 2222, 60, 8), "nh_thall", (6290, 2180), "up")]),+ # the room before the barrier ("The End"), and the barrier+ dict(name="nh_barrier", area="newhome", rect=(5820, 850, 700, 240), title="The End", open=True,+ floor_rects=[(5839, 977, 640, 44), (5839, 880, 262, 116), (5939, 1021, 62, 56), (6400, 960, 56, 20)],+ doors=[((5939, 1070, 62, 8), "nh_throne", (5955, 1120), "down"), ((6400, 960, 56, 8), "nh_wall", (6330, 780), "up")]),+ dict(name="nh_wall", area="newhome", rect=(6170, 560, 350, 270), title="The Barrier", open=True,+ floor_rects=[(6190, 600, 320, 215)],+ doors=[((6300, 810, 60, 8), "nh_barrier", (6415, 985), "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 fc5e3f3f..786204f6 100644--- a/games/undertale/tools/sprites.py+++ b/games/undertale/tools/sprites.py@@ -285,13 +285,60 @@ def gen_exarm():return [im]+def gen_xshot():+ # Omega Flowey's eyes' bullets: an X+ im = _img(7, 7)+ d = ImageDraw.Draw(im)+ d.line([(0, 0), (6, 6)], fill=(255, 255, 255, 255), width=2)+ d.line([(6, 0), (0, 6)], fill=(255, 255, 255, 255), width=2)+ return [im]+++def gen_pan():+ # the green SOUL's frying pan: a disc and its handle+ im = _img(20, 8)+ d = ImageDraw.Draw(im)+ d.ellipse([0, 0, 12, 7], fill=(255, 255, 255, 255))+ d.rectangle([12, 3, 19, 4], fill=(255, 255, 255, 255))+ return [im]+++def gen_shoe():+ # the blue SOUL's ballet shoe+ im = _img(12, 7)+ d = ImageDraw.Draw(im)+ d.polygon([(0, 2), (8, 1), (11, 3), (11, 6), (1, 6)], fill=(255, 255, 255, 255))+ d.line([(3, 0), (6, 3)], fill=(255, 255, 255, 255))+ return [im]+++def gen_book():+ # the purple SOUL's book+ im = _img(10, 12)+ d = ImageDraw.Draw(im)+ d.rectangle([0, 0, 9, 11], fill=(255, 255, 255, 255))+ d.line([(2, 0), (2, 11)], fill=(0, 0, 0, 255))+ return [im]+++def gen_actbutton():+ # the ACT button, coming down among a SOUL's attack (touch it to call for help)+ im = _img(26, 11)+ d = ImageDraw.Draw(im)+ d.rectangle([0, 0, 25, 10], outline=(255, 160, 0, 255))+ for x, ys in ((3, (2, 8)), (9, (2, 8)), (15, (2, 8)), (21, (2, 8))):+ d.line([(x, ys[0]), (x + 2, ys[1])], fill=(255, 160, 0, 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, "exblock": gen_exblock, "exleg": gen_exleg, "mttheart": gen_mttheart,- "disco": gen_disco, "exarm": gen_exarm}+ "disco": gen_disco, "exarm": gen_exarm, "xshot": gen_xshot, "pan": gen_pan, "shoe": gen_shoe, "book": gen_book,+ "actbutton": gen_actbutton}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:"@@ -474,6 +521,18 @@ SPRITES = [("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"]],+ # New Home: Asgore (in the castle, in battle: his idle thinned out, hurt, kneeling), his face; Omega Flowey's+ # screen (his smile, his laugh); the six SOULs; the shapes of their attacks+ ("asgore_ow", "wiki:Asgore_Dreemurr_overworld.png", {"feet": True}),+ ("asgore_b", "wiki:Asgore_Dreemurr_battle_idle.gif", {"feet": True, "clear_bg": True, "dedupe": True, "every": 24}),+ ("asgore_hurt", "wiki:Asgore_Dreemurr_battle_hurt.png", {"feet": True, "clear_bg": True}),+ ("asgore_kneel", "wiki:Asgore_Dreemurr_battle_kneeling.png", {"feet": True, "clear_bg": True}),+ ("face_asgore", "wiki:Asgore_Dreemurr_face.png", {"keep": True}),+ ("omega", "wiki:Omega_Flowey_battle_smile.png", {"center": True, "clear_bg": True}),+ ("omega_laugh", "wiki:Omega_Flowey_battle_laugh.gif", {"center": True, "clear_bg": True, "dedupe": True, "every": 6}),+ *[("soul_" + c.lower(), "wiki:" + c + "_SOUL_sprite.png", {"center": True})+ for c in ["Light_blue", "Orange", "Blue", "Purple", "Green", "Yellow"]],+ *[(n, "gen:" + n, {"center": True}) for n in ["xshot", "pan", "shoe", "book", "actbutton"]],("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",