]> granicus.if.org Git - nethack/commitdiff
wizard ^G tweaks
authornethack.rankin <nethack.rankin>
Thu, 28 Sep 2006 03:56:02 +0000 (03:56 +0000)
committernethack.rankin <nethack.rankin>
Thu, 28 Sep 2006 03:56:02 +0000 (03:56 +0000)
     Wizard mode's ^G lets you specify "tame <foo>", "peaceful <foo>", or
"hostile <foo>" to override the created monster's default disposition.
Since it also lets you override the restriction against creating unique
monsters and various other special ones like shopkeepers (a post-3.4.3
change), it became possible to produce tame versions of monsters that
ordinarily are impossible to tame.  That's pretty iffy even when it only
applies to debugging, so switch from internal tameness conversion to use
of tamedog() to get the non-tameable cases handled.  (Minor side-effect:
full moon might prevent a request for "tame dog" from starting out tame.)

     Also, for <N>^G, give up before the specified count is reached if
creation fails when creating multiple copies of a specific type of monster,
on the assumption that the level has become filled up.  (When the type is
random, keep trying in case you subsequently get something different which
could survive on water or inside solid rock.)

src/read.c

index 8d848572cb46459da8009337a1abeecbe7f4f192..ae95f9938be34984e9ad0d965ee2ea3fe4530318 100644 (file)
@@ -2066,30 +2066,27 @@ create_particular()
                whichpm = &mons[which];
            }
            for (i = 0; i <= multi; i++) {
-               if (randmonst)
-                   whichpm = rndmonst();
                if (monclass != MAXMCLASSES)
                    whichpm = mkclass(monclass, 0);
-               if (maketame) {
-                   mtmp = makemon(whichpm, u.ux, u.uy, MM_EDOG);
-                   if (mtmp) {
-                       initedog(mtmp);
-                       set_malign(mtmp);
-                       newsym(mtmp->mx, mtmp->my);
-                   }
-               } else {
-                   mtmp = makemon(whichpm, u.ux, u.uy, NO_MM_FLAGS);
-                   if ((makepeaceful || makehostile) && mtmp) {
-                       mtmp->mtame = 0;        /* sanity precaution */
-                       mtmp->mpeaceful = makepeaceful ? 1 : 0;
-                       set_malign(mtmp);
-                   }
+               else if (randmonst)
+                   whichpm = rndmonst();
+               mtmp = makemon(whichpm, u.ux, u.uy, NO_MM_FLAGS);
+               if (!mtmp) {
+                   /* quit trying if creation failed and is going to repeat */
+                   if (monclass == MAXMCLASSES && !randmonst) break;
+                   /* otherwise try again */
+                   continue;
                }
-               if (mtmp) {
-                   madeany = TRUE;
-                   if (mtmp->cham >= LOW_PM && firstchoice != NON_PM)
-                       (void)newcham(mtmp, &mons[firstchoice], FALSE, FALSE);
+               if (maketame) {
+                   (void) tamedog(mtmp, (struct obj *) 0);
+               } else if (makepeaceful || makehostile) {
+                   mtmp->mtame = 0;    /* sanity precaution */
+                   mtmp->mpeaceful = makepeaceful ? 1 : 0;
+                   set_malign(mtmp);
                }
+               madeany = TRUE;
+               if (mtmp->cham >= LOW_PM && firstchoice != NON_PM)
+                   (void)newcham(mtmp, &mons[firstchoice], FALSE, FALSE);
            }
        }
        return madeany;