From: cohrs Date: Wed, 5 Nov 2003 15:47:50 +0000 (+0000) Subject: U716 - trapped monster switching weapons X-Git-Tag: MOVE2GIT~1609 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf07cbf5561ed98bdaaeeee17ffc17503e49d0da;p=nethack U716 - trapped monster switching weapons A trapped monster with one step between you and the monster (@.@) would repeatedly switch between a ranged and hand-to-hand weapon if carrying both. Since the monster switches each turn, it will not make ranged attacks. Modified the test in dochug to prefer a ranged weapon in this case. --- diff --git a/src/monmove.c b/src/monmove.c index be4bdb8ae..37dddf336 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -441,11 +441,15 @@ toofar: /* The scared check is necessary. Otherwise a monster that is * one square near the player but fleeing into a wall would keep - * switching between pick-axe and weapon. + * switching between pick-axe and weapon. If monster is stuck + * in a trap, prefer ranged weapon (wielding is done in thrwmu). + * This may cost the monster an attack, but keeps the monster + * from switching back and forth if carrying both. */ mw_tmp = MON_WEP(mtmp); if (!(scared && mw_tmp && is_pick(mw_tmp)) && - mtmp->weapon_check == NEED_WEAPON) { + mtmp->weapon_check == NEED_WEAPON && + !(mtmp->mtrapped && !nearby && select_rwep(mtmp))) { mtmp->weapon_check = NEED_HTH_WEAPON; if (mon_wield_item(mtmp) != 0) return(0); }