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

Function moverock_core

src/hack.c:347–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347staticfn int
348moverock_core(coordxy sx, coordxy sy)
349{
350 coordxy rx, ry;
351 struct obj *otmp;
352 struct trap *ttmp;
353 struct monst *mtmp;
354 boolean costly, firstboulder = TRUE;
355
356 while ((otmp = sobj_at(BOULDER, sx, sy)) != 0) {
357
358 if (Blind && glyph_to_obj(glyph_at(sx, sy)) != BOULDER) {
359 pline("That feels like a boulder.");
360 map_object(otmp, TRUE);
361 nomul(0);
362 return -1;
363 }
364
365 /* when otmp->next_boulder is 1, xname() will format it as
366 "next boulder" instead of just "boulder"; affects
367 boulder_hits_pool()'s messages as well as messages below */
368 otmp->next_boulder = firstboulder ? 0 : 1;
369 /* FIXME? 'firstboulder' should be reset to True if this boulder
370 isn't the first and the previous one is named differently from
371 this one. Probably not worth bothering with... */
372 firstboulder = FALSE;
373
374 /* make sure that this boulder is visible as the top object */
375 if (otmp != svl.level.objects[sx][sy])
376 movobj(otmp, sx, sy);
377
378 rx = u.ux + 2 * u.dx; /* boulder destination position */
379 ry = u.uy + 2 * u.dy;
380 nomul(0);
381
382 /* using m<dir> towards an adjacent boulder steps over/onto it if
383 poly'd into a giant or squeezes under/beside it if small/light
384 enough but is a no-op in other circumstances unless move attempt
385 reveals an unseen boulder or lack of remembered, unseen monster */
386 if (svc.context.nopick) {
387 int oldglyph = glyph_at(sx, sy); /* before feel_location() */
388 int res;
389
390 feel_location(sx, sy); /* same for all 3 if/else-if/else cases */
391 if (throws_rocks(gy.youmonst.data)) {
392 /* player has used 'm<dir>' to move, so step to boulder's
393 spot without pushing it; hero is poly'd into a giant,
394 so exotic forms of locomotion are out, but might be
395 levitating (ring, potion, spell) or flying (amulet) */
396 You("%s over a boulder here.", u_locomotion("step"));
397 /* ["over" seems weird on air level but what else to say?] */
398 sokoban_guilt();
399 res = 0; /* move to <sx,sy> */
400 } else if (could_move_onto_boulder(sx, sy)) {
401 You("squeeze yourself %s the boulder.",
402 Flying ? "over" : "against");
403 sokoban_guilt();
404 res = 0; /* move to <sx,sy> */

Callers 1

moverockFunction · 0.85

Calls 15

sobj_atFunction · 0.85
glyph_atFunction · 0.85
map_objectFunction · 0.85
nomulFunction · 0.85
movobjFunction · 0.85
feel_locationFunction · 0.85
YouFunction · 0.85
u_locomotionFunction · 0.85
sokoban_guiltFunction · 0.85
could_move_onto_boulderFunction · 0.85
ThereFunction · 0.85
theFunction · 0.85

Tested by

no test coverage detected