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

Function polymorph_sink

src/do.c:403–455  ·  view source on GitHub ↗

Transforms the sink at the player's position into a fountain, throne, altar or grave. */

Source from the content-addressed store, hash-verified

401/* Transforms the sink at the player's position into
402 a fountain, throne, altar or grave. */
403void
404polymorph_sink(void)
405{
406 uchar sym = S_sink;
407 boolean sinklooted;
408 int algn;
409
410 if (levl[u.ux][u.uy].typ != SINK)
411 return;
412
413 sinklooted = levl[u.ux][u.uy].looted != 0;
414 /* svl.level.flags.nsinks--; // set_levltyp() will update this */
415 levl[u.ux][u.uy].flags = 0;
416 switch (rn2(4)) {
417 default:
418 case 0:
419 sym = S_fountain;
420 set_levltyp(u.ux, u.uy, FOUNTAIN); /* updates level.flags.nfountains */
421 levl[u.ux][u.uy].blessedftn = 0;
422 if (sinklooted)
423 SET_FOUNTAIN_LOOTED(u.ux, u.uy);
424 break;
425 case 1:
426 sym = S_throne;
427 set_levltyp(u.ux, u.uy, THRONE);
428 if (sinklooted)
429 levl[u.ux][u.uy].looted = T_LOOTED;
430 break;
431 case 2:
432 sym = S_altar;
433 set_levltyp(u.ux, u.uy, ALTAR);
434 /* 3.6.3: this used to pass 'rn2(A_LAWFUL + 2) - 1' to
435 Align2amask() but that evaluates its argument more than once */
436 algn = rn2(3) - 1; /* -1 (A_Cha) or 0 (A_Neu) or +1 (A_Law) */
437 levl[u.ux][u.uy].altarmask = ((Inhell && rn2(3)) ? AM_NONE
438 : Align2amask(algn));
439 break;
440 case 3:
441 sym = S_room;
442 set_levltyp(u.ux, u.uy, ROOM);
443 make_grave(u.ux, u.uy, (char *) 0);
444 if (levl[u.ux][u.uy].typ == GRAVE)
445 sym = S_grave;
446 break;
447 }
448 /* give message even if blind; we know we're not levitating,
449 so can feel the outcome even if we can't directly see it */
450 if (levl[u.ux][u.uy].typ != ROOM)
451 pline_The("sink transforms into %s!", an(defsyms[sym].explanation));
452 else
453 pline_The("sink vanishes.");
454 newsym(u.ux, u.uy);
455}
456
457/* Teleports the sink at the player's position;
458 return True if sink teleported. */

Callers 2

dosinkringFunction · 0.85
dipsinkFunction · 0.85

Calls 6

rn2Function · 0.85
set_levltypFunction · 0.85
make_graveFunction · 0.85
pline_TheFunction · 0.85
anFunction · 0.85
newsymFunction · 0.85

Tested by

no test coverage detected