From 64d41e10de20ed438d12a41212e2df2106f449ac Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 9 Dec 2024 21:14:14 -0500 Subject: [PATCH] update #migratemons for debugging purposes For the wizard-mode command #migratemons at the "How many random monsters to migrate to next level? [0]" prompt, allow a negative number to cause it to use existing monsters already on the level for the forced migration, up until the absolute value of the number, instead of random new monsters as it does for a positive number. For example, specify -20 to force-migrate 20 existing monsters already on the map. --- src/wizcmds.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/wizcmds.c b/src/wizcmds.c index c7cdd707e..c752d89da 100644 --- a/src/wizcmds.c +++ b/src/wizcmds.c @@ -1807,6 +1807,7 @@ wiz_migrate_mons(void) char inbuf[BUFSZ]; struct permonst *ptr; struct monst *mtmp; + boolean use_existing_map_mon = FALSE; #endif d_level tolevel; @@ -1830,17 +1831,32 @@ wiz_migrate_mons(void) return ECMD_OK; mcount = atoi(inbuf); + if (mcount < 0) { + use_existing_map_mon = TRUE; + mcount *= -1; + } if (mcount < 1) mcount = 0; else if (mcount > ((COLNO - 1) * ROWNO)) mcount = (COLNO - 1) * ROWNO; while (mcount > 0) { - ptr = rndmonst(); - mtmp = makemon(ptr, 0, 0, MM_NOMSG); - if (mtmp) - migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM, - (coord *) 0); + if (!use_existing_map_mon) { + ptr = rndmonst(); + mtmp = makemon(ptr, 0, 0, MM_NOMSG); + if (mtmp) + migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM, + (coord *) 0); + } else { + struct monst *nextmon; + + for (mtmp = fmon; mtmp; mtmp = nextmon) { + nextmon = mtmp->nmon; + migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM, + (coord *) 0); + break; + } + } mcount--; } #endif /* DEBUG_MIGRATING_MONS */