]> granicus.if.org Git - nethack/commitdiff
cancelled zombification
authorPatR <rankin@nethack.org>
Wed, 31 Mar 2021 00:33:31 +0000 (17:33 -0700)
committerPatR <rankin@nethack.org>
Wed, 31 Mar 2021 00:33:31 +0000 (17:33 -0700)
Don't let cancelled zombies or cancelled liches create new zombies.

include/extern.h
src/decl.c
src/end.c
src/mhitm.c
src/mon.c

index 8b12864aa0818f6d21672c28609fa2de1487b032..25cb5dc06e61a9377d5262c84d7ffece5e381f5e 100644 (file)
@@ -1375,7 +1375,7 @@ extern int cmap_to_type(int);
 /* ### mon.c ### */
 
 extern void mon_sanity_check(void);
-extern boolean zombie_maker(struct permonst *);
+extern boolean zombie_maker(struct monst *);
 extern int zombie_form(struct permonst *);
 extern int m_poisongas_ok(struct monst *);
 extern int undead_to_corpse(int);
index f40f9088898be80e13cfe232ab6a73e5874024d5..da8402cd9e172908b47f3e5bbeffccb9db0c2702 100644 (file)
@@ -476,7 +476,7 @@ const struct instance_globals g_init = {
 
     /* mkmaze.c */
     { {COLNO, ROWNO, 0, 0}, {COLNO, ROWNO, 0, 0} }, /* bughack */
-    UNDEFINED_VALUE, /* was_waterlevel */
+    FALSE, /* was_waterlevel */
     UNDEFINED_PTR, /* bbubbles */
     UNDEFINED_PTR, /* ebubbles */
     UNDEFINED_PTR, /* wportal */
@@ -487,9 +487,9 @@ const struct instance_globals g_init = {
     0, /* ransacked */
 
     /* mon.c */
-    UNDEFINED_VALUE, /* vamp_rise_msg */
-    UNDEFINED_VALUE, /* disintegested */
-    UNDEFINED_VALUE, /* zombify */
+    FALSE, /* vamp_rise_msg */
+    FALSE, /* disintegested */
+    FALSE, /* zombify */
     NULL, /* animal_list */
     UNDEFINED_VALUE, /* animal_list_count */
 
@@ -502,7 +502,7 @@ const struct instance_globals g_init = {
     FALSE, /* m_using */
     UNDEFINED_VALUE, /* trapx */
     UNDEFINED_VALUE, /* trapy */
-    UNDEFINED_VALUE, /* zap_oseen */
+    FALSE, /* zap_oseen */
     UNDEFINED_VALUES, /* m */
 
     /* nhlan.c */
index 288e95e504d952530a8091cd8707b5768af94f98..98e1a9c51c3d67bbdfb0173dc07d55b3e75270fd 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -507,7 +507,7 @@ done_in_by(struct monst *mtmp, int how)
         u.ugrave_arise = PM_WRAITH;
     else if (mptr->mlet == S_MUMMY && g.urace.mummynum != NON_PM)
         u.ugrave_arise = g.urace.mummynum;
-    else if (zombie_maker(mptr) && zombie_form(g.youmonst.data) != NON_PM)
+    else if (zombie_maker(mtmp) && zombie_form(g.youmonst.data) != NON_PM)
         u.ugrave_arise = zombie_form(g.youmonst.data);
     else if (mptr->mlet == S_VAMPIRE && Race_if(PM_HUMAN))
         u.ugrave_arise = PM_VAMPIRE;
index 8f9e9a28b9a3cabb0bbc5f531d0cf958edde20ff..2c3f2388ef7de05708e3bb5e66c6eff3ca2caf28 100644 (file)
@@ -906,11 +906,11 @@ mdamagem(struct monst *magr, struct monst *mdef,
             place_monster(mdef, mdef->mx, mdef->my);
             mdef->mhp = 0;
         }
-        g.zombify = !mwep && zombie_maker(magr->data)
-            && ((mattk->aatyp == AT_TUCH
-                 || mattk->aatyp == AT_CLAW
-                 || mattk->aatyp == AT_BITE)
-                && zombie_form(mdef->data) != NON_PM);
+        g.zombify = (!mwep && zombie_maker(magr)
+                     && (mattk->aatyp == AT_TUCH
+                         || mattk->aatyp == AT_CLAW
+                         || mattk->aatyp == AT_BITE)
+                     && zombie_form(mdef->data) != NON_PM);
         monkilled(mdef, "", (int) mattk->adtyp);
         g.zombify = FALSE; /* reset */
         if (!DEADMONSTER(mdef))
index 68b650ae9f1ef426a9ccb5bd4502da11679cedb5..7e740e696d4cc18b8becf114b8291d4ce53dcb82 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -276,12 +276,16 @@ m_poisongas_ok(struct monst* mtmp)
     return M_POISONGAS_BAD;
 }
 
-/* Return TRUE if this monster is capable of converting other monsters into
- * zombies. */
+/* return True if mon is capable of converting other monsters into zombies */
 boolean
-zombie_maker(struct permonst* pm)
+zombie_maker(struct monst *mon)
 {
-    switch(pm->mlet) {
+    struct permonst *pm = mon->data;
+
+    if (mon->mcan)
+        return FALSE;
+
+    switch (pm->mlet) {
     case S_ZOMBIE:
         /* Z-class monsters that aren't actually zombies go here */
         if (pm == &mons[PM_GHOUL] || pm == &mons[PM_SKELETON])
@@ -294,15 +298,15 @@ zombie_maker(struct permonst* pm)
     return FALSE;
 }
 
-/* return the monster index of the zombie monster which this monster could be
- * turned into, or NON_PM if it doesn't have a direct counterpart. Sort of the
- * zombie-specific inverse of undead_to_corpse.
- * If a zombie gets passed to this function, it should return NON_PM, not the
- * same monster again. */
+/* Return monster index of zombie monster which this monster could
+   be turned into, or NON_PM if it doesn't have a direct counterpart.
+   Sort of the zombie-specific inverse of undead_to_corpse. */
 int
-zombie_form(struct permonstpm)
+zombie_form(struct permonst *pm)
 {
-    switch(pm->mlet) {
+    switch (pm->mlet) {
+    case S_ZOMBIE: /* when already a zombie/ghoul/skeleton, will stay as is */
+        return NON_PM;
     case S_KOBOLD:
         return PM_KOBOLD_ZOMBIE;
     case S_ORC:
@@ -1892,18 +1896,15 @@ mfndpos(
     return cnt;
 }
 
-/* Part of mm_aggression that represents two-way aggression. To avoid having to
- * code each case twice, this function contains those cases that ought to
* happen twice, and mm_aggression will call it twice. */
+/* Part of mm_aggression that represents two-way aggression.  To avoid
+   having to code each case twice, this function contains those cases that
  ought to happen twice, and mm_aggression will call it twice. */
 static long
-mm_2way_aggression(struct monst* magr, struct monst* mdef)
+mm_2way_aggression(struct monst *magr, struct monst *mdef)
 {
-    struct permonst *ma = magr->data;
-    struct permonst *md = mdef->data;
-
     /* zombies vs things that can be zombified */
-    if (zombie_maker(ma) && zombie_form(md) != NON_PM)
-        return ALLOW_M|ALLOW_TM;
+    if (zombie_maker(magr) && zombie_form(mdef->data) != NON_PM)
+        return (ALLOW_M | ALLOW_TM);
 
     return 0;
 }
@@ -2880,7 +2881,7 @@ xkilled(
         /* corpse--none if hero was inside the monster */
         if (!wasinside && corpse_chance(mtmp, (struct monst *) 0, FALSE)) {
             g.zombify = (!g.thrownobj && !g.stoned && !uwep
-                         && zombie_maker(g.youmonst.data)
+                         && zombie_maker(&g.youmonst)
                          && zombie_form(mtmp->data) != NON_PM);
             cadaver = make_corpse(mtmp, burycorpse ? CORPSTAT_BURIED
                                                    : CORPSTAT_NONE);