136981Sbostic /* create.c Larn is copyrighted 1986 by Noah Morgan. */
236981Sbostic #include "header.h"
336981Sbostic extern char spelknow[],larnlevels[];
436981Sbostic extern char beenhere[],wizard,level;
536981Sbostic extern short oldx,oldy;
636981Sbostic /*
736981Sbostic makeplayer()
836981Sbostic
936981Sbostic subroutine to create the player and the players attributes
1036981Sbostic this is called at the beginning of a game and at no other time
1136981Sbostic */
makeplayer()1236981Sbostic makeplayer()
1336981Sbostic {
1436981Sbostic register int i;
1536981Sbostic scbr(); clear();
1636981Sbostic c[HPMAX]=c[HP]=10; /* start player off with 15 hit points */
1736981Sbostic c[LEVEL]=1; /* player starts at level one */
1836981Sbostic c[SPELLMAX]=c[SPELLS]=1; /* total # spells starts off as 3 */
1936981Sbostic c[REGENCOUNTER]=16; c[ECOUNTER]=96; /*start regeneration correctly*/
2036981Sbostic c[SHIELD] = c[WEAR] = c[WIELD] = -1;
2136981Sbostic for (i=0; i<26; i++) iven[i]=0;
2236981Sbostic spelknow[0]=spelknow[1]=1; /*he knows protection, magic missile*/
2336981Sbostic if (c[HARDGAME]<=0)
2436981Sbostic {
2536981Sbostic iven[0]=OLEATHER; iven[1]=ODAGGER;
2636981Sbostic ivenarg[1]=ivenarg[0]=c[WEAR]=0; c[WIELD]=1;
2736981Sbostic }
2836981Sbostic playerx=rnd(MAXX-2); playery=rnd(MAXY-2);
2936981Sbostic oldx=0; oldy=25;
3036981Sbostic gtime=0; /* time clock starts at zero */
3136981Sbostic cbak[SPELLS] = -50;
3236981Sbostic for (i=0; i<6; i++) c[i]=12; /* make the attributes, ie str, int, etc. */
3336981Sbostic recalc();
3436981Sbostic }
3536981Sbostic
3636981Sbostic /*
3736981Sbostic newcavelevel(level)
3836981Sbostic int level;
3936981Sbostic
4036981Sbostic function to enter a new level. This routine must be called anytime the
4136981Sbostic player changes levels. If that level is unknown it will be created.
4236981Sbostic A new set of monsters will be created for a new level, and existing
4336981Sbostic levels will get a few more monsters.
4436981Sbostic Note that it is here we remove genocided monsters from the present level.
4536981Sbostic */
newcavelevel(x)4636981Sbostic newcavelevel(x)
4736981Sbostic register int x;
4836981Sbostic {
4936981Sbostic register int i,j;
5036981Sbostic if (beenhere[level]) savelevel(); /* put the level back into storage */
5136981Sbostic level = x; /* get the new level and put in working storage */
5236981Sbostic if (beenhere[x]==0) for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) know[j][i]=mitem[j][i]=0;
5336981Sbostic else { getlevel(); sethp(0); goto chgn; }
5436981Sbostic makemaze(x); makeobject(x); beenhere[x]=1; sethp(1);
5536981Sbostic
5636981Sbostic #if WIZID
5736981Sbostic if (wizard || x==0)
5836981Sbostic #else
5936981Sbostic if (x==0)
6036981Sbostic #endif
6136981Sbostic
6236981Sbostic for (j=0; j<MAXY; j++)
6336981Sbostic for (i=0; i<MAXX; i++)
6436981Sbostic know[i][j]=1;
6536981Sbostic chgn: checkgen(); /* wipe out any genocided monsters */
6636981Sbostic }
6736981Sbostic
6836981Sbostic /*
6936981Sbostic makemaze(level)
7036981Sbostic int level;
7136981Sbostic
7236981Sbostic subroutine to make the caverns for a given level. only walls are made.
7336981Sbostic */
7436981Sbostic static int mx,mxl,mxh,my,myl,myh,tmp2;
makemaze(k)7536981Sbostic makemaze(k)
7636981Sbostic int k;
7736981Sbostic {
7836981Sbostic register int i,j,tmp;
7936981Sbostic int z;
8036981Sbostic if (k > 1 && (rnd(17)<=4 || k==MAXLEVEL-1 || k==MAXLEVEL+MAXVLEVEL-1))
8136981Sbostic {
8236981Sbostic if (cannedlevel(k)); return; /* read maze from data file */
8336981Sbostic }
8436981Sbostic if (k==0) tmp=0; else tmp=OWALL;
8536981Sbostic for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) item[j][i]=tmp;
8636981Sbostic if (k==0) return; eat(1,1);
8736981Sbostic if (k==1) item[33][MAXY-1]=0; /* exit from dungeon */
8836981Sbostic
8936981Sbostic /* now for open spaces -- not on level 10 */
9036981Sbostic if (k != MAXLEVEL-1)
9136981Sbostic {
9236981Sbostic tmp2 = rnd(3)+3;
9336981Sbostic for (tmp=0; tmp<tmp2; tmp++)
9436981Sbostic {
9536981Sbostic my = rnd(11)+2; myl = my - rnd(2); myh = my + rnd(2);
9636981Sbostic if (k < MAXLEVEL)
9736981Sbostic {
9836981Sbostic mx = rnd(44)+5; mxl = mx - rnd(4); mxh = mx + rnd(12)+3;
9936981Sbostic z=0;
10036981Sbostic }
10136981Sbostic else
10236981Sbostic {
10336981Sbostic mx = rnd(60)+3; mxl = mx - rnd(2); mxh = mx + rnd(2);
10436981Sbostic z = makemonst(k);
10536981Sbostic }
10636981Sbostic for (i=mxl; i<mxh; i++) for (j=myl; j<myh; j++)
10736981Sbostic { item[i][j]=0;
10836981Sbostic if ((mitem[i][j]=z)) hitp[i][j]=monster[z].hitpoints;
10936981Sbostic }
11036981Sbostic }
11136981Sbostic }
11236981Sbostic if (k!=MAXLEVEL-1) { my=rnd(MAXY-2); for (i=1; i<MAXX-1; i++) item[i][my] = 0; }
11336981Sbostic if (k>1) treasureroom(k);
11436981Sbostic }
11536981Sbostic
11636981Sbostic /*
11736981Sbostic function to eat away a filled in maze
11836981Sbostic */
eat(xx,yy)11936981Sbostic eat(xx,yy)
12036981Sbostic register int xx,yy;
12136981Sbostic {
12236981Sbostic register int dir,try;
12336981Sbostic dir = rnd(4); try=2;
12436981Sbostic while (try)
12536981Sbostic {
12636981Sbostic switch(dir)
12736981Sbostic {
12836981Sbostic case 1: if (xx <= 2) break; /* west */
12936981Sbostic if ((item[xx-1][yy]!=OWALL) || (item[xx-2][yy]!=OWALL)) break;
13036981Sbostic item[xx-1][yy] = item[xx-2][yy] = 0;
13136981Sbostic eat(xx-2,yy); break;
13236981Sbostic
13336981Sbostic case 2: if (xx >= MAXX-3) break; /* east */
13436981Sbostic if ((item[xx+1][yy]!=OWALL) || (item[xx+2][yy]!=OWALL)) break;
13536981Sbostic item[xx+1][yy] = item[xx+2][yy] = 0;
13636981Sbostic eat(xx+2,yy); break;
13736981Sbostic
13836981Sbostic case 3: if (yy <= 2) break; /* south */
13936981Sbostic if ((item[xx][yy-1]!=OWALL) || (item[xx][yy-2]!=OWALL)) break;
14036981Sbostic item[xx][yy-1] = item[xx][yy-2] = 0;
14136981Sbostic eat(xx,yy-2); break;
14236981Sbostic
14336981Sbostic case 4: if (yy >= MAXY-3 ) break; /* north */
14436981Sbostic if ((item[xx][yy+1]!=OWALL) || (item[xx][yy+2]!=OWALL)) break;
14536981Sbostic item[xx][yy+1] = item[xx][yy+2] = 0;
14636981Sbostic eat(xx,yy+2); break;
14736981Sbostic };
14836981Sbostic if (++dir > 4) { dir=1; --try; }
14936981Sbostic }
15036981Sbostic }
15136981Sbostic
15236981Sbostic /*
15336981Sbostic * function to read in a maze from a data file
15436981Sbostic *
15536981Sbostic * Format of maze data file: 1st character = # of mazes in file (ascii digit)
15636981Sbostic * For each maze: 18 lines (1st 17 used) 67 characters per line
15736981Sbostic *
15836981Sbostic * Special characters in maze data file:
15936981Sbostic *
16036981Sbostic * # wall D door . random monster
16136981Sbostic * ~ eye of larn ! cure dianthroritis
16236981Sbostic * - random object
16336981Sbostic */
cannedlevel(k)16436981Sbostic cannedlevel(k)
16536981Sbostic int k;
16636981Sbostic {
16736981Sbostic char *row,*lgetl();
16836981Sbostic register int i,j;
16936981Sbostic int it,arg,mit,marg;
17036981Sbostic if (lopen(larnlevels)<0)
17136981Sbostic {
17236981Sbostic write(1,"Can't open the maze data file\n",30); died(-282); return(0);
17336981Sbostic }
17436981Sbostic i=lgetc(); if (i<='0') { died(-282); return(0); }
17536981Sbostic for (i=18*rund(i-'0'); i>0; i--) lgetl(); /* advance to desired maze */
17636981Sbostic for (i=0; i<MAXY; i++)
17736981Sbostic {
17836981Sbostic row = lgetl();
17936981Sbostic for (j=0; j<MAXX; j++)
18036981Sbostic {
18136981Sbostic it = mit = arg = marg = 0;
18236981Sbostic switch(*row++)
18336981Sbostic {
18436981Sbostic case '#': it = OWALL; break;
18536981Sbostic case 'D': it = OCLOSEDDOOR; arg = rnd(30); break;
18636981Sbostic case '~': if (k!=MAXLEVEL-1) break;
18736981Sbostic it = OLARNEYE;
18836981Sbostic mit = rund(8)+DEMONLORD;
18936981Sbostic marg = monster[mit].hitpoints; break;
19036981Sbostic case '!': if (k!=MAXLEVEL+MAXVLEVEL-1) break;
19136981Sbostic it = OPOTION; arg = 21;
19236981Sbostic mit = DEMONLORD+7;
19336981Sbostic marg = monster[mit].hitpoints; break;
19436981Sbostic case '.': if (k<MAXLEVEL) break;
19536981Sbostic mit = makemonst(k+1);
19636981Sbostic marg = monster[mit].hitpoints; break;
19736981Sbostic case '-': it = newobject(k+1,&arg); break;
19836981Sbostic };
19936981Sbostic item[j][i] = it; iarg[j][i] = arg;
20036981Sbostic mitem[j][i] = mit; hitp[j][i] = marg;
20136981Sbostic
20236981Sbostic #if WIZID
20336981Sbostic know[j][i] = (wizard) ? 1 : 0;
20436981Sbostic #else
20536981Sbostic know[j][i] = 0;
20636981Sbostic #endif
20736981Sbostic }
20836981Sbostic }
20936981Sbostic lrclose();
21036981Sbostic return(1);
21136981Sbostic }
21236981Sbostic
21336981Sbostic /*
21436981Sbostic function to make a treasure room on a level
21536981Sbostic level 10's treasure room has the eye in it and demon lords
21636981Sbostic level V3 has potion of cure dianthroritis and demon prince
21736981Sbostic */
treasureroom(lv)21836981Sbostic treasureroom(lv)
21936981Sbostic register int lv;
22036981Sbostic {
22136981Sbostic register int tx,ty,xsize,ysize;
22236981Sbostic
22336981Sbostic for (tx=1+rnd(10); tx<MAXX-10; tx+=10)
22436981Sbostic if ( (lv==MAXLEVEL-1) || (lv==MAXLEVEL+MAXVLEVEL-1) || rnd(13)==2)
22536981Sbostic {
22636981Sbostic xsize = rnd(6)+3; ysize = rnd(3)+3;
22736981Sbostic ty = rnd(MAXY-9)+1; /* upper left corner of room */
22836981Sbostic if (lv==MAXLEVEL-1 || lv==MAXLEVEL+MAXVLEVEL-1)
22936981Sbostic troom(lv,xsize,ysize,tx=tx+rnd(MAXX-24),ty,rnd(3)+6);
23036981Sbostic else troom(lv,xsize,ysize,tx,ty,rnd(9));
23136981Sbostic }
23236981Sbostic }
23336981Sbostic
23436981Sbostic /*
23536981Sbostic * subroutine to create a treasure room of any size at a given location
23636981Sbostic * room is filled with objects and monsters
23736981Sbostic * the coordinate given is that of the upper left corner of the room
23836981Sbostic */
troom(lv,xsize,ysize,tx,ty,glyph)23936981Sbostic troom(lv,xsize,ysize,tx,ty,glyph)
24036981Sbostic int lv,xsize,ysize,tx,ty,glyph;
24136981Sbostic {
24236981Sbostic register int i,j;
24336981Sbostic int tp1,tp2;
24436981Sbostic for (j=ty-1; j<=ty+ysize; j++)
24536981Sbostic for (i=tx-1; i<=tx+xsize; i++) /* clear out space for room */
24636981Sbostic item[i][j]=0;
24736981Sbostic for (j=ty; j<ty+ysize; j++)
24836981Sbostic for (i=tx; i<tx+xsize; i++) /* now put in the walls */
24936981Sbostic {
25036981Sbostic item[i][j]=OWALL; mitem[i][j]=0;
25136981Sbostic }
25236981Sbostic for (j=ty+1; j<ty+ysize-1; j++)
25336981Sbostic for (i=tx+1; i<tx+xsize-1; i++) /* now clear out interior */
25436981Sbostic item[i][j]=0;
25536981Sbostic
25636981Sbostic switch(rnd(2)) /* locate the door on the treasure room */
25736981Sbostic {
25836981Sbostic case 1: item[i=tx+rund(xsize)][j=ty+(ysize-1)*rund(2)]=OCLOSEDDOOR;
25936981Sbostic iarg[i][j] = glyph; /* on horizontal walls */
26036981Sbostic break;
26136981Sbostic case 2: item[i=tx+(xsize-1)*rund(2)][j=ty+rund(ysize)]=OCLOSEDDOOR;
26236981Sbostic iarg[i][j] = glyph; /* on vertical walls */
26336981Sbostic break;
26436981Sbostic };
26536981Sbostic
26636981Sbostic tp1=playerx; tp2=playery; playery=ty+(ysize>>1);
26736981Sbostic if (c[HARDGAME]<2)
26836981Sbostic for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2)
26936981Sbostic for (i=0, j=rnd(6); i<=j; i++)
27036981Sbostic { something(lv+2); createmonster(makemonst(lv+1)); }
27136981Sbostic else
27236981Sbostic for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2)
27336981Sbostic for (i=0, j=rnd(4); i<=j; i++)
27436981Sbostic { something(lv+2); createmonster(makemonst(lv+3)); }
27536981Sbostic
27636981Sbostic playerx=tp1; playery=tp2;
27736981Sbostic }
27836981Sbostic
279*46749Sbostic static void fillroom();
280*46749Sbostic
28136981Sbostic /*
28236981Sbostic ***********
28336981Sbostic MAKE_OBJECT
28436981Sbostic ***********
28536981Sbostic subroutine to create the objects in the maze for the given level
28636981Sbostic */
makeobject(j)28736981Sbostic makeobject(j)
28836981Sbostic register int j;
28936981Sbostic {
29036981Sbostic register int i;
29136981Sbostic if (j==0)
29236981Sbostic {
29336981Sbostic fillroom(OENTRANCE,0); /* entrance to dungeon */
29436981Sbostic fillroom(ODNDSTORE,0); /* the DND STORE */
29536981Sbostic fillroom(OSCHOOL,0); /* college of Larn */
29636981Sbostic fillroom(OBANK,0); /* 1st national bank of larn */
29736981Sbostic fillroom(OVOLDOWN,0); /* volcano shaft to temple */
29836981Sbostic fillroom(OHOME,0); /* the players home & family */
29936981Sbostic fillroom(OTRADEPOST,0); /* the trading post */
30036981Sbostic fillroom(OLRS,0); /* the larn revenue service */
30136981Sbostic return;
30236981Sbostic }
30336981Sbostic
30436981Sbostic if (j==MAXLEVEL) fillroom(OVOLUP,0); /* volcano shaft up from the temple */
30536981Sbostic
30636981Sbostic /* make the fixed objects in the maze STAIRS */
30736981Sbostic if ((j>0) && (j != MAXLEVEL-1) && (j != MAXLEVEL+MAXVLEVEL-1))
30836981Sbostic fillroom(OSTAIRSDOWN,0);
30936981Sbostic if ((j > 1) && (j != MAXLEVEL)) fillroom(OSTAIRSUP,0);
31036981Sbostic
31136981Sbostic /* make the random objects in the maze */
31236981Sbostic
31336981Sbostic fillmroom(rund(3),OBOOK,j); fillmroom(rund(3),OALTAR,0);
31436981Sbostic fillmroom(rund(3),OSTATUE,0); fillmroom(rund(3),OPIT,0);
31536981Sbostic fillmroom(rund(3),OFOUNTAIN,0); fillmroom( rnd(3)-2,OIVTELETRAP,0);
31636981Sbostic fillmroom(rund(2),OTHRONE,0); fillmroom(rund(2),OMIRROR,0);
31736981Sbostic fillmroom(rund(2),OTRAPARROWIV,0); fillmroom( rnd(3)-2,OIVDARTRAP,0);
31836981Sbostic fillmroom(rund(3),OCOOKIE,0);
31936981Sbostic if (j==1) fillmroom(1,OCHEST,j);
32036981Sbostic else fillmroom(rund(2),OCHEST,j);
32136981Sbostic if ((j != MAXLEVEL-1) && (j != MAXLEVEL+MAXVLEVEL-1))
32236981Sbostic fillmroom(rund(2),OIVTRAPDOOR,0);
32336981Sbostic if (j<=10)
32436981Sbostic {
32536981Sbostic fillmroom((rund(2)),ODIAMOND,rnd(10*j+1)+10);
32636981Sbostic fillmroom(rund(2),ORUBY,rnd(6*j+1)+6);
32736981Sbostic fillmroom(rund(2),OEMERALD,rnd(4*j+1)+4);
32836981Sbostic fillmroom(rund(2),OSAPPHIRE,rnd(3*j+1)+2);
32936981Sbostic }
33036981Sbostic for (i=0; i<rnd(4)+3; i++)
33136981Sbostic fillroom(OPOTION,newpotion()); /* make a POTION */
33236981Sbostic for (i=0; i<rnd(5)+3; i++)
33336981Sbostic fillroom(OSCROLL,newscroll()); /* make a SCROLL */
33436981Sbostic for (i=0; i<rnd(12)+11; i++)
33536981Sbostic fillroom(OGOLDPILE,12*rnd(j+1)+(j<<3)+10); /* make GOLD */
33636981Sbostic if (j==5) fillroom(OBANK2,0); /* branch office of the bank */
33736981Sbostic froom(2,ORING,0); /* a ring mail */
33836981Sbostic froom(1,OSTUDLEATHER,0); /* a studded leather */
33936981Sbostic froom(3,OSPLINT,0); /* a splint mail */
34036981Sbostic froom(5,OSHIELD,rund(3)); /* a shield */
34136981Sbostic froom(2,OBATTLEAXE,rund(3)); /* a battle axe */
34236981Sbostic froom(5,OLONGSWORD,rund(3)); /* a long sword */
34336981Sbostic froom(5,OFLAIL,rund(3)); /* a flail */
34436981Sbostic froom(4,OREGENRING,rund(3)); /* ring of regeneration */
34536981Sbostic froom(1,OPROTRING,rund(3)); /* ring of protection */
34636981Sbostic froom(2,OSTRRING,4); /* ring of strength + 4 */
34736981Sbostic froom(7,OSPEAR,rnd(5)); /* a spear */
34836981Sbostic froom(3,OORBOFDRAGON,0); /* orb of dragon slaying*/
34936981Sbostic froom(4,OSPIRITSCARAB,0); /*scarab of negate spirit*/
35036981Sbostic froom(4,OCUBEofUNDEAD,0); /* cube of undead control */
35136981Sbostic froom(2,ORINGOFEXTRA,0); /* ring of extra regen */
35236981Sbostic froom(3,ONOTHEFT,0); /* device of antitheft */
35336981Sbostic froom(2,OSWORDofSLASHING,0); /* sword of slashing */
35436981Sbostic if (c[BESSMANN]==0)
35536981Sbostic {
35636981Sbostic froom(4,OHAMMER,0);/*Bessman's flailing hammer*/ c[BESSMANN]=1;
35736981Sbostic }
35836981Sbostic if (c[HARDGAME]<3 || (rnd(4)==3))
35936981Sbostic {
36036981Sbostic if (j>3)
36136981Sbostic {
36236981Sbostic froom(3,OSWORD,3); /* sunsword + 3 */
36336981Sbostic froom(5,O2SWORD,rnd(4)); /* a two handed sword */
36436981Sbostic froom(3,OBELT,4); /* belt of striking */
36536981Sbostic froom(3,OENERGYRING,3); /* energy ring */
36636981Sbostic froom(4,OPLATE,5); /* platemail + 5 */
36736981Sbostic }
36836981Sbostic }
36936981Sbostic }
37036981Sbostic
37136981Sbostic /*
37236981Sbostic subroutine to fill in a number of objects of the same kind
37336981Sbostic */
37436981Sbostic
fillmroom(n,what,arg)37536981Sbostic fillmroom(n,what,arg)
37636981Sbostic int n,arg;
37736981Sbostic char what;
37836981Sbostic {
37936981Sbostic register int i;
38036981Sbostic for (i=0; i<n; i++) fillroom(what,arg);
38136981Sbostic }
froom(n,itm,arg)38236981Sbostic froom(n,itm,arg)
38336981Sbostic int n,arg;
38436981Sbostic char itm;
38536981Sbostic { if (rnd(151) < n) fillroom(itm,arg); }
38636981Sbostic
38736981Sbostic /*
38836981Sbostic subroutine to put an object into an empty room
38936981Sbostic * uses a random walk
39036981Sbostic */
391*46749Sbostic static void
fillroom(what,arg)392*46749Sbostic fillroom(what,arg)
39336981Sbostic int arg;
39436981Sbostic char what;
39536981Sbostic {
39636981Sbostic register int x,y;
39736981Sbostic
39836981Sbostic #ifdef EXTRA
39936981Sbostic c[FILLROOM]++;
40036981Sbostic #endif
40136981Sbostic
40236981Sbostic x=rnd(MAXX-2); y=rnd(MAXY-2);
40336981Sbostic while (item[x][y])
40436981Sbostic {
40536981Sbostic
40636981Sbostic #ifdef EXTRA
40736981Sbostic c[RANDOMWALK]++; /* count up these random walks */
40836981Sbostic #endif
40936981Sbostic
41036981Sbostic x += rnd(3)-2; y += rnd(3)-2;
41136981Sbostic if (x > MAXX-2) x=1; if (x < 1) x=MAXX-2;
41236981Sbostic if (y > MAXY-2) y=1; if (y < 1) y=MAXY-2;
41336981Sbostic }
41436981Sbostic item[x][y]=what; iarg[x][y]=arg;
41536981Sbostic }
41636981Sbostic
41736981Sbostic /*
41836981Sbostic subroutine to put monsters into an empty room without walls or other
41936981Sbostic monsters
42036981Sbostic */
fillmonst(what)42136981Sbostic fillmonst(what)
42236981Sbostic char what;
42336981Sbostic {
42436981Sbostic register int x,y,trys;
42536981Sbostic for (trys=5; trys>0; --trys) /* max # of creation attempts */
42636981Sbostic {
42736981Sbostic x=rnd(MAXX-2); y=rnd(MAXY-2);
42836981Sbostic if ((item[x][y]==0) && (mitem[x][y]==0) && ((playerx!=x) || (playery!=y)))
42936981Sbostic {
43036981Sbostic mitem[x][y] = what; know[x][y]=0;
43136981Sbostic hitp[x][y] = monster[what].hitpoints; return(0);
43236981Sbostic }
43336981Sbostic }
43436981Sbostic return(-1); /* creation failure */
43536981Sbostic }
43636981Sbostic
43736981Sbostic /*
43836981Sbostic creates an entire set of monsters for a level
43936981Sbostic must be done when entering a new level
44036981Sbostic if sethp(1) then wipe out old monsters else leave them there
44136981Sbostic */
sethp(flg)44236981Sbostic sethp(flg)
44336981Sbostic int flg;
44436981Sbostic {
44536981Sbostic register int i,j;
44636981Sbostic if (flg) for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) stealth[j][i]=0;
44736981Sbostic if (level==0) { c[TELEFLAG]=0; return; } /* if teleported and found level 1 then know level we are on */
44836981Sbostic if (flg) j = rnd(12) + 2 + (level>>1); else j = (level>>1) + 1;
44936981Sbostic for (i=0; i<j; i++) fillmonst(makemonst(level));
45036981Sbostic positionplayer();
45136981Sbostic }
45236981Sbostic
45336981Sbostic /*
45436981Sbostic * Function to destroy all genocided monsters on the present level
45536981Sbostic */
checkgen()45636981Sbostic checkgen()
45736981Sbostic {
45836981Sbostic register int x,y;
45936981Sbostic for (y=0; y<MAXY; y++)
46036981Sbostic for (x=0; x<MAXX; x++)
46136981Sbostic if (monster[mitem[x][y]].genocided)
46236981Sbostic mitem[x][y]=0; /* no more monster */
46336981Sbostic }
464