MCPcopy Index your code
hub / github.com/NetHack/NetHack / hits_bars

Function hits_bars

src/mthrowu.c:1498–1559  ·  view source on GitHub ↗

TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */

Source from the content-addressed store, hash-verified

1496
1497/* TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */
1498boolean
1499hits_bars(
1500 struct obj **obj_p, /* *obj_p will be set to NULL if object breaks */
1501 coordxy x, coordxy y,
1502 coordxy barsx, coordxy barsy,
1503 int always_hit, /* caller can force a hit for items which would
1504 * fit through */
1505 int whodidit) /* 1==hero, 0=other, -1==just check whether it
1506 * will pass through */
1507{
1508 struct obj *otmp = *obj_p;
1509 int obj_type = otmp->otyp;
1510 boolean hits = always_hit;
1511
1512 if (!hits)
1513 switch (otmp->oclass) {
1514 case WEAPON_CLASS: {
1515 int oskill = objects[obj_type].oc_skill;
1516
1517 hits = (oskill != -P_BOW && oskill != -P_CROSSBOW
1518 && oskill != -P_DART && oskill != -P_SHURIKEN
1519 && oskill != P_SPEAR
1520 && oskill != P_KNIFE); /* but not dagger */
1521 break;
1522 }
1523 case ARMOR_CLASS:
1524 hits = (objects[obj_type].oc_armcat != ARM_GLOVES);
1525 break;
1526 case TOOL_CLASS:
1527 hits = (obj_type != SKELETON_KEY && obj_type != LOCK_PICK
1528 && obj_type != CREDIT_CARD && obj_type != TALLOW_CANDLE
1529 && obj_type != WAX_CANDLE && obj_type != LENSES
1530 && obj_type != TIN_WHISTLE && obj_type != MAGIC_WHISTLE);
1531 break;
1532 case ROCK_CLASS: /* includes boulder */
1533 if (obj_type != STATUE || mons[otmp->corpsenm].msize > MZ_TINY)
1534 hits = TRUE;
1535 break;
1536 case FOOD_CLASS:
1537 if (obj_type == CORPSE && mons[otmp->corpsenm].msize > MZ_TINY)
1538 hits = TRUE;
1539 else
1540 hits = (obj_type == MEAT_STICK
1541 || obj_type == ENORMOUS_MEATBALL);
1542 break;
1543 case SPBOOK_CLASS:
1544 case WAND_CLASS:
1545 case BALL_CLASS:
1546 case CHAIN_CLASS:
1547 hits = TRUE;
1548 break;
1549 default:
1550 break;
1551 }
1552
1553 if (hits && whodidit != -1) {
1554 hit_bars(obj_p, x, y, barsx, barsy,
1555 (whodidit == 1) ? BRK_BY_HERO : 0);

Callers 3

launch_objFunction · 0.85
bhitFunction · 0.85
mthrowu.cFile · 0.85

Calls 1

hit_barsFunction · 0.85

Tested by

no test coverage detected