| 3730 | } |
| 3731 | |
| 3732 | int |
| 3733 | mintrap(struct monst *mtmp, unsigned mintrapflags) |
| 3734 | { |
| 3735 | struct trap *trap = t_at(mtmp->mx, mtmp->my); |
| 3736 | struct permonst *mptr = mtmp->data; |
| 3737 | int trap_result = Trap_Effect_Finished; |
| 3738 | |
| 3739 | if (!trap) { |
| 3740 | mtmp->mtrapped = 0; /* perhaps teleported? */ |
| 3741 | } else if (mtmp->mtrapped) { /* is currently in the trap */ |
| 3742 | if (!trap->tseen && cansee(mtmp->mx, mtmp->my) && canseemon(mtmp) |
| 3743 | && (is_pit(trap->ttyp) || trap->ttyp == BEAR_TRAP |
| 3744 | || trap->ttyp == HOLE |
| 3745 | || trap->ttyp == WEB)) { |
| 3746 | /* If you come upon an obviously trapped monster, then |
| 3747 | you must be able to see the trap it's in too. */ |
| 3748 | seetrap(trap); |
| 3749 | } |
| 3750 | |
| 3751 | if (!rn2(40) || (is_pit(trap->ttyp) && m_easy_escape_pit(mtmp))) { |
| 3752 | if (sobj_at(BOULDER, mtmp->mx, mtmp->my) |
| 3753 | && is_pit(trap->ttyp)) { |
| 3754 | if (!rn2(2)) { |
| 3755 | mtmp->mtrapped = 0; |
| 3756 | if (canseemon(mtmp)) |
| 3757 | pline_mon(mtmp, "%s pulls free...", |
| 3758 | Monnam(mtmp)); |
| 3759 | fill_pit(mtmp->mx, mtmp->my); |
| 3760 | } |
| 3761 | } else { |
| 3762 | if (canseemon(mtmp)) { |
| 3763 | set_msg_xy(mtmp->mx, mtmp->my); |
| 3764 | if (is_pit(trap->ttyp)) |
| 3765 | pline("%s climbs %sout of the pit.", Monnam(mtmp), |
| 3766 | m_easy_escape_pit(mtmp) ? "easily " : ""); |
| 3767 | else if (trap->ttyp == BEAR_TRAP || trap->ttyp == WEB) |
| 3768 | pline("%s pulls free of the %s.", Monnam(mtmp), |
| 3769 | trapname(trap->ttyp, FALSE)); |
| 3770 | } |
| 3771 | mtmp->mtrapped = 0; |
| 3772 | } |
| 3773 | } else if (metallivorous(mptr)) { |
| 3774 | if (trap->ttyp == BEAR_TRAP) { |
| 3775 | if (canseemon(mtmp)) |
| 3776 | pline_mon(mtmp, "%s eats a bear trap!", |
| 3777 | Monnam(mtmp)); |
| 3778 | deltrap(trap); |
| 3779 | mtmp->meating = 5; |
| 3780 | mtmp->mtrapped = 0; |
| 3781 | } else if (trap->ttyp == SPIKED_PIT) { |
| 3782 | if (canseemon(mtmp)) |
| 3783 | pline_mon(mtmp, "%s munches on some spikes!", |
| 3784 | Monnam(mtmp)); |
| 3785 | trap->ttyp = PIT; |
| 3786 | mtmp->meating = 5; |
| 3787 | } |
| 3788 | } |
| 3789 | trap_result = mtmp->mtrapped ? Trap_Caught_Mon : Trap_Effect_Finished; |
no test coverage detected