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

Function escape_from_sticky_mon

src/hack.c:2638–2692  ·  view source on GitHub ↗

try to pull free from sticking monster, or you release a monster you're sticking to. returns TRUE if you lose your movement. */

Source from the content-addressed store, hash-verified

2636/* try to pull free from sticking monster, or you release a monster
2637 you're sticking to. returns TRUE if you lose your movement. */
2638staticfn boolean
2639escape_from_sticky_mon(coordxy x, coordxy y)
2640{
2641 if (u.ustuck && (x != u.ustuck->mx || y != u.ustuck->my)) {
2642 struct monst *mtmp;
2643
2644 if (!m_next2u(u.ustuck)) {
2645 /* perhaps it fled (or was teleported or ... ) */
2646 set_ustuck((struct monst *) 0);
2647 } else if (sticks(gy.youmonst.data)) {
2648 /* When polymorphed into a sticking monster,
2649 * u.ustuck means it's stuck to you, not you to it.
2650 */
2651 mtmp = u.ustuck;
2652 set_ustuck((struct monst *) 0);
2653 You("release %s.", y_monnam(mtmp));
2654 } else {
2655 /* If holder is asleep or paralyzed:
2656 * 37.5% chance of getting away,
2657 * 12.5% chance of waking/releasing it;
2658 * otherwise:
2659 * 7.5% chance of getting away.
2660 * [strength ought to be a factor]
2661 * If holder is tame and there is no conflict,
2662 * guaranteed escape.
2663 */
2664 switch (rn2(!u.ustuck->mcanmove ? 8 : 40)) {
2665 case 3:
2666 if (!u.ustuck->mcanmove) {
2667 /* it's free to move on next turn */
2668 u.ustuck->mfrozen = 1;
2669 u.ustuck->msleeping = 0;
2670 }
2671 FALLTHROUGH;
2672 /*FALLTHRU*/
2673 default:
2674 if (Conflict || u.ustuck->mconf || !u.ustuck->mtame) {
2675 You("cannot escape from %s!", y_monnam(u.ustuck));
2676 nomul(0);
2677 return TRUE;
2678 }
2679 FALLTHROUGH;
2680 /*FALLTHRU*/
2681 case 0:
2682 case 1:
2683 case 2:
2684 mtmp = u.ustuck;
2685 set_ustuck((struct monst *) 0);
2686 You("pull free from %s.", y_monnam(mtmp));
2687 break;
2688 }
2689 }
2690 }
2691 return FALSE;
2692}
2693
2694void
2695domove(void)

Callers 1

domove_coreFunction · 0.85

Calls 6

set_ustuckFunction · 0.85
sticksFunction · 0.85
YouFunction · 0.85
y_monnamFunction · 0.85
rn2Function · 0.85
nomulFunction · 0.85

Tested by

no test coverage detected