]> granicus.if.org Git - nethack/commitdiff
up/down level feedback
authorPatR <rankin@nethack.org>
Sat, 4 Feb 2023 23:28:13 +0000 (15:28 -0800)
committerPatR <rankin@nethack.org>
Sat, 4 Feb 2023 23:28:13 +0000 (15:28 -0800)
With sounds on, using #levelchange to drop more than one level only
gave the level-loss sound effect once.  Level-gain sound was better
because the more verbose messaging triggered --More-- before moving
on.  Have both gain and loss use urgent_pline() in case messages
are being suppressed due to ESC, and have both request --More-- to
make the player acknowledge the message.  That has a side-effect of
letting the sound play to conclusion.

src/exper.c

index 120aa91b3be10eb66efdecc73e1b3a0456c0d4bf..71f99e25a7655e65ec2768a9405768e35591cbfe 100644 (file)
@@ -220,14 +220,18 @@ losexp(
        (drainer==NULL) resets a level 1 character to 0 experience points
        without reducing level and that isn't fatal so suppress the message
        in that situation */
-    if (u.ulevel > 1 || drainer)
-        pline("%s level %d.", Goodbye(), u.ulevel);
+    if (u.ulevel > 1 || drainer) {
+        urgent_pline("%s level %d.", Goodbye(), u.ulevel);
+        SoundAchievement(0, sa2_xpleveldown, 0);
+        /* issue --More-- so that player acknowleges the loss in level
+           and also to give the sound effect enough time to play */
+        display_nhwindow(WIN_MESSAGE, TRUE);
+    }
     if (u.ulevel > 1) {
         u.ulevel -= 1;
         /* remove intrinsic abilities */
         adjabil(u.ulevel + 1, u.ulevel);
         livelog_printf(LL_MINORAC, "lost experience level %d", u.ulevel + 1);
-        SoundAchievement(0, sa2_xpleveldown, 0);
     } else {
         if (drainer) {
             gk.killer.format = KILLED_BY;
@@ -235,7 +239,7 @@ losexp(
                 Strcpy(gk.killer.name, drainer);
             done(DIED);
         }
-        /* no drainer or lifesaved */
+        /* no drainer or else lifesaved */
         u.uexp = 0;
         livelog_printf(LL_MINORAC, "lost all experience");
     }
@@ -339,13 +343,16 @@ pluslvl(
             u.uexp = newuexp(u.ulevel);
         }
         ++u.ulevel;
-        pline("Welcome %sto experience level %d.",
-              (u.ulevelmax < u.ulevel) ? "" : "back ",
-              u.ulevel);
+        urgent_pline("Welcome %sto experience level %d.",
+                     (u.ulevelmax < u.ulevel) ? "" : "back ", u.ulevel);
+        SoundAchievement(0, sa2_xplevelup, 0);
+        /* issue --More-- so that player acknowleges the gain in level
+           and also to give the sound effect enough time to play */
+        display_nhwindow(WIN_MESSAGE, TRUE);
         if (u.ulevelmax < u.ulevel)
             u.ulevelmax = u.ulevel;
         adjabil(u.ulevel - 1, u.ulevel); /* give new intrinsics */
-        SoundAchievement(0, sa2_xplevelup, 0);
+
         old_ach_cnt = count_achievements();
         newrank = xlev_to_rank(u.ulevel);
         if (newrank > oldrank)