From ee27ec97d1b937a127dd13992c8c2a7e0ced1981 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 4 Jun 2023 00:22:14 -0700 Subject: [PATCH] tutorial tweaks Replace tests against tutorial_dnum with 'In_tutorial()' predicate. Give a message when entering the tutorial (via level change mechanism). Likewise, give a message when resuming regular play. If player uses #quit or ^C in the tutorial, ask whether to cut the tutorial short and resume regular play; skip "Really quit?" if the answer is yes. Behavior is a bit odd for ^C + yes; it just sits there until player types something. --- include/dungeon.h | 3 ++- src/allmain.c | 5 +++-- src/botl.c | 9 ++++----- src/do.c | 6 +++--- src/end.c | 15 +++++++++++++-- src/teleport.c | 5 +++-- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/include/dungeon.h b/include/dungeon.h index e389b3641..e0539d4a8 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 dungeon.h $NHDT-Date: 1596498535 2020/08/03 23:48:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.39 $ */ +/* NetHack 3.7 dungeon.h $NHDT-Date: 1685863327 2023/06/04 07:22:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.47 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -139,6 +139,7 @@ typedef struct branch { #define In_sokoban(x) ((x)->dnum == sokoban_dnum) #define Inhell In_hell(&u.uz) /* now gehennom */ #define In_endgame(x) ((x)->dnum == astral_level.dnum) +#define In_tutorial(x) ((x)->dnum == tutorial_dnum) #define within_bounded_area(X, Y, LX, LY, HX, HY) \ ((X) >= (LX) && (X) <= (HX) && (Y) >= (LY) && (Y) <= (HY)) diff --git a/src/allmain.c b/src/allmain.c index 8fe7df980..fafbd8761 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 allmain.c $NHDT-Date: 1652831519 2022/05/17 23:51:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.185 $ */ +/* NetHack 3.7 allmain.c $NHDT-Date: 1685863328 2023/06/04 07:22:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.218 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -520,7 +520,8 @@ maybe_do_tutorial(void) if (ask_do_tutorial()) { assign_level(&u.ucamefrom, &u.uz); iflags.nofollowers = TRUE; - schedule_goto(&sp->dlevel, UTOTYPE_NONE, (char *) 0, (char *) 0); + schedule_goto(&sp->dlevel, UTOTYPE_NONE, + "Entering the tutorial.", (char *) 0); deferred_goto(); vision_recalc(0); docrt(); diff --git a/src/botl.c b/src/botl.c index 0159e86aa..a1e81e86a 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 botl.c $NHDT-Date: 1646171622 2022/03/01 21:53:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.209 $ */ +/* NetHack 3.7 botl.c $NHDT-Date: 1685863332 2023/06/04 07:22:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.233 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -445,10 +445,9 @@ describe_level( addbranch = FALSE; } else { /* ports with more room may expand this one */ - if (u.uz.dnum == tutorial_dnum) - Sprintf(buf, "Tutorial:%-2d", depth(&u.uz)); - else if (!addbranch) - Sprintf(buf, "Dlvl:%-2d", depth(&u.uz)); + if (!addbranch) + Sprintf(buf, "%s:%-2d", /* "Dlvl:n" (grep fodder) */ + In_tutorial(&u.uz) ? "Tutorial" : "Dlvl", depth(&u.uz)); else Sprintf(buf, "level %d", depth(&u.uz)); ret = 0; diff --git a/src/do.c b/src/do.c index 7512c91c2..88b14e135 100644 --- a/src/do.c +++ b/src/do.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 do.c $NHDT-Date: 1683832317 2023/05/11 19:11:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.352 $ */ +/* NetHack 3.7 do.c $NHDT-Date: 1685863330 2023/06/04 07:22:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.355 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1417,9 +1417,9 @@ goto_level( return; /* must have the Amulet */ if (!wizard) /* wizard ^V can bypass Earth level */ assign_level(newlevel, &earth_level); /* (redundant) */ - } else if (newlevel->dnum == tutorial_dnum) { + } else if (In_tutorial(newlevel)) { tutorial(TRUE); /* entering tutorial */ - } else if (u.uz.dnum == tutorial_dnum) { + } else if (In_tutorial(&u.uz)) { tutorial(FALSE); /* leaving tutorial */ up = FALSE; /* re-enter level 1 as if starting new game */ /* TODO: remove tutorial level(s) from #overview data */ diff --git a/src/end.c b/src/end.c index c8ce83fc9..d3caf0607 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 end.c $NHDT-Date: 1674546299 2023/01/24 07:44:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.265 $ */ +/* NetHack 3.7 end.c $NHDT-Date: 1685863329 2023/06/04 07:22:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.274 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -327,7 +327,13 @@ done1(int sig_unused UNUSED) int done2(void) { - if (!paranoid_query(ParanoidQuit, "Really quit?")) { + boolean abandon_tutorial = FALSE; + + if (In_tutorial(&u.uz) + && y_n("Switch from the tutorial back to regular play?") == 'y') + abandon_tutorial = TRUE; + + if (abandon_tutorial || !paranoid_query(ParanoidQuit, "Really quit?")) { #ifndef NO_SIGNAL (void) signal(SIGINT, (SIG_RET_TYPE) done1); #endif @@ -340,8 +346,13 @@ done2(void) u.uinvulnerable = FALSE; /* avoid ctrl-C bug -dlc */ u.usleep = 0; } + + if (abandon_tutorial) + schedule_goto(&u.ucamefrom, UTOTYPE_ATSTAIRS, + "Resuming regular play", (char *) 0); return ECMD_OK; } + #if (defined(UNIX) || defined(VMS) || defined(LATTICE)) if (wizard) { int c; diff --git a/src/teleport.c b/src/teleport.c index a723013f4..def2138b4 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 teleport.c $NHDT-Date: 1684374686 2023/05/18 01:51:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.202 $ */ +/* NetHack 3.7 teleport.c $NHDT-Date: 1685863331 2023/06/04 07:22:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.206 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1421,9 +1421,10 @@ domagicportal(struct trap *ttmp) target_level = ttmp->dst; /* coming back from tutorial doesn't trigger stunning */ - if (u.uz.dnum == tutorial_dnum && target_level.dnum != tutorial_dnum) { + if (In_tutorial(&u.uz) && !In_tutorial(&target_level)) { /* returning to normal play => arrive on level 1 stairs */ totype = UTOTYPE_ATSTAIRS; + stunmsg = "Resuming regular play."; } else { totype = UTOTYPE_PORTAL; stunmsg = !Stunned ? "You feel slightly dizzy."