1 /* SCCS Id: @(#)vault.c 3.4 2003/01/15 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
8 STATIC_DCL
struct monst
*findgd(void);
10 #define g_monnam(mtmp) \
11 x_monnam(mtmp, ARTICLE_NONE, (char *)0, SUPPRESS_IT, FALSE)
15 STATIC_DCL boolean
clear_fcorr(struct monst
*,BOOLEAN_P
);
16 STATIC_DCL
void restfakecorr(struct monst
*);
17 STATIC_DCL boolean
in_fcorridor(struct monst
*,int,int);
18 STATIC_DCL
void move_gold(struct obj
*,int);
19 STATIC_DCL
void wallify_vault(struct monst
*);
22 clear_fcorr(grd
, forceshow
)
23 register struct monst
*grd
;
24 register boolean forceshow
;
26 register int fcx
, fcy
, fcbeg
;
27 register struct monst
*mtmp
;
29 if (!on_level(&(EGD(grd
)->gdlevel
), &u
.uz
)) return TRUE
;
31 while((fcbeg
= EGD(grd
)->fcbeg
) < EGD(grd
)->fcend
) {
32 fcx
= EGD(grd
)->fakecorr
[fcbeg
].fx
;
33 fcy
= EGD(grd
)->fakecorr
[fcbeg
].fy
;
34 if((grd
->mhp
<= 0 || !in_fcorridor(grd
, u
.ux
, u
.uy
)) &&
37 if((u
.ux
== fcx
&& u
.uy
== fcy
&& grd
->mhp
> 0)
38 || (!forceshow
&& couldsee(fcx
,fcy
))
39 || (Punished
&& !carried(uball
)
40 && uball
->ox
== fcx
&& uball
->oy
== fcy
))
43 if ((mtmp
= m_at(fcx
,fcy
)) != 0) {
44 if(mtmp
->isgd
) return(FALSE
);
45 else if(!in_fcorridor(grd
, u
.ux
, u
.uy
)) {
46 if(mtmp
->mtame
) yelp(mtmp
);
47 (void) rloc(mtmp
, FALSE
);
50 levl
[fcx
][fcy
].typ
= EGD(grd
)->fakecorr
[fcbeg
].ftyp
;
51 map_location(fcx
, fcy
, 1); /* bypass vision */
52 if(!ACCESSIBLE(levl
[fcx
][fcy
].typ
)) block_point(fcx
,fcy
);
56 pline_The("corridor disappears.");
57 if(IS_ROCK(levl
[u
.ux
][u
.uy
].typ
)) You("are encased in rock.");
64 register struct monst
*grd
;
66 /* it seems you left the corridor - let the guard disappear */
67 if(clear_fcorr(grd
, FALSE
)) mongone(grd
);
71 grddead(grd
) /* called in mon.c */
72 register struct monst
*grd
;
74 register boolean dispose
= clear_fcorr(grd
, TRUE
);
77 /* see comment by newpos in gd_move() */
78 remove_monster(grd
->mx
, grd
->my
);
79 newsym(grd
->mx
, grd
->my
);
80 place_monster(grd
, 0, 0);
81 EGD(grd
)->ogx
= grd
->mx
;
82 EGD(grd
)->ogy
= grd
->my
;
83 dispose
= clear_fcorr(grd
, TRUE
);
89 in_fcorridor(grd
, x
, y
)
90 register struct monst
*grd
;
95 for(fci
= EGD(grd
)->fcbeg
; fci
< EGD(grd
)->fcend
; fci
++)
96 if(x
== EGD(grd
)->fakecorr
[fci
].fx
&&
97 y
== EGD(grd
)->fakecorr
[fci
].fy
)
106 register struct monst
*mtmp
;
108 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
109 if(mtmp
->isgd
&& !DEADMONSTER(mtmp
) && on_level(&(EGD(mtmp
)->gdlevel
), &u
.uz
))
111 return((struct monst
*)0);
118 vault_occupied(array
)
123 for (ptr
= array
; *ptr
; ptr
++)
124 if (rooms
[*ptr
- ROOMOFFSET
].rtype
== VAULT
)
133 int dummy
; /* hack to avoid schain botch */
136 int trycount
, vaultroom
= (int)vault_occupied(u
.urooms
);
143 vaultroom
-= ROOMOFFSET
;
146 if(++u
.uinvault
% 30 == 0 && !guard
) { /* if time ok and no guard now. */
148 register int x
, y
, dd
, gx
, gy
;
153 /* first find the goal for the guard */
154 for(dd
= 2; (dd
< ROWNO
|| dd
< COLNO
); dd
++) {
155 for(y
= u
.uy
-dd
; y
<= u
.uy
+dd
; ly
= y
, y
++) {
156 if(y
< 0 || y
> ROWNO
-1) continue;
157 for(x
= u
.ux
-dd
; x
<= u
.ux
+dd
; lx
= x
, x
++) {
158 if(y
!= u
.uy
-dd
&& y
!= u
.uy
+dd
&& x
!= u
.ux
-dd
)
160 if(x
< 1 || x
> COLNO
-1) continue;
161 if(levl
[x
][y
].typ
== CORR
) {
162 if(x
< u
.ux
) lx
= x
+ 1;
163 else if(x
> u
.ux
) lx
= x
- 1;
165 if(y
< u
.uy
) ly
= y
+ 1;
166 else if(y
> u
.uy
) ly
= y
- 1;
168 if(levl
[lx
][ly
].typ
!= STONE
&& levl
[lx
][ly
].typ
!= CORR
)
176 impossible("Not a single corridor on this level??");
182 /* next find a good place for a door in the wall */
184 if(levl
[x
][y
].typ
!= ROOM
) { /* player dug a door and is in it */
185 if(levl
[x
+1][y
].typ
== ROOM
) x
= x
+ 1;
186 else if(levl
[x
][y
+1].typ
== ROOM
) y
= y
+ 1;
187 else if(levl
[x
-1][y
].typ
== ROOM
) x
= x
- 1;
188 else if(levl
[x
][y
-1].typ
== ROOM
) y
= y
- 1;
189 else if(levl
[x
+1][y
+1].typ
== ROOM
) {
192 } else if (levl
[x
-1][y
-1].typ
== ROOM
) {
195 } else if (levl
[x
+1][y
-1].typ
== ROOM
) {
198 } else if (levl
[x
-1][y
+1].typ
== ROOM
) {
203 while(levl
[x
][y
].typ
== ROOM
) {
206 dx
= (gx
> x
) ? 1 : (gx
< x
) ? -1 : 0;
207 dy
= (gy
> y
) ? 1 : (gy
< y
) ? -1 : 0;
208 if(abs(gx
-x
) >= abs(gy
-y
))
213 if(x
== u
.ux
&& y
== u
.uy
) {
214 if(levl
[x
+1][y
].typ
== HWALL
|| levl
[x
+1][y
].typ
== DOOR
)
216 else if(levl
[x
-1][y
].typ
== HWALL
|| levl
[x
-1][y
].typ
== DOOR
)
218 else if(levl
[x
][y
+1].typ
== VWALL
|| levl
[x
][y
+1].typ
== DOOR
)
220 else if(levl
[x
][y
-1].typ
== VWALL
|| levl
[x
][y
-1].typ
== DOOR
)
225 /* make something interesting happen */
226 if(!(guard
= makemon( ((level_difficulty() + u
.pompejipermanentrecord
) > 79) ? &mons
[PM_ELITE_GUARD
] : ((level_difficulty() + u
.pompejipermanentrecord
) > 59) ? &mons
[PM_EXCEPTIONAL_GUARD
] : ((level_difficulty() + u
.pompejipermanentrecord
) > 39) ? &mons
[PM_MASTER_GUARD
] : ((level_difficulty() + u
.pompejipermanentrecord
) > 19) ? &mons
[PM_EXPERIENCED_GUARD
] : &mons
[PM_GUARD
], x
, y
, NO_MM_FLAGS
))) return;
228 guard
->mpeaceful
= 1;
230 EGD(guard
)->gddone
= 0;
233 assign_level(&(EGD(guard
)->gdlevel
), &u
.uz
);
234 EGD(guard
)->vroom
= vaultroom
;
235 EGD(guard
)->warncnt
= 0;
237 reset_faint(); /* if fainted - wake up */
238 if (canspotmon(guard
))
239 pline("Suddenly one of the Vault's %s enters!",
240 makeplural(g_monnam(guard
)));
242 pline("Someone else has entered the Vault.");
243 newsym(guard
->mx
,guard
->my
);
244 if (youmonst
.m_ap_type
== M_AP_OBJECT
|| u
.uundetected
) {
245 if (youmonst
.m_ap_type
== M_AP_OBJECT
&&
246 youmonst
.mappearance
!= GOLD_PIECE
)
247 verbalize("Hey! Who left that %s in here?", mimic_obj_name(&youmonst
));
248 /* You're mimicking some object or you're hidden. */
249 pline("Puzzled, %s turns around and leaves.", mhe(guard
));
254 /* janitors on duty get a free pass; since there is no janitor uniform, they always count as on duty :D --Amy */
255 if (Role_if(PM_JANITOR
)) {
256 verbalize("Oh, you're the janitor, I see. Now go and make that vault floor sparkle!");
261 if((Role_if(PM_CONVICT
) || Role_if(PM_MURDERER
) || Race_if(PM_ALBAE
) || Race_if(PM_PLAYER_DYNAMO
)) && !Upolyd
) {
263 verbalize("I saw your pic on the wanted poster!");
264 if (!MON_WEP(guard
)) {
265 guard
->weapon_check
= NEED_HTH_WEAPON
;
266 (void) mon_wield_item(guard
);
270 if (Strangled
|| is_silent(youmonst
.data
) || multi
< 0) {
271 /* [we ought to record whether this this message has already
272 been given in order to vary it upon repeat visits, but
273 discarding the monster and its egd data renders that hard] */
274 verbalize("I'll be back when you're ready to speak to me!");
279 stop_occupation(); /* if occupied, stop it *now* */
280 if (multi
> 0) { nomul(0, 0, FALSE
); unmul((char *)0); }
283 if (Role_if(PM_BUTT_LOVER
) && rn2(3)) {
284 verbalize("Hello stranger, who are you?");
285 pline("Since you cannot lie, you tell your name to the vault guard.");
286 strncpy(buf
, plname
, sizeof(buf
));
291 getlin("\"Hello stranger, who are you?\" -", buf
);
292 (void) mungspaces(buf
);
293 } while (!letter(buf
[0]) && --trycount
> 0);
295 if (u
.ualign
.type
== A_LAWFUL
&&
296 /* ignore trailing text, in case player includes character's rank */
297 strncmpi(buf
, plname
, (int) strlen(plname
)) != 0 && (!plalias
[0] || strncmpi(buf
, plalias
, (int) strlen(plalias
)) != 0) ) {
298 adjalign(-1); /* Liar! */
301 if (Role_if(PM_BUTT_LOVER
) && (strncmpi(buf
, plname
, (int) strlen(plname
)) != 0 && (!plalias
[0] || strncmpi(buf
, plalias
, (int) strlen(plalias
)) != 0)) ) {
302 You("accidentally drop your pack, and bend over to pick it up...");
303 verbalize("Liar! You really thought that'd work on me, punk?");
308 if (!rn2(10) || (strncmpi(buf
, plname
, (int) strlen(plname
)) != 0 && (!plalias
[0] || strncmpi(buf
, plalias
, (int) strlen(plalias
)) != 0)) ) {
309 boolean rumoristrue
= rn2(2);
310 verbalize("I don't believe you. We will have to do a quiz to verify your identity.");
311 verbalize("You will now tell me whether the following rumor is true or not!");
313 if (rumoristrue
) outrumor(1, BY_OTHER
, TRUE
);
314 else outrumor(-1, BY_OTHER
, TRUE
);
316 if (yn("Now tell me if this rumor was true!") != 'y') { /* player said it's false */
319 verbalize("Ah-ha, you obviously lied! You don't even know the simplest facts! Well here's another one: You will die now, intruder.");
323 verbalize("You're right, this rumor was false. Sorry that I assumed you were lying to me.");
326 } else { /* player said it's true */
328 verbalize("Correct! I see you actually gave me your true identity.");
330 verbalize("Of course not! Are you really that stupid? Do you know what happens to unwanted intruders in this vault? They die, and so will you now.");
341 if (!strcmpi(buf
, "Croesus") || !strcmpi(buf
, "Kroisos")
342 || !strcmpi(buf
, "Creosote")
344 if (!mvitals
[PM_CROESUS
].died
) {
345 verbalize("Oh, yes, of course. Sorry to have disturbed you.");
349 verbalize("Back from the dead, are you? I'll remedy that!");
350 /* don't want guard to waste next turn wielding a weapon */
351 if (!MON_WEP(guard
)) {
352 guard
->weapon_check
= NEED_HTH_WEAPON
;
353 (void) mon_wield_item(guard
);
359 verbalize("I don't know you.");
361 if (!u
.ugold
&& !hidden_gold())
362 verbalize("Please follow me.");
365 verbalize("You have hidden gold.");
366 verbalize("Most likely all your gold was stolen from this vault.");
367 verbalize("Please drop that gold and follow me.");
370 umoney
= money_cnt(invent
);
371 if (!umoney
&& !hidden_gold())
372 verbalize("Please follow me.");
375 verbalize("You have hidden money.");
376 verbalize("Most likely all your money was stolen from this vault.");
377 verbalize("Please drop that money and follow me.");
380 EGD(guard
)->gdx
= gx
;
381 EGD(guard
)->gdy
= gy
;
382 EGD(guard
)->fcbeg
= 0;
383 EGD(guard
)->fakecorr
[0].fx
= x
;
384 EGD(guard
)->fakecorr
[0].fy
= y
;
385 if(IS_WALL(levl
[x
][y
].typ
))
386 EGD(guard
)->fakecorr
[0].ftyp
= levl
[x
][y
].typ
;
387 else { /* the initial guard location is a dug door */
388 int vlt
= EGD(guard
)->vroom
;
389 xchar lowx
= rooms
[vlt
].lx
, hix
= rooms
[vlt
].hx
;
390 xchar lowy
= rooms
[vlt
].ly
, hiy
= rooms
[vlt
].hy
;
392 if(x
== lowx
-1 && y
== lowy
-1)
393 EGD(guard
)->fakecorr
[0].ftyp
= TLCORNER
;
394 else if(x
== hix
+1 && y
== lowy
-1)
395 EGD(guard
)->fakecorr
[0].ftyp
= TRCORNER
;
396 else if(x
== lowx
-1 && y
== hiy
+1)
397 EGD(guard
)->fakecorr
[0].ftyp
= BLCORNER
;
398 else if(x
== hix
+1 && y
== hiy
+1)
399 EGD(guard
)->fakecorr
[0].ftyp
= BRCORNER
;
400 else if(y
== lowy
-1 || y
== hiy
+1)
401 EGD(guard
)->fakecorr
[0].ftyp
= HWALL
;
402 else if(x
== lowx
-1 || x
== hix
+1)
403 EGD(guard
)->fakecorr
[0].ftyp
= VWALL
;
405 levl
[x
][y
].typ
= DOOR
;
406 levl
[x
][y
].doormask
= D_NODOOR
;
407 unblock_point(x
, y
); /* doesn't block light */
408 EGD(guard
)->fcend
= 1;
409 EGD(guard
)->warncnt
= 1;
417 move_gold(gold
, vroom
)
424 newsym(gold
->ox
, gold
->oy
);
425 nx
= rooms
[vroom
].lx
+ rn2(2);
426 ny
= rooms
[vroom
].ly
+ rn2(2);
427 place_object(gold
, nx
, ny
);
437 int vlt
= EGD(grd
)->vroom
;
439 xchar lox
= rooms
[vlt
].lx
- 1, hix
= rooms
[vlt
].hx
+ 1,
440 loy
= rooms
[vlt
].ly
- 1, hiy
= rooms
[vlt
].hy
+ 1;
444 boolean fixed
= FALSE
;
445 boolean movedgold
= FALSE
;
447 for (x
= lox
; x
<= hix
; x
++)
448 for (y
= loy
; y
<= hiy
; y
++) {
449 /* if not on the room boundary, skip ahead */
450 if (x
!= lox
&& x
!= hix
&& y
!= loy
&& y
!= hiy
) continue;
452 if (!IS_WALL(levl
[x
][y
].typ
) && !in_fcorridor(grd
, x
, y
)) {
453 if ((mon
= m_at(x
, y
)) != 0 && mon
!= grd
) {
454 if (mon
->mtame
) yelp(mon
);
455 (void) rloc(mon
, FALSE
);
457 if ((gold
= g_at(x
, y
)) != 0) {
458 move_gold(gold
, EGD(grd
)->vroom
);
461 if ((trap
= t_at(x
, y
)) != 0)
464 typ
= (y
== loy
) ? TLCORNER
:
465 (y
== hiy
) ? BLCORNER
: VWALL
;
467 typ
= (y
== loy
) ? TRCORNER
:
468 (y
== hiy
) ? BRCORNER
: VWALL
;
469 else /* not left or right side, must be top or bottom */
471 levl
[x
][y
].typ
= typ
;
472 levl
[x
][y
].doormask
= 0;
474 * hack: player knows walls are restored because of the
475 * message, below, so show this on the screen.
477 tmp_viz
= viz_array
[y
][x
];
478 viz_array
[y
][x
] = IN_SIGHT
|COULD_SEE
;
480 viz_array
[y
][x
] = tmp_viz
;
486 if(movedgold
|| fixed
) {
487 if(in_fcorridor(grd
, grd
->mx
, grd
->my
) || cansee(grd
->mx
, grd
->my
))
488 pline_The("%s whispers an incantation.", g_monnam(grd
));
489 else You_hear("a distant chant.");
491 pline("A mysterious force moves the gold into the vault.");
493 pline_The("damaged vault's walls are magically restored!");
498 * return 1: guard moved, 0: guard didn't, -1: let m_move do it, -2: died
502 register struct monst
*grd
;
504 int x
, y
, nx
, ny
, m
, n
;
505 int dx
, dy
, gx
, gy
, fci
;
508 struct fakecorridor
*fcp
;
509 register struct egd
*egrd
= EGD(grd
);
510 register struct rm
*crm
;
511 register boolean goldincorridor
= FALSE
,
512 u_in_vault
= vault_occupied(u
.urooms
)? TRUE
: FALSE
,
513 grd_in_vault
= *in_rooms(grd
->mx
, grd
->my
, VAULT
)?
515 boolean disappear_msg_seen
= FALSE
, semi_dead
= (grd
->mhp
<= 0);
517 register boolean u_carry_gold
= ((u
.ugold
+ hidden_gold()) > 0L);
519 long umoney
= money_cnt(invent
);
520 register boolean u_carry_gold
= ((umoney
+ hidden_gold()) > 0L);
524 if(!on_level(&(egrd
->gdlevel
), &u
.uz
)) return(-1);
526 if(!u_in_vault
&& !grd_in_vault
)
528 if(!grd
->mpeaceful
) {
535 (in_fcorridor(grd
, grd
->mx
, grd
->my
) &&
536 !in_fcorridor(grd
, u
.ux
, u
.uy
)))) {
537 (void) rloc(grd
, FALSE
);
539 (void) clear_fcorr(grd
, TRUE
);
542 if(!in_fcorridor(grd
, grd
->mx
, grd
->my
))
543 (void) clear_fcorr(grd
, TRUE
);
546 if(abs(egrd
->ogx
- grd
->mx
) > 1 ||
547 abs(egrd
->ogy
- grd
->my
) > 1)
548 return(-1); /* teleported guard - treat as monster */
549 if(egrd
->fcend
== 1) {
551 (u_carry_gold
|| um_dist(grd
->mx
, grd
->my
, 1))) {
552 if(egrd
->warncnt
== 3)
553 verbalize("I repeat, %sfollow me!",
557 "drop that hidden gold and " :
558 "drop that gold and ") : "");
561 "drop that hidden money and " :
562 "drop that money and ") : "");
564 if(egrd
->warncnt
== 7) {
567 verbalize("You've been warned, knave!");
569 levl
[m
][n
].typ
= egrd
->fakecorr
[0].ftyp
;
574 /* not fair to get mad when (s)he's fainted or paralyzed */
575 if(!is_fainted() && multi
>= 0) egrd
->warncnt
++;
580 if (u_carry_gold
) { /* player teleported */
583 (void) rloc(grd
, FALSE
);
584 levl
[m
][n
].typ
= egrd
->fakecorr
[0].ftyp
;
588 if (!cansee(grd
->mx
, grd
->my
) || !mon_visible(grd
))
589 You_hear("the shrill sound of a guard's whistle.");
591 You(um_dist(grd
->mx
, grd
->my
, 2) ?
592 "see an angry %s approaching." :
593 "are confronted by an angry %s.",
596 u
.cnd_kopsummonamount
++;
597 copcnt
= rnd(monster_difficulty() ) + 1;
598 if (rn2(5)) copcnt
= (copcnt
/ (rnd(4) + 1)) + 1;
599 if (Role_if(PM_CAMPERSTRIKER
)) copcnt
*= (rn2(5) ? 2 : rn2(5) ? 3 : 5);
601 if (uarmh
&& itemhasappearance(uarmh
, APP_ANTI_GOVERNMENT_HELMET
) ) {
602 copcnt
= (copcnt
/ 2) + 1;
605 if (RngeAntiGovernment
) {
606 copcnt
= (copcnt
/ 2) + 1;
609 while(--copcnt
>= 0) {
610 (void) makemon(mkclass(S_KOP
,0), grd
->mx
, grd
->my
, MM_ANGRY
|MM_ADJACENTOK
|MM_FRENZIED
);
617 for (koptryct
= 0; koptryct
< 2000; koptryct
++) {
618 kox
= rn1(COLNO
-3,2);
621 if (kox
&& koy
&& isok(kox
, koy
) && (levl
[kox
][koy
].typ
> DBWALL
) && !(t_at(kox
, koy
)) ) {
622 (void) maketrap(kox
, koy
, KOP_CUBE
, 0, FALSE
);
633 verbalize("Well, begone.");
641 if(egrd
->fcend
> 1) {
642 if(egrd
->fcend
> 2 && in_fcorridor(grd
, grd
->mx
, grd
->my
) &&
643 !egrd
->gddone
&& !in_fcorridor(grd
, u
.ux
, u
.uy
) &&
644 levl
[egrd
->fakecorr
[0].fx
][egrd
->fakecorr
[0].fy
].typ
645 == egrd
->fakecorr
[0].ftyp
) {
646 pline_The("%s, confused, disappears.", g_monnam(grd
));
647 disappear_msg_seen
= TRUE
;
651 (in_fcorridor(grd
, u
.ux
, u
.uy
) ||
652 /* cover a 'blind' spot */
653 (egrd
->fcend
> 1 && u_in_vault
))) {
658 if(egrd
->warncnt
< 6) {
660 verbalize("Drop all your gold, scoundrel!");
663 verbalize("So be it, rogue!");
669 for(fci
= egrd
->fcbeg
; fci
< egrd
->fcend
; fci
++)
670 if(g_at(egrd
->fakecorr
[fci
].fx
, egrd
->fakecorr
[fci
].fy
)){
671 m
= egrd
->fakecorr
[fci
].fx
;
672 n
= egrd
->fakecorr
[fci
].fy
;
673 goldincorridor
= TRUE
;
675 if(goldincorridor
&& !egrd
->gddone
) {
678 if (m
== u
.ux
&& n
== u
.uy
) {
679 struct obj
*gold
= g_at(m
,n
);
680 /* Grab the gold from between the hero's feet. */
682 grd
->mgold
+= gold
->quan
;
685 obj_extract_self(gold
);
686 add_to_minv(grd
, gold
);
689 } else if (m
== x
&& n
== y
) {
690 mpickgold(grd
); /* does a newsym */
692 /* just for insurance... */
693 if (MON_AT(m
, n
) && m
!= grd
->mx
&& n
!= grd
->my
) {
694 verbalize("Out of my way, scum!");
695 (void) rloc(m_at(m
, n
), FALSE
);
697 remove_monster(grd
->mx
, grd
->my
);
698 newsym(grd
->mx
, grd
->my
);
699 place_monster(grd
, m
, n
);
700 mpickgold(grd
); /* does a newsym */
703 pline("%s%s picks up the gold.", Monnam(grd
),
704 grd
->mpeaceful
? " calms down and" : "");
705 if(x
!= grd
->mx
|| y
!= grd
->my
) {
706 remove_monster(grd
->mx
, grd
->my
);
707 newsym(grd
->mx
, grd
->my
);
708 place_monster(grd
, x
, y
);
711 if(!grd
->mpeaceful
) return(-1);
717 if(um_dist(grd
->mx
, grd
->my
, 1) || egrd
->gddone
) {
718 if(!egrd
->gddone
&& !rn2(10)) verbalize("Move along!");
720 return(0); /* didn't move */
725 if(u_in_vault
) goto nextpos
;
727 /* look around (hor & vert only) for accessible places */
728 for(nx
= x
-1; nx
<= x
+1; nx
++) for(ny
= y
-1; ny
<= y
+1; ny
++) {
729 if((nx
== x
|| ny
== y
) && (nx
!= x
|| ny
!= y
) && isok(nx
, ny
)) {
731 typ
= (crm
= &levl
[nx
][ny
])->typ
;
732 if(!IS_STWALL(typ
) && !IS_POOL(typ
)) {
734 if(in_fcorridor(grd
, nx
, ny
))
737 if(*in_rooms(nx
,ny
,VAULT
))
740 /* seems we found a good place to leave him alone */
742 if(ACCESSIBLE(typ
)) goto newpos
;
749 crm
->typ
= (typ
== SCORR
) ? CORR
: DOOR
;
751 if(crm
->typ
== DOOR
) crm
->doormask
= D_NODOOR
;
762 dx
= (gx
> x
) ? 1 : (gx
< x
) ? -1 : 0;
763 dy
= (gy
> y
) ? 1 : (gy
< y
) ? -1 : 0;
764 if(abs(gx
-x
) >= abs(gy
-y
)) nx
+= dx
; else ny
+= dy
;
766 while((typ
= (crm
= &levl
[nx
][ny
])->typ
) != 0) {
767 /* in view of the above we must have IS_WALL(typ) or typ == POOL */
768 /* must be a wall here */
769 if(isok(nx
+nx
-x
,ny
+ny
-y
) && !IS_POOL(typ
) &&
770 IS_ROOM(levl
[nx
+nx
-x
][ny
+ny
-y
].typ
)){
772 crm
->doormask
= D_NODOOR
;
780 ny
= y
; nx
= x
+dx
; dy
= 0;
783 /* I don't like this, but ... */
786 crm
->doormask
= D_NODOOR
;
793 unblock_point(nx
, ny
); /* doesn't block light */
797 fcp
= &(egrd
->fakecorr
[egrd
->fcend
]);
798 if(egrd
->fcend
++ == FCSIZ
) panic("fakecorr overflow");
804 /* The following is a kludge. We need to keep */
805 /* the guard around in order to be able to make */
806 /* the fake corridor disappear as the player */
807 /* moves out of it, but we also need the guard */
808 /* out of the way. We send the guard to never- */
809 /* never land. We set ogx ogy to mx my in order */
810 /* to avoid a check at the top of this function. */
811 /* At the end of the process, the guard is killed */
812 /* in restfakecorr(). */
814 x
= grd
->mx
; y
= grd
->my
;
816 see_guard
= canspotmon(grd
);
818 remove_monster(grd
->mx
, grd
->my
);
819 newsym(grd
->mx
,grd
->my
);
820 place_monster(grd
, 0, 0);
824 if(!semi_dead
&& (in_fcorridor(grd
, u
.ux
, u
.uy
) ||
826 if (!disappear_msg_seen
&& see_guard
)
827 pline("Suddenly, the %s disappears.", g_monnam(grd
));
832 egrd
->ogx
= grd
->mx
; /* update old positions */
834 remove_monster(grd
->mx
, grd
->my
);
835 place_monster(grd
, nx
, ny
);
836 newsym(grd
->mx
,grd
->my
);
841 /* Routine when dying or quitting with a vault guard around */
845 register struct monst
*grd
= findgd();
849 long umoney
= money_cnt(invent
);
850 struct obj
*coins
, *nextcoins
;
856 if (!u
.ugold
|| !grd
) return;
858 if (!umoney
|| !grd
) return;
862 Your("%ld %s goes into the Magic Memory Vault.",
873 if(grd
->mpeaceful
) { /* guard has no "right" to your gold */
878 pline("%s remits your gold to the vault.", Monnam(grd
));
879 gx
= rooms
[EGD(grd
)->vroom
].lx
+ rn2(2);
880 gy
= rooms
[EGD(grd
)->vroom
].ly
+ rn2(2);
882 "To Croesus: here's the gold recovered from %s the %s.",
883 playeraliasname
, mons
[u
.umonster
].mname
);
884 make_grave(gx
, gy
, buf
);
887 place_object(gold
= mkgoldobj(u
.ugold
), gx
, gy
);
890 for (coins
= invent
; coins
; coins
= nextcoins
) {
891 nextcoins
= coins
->nobj
;
892 if (objects
[coins
->otyp
].oc_class
== COIN_CLASS
) {
894 place_object(coins
, gx
, gy
);
905 register long value
= 0L;
906 register struct obj
*obj
;
908 for (obj
= invent
; obj
; obj
= obj
->nobj
)
909 if (Has_contents(obj
))
910 value
+= contained_gold(obj
);
911 /* unknown gold stuck inside statues may cause some consternation... */
917 gd_sound() /* prevent "You hear footsteps.." when inappropriate */
919 register struct monst
*grd
= findgd();
921 if (vault_occupied(u
.urooms
)) return(FALSE
);
922 else return((boolean
)(grd
== (struct monst
*)0));