From: PatR Date: Tue, 10 May 2016 22:59:22 +0000 (-0700) Subject: more angry god vs pacifist conduct X-Git-Tag: NetHack-3.6.1_RC01~783 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=74ee31e5042564095ae318b669dd5498af4bf36d;p=nethack more angry god vs pacifist conduct 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. --- diff --git a/include/hack.h b/include/hack.h index 9054e0cf1..fb25a1672 100644 --- a/include/hack.h +++ b/include/hack.h @@ -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 diff --git a/src/apply.c b/src/apply.c index ddd253aee..24db211d3 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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; diff --git a/src/dbridge.c b/src/dbridge.c index 428161de5..be087fd4b 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -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); } diff --git a/src/mhitu.c b/src/mhitu.c index 99aea801b..6ab8481cc 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -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; diff --git a/src/mon.c b/src/mon.c index adae17563..0e7a5501c 100644 --- 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))); } } diff --git a/src/mthrowu.c b/src/mthrowu.c index 54ef961fd..fbf9d08cf 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -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); } diff --git a/src/muse.c b/src/muse.c index b0a843d7d..f0b8bbb70 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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; diff --git a/src/music.c b/src/music.c index f21a19483..b765b6722 100644 --- a/src/music.c +++ b/src/music.c @@ -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) { diff --git a/src/pray.c b/src/pray.c index 6d2908990..7982040ee 100644 --- a/src/pray.c +++ b/src/pray.c @@ -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 { diff --git a/src/read.c b/src/read.c index 372f90b42..87b30ef1d 100644 --- a/src/read.c +++ b/src/read.c @@ -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); } diff --git a/src/trap.c b/src/trap.c index cf2e7d43c..92d2dfd6d 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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); } diff --git a/src/uhitm.c b/src/uhitm.c index 4512006dc..a91c48c49 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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)); diff --git a/src/zap.c b/src/zap.c index b0a182873..8631483e4 100644 --- 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); } /*