when moving in water, possibly (1 in 3) alter the intended destination */
| 1686 | |
| 1687 | /* when moving in water, possibly (1 in 3) alter the intended destination */ |
| 1688 | void |
| 1689 | water_friction(void) |
| 1690 | { |
| 1691 | coordxy x, y, dx, dy; |
| 1692 | boolean eff = FALSE; |
| 1693 | |
| 1694 | if (Swimming && rn2(4)) |
| 1695 | return; /* natural swimmers have advantage */ |
| 1696 | |
| 1697 | if (u.dx && !rn2(!u.dy ? 3 : 6)) { /* 1/3 chance or half that */ |
| 1698 | /* cancel delta x and choose an arbitrary delta y value */ |
| 1699 | x = u.ux; |
| 1700 | do { |
| 1701 | dy = rn2(3) - 1; /* -1, 0, 1 */ |
| 1702 | y = u.uy + dy; |
| 1703 | } while (dy && (!isok(x, y) || !is_pool(x, y))); |
| 1704 | u.dx = 0; |
| 1705 | u.dy = dy; |
| 1706 | eff = TRUE; |
| 1707 | } else if (u.dy && !rn2(!u.dx ? 3 : 5)) { /* 1/3 or 1/5*(5/6) */ |
| 1708 | /* cancel delta y and choose an arbitrary delta x value */ |
| 1709 | y = u.uy; |
| 1710 | do { |
| 1711 | dx = rn2(3) - 1; /* -1 .. 1 */ |
| 1712 | x = u.ux + dx; |
| 1713 | } while (dx && (!isok(x, y) || !is_pool(x, y))); |
| 1714 | u.dy = 0; |
| 1715 | u.dx = dx; |
| 1716 | eff = TRUE; |
| 1717 | } |
| 1718 | if (eff) |
| 1719 | pline("Water turbulence affects your movements."); |
| 1720 | } |
| 1721 | |
| 1722 | void |
| 1723 | save_waterlevel(NHFILE *nhfp) |
no test coverage detected