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

Function dodown

src/do.c:1130–1294  ·  view source on GitHub ↗

the #down command */

Source from the content-addressed store, hash-verified

1128
1129/* the #down command */
1130int
1131dodown(void)
1132{
1133 struct trap *trap = 0;
1134 stairway *stway;
1135 boolean stairs_down, ladder_down;
1136
1137 set_move_cmd(DIR_DOWN, 0);
1138
1139 if (u_rooted())
1140 return ECMD_TIME;
1141
1142 if (stucksteed(TRUE)) {
1143 return ECMD_OK;
1144 }
1145
1146 stairs_down = ladder_down = FALSE;
1147 if ((stway = stairway_at(u.ux, u.uy)) != 0 && !stway->up) {
1148 stairs_down = !stway->isladder;
1149 ladder_down = !stairs_down;
1150 }
1151
1152 /* Levitation might be blocked, but player can still use '>' to
1153 turn off controlled levitation */
1154 if (HLevitation || ELevitation) {
1155 if ((HLevitation & I_SPECIAL) || (ELevitation & W_ARTI)) {
1156 /* end controlled levitation */
1157 if (ELevitation & W_ARTI) {
1158 struct obj *obj;
1159
1160 for (obj = gi.invent; obj; obj = obj->nobj) {
1161 if (obj->oartifact
1162 && artifact_has_invprop(obj, LEVITATION)) {
1163 if (obj->age < svm.moves)
1164 obj->age = svm.moves;
1165 obj->age += rnz(100);
1166 }
1167 }
1168 }
1169 if (float_down(I_SPECIAL | TIMEOUT, W_ARTI)) {
1170 return ECMD_TIME; /* came down, so moved */
1171 } else if (!HLevitation && !ELevitation) {
1172 Your("latent levitation ceases.");
1173 return ECMD_TIME; /* did something, effectively moved */
1174 }
1175 }
1176 if (BLevitation) {
1177 ; /* weren't actually floating after all */
1178 } else if (Blind) {
1179 /* glyph_to_cmap() is a macro which expands its argument many
1180 times; use this to do part of its work just once */
1181 int glyph_at_uxuy = levl[u.ux][u.uy].glyph;
1182
1183 /* Avoid alerting player to an unknown stair or ladder.
1184 * Changes the message for a covered, known staircase
1185 * too; staircase knowledge is not stored anywhere.
1186 */
1187 if (stairs_down)

Callers

nothing calls this directly

Calls 15

set_move_cmdFunction · 0.85
u_rootedFunction · 0.85
stucksteedFunction · 0.85
stairway_atFunction · 0.85
artifact_has_invpropFunction · 0.85
rnzFunction · 0.85
float_downFunction · 0.85
YourFunction · 0.85
glyph_to_cmapFunction · 0.85
YouFunction · 0.85
surfaceFunction · 0.85
is_poolFunction · 0.85

Tested by

no test coverage detected