MCPcopy Index your code
hub / github.com/NetHack/NetHack / jump

Function jump

src/apply.c:1987–2164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1985}
1986
1987int
1988jump(int magic) /* 0=Physical, otherwise skill level */
1989{
1990 coord cc;
1991
1992 /* attempt "jumping" spell if hero has no innate jumping ability */
1993 if (!magic && !Jumping && known_spell(SPE_JUMPING) >= spe_Fresh)
1994 return spelleffects(SPE_JUMPING, FALSE, FALSE);
1995
1996 if (!magic && (nolimbs(gy.youmonst.data) || slithy(gy.youmonst.data))) {
1997 /* normally (nolimbs || slithy) implies !Jumping,
1998 but that isn't necessarily the case for knights */
1999 You_cant("jump; you have no legs!");
2000 return ECMD_OK;
2001 } else if (!magic && !Jumping) {
2002 You_cant("jump very far.");
2003 return ECMD_OK;
2004
2005 /* if steed is immobile, can't do physical jump but can do spell one */
2006 } else if (!magic && u.usteed && stucksteed(FALSE)) {
2007 /* stucksteed gave "<steed> won't move" message */
2008 return ECMD_OK;
2009 } else if (u.uswallow) {
2010 if (magic) {
2011 You("bounce around a little.");
2012 return ECMD_TIME;
2013 }
2014 pline("You've got to be kidding!");
2015 return ECMD_OK;
2016 } else if (u.uinwater) {
2017 if (magic) {
2018 You("swish around a little.");
2019 return ECMD_TIME;
2020 }
2021 pline("This calls for swimming, not jumping!");
2022 return ECMD_OK;
2023 } else if (u.ustuck) {
2024 if (u.ustuck->mtame && !Conflict && !u.ustuck->mconf) {
2025 struct monst *mtmp = u.ustuck;
2026
2027 set_ustuck((struct monst *) 0);
2028 You("pull free from %s.", mon_nam(mtmp));
2029 return ECMD_TIME;
2030 }
2031 if (magic) {
2032 You("writhe a little in the grasp of %s!", mon_nam(u.ustuck));
2033 return ECMD_TIME;
2034 }
2035 You("cannot escape from %s!", mon_nam(u.ustuck));
2036 return ECMD_OK;
2037 } else if (Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) {
2038 if (magic) {
2039 You("flail around a little.");
2040 return ECMD_TIME;
2041 }
2042 You("don't have enough traction to jump.");
2043 return ECMD_OK;
2044 } else if (!magic && near_capacity() > UNENCUMBERED) {

Callers 2

spelleffectsFunction · 0.85
dojumpFunction · 0.85

Calls 15

known_spellFunction · 0.85
spelleffectsFunction · 0.85
You_cantFunction · 0.85
stucksteedFunction · 0.85
YouFunction · 0.85
set_ustuckFunction · 0.85
mon_namFunction · 0.85
near_capacityFunction · 0.85
legs_in_no_shapeFunction · 0.85
MonnamFunction · 0.85
getpos_sethiliteFunction · 0.85
getposFunction · 0.85

Tested by

no test coverage detected