/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.vault.c - version 1.0.2 */
setgd(/* mtmp */) /* struct monst *mtmp; */ {}
gddead(mtmp
) struct monst
*mtmp
; {}
replgd(mtmp
,mtmp2
) struct monst
*mtmp
, *mtmp2
; {}
extern struct monst
*makemon();
#define FCSIZ (ROWNO+COLNO)
int fcbeg
, fcend
; /* fcend: first unused pos */
xchar gdx
, gdy
; /* goal of guard's walk */
struct fakecorridor fakecorr
[FCSIZ
];
static struct permonst pm_guard
=
{ "guard", '@', 12, 12, -1, 4, 10, sizeof(struct egd
) };
static struct monst
*guard
;
#define EGD ((struct egd *)(&(guard->mextra[0])))
while((fcbeg
= EGD
->fcbeg
) < EGD
->fcend
) {
fcx
= EGD
->fakecorr
[fcbeg
].fx
;
fcy
= EGD
->fakecorr
[fcbeg
].fy
;
if((u
.ux
== fcx
&& u
.uy
== fcy
) || cansee(fcx
,fcy
) ||
crm
->typ
= EGD
->fakecorr
[fcbeg
].ftyp
;
if(!crm
->typ
) crm
->seen
= 0;
/* it seems he left the corridor - let the guard disappear */
for(fci
= EGD
->fcbeg
; fci
< EGD
->fcend
; fci
++)
if(g_at(EGD
->fakecorr
[fci
].fx
, EGD
->fakecorr
[fci
].fy
))
register struct monst
*mtmp
;
for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) if(mtmp
->isgd
){
register tmp
= inroom(u
.ux
, u
.uy
);
if(tmp
< 0 || rooms
[tmp
].rtype
!= VAULT
) {
if(++u
.uinvault
% 50 == 0 && (!guard
|| gdlevel
!= dlevel
)) {
/* first find the goal for the guard */
for(dd
= 1; (dd
< ROWNO
|| dd
< COLNO
); dd
++) {
for(y
= u
.uy
-dd
; y
<= u
.uy
+dd
; y
++) {
if(y
< 0 || y
> ROWNO
-1) continue;
for(x
= u
.ux
-dd
; x
<= u
.ux
+dd
; x
++) {
if(y
!= u
.uy
-dd
&& y
!= u
.uy
+dd
&& x
!= u
.ux
-dd
)
if(x
< 0 || x
> COLNO
-1) continue;
if(levl
[x
][y
].typ
== CORR
) goto fnd
;
impossible("Not a single corridor on this level??");
/* next find a good place for a door in the wall */
while(levl
[x
][y
].typ
== ROOM
) {
dx
= (gx
> x
) ? 1 : (gx
< x
) ? -1 : 0;
dy
= (gy
> y
) ? 1 : (gy
< y
) ? -1 : 0;
if(abs(gx
-x
) >= abs(gy
-y
))
/* make something interesting happen */
if(!(guard
= makemon(&pm_guard
,x
,y
))) return;
guard
->isgd
= guard
->mpeaceful
= 1;
if(!cansee(guard
->mx
, guard
->my
)) {
pline("Suddenly one of the Vault's guards enters!");
pline("\"Hello stranger, who are you?\" - ");
} while (!letter(buf
[0]));
if(!strcmp(buf
, "Croesus") || !strcmp(buf
, "Kroisos")) {
pline("\"Oh, yes - of course. Sorry to have disturbed you.\"");
pline("\"I don't know you.\"");
pline("\"Please follow me.\"");
pline("\"Most likely all that gold was stolen from this vault.\"");
pline("\"Please drop your gold (say d$ ) and follow me.\"");
EGD
->fakecorr
[0].ftyp
= levl
[x
][y
].typ
;
register int x
,y
,dx
,dy
,gx
,gy
,nx
,ny
,typ
;
register struct fakecorridor
*fcp
;
if(!guard
|| gdlevel
!= dlevel
){
impossible("Where is the guard?");
if(u
.ugold
|| goldincorridor())
return(0); /* didnt move */
if(dist(guard
->mx
,guard
->my
) > 1 || EGD
->gddone
) {
return(0); /* didnt move */
/* look around (hor & vert only) for accessible places */
for(nx
= x
-1; nx
<= x
+1; nx
++) for(ny
= y
-1; ny
<= y
+1; ny
++) {
if(nx
== x
|| ny
== y
) if(nx
!= x
|| ny
!= y
)
if(!IS_WALL(typ
= (crm
= &levl
[nx
][ny
])->typ
) && typ
!= POOL
) {
for(i
= EGD
->fcbeg
; i
< EGD
->fcend
; i
++)
if(EGD
->fakecorr
[i
].fx
== nx
&&
EGD
->fakecorr
[i
].fy
== ny
)
if((i
= inroom(nx
,ny
)) >= 0 && rooms
[i
].rtype
== VAULT
)
/* seems we found a good place to leave him alone */
if(ACCESSIBLE(typ
)) goto newpos
;
crm
->typ
= (typ
== SCORR
) ? CORR
: DOOR
;
dx
= (gx
> x
) ? 1 : (gx
< x
) ? -1 : 0;
dy
= (gy
> y
) ? 1 : (gy
< y
) ? -1 : 0;
if(abs(gx
-x
) >= abs(gy
-y
)) nx
+= dx
; else ny
+= dy
;
while((typ
= (crm
= &levl
[nx
][ny
])->typ
) != 0) {
/* in view of the above we must have IS_WALL(typ) or typ == POOL */
/* must be a wall here */
if(isok(nx
+nx
-x
,ny
+ny
-y
) && typ
!= POOL
&&
ZAP_POS(levl
[nx
+nx
-x
][ny
+ny
-y
].typ
)){
ny
= y
; nx
= x
+dx
; dy
= 0;
/* I don't like this, but ... */
fcp
= &(EGD
->fakecorr
[EGD
->fcend
]);
if(EGD
->fcend
++ == FCSIZ
) panic("fakecorr overflow");
if(EGD
->gddone
) nx
= ny
= 0;
register struct monst
*mtmp
, *mtmp2
;