]> granicus.if.org Git - nethack/commitdiff
Allow custom increment amounts in #wizintrinsic
authorMichael Meyer <me@entrez.cc>
Fri, 22 Jan 2021 19:14:12 +0000 (14:14 -0500)
committerPasi Kallinen <paxed@alt.org>
Fri, 22 Jan 2021 20:34:54 +0000 (22:34 +0200)
Let users of #wizintrinsic set a specific amount by which they want to
increment each particular timeout, by entering a count/typing in
numerals before selecting the item in the list.  I think doing it this
way should be pretty intuitive to players who are familiar with the
'enter count -> make selection' flow of normal inventory menus in
NetHack, and is simpler than using a separate prompt, as was mentioned
as a possibility in a comment.

When an intrinsic is selected without entering a count, the increment
will continue to default to the previous value of 30; this value is set
via the DEFAULT_TIMEOUT_INCR macro.

I also deleted a redundant declaration of wiz_intrinsic; the duplicate
seems to have been added by mistake in ff6139c6c5.

src/cmd.c

index bfc9ece1c691de91cdd36d3d3fbc358a3004a10e..f4233aa6aaf448b232abfe00c37329090f9b647a 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -130,7 +130,6 @@ static int NDECL(dotravel);
 static int NDECL(doterrain);
 static int NDECL(wiz_wish);
 static int NDECL(wiz_identify);
-static int NDECL(wiz_intrinsic);
 static int NDECL(wiz_map);
 static int NDECL(wiz_makemap);
 static int NDECL(wiz_genesis);
@@ -1548,6 +1547,8 @@ wiz_smell(VOID_ARGS)
     return 0;
 }
 
+#define DEFAULT_TIMEOUT_INCR 30
+
 /* #wizinstrinsic command to set some intrinsics for testing */
 static int
 wiz_intrinsic(VOID_ARGS)
@@ -1600,11 +1601,12 @@ wiz_intrinsic(VOID_ARGS)
         n = select_menu(win, PICK_ANY, &pick_list);
         destroy_nhwindow(win);
 
-        amt = 30; /* TODO: prompt for duration */
         for (j = 0; j < n; ++j) {
             i = pick_list[j].item.a_int - 1; /* -1: reverse +1 above */
             p = propertynames[i].prop_num;
             oldtimeout = u.uprops[p].intrinsic & TIMEOUT;
+            amt = (pick_list[j].count == -1L) ? DEFAULT_TIMEOUT_INCR
+                                              : (int) pick_list[j].count;
             newtimeout = oldtimeout + (long) amt;
             switch (p) {
             case SICK: