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

Function doup

src/do.c:1297–1344  ·  view source on GitHub ↗

the #up command - move up a staircase */

Source from the content-addressed store, hash-verified

1295
1296/* the #up command - move up a staircase */
1297int
1298doup(void)
1299{
1300 stairway *stway = stairway_at(u.ux,u.uy);
1301
1302 set_move_cmd(DIR_UP, 0);
1303
1304 if (u_rooted())
1305 return ECMD_TIME;
1306
1307 /* "up" to get out of a pit... */
1308 if (u.utrap && u.utraptype == TT_PIT) {
1309 climb_pit();
1310 return ECMD_TIME;
1311 }
1312
1313 if (!stway || (stway && !stway->up)) {
1314 You_cant("go up here.");
1315 return ECMD_OK;
1316 }
1317 if (stucksteed(TRUE)) {
1318 return ECMD_OK;
1319 }
1320
1321 if (u_stuck_cannot_go("up"))
1322 return ECMD_TIME;
1323
1324 if (near_capacity() > SLT_ENCUMBER) {
1325 /* No levitation check; inv_weight() already allows for it */
1326 Your("load is too heavy to climb the %s.",
1327 levl[u.ux][u.uy].typ == STAIRS ? "stairs" : "ladder");
1328 return ECMD_TIME;
1329 }
1330 if (ledger_no(&u.uz) == 1) {
1331 if (iflags.debug_fuzzer)
1332 return ECMD_OK;
1333 if (y_n("Beware, there will be no return! Still climb?") != 'y')
1334 return ECMD_OK;
1335 }
1336 if (!next_to_u()) {
1337 You("are held back by your pet!");
1338 return ECMD_OK;
1339 }
1340 ga.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER);
1341 prev_level(TRUE);
1342 ga.at_ladder = FALSE;
1343 return ECMD_TIME;
1344}
1345
1346/* check that we can write out the current level */
1347staticfn NHFILE *

Callers 1

peffect_levitationFunction · 0.85

Calls 13

stairway_atFunction · 0.85
set_move_cmdFunction · 0.85
u_rootedFunction · 0.85
climb_pitFunction · 0.85
You_cantFunction · 0.85
stucksteedFunction · 0.85
u_stuck_cannot_goFunction · 0.85
near_capacityFunction · 0.85
YourFunction · 0.85
ledger_noFunction · 0.85
next_to_uFunction · 0.85
YouFunction · 0.85

Tested by

no test coverage detected