]> granicus.if.org Git - nethack/commitdiff
R809 - newcham message reorganization
authorcohrs <cohrs>
Tue, 23 Apr 2002 06:15:52 +0000 (06:15 +0000)
committercohrs <cohrs>
Tue, 23 Apr 2002 06:15:52 +0000 (06:15 +0000)
Add a param to newcham() to let it print "The oldmon turns into a newmon!"
rather than always printing this externally.  Should ensure a good ordering
of the messages.  Also put some special name handling in one place and
catch a couple cases where "saddled" was printed, resulting in funny messages.

include/extern.h
src/dogmove.c
src/makemon.c
src/mhitm.c
src/mon.c
src/muse.c
src/trap.c
src/uhitm.c
src/zap.c

index ba1fc3720178e4dafb587661a11ac3ddea2bc373..3ea9381bc3154a19bcd9b33f8a406a38f4d86215 100644 (file)
@@ -1107,7 +1107,7 @@ E void NDECL(rescham);
 E void NDECL(restartcham);
 E void FDECL(restore_cham, (struct monst *));
 E void FDECL(mon_animal_list, (BOOLEAN_P));
-E int FDECL(newcham, (struct monst *,struct permonst *,BOOLEAN_P));
+E int FDECL(newcham, (struct monst *,struct permonst *,BOOLEAN_P,BOOLEAN_P));
 E int FDECL(can_be_hatched, (int));
 E int FDECL(egg_type_from_parent, (int,BOOLEAN_P));
 E boolean FDECL(dead_species, (int,BOOLEAN_P));
index 23d57573d9fc0bbec7d624dd786ebd4495a5269a..536092a6e2574874d5f9eb8b4180879fd391728c 100644 (file)
@@ -191,23 +191,8 @@ boolean devour;
            delobj(obj);
 
        if (poly) {
-           char oldpet[BUFSZ];
-#ifdef STEED
-           long mw = mtmp->misc_worn_check;
-
-           mtmp->misc_worn_check &= ~W_SADDLE;
-#endif
-           Strcpy(oldpet, Monnam(mtmp));
-#ifdef STEED
-           mtmp->misc_worn_check = mw;
-#endif
-           if (newcham(mtmp, (struct permonst *)0, FALSE) &&
-                       cansee(mtmp->mx, mtmp->my)) {
-               uchar save_mnamelth = mtmp->mnamelth;
-               mtmp->mnamelth = 0;
-               pline("%s turns into %s!", oldpet, a_monnam(mtmp));
-               mtmp->mnamelth = save_mnamelth;
-           }
+           (void) newcham(mtmp, (struct permonst *)0, FALSE,
+                          cansee(mtmp->mx, mtmp->my));
        }
        /* limit "instant" growth to prevent potential abuse */
        if (grow && (int) mtmp->m_lev < (int)mtmp->data->mlevel + 15) {
index b6276399e029002cdee8a6e885678c1f93fb8b42..38696148d4f0a8bcbde88bf9fb50036784990b56 100644 (file)
@@ -955,7 +955,7 @@ register int        mmflags;
                        mtmp->cham = CHAM_ORDINARY;
                else {
                        mtmp->cham = mcham;
-                       (void) newcham(mtmp, rndmonst(), FALSE);
+                       (void) newcham(mtmp, rndmonst(), FALSE, FALSE);
                }
        } else if (mndx == PM_WIZARD_OF_YENDOR) {
                mtmp->iswiz = TRUE;
index efb3657cd7b73e24587e85d0d5b9ad99ef00ba53..7ba9575c9ee1944e976724d3eff5240e22f8a1f8 100644 (file)
@@ -1072,8 +1072,7 @@ label2:                   if (mdef->mhp > 0) return 0;
                                mdef->data != &mons[PM_FIRE_ELEMENTAL] &&
                                mdef->data != &mons[PM_SALAMANDER] &&
                                mdef->data != &mons[PM_GREEN_SLIME]) {
-                   if (vis) pline("%s turns into slime.", Monnam(mdef));
-                   (void) newcham(mdef, &mons[PM_GREEN_SLIME], FALSE);
+                   (void) newcham(mdef, &mons[PM_GREEN_SLIME], FALSE, vis);
                    mdef->mstrategy &= ~STRAT_WAITFORU;
                    tmp = 0;
                }
index 690186d0cc14f816936875f747efc6e98ba7e354..9cd9770805e9a161b04299984738584f01177a97 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -462,7 +462,7 @@ mcalcdistress()
 
        /* possibly polymorph shapechangers and lycanthropes */
        if (mtmp->cham && !rn2(6))
-           (void) newcham(mtmp, (struct permonst *)0, FALSE);
+           (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE);
        were_change(mtmp);
 
        /* gradually time out temporary problems */
@@ -642,7 +642,8 @@ meatmetal(mtmp)
                        delobj(otmp);
                        ptr = mtmp->data;
                        if (poly) {
-                           if (newcham(mtmp, (struct permonst *)0, FALSE))
+                           if (newcham(mtmp, (struct permonst *)0,
+                                       FALSE, FALSE))
                                ptr = mtmp->data;
                        } else if (grow) {
                            ptr = grow_up(mtmp, (struct monst *)0);
@@ -727,7 +728,8 @@ meatobj(mtmp)               /* for gelatinous cubes */
                delobj(otmp);           /* munch */
                ptr = mtmp->data;
                if (poly) {
-                   if (newcham(mtmp, (struct permonst *)0, FALSE)) ptr = mtmp->data;
+                   if (newcham(mtmp, (struct permonst *)0, FALSE, FALSE))
+                       ptr = mtmp->data;
                } else if (grow) {
                    ptr = grow_up(mtmp, (struct monst *)0);
                } else if (heal) {
@@ -1803,7 +1805,7 @@ mon_to_stone(mtmp)
        /* it's a golem, and not a stone golem */
        if(canseemon(mtmp))
            pline("%s solidifies...", Monnam(mtmp));
-       if (newcham(mtmp, &mons[PM_STONE_GOLEM], FALSE)) {
+       if (newcham(mtmp, &mons[PM_STONE_GOLEM], FALSE, FALSE)) {
            if(canseemon(mtmp))
                pline("Now it's %s.", an(mtmp->data->mname));
        } else {
@@ -2091,7 +2093,8 @@ rescham()
                mcham = (int) mtmp->cham;
                if (mcham) {
                        mtmp->cham = CHAM_ORDINARY;
-                       (void) newcham(mtmp, &mons[cham_to_pm[mcham]], FALSE);
+                       (void) newcham(mtmp, &mons[cham_to_pm[mcham]],
+                                      FALSE, FALSE);
                }
                if(is_were(mtmp->data) && mtmp->data->mlet != S_HUMAN)
                        new_were(mtmp);
@@ -2134,7 +2137,7 @@ struct monst *mon;
            mcham = (int) mon->cham;
            if (mcham) {
                mon->cham = CHAM_ORDINARY;
-               (void) newcham(mon, &mons[cham_to_pm[mcham]], FALSE);
+               (void) newcham(mon, &mons[cham_to_pm[mcham]], FALSE, FALSE);
            } else if (is_were(mon->data) && !is_human(mon->data)) {
                new_were(mon);
            }
@@ -2254,14 +2257,23 @@ struct monst *mon;
 
 /* make a chameleon look like a new monster; returns 1 if it actually changed */
 int
-newcham(mtmp, mdat, polyspot)
+newcham(mtmp, mdat, polyspot, msg)
 struct monst *mtmp;
 struct permonst *mdat;
 boolean polyspot;      /* change is the result of wand or spell of polymorph */
+boolean msg;           /* "The oldmon turns into a newmon!" */
 {
        int mhp, hpn, hpd;
        int mndx, tryct;
        struct permonst *olddata = mtmp->data;
+       char oldname[BUFSZ];
+
+       if (msg) {
+           /* like Monnam() but never mention saddle */
+           Strcpy(oldname, x_monnam(mtmp, ARTICLE_THE, (char *)0,
+                                    SUPPRESS_SADDLE, FALSE));
+           oldname[0] = highc(oldname[0]);
+       }
 
        /* mdat = 0 -> caller wants a random monster shape */
        tryct = 0;
@@ -2393,6 +2405,15 @@ boolean polyspot;        /* change is the result of wand or spell of polymorph */
 
        newsym(mtmp->mx,mtmp->my);
 
+       if (msg) {
+           uchar save_mnamelth = mtmp->mnamelth;
+           mtmp->mnamelth = 0;
+           pline("%s turns into %s!", oldname,
+                 mdat == &mons[PM_GREEN_SLIME] ? "slime" :
+                 x_monnam(mtmp, ARTICLE_A, (char*)0, SUPPRESS_SADDLE, FALSE));
+           mtmp->mnamelth = save_mnamelth;
+       }
+
        mon_break_armor(mtmp, polyspot);
        if (!(mtmp->misc_worn_check & W_ARMG))
            mselftouch(mtmp, "No longer petrify-resistant, ",
@@ -2543,7 +2564,7 @@ kill_genocided_monsters()
            mndx = monsndx(mtmp->data);
            if ((mvitals[mndx].mvflags & G_GENOD) || kill_cham[mtmp->cham]) {
                if (mtmp->cham && !kill_cham[mtmp->cham])
-                   (void) newcham(mtmp, (struct permonst *)0, FALSE);
+                   (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE);
                else
                    mondead(mtmp);
            }
index a9b082d022be556155bfe697f97e786e9d51b327..36189a40741e566226a62d9ca99c6d7f47821835 100644 (file)
@@ -1783,13 +1783,13 @@ skipmsg:
        case MUSE_WAN_POLYMORPH:
                mzapmsg(mtmp, otmp, TRUE);
                otmp->spe--;
-               (void) newcham(mtmp, muse_newcham_mon(mtmp), TRUE);
+               (void) newcham(mtmp, muse_newcham_mon(mtmp), TRUE, FALSE);
                if (oseen) makeknown(WAN_POLYMORPH);
                return 2;
        case MUSE_POT_POLYMORPH:
                mquaffmsg(mtmp, otmp);
                if (vismon) pline("%s suddenly mutates!", Monnam(mtmp));
-               (void) newcham(mtmp, muse_newcham_mon(mtmp), FALSE);
+               (void) newcham(mtmp, muse_newcham_mon(mtmp), FALSE, FALSE);
                if (oseen) makeknown(POT_POLYMORPH);
                m_useup(mtmp, otmp);
                return 2;
@@ -1807,7 +1807,7 @@ skipmsg:
                if (mtmp->wormno) worm_move(mtmp);
                newsym(trapx, trapy);
 
-               (void) newcham(mtmp, (struct permonst *)0, FALSE);
+               (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE);
                return 2;
        case MUSE_BULLWHIP:
                /* attempt to disarm hero */
index 53df926fc4acf598c7341d5e31daf549c1240840..dbaaee74618d1ac9a5b2f0fcc78b66c53a1e7133 100644 (file)
@@ -1090,7 +1090,8 @@ struct obj *otmp;
                case POLY_TRAP: 
                    if (!resists_magm(mtmp)) {
                        if (!resist(mtmp, WAND_CLASS, 0, NOTELL)) {
-                       (void) newcham(mtmp, (struct permonst *)0, FALSE);
+                       (void) newcham(mtmp, (struct permonst *)0,
+                                      FALSE, FALSE);
                        if (!can_saddle(mtmp) || !can_ride(mtmp)) {
                                dismount_steed(DISMOUNT_POLY);
                        } else {
@@ -1888,7 +1889,8 @@ glovecheck:                   target = which_armor(mtmp, W_ARMG);
                    if (resists_magm(mtmp)) {
                        shieldeff(mtmp->mx, mtmp->my);
                    } else if (!resist(mtmp, WAND_CLASS, 0, NOTELL)) {
-                       (void) newcham(mtmp, (struct permonst *)0, FALSE);
+                       (void) newcham(mtmp, (struct permonst *)0,
+                                      FALSE, FALSE);
                        if (in_sight) seetrap(trap);
                    }
                    break;
index aa7d6c5474d993c06aa7d3ed3daf844bd3fd9fe6..6799ecb5da915268cc4fa203cf659619f9a0f65e 100644 (file)
@@ -1453,7 +1453,7 @@ register struct attack *mattk;
                                mdef->data != &mons[PM_SALAMANDER] &&
                                mdef->data != &mons[PM_GREEN_SLIME]) {
                    You("turn %s into slime.", mon_nam(mdef));
-                   (void) newcham(mdef, &mons[PM_GREEN_SLIME], FALSE);
+                   (void) newcham(mdef, &mons[PM_GREEN_SLIME], FALSE, FALSE);
                    tmp = 0;
                }
                break;
index cc3bf4219593045248814dcfd5b74174174ef0fe..421b7b6e4024923404a75f425ed0046cc55576f2 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -191,7 +191,7 @@ struct obj *otmp;
                        /* no corpse after system shock */
                        xkilled(mtmp, 3);
                    } else if (newcham(mtmp, (struct permonst *)0,
-                                      (otyp != POT_POLYMORPH))) {
+                                      (otyp != POT_POLYMORPH), FALSE)) {
                        if (!Hallucination && canspotmon(mtmp))
                            makeknown(otyp);
                    }
@@ -293,7 +293,7 @@ struct obj *otmp;
                if (monsndx(mtmp->data) == PM_STONE_GOLEM) {
                    char *name = Monnam(mtmp);
                    /* turn into flesh golem */
-                   if (newcham(mtmp, &mons[PM_FLESH_GOLEM], FALSE)) {
+                   if (newcham(mtmp, &mons[PM_FLESH_GOLEM], FALSE, FALSE)) {
                        if (canseemon(mtmp))
                            pline("%s turns to flesh!", name);
                    } else {