]> granicus.if.org Git - nethack/commitdiff
U716 - trapped monster switching weapons
authorcohrs <cohrs>
Wed, 5 Nov 2003 15:47:50 +0000 (15:47 +0000)
committercohrs <cohrs>
Wed, 5 Nov 2003 15:47:50 +0000 (15:47 +0000)
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.

src/monmove.c

index be4bdb8ae6efb5a8bf5fcb44a9874db0f7ddddfa..37dddf3362e0c374ba44cb107f0f03a8012e4cd2 100644 (file)
@@ -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);
            }