1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.vault.c - version 1.0.2 */
7 setgd(/* mtmp */) /* struct monst *mtmp; */ {}
8 gd_move() { return(2); }
9 gddead(mtmp) struct monst *mtmp; {}
10 replgd(mtmp,mtmp2) struct monst *mtmp, *mtmp2; {}
16 #include "def.mkroom.h"
17 extern struct monst *makemon();
18 #define FCSIZ (ROWNO+COLNO)
24 int fcbeg, fcend; /* fcend: first unused pos */
25 xchar gdx, gdy; /* goal of guard's walk */
27 struct fakecorridor fakecorr[FCSIZ];
30 static struct permonst pm_guard =
31 { "guard", '@', 12, 12, -1, 4, 10, sizeof(struct egd) };
33 static struct monst *guard;
35 #define EGD ((struct egd *)(&(guard->mextra[0])))
43 while((fcbeg = EGD->fcbeg) < EGD->fcend) {
44 fcx = EGD->fakecorr[fcbeg].fx;
45 fcy = EGD->fakecorr[fcbeg].fy;
46 if((u.ux == fcx && u.uy == fcy) || cansee(fcx,fcy) ||
49 crm = &levl[fcx][fcy];
50 crm->typ = EGD->fakecorr[fcbeg].ftyp;
51 if(!crm->typ) crm->seen = 0;
55 /* it seems he left the corridor - let the guard disappear */
65 for(fci = EGD->fcbeg; fci < EGD->fcend; fci++)
66 if(g_at(EGD->fakecorr[fci].fx, EGD->fakecorr[fci].fy))
73 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(mtmp->isgd){
82 int tmp = inroom(u.ux, u.uy);
83 if(tmp < 0 || rooms[tmp].rtype != VAULT) {
87 if(++u.uinvault % 50 == 0 && (!guard || gdlevel != dlevel)) {
91 /* first find the goal for the guard */
92 for(dd = 1; (dd < ROWNO || dd < COLNO); dd++) {
93 for(y = u.uy-dd; y <= u.uy+dd; y++) {
94 if(y < 0 || y > ROWNO-1) continue;
95 for(x = u.ux-dd; x <= u.ux+dd; x++) {
96 if(y != u.uy-dd && y != u.uy+dd && x != u.ux-dd)
98 if(x < 0 || x > COLNO-1) continue;
99 if(levl[x][y].typ == CORR) goto fnd;
103 impossible("Not a single corridor on this level??");
109 /* next find a good place for a door in the wall */
111 while(levl[x][y].typ == ROOM) {
114 dx = (gx > x) ? 1 : (gx < x) ? -1 : 0;
115 dy = (gy > y) ? 1 : (gy < y) ? -1 : 0;
116 if(abs(gx-x) >= abs(gy-y))
122 /* make something interesting happen */
123 if(!(guard = makemon(&pm_guard,x,y))) return;
124 guard->isgd = guard->mpeaceful = 1;
127 if(!cansee(guard->mx, guard->my)) {
133 pline("Suddenly one of the Vault's guards enters!");
136 pline("\"Hello stranger, who are you?\" - ");
138 } while (!letter(buf[0]));
140 if(!strcmp(buf, "Croesus") || !strcmp(buf, "Kroisos")) {
141 pline("\"Oh, yes - of course. Sorry to have disturbed you.\"");
147 pline("\"I don't know you.\"");
149 pline("\"Please follow me.\"");
151 pline("\"Most likely all that gold was stolen from this vault.\"");
152 pline("\"Please drop your gold (say d$ ) and follow me.\"");
157 EGD->fakecorr[0].fx = x;
158 EGD->fakecorr[0].fy = y;
159 EGD->fakecorr[0].ftyp = levl[x][y].typ;
160 levl[x][y].typ = DOOR;
166 int x,y,dx,dy,gx,gy,nx,ny,typ;
167 struct fakecorridor *fcp;
169 if(!guard || gdlevel != dlevel){
170 impossible("Where is the guard?");
171 return(2); /* died */
173 if(u.ugold || goldincorridor())
174 return(0); /* didnt move */
175 if(dist(guard->mx,guard->my) > 1 || EGD->gddone) {
177 return(0); /* didnt move */
181 /* look around (hor & vert only) for accessible places */
182 for(nx = x-1; nx <= x+1; nx++) for(ny = y-1; ny <= y+1; ny++) {
183 if(nx == x || ny == y) if(nx != x || ny != y)
185 if(!IS_WALL(typ = (crm = &levl[nx][ny])->typ) && typ != POOL) {
187 for(i = EGD->fcbeg; i < EGD->fcend; i++)
188 if(EGD->fakecorr[i].fx == nx &&
189 EGD->fakecorr[i].fy == ny)
191 if((i = inroom(nx,ny)) >= 0 && rooms[i].rtype == VAULT)
193 /* seems we found a good place to leave him alone */
195 if(ACCESSIBLE(typ)) goto newpos;
196 crm->typ = (typ == SCORR) ? CORR : DOOR;
205 dx = (gx > x) ? 1 : (gx < x) ? -1 : 0;
206 dy = (gy > y) ? 1 : (gy < y) ? -1 : 0;
207 if(abs(gx-x) >= abs(gy-y)) nx += dx; else ny += dy;
209 while((typ = (crm = &levl[nx][ny])->typ) != 0) {
210 /* in view of the above we must have IS_WALL(typ) or typ == POOL */
211 /* must be a wall here */
212 if(isok(nx+nx-x,ny+ny-y) && typ != POOL &&
213 ZAP_POS(levl[nx+nx-x][ny+ny-y].typ)){
222 ny = y; nx = x+dx; dy = 0;
225 /* I don't like this, but ... */
235 fcp = &(EGD->fakecorr[EGD->fcend]);
236 if(EGD->fcend++ == FCSIZ) panic("fakecorr overflow");
241 if(EGD->gddone) nx = ny = 0;
254 struct monst *mtmp, *mtmp2;