]> granicus.if.org Git - nethack/commitdiff
conditional status condition tracking
authorPatR <rankin@nethack.org>
Mon, 2 Mar 2020 23:16:50 +0000 (15:16 -0800)
committerPatR <rankin@nethack.org>
Mon, 2 Mar 2020 23:16:50 +0000 (15:16 -0800)
If 'sinking-into-lava' is disabled as a displayed status condition
but general 'trapped' is enabled, then display 'trapped' when in lava.
Similarly, if 'grabbed-by-eel' is disabled but more general 'held' is
enabled, display 'held' when grabbed.

src/botl.c

index 4a80ed43be874bd36ff2e6ce9a1bd77dd64f609a..3b29e348b644d445777c51c6c51c0d26cace4591 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 botl.c  $NHDT-Date: 1573178085 2019/11/08 01:54:45 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.148 $ */
+/* NetHack 3.6 botl.c  $NHDT-Date: 1583190980 2020/03/02 23:16:20 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.185 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -835,38 +835,57 @@ bot_via_windowport()
 
 #define test_if_enabled(c) if (condtests[(c)].enabled) condtests[(c)].test
 
+    condtests[bl_foodpois].test = condtests[bl_termill].test = FALSE;
+    if (Sick) {
+        test_if_enabled(bl_foodpois) = (u.usick_type & SICK_VOMITABLE) != 0;
+        test_if_enabled(bl_termill) = (u.usick_type & SICK_NONVOMITABLE) != 0;
+    }
+    condtests[bl_inlava].test = condtests[bl_tethered].test
+        = condtests[bl_trapped].test = FALSE;
+    if (u.utrap) {
+        test_if_enabled(bl_inlava) = (u.utraptype == TT_LAVA);
+        test_if_enabled(bl_tethered) = (u.utraptype == TT_BURIEDBALL);
+        /* if in-lava or tethered is disabled and the condition applies,
+           lump it in with trapped */
+        test_if_enabled(bl_trapped) = (!condtests[bl_inlava].test
+                                       && !condtests[bl_tethered].test);
+    }
+    condtests[bl_grab].test = condtests[bl_held].test
+        = condtests[bl_holding].test = FALSE;
+    if (u.ustuck) {
+        if (Upolyd && sticks(g.youmonst.data)) {
+            test_if_enabled(bl_holding) = TRUE;
+        } else {
+            test_if_enabled(bl_grab) = (u.ustuck->data->mlet == S_EEL);
+#if 0
+            test_if_enabled(bl_engulfed) = u.uswallow ? TRUE : FALSE;
+            test_if_enabled(bl_held) = (!condtests[bl_grab].test
+                                        && !condtests[bl_engulfed].test);
+#else
+            test_if_enabled(bl_held) = (!condtests[bl_grab].test
+                /* engulfed/swallowed isn't currently a tracked condition
+                   and showing "held" when in that state looks a bit odd,
+                   so suppress "held" if swallowed */
+                                        && !u.uswallow);
+#endif
+        }
+    }
     condtests[bl_blind].test     = (Blind);
     condtests[bl_conf].test      = (Confusion) ? TRUE : FALSE;
     condtests[bl_deaf].test      = (Deaf);
     condtests[bl_fly].test       = (Flying);
-    condtests[bl_foodpois].test  = (Sick
-                                    && (u.usick_type & SICK_VOMITABLE) != 0);
     condtests[bl_glowhands].test = (u.umconf);
-    condtests[bl_grab].test      = (u.ustuck && u.ustuck->data->mlet == S_EEL);
     condtests[bl_hallu].test     = (Hallucination);
-    condtests[bl_inlava].test    = (u.utrap && u.utraptype == TT_LAVA);
     condtests[bl_lev].test       = (Levitation);
     condtests[bl_ride].test      = (u.usteed) ? TRUE : FALSE;
     condtests[bl_slime].test     = (Slimed) ? TRUE : FALSE;
     condtests[bl_stone].test     = (Stoned) ? TRUE : FALSE;
     condtests[bl_strngl].test    = (Strangled) ? TRUE : FALSE;
     condtests[bl_stun].test      = (Stunned) ? TRUE : FALSE;
-    condtests[bl_termill].test   = (Sick
-                                    && (u.usick_type & SICK_NONVOMITABLE)
-                                        != 0);
     test_if_enabled(bl_elf_iron) = (FALSE);
     test_if_enabled(bl_bareh)    = (!uarmg && !uwep);
-    /* do this next one before bl_held */
-    condtests[bl_holding].test   = (u.ustuck && !u.uswallow
-                                    && Upolyd && sticks(g.youmonst.data));
-    test_if_enabled(bl_held)     = (u.ustuck && !u.uswallow
-                                    && !condtests[bl_holding].test
-                                    && !condtests[bl_grab].test);
     test_if_enabled(bl_icy)      = levl[u.ux][u.uy].typ == ICE;
     test_if_enabled(bl_slippery) = (Glib) ? TRUE : FALSE;
-    test_if_enabled(bl_trapped)  = (u.utrap && u.utraptype != TT_BURIEDBALL
-                                            && u.utraptype != TT_LAVA);
-    test_if_enabled(bl_tethered) = (u.utrap && u.utraptype == TT_BURIEDBALL);
     test_if_enabled(bl_woundedl) = (Wounded_legs);
 
     if (g.multi < 0) {