]> granicus.if.org Git - nethack/commitdiff
onscary() vs "Elbereth"
authorPatR <rankin@nethack.org>
Tue, 12 Sep 2017 01:47:26 +0000 (18:47 -0700)
committerPatR <rankin@nethack.org>
Tue, 12 Sep 2017 01:47:26 +0000 (18:47 -0700)
When checking whether hero is on a protected spot, don't check for
engraved "Elbereth" unless/until other conditions have been exhausted.

src/monmove.c

index 92cdac8dd1f6115479d3bf66b32a371442aa848f..0d1241ab42917f58b665647649025510f7a469c9 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 monmove.c       $NHDT-Date: 1496534703 2017/06/04 00:05:03 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.91 $ */
+/* NetHack 3.6 monmove.c       $NHDT-Date: 1505180840 2017/09/12 01:47:20 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.92 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -134,8 +134,6 @@ onscary(x, y, mtmp)
 int x, y;
 struct monst *mtmp;
 {
-    boolean epresent = sengr_at("Elbereth", x, y, TRUE);
-
     /* creatures who are directly resistant to magical scaring:
      * Rodney, lawful minions, angels, the Riders */
     if (mtmp->iswiz || is_lminion(mtmp) || mtmp->data == &mons[PM_ANGEL]
@@ -152,16 +150,18 @@ struct monst *mtmp;
     if (sobj_at(SCR_SCARE_MONSTER, x, y))
         return TRUE;
 
-    /* creatures who don't (or can't) fear a written Elbereth:
+    /*
+     * Creatures who don't (or can't) fear a written Elbereth:
      * all the above plus shopkeepers, guards, blind or
      * peaceful monsters, humans, and minotaurs.
      *
-     * if the player isn't actually on the square OR the player's image
-     * isn't displaced to the square, no protection is being granted
+     * If the player isn't actually on the square OR the player's image
+     * isn't displaced to the square, no protection is being granted.
      *
      * Elbereth doesn't work in Gehennom, the Elemental Planes, or the
-     * Astral Plane; the influence of the Valar only reaches so far.  */
-    return (epresent
+     * Astral Plane; the influence of the Valar only reaches so far.
+     */
+    return (sengr_at("Elbereth", x, y, TRUE)
             && ((u.ux == x && u.uy == y)
                 || (Displaced && mtmp->mux == x && mtmp->muy == y))
             && !(mtmp->isshk || mtmp->isgd || !mtmp->mcansee