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

Function swim_move_danger

src/hack.c:1884–1921  ·  view source on GitHub ↗

Is it dangerous for hero to move to x,y due to water or lava? */

Source from the content-addressed store, hash-verified

1882
1883/* Is it dangerous for hero to move to x,y due to water or lava? */
1884staticfn boolean
1885swim_move_danger(coordxy x, coordxy y)
1886{
1887 schar newtyp = u_simple_floortyp(x, y);
1888 boolean liquid_wall = IS_WATERWALL(newtyp) || newtyp == LAVAWALL;
1889
1890 if (Underwater && (is_pool(x,y) || IS_WATERWALL(newtyp)))
1891 return FALSE;
1892
1893 if ((newtyp != u_simple_floortyp(u.ux, u.uy))
1894 && !Stunned && !Confusion && levl[x][y].seenv
1895 && (is_pool(x, y) || is_lava(x, y) || liquid_wall)) {
1896
1897 /* FIXME: This can be exploited to identify ring of fire resistance
1898 * if the player is wearing it unidentified and has identified
1899 * fireproof boots of water walking and is walking over lava. However,
1900 * this is such a marginal case that it may not be worth fixing. */
1901 if ((is_pool(x, y) && !Known_wwalking)
1902 /* is_lava(ux,uy): don't move onto/over lava with known
1903 lava-walking because it isn't completely safe, but do
1904 continue to move over lava if already doing so */
1905 || (is_lava(x, y) && !Known_lwalking && !is_lava(u.ux, u.uy))
1906 || liquid_wall) {
1907 if (svc.context.nopick) {
1908 /* moving with m-prefix */
1909 svc.context.tips |= (1 << TIP_SWIM);
1910 return FALSE;
1911 } else if (ParanoidSwim || liquid_wall) {
1912 You("avoid %s into the %s.",
1913 ing_suffix(u_locomotion("step")),
1914 waterbody_name(x, y));
1915 (void) handle_tip(TIP_SWIM);
1916 return TRUE;
1917 }
1918 }
1919 }
1920 return FALSE;
1921}
1922
1923/* moving with 'm' prefix, bump into a monster? */
1924staticfn boolean

Callers 1

domove_coreFunction · 0.85

Calls 8

u_simple_floortypFunction · 0.85
is_poolFunction · 0.85
is_lavaFunction · 0.85
YouFunction · 0.85
ing_suffixFunction · 0.85
u_locomotionFunction · 0.85
waterbody_nameFunction · 0.85
handle_tipFunction · 0.85

Tested by

no test coverage detected