From 68d28bd7484de3bda3861ccae48b29f8119edf2e Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 23 Jun 2019 17:27:15 -0700 Subject: [PATCH] level overcrowding tweaks A couple changes dealing with overcrowded levels. So many monsters are moving from the Plane of Water to the Astral Plane that the latter can start out completely full. Give monsters who trigger the endgame portals a 6/7 chance to not go through ('home' elementals or any monster carrying the Amulet already wouldn't go through). They should learn about magic portal trap in the process and not voluntarily step on that afterward. When the Wizard or other covetous monster tries to teleport next to the hero and fails, he was being sent to limbo. There's no need for that; he's already on the map and can just stay where he is. That doesn't actually help with the endgame population issue, it just fixes a couple of uses of mnearto(). I have significant changes for mnearto() and elemental_clog() that also help with this but will test those more before committing. --- src/teleport.c | 7 ++++--- src/wizard.c | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/teleport.c b/src/teleport.c index 61ca40fa7..100a74d3b 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 teleport.c $NHDT-Date: 1559733391 2019/06/05 11:16:31 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.88 $ */ +/* NetHack 3.6 teleport.c $NHDT-Date: 1561336020 2019/06/24 00:27:00 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.89 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1353,8 +1353,9 @@ int in_sight; get_level(&tolevel, depth(&u.uz) + 1); } } else if (tt == MAGIC_PORTAL) { - if (In_endgame(&u.uz) - && (mon_has_amulet(mtmp) || is_home_elemental(mtmp->data))) { + if (In_endgame(&u.uz) && (mon_has_amulet(mtmp) + || is_home_elemental(mtmp->data) + || rn2(7))) { if (in_sight && mtmp->data->mlet != S_ELEMENTAL) { pline("%s seems to shimmer for a moment.", Monnam(mtmp)); seetrap(trap); diff --git a/src/wizard.c b/src/wizard.c index df64a4d2d..b1dae1e59 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 wizard.c $NHDT-Date: 1539804905 2018/10/17 19:35:05 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.53 $ */ +/* NetHack 3.6 wizard.c $NHDT-Date: 1561336025 2019/06/24 00:27:05 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.56 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2016. */ /* NetHack may be freely redistributed. See license for details. */ @@ -356,7 +356,6 @@ xchar *sy; *sx = x; *sy = y; } - } int @@ -364,28 +363,33 @@ tactics(mtmp) register struct monst *mtmp; { unsigned long strat = strategy(mtmp); - xchar sx = 0, sy = 0; + xchar sx = 0, sy = 0, mx, my; mtmp->mstrategy = (mtmp->mstrategy & (STRAT_WAITMASK | STRAT_APPEARMSG)) | strat; switch (strat) { case STRAT_HEAL: /* hide and recover */ + mx = mtmp->mx, my = mtmp->my; /* if wounded, hole up on or near the stairs (to block them) */ choose_stairs(&sx, &sy); mtmp->mavenge = 1; /* covetous monsters attack while fleeing */ - if (In_W_tower(mtmp->mx, mtmp->my, &u.uz) + if (In_W_tower(mx, my, &u.uz) || (mtmp->iswiz && !sx && !mon_has_amulet(mtmp))) { if (!rn2(3 + mtmp->mhp / 10)) (void) rloc(mtmp, TRUE); - } else if (sx && (mtmp->mx != sx || mtmp->my != sy)) { + } else if (sx && (mx != sx || my != sy)) { if (!mnearto(mtmp, sx, sy, TRUE)) { - m_into_limbo(mtmp); + /* couldn't move to the target spot for some reason, + so stay where we are (don't actually need rloc_to() + because mtmp is still on the map at ... */ + rloc_to(mtmp, mx, my); return 0; } + mx = mtmp->mx, my = mtmp->my; /* update cached location */ } /* if you're not around, cast healing spells */ - if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM)) + if (distu(mx, my) > (BOLT_LIM * BOLT_LIM)) if (mtmp->mhp <= mtmp->mhpmax - 8) { mtmp->mhp += rnd(8); return 1; @@ -435,12 +439,13 @@ register struct monst *mtmp; return 0; } } else { /* a monster has it - 'port beside it. */ + mx = mtmp->mx, my = mtmp->my; if (!mnearto(mtmp, tx, ty, FALSE)) - m_into_limbo(mtmp); + rloc_to(mtmp, mx, my); /* no room? stay put */ return 0; } - } - } + } /* default case */ + } /* switch */ /*NOTREACHED*/ return 0; }