]> granicus.if.org Git - nethack/commitdiff
alignment of Angels
authornethack.rankin <nethack.rankin>
Wed, 5 Oct 2005 05:15:46 +0000 (05:15 +0000)
committernethack.rankin <nethack.rankin>
Wed, 5 Oct 2005 05:15:46 +0000 (05:15 +0000)
     From a bug report, the probing/stethoscope code assumed that all Angels
(the specific monster type, not the whole 'A' class) used the epri extension
to hold alignment, but that's not true for randomly generated ones.  So
monster status feedback gave erroneous results, and it would vary based on
pet behavior if the random Angel had been tamed.  Also, touch_artifact()
didn't know about special alignment handling for Angels and aligned priests
so always used their default alignment.

     There are other problems with Angels--such as whether they should even
be allowed to be generated randomly in the first place--that this doesn't
attempt to address.  The patch for that was starting to sprawl all over the
place so I pulled this simpler bit out for a first cut.  Probing now shows
the Wizard of Yendor as unaligned instead of lumping him in with chaotics.

     Another Makefile update needed:  pline.[c,o] no longer needs epri.h.

doc/fixes34.4
include/extern.h
src/artifact.c
src/pline.c
src/priest.c

index 0b9d2d982d4c219dccc28aaf74e399e4e8ead2b6..ec6d9195f64594f55d0ad8f9327fdec1f258cb3c 100644 (file)
@@ -149,6 +149,7 @@ unicorn can't catch gems if it is asleep or paralyzed
 fix grammar when choking on gold
 some messages which referred to "mirror" ought to have used "looking glass"
 incubi react to mirrors
+alignment of Angels was handled inconsistently
 
 
 Platform- and/or Interface-Specific Fixes
index b2ccde1ee0bc6fba01bb376fe74698cf5e4cfacf..0fd51656f06616b6a1247bb162d92afbf72783ac 100644 (file)
@@ -1663,6 +1663,7 @@ E int FDECL(move_special, (struct monst *,BOOLEAN_P,SCHAR_P,BOOLEAN_P,BOOLEAN_P,
 E char FDECL(temple_occupied, (char *));
 E int FDECL(pri_move, (struct monst *));
 E void FDECL(priestini, (d_level *,struct mkroom *,int,int,BOOLEAN_P));
+E aligntyp FDECL(mon_aligntyp, (struct monst *));
 E char *FDECL(priestname, (struct monst *,char *));
 E boolean FDECL(p_coaligned, (struct monst *));
 E struct monst *FDECL(findpriest, (CHAR_P));
index c8950b1e56d3ebb59887e8bf4416fb35df22864b..9ea4ae6c829e10dd9269157cb7f6dc00714df713 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)artifact.c 3.5     2005/09/20      */
+/*     SCCS Id: @(#)artifact.c 3.5     2005/10/01      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -507,7 +507,7 @@ touch_artifact(obj,mon)
        badclass = self_willed &&
                   oart->role != NON_PM && oart != &artilist[ART_EXCALIBUR];
        badalign = (oart->spfx & SPFX_RESTR) && oart->alignment != A_NONE &&
-                  (oart->alignment != sgn(mon->data->maligntyp));
+                  (oart->alignment != sgn(mon_aligntyp(mon)));
     } else {    /* an M3_WANTSxxx monster or a fake player */
        /* special monsters trying to take the Amulet, invocation tools or
           quest item can touch anything except for `spec_applies' artifacts */
index ffc458e641c4526879360b8e049954bea1a2b498..c9b071a4d92d39118409087231bf1bcf2b16a82a 100644 (file)
@@ -1,10 +1,9 @@
-/*     SCCS Id: @(#)pline.c    3.5     2005/06/22      */
+/*     SCCS Id: @(#)pline.c    3.5     2005/10/01      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 #define NEED_VARARGS /* Uses ... */    /* comment line for pre-compiled headers */
 #include "hack.h"
-#include "epri.h"
 #ifdef WIZARD
 #include "edog.h"
 #endif
@@ -304,18 +303,9 @@ void
 mstatusline(mtmp)
 register struct monst *mtmp;
 {
-       aligntyp alignment;
+       aligntyp alignment = mon_aligntyp(mtmp);
        char info[BUFSZ], monnambuf[BUFSZ];
 
-       if (mtmp->ispriest || mtmp->data == &mons[PM_ALIGNED_PRIEST]
-                               || mtmp->data == &mons[PM_ANGEL])
-               alignment = EPRI(mtmp)->shralign;
-       else
-               alignment = mtmp->data->maligntyp;
-       alignment = (alignment > 0) ? A_LAWFUL :
-               (alignment < 0) ? A_CHAOTIC :
-               A_NEUTRAL;
-
        info[0] = 0;
        if (mtmp->mtame) {        Strcat(info, ", tame");
 #ifdef WIZARD
index 79490e07e465db6c2f6350c4d591520a748f61e4..f98ba9e32d70f3148db7e5683a94fcb46d2a59c5 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)priest.c   3.5     2002/11/06      */
+/*     SCCS Id: @(#)priest.c   3.5     2005/10/01      */
 /* Copyright (c) Izchak Miller, Steve Linhart, 1989.             */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -221,6 +221,19 @@ boolean sanctum;   /* is it the seat of the high priest? */
        }
 }
 
+/* get a monster's alignment type without caller needing EPRI & EMIN */
+aligntyp
+mon_aligntyp(mon)
+struct monst *mon;
+{
+    aligntyp algn = mon->ispriest ? EPRI(mon)->shralign :
+                   mon->isminion ? EMIN(mon)->min_align :
+                   mon->data->maligntyp;
+
+    if (algn == A_NONE) return A_NONE; /* negative but differs from chaotic */
+    return (algn > 0) ? A_LAWFUL : (algn < 0) ? A_CHAOTIC : A_NEUTRAL;
+}
+
 /*
  * Specially aligned monsters are named specially.
  *     - aligned priests with ispriest and high priests have shrines