From: cohrs Date: Wed, 3 Jul 2002 06:35:35 +0000 (+0000) Subject: cursed daggers thrown by monsters can go thru closed doors X-Git-Tag: MOVE2GIT~2685 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d51c1853a493edb23d8bbce66fc0e5a4080aeb2;p=nethack cursed daggers thrown by monsters can go thru closed doors based on a bugfix forwarded by , check for closed doors and drop the missle before it. I re-arranged the pre checks a bit so m_throw no longer needs to trust the caller to ensure everything is OK beforehand. --- diff --git a/doc/fixes34.1 b/doc/fixes34.1 index 77675a15e..147e4ceb3 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -136,6 +136,7 @@ monsters that are frozen or sleeping cannot be grateful for untrapping grammar of blessed-detection eating warning messages when eating 1 of N objects message for charging for items lost in a cursed magic bag wasn't always shown dropping gold on an altar printed no message and didn't change gnostic conduct +don't allow cursed daggers thrown by monsters to go thru closed doors Platform- and/or Interface-Specific Fixes diff --git a/src/mthrowu.c b/src/mthrowu.c index b4e2aec75..896a6d899 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -302,21 +302,21 @@ m_throw(mon, x, y, dx, dy, range, obj) } dx = rn2(3)-1; dy = rn2(3)-1; - /* pre-check validity of new direction */ - if((!dx && !dy) - || !isok(bhitpos.x+dx,bhitpos.y+dy) - /* missile hits the wall */ - || IS_ROCK(levl[bhitpos.x+dx][bhitpos.y+dy].typ)) { + /* check validity of new direction */ + if (!dx && !dy) { (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y); return; } } - /* also need to pre-check for bars regardless of direction, - but we know that isok() has already been verified; + /* pre-check for doors, walls and boundaries. + Also need to pre-check for bars regardless of direction; the random chance for small objects hitting bars is skipped when reaching them at point blank range */ - if ((levl[bhitpos.x + dx][bhitpos.y + dy].typ == IRONBARS && + if (!isok(bhitpos.x+dx,bhitpos.y+dy) + || IS_ROCK(levl[bhitpos.x+dx][bhitpos.y+dy].typ) + || closed_door(bhitpos.x+dx, bhitpos.y+dy) + || (levl[bhitpos.x + dx][bhitpos.y + dy].typ == IRONBARS && hits_bars(&singleobj, bhitpos.x, bhitpos.y, 0, 0))) { (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y); return; @@ -447,6 +447,8 @@ m_throw(mon, x, y, dx, dy, range, obj) || !isok(bhitpos.x+dx,bhitpos.y+dy) /* missile hits the wall */ || IS_ROCK(levl[bhitpos.x+dx][bhitpos.y+dy].typ) + /* missile hit closed door */ + || closed_door(bhitpos.x+dx, bhitpos.y+dy) /* missile might hit iron bars */ || (levl[bhitpos.x+dx][bhitpos.y+dy].typ == IRONBARS && hits_bars(&singleobj, bhitpos.x, bhitpos.y, !rn2(2), 0))