]> granicus.if.org Git - nethack/commitdiff
more angry god vs pacifist conduct
authorPatR <rankin@nethack.org>
Tue, 10 May 2016 22:59:22 +0000 (15:59 -0700)
committerPatR <rankin@nethack.org>
Tue, 10 May 2016 22:59:22 +0000 (15:59 -0700)
Do it properly, using the arguments to xkilled() instead of reversing
the conduct counter after the fact.

The xkilled() flag value of '1' has been reversed.  It used to mean
'display message' but now means 'suppress message' since both of the
other flag bits are for suppression.  All callers have been updated
to specify either XKILL_GIVEMSG or XKILL_NOMSG so the underlying
number remains transparent.

13 files changed:
include/hack.h
src/apply.c
src/dbridge.c
src/mhitu.c
src/mon.c
src/mthrowu.c
src/muse.c
src/music.c
src/pray.c
src/read.c
src/trap.c
src/uhitm.c
src/zap.c

index 9054e0cf16bb901de561e0a0ff2f994a3cb020d8..fb25a167286e6a8327223273bc2f109efa28c278 100644 (file)
@@ -326,6 +326,13 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
 #define SORTLOOT_INVLET 0x02
 #define SORTLOOT_LOOT   0x04
 
+/* flags for xkilled() [note: meaning of first bit used to be reversed,
+   1 to give message and 0 to suppress] */
+#define XKILL_GIVEMSG   0
+#define XKILL_NOMSG     1
+#define XKILL_NOCORPSE  2
+#define XKILL_NOCONDUCT 4
+
 /* Macros for messages referring to hands, eyes, feet, etc... */
 #define ARM 0
 #define EYE 1
index ddd253aeed46f60064c0fc5e772a96bf56608289..24db211d39ab1d827fbdd068d53d3287ca8edc90 100644 (file)
@@ -737,7 +737,7 @@ register xchar x, y;
                        that's the result of his actions; gain experience,
                        lose pacifism, take alignment and luck hit, make
                        corpse less likely to remain tame after revival */
-                    xkilled(mtmp, 0); /* no "you kill it" message */
+                    xkilled(mtmp, XKILL_NOMSG);
                     /* life-saving doesn't ordinarily reset this */
                     if (mtmp->mhp > 0)
                         u.uconduct.killer = save_pacifism;
index 428161de59697ccad567bb46462f2c1d1e7b095b..be087fd4b66308272a25f814bfd2fbfdf505dd5d 100644 (file)
@@ -423,9 +423,9 @@ int x, y;
 }
 
 STATIC_OVL void
-e_died(etmp, dest, how)
+e_died(etmp, xkill_flags, how)
 struct entity *etmp;
-int dest, how;
+int xkill_flags, how;
 {
     if (is_u(etmp)) {
         if (how == DROWNING) {
@@ -462,13 +462,14 @@ int dest, how;
 
         killer.name[0] = 0;
 /* fake "digested to death" damage-type suppresses corpse */
-#define mk_message(dest) ((dest & 1) ? "" : (char *) 0)
-#define mk_corpse(dest) ((dest & 2) ? AD_DGST : AD_PHYS)
+#define mk_message(dest) (((dest & XKILL_NOMSG) != 0) ? (char *) 0 : "")
+#define mk_corpse(dest) (((dest & XKILL_NOCORPSE) != 0) ? AD_DGST : AD_PHYS)
         /* if monsters are moving, one of them caused the destruction */
         if (context.mon_moving)
-            monkilled(etmp->emon, mk_message(dest), mk_corpse(dest));
+            monkilled(etmp->emon,
+                      mk_message(xkill_flags), mk_corpse(xkill_flags));
         else /* you caused it */
-            xkilled(etmp->emon, dest);
+            xkilled(etmp->emon, xkill_flags);
         etmp->edata = (struct permonst *) 0;
 
         /* dead long worm handling */
@@ -605,7 +606,9 @@ struct entity *etmp;
         if (crm->typ == DRAWBRIDGE_DOWN) {
             pline("%s crushed underneath the drawbridge.",
                   E_phrase(etmp, "are"));             /* no jump */
-            e_died(etmp, e_inview ? 3 : 2, CRUSHING); /* no corpse */
+            e_died(etmp,
+                   XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG),
+                   CRUSHING); /* no corpse */
             return;       /* Note: Beyond this point, we know we're  */
         }                 /* not at an opened drawbridge, since all  */
         must_jump = TRUE; /* *missable* creatures survive on the     */
@@ -621,7 +624,10 @@ struct entity *etmp;
                           E_phrase(etmp, "are"));
                 else if (!Deaf)
                     You_hear("a crushing sound.");
-                e_died(etmp, e_inview ? 3 : 2, CRUSHING);
+                e_died(etmp,
+                       XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG
+                                                  : XKILL_NOMSG),
+                       CRUSHING);
                 /* no corpse */
                 return;
             }
@@ -717,7 +723,7 @@ struct entity *etmp;
         if (!e_survives_at(etmp, etmp->ex, etmp->ey)) {
             killer.format = KILLED_BY_AN;
             Strcpy(killer.name, "closing drawbridge");
-            e_died(etmp, 0, CRUSHING); /* no message */
+            e_died(etmp, XKILL_NOMSG, CRUSHING);
             return;
         }
         debugpline1("%s in here", E_phrase(etmp, "survive"));
@@ -748,11 +754,11 @@ struct entity *etmp;
             }
         killer.format = NO_KILLER_PREFIX;
         Strcpy(killer.name, "fell from a drawbridge");
-        e_died(etmp, e_inview ? 3 : 2, /* CRUSHING is arbitrary */
-               (is_pool(etmp->ex, etmp->ey))
-                   ? DROWNING
-                   : (is_lava(etmp->ex, etmp->ey)) ? BURNING
-                                                   : CRUSHING); /*no corpse*/
+        e_died(etmp, /* CRUSHING is arbitrary */
+               XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG),
+               is_pool(etmp->ex, etmp->ey) ? DROWNING
+                 : is_lava(etmp->ex, etmp->ey) ? BURNING
+                   : CRUSHING); /*no corpse*/
         return;
     }
 }
@@ -954,7 +960,9 @@ int x, y;
                       E_phrase(etmp2, "are"));
             killer.format = KILLED_BY_AN;
             Strcpy(killer.name, "exploding drawbridge");
-            e_died(etmp2, e_inview ? 3 : 2, CRUSHING); /*no corpse*/
+            e_died(etmp2,
+                   XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG),
+                   CRUSHING); /*no corpse*/
         } /* nothing which is vulnerable can survive this */
     }
     set_entity(x, y, etmp1);
@@ -984,7 +992,9 @@ int x, y;
             }
             killer.format = KILLED_BY_AN;
             Strcpy(killer.name, "collapsing drawbridge");
-            e_died(etmp1, e_inview ? 3 : 2, CRUSHING); /*no corpse*/
+            e_died(etmp1,
+                   XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG),
+                   CRUSHING); /*no corpse*/
             if (levl[etmp1->ex][etmp1->ey].typ == MOAT)
                 do_entity(etmp1);
         }
index 99aea801b01034092118b087afed0c3b00677376..6ab8481cc83f79ed367323b7f47747e0106a8504 100644 (file)
@@ -2664,7 +2664,7 @@ register struct attack *mattk;
             }
             pline("%s turns to stone!", Monnam(mtmp));
             stoned = 1;
-            xkilled(mtmp, 0);
+            xkilled(mtmp, XKILL_NOMSG);
             if (mtmp->mhp > 0)
                 return 1;
             return 2;
@@ -2773,7 +2773,7 @@ register struct attack *mattk;
 assess_dmg:
     if ((mtmp->mhp -= tmp) <= 0) {
         pline("%s dies!", Monnam(mtmp));
-        xkilled(mtmp, 0);
+        xkilled(mtmp, XKILL_NOMSG);
         if (mtmp->mhp > 0)
             return 1;
         return 2;
index adae1756331011dc92e5cd53d710d32f6e73ff0b..0e7a5501cbbbd28f316aa190f0eecd7cb6d55126 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -2153,26 +2153,29 @@ void
 killed(mtmp)
 struct monst *mtmp;
 {
-    xkilled(mtmp, 1);
+    xkilled(mtmp, XKILL_GIVEMSG);
 }
 
 /* the player has killed the monster mtmp */
 void
-xkilled(mtmp, dflags)
+xkilled(mtmp, xkill_flags)
 struct monst *mtmp;
-int dflags; /* disposition flags:  1 => give message, 2 => suppress corpse */
+int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */
 {
     int tmp, mndx, x = mtmp->mx, y = mtmp->my;
     struct permonst *mdat;
     struct obj *otmp;
     struct trap *t;
-    boolean wasinside = u.uswallow && (u.ustuck == mtmp), burycorpse = FALSE,
-            givemsg = (dflags & 1) != 0, nocorpse = (dflags & 2) != 0;
+    boolean wasinside = u.uswallow && (u.ustuck == mtmp),
+            burycorpse = FALSE,
+            nomsg = (xkill_flags & XKILL_NOMSG) != 0,
+            nocorpse = (xkill_flags & XKILL_NOCORPSE) != 0,
+            noconduct = (xkill_flags & XKILL_NOCONDUCT) != 0;
 
-    /* KMH, conduct */
-    u.uconduct.killer++;
+    if (!noconduct) /* KMH, conduct */
+        u.uconduct.killer++;
 
-    if (givemsg)
+    if (!nomsg)
         You("%s %s!",
             nonliving(mtmp->data) ? "destroy" : "kill",
             !(wasinside || canspotmon(mtmp)) ? "it"
@@ -2260,7 +2263,7 @@ int dflags; /* disposition flags:  1 => give message, 2 => suppress corpse */
                 /* oc_big is also oc_bimanual and oc_bulky */
                 && (otmp->owt > 30 || objects[otyp].oc_big)) {
                 delobj(otmp);
-            } else if (!flooreffects(otmp, x, y, givemsg ? "fall" : "")) {
+            } else if (!flooreffects(otmp, x, y, nomsg ? "" : "fall")) {
                 place_object(otmp, x, y);
                 stackobj(otmp);
             }
@@ -2270,7 +2273,7 @@ int dflags; /* disposition flags:  1 => give message, 2 => suppress corpse */
             cadaver = make_corpse(mtmp, burycorpse ? CORPSTAT_BURIED
                                                    : CORPSTAT_NONE);
             if (burycorpse && cadaver && cansee(x, y) && !mtmp->minvis
-                && cadaver->where == OBJ_BURIED && givemsg) {
+                && cadaver->where == OBJ_BURIED && !nomsg) {
                 pline("%s corpse ends up buried.", s_suffix(Monnam(mtmp)));
             }
         }
index 54ef961fd410bb7095e9d66b6680f2e51c15e350..fbf9d08cf22aadf69e43da3ebe6965426ff7da73 100644 (file)
@@ -225,7 +225,7 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
             /* don't blame hero for unknown rolling boulder trap */
             if (!context.mon_moving
                 && (otmp->otyp != BOULDER || range >= 0 || otmp->otrapped))
-                xkilled(mtmp, 0);
+                xkilled(mtmp, XKILL_NOMSG);
             else
                 mondied(mtmp);
         }
index b0a843d7d61cef1589a376993945c9e053449596..f0b8bbb7081929c60136f6af5ca416e8555e6ea3 100644 (file)
@@ -2240,7 +2240,7 @@ boolean stoning;
         if (mon->mhp <= 0) {
             pline("%s dies!", Monnam(mon));
             if (by_you)
-                xkilled(mon, 0);
+                xkilled(mon, XKILL_NOMSG);
             else
                 mondead(mon);
             return;
index f21a1948352dbe02a17b617bc686cfc341ce1acb..b765b67223b9568907c3f2d526a0c5e4afd58d40 100644 (file)
@@ -360,16 +360,15 @@ int force;
                                     else {
                                         You("destroy %s!",
                                             mtmp->mtame
-                                                ? x_monnam(
-                                                      mtmp, ARTICLE_THE,
-                                                      "poor",
-                                                      (has_mname(mtmp))
-                                                          ? SUPPRESS_SADDLE
-                                                          : 0,
-                                                      FALSE)
-                                                : mon_nam(mtmp));
+                                              ? x_monnam(mtmp, ARTICLE_THE,
+                                                         "poor",
+                                                         has_mname(mtmp)
+                                                           ? SUPPRESS_SADDLE
+                                                           : 0,
+                                                         FALSE)
+                                              : mon_nam(mtmp));
                                     }
-                                    xkilled(mtmp, 0);
+                                    xkilled(mtmp, XKILL_NOMSG);
                                 }
                         }
                     } else if (x == u.ux && y == u.uy) {
index 6d29089906d6bf7600d8f51db89c5187459e7945..7982040ee431b061da84f79264d43ba39fd7a435 100644 (file)
@@ -531,8 +531,6 @@ STATIC_OVL void
 god_zaps_you(resp_god)
 aligntyp resp_god;
 {
-    long oldkillcount = u.uconduct.killer;
-
     if (u.uswallow) {
         pline(
           "Suddenly a bolt of lightning comes down at you from the heavens!");
@@ -544,8 +542,7 @@ aligntyp resp_god;
              * Other credit/blame applies (luck or alignment adjustments),
              * but not direct kill count (pacifist conduct).
              */
-            xkilled(u.ustuck, 0);
-            u.uconduct.killer = oldkillcount;
+            xkilled(u.ustuck, XKILL_NOMSG | XKILL_NOCONDUCT);
         } else
             pline("%s seems unaffected.", Monnam(u.ustuck));
     } else {
@@ -569,8 +566,7 @@ aligntyp resp_god;
               mon_nam(u.ustuck));
         if (!resists_disint(u.ustuck)) {
             pline("%s disintegrates into a pile of dust!", Monnam(u.ustuck));
-            xkilled(u.ustuck, 2); /* no corpse */
-            u.uconduct.killer = oldkillcount;
+            xkilled(u.ustuck, XKILL_NOMSG | XKILL_NOCORPSE | XKILL_NOCONDUCT);
         } else
             pline("%s seems unaffected.", Monnam(u.ustuck));
     } else {
index 372f90b42fafc6d2a7256c6d66eba029ed370e3c..87b30ef1d714e36913fdd1a073bc5507bccfadb8 100644 (file)
@@ -1744,9 +1744,9 @@ boolean confused, byu;
         }
         mtmp->mhp -= mdmg;
         if (mtmp->mhp <= 0) {
-            if (byu)
-                xkilled(mtmp, 1);
-            else {
+            if (byu) {
+                killed(mtmp);
+            else {
                 pline("%s is killed.", Monnam(mtmp));
                 mondied(mtmp);
             }
index cf2e7d43c9e77b8fb29403f8cf3d9f87c9286904..92d2dfd6dcb61226af5317d63e396af517ee3c8b 100644 (file)
@@ -2679,7 +2679,7 @@ boolean byplayer;
         pline("%s turns to stone.", Monnam(mon));
     if (byplayer) {
         stoned = TRUE;
-        xkilled(mon, 0);
+        xkilled(mon, XKILL_NOMSG);
     } else
         monstone(mon);
 }
index 4512006dc6a18f000dc04120a990f9e30ab2499e..a91c48c4973912ba1ad93d0e39bc1610087a0b73 100644 (file)
@@ -1152,7 +1152,7 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
     if (poiskilled) {
         pline_The("poison was deadly...");
         if (!already_killed)
-            xkilled(mon, 0);
+            xkilled(mon, XKILL_NOMSG);
         destroyed = TRUE; /* return FALSE; */
     } else if (destroyed) {
         if (!already_killed)
@@ -1471,7 +1471,7 @@ register struct attack *mattk;
         if (pd == &mons[PM_STRAW_GOLEM] || pd == &mons[PM_PAPER_GOLEM]) {
             if (!Blind)
                 pline("%s burns completely!", Monnam(mdef));
-            xkilled(mdef, 2);
+            xkilled(mdef, XKILL_NOMSG | XKILL_NOCORPSE);
             tmp = 0;
             break;
             /* Don't return yet; keep hp<1 and tmp=0 for pet msg */
@@ -1589,7 +1589,7 @@ register struct attack *mattk;
                 if (!Blind)
                     pline("Some writing vanishes from %s head!",
                           s_suffix(mon_nam(mdef)));
-                xkilled(mdef, 0);
+                xkilled(mdef, XKILL_NOMSG);
                 /* Don't return yet; keep hp<1 and tmp=0 for pet msg */
             } else {
                 mdef->mcan = 1;
@@ -1601,11 +1601,12 @@ register struct attack *mattk;
     case AD_DRLI:
         if (!negated && !rn2(3) && !resists_drli(mdef)) {
             int xtmp = d(2, 6);
+
             pline("%s suddenly seems weaker!", Monnam(mdef));
             mdef->mhpmax -= xtmp;
             if ((mdef->mhp -= xtmp) <= 0 || !mdef->m_lev) {
                 pline("%s dies!", Monnam(mdef));
-                xkilled(mdef, 0);
+                xkilled(mdef, XKILL_NOMSG);
             } else
                 mdef->m_lev--;
             tmp = 0;
@@ -1614,7 +1615,7 @@ register struct attack *mattk;
     case AD_RUST:
         if (pd == &mons[PM_IRON_GOLEM]) {
             pline("%s falls to pieces!", Monnam(mdef));
-            xkilled(mdef, 0);
+            xkilled(mdef, XKILL_NOMSG);
         }
         erode_armor(mdef, ERODE_RUST);
         tmp = 0;
@@ -1626,7 +1627,7 @@ register struct attack *mattk;
     case AD_DCAY:
         if (pd == &mons[PM_WOOD_GOLEM] || pd == &mons[PM_LEATHER_GOLEM]) {
             pline("%s falls to pieces!", Monnam(mdef));
-            xkilled(mdef, 0);
+            xkilled(mdef, XKILL_NOMSG);
         }
         erode_armor(mdef, ERODE_ROT);
         tmp = 0;
@@ -1770,11 +1771,11 @@ register struct attack *mattk;
         if (mdef->mtame && !cansee(mdef->mx, mdef->my)) {
             You_feel("embarrassed for a moment.");
             if (tmp)
-                xkilled(mdef, 0); /* !tmp but hp<1: already killed */
+                xkilled(mdef, XKILL_NOMSG); /* !tmp but hp<1: already killed */
         } else if (!flags.verbose) {
             You("destroy it!");
             if (tmp)
-                xkilled(mdef, 0);
+                xkilled(mdef, XKILL_NOMSG);
         } else if (tmp)
             killed(mdef);
         return 2;
@@ -1933,7 +1934,7 @@ register struct attack *mattk;
                     m_useup(mdef, otmp);
 
                 newuhs(FALSE);
-                xkilled(mdef, 2);
+                xkilled(mdef, XKILL_NOMSG | XKILL_NOCORPSE);
                 if (mdef->mhp > 0) { /* monster lifesaved */
                     You("hurriedly regurgitate the sizzling in your %s.",
                         body_part(STOMACH));
index b0a182873c51281365ad86892b31fec7b5e99c0d..8631483e45a01814663b33355ce34488e1a8be0a 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -242,7 +242,7 @@ struct obj *otmp;
                 }
                 /* context.bypasses = TRUE; ## for make_corpse() */
                 /* no corpse after system shock */
-                xkilled(mtmp, 3);
+                xkilled(mtmp, XKILL_GIVEMSG | XKILL_NOCORPSE);
             } else if (newcham(mtmp, (struct permonst *) 0,
                                polyspot, give_msg) != 0
                        /* if shapechange failed because there aren't
@@ -401,14 +401,15 @@ struct obj *otmp;
             dmg *= 2;
         if (otyp == SPE_DRAIN_LIFE)
             dmg = spell_damage_bonus(dmg);
-        if (resists_drli(mtmp))
+        if (resists_drli(mtmp)) {
             shieldeff(mtmp->mx, mtmp->my);
-        else if (!resist(mtmp, otmp->oclass, dmg, NOTELL) && mtmp->mhp > 0) {
+        else if (!resist(mtmp, otmp->oclass, dmg, NOTELL) && mtmp->mhp > 0) {
             mtmp->mhp -= dmg;
             mtmp->mhpmax -= dmg;
-            if (mtmp->mhp <= 0 || mtmp->mhpmax <= 0 || mtmp->m_lev < 1)
-                xkilled(mtmp, 1);
-            else {
+            /* die if already level 0, regardless of hit points */
+            if (mtmp->mhp <= 0 || mtmp->mhpmax <= 0 || mtmp->m_lev < 1) {
+                killed(mtmp);
+            } else {
                 mtmp->m_lev--;
                 if (canseemon(mtmp))
                     pline("%s suddenly seems weaker!", Monnam(mtmp));
@@ -3843,7 +3844,7 @@ const char *fltxt;
     if (type < 0)
         monkilled(mon, (char *) 0, -AD_RBRE);
     else
-        xkilled(mon, 2);
+        xkilled(mon, XKILL_NOMSG | XKILL_NOCORPSE);
 }
 
 /*