OSDN Git Service

update year to 2020
[jnethack/source.git] / src / vault.c
1 /* NetHack 3.6  vault.c $NHDT-Date: 1549921171 2019/02/11 21:39:31 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.62 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2011. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2020            */
9 /* JNetHack may be freely redistributed.  See license for details. */
10
11 #include "hack.h"
12
13 STATIC_DCL boolean FDECL(clear_fcorr, (struct monst *, BOOLEAN_P));
14 STATIC_DCL void FDECL(blackout, (int, int));
15 STATIC_DCL void FDECL(restfakecorr, (struct monst *));
16 STATIC_DCL void FDECL(parkguard, (struct monst *));
17 STATIC_DCL boolean FDECL(in_fcorridor, (struct monst *, int, int));
18 STATIC_DCL boolean FDECL(find_guard_dest, (struct monst *, xchar *, xchar *));
19 STATIC_DCL void FDECL(move_gold, (struct obj *, int));
20 STATIC_DCL void FDECL(wallify_vault, (struct monst *));
21 STATIC_DCL void FDECL(gd_mv_monaway, (struct monst *, int, int));
22 STATIC_OVL void FDECL(gd_pick_corridor_gold, (struct monst *, int, int));
23
24 void
25 newegd(mtmp)
26 struct monst *mtmp;
27 {
28     if (!mtmp->mextra)
29         mtmp->mextra = newmextra();
30     if (!EGD(mtmp)) {
31         EGD(mtmp) = (struct egd *) alloc(sizeof (struct egd));
32         (void) memset((genericptr_t) EGD(mtmp), 0, sizeof (struct egd));
33     }
34 }
35
36 void
37 free_egd(mtmp)
38 struct monst *mtmp;
39 {
40     if (mtmp->mextra && EGD(mtmp)) {
41         free((genericptr_t) EGD(mtmp));
42         EGD(mtmp) = (struct egd *) 0;
43     }
44     mtmp->isgd = 0;
45 }
46
47 /* try to remove the temporary corridor (from vault to rest of map) being
48    maintained by guard 'grd'; if guard is still in it, removal will fail,
49    to be tried again later */
50 STATIC_OVL boolean
51 clear_fcorr(grd, forceshow)
52 struct monst *grd;
53 boolean forceshow;
54 {
55     register int fcx, fcy, fcbeg;
56     struct monst *mtmp;
57     boolean sawcorridor = FALSE,
58             silently = program_state.stopprint ? TRUE : FALSE;
59     struct egd *egrd = EGD(grd);
60     struct trap *trap;
61     struct rm *lev;
62
63     if (!on_level(&egrd->gdlevel, &u.uz))
64         return TRUE;
65
66     /* note: guard remains on 'fmons' list (alive or dead, at off-map
67        coordinate <0,0>), until temporary corridor from vault back to
68        civilization has been removed */
69     while ((fcbeg = egrd->fcbeg) < egrd->fcend) {
70         fcx = egrd->fakecorr[fcbeg].fx;
71         fcy = egrd->fakecorr[fcbeg].fy;
72         if ((DEADMONSTER(grd) || !in_fcorridor(grd, u.ux, u.uy))
73             && egrd->gddone)
74             forceshow = TRUE;
75         if ((u.ux == fcx && u.uy == fcy && !DEADMONSTER(grd))
76             || (!forceshow && couldsee(fcx, fcy))
77             || (Punished && !carried(uball) && uball->ox == fcx
78                 && uball->oy == fcy))
79             return FALSE;
80
81         if ((mtmp = m_at(fcx, fcy)) != 0) {
82             if (mtmp->isgd) {
83                 return FALSE;
84             } else if (!in_fcorridor(grd, u.ux, u.uy)) {
85                 if (mtmp->mtame)
86                     yelp(mtmp);
87                 if (!rloc(mtmp, TRUE))
88                     m_into_limbo(mtmp);
89             }
90         }
91         lev = &levl[fcx][fcy];
92         if (lev->typ == CORR && cansee(fcx, fcy))
93             sawcorridor = TRUE;
94         lev->typ = egrd->fakecorr[fcbeg].ftyp;
95         if (IS_STWALL(lev->typ)) {
96             /* destroy any trap here (pit dug by you, hole dug via
97                wand while levitating or by monster, bear trap or land
98                mine via object, spun web) when spot reverts to stone */
99             if ((trap = t_at(fcx, fcy)) != 0)
100                 deltrap(trap);
101             /* undo scroll/wand/spell of light affecting this spot */
102             if (lev->typ == STONE)
103                 blackout(fcx, fcy);
104         }
105         map_location(fcx, fcy, 1); /* bypass vision */
106         if (!ACCESSIBLE(lev->typ))
107             block_point(fcx, fcy);
108         vision_full_recalc = 1;
109         egrd->fcbeg++;
110     }
111     if (sawcorridor && !silently)
112 /*JP
113         pline_The("corridor disappears.");
114 */
115         pline("\92Ê\98H\82Í\8fÁ\82¦\82½\81D");
116     /* only give encased message if hero is still alive (might get here
117        via paygd() -> mongone() -> grddead() when game is over;
118        died: no message, quit: message) */
119     if (IS_ROCK(levl[u.ux][u.uy].typ) && (Upolyd ? u.mh : u.uhp) > 0
120         && !silently)
121 /*JP
122         You("are encased in rock.");
123 */
124         You("\90Î\82É\82Â\82Â\82Ü\82ê\82½\81D");
125     return TRUE;
126 }
127
128 /* as a temporary corridor is removed, set stone locations and adjacent
129    spots to unlit; if player used scroll/wand/spell of light while inside
130    the corridor, we don't want the light to reappear if/when a new tunnel
131    goes through the same area */
132 STATIC_OVL void
133 blackout(x, y)
134 int x, y;
135 {
136     struct rm *lev;
137     int i, j;
138
139     for (i = x - 1; i <= x + 1; ++i)
140         for (j = y - 1; j <= y + 1; ++j) {
141             if (!isok(i, j))
142                 continue;
143             lev = &levl[i][j];
144             /* [possible bug: when (i != x || j != y), perhaps we ought
145                to check whether the spot on the far side is lit instead
146                of doing a blanket blackout of adjacent locations] */
147             if (lev->typ == STONE)
148                 lev->lit = lev->waslit = 0;
149             /* mark <i,j> as not having been seen from <x,y> */
150             unset_seenv(lev, x, y, i, j);
151         }
152 }
153
154 STATIC_OVL void
155 restfakecorr(grd)
156 struct monst *grd;
157 {
158     /* it seems you left the corridor - let the guard disappear */
159     if (clear_fcorr(grd, FALSE)) {
160         grd->isgd = 0; /* dmonsfree() should delete this mon */
161         mongone(grd);
162     }
163 }
164
165 /* move guard--dead to alive--to <0,0> until temporary corridor is removed */
166 STATIC_OVL void
167 parkguard(grd)
168 struct monst *grd;
169 {
170     /* either guard is dead or will now be treated as if so;
171        monster traversal loops should skip it */
172     if (grd == context.polearm.hitmon)
173         context.polearm.hitmon = 0;
174     if (grd->mx) {
175         remove_monster(grd->mx, grd->my);
176         newsym(grd->mx, grd->my);
177         place_monster(grd, 0, 0);
178         /* [grd->mx,my just got set to 0,0 by place_monster(), so this
179            just sets EGD(grd)->ogx,ogy to 0,0 too; is that what we want?] */
180         EGD(grd)->ogx = grd->mx;
181         EGD(grd)->ogy = grd->my;
182     }
183 }
184
185 /* called in mon.c */
186 boolean
187 grddead(grd)
188 struct monst *grd;
189 {
190     boolean dispose = clear_fcorr(grd, TRUE);
191
192     if (!dispose) {
193         /* destroy guard's gold; drop any other inventory */
194         relobj(grd, 0, FALSE);
195         grd->mhp = 0;
196         parkguard(grd);
197         dispose = clear_fcorr(grd, TRUE);
198     }
199     if (dispose)
200         grd->isgd = 0; /* for dmonsfree() */
201     return dispose;
202 }
203
204 STATIC_OVL boolean
205 in_fcorridor(grd, x, y)
206 struct monst *grd;
207 int x, y;
208 {
209     register int fci;
210     struct egd *egrd = EGD(grd);
211
212     for (fci = egrd->fcbeg; fci < egrd->fcend; fci++)
213         if (x == egrd->fakecorr[fci].fx && y == egrd->fakecorr[fci].fy)
214             return TRUE;
215     return FALSE;
216 }
217
218 struct monst *
219 findgd()
220 {
221     register struct monst *mtmp;
222
223     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
224         if (DEADMONSTER(mtmp))
225             continue;
226         if (mtmp->isgd && on_level(&(EGD(mtmp)->gdlevel), &u.uz))
227             return mtmp;
228     }
229     return (struct monst *) 0;
230 }
231
232 void
233 vault_summon_gd()
234 {
235     if (vault_occupied(u.urooms) && !findgd())
236         u.uinvault = (VAULT_GUARD_TIME - 1);
237 }
238
239 char
240 vault_occupied(array)
241 char *array;
242 {
243     register char *ptr;
244
245     for (ptr = array; *ptr; ptr++)
246         if (rooms[*ptr - ROOMOFFSET].rtype == VAULT)
247             return *ptr;
248     return '\0';
249 }
250
251 /* hero has teleported out of vault while a guard is active */
252 void
253 uleftvault(grd)
254 struct monst *grd;
255 {
256     /* only called if caller has checked vault_occupied() and findgd() */
257     if (!grd || !grd->isgd || DEADMONSTER(grd)) {
258         impossible("escaping vault without guard?");
259         return;
260     }
261     /* if carrying gold and arriving anywhere other than next to the guard,
262        set the guard loose */
263     if ((money_cnt(invent) || hidden_gold())
264         && um_dist(grd->mx, grd->my, 1)) {
265         if (grd->mpeaceful) {
266             if (canspotmon(grd)) /* see or sense via telepathy */
267 /*JP
268                 pline("%s becomes irate.", Monnam(grd));
269 */
270                 pline("%s\82Í\8c\83\93{\82µ\82½\81D", Monnam(grd));
271             grd->mpeaceful = 0; /* bypass setmangry() */
272         }
273         /* if arriving outside guard's temporary corridor, give the
274            guard an extra move to deliver message(s) and to teleport
275            out of and remove that corridor */
276         if (!in_fcorridor(grd, u.ux, u.uy))
277             (void) gd_move(grd);
278     }
279 }
280
281 STATIC_OVL boolean
282 find_guard_dest(guard, rx, ry)
283 struct monst *guard;
284 xchar *rx, *ry;
285 {
286     register int x, y, dd, lx = 0, ly = 0;
287
288     for (dd = 2; (dd < ROWNO || dd < COLNO); dd++) {
289         for (y = u.uy - dd; y <= u.uy + dd; ly = y, y++) {
290             if (y < 0 || y > ROWNO - 1)
291                 continue;
292             for (x = u.ux - dd; x <= u.ux + dd; lx = x, x++) {
293                 if (y != u.uy - dd && y != u.uy + dd && x != u.ux - dd)
294                     x = u.ux + dd;
295                 if (x < 1 || x > COLNO - 1)
296                     continue;
297                 if (guard && ((x == guard->mx && y == guard->my)
298                               || (guard->isgd && in_fcorridor(guard, x, y))))
299                     continue;
300                 if (levl[x][y].typ == CORR) {
301                     lx = (x < u.ux) ? x + 1 : (x > u.ux) ? x - 1 : x;
302                     ly = (y < u.uy) ? y + 1 : (y > u.uy) ? y - 1 : y;
303                     if (levl[lx][ly].typ != STONE && levl[lx][ly].typ != CORR)
304                         goto incr_radius;
305                     *rx = x;
306                     *ry = y;
307                     return TRUE;
308                 }
309             }
310         }
311  incr_radius:
312         ;
313     }
314     impossible("Not a single corridor on this level?");
315     tele();
316     return FALSE;
317 }
318
319 void
320 invault()
321 {
322 #ifdef BSD_43_BUG
323     int dummy; /* hack to avoid schain botch */
324 #endif
325     struct monst *guard;
326     boolean gsensed;
327     int trycount, vaultroom = (int) vault_occupied(u.urooms);
328
329     if (!vaultroom) {
330         u.uinvault = 0;
331         return;
332     }
333     vaultroom -= ROOMOFFSET;
334
335     guard = findgd();
336     if (++u.uinvault % VAULT_GUARD_TIME == 0 && !guard) {
337         /* if time ok and no guard now. */
338         char buf[BUFSZ];
339         register int x, y, gx, gy;
340         xchar rx, ry;
341         long umoney;
342
343         /* first find the goal for the guard */
344         if (!find_guard_dest((struct monst *)0, &rx, &ry))
345             return;
346         gx = rx, gy = ry;
347
348         /* next find a good place for a door in the wall */
349         x = u.ux;
350         y = u.uy;
351         if (levl[x][y].typ != ROOM) { /* player dug a door and is in it */
352             if (levl[x + 1][y].typ == ROOM)
353                 x = x + 1;
354             else if (levl[x][y + 1].typ == ROOM)
355                 y = y + 1;
356             else if (levl[x - 1][y].typ == ROOM)
357                 x = x - 1;
358             else if (levl[x][y - 1].typ == ROOM)
359                 y = y - 1;
360             else if (levl[x + 1][y + 1].typ == ROOM) {
361                 x = x + 1;
362                 y = y + 1;
363             } else if (levl[x - 1][y - 1].typ == ROOM) {
364                 x = x - 1;
365                 y = y - 1;
366             } else if (levl[x + 1][y - 1].typ == ROOM) {
367                 x = x + 1;
368                 y = y - 1;
369             } else if (levl[x - 1][y + 1].typ == ROOM) {
370                 x = x - 1;
371                 y = y + 1;
372             }
373         }
374         while (levl[x][y].typ == ROOM) {
375             register int dx, dy;
376
377             dx = (gx > x) ? 1 : (gx < x) ? -1 : 0;
378             dy = (gy > y) ? 1 : (gy < y) ? -1 : 0;
379             if (abs(gx - x) >= abs(gy - y))
380                 x += dx;
381             else
382                 y += dy;
383         }
384         if (x == u.ux && y == u.uy) {
385             if (levl[x + 1][y].typ == HWALL || levl[x + 1][y].typ == DOOR)
386                 x = x + 1;
387             else if (levl[x - 1][y].typ == HWALL
388                      || levl[x - 1][y].typ == DOOR)
389                 x = x - 1;
390             else if (levl[x][y + 1].typ == VWALL
391                      || levl[x][y + 1].typ == DOOR)
392                 y = y + 1;
393             else if (levl[x][y - 1].typ == VWALL
394                      || levl[x][y - 1].typ == DOOR)
395                 y = y - 1;
396             else
397                 return;
398         }
399
400         /* make something interesting happen */
401         if (!(guard = makemon(&mons[PM_GUARD], x, y, MM_EGD)))
402             return;
403         guard->isgd = 1;
404         guard->mpeaceful = 1;
405         set_malign(guard);
406         EGD(guard)->gddone = 0;
407         EGD(guard)->ogx = x;
408         EGD(guard)->ogy = y;
409         assign_level(&(EGD(guard)->gdlevel), &u.uz);
410         EGD(guard)->vroom = vaultroom;
411         EGD(guard)->warncnt = 0;
412
413         reset_faint(); /* if fainted - wake up */
414         gsensed = !canspotmon(guard);
415         if (!gsensed)
416 #if 0 /*JP:T*/
417             pline("Suddenly one of the Vault's %s enters!",
418                   makeplural(guard->data->mname));
419 #else
420             pline("\93Ë\91R\81C\91q\8cÉ\82Ì\94Ô\95º\82ª\93ü\82Á\82Ä\82«\82½\81I");
421 #endif
422         else
423 /*JP
424             pline("Someone else has entered the Vault.");
425 */
426             pline("\92N\82©\82ª\91q\8cÉ\82É\93ü\82Á\82Ä\82«\82½\81D");
427         newsym(guard->mx, guard->my);
428         if (u.uswallow) {
429             /* can't interrogate hero, don't interrogate engulfer */
430             if (!Deaf)
431 /*JP
432                 verbalize("What's going on here?");
433 */
434                 verbalize("\82±\82±\82Å\89½\82ð\82µ\82Ä\82¢\82é\82ñ\82¾\81H");
435             if (gsensed)
436 /*JP
437                 pline_The("other presence vanishes.");
438 */
439                 pline("\91¼\90l\82Ì\8bC\94z\82Í\8fÁ\82¦\82½\81D");
440             mongone(guard);
441             return;
442         }
443         if (U_AP_TYPE == M_AP_OBJECT || u.uundetected) {
444             if (U_AP_TYPE == M_AP_OBJECT
445                 && youmonst.mappearance != GOLD_PIECE)
446                 if (!Deaf)
447 #if 0 /*JP:T*/
448                     verbalize("Hey!  Who left that %s in here?",
449                               mimic_obj_name(&youmonst));
450 #else
451                     verbalize("\82¨\82¢\81I\82¾\82ê\82ª\82±\82Ì%s\82ð\82±\82±\82É\92u\82¢\82Ä\8ds\82Á\82½\82ñ\82¾\81H",
452                               mimic_obj_name(&youmonst));
453 #endif
454             /* You're mimicking some object or you're hidden. */
455 /*JP
456             pline("Puzzled, %s turns around and leaves.", mhe(guard));
457 */
458             pline("%s\82Í\8d¢\98f\82µ\82È\82ª\82ç\81C\8cü\82«\92¼\82Á\82Ä\8b\8e\82Á\82Ä\82¢\82Á\82½\81D", mhe(guard));
459             mongone(guard);
460             return;
461         }
462         if (Strangled || is_silent(youmonst.data) || multi < 0) {
463             /* [we ought to record whether this this message has already
464                been given in order to vary it upon repeat visits, but
465                discarding the monster and its egd data renders that hard] */
466             if (Deaf)
467 /*JP
468                 pline("%s huffs and turns to leave.", noit_Monnam(guard));
469 */
470                 pline("%s\82Í\95s\8b@\8c\99\82É\82È\82Á\82Ä\81C\8b\8e\82Á\82Ä\82¢\82Á\82½\81D", noit_Monnam(guard));
471             else
472 /*JP
473                 verbalize("I'll be back when you're ready to speak to me!");
474 */
475                 verbalize("\98b\82¹\82é\82æ\82¤\82É\82È\82Á\82½\82ç\96ß\82Á\82Ä\82«\82Ä\82â\82é\81I");
476             mongone(guard);
477             return;
478         }
479
480         stop_occupation(); /* if occupied, stop it *now* */
481         if (multi > 0) {
482             nomul(0);
483             unmul((char *) 0);
484         }
485         buf[0] = '\0';
486         trycount = 5;
487         do {
488 #if 0 /*JP:T*/
489             getlin(Deaf ? "You are required to supply your name. -"
490                         : "\"Hello stranger, who are you?\" -", buf);
491 #else
492             getlin(Deaf ? "\96¼\91O\82ð\8c¾\82¤\82æ\82¤\82É\8b\81\82ß\82ç\82ê\82½\81D-"
493                         : "\81u\8c©\82È\82¢\8aç\82¾\82È\81C\82¨\82Ü\82¦\82Í\92N\82¾\81H\81v-", buf);
494 #endif
495             (void) mungspaces(buf);
496 #if 0 /*JP*/
497         } while (!buf[0] && --trycount > 0);
498 #else
499         } while (!buf[0] && !is_kanji(buf[0]) && --trycount > 0);
500 #endif
501
502         if (u.ualign.type == A_LAWFUL
503             /* ignore trailing text, in case player includes rank */
504             && strncmpi(buf, plname, (int) strlen(plname)) != 0) {
505             adjalign(-1); /* Liar! */
506         }
507
508 #if 0 /*JP:T*/
509         if (!strcmpi(buf, "Croesus") || !strcmpi(buf, "Kroisos")
510             || !strcmpi(buf, "Creosote")) { /* Discworld */
511 #else
512         if (!strcmpi(buf, "Croesus") || !strcmpi(buf, "Kroisos")
513             || !strcmpi(buf, "Creosote") /* Discworld */
514             || !strcmp(buf, "\83N\83\8d\83C\83\\83X") || !strcmp(buf, "\83N\83\8c\83I\83\\81[\83g")) {
515 #endif
516             if (!mvitals[PM_CROESUS].died) {
517                 if (Deaf) {
518                     if (!Blind)
519 /*JP
520                         pline("%s waves goodbye.", noit_Monnam(guard));
521 */
522                         pline("%s\82Í\82³\82æ\82È\82ç\82Æ\8eè\82ð\90U\82Á\82½\81D", noit_Monnam(guard));
523                 } else {
524                     verbalize(
525 /*JP
526                          "Oh, yes, of course.  Sorry to have disturbed you.");
527 */
528                          "\82¢\82â\81C\82±\82è\82á\81C\82¦\81[\82Æ\81C\82¨\91\9b\82ª\82¹\82µ\82Ü\82µ\82½\81D");
529                 }
530                 mongone(guard);
531             } else {
532                 setmangry(guard, FALSE);
533                 if (Deaf) {
534                    if (!Blind)
535 #if 0 /*JP:T*/
536                         pline("%s mouths something and looks very angry!",
537                               noit_Monnam(guard));
538 #else
539                         pline("%s\82Í\89½\82©\82ð\8c¾\82Á\82Ä\82¢\82é\81D\82Æ\82Ä\82à\93{\82Á\82Ä\82¢\82é\82æ\82¤\82¾\81I",
540                               noit_Monnam(guard));
541 #endif
542                 } else {
543 #if 0 /*JP:T*/
544                    verbalize(
545                            "Back from the dead, are you?  I'll remedy that!");
546 #else
547                    verbalize(
548                            "\82Ù\82¤\81I\8e\80\82Ì\90¢\8aE\82©\82ç\96ß\82Á\82Ä\82«\82½\82Ì\82©\81H\82¤\82»\82È\82ç\8fã\8eè\82É\82Â\82¯\81I");
549 #endif
550                 }
551                 /* don't want guard to waste next turn wielding a weapon */
552                 if (!MON_WEP(guard)) {
553                     guard->weapon_check = NEED_HTH_WEAPON;
554                     (void) mon_wield_item(guard);
555                 }
556             }
557             return;
558         }
559         if (Deaf)
560 #if 0 /*JP:T*/
561             pline("%s doesn't %srecognize you.", noit_Monnam(guard),
562                     (Blind) ? "" : "appear to ");
563 #else
564             pline("%s\82Í\82 \82È\82½\82Ì\82±\82Æ\82ª\95ª\82©\82ç\82È\82¢\82æ\82¤\82¾\81D", noit_Monnam(guard));
565 #endif
566         else
567 /*JP
568             verbalize("I don't know you.");
569 */
570             verbalize("\92m\82ç\82ñ\82È\81D");
571         umoney = money_cnt(invent);
572         if (!umoney && !hidden_gold()) {
573             if (Deaf)
574 #if 0 /*JP:T*/
575                 pline("%s stomps%s.", noit_Monnam(guard),
576                       (Blind) ? "" : " and beckons");
577 #else
578                 pline("%s\82Í\91«\82ð\93¥\82Ý\96Â\82ç\82µ%s\82½\81D", noit_Monnam(guard),
579                       (Blind) ? "" : "\82Ä\8eè\8fµ\82«\82µ");
580 #endif
581             else
582 /*JP
583                 verbalize("Please follow me.");
584 */
585                 verbalize("\8e\84\82Ì\8cã\82É\82Â\82¢\82Ä\82«\82È\82³\82¢\81D");
586         } else {
587             if (!umoney) {
588                 if (Deaf) {
589                     if (!Blind)
590 #if 0 /*JP:T*/
591                         pline("%s glares at you%s.", noit_Monnam(guard),
592                               invent ? "r stuff" : "");
593 #else
594                         pline("%s\82Í\82 \82È\82½%s\82ð\82É\82ç\82Ý\82Â\82¯\82½\81D", noit_Monnam(guard),
595                               invent ? "\82Ì\8e\9d\82¿\95¨" : "");
596 #endif
597                 } else {
598 /*JP
599                    verbalize("You have hidden gold.");
600 */
601                    verbalize("\82Ü\82¾\8bà\89Ý\82ð\89B\82µ\82Ä\82é\82È\81D");
602                 }
603             }
604             if (Deaf) {
605                 if (!Blind)
606 #if 0 /*JP:T*/
607                     pline(
608                        "%s holds out %s palm and beckons with %s other hand.",
609                           noit_Monnam(guard), noit_mhis(guard),
610                           noit_mhis(guard));
611 #else
612                     pline(
613                        "%s\82Í\95Ð\8eè\82ð\8d·\82µ\8fo\82µ\81C\82à\82¤\95Ð\8eè\82Å\8eè\8fµ\82«\82µ\82½\81D",
614                           noit_Monnam(guard));
615 #endif
616             } else {
617                 verbalize(
618 /*JP
619                     "Most likely all your gold was stolen from this vault.");
620 */
621                     "\91q\8cÉ\82©\82ç\93\90\82ñ\82¾\8bà\89Ý\82ª\82 \82é\82¾\82ë\82¤\81D");
622 /*JP
623                 verbalize("Please drop that gold and follow me.");
624 */
625                 verbalize("\82»\82ê\82ð\82»\82Á\82­\82è\96ß\82µ\82Ä\82©\82ç\81C\8e\84\82Ì\8cã\82É\82Â\82¢\82Ä\82«\82È\82³\82¢\81D");
626             }
627         }
628         EGD(guard)->gdx = gx;
629         EGD(guard)->gdy = gy;
630         EGD(guard)->fcbeg = 0;
631         EGD(guard)->fakecorr[0].fx = x;
632         EGD(guard)->fakecorr[0].fy = y;
633         if (IS_WALL(levl[x][y].typ)) {
634             EGD(guard)->fakecorr[0].ftyp = levl[x][y].typ;
635         } else { /* the initial guard location is a dug door */
636             int vlt = EGD(guard)->vroom;
637             xchar lowx = rooms[vlt].lx, hix = rooms[vlt].hx;
638             xchar lowy = rooms[vlt].ly, hiy = rooms[vlt].hy;
639
640             if (x == lowx - 1 && y == lowy - 1)
641                 EGD(guard)->fakecorr[0].ftyp = TLCORNER;
642             else if (x == hix + 1 && y == lowy - 1)
643                 EGD(guard)->fakecorr[0].ftyp = TRCORNER;
644             else if (x == lowx - 1 && y == hiy + 1)
645                 EGD(guard)->fakecorr[0].ftyp = BLCORNER;
646             else if (x == hix + 1 && y == hiy + 1)
647                 EGD(guard)->fakecorr[0].ftyp = BRCORNER;
648             else if (y == lowy - 1 || y == hiy + 1)
649                 EGD(guard)->fakecorr[0].ftyp = HWALL;
650             else if (x == lowx - 1 || x == hix + 1)
651                 EGD(guard)->fakecorr[0].ftyp = VWALL;
652         }
653         levl[x][y].typ = DOOR;
654         levl[x][y].doormask = D_NODOOR;
655         unblock_point(x, y); /* doesn't block light */
656         EGD(guard)->fcend = 1;
657         EGD(guard)->warncnt = 1;
658     }
659 }
660
661 STATIC_OVL void
662 move_gold(gold, vroom)
663 struct obj *gold;
664 int vroom;
665 {
666     xchar nx, ny;
667
668     remove_object(gold);
669     newsym(gold->ox, gold->oy);
670     nx = rooms[vroom].lx + rn2(2);
671     ny = rooms[vroom].ly + rn2(2);
672     place_object(gold, nx, ny);
673     stackobj(gold);
674     newsym(nx, ny);
675 }
676
677 STATIC_OVL void
678 wallify_vault(grd)
679 struct monst *grd;
680 {
681     int x, y, typ;
682     int vlt = EGD(grd)->vroom;
683     char tmp_viz;
684     xchar lox = rooms[vlt].lx - 1, hix = rooms[vlt].hx + 1,
685           loy = rooms[vlt].ly - 1, hiy = rooms[vlt].hy + 1;
686     struct monst *mon;
687     struct obj *gold;
688     struct trap *trap;
689     boolean fixed = FALSE;
690     boolean movedgold = FALSE;
691
692     for (x = lox; x <= hix; x++)
693         for (y = loy; y <= hiy; y++) {
694             /* if not on the room boundary, skip ahead */
695             if (x != lox && x != hix && y != loy && y != hiy)
696                 continue;
697
698             if (!IS_WALL(levl[x][y].typ) && !in_fcorridor(grd, x, y)) {
699                 if ((mon = m_at(x, y)) != 0 && mon != grd) {
700                     if (mon->mtame)
701                         yelp(mon);
702                     (void) rloc(mon, FALSE);
703                 }
704                 if ((gold = g_at(x, y)) != 0) {
705                     move_gold(gold, EGD(grd)->vroom);
706                     movedgold = TRUE;
707                 }
708                 if ((trap = t_at(x, y)) != 0)
709                     deltrap(trap);
710                 if (x == lox)
711                     typ =
712                         (y == loy) ? TLCORNER : (y == hiy) ? BLCORNER : VWALL;
713                 else if (x == hix)
714                     typ =
715                         (y == loy) ? TRCORNER : (y == hiy) ? BRCORNER : VWALL;
716                 else /* not left or right side, must be top or bottom */
717                     typ = HWALL;
718                 levl[x][y].typ = typ;
719                 levl[x][y].doormask = 0;
720                 /*
721                  * hack: player knows walls are restored because of the
722                  * message, below, so show this on the screen.
723                  */
724                 tmp_viz = viz_array[y][x];
725                 viz_array[y][x] = IN_SIGHT | COULD_SEE;
726                 newsym(x, y);
727                 viz_array[y][x] = tmp_viz;
728                 block_point(x, y);
729                 fixed = TRUE;
730             }
731         }
732
733     if (movedgold || fixed) {
734         if (in_fcorridor(grd, grd->mx, grd->my) || cansee(grd->mx, grd->my))
735 /*JP
736             pline("%s whispers an incantation.", noit_Monnam(grd));
737 */
738             pline("%s\82Í\8eô\95\82ð\82³\82³\82â\82¢\82½\81D", noit_Monnam(grd));
739         else
740 /*JP
741             You_hear("a distant chant.");
742 */
743             You_hear("\89\93\95û\82Å\82Ì\8eô\95\82ð\95·\82¢\82½\81D");
744         if (movedgold)
745 /*JP
746             pline("A mysterious force moves the gold into the vault.");
747 */
748             pline("\95s\8ev\8bc\82È\97Í\82ª\8bà\89Ý\82ð\91q\8cÉ\82Ö\89^\82ñ\82¾\81D");
749         if (fixed)
750 /*JP
751             pline_The("damaged vault's walls are magically restored!");
752 */
753             pline("\8f\9d\82Â\82¢\82½\91q\8cÉ\82Ì\95Ç\82Í\96\82\96@\82Å\95\9c\8c³\82³\82ê\82½\81I");
754     }
755 }
756
757 STATIC_OVL void
758 gd_mv_monaway(grd, nx, ny)
759 register struct monst *grd;
760 int nx, ny;
761 {
762     if (MON_AT(nx, ny) && !(nx == grd->mx && ny == grd->my)) {
763         if (!Deaf)
764 /*JP
765             verbalize("Out of my way, scum!");
766 */
767             verbalize("\96Ú\82Ì\91O\82©\82ç\8fÁ\82¦\82ë\81C\83N\83\\82Á\82½\82ê\81I");
768         if (!rloc(m_at(nx, ny), FALSE) || MON_AT(nx, ny))
769             m_into_limbo(m_at(nx, ny));
770     }
771 }
772
773 /* have guard pick gold off the floor, possibly moving to the gold's
774    position before message and back to his current spot after */
775 STATIC_OVL void
776 gd_pick_corridor_gold(grd, goldx, goldy)
777 struct monst *grd;
778 int goldx, goldy; /* <gold->ox, gold->oy> */
779 {
780     struct obj *gold;
781     coord newcc, bestcc;
782     int gdelta, newdelta, bestdelta, tryct,
783         guardx = grd->mx, guardy = grd->my;
784     boolean under_u = (goldx == u.ux && goldy == u.uy),
785             see_it = cansee(goldx, goldy);
786
787     if (under_u) {
788         /* Grab the gold from between the hero's feet.
789            If guard is two or more steps away; bring him closer first. */
790         gold = g_at(goldx, goldy);
791         if (!gold) {
792             impossible("vault guard: no gold at hero's feet?");
793             return;
794         }
795         gdelta = distu(guardx, guardy);
796         if (gdelta > 2 && see_it) { /* skip if player won't see it */
797             bestdelta = gdelta;
798             bestcc.x = (xchar) guardx, bestcc.y = (xchar) guardy;
799             tryct = 9;
800             do {
801                 /* pick an available spot nearest the hero and also try
802                    to find the one meeting that criterium which is nearest
803                    the guard's current location */
804                 if (enexto(&newcc, goldx, goldy, grd->data)) {
805                     if ((newdelta = distu(newcc.x, newcc.y)) < bestdelta
806                         || (newdelta == bestdelta
807                             && dist2(newcc.x, newcc.y, guardx, guardy)
808                                < dist2(bestcc.x, bestcc.y, guardx, guardy))) {
809                         bestdelta = newdelta;
810                         bestcc = newcc;
811                     }
812                 }
813             } while (--tryct >= 0);
814
815             if (bestdelta < gdelta) {
816                 remove_monster(guardx, guardy);
817                 newsym(guardx, guardy);
818                 place_monster(grd, (int) bestcc.x, (int) bestcc.y);
819                 newsym(grd->mx, grd->my);
820             }
821         }
822         obj_extract_self(gold);
823         add_to_minv(grd, gold);
824         newsym(goldx, goldy);
825
826     /* guard is already at gold's location */
827     } else if (goldx == guardx && goldy == guardy) {
828         mpickgold(grd); /* does a newsym */
829
830     /* gold is at some third spot, neither guard's nor hero's */
831     } else {
832         /* just for insurance... */
833         gd_mv_monaway(grd, goldx, goldy); /* make room for guard */
834         if (see_it) { /* skip if player won't see the message */
835             remove_monster(grd->mx, grd->my);
836             newsym(grd->mx, grd->my);
837             place_monster(grd, goldx, goldy); /* sets <grd->mx, grd->my> */
838         }
839         mpickgold(grd); /* does a newsym */
840     }
841
842     if (see_it) { /* cansee(goldx, goldy) */
843         char monnambuf[BUFSZ];
844
845         Strcpy(monnambuf, Monnam(grd));
846         if (!strcmpi(monnambuf, "It"))
847             Strcpy(monnambuf, "Someone");
848 #if 0 /*JP:T*/
849         pline("%s%s picks up the gold%s.", monnambuf,
850               (grd->mpeaceful && EGD(grd)->warncnt > 5)
851                  ? " calms down and" : "",
852               under_u ? " from beneath you" : "");
853 #else
854         pline("%s\82Í%s%s\8bà\89Ý\82ð\8fE\82Á\82½\81D", monnambuf,
855               (grd->mpeaceful && EGD(grd)->warncnt > 5)
856                  ? "\93{\82è\82ð\90Ã\82ß" : "",
857               under_u ? "\82 \82È\82½\82Ì\91«\8c³\82Ì" : "");
858 #endif
859     }
860
861     /* if guard was moved to get the gold, move him back */
862     if (grd->mx != guardx || grd->my != guardy) {
863         remove_monster(grd->mx, grd->my);
864         newsym(grd->mx, grd->my);
865         place_monster(grd, guardx, guardy);
866         newsym(guardx, guardy);
867     }
868     return;
869 }
870
871 /*
872  * return  1: guard moved,  0: guard didn't,  -1: let m_move do it,  -2: died
873  */
874 int
875 gd_move(grd)
876 register struct monst *grd;
877 {
878     int x, y, nx, ny, m, n;
879     int dx, dy, gx = 0, gy = 0, fci;
880     uchar typ;
881     struct rm *crm;
882     struct fakecorridor *fcp;
883     register struct egd *egrd = EGD(grd);
884     long umoney = 0L;
885     boolean goldincorridor = FALSE, u_in_vault = FALSE, grd_in_vault = FALSE,
886             disappear_msg_seen = FALSE, semi_dead = DEADMONSTER(grd),
887             u_carry_gold = FALSE, newspot = FALSE, see_guard;
888
889     if (!on_level(&(egrd->gdlevel), &u.uz))
890         return -1;
891     nx = ny = m = n = 0;
892     if (semi_dead || !grd->mx || egrd->gddone) {
893         egrd->gddone = 1;
894         goto cleanup;
895     }
896     debugpline1("gd_move: %s guard", grd->mpeaceful ? "peaceful" : "hostile");
897
898     u_in_vault = vault_occupied(u.urooms) ? TRUE : FALSE;
899     grd_in_vault = *in_rooms(grd->mx, grd->my, VAULT) ? TRUE : FALSE;
900     if (!u_in_vault && !grd_in_vault)
901         wallify_vault(grd);
902
903     if (!grd->mpeaceful) {
904         if (!u_in_vault
905             && (grd_in_vault || (in_fcorridor(grd, grd->mx, grd->my)
906                                  && !in_fcorridor(grd, u.ux, u.uy)))) {
907             (void) rloc(grd, TRUE);
908             wallify_vault(grd);
909             if (!in_fcorridor(grd, grd->mx, grd->my))
910                 (void) clear_fcorr(grd, TRUE);
911             goto letknow;
912         }
913         if (!in_fcorridor(grd, grd->mx, grd->my))
914             (void) clear_fcorr(grd, TRUE);
915         return -1;
916     }
917     if (abs(egrd->ogx - grd->mx) > 1 || abs(egrd->ogy - grd->my) > 1)
918         return -1; /* teleported guard - treat as monster */
919
920     if (egrd->witness) {
921         if (!Deaf)
922 #if 0 /*JP:T*/
923             verbalize("How dare you %s that gold, scoundrel!",
924                       (egrd->witness & GD_EATGOLD) ? "consume" : "destroy");
925 #else
926             verbalize("\82æ\82­\82à\82Ü\82 \8bà\82ð%s\82à\82Ì\82¾\81C\88«\93}\82ß\81I",
927                       (egrd->witness & GD_EATGOLD) ? "\8eg\82Á\82½" : "\89ó\82µ\82½");
928 #endif
929         egrd->witness = 0;
930         grd->mpeaceful = 0;
931         return -1;
932     }
933
934     umoney = money_cnt(invent);
935     u_carry_gold = umoney > 0L || hidden_gold() > 0L;
936     if (egrd->fcend == 1) {
937         if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) {
938             if (egrd->warncnt == 3 && !Deaf)
939 #if 0 /*JP:T*/
940                 verbalize("I repeat, %sfollow me!",
941                           u_carry_gold
942                               ? (!umoney ? "drop that hidden money and "
943                                          : "drop that money and ")
944                               : "");
945 #else
946                 verbalize("\8cJ\82è\95Ô\82·\81I%s\8e\84\82É\82Â\82¢\82Ä\82±\82¢\81I",
947                           u_carry_gold
948                               ? (!umoney ? "\89B\82µ\8e\9d\82Á\82Ä\82é\8bà\82ð\92u\82¢\82Ä"
949                                          : "\8bà\82ð\92u\82¢\82Ä")
950                               : "");
951 #endif
952             if (egrd->warncnt == 7) {
953                 m = grd->mx;
954                 n = grd->my;
955                 if (!Deaf)
956 /*JP
957                     verbalize("You've been warned, knave!");
958 */
959                     verbalize("\8cx\8d\90\82Í\82µ\82½\82¼\81C\88«\93}\82ß\81I");
960                 mnexto(grd);
961                 levl[m][n].typ = egrd->fakecorr[0].ftyp;
962                 newsym(m, n);
963                 grd->mpeaceful = 0;
964                 return -1;
965             }
966             /* not fair to get mad when (s)he's fainted or paralyzed */
967             if (!is_fainted() && multi >= 0)
968                 egrd->warncnt++;
969             return 0;
970         }
971
972         if (!u_in_vault) {
973             if (u_carry_gold) { /* player teleported */
974                 m = grd->mx;
975                 n = grd->my;
976                 (void) rloc(grd, TRUE);
977                 levl[m][n].typ = egrd->fakecorr[0].ftyp;
978                 newsym(m, n);
979                 grd->mpeaceful = 0;
980  letknow:
981                 if (!cansee(grd->mx, grd->my) || !mon_visible(grd))
982 #if 0 /*JP:T*/
983                     You_hear("%s.",
984                              m_carrying(grd, TIN_WHISTLE)
985                                  ? "the shrill sound of a guard's whistle"
986                                  : "angry shouting");
987 #else
988                     You_hear("%s\82ð\95·\82¢\82½\81D",
989                              m_carrying(grd, TIN_WHISTLE)
990                                  ? "\94Ô\95º\82Ì\89s\82¢\93J\82Ì\89¹"
991                                  : "\93{\82è\82Ì\8b©\82Ñ");
992 #endif
993                 else
994 #if 0 /*JP:T*/
995                     You(um_dist(grd->mx, grd->my, 2)
996                             ? "see %s approaching."
997                             : "are confronted by %s.",
998                         /* "an angry guard" */
999                         x_monnam(grd, ARTICLE_A, "angry", 0, FALSE));
1000 #else
1001                     You(um_dist(grd->mx, grd->my, 2)
1002                         ? "%s\82ª\8bß\82Ã\82¢\82Ä\82­\82é\82Ì\82ð\8c©\82½\81D"
1003                         : "%s\82Æ\91Î\9b³\82µ\82½\81D",
1004                         x_monnam(grd, ARTICLE_A, "\93{\82Á\82½", 0, FALSE));
1005 #endif
1006                 return -1;
1007             } else {
1008                 if (!Deaf)
1009 /*JP
1010                     verbalize("Well, begone.");
1011 */
1012                     verbalize("\97§\82¿\8b\8e\82ê\81D");
1013                 egrd->gddone = 1;
1014                 goto cleanup;
1015             }
1016         }
1017     }
1018
1019     if (egrd->fcend > 1) {
1020         if (egrd->fcend > 2 && in_fcorridor(grd, grd->mx, grd->my)
1021             && !egrd->gddone && !in_fcorridor(grd, u.ux, u.uy)
1022             && levl[egrd->fakecorr[0].fx][egrd->fakecorr[0].fy].typ
1023                    == egrd->fakecorr[0].ftyp) {
1024 /*JP
1025             pline("%s, confused, disappears.", noit_Monnam(grd));
1026 */
1027             pline("%s\82Í\8d¬\97\90\82µ\81C\8fÁ\82¦\82½\81D", noit_Monnam(grd));
1028             disappear_msg_seen = TRUE;
1029             goto cleanup;
1030         }
1031         if (u_carry_gold && (in_fcorridor(grd, u.ux, u.uy)
1032                              /* cover a 'blind' spot */
1033                              || (egrd->fcend > 1 && u_in_vault))) {
1034             if (!grd->mx) {
1035                 restfakecorr(grd);
1036                 return -2;
1037             }
1038             if (egrd->warncnt < 6) {
1039                 egrd->warncnt = 6;
1040                 if (Deaf) {
1041                     if (!Blind)
1042 #if 0 /*JP:T*/
1043                         pline("%s holds out %s palm demandingly!",
1044                               noit_Monnam(grd), noit_mhis(grd));
1045 #else
1046                         pline("%s\82Í\8cµ\82µ\82¢\92²\8eq\82Å\8eè\82Ì\82Ð\82ç\82ð\8d·\82µ\8fo\82µ\82½\81I",
1047                               noit_Monnam(grd));
1048 #endif
1049                 } else {
1050 /*JP
1051                     verbalize("Drop all your gold, scoundrel!");
1052 */
1053                     verbalize("\8bà\82ð\91S\95\94\92u\82¢\82Ä\82ä\82¯\81C\82È\82ç\82¸\82à\82Ì\81I");
1054                 }
1055                 return 0;
1056             } else {
1057                 if (Deaf) {
1058                     if (!Blind)
1059 #if 0 /*JP:T*/
1060                         pline("%s rubs %s hands with enraged delight!",
1061                               noit_Monnam(grd), noit_mhis(grd));
1062 #else
1063                         pline("%s\82Í\93{\82è\82È\82ª\82ç\8eè\82ð\82·\82è\82 \82í\82¹\82½\81I",
1064                               noit_Monnam(grd));
1065 #endif
1066                 } else {
1067 /*JP
1068                     verbalize("So be it, rogue!");
1069 */
1070                     verbalize("\93\90\90l\82ß\81I");
1071                 }
1072                 grd->mpeaceful = 0;
1073                 return -1;
1074             }
1075         }
1076     }
1077     for (fci = egrd->fcbeg; fci < egrd->fcend; fci++)
1078         if (g_at(egrd->fakecorr[fci].fx, egrd->fakecorr[fci].fy)) {
1079             m = egrd->fakecorr[fci].fx;
1080             n = egrd->fakecorr[fci].fy;
1081             goldincorridor = TRUE;
1082             break;
1083         }
1084     /* new gold can appear if it was embedded in stone and hero kicks it
1085        (on even via wish and drop) so don't assume hero has been warned */
1086     if (goldincorridor && !egrd->gddone) {
1087         gd_pick_corridor_gold(grd, m, n);
1088         if (!grd->mpeaceful)
1089             return -1;
1090         egrd->warncnt = 5;
1091         return 0;
1092     }
1093     if (um_dist(grd->mx, grd->my, 1) || egrd->gddone) {
1094         if (!egrd->gddone && !rn2(10) && !Deaf && !u.uswallow
1095             && !(u.ustuck && !sticks(youmonst.data)))
1096 /*JP
1097             verbalize("Move along!");
1098 */
1099             verbalize("\97£\82ê\82é\82È\81I");
1100         restfakecorr(grd);
1101         return 0; /* didn't move */
1102     }
1103     x = grd->mx;
1104     y = grd->my;
1105
1106     if (u_in_vault)
1107         goto nextpos;
1108
1109     /* look around (hor & vert only) for accessible places */
1110     for (nx = x - 1; nx <= x + 1; nx++)
1111         for (ny = y - 1; ny <= y + 1; ny++) {
1112             if ((nx == x || ny == y) && (nx != x || ny != y)
1113                 && isok(nx, ny)) {
1114                 typ = (crm = &levl[nx][ny])->typ;
1115                 if (!IS_STWALL(typ) && !IS_POOL(typ)) {
1116                     if (in_fcorridor(grd, nx, ny))
1117                         goto nextnxy;
1118
1119                     if (*in_rooms(nx, ny, VAULT))
1120                         continue;
1121
1122                     /* seems we found a good place to leave him alone */
1123                     egrd->gddone = 1;
1124                     if (ACCESSIBLE(typ))
1125                         goto newpos;
1126 #ifdef STUPID
1127                     if (typ == SCORR)
1128                         crm->typ = CORR;
1129                     else
1130                         crm->typ = DOOR;
1131 #else
1132                     crm->typ = (typ == SCORR) ? CORR : DOOR;
1133 #endif
1134                     if (crm->typ == DOOR)
1135                         crm->doormask = D_NODOOR;
1136                     goto proceed;
1137                 }
1138             }
1139  nextnxy:
1140             ;
1141         }
1142  nextpos:
1143     nx = x;
1144     ny = y;
1145     gx = egrd->gdx;
1146     gy = egrd->gdy;
1147     dx = (gx > x) ? 1 : (gx < x) ? -1 : 0;
1148     dy = (gy > y) ? 1 : (gy < y) ? -1 : 0;
1149     if (abs(gx - x) >= abs(gy - y))
1150         nx += dx;
1151     else
1152         ny += dy;
1153
1154     while ((typ = (crm = &levl[nx][ny])->typ) != STONE) {
1155         /* in view of the above we must have IS_WALL(typ) or typ == POOL */
1156         /* must be a wall here */
1157         if (isok(nx + nx - x, ny + ny - y) && !IS_POOL(typ)
1158             && IS_ROOM(levl[nx + nx - x][ny + ny - y].typ)) {
1159             crm->typ = DOOR;
1160             crm->doormask = D_NODOOR;
1161             goto proceed;
1162         }
1163         if (dy && nx != x) {
1164             nx = x;
1165             ny = y + dy;
1166             continue;
1167         }
1168         if (dx && ny != y) {
1169             ny = y;
1170             nx = x + dx;
1171             dy = 0;
1172             continue;
1173         }
1174         /* I don't like this, but ... */
1175         if (IS_ROOM(typ)) {
1176             crm->typ = DOOR;
1177             crm->doormask = D_NODOOR;
1178             goto proceed;
1179         }
1180         break;
1181     }
1182     crm->typ = CORR;
1183  proceed:
1184     newspot = TRUE;
1185     unblock_point(nx, ny); /* doesn't block light */
1186     if (cansee(nx, ny))
1187         newsym(nx, ny);
1188
1189     if ((nx != gx || ny != gy) || (grd->mx != gx || grd->my != gy)) {
1190         fcp = &(egrd->fakecorr[egrd->fcend]);
1191         if (egrd->fcend++ == FCSIZ)
1192             panic("fakecorr overflow");
1193         fcp->fx = nx;
1194         fcp->fy = ny;
1195         fcp->ftyp = typ;
1196     } else if (!egrd->gddone) {
1197         /* We're stuck, so try to find a new destination. */
1198         if (!find_guard_dest(grd, &egrd->gdx, &egrd->gdy)
1199             || (egrd->gdx == gx && egrd->gdy == gy)) {
1200 /*JP
1201             pline("%s, confused, disappears.", Monnam(grd));
1202 */
1203             pline("%s\82Í\8d¬\97\90\82µ\81C\8fÁ\82¦\82½\81D", Monnam(grd));
1204             disappear_msg_seen = TRUE;
1205             goto cleanup;
1206         } else
1207             goto nextpos;
1208     }
1209  newpos:
1210     gd_mv_monaway(grd, nx, ny);
1211     if (egrd->gddone) {
1212         /* The following is a kludge.  We need to keep    */
1213         /* the guard around in order to be able to make   */
1214         /* the fake corridor disappear as the player      */
1215         /* moves out of it, but we also need the guard    */
1216         /* out of the way.  We send the guard to never-   */
1217         /* never land.  We set ogx ogy to mx my in order  */
1218         /* to avoid a check at the top of this function.  */
1219         /* At the end of the process, the guard is killed */
1220         /* in restfakecorr().                             */
1221  cleanup:
1222         x = grd->mx, y = grd->my;
1223         see_guard = canspotmon(grd);
1224         parkguard(grd); /* move to <0,0> */
1225         wallify_vault(grd);
1226         restfakecorr(grd);
1227         debugpline2("gd_move: %scleanup%s",
1228                     grd->isgd ? "" : "final ",
1229                     grd->isgd ? " attempt" : "");
1230         if (!semi_dead && (in_fcorridor(grd, u.ux, u.uy) || cansee(x, y))) {
1231             if (!disappear_msg_seen && see_guard)
1232 /*JP
1233                 pline("Suddenly, %s disappears.", noit_mon_nam(grd));
1234 */
1235                 pline("\93Ë\91R\81C%s\82Í\8fÁ\82¦\82½\81D", noit_mon_nam(grd));
1236             return 1;
1237         }
1238         return -2;
1239     }
1240     egrd->ogx = grd->mx; /* update old positions */
1241     egrd->ogy = grd->my;
1242     remove_monster(grd->mx, grd->my);
1243     place_monster(grd, nx, ny);
1244     if (newspot && g_at(nx, ny)) {
1245         /* if there's gold already here (most likely from mineralize()),
1246            pick it up now so that guard doesn't later think hero dropped
1247            it and give an inappropriate message */
1248         mpickgold(grd);
1249         if (canspotmon(grd))
1250 /*JP
1251             pline("%s picks up some gold.", Monnam(grd));
1252 */
1253             pline("%s\82Í\8bà\82ð\8fE\82Á\82½\81D", Monnam(grd));
1254     } else
1255         newsym(grd->mx, grd->my);
1256     restfakecorr(grd);
1257     return 1;
1258 }
1259
1260 /* Routine when dying or quitting with a vault guard around */
1261 void
1262 paygd(silently)
1263 boolean silently;
1264 {
1265     register struct monst *grd = findgd();
1266     long umoney = money_cnt(invent);
1267     struct obj *coins, *nextcoins;
1268     int gx, gy;
1269     char buf[BUFSZ];
1270
1271     if (!umoney || !grd)
1272         return;
1273
1274     if (u.uinvault) {
1275         if (!silently)
1276 #if 0 /*JP:T*/
1277             Your("%ld %s goes into the Magic Memory Vault.",
1278                  umoney, currency(umoney));
1279 #else
1280             Your("%ld%s\82Í\96\82\96@\82Ì\8bL\94O\91q\8cÉ\82É\93ü\82Á\82½\81D",
1281                  umoney, currency(umoney));
1282 #endif
1283         gx = u.ux;
1284         gy = u.uy;
1285     } else {
1286         if (grd->mpeaceful) /* peaceful guard has no "right" to your gold */
1287             goto remove_guard;
1288
1289         mnexto(grd);
1290         if (!silently)
1291 /*JP
1292             pline("%s remits your gold to the vault.", Monnam(grd));
1293 */
1294             pline("%s\82Í\82 \82È\82½\82Ì\8bà\89Ý\82ð\91q\8cÉ\82É\91\97\82Á\82½\81D", Monnam(grd));
1295         gx = rooms[EGD(grd)->vroom].lx + rn2(2);
1296         gy = rooms[EGD(grd)->vroom].ly + rn2(2);
1297 #if 0 /*JP:T*/
1298         Sprintf(buf, "To Croesus: here's the gold recovered from %s the %s.",
1299                 plname, mons[u.umonster].mname);
1300 #else
1301         Sprintf(buf, "\83N\83\8d\83C\83\\83X\82Ö: \82±\82±\82É%s\82Ì%s\82©\82ç\8eæ\82è\96ß\82µ\82½\8bà\89Ý\82ð\91\97\82é\81D",
1302                 mons[u.umonster].mname, plname);
1303 #endif
1304         make_grave(gx, gy, buf);
1305     }
1306     for (coins = invent; coins; coins = nextcoins) {
1307         nextcoins = coins->nobj;
1308         if (objects[coins->otyp].oc_class == COIN_CLASS) {
1309             freeinv(coins);
1310             place_object(coins, gx, gy);
1311             stackobj(coins);
1312         }
1313     }
1314  remove_guard:
1315     mongone(grd);
1316     return;
1317 }
1318
1319 long
1320 hidden_gold()
1321 {
1322     long value = 0L;
1323     struct obj *obj;
1324
1325     for (obj = invent; obj; obj = obj->nobj)
1326         if (Has_contents(obj))
1327             value += contained_gold(obj);
1328     /* unknown gold stuck inside statues may cause some consternation... */
1329
1330     return value;
1331 }
1332
1333 /* prevent "You hear footsteps.." when inappropriate */
1334 boolean
1335 gd_sound()
1336 {
1337     struct monst *grd = findgd();
1338
1339     if (vault_occupied(u.urooms))
1340         return FALSE;
1341     else
1342         return (boolean) (grd == (struct monst *) 0);
1343 }
1344
1345 void
1346 vault_gd_watching(activity)
1347 unsigned int activity;
1348 {
1349     struct monst *guard = findgd();
1350
1351     if (guard && guard->mcansee && m_canseeu(guard)) {
1352         if (activity == GD_EATGOLD || activity == GD_DESTROYGOLD)
1353             EGD(guard)->witness = activity;
1354     }
1355 }
1356
1357 /*vault.c*/