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

Function mkswamp

src/mkroom.c:529–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527}
528
529staticfn void
530mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
531{
532 struct mkroom *sroom;
533 int i, eelct = 0;
534 coordxy sx, sy;
535 int rmno;
536
537 for (i = 0; i < 5; i++) { /* turn up to 5 rooms swampy */
538 sroom = &svr.rooms[rn2(svn.nroom)];
539 if (sroom->hx < 0 || sroom->rtype != OROOM || has_upstairs(sroom)
540 || has_dnstairs(sroom))
541 continue;
542
543 rmno = (int)(sroom - svr.rooms) + ROOMOFFSET;
544
545 /* satisfied; make a swamp */
546 sroom->rtype = SWAMP;
547 for (sx = sroom->lx; sx <= sroom->hx; sx++)
548 for (sy = sroom->ly; sy <= sroom->hy; sy++) {
549 if (!IS_ROOM(levl[sx][sy].typ)
550 || (int) levl[sx][sy].roomno != rmno)
551 continue;
552 if (!OBJ_AT(sx, sy) && !MON_AT(sx, sy) && !t_at(sx, sy)
553 && !nexttodoor(sx, sy)) {
554 if ((sx + sy) % 2) {
555 del_engr_at(sx, sy);
556 levl[sx][sy].typ = POOL;
557 if (!eelct || !rn2(4)) {
558 /* mkclass() won't do, as we might get kraken */
559 (void) makemon(rn2(5)
560 ? &mons[PM_GIANT_EEL]
561 : rn2(2)
562 ? &mons[PM_PIRANHA]
563 : &mons[PM_ELECTRIC_EEL],
564 sx, sy, NO_MM_FLAGS);
565 eelct++;
566 }
567 } else if (!rn2(4)) /* swamps tend to be moldy */
568 (void) makemon(mkclass(S_FUNGUS, 0), sx, sy,
569 NO_MM_FLAGS);
570 }
571 }
572 svl.level.flags.has_swamp = 1;
573 }
574}
575
576staticfn coord *
577shrine_pos(int roomno)

Callers 2

do_mkroomFunction · 0.85
mkshopFunction · 0.85

Calls 8

rn2Function · 0.85
has_upstairsFunction · 0.85
has_dnstairsFunction · 0.85
t_atFunction · 0.85
nexttodoorFunction · 0.85
del_engr_atFunction · 0.85
makemonFunction · 0.85
mkclassFunction · 0.85

Tested by

no test coverage detected