]> granicus.if.org Git - nethack/commitdiff
polywarn (trunk only)
authornethack.allison <nethack.allison>
Thu, 3 Jun 2004 04:20:13 +0000 (04:20 +0000)
committernethack.allison <nethack.allison>
Thu, 3 Jun 2004 04:20:13 +0000 (04:20 +0000)
This patch increments editlevel making existing save and bones files useless.

Add polywarn() code to grant the ability to detect certain monster
types while polymorphed into other specific monster types.

If you polymorph into a vampire or vampire lord, you are able to
sense humans.

And just for fun, if you polymorph into a purple worm, you are able to
sense shriekers :-)

doc/fixes35.0
include/context.h
include/hack.h
include/patchlevel.h
src/artifact.c
src/cmd.c
src/polyself.c
src/restore.c

index ff4a9427df42171aa951d6dffed3d9f598edb2cc..96cd23f6d008bc8f19bdae08c0057df149a6b417 100644 (file)
@@ -106,6 +106,7 @@ wishing for particular variety of tin contents (deep fried, broiled, etc.)
 debug-mode wishing for random monster(s) via '*'
 health-food store that stocks monk-appropriate foods in mine town when monk
 give more information about your attributes in debug mode
+polywarn to give intrinsic monster detection of limited species while polymorphed
 
 
 Platform- and/or Interface-Specific New Features
index dc16cfe13f34363019d08b1cd4057db195ddf1ac..d4d4d7153e03f2a245cd06409ce73b081b23a2a5 100644 (file)
@@ -65,8 +65,14 @@ struct victual_info {
        Bitfield(doreset,1);    /* stop eating at end of turn */
 };
 
+struct warntype_info {
+       unsigned long obj;      /* object warn_of_mon monster type M2 */
+       unsigned long polyd;    /* warn_of_mon monster type M2 due to poly */
+       struct permonst *species;       /* particular species due to poly */
+       short speciesidx;       /* index of above in mons[] (for save/restore) */
+};
+
 struct context_info {
-       unsigned long warntype; /* warn_of_mon monster type M2 */
        unsigned ident;         /* social security number for each monster */
        unsigned no_of_wizards; /* 0, 1 or 2 (wizard and his shadow) */
        unsigned run;           /* 0: h (etc), 1: H (etc), 2: fh (etc) */
@@ -94,6 +100,7 @@ struct context_info {
        struct tin_info tin;
        struct book_info spbook;
        struct takeoff_info takeoff;
+       struct warntype_info warntype;
 };
 
 extern NEARDATA struct context_info context;
index 26cde3aae008e58f56aa5072bf1c1574f8e3e6d6..ba77608c15e44900419adc8ea2652cd7698248fd 100644 (file)
@@ -101,8 +101,13 @@ NEARDATA extern coord bhitpos;     /* place where throw or zap hits or stops */
 #define FLASHED_LIGHT  3
 #define INVIS_BEAM     4
 
-#define MATCH_WARN_OF_MON(mon)  (Warn_of_mon && context.warntype && \
-                                (context.warntype & (mon)->data->mflags2))
+#define MATCH_WARN_OF_MON(mon)  (Warn_of_mon && \
+                                ((context.warntype.obj && \
+                                 (context.warntype.obj & (mon)->data->mflags2)) || \
+                                 (context.warntype.polyd && \
+                                 (context.warntype.polyd & (mon)->data->mflags2)) || \
+                                 (context.warntype.species && \
+                                 (context.warntype.species == (mon)->data))))
 
 #include "trap.h"
 #include "flag.h"
index 02d94a12678ae5692fb7a6d881d9bd4d5a4d14f7..5eb92c4cb69be385c48acd789acb063bc2f7c0ed 100644 (file)
@@ -13,7 +13,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      10
+#define EDITLEVEL      11
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2004"
index dafd7db816b315be8ddb230b223fd0617d4c2a9a..a071842daa7a8f8f9f8ae2bbd0d484d70eb658ec 100644 (file)
@@ -434,10 +434,10 @@ long wp_mask;
            if (spec_m2(otmp)) {
                if (on) {
                        EWarn_of_mon |= wp_mask;
-                       context.warntype |= spec_m2(otmp);
+                       context.warntype.obj |= spec_m2(otmp);
                } else {
                        EWarn_of_mon &= ~wp_mask;
-                       context.warntype &= ~spec_m2(otmp);
+                       context.warntype.obj &= ~spec_m2(otmp);
                }
                see_monsters();
            } else {
index 13df80e2f8790b5b12f34ded3d0c691b77cd73cc..ffd47ec889276c44093db1c01625949672730d52 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -975,13 +975,29 @@ int final;        /* 0 => still in progress; 1 => over, survived; 2 => dead */
                                        from_what(SEE_INVIS));
        if (Blind_telepat) you_are("telepathic",from_what(TELEPAT));
        if (Warning) you_are("warned", from_what(WARNING));
-       if (Warn_of_mon && context.warntype) {
+       if (Warn_of_mon && context.warntype.obj) {
                Sprintf(buf, "aware of the presence of %s",
-                       (context.warntype & M2_ORC) ? "orcs" :
-                       (context.warntype & M2_DEMON) ? "demons" :
+                       (context.warntype.obj & M2_ORC) ? "orcs" :
+                       (context.warntype.obj & M2_DEMON) ? "demons" :
                        something); 
                you_are(buf,from_what(WARN_OF_MON));
        }
+       if (Warn_of_mon && context.warntype.polyd) {
+               Sprintf(buf, "aware of the presence of %s",
+                   ((context.warntype.polyd &
+                     (M2_HUMAN|M2_ELF))==(M2_HUMAN|M2_ELF)) ? "humans and elves" :
+                   (context.warntype.polyd & M2_HUMAN) ? "humans" :
+                   (context.warntype.polyd & M2_ELF) ? "elves" :
+                   (context.warntype.polyd & M2_ORC) ? "orcs" :
+                   (context.warntype.polyd & M2_DEMON) ? "demons" :
+                   "certain monsters");
+               you_are(buf,from_what(WARN_OF_MON));
+       }
+       if (Warn_of_mon && context.warntype.speciesidx) {
+               Sprintf(buf, "aware of the presence of %s",
+                       makeplural(mons[context.warntype.speciesidx].mname));
+               you_are(buf,from_what(WARN_OF_MON));
+       }
        if (Undead_warning) you_are("warned of undead",from_what(WARN_UNDEAD));
        if (Searching) you_have("automatic searching",from_what(SEARCHING));
        if (Clairvoyant) you_are("clairvoyant",from_what(CLAIRVOYANT));
index 210eded106e22daa272b695205a6c2d5cd55b68d..fa5f42967baf00ab5f06e2918f6ddaf0fb53b26b 100644 (file)
@@ -18,6 +18,7 @@ STATIC_DCL void FDECL(drop_weapon,(int));
 STATIC_DCL void NDECL(uunstick);
 STATIC_DCL int FDECL(armor_to_dragon,(int));
 STATIC_DCL void NDECL(newman);
+STATIC_DCL boolean FDECL(polysense,(struct permonst *));
 
 /* update the youmonst.data structure pointer */
 void
@@ -205,6 +206,7 @@ dead: /* we come directly here if their experience level went to 0 or less */
                    Strcpy(killer.name, "unsuccessful polymorph");
                    done(DIED);
                    newuhs(FALSE);
+                   (void) polysense(youmonst.data);
                    return; /* lifesaved */
                }
        }
@@ -216,6 +218,7 @@ dead: /* we come directly here if their experience level went to 0 or less */
                Your("body transforms, but there is still slime on you.");
                make_slimed(10L, (const char*) 0);
        }
+       (void) polysense(youmonst.data);
        context.botl = 1;
        see_monsters();
        (void) encumber_msg();
@@ -559,6 +562,8 @@ int mntmp;
            You("orient yourself on the web.");
            u.utrap = 0;
        }
+       (void) polysense(youmonst.data);
+
        context.botl = 1;
        vision_full_recalc = 1;
        see_monsters();
@@ -1329,4 +1334,37 @@ int atyp;
        }
 }
 
+/*
+ * Some species have awareness of other species
+ */
+static boolean
+polysense(mptr)
+struct permonst *mptr;
+{
+       short warnidx = 0;
+       context.warntype.speciesidx = 0;
+       context.warntype.species = 0;
+       context.warntype.polyd = 0;
+
+       switch (monsndx(mptr)) {
+           case PM_PURPLE_WORM:
+               warnidx = PM_SHRIEKER;
+               break;
+           case PM_VAMPIRE:
+           case PM_VAMPIRE_LORD:
+               context.warntype.polyd = M2_HUMAN | M2_ELF;
+               HWarn_of_mon |= FROMRACE;
+               return TRUE;
+       }
+       if (warnidx) {
+               context.warntype.speciesidx = warnidx;
+               context.warntype.species = &mons[warnidx];
+               HWarn_of_mon |= FROMRACE;
+               return TRUE;
+       }
+       context.warntype.speciesidx = 0;
+       context.warntype.species = 0;
+       HWarn_of_mon &= ~FROMRACE;
+       return FALSE;
+}
 /*polyself.c*/
index 76fcbd3b2f5cd37b07ec6096f50e6673ccae462d..f3fcc9e810fd68a3d0a614f52a010c1828c461c7 100644 (file)
@@ -381,6 +381,9 @@ unsigned int *stuckid, *steedid;    /* STEED */
                return FALSE;
        }
        mread(fd, (genericptr_t) &context, sizeof(struct context_info));
+       if (context.warntype.speciesidx)
+               context.warntype.species = &mons[context.warntype.speciesidx];
+
        mread(fd, (genericptr_t) &flags, sizeof(struct flag));
        if (remember_discover) discover = remember_discover;
 #ifdef SYSFLAGS