| 1476 | } |
| 1477 | |
| 1478 | staticfn int |
| 1479 | trapeffect_bear_trap( |
| 1480 | struct monst *mtmp, |
| 1481 | struct trap *trap, |
| 1482 | unsigned trflags) |
| 1483 | { |
| 1484 | boolean is_you = mtmp == &gy.youmonst, |
| 1485 | forcetrap = ((trflags & FORCETRAP) != 0 |
| 1486 | || (trflags & FAILEDUNTRAP) != 0 |
| 1487 | || (is_you && (trflags & VIASITTING) != 0)); |
| 1488 | |
| 1489 | if (is_you) { |
| 1490 | int dmg = d(2, 4); |
| 1491 | |
| 1492 | if ((Levitation || Flying) && !forcetrap) |
| 1493 | return Trap_Effect_Finished; |
| 1494 | feeltrap(trap); |
| 1495 | if (amorphous(gy.youmonst.data) || is_whirly(gy.youmonst.data) |
| 1496 | || unsolid(gy.youmonst.data)) { |
| 1497 | pline("%s bear trap closes harmlessly through you.", |
| 1498 | A_Your[trap->madeby_u]); |
| 1499 | return Trap_Effect_Finished; |
| 1500 | } |
| 1501 | if (!u.usteed && gy.youmonst.data->msize <= MZ_SMALL) { |
| 1502 | pline("%s bear trap closes harmlessly over you.", |
| 1503 | A_Your[trap->madeby_u]); |
| 1504 | return Trap_Effect_Finished; |
| 1505 | } |
| 1506 | set_utrap((unsigned) rn1(4, 4), TT_BEARTRAP); |
| 1507 | if (u.usteed) { |
| 1508 | pline("%s bear trap closes on %s %s!", A_Your[trap->madeby_u], |
| 1509 | s_suffix(mon_nam(u.usteed)), mbodypart(u.usteed, FOOT)); |
| 1510 | if (thitm(0, u.usteed, (struct obj *) 0, dmg, FALSE)) |
| 1511 | reset_utrap(TRUE); /* steed died, hero not trapped */ |
| 1512 | } else { |
| 1513 | pline("%s bear trap closes on your %s!", A_Your[trap->madeby_u], |
| 1514 | body_part(FOOT)); |
| 1515 | if (u.umonnum == PM_OWLBEAR || u.umonnum == PM_BUGBEAR) |
| 1516 | You("howl in anger!"); |
| 1517 | if (wearing_iron_shoes(mtmp)) |
| 1518 | pline("%s protects your leg.", Yname2(uarmf)); |
| 1519 | else { |
| 1520 | set_wounded_legs(rn2(2) ? RIGHT_SIDE : LEFT_SIDE, rn1(10, 10)); |
| 1521 | losehp(Maybe_Half_Phys(dmg), "bear trap", KILLED_BY_AN); |
| 1522 | } |
| 1523 | } |
| 1524 | exercise(A_DEX, FALSE); |
| 1525 | } else { |
| 1526 | struct permonst *mptr = mtmp->data; |
| 1527 | boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed); |
| 1528 | boolean trapkilled = FALSE; |
| 1529 | |
| 1530 | if (mptr->msize > MZ_SMALL && !amorphous(mptr) && !m_in_air(mtmp) |
| 1531 | && !is_whirly(mptr) && !unsolid(mptr)) { |
| 1532 | mtmp->mtrapped = 1; |
| 1533 | if (in_sight) { |
| 1534 | pline_mon(mtmp, |
| 1535 | "%s is caught in %s bear trap!", Monnam(mtmp), |
no test coverage detected