1 /* NetHack 3.6 vault.c $NHDT-Date: 1452132199 2016/01/07 02:03:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.42 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
7 STATIC_DCL
struct monst
*NDECL(findgd
);
9 STATIC_DCL boolean
FDECL(clear_fcorr
, (struct monst
*, BOOLEAN_P
));
10 STATIC_DCL
void FDECL(blackout
, (int, int));
11 STATIC_DCL
void FDECL(restfakecorr
, (struct monst
*));
12 STATIC_DCL boolean
FDECL(in_fcorridor
, (struct monst
*, int, int));
13 STATIC_DCL
void FDECL(move_gold
, (struct obj
*, int));
14 STATIC_DCL
void FDECL(wallify_vault
, (struct monst
*));
21 mtmp
->mextra
= newmextra();
23 EGD(mtmp
) = (struct egd
*) alloc(sizeof(struct egd
));
24 (void) memset((genericptr_t
) EGD(mtmp
), 0, sizeof(struct egd
));
32 if (mtmp
->mextra
&& EGD(mtmp
)) {
33 free((genericptr_t
) EGD(mtmp
));
34 EGD(mtmp
) = (struct egd
*) 0;
40 clear_fcorr(grd
, forceshow
)
44 register int fcx
, fcy
, fcbeg
;
46 boolean sawcorridor
= FALSE
;
47 struct egd
*egrd
= EGD(grd
);
51 if (!on_level(&egrd
->gdlevel
, &u
.uz
))
54 while ((fcbeg
= egrd
->fcbeg
) < egrd
->fcend
) {
55 fcx
= egrd
->fakecorr
[fcbeg
].fx
;
56 fcy
= egrd
->fakecorr
[fcbeg
].fy
;
57 if ((grd
->mhp
<= 0 || !in_fcorridor(grd
, u
.ux
, u
.uy
)) && egrd
->gddone
)
59 if ((u
.ux
== fcx
&& u
.uy
== fcy
&& grd
->mhp
> 0)
60 || (!forceshow
&& couldsee(fcx
, fcy
))
61 || (Punished
&& !carried(uball
) && uball
->ox
== fcx
65 if ((mtmp
= m_at(fcx
, fcy
)) != 0) {
68 } else if (!in_fcorridor(grd
, u
.ux
, u
.uy
)) {
71 (void) rloc(mtmp
, FALSE
);
74 lev
= &levl
[fcx
][fcy
];
75 if (lev
->typ
== CORR
&& cansee(fcx
, fcy
))
77 lev
->typ
= egrd
->fakecorr
[fcbeg
].ftyp
;
78 if (IS_STWALL(lev
->typ
)) {
79 /* destroy any trap here (pit dug by you, hole dug via
80 wand while levitating or by monster, bear trap or land
81 mine via object, spun web) when spot reverts to stone */
82 if ((trap
= t_at(fcx
, fcy
)) != 0)
84 /* undo scroll/wand/spell of light affecting this spot */
85 if (lev
->typ
== STONE
)
88 map_location(fcx
, fcy
, 1); /* bypass vision */
89 if (!ACCESSIBLE(lev
->typ
))
90 block_point(fcx
, fcy
);
91 vision_full_recalc
= 1;
95 pline_The("corridor disappears.");
96 if (IS_ROCK(levl
[u
.ux
][u
.uy
].typ
))
97 You("are encased in rock.");
101 /* as a temporary corridor is removed, set stone locations and adjacent
102 spots to unlit; if player used scroll/wand/spell of light while inside
103 the corridor, we don't want the light to reappear if/when a new tunnel
104 goes through the same area */
112 for (i
= x
- 1; i
<= x
+ 1; ++i
)
113 for (j
= y
- 1; j
<= y
+ 1; ++j
) {
117 /* [possible bug: when (i != x || j != y), perhaps we ought
118 to check whether the spot on the far side is lit instead
119 of doing a blanket blackout of adjacent locations] */
120 if (lev
->typ
== STONE
)
121 lev
->lit
= lev
->waslit
= 0;
122 /* mark <i,j> as not having been seen from <x,y> */
123 unset_seenv(lev
, x
, y
, i
, j
);
131 /* it seems you left the corridor - let the guard disappear */
132 if (clear_fcorr(grd
, FALSE
)) {
133 grd
->isgd
= 0; /* dmonsfree() should delete this mon */
138 /* called in mon.c */
143 boolean dispose
= clear_fcorr(grd
, TRUE
);
146 /* destroy guard's gold; drop any other inventory */
147 relobj(grd
, 0, FALSE
);
148 /* guard is dead; monster traversal loops should skip it */
150 if (grd
== context
.polearm
.hitmon
)
151 context
.polearm
.hitmon
= 0;
152 /* see comment by newpos in gd_move() */
153 remove_monster(grd
->mx
, grd
->my
);
154 newsym(grd
->mx
, grd
->my
);
155 place_monster(grd
, 0, 0);
156 EGD(grd
)->ogx
= grd
->mx
;
157 EGD(grd
)->ogy
= grd
->my
;
158 dispose
= clear_fcorr(grd
, TRUE
);
161 grd
->isgd
= 0; /* for dmonsfree() */
166 in_fcorridor(grd
, x
, y
)
171 struct egd
*egrd
= EGD(grd
);
173 for (fci
= egrd
->fcbeg
; fci
< egrd
->fcend
; fci
++)
174 if (x
== egrd
->fakecorr
[fci
].fx
&& y
== egrd
->fakecorr
[fci
].fy
)
183 register struct monst
*mtmp
;
185 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
186 if (DEADMONSTER(mtmp
))
188 if (mtmp
->isgd
&& on_level(&(EGD(mtmp
)->gdlevel
), &u
.uz
))
191 return (struct monst
*) 0;
195 vault_occupied(array
)
200 for (ptr
= array
; *ptr
; ptr
++)
201 if (rooms
[*ptr
- ROOMOFFSET
].rtype
== VAULT
)
210 int dummy
; /* hack to avoid schain botch */
214 int trycount
, vaultroom
= (int) vault_occupied(u
.urooms
);
221 vaultroom
-= ROOMOFFSET
;
224 if (++u
.uinvault
% 30 == 0 && !guard
) { /* if time ok and no guard now. */
226 register int x
, y
, dd
, gx
, gy
;
230 /* first find the goal for the guard */
231 for (dd
= 2; (dd
< ROWNO
|| dd
< COLNO
); dd
++) {
232 for (y
= u
.uy
- dd
; y
<= u
.uy
+ dd
; ly
= y
, y
++) {
233 if (y
< 0 || y
> ROWNO
- 1)
235 for (x
= u
.ux
- dd
; x
<= u
.ux
+ dd
; lx
= x
, x
++) {
236 if (y
!= u
.uy
- dd
&& y
!= u
.uy
+ dd
&& x
!= u
.ux
- dd
)
238 if (x
< 1 || x
> COLNO
- 1)
240 if (levl
[x
][y
].typ
== CORR
) {
253 if (levl
[lx
][ly
].typ
!= STONE
254 && levl
[lx
][ly
].typ
!= CORR
)
263 impossible("Not a single corridor on this level??");
270 /* next find a good place for a door in the wall */
273 if (levl
[x
][y
].typ
!= ROOM
) { /* player dug a door and is in it */
274 if (levl
[x
+ 1][y
].typ
== ROOM
)
276 else if (levl
[x
][y
+ 1].typ
== ROOM
)
278 else if (levl
[x
- 1][y
].typ
== ROOM
)
280 else if (levl
[x
][y
- 1].typ
== ROOM
)
282 else if (levl
[x
+ 1][y
+ 1].typ
== ROOM
) {
285 } else if (levl
[x
- 1][y
- 1].typ
== ROOM
) {
288 } else if (levl
[x
+ 1][y
- 1].typ
== ROOM
) {
291 } else if (levl
[x
- 1][y
+ 1].typ
== ROOM
) {
296 while (levl
[x
][y
].typ
== ROOM
) {
299 dx
= (gx
> x
) ? 1 : (gx
< x
) ? -1 : 0;
300 dy
= (gy
> y
) ? 1 : (gy
< y
) ? -1 : 0;
301 if (abs(gx
- x
) >= abs(gy
- y
))
306 if (x
== u
.ux
&& y
== u
.uy
) {
307 if (levl
[x
+ 1][y
].typ
== HWALL
|| levl
[x
+ 1][y
].typ
== DOOR
)
309 else if (levl
[x
- 1][y
].typ
== HWALL
310 || levl
[x
- 1][y
].typ
== DOOR
)
312 else if (levl
[x
][y
+ 1].typ
== VWALL
313 || levl
[x
][y
+ 1].typ
== DOOR
)
315 else if (levl
[x
][y
- 1].typ
== VWALL
316 || levl
[x
][y
- 1].typ
== DOOR
)
322 /* make something interesting happen */
323 if (!(guard
= makemon(&mons
[PM_GUARD
], x
, y
, MM_EGD
)))
326 guard
->mpeaceful
= 1;
328 EGD(guard
)->gddone
= 0;
331 assign_level(&(EGD(guard
)->gdlevel
), &u
.uz
);
332 EGD(guard
)->vroom
= vaultroom
;
333 EGD(guard
)->warncnt
= 0;
335 reset_faint(); /* if fainted - wake up */
336 gsensed
= !canspotmon(guard
);
338 pline("Suddenly one of the Vault's %s enters!",
339 makeplural(guard
->data
->mname
));
341 pline("Someone else has entered the Vault.");
342 newsym(guard
->mx
, guard
->my
);
344 /* can't interrogate hero, don't interrogate engulfer */
345 if (!Deaf
) verbalize("What's going on here?");
347 pline_The("other presence vanishes.");
351 if (youmonst
.m_ap_type
== M_AP_OBJECT
|| u
.uundetected
) {
352 if (youmonst
.m_ap_type
== M_AP_OBJECT
353 && youmonst
.mappearance
!= GOLD_PIECE
)
354 if (!Deaf
) verbalize("Hey! Who left that %s in here?",
355 mimic_obj_name(&youmonst
));
356 /* You're mimicking some object or you're hidden. */
357 pline("Puzzled, %s turns around and leaves.", mhe(guard
));
361 if (Strangled
|| is_silent(youmonst
.data
) || multi
< 0) {
362 /* [we ought to record whether this this message has already
363 been given in order to vary it upon repeat visits, but
364 discarding the monster and its egd data renders that hard] */
366 pline("%s huffs and turns to leave.", noit_Monnam(guard
));
368 verbalize("I'll be back when you're ready to speak to me!");
373 stop_occupation(); /* if occupied, stop it *now* */
380 getlin(Deaf
? "You are required to supply your name. -"
381 : "\"Hello stranger, who are you?\" -", buf
);
382 (void) mungspaces(buf
);
383 } while (!buf
[0] && --trycount
> 0);
385 if (u
.ualign
.type
== A_LAWFUL
386 /* ignore trailing text, in case player includes rank */
387 && strncmpi(buf
, plname
, (int) strlen(plname
)) != 0) {
388 adjalign(-1); /* Liar! */
391 if (!strcmpi(buf
, "Croesus") || !strcmpi(buf
, "Kroisos")
392 || !strcmpi(buf
, "Creosote")) {
393 if (!mvitals
[PM_CROESUS
].died
) {
396 pline("%s waves goodbye.", noit_Monnam(guard
));
399 "Oh, yes, of course. Sorry to have disturbed you.");
406 pline("%s mouths something and looks very angry!",
410 "Back from the dead, are you? I'll remedy that!");
412 /* don't want guard to waste next turn wielding a weapon */
413 if (!MON_WEP(guard
)) {
414 guard
->weapon_check
= NEED_HTH_WEAPON
;
415 (void) mon_wield_item(guard
);
421 pline("%s doesn't %srecognize you.", noit_Monnam(guard
),
422 (Blind
) ? "" : "appear to ");
424 verbalize("I don't know you.");
425 umoney
= money_cnt(invent
);
426 if (!umoney
&& !hidden_gold()) {
428 pline("%s stomps%s.", noit_Monnam(guard
),
429 (Blind
) ? "" : " and beckons");
431 verbalize("Please follow me.");
436 pline("%s glares at you%s.", noit_Monnam(guard
),
437 invent
? "r stuff" : "");
439 verbalize("You have hidden gold.");
445 "%s holds out %s palm and beckons with %s other hand.",
446 noit_Monnam(guard
), mhis(guard
), mhis(guard
));
449 "Most likely all your gold was stolen from this vault.");
450 verbalize("Please drop that gold and follow me.");
453 EGD(guard
)->gdx
= gx
;
454 EGD(guard
)->gdy
= gy
;
455 EGD(guard
)->fcbeg
= 0;
456 EGD(guard
)->fakecorr
[0].fx
= x
;
457 EGD(guard
)->fakecorr
[0].fy
= y
;
458 if (IS_WALL(levl
[x
][y
].typ
))
459 EGD(guard
)->fakecorr
[0].ftyp
= levl
[x
][y
].typ
;
460 else { /* the initial guard location is a dug door */
461 int vlt
= EGD(guard
)->vroom
;
462 xchar lowx
= rooms
[vlt
].lx
, hix
= rooms
[vlt
].hx
;
463 xchar lowy
= rooms
[vlt
].ly
, hiy
= rooms
[vlt
].hy
;
465 if (x
== lowx
- 1 && y
== lowy
- 1)
466 EGD(guard
)->fakecorr
[0].ftyp
= TLCORNER
;
467 else if (x
== hix
+ 1 && y
== lowy
- 1)
468 EGD(guard
)->fakecorr
[0].ftyp
= TRCORNER
;
469 else if (x
== lowx
- 1 && y
== hiy
+ 1)
470 EGD(guard
)->fakecorr
[0].ftyp
= BLCORNER
;
471 else if (x
== hix
+ 1 && y
== hiy
+ 1)
472 EGD(guard
)->fakecorr
[0].ftyp
= BRCORNER
;
473 else if (y
== lowy
- 1 || y
== hiy
+ 1)
474 EGD(guard
)->fakecorr
[0].ftyp
= HWALL
;
475 else if (x
== lowx
- 1 || x
== hix
+ 1)
476 EGD(guard
)->fakecorr
[0].ftyp
= VWALL
;
478 levl
[x
][y
].typ
= DOOR
;
479 levl
[x
][y
].doormask
= D_NODOOR
;
480 unblock_point(x
, y
); /* doesn't block light */
481 EGD(guard
)->fcend
= 1;
482 EGD(guard
)->warncnt
= 1;
487 move_gold(gold
, vroom
)
494 newsym(gold
->ox
, gold
->oy
);
495 nx
= rooms
[vroom
].lx
+ rn2(2);
496 ny
= rooms
[vroom
].ly
+ rn2(2);
497 place_object(gold
, nx
, ny
);
507 int vlt
= EGD(grd
)->vroom
;
509 xchar lox
= rooms
[vlt
].lx
- 1, hix
= rooms
[vlt
].hx
+ 1,
510 loy
= rooms
[vlt
].ly
- 1, hiy
= rooms
[vlt
].hy
+ 1;
514 boolean fixed
= FALSE
;
515 boolean movedgold
= FALSE
;
517 for (x
= lox
; x
<= hix
; x
++)
518 for (y
= loy
; y
<= hiy
; y
++) {
519 /* if not on the room boundary, skip ahead */
520 if (x
!= lox
&& x
!= hix
&& y
!= loy
&& y
!= hiy
)
523 if (!IS_WALL(levl
[x
][y
].typ
) && !in_fcorridor(grd
, x
, y
)) {
524 if ((mon
= m_at(x
, y
)) != 0 && mon
!= grd
) {
527 (void) rloc(mon
, FALSE
);
529 if ((gold
= g_at(x
, y
)) != 0) {
530 move_gold(gold
, EGD(grd
)->vroom
);
533 if ((trap
= t_at(x
, y
)) != 0)
537 (y
== loy
) ? TLCORNER
: (y
== hiy
) ? BLCORNER
: VWALL
;
540 (y
== loy
) ? TRCORNER
: (y
== hiy
) ? BRCORNER
: VWALL
;
541 else /* not left or right side, must be top or bottom */
543 levl
[x
][y
].typ
= typ
;
544 levl
[x
][y
].doormask
= 0;
546 * hack: player knows walls are restored because of the
547 * message, below, so show this on the screen.
549 tmp_viz
= viz_array
[y
][x
];
550 viz_array
[y
][x
] = IN_SIGHT
| COULD_SEE
;
552 viz_array
[y
][x
] = tmp_viz
;
558 if (movedgold
|| fixed
) {
559 if (in_fcorridor(grd
, grd
->mx
, grd
->my
) || cansee(grd
->mx
, grd
->my
))
560 pline("%s whispers an incantation.", noit_Monnam(grd
));
562 You_hear("a distant chant.");
564 pline("A mysterious force moves the gold into the vault.");
566 pline_The("damaged vault's walls are magically restored!");
571 * return 1: guard moved, 0: guard didn't, -1: let m_move do it, -2: died
575 register struct monst
*grd
;
577 int x
, y
, nx
, ny
, m
, n
;
578 int dx
, dy
, gx
, gy
, fci
;
580 struct fakecorridor
*fcp
;
581 register struct egd
*egrd
= EGD(grd
);
583 boolean goldincorridor
= FALSE
,
584 u_in_vault
= vault_occupied(u
.urooms
) ? TRUE
: FALSE
,
585 grd_in_vault
= *in_rooms(grd
->mx
, grd
->my
, VAULT
) ? TRUE
: FALSE
;
586 boolean disappear_msg_seen
= FALSE
, semi_dead
= (grd
->mhp
<= 0);
587 long umoney
= money_cnt(invent
);
588 register boolean u_carry_gold
= ((umoney
+ hidden_gold()) > 0L);
589 boolean see_guard
, newspot
= FALSE
;
591 if (!on_level(&(egrd
->gdlevel
), &u
.uz
))
594 if (!u_in_vault
&& !grd_in_vault
)
596 if (!grd
->mpeaceful
) {
602 && (grd_in_vault
|| (in_fcorridor(grd
, grd
->mx
, grd
->my
)
603 && !in_fcorridor(grd
, u
.ux
, u
.uy
)))) {
604 (void) rloc(grd
, FALSE
);
606 (void) clear_fcorr(grd
, TRUE
);
609 if (!in_fcorridor(grd
, grd
->mx
, grd
->my
))
610 (void) clear_fcorr(grd
, TRUE
);
613 if (abs(egrd
->ogx
- grd
->mx
) > 1 || abs(egrd
->ogy
- grd
->my
) > 1)
614 return -1; /* teleported guard - treat as monster */
618 verbalize("How dare you %s that gold, scoundrel!",
619 (egrd
->witness
& GD_EATGOLD
) ? "consume" : "destroy");
624 if (egrd
->fcend
== 1) {
625 if (u_in_vault
&& (u_carry_gold
|| um_dist(grd
->mx
, grd
->my
, 1))) {
626 if (egrd
->warncnt
== 3 && !Deaf
)
627 verbalize("I repeat, %sfollow me!",
629 ? (!umoney
? "drop that hidden money and "
630 : "drop that money and ")
632 if (egrd
->warncnt
== 7) {
636 verbalize("You've been warned, knave!");
638 levl
[m
][n
].typ
= egrd
->fakecorr
[0].ftyp
;
643 /* not fair to get mad when (s)he's fainted or paralyzed */
644 if (!is_fainted() && multi
>= 0)
650 if (u_carry_gold
) { /* player teleported */
653 (void) rloc(grd
, TRUE
);
654 levl
[m
][n
].typ
= egrd
->fakecorr
[0].ftyp
;
658 if (!cansee(grd
->mx
, grd
->my
) || !mon_visible(grd
))
659 You_hear("the shrill sound of a guard's whistle.");
661 You(um_dist(grd
->mx
, grd
->my
, 2)
662 ? "see %s approaching."
663 : "are confronted by %s.",
664 /* "an angry guard" */
665 x_monnam(grd
, ARTICLE_A
, "angry", 0, FALSE
));
669 verbalize("Well, begone.");
677 if (egrd
->fcend
> 1) {
678 if (egrd
->fcend
> 2 && in_fcorridor(grd
, grd
->mx
, grd
->my
)
679 && !egrd
->gddone
&& !in_fcorridor(grd
, u
.ux
, u
.uy
)
680 && levl
[egrd
->fakecorr
[0].fx
][egrd
->fakecorr
[0].fy
].typ
681 == egrd
->fakecorr
[0].ftyp
) {
682 pline("%s, confused, disappears.", noit_Monnam(grd
));
683 disappear_msg_seen
= TRUE
;
686 if (u_carry_gold
&& (in_fcorridor(grd
, u
.ux
, u
.uy
)
687 /* cover a 'blind' spot */
688 || (egrd
->fcend
> 1 && u_in_vault
))) {
693 if (egrd
->warncnt
< 6) {
697 pline("%s holds out %s palm demandingly!",
698 noit_Monnam(grd
), mhis(grd
));
700 verbalize("Drop all your gold, scoundrel!");
706 pline("%s rubs %s hands with enraged delight!",
707 noit_Monnam(grd
), mhis(grd
));
709 verbalize("So be it, rogue!");
716 for (fci
= egrd
->fcbeg
; fci
< egrd
->fcend
; fci
++)
717 if (g_at(egrd
->fakecorr
[fci
].fx
, egrd
->fakecorr
[fci
].fy
)) {
718 m
= egrd
->fakecorr
[fci
].fx
;
719 n
= egrd
->fakecorr
[fci
].fy
;
720 goldincorridor
= TRUE
;
722 if (goldincorridor
&& !egrd
->gddone
) {
725 if (m
== u
.ux
&& n
== u
.uy
) {
726 struct obj
*gold
= g_at(m
, n
);
727 /* Grab the gold from between the hero's feet. */
728 obj_extract_self(gold
);
729 add_to_minv(grd
, gold
);
731 } else if (m
== x
&& n
== y
) {
732 mpickgold(grd
); /* does a newsym */
734 /* just for insurance... */
735 if (MON_AT(m
, n
) && m
!= grd
->mx
&& n
!= grd
->my
) {
737 verbalize("Out of my way, scum!");
738 (void) rloc(m_at(m
, n
), FALSE
);
740 remove_monster(grd
->mx
, grd
->my
);
741 newsym(grd
->mx
, grd
->my
);
742 place_monster(grd
, m
, n
);
743 mpickgold(grd
); /* does a newsym */
746 pline("%s%s picks up the gold.", Monnam(grd
),
747 grd
->mpeaceful
? " calms down and" : "");
748 if (x
!= grd
->mx
|| y
!= grd
->my
) {
749 remove_monster(grd
->mx
, grd
->my
);
750 newsym(grd
->mx
, grd
->my
);
751 place_monster(grd
, x
, y
);
759 if (um_dist(grd
->mx
, grd
->my
, 1) || egrd
->gddone
) {
760 if (!egrd
->gddone
&& !rn2(10) && !Deaf
&& !u
.uswallow
761 && !(u
.ustuck
&& !sticks(youmonst
.data
)))
762 verbalize("Move along!");
764 return 0; /* didn't move */
772 /* look around (hor & vert only) for accessible places */
773 for (nx
= x
- 1; nx
<= x
+ 1; nx
++)
774 for (ny
= y
- 1; ny
<= y
+ 1; ny
++) {
775 if ((nx
== x
|| ny
== y
) && (nx
!= x
|| ny
!= y
)
777 typ
= (crm
= &levl
[nx
][ny
])->typ
;
778 if (!IS_STWALL(typ
) && !IS_POOL(typ
)) {
779 if (in_fcorridor(grd
, nx
, ny
))
782 if (*in_rooms(nx
, ny
, VAULT
))
785 /* seems we found a good place to leave him alone */
795 crm
->typ
= (typ
== SCORR
) ? CORR
: DOOR
;
797 if (crm
->typ
== DOOR
)
798 crm
->doormask
= D_NODOOR
;
810 dx
= (gx
> x
) ? 1 : (gx
< x
) ? -1 : 0;
811 dy
= (gy
> y
) ? 1 : (gy
< y
) ? -1 : 0;
812 if (abs(gx
- x
) >= abs(gy
- y
))
817 while ((typ
= (crm
= &levl
[nx
][ny
])->typ
) != 0) {
818 /* in view of the above we must have IS_WALL(typ) or typ == POOL */
819 /* must be a wall here */
820 if (isok(nx
+ nx
- x
, ny
+ ny
- y
) && !IS_POOL(typ
)
821 && IS_ROOM(levl
[nx
+ nx
- x
][ny
+ ny
- y
].typ
)) {
823 crm
->doormask
= D_NODOOR
;
837 /* I don't like this, but ... */
840 crm
->doormask
= D_NODOOR
;
848 unblock_point(nx
, ny
); /* doesn't block light */
852 fcp
= &(egrd
->fakecorr
[egrd
->fcend
]);
853 if (egrd
->fcend
++ == FCSIZ
)
854 panic("fakecorr overflow");
860 /* The following is a kludge. We need to keep */
861 /* the guard around in order to be able to make */
862 /* the fake corridor disappear as the player */
863 /* moves out of it, but we also need the guard */
864 /* out of the way. We send the guard to never- */
865 /* never land. We set ogx ogy to mx my in order */
866 /* to avoid a check at the top of this function. */
867 /* At the end of the process, the guard is killed */
868 /* in restfakecorr(). */
873 see_guard
= canspotmon(grd
);
875 remove_monster(grd
->mx
, grd
->my
);
876 newsym(grd
->mx
, grd
->my
);
877 place_monster(grd
, 0, 0);
881 if (!semi_dead
&& (in_fcorridor(grd
, u
.ux
, u
.uy
) || cansee(x
, y
))) {
882 if (!disappear_msg_seen
&& see_guard
)
883 pline("Suddenly, %s disappears.", noit_mon_nam(grd
));
888 egrd
->ogx
= grd
->mx
; /* update old positions */
890 remove_monster(grd
->mx
, grd
->my
);
891 place_monster(grd
, nx
, ny
);
892 if (newspot
&& g_at(nx
, ny
)) {
893 /* if there's gold already here (most likely from mineralize()),
894 pick it up now so that guard doesn't later think hero dropped
895 it and give an inappropriate message */
898 pline("%s picks up some gold.", Monnam(grd
));
900 newsym(grd
->mx
, grd
->my
);
905 /* Routine when dying or quitting with a vault guard around */
909 register struct monst
*grd
= findgd();
910 long umoney
= money_cnt(invent
);
911 struct obj
*coins
, *nextcoins
;
919 Your("%ld %s goes into the Magic Memory Vault.", umoney
,
924 if (grd
->mpeaceful
) { /* guard has no "right" to your gold */
929 pline("%s remits your gold to the vault.", Monnam(grd
));
930 gx
= rooms
[EGD(grd
)->vroom
].lx
+ rn2(2);
931 gy
= rooms
[EGD(grd
)->vroom
].ly
+ rn2(2);
932 Sprintf(buf
, "To Croesus: here's the gold recovered from %s the %s.",
933 plname
, mons
[u
.umonster
].mname
);
934 make_grave(gx
, gy
, buf
);
936 for (coins
= invent
; coins
; coins
= nextcoins
) {
937 nextcoins
= coins
->nobj
;
938 if (objects
[coins
->otyp
].oc_class
== COIN_CLASS
) {
940 place_object(coins
, gx
, gy
);
953 for (obj
= invent
; obj
; obj
= obj
->nobj
)
954 if (Has_contents(obj
))
955 value
+= contained_gold(obj
);
956 /* unknown gold stuck inside statues may cause some consternation... */
961 /* prevent "You hear footsteps.." when inappropriate */
965 struct monst
*grd
= findgd();
967 if (vault_occupied(u
.urooms
))
970 return (boolean
) (grd
== (struct monst
*) 0);
974 vault_gd_watching(activity
)
975 unsigned int activity
;
977 struct monst
*guard
= findgd();
979 if (guard
&& guard
->mcansee
&& m_canseeu(guard
)) {
980 if (activity
== GD_EATGOLD
|| activity
== GD_DESTROYGOLD
)
981 EGD(guard
)->witness
= activity
;