MCPcopy Create free account
hub / github.com/NetHack/NetHack / block_entry

Function block_entry

src/shk.c:5825–5858  ·  view source on GitHub ↗

used in domove to block diagonal shop-entry; u.ux, u.uy should always be a door */

Source from the content-addressed store, hash-verified

5823/* used in domove to block diagonal shop-entry;
5824 u.ux, u.uy should always be a door */
5825boolean
5826block_entry(coordxy x, coordxy y)
5827{
5828 coordxy sx, sy;
5829 int roomno;
5830 struct monst *shkp;
5831
5832 if (!(IS_DOOR(levl[u.ux][u.uy].typ)
5833 && levl[u.ux][u.uy].doormask == D_BROKEN))
5834 return FALSE;
5835
5836 roomno = *in_rooms(x, y, SHOPBASE);
5837 if (roomno < 0 || !IS_SHOP(roomno))
5838 return FALSE;
5839 shkp = shop_keeper((char) roomno);
5840 if (!shkp || !inhishop(shkp))
5841 return FALSE;
5842
5843 if (ESHK(shkp)->shd.x != u.ux || ESHK(shkp)->shd.y != u.uy)
5844 return FALSE;
5845
5846 sx = ESHK(shkp)->shk.x;
5847 sy = ESHK(shkp)->shk.y;
5848
5849 if (shkp->mx == sx && shkp->my == sy && !helpless(shkp)
5850 && (x == sx - 1 || x == sx + 1 || y == sy - 1 || y == sy + 1)
5851 && (Invis || carrying(PICK_AXE) || carrying(DWARVISH_MATTOCK)
5852 || u.usteed)) {
5853 pline("%s%s blocks your way!", Shknam(shkp),
5854 Invis ? " senses your motion and" : "");
5855 return TRUE;
5856 }
5857 return FALSE;
5858}
5859
5860/* "your " or "Foobar's " (note the trailing space) */
5861char *

Callers 1

test_moveFunction · 0.85

Calls 6

in_roomsFunction · 0.85
shop_keeperFunction · 0.85
inhishopFunction · 0.85
carryingFunction · 0.85
ShknamFunction · 0.85
plineFunction · 0.70

Tested by 1

test_moveFunction · 0.68