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

Function swallowed

src/display.c:1331–1386  ·  view source on GitHub ↗

* swallowed() * * The hero is swallowed. Show a special graphics sequence for this. This * bypasses all of the display routines and messes with buffered screen * directly. This method works because both vision and display check for * being swallowed. */

Source from the content-addressed store, hash-verified

1329 * being swallowed.
1330 */
1331void
1332swallowed(int first)
1333{
1334 static coordxy lastx, lasty; /* last swallowed position */
1335 int swallower, left_ok, rght_ok;
1336
1337 if (first) {
1338 cls();
1339 bot();
1340 } else {
1341 coordxy x, y;
1342
1343 /* Clear old location */
1344 for (y = lasty - 1; y <= lasty + 1; y++)
1345 for (x = lastx - 1; x <= lastx + 1; x++)
1346 if (isok(x, y))
1347 show_glyph(x, y, GLYPH_UNEXPLORED);
1348 }
1349
1350 swallower = monsndx(u.ustuck->data);
1351 /* assume isok(u.ux,u.uy) */
1352 left_ok = isok(u.ux - 1, u.uy);
1353 rght_ok = isok(u.ux + 1, u.uy);
1354 /*
1355 * Display the hero surrounded by the monster's stomach.
1356 */
1357 if (isok(u.ux, u.uy - 1)) {
1358 if (left_ok)
1359 show_glyph(u.ux - 1, u.uy - 1,
1360 swallow_to_glyph(swallower, S_sw_tl));
1361 show_glyph(u.ux, u.uy - 1, swallow_to_glyph(swallower, S_sw_tc));
1362 if (rght_ok)
1363 show_glyph(u.ux + 1, u.uy - 1,
1364 swallow_to_glyph(swallower, S_sw_tr));
1365 }
1366
1367 if (left_ok)
1368 show_glyph(u.ux - 1, u.uy, swallow_to_glyph(swallower, S_sw_ml));
1369 display_self();
1370 if (rght_ok)
1371 show_glyph(u.ux + 1, u.uy, swallow_to_glyph(swallower, S_sw_mr));
1372
1373 if (isok(u.ux, u.uy + 1)) {
1374 if (left_ok)
1375 show_glyph(u.ux - 1, u.uy + 1,
1376 swallow_to_glyph(swallower, S_sw_bl));
1377 show_glyph(u.ux, u.uy + 1, swallow_to_glyph(swallower, S_sw_bc));
1378 if (rght_ok)
1379 show_glyph(u.ux + 1, u.uy + 1,
1380 swallow_to_glyph(swallower, S_sw_br));
1381 }
1382
1383 /* Update the swallowed position. */
1384 lastx = u.ux;
1385 lasty = u.uy;
1386}
1387
1388/*

Callers 7

docornerFunction · 0.85
allmain.cFile · 0.85
make_hallucinatedFunction · 0.85
docrt_flagsFunction · 0.85
newchamFunction · 0.85
postmovFunction · 0.85
gulpmuFunction · 0.85

Calls 5

clsFunction · 0.85
botFunction · 0.85
isokFunction · 0.85
show_glyphFunction · 0.85
swallow_to_glyphFunction · 0.85

Tested by

no test coverage detected