OSDN Git Service

宿屋に24時間いつでも泊まれるように変更. 朝や昼に泊まった場合は当日の
[hengband/hengband.git] / src / bldg.c
1 /* File: bldg.c */
2
3 /*
4  * Purpose: Building commands
5  * Created by Ken Wigle for Kangband - a variant of Angband 2.8.3
6  * -KMW-
7  *
8  * Rewritten for Kangband 2.8.3i using Kamband's version of
9  * bldg.c as written by Ivan Tkatchev
10  *
11  * Changed for ZAngband by Robert Ruehlmann
12  */
13
14 #include "angband.h"
15
16 /* hack as in leave_store in store.c */
17 static bool leave_bldg = FALSE;
18
19 static bool is_owner(building_type *bldg)
20 {
21         if (bldg->member_class[p_ptr->pclass] == BUILDING_OWNER)
22         {
23                 return (TRUE);
24         }
25
26         if (bldg->member_race[p_ptr->prace] == BUILDING_OWNER)
27         {
28                 return (TRUE);
29         }
30
31         if ((is_magic(p_ptr->realm1) && (bldg->member_realm[p_ptr->realm1] == BUILDING_OWNER)) ||
32                 (is_magic(p_ptr->realm2) && (bldg->member_realm[p_ptr->realm2] == BUILDING_OWNER)))
33         {
34                 return (TRUE);
35         }
36
37         return (FALSE);
38 }
39
40
41 static bool is_member(building_type *bldg)
42 {
43         if (bldg->member_class[p_ptr->pclass])
44         {
45                 return (TRUE);
46         }
47
48         if (bldg->member_race[p_ptr->prace])
49         {
50                 return (TRUE);
51         }
52
53         if ((is_magic(p_ptr->realm1) && bldg->member_realm[p_ptr->realm1]) ||
54             (is_magic(p_ptr->realm2) && bldg->member_realm[p_ptr->realm2]))
55         {
56                 return (TRUE);
57         }
58
59
60         if (p_ptr->pclass == CLASS_SORCERER)
61         {
62                 int i;
63                 bool OK = FALSE;
64                 for (i = 0; i < MAX_MAGIC; i++)
65                 {
66                         if (bldg->member_realm[i+1]) OK = TRUE;
67                 }
68                 return OK;
69         }
70         return (FALSE);
71 }
72
73
74 /*
75  * Clear the building information
76  */
77 static void clear_bldg(int min_row, int max_row)
78 {
79         int   i;
80
81         for (i = min_row; i <= max_row; i++)
82                 prt("", i, 0);
83 }
84
85 static void building_prt_gold(void)
86 {
87         char tmp_str[80];
88
89 #ifdef JP
90 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 23,53);
91 #else
92         prt("Gold Remaining: ", 23, 53);
93 #endif
94
95
96         sprintf(tmp_str, "%9ld", (long)p_ptr->au);
97         prt(tmp_str, 23, 68);
98 }
99
100
101 /*
102  * Display a building.
103  */
104 static void show_building(building_type* bldg)
105 {
106         char buff[20];
107         int i;
108         byte action_color;
109         char tmp_str[80];
110
111         Term_clear();
112         sprintf(tmp_str, "%s (%s) %35s", bldg->owner_name, bldg->owner_race, bldg->name);
113         prt(tmp_str, 2, 1);
114
115
116         for (i = 0; i < 8; i++)
117         {
118                 if (bldg->letters[i])
119                 {
120                         if (bldg->action_restr[i] == 0)
121                         {
122                                 if ((is_owner(bldg) && (bldg->member_costs[i] == 0)) ||
123                                         (!is_owner(bldg) && (bldg->other_costs[i] == 0)))
124                                 {
125                                         action_color = TERM_WHITE;
126                                         buff[0] = '\0';
127                                 }
128                                 else if (is_owner(bldg))
129                                 {
130                                         action_color = TERM_YELLOW;
131 #ifdef JP
132 sprintf(buff, "($%ld)", bldg->member_costs[i]);
133 #else
134                                         sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
135 #endif
136
137                                 }
138                                 else
139                                 {
140                                         action_color = TERM_YELLOW;
141 #ifdef JP
142 sprintf(buff, "($%ld)", bldg->other_costs[i]);
143 #else
144                                         sprintf(buff, "(%ldgp)", bldg->other_costs[i]);
145 #endif
146
147                                 }
148                         }
149                         else if (bldg->action_restr[i] == 1)
150                         {
151                                 if (!is_member(bldg))
152                                 {
153                                         action_color = TERM_L_DARK;
154 #ifdef JP
155 strcpy(buff, "(ÊÄŹ)");
156 #else
157                                         strcpy(buff, "(closed)");
158 #endif
159
160                                 }
161                                 else if ((is_owner(bldg) && (bldg->member_costs[i] == 0)) ||
162                                         (is_member(bldg) && (bldg->other_costs[i] == 0)))
163                                 {
164                                         action_color = TERM_WHITE;
165                                         buff[0] = '\0';
166                                 }
167                                 else if (is_owner(bldg))
168                                 {
169                                         action_color = TERM_YELLOW;
170 #ifdef JP
171 sprintf(buff, "($%ld)", bldg->member_costs[i]);
172 #else
173                                         sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
174 #endif
175
176                                 }
177                                 else
178                                 {
179                                         action_color = TERM_YELLOW;
180 #ifdef JP
181 sprintf(buff, "($%ld)", bldg->other_costs[i]);
182 #else
183                                         sprintf(buff, "(%ldgp)", bldg->other_costs[i]);
184 #endif
185
186                                 }
187                         }
188                         else
189                         {
190                                 if (!is_owner(bldg))
191                                 {
192                                         action_color = TERM_L_DARK;
193 #ifdef JP
194 strcpy(buff, "(ÊÄŹ)");
195 #else
196                                         strcpy(buff, "(closed)");
197 #endif
198
199                                 }
200                                 else if (bldg->member_costs[i] != 0)
201                                 {
202                                         action_color = TERM_YELLOW;
203 #ifdef JP
204 sprintf(buff, "($%ld)", bldg->member_costs[i]);
205 #else
206                                         sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
207 #endif
208
209                                 }
210                                 else
211                                 {
212                                         action_color = TERM_WHITE;
213                                         buff[0] = '\0';
214                                 }
215                         }
216
217                         sprintf(tmp_str," %c) %s %s", bldg->letters[i], bldg->act_names[i], buff);
218                         c_put_str(action_color, tmp_str, 19+(i/2), 35*(i%2));
219                 }
220         }
221
222 #ifdef JP
223 prt(" ESC) ·úʪ¤ò½Ð¤ë", 23, 0);
224 #else
225         prt(" ESC) Exit building", 23, 0);
226 #endif
227
228 }
229
230
231 /*
232  * arena commands
233  */
234 static void arena_comm(int cmd)
235 {
236         monster_race    *r_ptr;
237         cptr            name;
238
239
240         switch (cmd)
241         {
242                 case BACT_ARENA:
243                         if (p_ptr->arena_number == MAX_ARENA_MONS)
244                         {
245                                 clear_bldg(5, 19);
246 #ifdef JP
247 prt("¥¢¥ê¡¼¥Ê¤ÎÍ¥¾¡¼Ô¡ª", 5, 0);
248 prt("¤ª¤á¤Ç¤È¤¦¡ª¤¢¤Ê¤¿¤ÏÁ´¤Æ¤ÎŨ¤òÅݤ·¤Þ¤·¤¿¡£", 7, 0); 
249 prt("¾Þ¶â¤È¤·¤Æ $1,000,000 ¤¬Í¿¤¨¤é¤ì¤Þ¤¹¡£", 8, 0);
250 #else
251                                 prt("               Arena Victor!", 5, 0);
252                                 prt("Congratulations!  You have defeated all before you.", 7, 0);
253                                 prt("For that, receive the prize: 1,000,000 gold pieces", 8, 0);
254 #endif
255
256                                 prt("", 10, 0);
257                                 prt("", 11, 0);
258                                 p_ptr->au += 1000000L;
259 #ifdef JP
260 msg_print("¥¹¥Ú¡¼¥¹¥­¡¼¤Ç³¹Ô");
261 #else
262                                 msg_print("Press the space bar to continue");
263 #endif
264
265                                 msg_print(NULL);
266                                 p_ptr->arena_number++;
267                         }
268                         else if (p_ptr->arena_number > MAX_ARENA_MONS)
269                         {
270                                 if (p_ptr->arena_number < MAX_ARENA_MONS+2)
271                                 {
272 #ifdef JP
273 msg_print("·¯¤Î¤¿¤á¤ËºÇ¶¯¤ÎÄ©Àï¼Ô¤òÍÑ°Õ¤·¤Æ¤ª¤¤¤¿¡£");
274 #else
275                                         msg_print("The strongest challenger is waiting for you.");
276 #endif
277
278                                         msg_print(NULL);
279 #ifdef JP
280                                         if (get_check("Ä©À魯¤ë¤«¤Í¡©"))
281 #else
282                                         if (get_check("Do you fight? "))
283 #endif
284                                         {
285                                                 p_ptr->leftbldg = TRUE;
286                                                 p_ptr->exit_bldg = FALSE;
287                                                 reset_tim_flags();
288
289                                                 /* Save the surface floor to preserve pets */
290                                                 prepare_change_floor_mode(CFM_SAVE_SURFACE);
291
292                                                 p_ptr->inside_arena = TRUE;
293                                                 p_ptr->leaving = TRUE;
294                                                 leave_bldg = TRUE;
295                                         }
296                                         else
297                                         {
298 #ifdef JP
299 msg_print("»ÄÇ°¤À¡£");
300 #else
301                                                 msg_print("We are disappointed.");
302 #endif
303                                         }
304                                 }
305                                 else
306                                 {
307 #ifdef JP
308 msg_print("¤¢¤Ê¤¿¤Ï¥¢¥ê¡¼¥Ê¤ËÆþ¤ê¡¢¤·¤Ð¤é¤¯¤Î´Ö±É¸÷¤Ë¤Ò¤¿¤Ã¤¿¡£");
309 #else
310                                         msg_print("You enter the arena briefly and bask in your glory.");
311 #endif
312
313                                         msg_print(NULL);
314                                 }
315                         }
316                         else if (p_ptr->riding && (p_ptr->pclass != CLASS_BEASTMASTER) && (p_ptr->pclass != CLASS_CAVALRY))
317                         {
318 #ifdef JP
319 msg_print("¥Ú¥Ã¥È¤Ë¾è¤Ã¤¿¤Þ¤Þ¤Ç¤Ï¥¢¥ê¡¼¥Ê¤ØÆþ¤ì¤µ¤»¤Æ¤â¤é¤¨¤Ê¤«¤Ã¤¿¡£");
320 #else
321                                 msg_print("You don't have permission to enter with pet.");
322 #endif
323
324                                 msg_print(NULL);
325                         }
326                         else
327                         {
328                                 p_ptr->leftbldg = TRUE;
329                                 p_ptr->exit_bldg = FALSE;
330                                 reset_tim_flags();
331
332                                 /* Save the surface floor to preserve pets */
333                                 prepare_change_floor_mode(CFM_SAVE_SURFACE);
334
335                                 p_ptr->inside_arena = TRUE;
336                                 p_ptr->leaving = TRUE;
337                                 leave_bldg = TRUE;
338                         }
339                         break;
340                 case BACT_POSTER:
341                         if (p_ptr->arena_number == MAX_ARENA_MONS)
342 #ifdef JP
343 msg_print("¤¢¤Ê¤¿¤Ï¾¡Íø¼Ô¤À¡£ ¥¢¥ê¡¼¥Ê¤Ç¤Î¥»¥ì¥â¥Ë¡¼¤Ë»²²Ã¤·¤Ê¤µ¤¤¡£");
344 #else
345                                 msg_print("You are victorious. Enter the arena for the ceremony.");
346 #endif
347
348                         else if (p_ptr->arena_number > MAX_ARENA_MONS)
349                         {
350 #ifdef JP
351 msg_print("¤¢¤Ê¤¿¤Ï¤¹¤Ù¤Æ¤ÎŨ¤Ë¾¡Íø¤·¤¿¡£");
352 #else
353                                 msg_print("You have won against all foes.");
354 #endif
355                         }
356                         else
357                         {
358                                 r_ptr = &r_info[arena_info[p_ptr->arena_number].r_idx];
359                                 name = (r_name + r_ptr->name);
360 #ifdef JP
361 msg_format("%s ¤ËÄ©À魯¤ë¤â¤Î¤Ï¤¤¤Ê¤¤¤«¡©", name);
362 #else
363                                 msg_format("Do I hear any challenges against: %s", name);
364 #endif
365                         }
366                         break;
367                 case BACT_ARENA_RULES:
368
369                         /* Save screen */
370                         screen_save();
371
372                         /* Peruse the arena help file */
373 #ifdef JP
374 (void)show_file(TRUE, "arena_j.txt", NULL, 0, 0);
375 #else
376                         (void)show_file(TRUE, "arena.txt", NULL, 0, 0);
377 #endif
378
379
380                         /* Load screen */
381                         screen_load();
382
383                         break;
384         }
385 }
386
387
388 /*
389  * display fruit for dice slots
390  */
391 static void display_fruit(int row, int col, int fruit)
392 {
393         switch (fruit)
394         {
395                 case 0: /* lemon */
396 #ifdef JP
397                         c_put_str(TERM_YELLOW, "   ####.", row, col);
398                         c_put_str(TERM_YELLOW, "  #    #", row + 1, col);
399                         c_put_str(TERM_YELLOW, " #     #", row + 2, col);
400                         c_put_str(TERM_YELLOW, "#      #", row + 3, col);
401                         c_put_str(TERM_YELLOW, "#      #", row + 4, col);
402                         c_put_str(TERM_YELLOW, "#     # ", row + 5, col);
403                         c_put_str(TERM_YELLOW, "#    #  ", row + 6, col);
404                         c_put_str(TERM_YELLOW, ".####   ", row + 7, col);
405                         prt(                   " ¥ì¥â¥ó ", row + 8, col);
406 #else
407                         c_put_str(TERM_YELLOW, "   ####.", row, col);
408                         c_put_str(TERM_YELLOW, "  #    #", row + 1, col);
409                         c_put_str(TERM_YELLOW, " #     #", row + 2, col);
410                         c_put_str(TERM_YELLOW, "#      #", row + 3, col);
411                         c_put_str(TERM_YELLOW, "#      #", row + 4, col);
412                         c_put_str(TERM_YELLOW, "#     # ", row + 5, col);
413                         c_put_str(TERM_YELLOW, "#    #  ", row + 6, col);
414                         c_put_str(TERM_YELLOW, ".####   ", row + 7, col);
415                         prt(                   " Lemon  ", row + 8, col);
416 #endif
417
418                         break;
419                 case 1: /* orange */
420 #ifdef JP
421                         c_put_str(TERM_ORANGE, "   ##   ", row, col);
422                         c_put_str(TERM_ORANGE, "  #..#  ", row + 1, col);
423                         c_put_str(TERM_ORANGE, " #....# ", row + 2, col);
424                         c_put_str(TERM_ORANGE, "#......#", row + 3, col);
425                         c_put_str(TERM_ORANGE, "#......#", row + 4, col);
426                         c_put_str(TERM_ORANGE, " #....# ", row + 5, col);
427                         c_put_str(TERM_ORANGE, "  #..#  ", row + 6, col);
428                         c_put_str(TERM_ORANGE, "   ##   ", row + 7, col);
429                         prt(                   "¥ª¥ì¥ó¥¸", row + 8, col);
430 #else
431                         c_put_str(TERM_ORANGE, "   ##   ", row, col);
432                         c_put_str(TERM_ORANGE, "  #..#  ", row + 1, col);
433                         c_put_str(TERM_ORANGE, " #....# ", row + 2, col);
434                         c_put_str(TERM_ORANGE, "#......#", row + 3, col);
435                         c_put_str(TERM_ORANGE, "#......#", row + 4, col);
436                         c_put_str(TERM_ORANGE, " #....# ", row + 5, col);
437                         c_put_str(TERM_ORANGE, "  #..#  ", row + 6, col);
438                         c_put_str(TERM_ORANGE, "   ##   ", row + 7, col);
439                         prt(                   " Orange ", row + 8, col);
440 #endif
441
442                         break;
443                 case 2: /* sword */
444 #ifdef JP
445                         c_put_str(TERM_SLATE, "   ¦«   " , row, col);
446                         c_put_str(TERM_SLATE, "   ||   " , row + 1, col);
447                         c_put_str(TERM_SLATE, "   ||   " , row + 2, col);
448                         c_put_str(TERM_SLATE, "   ||   " , row + 3, col);
449                         c_put_str(TERM_SLATE, "   ||   " , row + 4, col);
450                         c_put_str(TERM_SLATE, "   ||   " , row + 5, col);
451                         c_put_str(TERM_UMBER, " |=°¡=| " , row + 6, col);
452                         c_put_str(TERM_UMBER, "   ÌÜ   " , row + 7, col);
453                         prt(                  "   ·õ   " , row + 8, col);
454 #else
455                         c_put_str(TERM_SLATE, "   /\\   " , row, col);
456                         c_put_str(TERM_SLATE, "   ##   " , row + 1, col);
457                         c_put_str(TERM_SLATE, "   ##   " , row + 2, col);
458                         c_put_str(TERM_SLATE, "   ##   " , row + 3, col);
459                         c_put_str(TERM_SLATE, "   ##   " , row + 4, col);
460                         c_put_str(TERM_SLATE, "   ##   " , row + 5, col);
461                         c_put_str(TERM_UMBER, " ###### " , row + 6, col);
462                         c_put_str(TERM_UMBER, "   ##   " , row + 7, col);
463                         prt(                  " Sword  " , row + 8, col);
464 #endif
465
466                         break;
467                 case 3: /* shield */
468 #ifdef JP
469                         c_put_str(TERM_SLATE, " ###### ", row, col);
470                         c_put_str(TERM_SLATE, "#      #", row + 1, col);
471                         c_put_str(TERM_SLATE, "# ++++ #", row + 2, col);
472                         c_put_str(TERM_SLATE, "# +==+ #", row + 3, col);
473                         c_put_str(TERM_SLATE, "#  ++  #", row + 4, col);
474                         c_put_str(TERM_SLATE, " #    # ", row + 5, col);
475                         c_put_str(TERM_SLATE, "  #  #  ", row + 6, col);
476                         c_put_str(TERM_SLATE, "   ##   ", row + 7, col);
477                         prt(                  "   ½â   ", row + 8, col);
478 #else
479                         c_put_str(TERM_SLATE, " ###### ", row, col);
480                         c_put_str(TERM_SLATE, "#      #", row + 1, col);
481                         c_put_str(TERM_SLATE, "# ++++ #", row + 2, col);
482                         c_put_str(TERM_SLATE, "# +==+ #", row + 3, col);
483                         c_put_str(TERM_SLATE, "#  ++  #", row + 4, col);
484                         c_put_str(TERM_SLATE, " #    # ", row + 5, col);
485                         c_put_str(TERM_SLATE, "  #  #  ", row + 6, col);
486                         c_put_str(TERM_SLATE, "   ##   ", row + 7, col);
487                         prt(                  " Shield ", row + 8, col);
488 #endif
489
490                         break;
491                 case 4: /* plum */
492 #ifdef JP
493                         c_put_str(TERM_VIOLET, "   ##   ", row, col);
494                         c_put_str(TERM_VIOLET, " ###### ", row + 1, col);
495                         c_put_str(TERM_VIOLET, "########", row + 2, col);
496                         c_put_str(TERM_VIOLET, "########", row + 3, col);
497                         c_put_str(TERM_VIOLET, "########", row + 4, col);
498                         c_put_str(TERM_VIOLET, " ###### ", row + 5, col);
499                         c_put_str(TERM_VIOLET, "  ####  ", row + 6, col);
500                         c_put_str(TERM_VIOLET, "   ##   ", row + 7, col);
501                         prt(                   " ¥×¥é¥à ", row + 8, col);
502 #else
503                         c_put_str(TERM_VIOLET, "   ##   ", row, col);
504                         c_put_str(TERM_VIOLET, " ###### ", row + 1, col);
505                         c_put_str(TERM_VIOLET, "########", row + 2, col);
506                         c_put_str(TERM_VIOLET, "########", row + 3, col);
507                         c_put_str(TERM_VIOLET, "########", row + 4, col);
508                         c_put_str(TERM_VIOLET, " ###### ", row + 5, col);
509                         c_put_str(TERM_VIOLET, "  ####  ", row + 6, col);
510                         c_put_str(TERM_VIOLET, "   ##   ", row + 7, col);
511                         prt(                   "  Plum  ", row + 8, col);
512 #endif
513
514                         break;
515                 case 5: /* cherry */
516 #ifdef JP
517                         c_put_str(TERM_RED, "      ##", row, col);
518                         c_put_str(TERM_RED, "   ###  ", row + 1, col);
519                         c_put_str(TERM_RED, "  #..#  ", row + 2, col);
520                         c_put_str(TERM_RED, "  #..#  ", row + 3, col);
521                         c_put_str(TERM_RED, " ###### ", row + 4, col);
522                         c_put_str(TERM_RED, "#..##..#", row + 5, col);
523                         c_put_str(TERM_RED, "#..##..#", row + 6, col);
524                         c_put_str(TERM_RED, " ##  ## ", row + 7, col);
525                         prt(                "¥Á¥§¥ê¡¼", row + 8, col);
526 #else
527                         c_put_str(TERM_RED, "      ##", row, col);
528                         c_put_str(TERM_RED, "   ###  ", row + 1, col);
529                         c_put_str(TERM_RED, "  #..#  ", row + 2, col);
530                         c_put_str(TERM_RED, "  #..#  ", row + 3, col);
531                         c_put_str(TERM_RED, " ###### ", row + 4, col);
532                         c_put_str(TERM_RED, "#..##..#", row + 5, col);
533                         c_put_str(TERM_RED, "#..##..#", row + 6, col);
534                         c_put_str(TERM_RED, " ##  ## ", row + 7, col);
535                         prt(                " Cherry ", row + 8, col);
536 #endif
537
538                         break;
539         }
540 }
541
542 /*
543  * kpoker no (tyuto-hannpa na)pakuri desu...
544  * joker ha shineru node haitte masen.
545  *
546  * TODO: donataka! tsukutte!
547  *  - agatta yaku no kiroku (like DQ).
548  *  - kakkoii card no e.
549  *  - sousa-sei no koujyo.
550  *  - code wo wakariyasuku.
551  *  - double up.
552  *  - Joker... -- done.
553  *
554  * 9/13/2000 --Koka
555  * 9/15/2000 joker wo jissou. soreto, code wo sukosi kakikae. --Habu
556  */
557 #define SUIT_OF(card)  ((card) / 13)
558 #define NUM_OF(card)   ((card) % 13)
559 #define IS_JOKER(card) ((card) == 52)
560
561 static int cards[5]; /* tefuda no card */
562
563 static void reset_deck(int deck[])
564 {
565         int i;
566         for (i = 0; i < 53; i++) deck[i] = i;
567
568         /* shuffle cards */
569         for (i = 0; i < 53; i++){
570                 int tmp1 = randint0(53 - i) + i;
571                 int tmp2 = deck[i];
572                 deck[i] = deck[tmp1];
573                 deck[tmp1] = tmp2;
574         }
575 }
576
577 static bool have_joker(void)
578 {
579         int i;
580
581         for (i = 0; i < 5; i++){
582           if(IS_JOKER(cards[i])) return TRUE;
583         }
584         return FALSE;
585 }
586
587 static bool find_card_num(int num)
588 {
589         int i;
590         for (i = 0; i < 5; i++)
591                 if (NUM_OF(cards[i]) == num && !IS_JOKER(cards[i])) return TRUE;
592         return FALSE;
593 }
594
595 static bool yaku_check_flush(void)
596 {
597         int i, suit;
598         bool joker_is_used = FALSE;
599
600         suit = IS_JOKER(cards[0]) ? SUIT_OF(cards[1]) : SUIT_OF(cards[0]);
601         for (i = 0; i < 5; i++){
602                 if (SUIT_OF(cards[i]) != suit){
603                   if(have_joker() && !joker_is_used)
604                     joker_is_used = TRUE;
605                   else
606                     return FALSE;
607                 }
608         }
609
610         return TRUE;
611 }
612
613 static int yaku_check_straight(void)
614 {
615         int i, lowest = 99;
616         bool joker_is_used = FALSE;
617
618         /* get lowest */
619         for (i = 0; i < 5; i++)
620         {
621                 if (NUM_OF(cards[i]) < lowest && !IS_JOKER(cards[i]))
622                         lowest = NUM_OF(cards[i]);
623         }
624         
625         if (yaku_check_flush())
626         {
627           if( lowest == 0 ){
628                 for (i = 0; i < 4; i++)
629                 {
630                         if (!find_card_num(9 + i)){
631                                 if( have_joker() && !joker_is_used )
632                                   joker_is_used = TRUE;
633                                 else
634                                   break;
635                         }
636                 }
637                 if (i == 4) return 3; /* Wow! Royal Flush!!! */
638           }
639           if( lowest == 9 ){
640                 for (i = 0; i < 3; i++)
641                 {
642                         if (!find_card_num(10 + i))
643                                 break;
644                 }
645                 if (i == 3 && have_joker()) return 3; /* Wow! Royal Flush!!! */
646           }
647         }
648
649         joker_is_used = FALSE;
650         for (i = 0; i < 5; i++)
651         {
652                 if (!find_card_num(lowest + i)){
653                   if( have_joker() && !joker_is_used )
654                     joker_is_used = TRUE;
655                   else
656                     return 0;
657                 }
658         }
659         
660         if (yaku_check_flush())
661                 return 2; /* Straight Flush */
662
663         return 1;
664 }
665
666 /*
667  * 0:nopair 1:1 pair 2:2 pair 3:3 cards 4:full house 6:4cards
668  */
669 static int yaku_check_pair(void)
670 {
671         int i, i2, matching = 0;
672
673         for (i = 0; i < 5; i++)
674         {
675                 for (i2 = i+1; i2 < 5; i2++)
676                 {
677                         if (IS_JOKER(cards[i]) || IS_JOKER(cards[i2])) continue;
678                         if (NUM_OF(cards[i]) == NUM_OF(cards[i2]))
679                                 matching++;
680                 }
681         }
682
683         if(have_joker()){
684           switch(matching){
685           case 0:
686             matching = 1;
687             break;
688           case 1:
689             matching = 3;
690             break;
691           case 2:
692             matching = 4;
693             break;
694           case 3:
695             matching = 6;
696             break;
697           case 6:
698             matching = 7;
699             break;
700           default:
701             /* don't reach */
702             break;
703           }
704         }
705
706         return matching;
707 }
708
709 #define ODDS_5A 3000
710 #define ODDS_5C 400
711 #define ODDS_RF 200
712 #define ODDS_SF 80
713 #define ODDS_4C 16
714 #define ODDS_FH 12
715 #define ODDS_FL 8
716 #define ODDS_ST 4
717 #define ODDS_3C 1
718 #define ODDS_2P 1
719
720 static int yaku_check(void)
721 {
722         prt("                            ", 4, 3);
723
724         switch(yaku_check_straight()){
725         case 3: /* RF! */
726 #ifdef JP
727                 c_put_str(TERM_YELLOW, "¥í¥¤¥ä¥ë¥¹¥È¥ì¡¼¥È¥Õ¥é¥Ã¥·¥å",  4,  3);
728 #else
729                 c_put_str(TERM_YELLOW, "Royal Flush",  4,  3);
730 #endif
731                 return ODDS_RF;
732         case 2: /* SF! */
733 #ifdef JP
734                 c_put_str(TERM_YELLOW, "¥¹¥È¥ì¡¼¥È¥Õ¥é¥Ã¥·¥å",  4,  3);
735 #else
736                 c_put_str(TERM_YELLOW, "Straight Flush",  4,  3);
737 #endif
738                 return ODDS_SF;
739         case 1:
740 #ifdef JP
741                 c_put_str(TERM_YELLOW, "¥¹¥È¥ì¡¼¥È",  4,  3);
742 #else
743                 c_put_str(TERM_YELLOW, "Straight",  4,  3);
744 #endif
745                 return ODDS_ST;
746         default:
747                 /* Not straight -- fall through */
748                 break;
749         }
750
751         if (yaku_check_flush())
752         {
753
754 #ifdef JP
755         c_put_str(TERM_YELLOW, "¥Õ¥é¥Ã¥·¥å",  4,  3);
756 #else
757         c_put_str(TERM_YELLOW, "Flush",  4,  3);
758 #endif
759                 return ODDS_FL;
760         }
761
762         switch (yaku_check_pair())
763         {
764         case 1:
765 #ifdef JP
766                 c_put_str(TERM_YELLOW, "¥ï¥ó¥Ú¥¢",  4,  3);
767 #else
768                 c_put_str(TERM_YELLOW, "One pair",  4,  3);
769 #endif
770                 return 0;
771         case 2:
772 #ifdef JP
773                 c_put_str(TERM_YELLOW, "¥Ä¡¼¥Ú¥¢",  4,  3);
774 #else
775                 c_put_str(TERM_YELLOW, "Two pair",  4,  3);
776 #endif
777                 return ODDS_2P;
778         case 3:
779 #ifdef JP
780                 c_put_str(TERM_YELLOW, "¥¹¥ê¡¼¥«¡¼¥É",  4,  3);
781 #else
782                 c_put_str(TERM_YELLOW, "Three of a kind",  4,  3);
783 #endif
784                 return ODDS_3C;
785         case 4:
786 #ifdef JP
787                 c_put_str(TERM_YELLOW, "¥Õ¥ë¥Ï¥¦¥¹",  4,  3);
788 #else
789                 c_put_str(TERM_YELLOW, "Full house",  4,  3);
790 #endif
791                 return ODDS_FH;
792         case 6:
793 #ifdef JP
794                 c_put_str(TERM_YELLOW, "¥Õ¥©¡¼¥«¡¼¥É",  4,  3);
795 #else
796                 c_put_str(TERM_YELLOW, "Four of a kind",  4,  3);
797 #endif
798                 return ODDS_4C;
799         case 7:
800                 if (!NUM_OF(cards[0]) || !NUM_OF(cards[1]))
801                 {
802 #ifdef JP
803                         c_put_str(TERM_YELLOW, "¥Õ¥¡¥¤¥Ö¥¨¡¼¥¹",  4,  3);
804 #else
805                         c_put_str(TERM_YELLOW, "Five ace",  4,  3);
806 #endif
807                         return ODDS_5A;
808                 }
809                 else
810                 {
811 #ifdef JP
812                         c_put_str(TERM_YELLOW, "¥Õ¥¡¥¤¥Ö¥«¡¼¥É",  4,  3);
813 #else
814                         c_put_str(TERM_YELLOW, "Five of a kind",  4,  3);
815 #endif
816                         return ODDS_5C;
817                 }
818         default:
819                 break;
820         }
821         return 0;
822 }
823
824 static void display_kaeruka(int hoge, int kaeruka[])
825 {
826         int i;
827         char col = TERM_WHITE;
828         for (i = 0; i < 5; i++)
829         {
830                 if (i == hoge) col = TERM_YELLOW;
831                 else if(kaeruka[i]) col = TERM_WHITE;
832                 else col = TERM_L_BLUE;
833 #ifdef JP
834                 if(kaeruka[i])
835                         c_put_str(col, "¤«¤¨¤ë", 14,  5+i*16);
836                 else
837                         c_put_str(col, "¤Î¤³¤¹", 14,  5+i*16);
838 #else
839                 if(kaeruka[i])
840                         c_put_str(col, "Change", 14,  5+i*16);
841                 else
842                         c_put_str(col, " Stay ", 14,  5+i*16);
843 #endif
844         }
845         if (hoge > 4) col = TERM_YELLOW;
846         else col = TERM_WHITE;
847 #ifdef JP
848         c_put_str(col, "·èÄê", 16,  38);
849 #else
850         c_put_str(col, "Sure", 16,  38);
851 #endif
852
853         /* Hilite current option */
854         if (hoge < 5) move_cursor(14, 5+hoge*16);
855         else move_cursor(16, 38);
856 }
857
858
859 static void display_cards(void)
860 {
861         int i, j;
862         char suitcolor[4] = {TERM_YELLOW, TERM_L_RED, TERM_L_BLUE, TERM_L_GREEN};
863 #ifdef JP
864         cptr suit[4] = {"¡ú", "¡ü", "¢ù", "¢÷"};
865         cptr card_grph[13][7] = {{"£Á   %s     ",
866                                   "     ÊÑ     ",
867                                   "     ¶ò     ",
868                                   "     ÈÚ     ",
869                                   "     ÅÜ     ",
870                                   "     %s     ",
871                                   "          £Á"},
872                                  {"£²          ",
873                                   "     %s     ",
874                                   "            ",
875                                   "            ",
876                                   "            ",
877                                   "     %s     ",
878                                   "          £²"},
879                                  {"£³          ",
880                                   "     %s     ",
881                                   "            ",
882                                   "     %s     ",
883                                   "            ",
884                                   "     %s     ",
885                                   "          £³"},
886                                  {"£´          ",
887                                   "   %s  %s   ",
888                                   "            ",
889                                   "            ",
890                                   "            ",
891                                   "   %s  %s   ",
892                                   "          £´"},
893                                  {"£µ          ",
894                                   "   %s  %s   ",
895                                   "            ",
896                                   "     %s     ",
897                                   "            ",
898                                   "   %s  %s   ",
899                                   "          £µ"},
900                                  {"£¶          ",
901                                   "   %s  %s   ",
902                                   "            ",
903                                   "   %s  %s   ",
904                                   "            ",
905                                   "   %s  %s   ",
906                                   "          £¶"},
907                                  {"£·          ",
908                                   "   %s  %s   ",
909                                   "     %s     ",
910                                   "   %s  %s   ",
911                                   "            ",
912                                   "   %s  %s   ",
913                                   "          £·"},
914                                  {"£¸          ",
915                                   "   %s  %s   ",
916                                   "     %s     ",
917                                   "   %s  %s   ",
918                                   "     %s     ",
919                                   "   %s  %s   ",
920                                   "          £¸"},
921                                  {"£¹ %s  %s   ",
922                                   "            ",
923                                   "   %s  %s   ",
924                                   "     %s     ",
925                                   "   %s  %s   ",
926                                   "            ",
927                                   "   %s  %s £¹"},
928                                  {"10 %s  %s   ",
929                                   "     %s     ",
930                                   "   %s  %s   ",
931                                   "            ",
932                                   "   %s  %s   ",
933                                   "     %s     ",
934                                   "   %s  %s 10"},
935                                  {"£Ê   ¦«     ",
936                                   "%s   ||     ",
937                                   "     ||     ",
938                                   "     ||     ",
939                                   "     ||     ",
940                                   "   |=°¡=| %s",
941                                   "     ÌÜ   £Ê"},
942                                  {"£Ñ ######   ",
943                                   "%s#      #  ",
944                                   "  # ++++ #  ",
945                                   "  # +==+ #  ",
946                                   "   # ++ #   ",
947                                   "    #  #  %s",
948                                   "     ##   £Ñ"},
949                                  {"£Ë          ",
950                                   "%s ¡®¢Þ¡­   ",
951                                   "  ¦Ã¦Ã¦Ã¦Ë  ",
952                                   "  ¦Ï ¦Ï ¦É  ",
953                                   "   ¦Ô    ¢ß ",
954                                   "    ¦Ò ¥Î %s",
955                                   "          £Ë"}};
956         cptr joker_grph[7] = {    "            ",
957                                   "     £Ê     ",
958                                   "     £Ï     ",
959                                   "     £Ë     ",
960                                   "     £Å     ",
961                                   "     £Ò     ",
962                                   "            "};
963
964 #else
965
966         cptr suit[4] = {"[]", "qp", "<>", "db"};
967         cptr card_grph[13][7] = {{"A    %s     ",
968                                   "     He     ",
969                                   "     ng     ",
970                                   "     ba     ",
971                                   "     nd     ",
972                                   "     %s     ",
973                                   "           A"},
974                                  {"2           ",
975                                   "     %s     ",
976                                   "            ",
977                                   "            ",
978                                   "            ",
979                                   "     %s     ",
980                                   "           2"},
981                                  {"3           ",
982                                   "     %s     ",
983                                   "            ",
984                                   "     %s     ",
985                                   "            ",
986                                   "     %s     ",
987                                   "           3"},
988                                  {"4           ",
989                                   "   %s  %s   ",
990                                   "            ",
991                                   "            ",
992                                   "            ",
993                                   "   %s  %s   ",
994                                   "           4"},
995                                  {"5           ",
996                                   "   %s  %s   ",
997                                   "            ",
998                                   "     %s     ",
999                                   "            ",
1000                                   "   %s  %s   ",
1001                                   "           5"},
1002                                  {"6           ",
1003                                   "   %s  %s   ",
1004                                   "            ",
1005                                   "   %s  %s   ",
1006                                   "            ",
1007                                   "   %s  %s   ",
1008                                   "           6"},
1009                                  {"7           ",
1010                                   "   %s  %s   ",
1011                                   "     %s     ",
1012                                   "   %s  %s   ",
1013                                   "            ",
1014                                   "   %s  %s   ",
1015                                   "           7"},
1016                                  {"8           ",
1017                                   "   %s  %s   ",
1018                                   "     %s     ",
1019                                   "   %s  %s   ",
1020                                   "     %s     ",
1021                                   "   %s  %s   ",
1022                                   "           8"},
1023                                  {"9  %s  %s   ",
1024                                   "            ",
1025                                   "   %s  %s   ",
1026                                   "     %s     ",
1027                                   "   %s  %s   ",
1028                                   "            ",
1029                                   "   %s  %s  9"},
1030                                  {"10 %s  %s   ",
1031                                   "     %s     ",
1032                                   "   %s  %s   ",
1033                                   "            ",
1034                                   "   %s  %s   ",
1035                                   "     %s     ",
1036                                   "   %s  %s 10"},
1037                                  {"J    /\\     ",
1038                                   "%s   ||     ",
1039                                   "     ||     ",
1040                                   "     ||     ",
1041                                   "     ||     ",
1042                                   "   |=HH=| %s",
1043                                   "     ][    J"},
1044                                  {"Q  ######   ",
1045                                   "%s#      #  ",
1046                                   "  # ++++ #  ",
1047                                   "  # +==+ #  ",
1048                                   "   # ++ #   ",
1049                                   "    #  #  %s",
1050                                   "     ##    Q"},
1051                                  {"K           ",
1052                                   "%s _'~~`_   ",
1053                                   "   jjjjj$&  ",
1054                                   "   q q uu   ",
1055                                   "   c    &   ",
1056                                   "    v__/  %s",
1057                                   "           K"}};
1058         cptr joker_grph[7] = {    "            ",
1059                                   "     J      ",
1060                                   "     O      ",
1061                                   "     K      ",
1062                                   "     E      ",
1063                                   "     R      ",
1064                                   "            "};
1065 #endif
1066
1067         for (i = 0; i < 5; i++)
1068         {
1069 #ifdef JP
1070                 prt("¨®¨¬¨¬¨¬¨¬¨¬¨¬¨¯",  5,  i*16);
1071 #else
1072                 prt(" +------------+ ",  5,  i*16);
1073 #endif
1074         }
1075
1076         for (i = 0; i < 5; i++)
1077         {
1078                 for (j = 0; j < 7; j++)
1079                 {
1080 #ifdef JP
1081                         prt("¨­",  j+6,  i*16);
1082 #else
1083                         prt(" |",  j+6,  i*16);
1084 #endif
1085                         if(IS_JOKER(cards[i]))
1086                                 c_put_str(TERM_VIOLET, joker_grph[j],  j+6,  2+i*16);
1087                         else
1088                                 c_put_str(suitcolor[SUIT_OF(cards[i])], format(card_grph[NUM_OF(cards[i])][j], suit[SUIT_OF(cards[i])], suit[SUIT_OF(cards[i])]),  j+6,  2+i*16);
1089 #ifdef JP
1090                         prt("¨­",  j+6,  i*16+14);
1091 #else
1092                         prt("| ",  j+6,  i*16+14);
1093 #endif
1094                 }
1095         }
1096         for (i = 0; i < 5; i++)
1097         {
1098 #ifdef JP
1099                 prt("¨±¨¬¨¬¨¬¨¬¨¬¨¬¨°", 13,  i*16);
1100 #else
1101                 prt(" +------------+ ", 13,  i*16);
1102 #endif
1103         }
1104 }
1105
1106 static int do_poker(void)
1107 {
1108         int i, k = 2;
1109         char cmd;
1110         int deck[53]; /* yamafuda : 0...52 */
1111         int deck_ptr = 0;
1112         int kaeruka[5]; /* 0:kaenai 1:kaeru */
1113
1114         bool done = FALSE;
1115         bool kettei = TRUE;
1116         bool kakikae = TRUE;
1117
1118         reset_deck(deck);
1119
1120         for (i = 0; i < 5; i++)
1121         {
1122                 cards[i] = deck[deck_ptr++];
1123                 kaeruka[i] = 0; /* default:nokosu */
1124         }
1125         
1126 #if 0
1127         /* debug:RF */
1128         cards[0] = 12;
1129         cards[1] = 0;
1130         cards[2] = 9;
1131         cards[3] = 11;
1132         cards[4] = 10;
1133 #endif
1134 #if 0
1135         /* debug:SF */
1136         cards[0] = 3;
1137         cards[1] = 2;
1138         cards[2] = 4;
1139         cards[3] = 6;
1140         cards[4] = 5;
1141 #endif
1142 #if 0
1143         /* debug:Four Cards */
1144         cards[0] = 0;
1145         cards[1] = 0 + 13 * 1;
1146         cards[2] = 0 + 13 * 2;
1147         cards[3] = 0 + 13 * 3;
1148         cards[4] = 51;
1149 #endif
1150 #if 0
1151         /* debug:Straight */
1152         cards[0] = 1;
1153         cards[1] = 0 + 13;
1154         cards[2] = 3;
1155         cards[3] = 2 + 26;
1156         cards[4] = 4;
1157 #endif
1158 #if 0
1159         /* debug */
1160         cards[0] = 52;
1161         cards[1] = 0;
1162         cards[2] = 1;
1163         cards[3] = 2;
1164         cards[4] = 3;
1165 #endif
1166
1167         /* suteruno wo kimeru */
1168 #ifdef JP
1169         prt("»Ä¤¹¥«¡¼¥É¤ò·è¤á¤Æ²¼¤µ¤¤(Êý¸þ¤Ç°ÜÆ°, ¥¹¥Ú¡¼¥¹¤ÇÁªÂò)¡£", 0, 0);
1170 #else
1171         prt("Stay witch? ", 0, 0);
1172 #endif
1173
1174         display_cards();
1175         yaku_check();
1176
1177         while (!done)
1178         {
1179                 if (kakikae) display_kaeruka(k+kettei*5, kaeruka);
1180                 kakikae = FALSE;
1181                 cmd = inkey();
1182                 switch (cmd)
1183                 {
1184                 case '6': case 'l': case 'L': case KTRL('F'):
1185                         if (!kettei) k = (k+1)%5;
1186                         else {k = 0;kettei = FALSE;}
1187                         kakikae = TRUE;
1188                         break;
1189                 case '4': case 'h': case 'H': case KTRL('B'):
1190                         if (!kettei) k = (k+4)%5;
1191                         else {k = 4;kettei = FALSE;}
1192                         kakikae = TRUE;
1193                         break;
1194                 case '2': case 'j': case 'J': case KTRL('N'):
1195                         if (!kettei) {kettei = TRUE;kakikae = TRUE;}
1196                         break;
1197                 case '8': case 'k': case 'K': case KTRL('P'):
1198                         if (kettei) {kettei = FALSE;kakikae = TRUE;}
1199                         break;
1200                 case ' ': case '\r':
1201                         if (kettei) done = TRUE;
1202                         else {kaeruka[k] = !kaeruka[k];kakikae = TRUE;}
1203                         break;
1204                 default:
1205                         break;
1206                 }
1207         }
1208         
1209         prt("",0,0);
1210
1211         for (i = 0; i < 5; i++)
1212                 if (kaeruka[i] == 1) cards[i] = deck[deck_ptr++]; /* soshite toru */
1213
1214         display_cards();
1215         
1216         return yaku_check();
1217 }
1218 #undef SUIT_OF
1219 #undef NUM_OF
1220 #undef IS_JOKER
1221 /* end of poker codes --Koka */
1222
1223 /*
1224  * gamble_comm
1225  */
1226 static bool gamble_comm(int cmd)
1227 {
1228         int i;
1229         int roll1, roll2, roll3, choice, odds, win;
1230         s32b wager;
1231         s32b maxbet;
1232         s32b oldgold;
1233
1234         char out_val[160], tmp_str[80], again;
1235         cptr p;
1236
1237         screen_save();
1238
1239         if (cmd == BACT_GAMBLE_RULES)
1240         {
1241                 /* Peruse the gambling help file */
1242 #ifdef JP
1243 (void)show_file(TRUE, "jgambling.txt", NULL, 0, 0);
1244 #else
1245                 (void)show_file(TRUE, "gambling.txt", NULL, 0, 0);
1246 #endif
1247
1248         }
1249         else
1250         {
1251                 /* No money */
1252                 if (p_ptr->au < 1)
1253                 {
1254 #ifdef JP
1255                         msg_print("¤ª¤¤¡ª¤ª¤Þ¤¨°ìʸ¤Ê¤·¤¸¤ã¤Ê¤¤¤«¡ª¤³¤Ã¤«¤é½Ð¤Æ¤¤¤±¡ª");
1256 #else
1257                         msg_print("Hey! You don't have gold - get out of here!");
1258 #endif
1259
1260                         msg_print(NULL);
1261                         screen_load();
1262                         return FALSE;
1263                 }
1264
1265                 clear_bldg(5, 23);
1266
1267                 maxbet = p_ptr->lev * 200;
1268
1269                 /* We can't bet more than we have */
1270                 maxbet = MIN(maxbet, p_ptr->au);
1271
1272                 /* Get the wager */
1273                 strcpy(out_val, "");
1274 #ifdef JP
1275 sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", maxbet);
1276 #else
1277                 sprintf(tmp_str,"Your wager (1-%ld) ? ", maxbet);
1278 #endif
1279
1280
1281                 /*
1282                  * Use get_string() because we may need more than
1283                  * the s16b value returned by get_quantity().
1284                  */
1285                 if (get_string(tmp_str, out_val, 32))
1286                 {
1287                         /* Strip spaces */
1288                         for (p = out_val; *p == ' '; p++);
1289
1290                         /* Get the wager */
1291                         wager = atol(p);
1292
1293                         if (wager > p_ptr->au)
1294                         {
1295 #ifdef JP
1296 msg_print("¤ª¤¤¡ª¶â¤¬Â­¤ê¤Ê¤¤¤¸¤ã¤Ê¤¤¤«¡ª½Ð¤Æ¤¤¤±¡ª");
1297 #else
1298                                 msg_print("Hey! You don't have the gold - get out of here!");
1299 #endif
1300
1301                                 msg_print(NULL);
1302                                 screen_load();
1303                                 return (FALSE);
1304                         }
1305                         else if (wager > maxbet)
1306                         {
1307 #ifdef JP
1308 msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", maxbet);
1309 #else
1310                                 msg_format("I'll take %ld gold of that. Keep the rest.", maxbet);
1311 #endif
1312
1313                                 wager = maxbet;
1314                         }
1315                         else if (wager < 1)
1316                         {
1317 #ifdef JP
1318 msg_print("£Ï£Ë¡¢£±¥´¡¼¥ë¥É¤«¤é¤Ï¤¸¤á¤è¤¦¡£");
1319 #else
1320                                 msg_print("Ok, we'll start with 1 gold.");
1321 #endif
1322
1323
1324                                 wager = 1;
1325                         }
1326                         msg_print(NULL);
1327                         win = FALSE;
1328                         odds = 0;
1329                         oldgold = p_ptr->au;
1330
1331 #ifdef JP
1332 sprintf(tmp_str, "¥²¡¼¥àÁ°¤Î½ê»ý¶â: %9ld", oldgold);
1333 #else
1334                         sprintf(tmp_str, "Gold before game: %9ld", oldgold);
1335 #endif
1336
1337                         prt(tmp_str, 20, 2);
1338
1339 #ifdef JP
1340 sprintf(tmp_str, "¸½ºß¤Î³Ý¤±¶â:     %9ld", wager);
1341 #else
1342                         sprintf(tmp_str, "Current Wager:    %9ld", wager);
1343 #endif
1344
1345                         prt(tmp_str, 21, 2);
1346
1347                         /* Prevent savefile-scumming of the casino */
1348 /*                      Rand_quick = TRUE; */
1349                         Rand_value = time(NULL);
1350
1351                         do
1352                         {
1353 #ifdef JP /* Prevent random seed cracking of the casino */
1354                                 clock_t clk;
1355                                 clk = clock();
1356                                 Rand_value *= clk;
1357 #endif
1358                                 p_ptr->au -= wager;
1359                                 switch (cmd)
1360                                 {
1361                                  case BACT_IN_BETWEEN: /* Game of In-Between */
1362 #ifdef JP
1363 c_put_str(TERM_GREEN, "¥¤¥ó¡¦¥Ó¥È¥¤¡¼¥ó",5,2);
1364 #else
1365                                         c_put_str(TERM_GREEN, "In Between", 5, 2);
1366 #endif
1367
1368                                         odds = 4;
1369                                         win = FALSE;
1370                                         roll1 = randint1(10);
1371                                         roll2 = randint1(10);
1372                                         choice = randint1(10);
1373 #ifdef JP
1374 sprintf(tmp_str, "¹õ¥À¥¤¥¹: %d        ¹õ¥À¥¤¥¹: %d", roll1, roll2);
1375 #else
1376                                         sprintf(tmp_str, "Black die: %d       Black Die: %d", roll1, roll2);
1377 #endif
1378
1379                                         prt(tmp_str, 8, 3);
1380 #ifdef JP
1381 sprintf(tmp_str, "ÀÖ¥À¥¤¥¹: %d", choice);
1382 #else
1383                                         sprintf(tmp_str, "Red die: %d", choice);
1384 #endif
1385
1386                                         prt(tmp_str, 11, 14);
1387                                         if (((choice > roll1) && (choice < roll2)) ||
1388                                                 ((choice < roll1) && (choice > roll2)))
1389                                                 win = TRUE;
1390                                         break;
1391                                 case BACT_CRAPS:  /* Game of Craps */
1392 #ifdef JP
1393 c_put_str(TERM_GREEN, "¥¯¥é¥Ã¥×¥¹", 5, 2);
1394 #else
1395                                         c_put_str(TERM_GREEN, "Craps", 5, 2);
1396 #endif
1397
1398                                         win = 3;
1399                                         odds = 2;
1400                                         roll1 = randint1(6);
1401                                         roll2 = randint1(6);
1402                                         roll3 = roll1 +  roll2;
1403                                         choice = roll3;
1404 #ifdef JP
1405 sprintf(tmp_str, "£±¿¶¤ê¤á: %d %d      Total: %d", roll1, 
1406 #else
1407                                         sprintf(tmp_str, "First roll: %d %d    Total: %d", roll1,
1408 #endif
1409
1410                                                  roll2, roll3);
1411                                         prt(tmp_str, 7, 5);
1412                                         if ((roll3 == 7) || (roll3 == 11))
1413                                                 win = TRUE;
1414                                         else if ((roll3 == 2) || (roll3 == 3) || (roll3 == 12))
1415                                                 win = FALSE;
1416                                         else
1417                                                 do
1418                                                 {
1419 #ifdef JP
1420 msg_print("¤Ê¤Ë¤«¥­¡¼¤ò²¡¤¹¤È¤â¤¦°ì²ó¿¶¤ê¤Þ¤¹¡£");
1421 #else
1422                                                         msg_print("Hit any key to roll again");
1423 #endif
1424
1425                                                         msg_print(NULL);
1426                                                         roll1 = randint1(6);
1427                                                         roll2 = randint1(6);
1428                                                         roll3 = roll1 +  roll2;
1429
1430 #ifdef JP
1431 sprintf(tmp_str, "½ÐÌÜ: %d %d          ¹ç·×:      %d",
1432 #else
1433                                                         sprintf(tmp_str, "Roll result: %d %d   Total:     %d",
1434 #endif
1435
1436                                                                  roll1, roll2, roll3);
1437                                                         prt(tmp_str, 8, 5);
1438                                                         if (roll3 == choice)
1439                                                                 win = TRUE;
1440                                                         else if (roll3 == 7)
1441                                                                 win = FALSE;
1442                                                 } while ((win != TRUE) && (win != FALSE));
1443                                         break;
1444
1445                                 case BACT_SPIN_WHEEL:  /* Spin the Wheel Game */
1446                                         win = FALSE;
1447                                         odds = 9;
1448 #ifdef JP
1449 c_put_str(TERM_GREEN, "¥ë¡¼¥ì¥Ã¥È", 5, 2);
1450 #else
1451                                         c_put_str(TERM_GREEN, "Wheel", 5, 2);
1452 #endif
1453
1454                                         prt("0  1  2  3  4  5  6  7  8  9", 7, 5);
1455                                         prt("--------------------------------", 8, 3);
1456                                         strcpy(out_val, "");
1457 #ifdef JP
1458 get_string("²¿ÈÖ¡© (0-9): ", out_val, 32);
1459 #else
1460                                         get_string("Pick a number (0-9): ", out_val, 32);
1461 #endif
1462
1463                                         for (p = out_val; isspace(*p); p++);
1464                                         choice = atol(p);
1465                                         if (choice < 0)
1466                                         {
1467 #ifdef JP
1468 msg_print("0È֤ˤ·¤È¤¯¤¼¡£");
1469 #else
1470                                                 msg_print("I'll put you down for 0.");
1471 #endif
1472
1473                                                 choice = 0;
1474                                         }
1475                                         else if (choice > 9)
1476                                         {
1477 #ifdef JP
1478 msg_print("£Ï£Ë¡¢9È֤ˤ·¤È¤¯¤¼¡£");
1479 #else
1480                                                 msg_print("Ok, I'll put you down for 9.");
1481 #endif
1482
1483                                                 choice = 9;
1484                                         }
1485                                         msg_print(NULL);
1486                                         roll1 = randint0(10);
1487 #ifdef JP
1488 sprintf(tmp_str, "¥ë¡¼¥ì¥Ã¥È¤Ï²ó¤ê¡¢»ß¤Þ¤Ã¤¿¡£¾¡¼Ô¤Ï %dÈÖ¤À¡£",
1489 #else
1490                                         sprintf(tmp_str, "The wheel spins to a stop and the winner is %d",
1491 #endif
1492
1493                                                 roll1);
1494                                         prt(tmp_str, 13, 3);
1495                                         prt("", 9, 0);
1496                                         prt("*", 9, (3 * roll1 + 5));
1497                                         if (roll1 == choice)
1498                                                 win = TRUE;
1499                                         break;
1500
1501                                 case BACT_DICE_SLOTS: /* The Dice Slots */
1502 #ifdef JP
1503 c_put_str(TERM_GREEN, "¥À¥¤¥¹¡¦¥¹¥í¥Ã¥È", 5, 2);
1504                                         c_put_str(TERM_YELLOW, "¥ì¥â¥ó   ¥ì¥â¥ó            2", 6, 37);
1505                                         c_put_str(TERM_YELLOW, "¥ì¥â¥ó   ¥ì¥â¥ó   ¥ì¥â¥ó   5", 7, 37);
1506                                         c_put_str(TERM_ORANGE, "¥ª¥ì¥ó¥¸ ¥ª¥ì¥ó¥¸ ¥ª¥ì¥ó¥¸ 10", 8, 37);
1507                                         c_put_str(TERM_UMBER, "·õ       ·õ       ·õ       20", 9, 37);
1508                                         c_put_str(TERM_SLATE, "½â       ½â       ½â       50", 10, 37);
1509                                         c_put_str(TERM_VIOLET, "¥×¥é¥à   ¥×¥é¥à   ¥×¥é¥à   200", 11, 37);
1510                                         c_put_str(TERM_RED, "¥Á¥§¥ê¡¼ ¥Á¥§¥ê¡¼ ¥Á¥§¥ê¡¼ 1000", 12, 37);
1511 #else
1512                                         c_put_str(TERM_GREEN, "Dice Slots", 5, 2);
1513 #endif
1514
1515                                         win = FALSE;
1516                                         roll1 = randint1(21);
1517                                         for (i=6;i>0;i--)
1518                                         {
1519                                                 if ((roll1-i) < 1)
1520                                                 {
1521                                                         roll1 = 7-i;
1522                                                         break;
1523                                                 }
1524                                                 roll1 -= i;
1525                                         }
1526                                         roll2 = randint1(21);
1527                                         for (i=6;i>0;i--)
1528                                         {
1529                                                 if ((roll2-i) < 1)
1530                                                 {
1531                                                         roll2 = 7-i;
1532                                                         break;
1533                                                 }
1534                                                 roll2 -= i;
1535                                         }
1536                                         choice = randint1(21);
1537                                         for (i=6;i>0;i--)
1538                                         {
1539                                                 if ((choice-i) < 1)
1540                                                 {
1541                                                         choice = 7-i;
1542                                                         break;
1543                                                 }
1544                                                 choice -= i;
1545                                         }
1546                                         put_str("/--------------------------\\", 7, 2);
1547                                         prt("\\--------------------------/", 17, 2);
1548                                         display_fruit(8,  3, roll1 - 1);
1549                                         display_fruit(8, 12, roll2 - 1);
1550                                         display_fruit(8, 21, choice - 1);
1551                                         if ((roll1 == roll2) && (roll2 == choice))
1552                                         {
1553                                                 win = TRUE;
1554                                                 switch(roll1)
1555                                                 {
1556                                                 case 1:
1557                                                         odds = 5;break;
1558                                                 case 2:
1559                                                         odds = 10;break;
1560                                                 case 3:
1561                                                         odds = 20;break;
1562                                                 case 4:
1563                                                         odds = 50;break;
1564                                                 case 5:
1565                                                         odds = 200;break;
1566                                                 case 6:
1567                                                         odds = 1000;break;
1568                                                 }
1569                                         }
1570                                         else if ((roll1 == 1) && (roll2 == 1))
1571                                         {
1572                                                 win = TRUE;
1573                                                 odds = 2;
1574                                         }
1575                                         break;
1576                                 case BACT_POKER:
1577                                         win = FALSE;
1578                                         odds = do_poker();
1579                                         if (odds) win = TRUE;
1580                                         break;
1581                                 }
1582
1583                                 if (win)
1584                                 {
1585 #ifdef JP
1586 prt("¤¢¤Ê¤¿¤Î¾¡¤Á", 16, 37);
1587 #else
1588                                         prt("YOU WON", 16, 37);
1589 #endif
1590
1591                                         p_ptr->au += odds * wager;
1592 #ifdef JP
1593 sprintf(tmp_str, "ÇÜΨ: %d", odds);
1594 #else
1595                                         sprintf(tmp_str, "Payoff: %d", odds);
1596 #endif
1597
1598                                         prt(tmp_str, 17, 37);
1599                                 }
1600                                 else
1601                                 {
1602 #ifdef JP
1603 prt("¤¢¤Ê¤¿¤ÎÉ餱", 16, 37);
1604 #else
1605                                         prt("You Lost", 16, 37);
1606 #endif
1607
1608                                         prt("", 17, 37);
1609                                 }
1610 #ifdef JP
1611 sprintf(tmp_str, "¸½ºß¤Î½ê»ý¶â:     %9ld", p_ptr->au);
1612 #else
1613                                 sprintf(tmp_str, "Current Gold:     %9ld", p_ptr->au);
1614 #endif
1615
1616                                 prt(tmp_str, 22, 2);
1617 #ifdef JP
1618 prt("¤â¤¦°ìÅÙ(Y/N)¡©", 18, 37);
1619 #else
1620                                 prt("Again(Y/N)?", 18, 37);
1621 #endif
1622
1623                                 move_cursor(18, 52);
1624                                 again = inkey();
1625                                 prt("", 16, 37);
1626                                 prt("", 17, 37);
1627                                 prt("", 18, 37);
1628                                 if (wager > p_ptr->au)
1629                                 {
1630 #ifdef JP
1631 msg_print("¤ª¤¤¡ª¶â¤¬Â­¤ê¤Ê¤¤¤¸¤ã¤Ê¤¤¤«¡ª¤³¤³¤«¤é½Ð¤Æ¹Ô¤±¡ª");
1632 #else
1633                                         msg_print("Hey! You don't have the gold - get out of here!");
1634 #endif
1635
1636                                         msg_print(NULL);
1637
1638                                         /* Get out here */
1639                                         break;
1640                                 }
1641                         } while ((again == 'y') || (again == 'Y'));
1642
1643                         /* Switch back to complex RNG */
1644                         Rand_quick = FALSE;
1645
1646                         prt("", 18, 37);
1647                         if (p_ptr->au >= oldgold)
1648                         {
1649 #ifdef JP
1650 msg_print("¡Öº£²ó¤ÏÌÙ¤±¤¿¤Ê¡ª¤Ç¤â¼¡¤Ï¤³¤Ã¤Á¤¬¾¡¤Ã¤Æ¤ä¤ë¤«¤é¤Ê¡¢ÀäÂФˡª¡×");
1651 #else
1652                                 msg_print("You came out a winner! We'll win next time, I'm sure.");
1653 #endif
1654                                 chg_virtue(V_CHANCE, 3);
1655                         }
1656                         else
1657                         {
1658 #ifdef JP
1659 msg_print("¡Ö¶â¤ò¥¹¥Ã¤Æ¤·¤Þ¤Ã¤¿¤Ê¡¢¤ï¤Ï¤Ï¡ª¤¦¤Á¤Ëµ¢¤Ã¤¿Êý¤¬¤¤¤¤¤¼¡£¡×");
1660 #else
1661                                 msg_print("You lost gold! Haha, better head home.");
1662 #endif
1663                                 chg_virtue(V_CHANCE, -3);
1664                         }
1665                 }
1666                 msg_print(NULL);
1667         }
1668         screen_load();
1669         return (TRUE);
1670 }
1671
1672 static bool vault_aux_battle(int r_idx)
1673 {
1674         int i;
1675         int dam = 0;
1676
1677         monster_race *r_ptr = &r_info[r_idx];
1678
1679         /* Decline town monsters */
1680 /*      if (!mon_hook_dungeon(r_idx)) return FALSE; */
1681
1682         /* Decline unique monsters */
1683 /*      if (r_ptr->flags1 & (RF1_UNIQUE)) return (FALSE); */
1684 /*      if (r_ptr->flags7 & (RF7_NAZGUL)) return (FALSE); */
1685
1686         if (r_ptr->flags1 & (RF1_NEVER_MOVE)) return (FALSE);
1687         if (r_ptr->flags2 & (RF2_MULTIPLY)) return (FALSE);
1688         if (r_ptr->flags2 & (RF2_QUANTUM)) return (FALSE);
1689         if (r_ptr->flags7 & (RF7_AQUATIC)) return (FALSE);
1690         if (r_ptr->flags7 & (RF7_CHAMELEON)) return (FALSE);
1691
1692         for (i = 0; i < 4; i++)
1693         {
1694                 if (r_ptr->blow[i].method == RBM_EXPLODE) return (FALSE);
1695                 if (r_ptr->blow[i].effect != RBE_DR_MANA) dam += r_ptr->blow[i].d_dice;
1696         }
1697         if (!dam && !(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK | RF4_BREATH_MASK)) && !(r_ptr->flags5 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_BREATH_MASK)) && !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK | RF6_BREATH_MASK))) return (FALSE);
1698
1699         /* Okay */
1700         return (TRUE);
1701 }
1702
1703 void battle_monsters(void)
1704 {
1705         int total, i;
1706         int max_dl = 0;
1707         int mon_level;
1708         int power[4];
1709         bool tekitou;
1710         bool old_inside_battle = p_ptr->inside_battle;
1711
1712         for (i = 0; i < max_d_idx; i++)
1713                 if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
1714
1715         mon_level = randint1(MIN(max_dl, 122))+5;
1716         if (randint0(100) < 60)
1717         {
1718                 i = randint1(MIN(max_dl, 122))+5;
1719                 mon_level = MAX(i, mon_level);
1720         }
1721         if (randint0(100) < 30)
1722         {
1723                 i = randint1(MIN(max_dl, 122))+5;
1724                 mon_level = MAX(i, mon_level);
1725         }
1726
1727         while (1)
1728         {
1729                 total = 0;
1730                 tekitou = FALSE;
1731                 for(i=0;i<4;i++)
1732                 {
1733                         int r_idx, j;
1734                         while (1)
1735                         {
1736                                 get_mon_num_prep(vault_aux_battle, NULL);
1737                                 p_ptr->inside_battle = TRUE;
1738                                 r_idx = get_mon_num(mon_level);
1739                                 p_ptr->inside_battle = old_inside_battle;
1740                                 if (!r_idx) continue;
1741
1742                                 if ((r_info[r_idx].flags1 & RF1_UNIQUE) || (r_info[r_idx].flags7 & RF7_UNIQUE2))
1743                                 {
1744                                         if ((r_info[r_idx].level + 10) > mon_level) continue;
1745                                 }
1746
1747                                 for (j = 0; j < i; j++)
1748                                         if(r_idx == battle_mon[j]) break;
1749                                 if (j<i) continue;
1750
1751                                 break;
1752                         }
1753                         battle_mon[i] = r_idx;
1754                         if (r_info[r_idx].level < 45) tekitou = TRUE;
1755                 }
1756
1757                 for (i=0;i<4;i++)
1758                 {
1759                         monster_race *r_ptr = &r_info[battle_mon[i]];
1760                         int num_taisei = count_bits(r_ptr->flagsr & (RFR_IM_ACID | RFR_IM_ELEC | RFR_IM_FIRE | RFR_IM_COLD | RFR_IM_POIS));
1761
1762                         if (r_ptr->flags1 & RF1_FORCE_MAXHP)
1763                                 power[i] = r_ptr->hdice * r_ptr->hside * 2;
1764                         else
1765                                 power[i] = r_ptr->hdice * (r_ptr->hside + 1);
1766                         power[i] = power[i] * (100 + r_ptr->level) / 100;
1767                         if (r_ptr->speed > 110)
1768                                 power[i] = power[i] * (r_ptr->speed * 2 - 110) / 100;
1769                         if (r_ptr->speed < 110)
1770                                 power[i] = power[i] * (r_ptr->speed - 20) / 100;
1771                         if (num_taisei > 2)
1772                                 power[i] = power[i] * (num_taisei*2+5) / 10;
1773                         else if (r_ptr->flags6 & RF6_INVULNER)
1774                                 power[i] = power[i] * 4 / 3;
1775                         else if (r_ptr->flags6 & RF6_HEAL)
1776                                 power[i] = power[i] * 4 / 3;
1777                         else if (r_ptr->flags5 & RF5_DRAIN_MANA)
1778                                 power[i] = power[i] * 11 / 10;
1779                         if (r_ptr->flags1 & RF1_RAND_25)
1780                                 power[i] = power[i] * 9 / 10;
1781                         if (r_ptr->flags1 & RF1_RAND_50)
1782                                 power[i] = power[i] * 9 / 10;
1783
1784                         switch (battle_mon[i])
1785                         {
1786                                 case MON_GREEN_G:
1787                                 case MON_THAT_BAT:
1788                                 case MON_GHOST_Q:
1789                                         power[i] /= 4;
1790                                         break;
1791                                 case MON_LOST_SOUL:
1792                                 case MON_GHOST:
1793                                         power[i] /= 2;
1794                                         break;
1795                                 case MON_UND_BEHOLDER:
1796                                 case MON_SANTACLAUS:
1797                                 case MON_ULT_BEHOLDER:
1798                                 case MON_UNGOLIANT:
1799                                 case MON_ATLACH_NACHA:
1800                                 case MON_Y_GOLONAC:
1801                                         power[i] = power[i] * 3 / 5;
1802                                         break;
1803                                 case MON_ROBIN_HOOD:
1804                                 case MON_RICH:
1805                                 case MON_LICH:
1806                                 case MON_COLOSSUS:
1807                                 case MON_CRYPT_THING:
1808                                 case MON_MASTER_LICH:
1809                                 case MON_DREADMASTER:
1810                                 case MON_DEMILICH:
1811                                 case MON_SHADOWLORD:
1812                                 case MON_ARCHLICH:
1813                                 case MON_BLEYS:
1814                                 case MON_CAINE:
1815                                 case MON_JULIAN:
1816                                 case MON_VENOM_WYRM:
1817                                 case MON_MASTER_MYS:
1818                                 case MON_G_MASTER_MYS:
1819                                         power[i] = power[i] * 3 / 4;
1820                                         break;
1821                                 case MON_VORPAL_BUNNY:
1822                                 case MON_SHAGRAT:
1823                                 case MON_GORBAG:
1824                                 case MON_LOG_MASTER:
1825                                 case MON_JURT:
1826                                 case MON_GRAV_HOUND:
1827                                 case MON_SHIM_VOR:
1828                                 case MON_JUBJUB:
1829                                 case MON_CLUB_DEMON:
1830                                 case MON_LLOIGOR:
1831                                 case MON_NIGHTCRAWLER:
1832                                 case MON_NIGHTWALKER:
1833                                 case MON_RAPHAEL:
1834                                 case MON_SHAMBLER:
1835                                 case MON_SKY_DRAKE:
1836                                 case MON_GERARD:
1837                                 case MON_G_CTHULHU:
1838                                 case MON_SPECT_WYRM:
1839                                 case MON_BAZOOKER:
1840                                 case MON_GCWADL:
1841                                 case MON_KIRIN:
1842                                 case MON_FENGHUANG:
1843                                         power[i] = power[i] * 4 / 3;
1844                                         break;
1845                                 case MON_UMBER_HULK:
1846                                 case MON_FIRE_VOR:
1847                                 case MON_WATER_VOR:
1848                                 case MON_COLD_VOR:
1849                                 case MON_ENERGY_VOR:
1850                                 case MON_GACHAPIN:
1851                                 case MON_REVENANT:
1852                                 case MON_NEXUS_VOR:
1853                                 case MON_PLASMA_VOR:
1854                                 case MON_TIME_VOR:
1855                                 case MON_MANDOR:
1856                                 case MON_KAVLAX:
1857                                 case MON_RINALDO:
1858                                 case MON_STORMBRINGER:
1859                                 case MON_TIME_HOUND:
1860                                 case MON_PLASMA_HOUND:
1861                                 case MON_TINDALOS:
1862                                 case MON_CHAOS_VOR:
1863                                 case MON_AETHER_VOR:
1864                                 case MON_AETHER_HOUND:
1865                                 case MON_CANTORAS:
1866                                 case MON_GODZILLA:
1867                                 case MON_TARRASQUE:
1868                                 case MON_DESTROYER:
1869                                 case MON_MORGOTH:
1870                                 case MON_SERPENT:
1871                                 case MON_OROCHI:
1872                                 case MON_D_ELF_SHADE:
1873                                 case MON_MANA_HOUND:
1874                                 case MON_SHARD_VOR:
1875                                 case MON_BANORLUPART:
1876                                 case MON_BOTEI:
1877                                 case MON_JAIAN:
1878                                 case MON_BAHAMUT:
1879                                 case MON_WAHHA:
1880                                         power[i] = power[i] * 3 / 2;
1881                                         break;
1882                                 case MON_ROLENTO:
1883                                 case MON_CYBER:
1884                                 case MON_CYBER_KING:
1885                                 case MON_UNICORN_ORD:
1886                                         power[i] = power[i] * 5 / 3;
1887                                         break;
1888                                 case MON_ARCH_VILE:
1889                                 case MON_PHANTOM_B:
1890                                 case MON_WYRM_POWER:
1891                                         power[i] *= 2;
1892                                         break;
1893                                 case MON_NODENS:
1894                                 case MON_CULVERIN:
1895                                         power[i] *= 3;
1896                                         break;
1897                                 case MON_ECHIZEN:
1898                                         power[i] *= 9;
1899                                         break;
1900                                 case MON_HAGURE:
1901                                         power[i] *= 100000;
1902                                         break;
1903                                 default:
1904                                         break;
1905                         }
1906                         total += power[i];
1907                 }
1908                 for (i=0;i<4;i++)
1909                 {
1910                         power[i] = total*60/power[i];
1911                         if (tekitou && ((power[i] < 160) || power[i] > 1500)) break;
1912                         if ((power[i] < 160) && randint0(20)) break;
1913                         if (power[i] < 101) power[i] = 100 + randint1(5);
1914                         mon_odds[i] = power[i];
1915                 }
1916                 if (i == 4) break;
1917         }
1918 }
1919
1920 static bool kakutoujou(void)
1921 {
1922         s32b maxbet;
1923         s32b wager;
1924         char out_val[160], tmp_str[80];
1925         cptr p;
1926
1927         if ((turn - old_battle) > TURNS_PER_TICK*250)
1928         {
1929                 battle_monsters();
1930                 old_battle = turn;
1931         }
1932
1933         screen_save();
1934
1935         /* No money */
1936         if (p_ptr->au < 1)
1937         {
1938 #ifdef JP
1939                 msg_print("¤ª¤¤¡ª¤ª¤Þ¤¨°ìʸ¤Ê¤·¤¸¤ã¤Ê¤¤¤«¡ª¤³¤Ã¤«¤é½Ð¤Æ¤¤¤±¡ª");
1940 #else
1941                 msg_print("Hey! You don't have gold - get out of here!");
1942 #endif
1943
1944                 msg_print(NULL);
1945                 screen_load();
1946                 return FALSE;
1947         }
1948         else
1949         {
1950                 int i;
1951
1952                 clear_bldg(4, 10);
1953
1954 #ifdef JP
1955                 prt("¥â¥ó¥¹¥¿¡¼                                                     ÇÜΨ", 4, 4);
1956 #else
1957                 prt("Monsters                                                       Odds", 4, 4);
1958 #endif
1959                 for (i=0;i<4;i++)
1960                 {
1961                         char buf[80];
1962                         monster_race *r_ptr = &r_info[battle_mon[i]];
1963
1964 #ifdef JP
1965                         sprintf(buf,"%d) %-58s  %4ld.%02ldÇÜ", i+1, format("%s%s",r_name + r_ptr->name, (r_ptr->flags1 & RF1_UNIQUE) ? "¤â¤É¤­" : "      "), mon_odds[i]/100, mon_odds[i]%100);
1966 #else
1967                         sprintf(buf,"%d) %-58s  %4ld.%02ld", i+1, format("%s%s", (r_ptr->flags1 & RF1_UNIQUE) ? "Fake " : "", r_name + r_ptr->name), mon_odds[i]/100, mon_odds[i]%100);
1968 #endif
1969                         prt(buf, 5+i, 1);
1970                 }
1971
1972 #ifdef JP
1973                 prt("¤É¤ì¤ËÅÒ¤±¤Þ¤¹¤«:", 0, 0);
1974 #else
1975                 prt("Which monster: ", 0, 0);
1976 #endif
1977                 while(1)
1978                 {
1979                         i = inkey();
1980
1981                         if (i == ESCAPE)
1982                         {
1983                                 screen_load();
1984                                 return FALSE;
1985                         }
1986                         if (i >= '1' && i <= '4')
1987                         {
1988                                 sel_monster = i-'1';
1989                                 battle_odds = mon_odds[sel_monster];
1990                                 break;
1991                         }
1992                         else bell();
1993                 }
1994
1995                 clear_bldg(4,4);
1996                 for (i=0;i<4;i++)
1997                         if (i !=sel_monster) clear_bldg(i+5,i+5);
1998
1999                 maxbet = p_ptr->lev * 200;
2000
2001                 /* We can't bet more than we have */
2002                 maxbet = MIN(maxbet, p_ptr->au);
2003
2004                 /* Get the wager */
2005                 strcpy(out_val, "");
2006 #ifdef JP
2007 sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", maxbet);
2008 #else
2009                 sprintf(tmp_str,"Your wager (1-%ld) ? ", maxbet);
2010 #endif
2011
2012
2013                 /*
2014                  * Use get_string() because we may need more than
2015                  * the s16b value returned by get_quantity().
2016                  */
2017                 if (get_string(tmp_str, out_val, 32))
2018                 {
2019                         /* Strip spaces */
2020                         for (p = out_val; *p == ' '; p++);
2021
2022                         /* Get the wager */
2023                         wager = atol(p);
2024
2025                         if (wager > p_ptr->au)
2026                         {
2027 #ifdef JP
2028 msg_print("¤ª¤¤¡ª¶â¤¬Â­¤ê¤Ê¤¤¤¸¤ã¤Ê¤¤¤«¡ª½Ð¤Æ¤¤¤±¡ª");
2029 #else
2030                                 msg_print("Hey! You don't have the gold - get out of here!");
2031 #endif
2032
2033                                 msg_print(NULL);
2034                                 screen_load();
2035                                 return (FALSE);
2036                         }
2037                         else if (wager > maxbet)
2038                         {
2039 #ifdef JP
2040 msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", maxbet);
2041 #else
2042                                 msg_format("I'll take %ld gold of that. Keep the rest.", maxbet);
2043 #endif
2044
2045                                 wager = maxbet;
2046                         }
2047                         else if (wager < 1)
2048                         {
2049 #ifdef JP
2050 msg_print("£Ï£Ë¡¢£±¥´¡¼¥ë¥É¤Ç¤¤¤³¤¦¡£");
2051 #else
2052                                 msg_print("Ok, we'll start with 1 gold.");
2053 #endif
2054
2055
2056                                 wager = 1;
2057                         }
2058                         msg_print(NULL);
2059                         battle_odds = MAX(wager+1, wager * battle_odds / 100);
2060                         kakekin = wager;
2061                         p_ptr->au -= wager;
2062                         p_ptr->leftbldg = TRUE;
2063                         reset_tim_flags();
2064
2065                         /* Save the surface floor to preserve pets */
2066                         prepare_change_floor_mode(CFM_SAVE_SURFACE);
2067
2068                         p_ptr->inside_battle = TRUE;
2069                         p_ptr->leaving = TRUE;
2070
2071                         leave_bldg = TRUE;
2072                         screen_load();
2073
2074                         return (TRUE);
2075                 }
2076         }
2077         screen_load();
2078
2079         return (FALSE);
2080 }
2081
2082 static void today_target(void)
2083 {
2084         char buf[160];
2085         monster_race *r_ptr = &r_info[today_mon];
2086
2087         clear_bldg(4,18);
2088 #ifdef JP
2089 c_put_str(TERM_YELLOW, "ËÜÆü¤Î¾Þ¶â¼ó", 5, 10);
2090 #else
2091         prt("Wanted monster that changes from day to day", 5, 10);
2092 #endif
2093 #ifdef JP
2094         sprintf(buf,"¥¿¡¼¥²¥Ã¥È¡§ %s",r_name + r_ptr->name);
2095 #else
2096         sprintf(buf,"target: %s",r_name + r_ptr->name);
2097 #endif
2098         c_put_str(TERM_YELLOW, buf, 6, 10);
2099 #ifdef JP
2100         sprintf(buf,"»àÂΠ---- $%d",r_ptr->level * 50 + 100);
2101 #else
2102         sprintf(buf,"corpse   ---- $%d",r_ptr->level * 50 + 100);
2103 #endif
2104         prt(buf, 8, 10);
2105 #ifdef JP
2106         sprintf(buf,"¹ü   ---- $%d",r_ptr->level * 30 + 60);
2107 #else
2108         sprintf(buf,"skeleton ---- $%d",r_ptr->level * 30 + 60);
2109 #endif
2110         prt(buf, 9, 10);
2111         p_ptr->today_mon = today_mon;
2112 }
2113
2114 static void tsuchinoko(void)
2115 {
2116         clear_bldg(4,18);
2117 #ifdef JP
2118 c_put_str(TERM_YELLOW, "°ì³ÍÀé¶â¤ÎÂç¥Á¥ã¥ó¥¹¡ª¡ª¡ª", 5, 10);
2119 c_put_str(TERM_YELLOW, "¥¿¡¼¥²¥Ã¥È¡§¸¸¤ÎÄÁ½Ã¡Ö¥Ä¥Á¥Î¥³¡×", 6, 10);
2120 c_put_str(TERM_WHITE, "À¸¤±Êá¤ê ---- $1,000,000", 8, 10);
2121 c_put_str(TERM_WHITE, "»àÂΠ    ----   $200,000", 9, 10);
2122 c_put_str(TERM_WHITE, "¹ü       ----   $100,000", 10, 10);
2123 #else
2124 c_put_str(TERM_YELLOW, "Big chance to quick money!!!", 5, 10);
2125 c_put_str(TERM_YELLOW, "target: the rarest animal 'Tsuchinoko'", 6, 10);
2126 c_put_str(TERM_WHITE, "catch alive ---- $1,000,000", 8, 10);
2127 c_put_str(TERM_WHITE, "corpse      ----   $200,000", 9, 10);
2128 c_put_str(TERM_WHITE, "bones       ----   $100,000", 10, 10);
2129 #endif
2130 }
2131
2132 static void shoukinkubi(void)
2133 {
2134         int i;
2135         int y = 0;
2136
2137         clear_bldg(4,18);
2138
2139 #ifdef JP
2140         prt("»àÂΤò»ý¤Áµ¢¤ì¤ÐÊó½·¤òº¹¤·¾å¤²¤Þ¤¹¡£",4 ,10);
2141 c_put_str(TERM_YELLOW, "¸½ºß¤Î¾Þ¶â¼ó", 6, 10);
2142 #else
2143         prt("Offer a prize when you bring a wanted monster's corpse",4 ,10);
2144 c_put_str(TERM_YELLOW, "Wanted monsters", 6, 10);
2145 #endif
2146
2147         for (i = 0; i < MAX_KUBI; i++)
2148         {
2149                 byte color;
2150                 cptr done_mark;
2151                 monster_race *r_ptr = &r_info[(kubi_r_idx[i] > 10000 ? kubi_r_idx[i] - 10000 : kubi_r_idx[i])];
2152
2153                 if (kubi_r_idx[i] > 10000)
2154                 {
2155                         color = TERM_RED;
2156 #ifdef JP
2157                         done_mark = "(ºÑ)";
2158 #else
2159                         done_mark = "(done)";
2160 #endif
2161                 }
2162                 else
2163                 {
2164                         color = TERM_WHITE;
2165                         done_mark = "";
2166                 }
2167
2168                 c_prt(color, format("%s %s", r_name + r_ptr->name, done_mark), y+7, 10);
2169
2170                 y = (y+1) % 10;
2171                 if (!y && (i < MAX_KUBI -1))
2172                 {
2173 #ifdef JP
2174                         prt("²¿¤«¥­¡¼¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤", 0, 0);
2175 #else
2176                         prt("Hit any key.", 0, 0);
2177 #endif
2178                         (void)inkey();
2179                         prt("", 0, 0);
2180                         clear_bldg(7,18);
2181                 }
2182         }
2183 }
2184
2185
2186 /* List of prize object */
2187 static struct {
2188         s16b tval;
2189         s16b sval;
2190 } prize_list[MAX_KUBI] = 
2191 {
2192         {TV_POTION, SV_POTION_CURING},
2193         {TV_POTION, SV_POTION_SPEED},
2194         {TV_POTION, SV_POTION_SPEED},
2195         {TV_POTION, SV_POTION_RESISTANCE},
2196         {TV_POTION, SV_POTION_ENLIGHTENMENT},
2197
2198         {TV_POTION, SV_POTION_HEALING},
2199         {TV_POTION, SV_POTION_RESTORE_MANA},
2200         {TV_SCROLL, SV_SCROLL_STAR_DESTRUCTION},
2201         {TV_POTION, SV_POTION_STAR_ENLIGHTENMENT},
2202         {TV_SCROLL, SV_SCROLL_SUMMON_PET},
2203
2204         {TV_SCROLL, SV_SCROLL_GENOCIDE},
2205         {TV_POTION, SV_POTION_STAR_HEALING},
2206         {TV_POTION, SV_POTION_STAR_HEALING},
2207         {TV_POTION, SV_POTION_NEW_LIFE},
2208         {TV_SCROLL, SV_SCROLL_MASS_GENOCIDE},
2209
2210         {TV_POTION, SV_POTION_LIFE},
2211         {TV_POTION, SV_POTION_LIFE},
2212         {TV_POTION, SV_POTION_AUGMENTATION},
2213         {TV_POTION, SV_POTION_INVULNERABILITY},
2214         {TV_SCROLL, SV_SCROLL_ARTIFACT},
2215 };
2216
2217
2218 /* Get prize */
2219 static bool kankin(void)
2220 {
2221         int i, j;
2222         bool change = FALSE;
2223         char o_name[MAX_NLEN];
2224         object_type *o_ptr;
2225
2226         /* Loop for inventory and right/left arm */
2227         for (i = 0; i <= INVEN_LARM; i++)
2228         {
2229                 o_ptr = &inventory[i];
2230
2231                 /* Living Tsuchinoko worthes $1000000 */
2232                 if ((o_ptr->tval == TV_CAPTURE) && (o_ptr->pval == MON_TSUCHINOKO))
2233                 {
2234                         char buf[MAX_NLEN+20];
2235                         object_desc(o_name, o_ptr, TRUE, 3);
2236 #ifdef JP
2237                         sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
2238 #else
2239                         sprintf(buf, "Convert %s into money? ",o_name);
2240 #endif
2241                         if (get_check(buf))
2242                         {
2243 #ifdef JP
2244                                 msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 1000000L * o_ptr->number);
2245 #else
2246                                 msg_format("You get %ldgp.", 1000000L * o_ptr->number);
2247 #endif
2248                                 p_ptr->au += 1000000L * o_ptr->number;
2249                                 p_ptr->redraw |= (PR_GOLD);
2250                                 inven_item_increase(i, -o_ptr->number);
2251                                 inven_item_describe(i);
2252                                 inven_item_optimize(i);
2253                         }
2254                         change = TRUE;
2255                 }
2256         }
2257
2258         for (i = 0; i < INVEN_PACK; i++)
2259         {
2260                 o_ptr = &inventory[i];
2261
2262                 /* Corpse of Tsuchinoko worthes $200000 */
2263                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == MON_TSUCHINOKO))
2264                 {
2265                         char buf[MAX_NLEN+20];
2266                         object_desc(o_name, o_ptr, TRUE, 3);
2267 #ifdef JP
2268                         sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
2269 #else
2270                         sprintf(buf, "Convert %s into money? ",o_name);
2271 #endif
2272                         if (get_check(buf))
2273                         {
2274 #ifdef JP
2275                                 msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 200000L * o_ptr->number);
2276 #else
2277                                 msg_format("You get %ldgp.", 200000L * o_ptr->number);
2278 #endif
2279                                 p_ptr->au += 200000L * o_ptr->number;
2280                                 p_ptr->redraw |= (PR_GOLD);
2281                                 inven_item_increase(i, -o_ptr->number);
2282                                 inven_item_describe(i);
2283                                 inven_item_optimize(i);
2284                         }
2285                         change = TRUE;
2286                 }
2287         }
2288
2289         for (i = 0; i < INVEN_PACK; i++)
2290         {
2291                 o_ptr = &inventory[i];
2292
2293                 /* Bones of Tsuchinoko worthes $100000 */
2294                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (o_ptr->pval == MON_TSUCHINOKO))
2295                 {
2296                         char buf[MAX_NLEN+20];
2297                         object_desc(o_name, o_ptr, TRUE, 3);
2298 #ifdef JP
2299                         sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
2300 #else
2301                         sprintf(buf, "Convert %s into money? ",o_name);
2302 #endif
2303                         if (get_check(buf))
2304                         {
2305 #ifdef JP
2306                                 msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 100000L * o_ptr->number);
2307 #else
2308                                 msg_format("You get %ldgp.", 100000L * o_ptr->number);
2309 #endif
2310                                 p_ptr->au += 100000L * o_ptr->number;
2311                                 p_ptr->redraw |= (PR_GOLD);
2312                                 inven_item_increase(i, -o_ptr->number);
2313                                 inven_item_describe(i);
2314                                 inven_item_optimize(i);
2315                         }
2316                         change = TRUE;
2317                 }
2318         }
2319
2320         for (i = 0; i < INVEN_PACK; i++)
2321         {
2322                 o_ptr = &inventory[i];
2323                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
2324                 {
2325                         char buf[MAX_NLEN+20];
2326                         object_desc(o_name, o_ptr, TRUE, 3);
2327 #ifdef JP
2328                         sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
2329 #else
2330                         sprintf(buf, "Convert %s into money? ",o_name);
2331 #endif
2332                         if (get_check(buf))
2333                         {
2334 #ifdef JP
2335                                 msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[today_mon].level * 50 + 100) * o_ptr->number);
2336 #else
2337                                 msg_format("You get %ldgp.", (r_info[today_mon].level * 50 + 100) * o_ptr->number);
2338 #endif
2339                                 p_ptr->au += (r_info[today_mon].level * 50 + 100) * o_ptr->number;
2340                                 p_ptr->redraw |= (PR_GOLD);
2341                                 inven_item_increase(i, -o_ptr->number);
2342                                 inven_item_describe(i);
2343                                 inven_item_optimize(i);
2344                         }
2345                         change = TRUE;
2346                 }
2347         }
2348
2349         for (i = 0; i < INVEN_PACK; i++)
2350         {
2351                 o_ptr = &inventory[i];
2352
2353                 if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
2354                 {
2355                         char buf[MAX_NLEN+20];
2356                         object_desc(o_name, o_ptr, TRUE, 3);
2357 #ifdef JP
2358                         sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
2359 #else
2360                         sprintf(buf, "Convert %s into money? ",o_name);
2361 #endif
2362                         if (get_check(buf))
2363                         {
2364 #ifdef JP
2365                                 msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[today_mon].level * 30 + 60) * o_ptr->number);
2366 #else
2367                                 msg_format("You get %ldgp.", (r_info[today_mon].level * 30 + 60) * o_ptr->number);
2368 #endif
2369                                 p_ptr->au += (r_info[today_mon].level * 30 + 60) * o_ptr->number;
2370                                 p_ptr->redraw |= (PR_GOLD);
2371                                 inven_item_increase(i, -o_ptr->number);
2372                                 inven_item_describe(i);
2373                                 inven_item_optimize(i);
2374                         }
2375                         change = TRUE;
2376                 }
2377         }
2378
2379         for (j = 0; j < MAX_KUBI; j++)
2380         {
2381                 /* Need reverse order --- Positions will be changed in the loop */
2382                 for (i = INVEN_PACK-1; i >= 0; i--)
2383                 {
2384                         o_ptr = &inventory[i];
2385                         if ((o_ptr->tval == TV_CORPSE) && (o_ptr->pval == kubi_r_idx[j]))
2386                         {
2387                                 char buf[MAX_NLEN+20];
2388                                 int num, k;
2389                                 object_type forge;
2390
2391                                 object_desc(o_name, o_ptr, TRUE, 3);
2392 #ifdef JP
2393                                 sprintf(buf, "%s¤òÅϤ·¤Þ¤¹¤«¡©",o_name);
2394 #else
2395                                 sprintf(buf, "Hand %s over? ",o_name);
2396 #endif
2397                                 if (!get_check(buf)) continue;
2398
2399 #if 0 /* Obsorated */
2400 #ifdef JP
2401                                 msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[kubi_r_idx[j]].level + 1) * 300 * o_ptr->number);
2402 #else
2403                                 msg_format("You get %ldgp.", (r_info[kubi_r_idx[j]].level + 1) * 300 * o_ptr->number);
2404 #endif
2405                                 p_ptr->au += (r_info[kubi_r_idx[j]].level+1) * 300 * o_ptr->number;
2406                                 p_ptr->redraw |= (PR_GOLD);
2407                                 inven_item_increase(i, -o_ptr->number);
2408                                 inven_item_describe(i);
2409                                 inven_item_optimize(i);
2410                                 chg_virtue(V_JUSTICE, 5);
2411                                 kubi_r_idx[j] += 10000;
2412
2413                                 change = TRUE;
2414 #endif /* Obsorated */
2415
2416                                 /* Hand it first */
2417                                 inven_item_increase(i, -o_ptr->number);
2418                                 inven_item_describe(i);
2419                                 inven_item_optimize(i);
2420
2421                                 chg_virtue(V_JUSTICE, 5);
2422                                 kubi_r_idx[j] += 10000;
2423
2424                                 /* Count number of unique corpses already handed */
2425                                 for (num = 0, k = 0; k < MAX_KUBI; k++)
2426                                 {
2427                                         if (kubi_r_idx[k] >= 10000) num++;
2428                                 }
2429
2430 #ifdef JP
2431                                 msg_format("¤³¤ì¤Ç¹ç·× %d ¥Ý¥¤¥ó¥È³ÍÆÀ¤·¤Þ¤·¤¿¡£", num);
2432 #else
2433                                 msg_format("You earned %d point%s total.", num, (num > 1 ? "s" : ""));
2434 #endif
2435
2436                                 /* Prepare to make a prize */
2437                                 object_prep(&forge, lookup_kind(prize_list[num-1].tval, prize_list[num-1].sval));
2438                                 apply_magic(&forge, object_level, AM_NO_FIXED_ART);
2439
2440                                 /* Identify it fully */
2441                                 object_aware(&forge);
2442                                 object_known(&forge);
2443
2444                                 /*
2445                                  * Hand it --- Assume there is an empty slot.
2446                                  * Since a corpse is handed at first,
2447                                  * there is at least one empty slot.
2448                                  */
2449                                 (void)inven_carry(&forge);
2450
2451                                 /* Describe the object */
2452                                 object_desc(o_name, &forge, TRUE, 3);
2453 #ifdef JP
2454                                 msg_format("%s ¤òÌã¤Ã¤¿¡£",o_name);
2455 #else
2456                                 msg_format("You get %s. ",o_name);
2457 #endif
2458
2459                                 change = TRUE;
2460                         }
2461                 }
2462         }
2463
2464         if (!change)
2465         {
2466 #ifdef JP
2467                 msg_print("¾Þ¶â¤òÆÀ¤é¤ì¤½¤¦¤Ê¤â¤Î¤Ï»ý¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£");
2468 #else
2469                 msg_print("You have nothing.");
2470 #endif
2471                 msg_print(NULL);
2472                 return FALSE;
2473         }
2474         return TRUE;
2475 }
2476
2477 bool get_nightmare(int r_idx)
2478 {
2479         monster_race *r_ptr = &r_info[r_idx];
2480
2481         /* Require eldritch horrors */
2482         if (!(r_ptr->flags2 & (RF2_ELDRITCH_HORROR))) return (FALSE);
2483
2484         /* Require high level */
2485         if (r_ptr->level <= p_ptr->lev) return (FALSE);
2486
2487         /* Accept this monster */
2488         return (TRUE);
2489 }
2490
2491
2492 void have_nightmare(int r_idx)
2493 {
2494         bool happened = FALSE;
2495         monster_race *r_ptr = &r_info[r_idx];
2496         int power = r_ptr->level + 10;
2497         char m_name[80];
2498         cptr desc = r_name + r_ptr->name;
2499
2500         /* Describe it */
2501 #ifndef JP
2502         if (!(r_ptr->flags1 & RF1_UNIQUE))
2503                 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
2504         else
2505 #endif
2506                 sprintf(m_name, "%s", desc);
2507
2508         if (!(r_ptr->flags1 & RF1_UNIQUE))
2509         {
2510                 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
2511         }
2512         else power *= 2;
2513
2514         if (saving_throw(p_ptr->skill_sav * 100 / power))
2515         {
2516 #ifdef JP
2517                 msg_format("Ì´¤ÎÃæ¤Ç%s¤ËÄɤ¤¤«¤±¤é¤ì¤¿¡£", m_name);
2518 #else
2519                 msg_format("%^s chases you through your dreams.", m_name);
2520 #endif
2521
2522                 /* Safe */
2523                 return;
2524         }
2525
2526         if (p_ptr->image)
2527         {
2528                 /* Something silly happens... */
2529 #ifdef JP
2530                 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2531 #else
2532                 msg_format("You behold the %s visage of %s!",
2533 #endif
2534
2535                                           funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2536
2537                 if (one_in_(3))
2538                 {
2539                         msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2540                         p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2541                 }
2542
2543                 /* Never mind; we can't see it clearly enough */
2544                 return;
2545         }
2546
2547         /* Something frightening happens... */
2548 #ifdef JP
2549         msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2550 #else
2551         msg_format("You behold the %s visage of %s!",
2552 #endif
2553
2554                                   horror_desc[randint0(MAX_SAN_HORROR)], desc);
2555
2556         r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2557
2558         if (!p_ptr->mimic_form)
2559         {
2560                 switch (p_ptr->prace)
2561                 {
2562                 /* Demons may make a saving throw */
2563                 case RACE_IMP:
2564                 case RACE_DEMON:
2565                         if (saving_throw(20 + p_ptr->lev)) return;
2566                         break;
2567                 /* Undead may make a saving throw */
2568                 case RACE_SKELETON:
2569                 case RACE_ZOMBIE:
2570                 case RACE_SPECTRE:
2571                 case RACE_VAMPIRE:
2572                         if (saving_throw(10 + p_ptr->lev)) return;
2573                         break;
2574                 }
2575         }
2576         else
2577         {
2578                 /* Demons may make a saving throw */
2579                 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
2580                 {
2581                         if (saving_throw(20 + p_ptr->lev)) return;
2582                 }
2583                 /* Undead may make a saving throw */
2584                 else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
2585                 {
2586                         if (saving_throw(10 + p_ptr->lev)) return;
2587                 }
2588         }
2589
2590         /* Mind blast */
2591         if (!saving_throw(p_ptr->skill_sav * 100 / power))
2592         {
2593                 if (!p_ptr->resist_conf)
2594                 {
2595                         (void)set_confused(p_ptr->confused + randint0(4) + 4);
2596                 }
2597                 if (!p_ptr->resist_chaos && one_in_(3))
2598                 {
2599                         (void)set_image(p_ptr->image + randint0(250) + 150);
2600                 }
2601                 return;
2602         }
2603
2604         /* Lose int & wis */
2605         if (!saving_throw(p_ptr->skill_sav * 100 / power))
2606         {
2607                 do_dec_stat(A_INT);
2608                 do_dec_stat(A_WIS);
2609                 return;
2610         }
2611
2612         /* Brain smash */
2613         if (!saving_throw(p_ptr->skill_sav * 100 / power))
2614         {
2615                 if (!p_ptr->resist_conf)
2616                 {
2617                         (void)set_confused(p_ptr->confused + randint0(4) + 4);
2618                 }
2619                 if (!p_ptr->free_act)
2620                 {
2621                         (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2622                 }
2623                 while (!saving_throw(p_ptr->skill_sav))
2624                 {
2625                         (void)do_dec_stat(A_INT);
2626                 }
2627                 while (!saving_throw(p_ptr->skill_sav))
2628                 {
2629                         (void)do_dec_stat(A_WIS);
2630                 }
2631                 if (!p_ptr->resist_chaos)
2632                 {
2633                         (void)set_image(p_ptr->image + randint0(250) + 150);
2634                 }
2635                 return;
2636         }
2637
2638
2639         /* Amnesia */
2640         if (!saving_throw(p_ptr->skill_sav * 100 / power))
2641         {
2642                 if (lose_all_info())
2643                 {
2644 #ifdef JP
2645 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2646 #else
2647                         msg_print("You forget everything in your utmost terror!");
2648 #endif
2649
2650                 }
2651                 return;
2652         }
2653
2654         /* Else gain permanent insanity */
2655         if ((p_ptr->muta3 & MUT3_MORONIC) && (p_ptr->muta2 & MUT2_BERS_RAGE) &&
2656                 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2657                 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2658         {
2659                 /* The poor bastard already has all possible insanities! */
2660                 return;
2661         }
2662
2663         while (!happened)
2664         {
2665                 switch (randint1(4))
2666                 {
2667                         case 1:
2668                         {
2669                                 if (!(p_ptr->muta3 & MUT3_MORONIC))
2670                                 {
2671                                         if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2672                                         {
2673 #ifdef JP
2674 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2675 #else
2676                                                 msg_print("You turn into an utter moron!");
2677 #endif
2678                                         }
2679                                         else
2680                                         {
2681 #ifdef JP
2682 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2683 #else
2684                                                 msg_print("You turn into an utter moron!");
2685 #endif
2686                                         }
2687
2688                                         if (p_ptr->muta3 & MUT3_HYPER_INT)
2689                                         {
2690 #ifdef JP
2691 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2692 #else
2693                                                 msg_print("Your brain is no longer a living computer.");
2694 #endif
2695
2696                                                 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2697                                         }
2698                                         p_ptr->muta3 |= MUT3_MORONIC;
2699                                         happened = TRUE;
2700                                 }
2701                                 break;
2702                         }
2703                         case 2:
2704                         {
2705                                 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2706                                 {
2707 #ifdef JP
2708 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2709 #else
2710                                         msg_print("You become paranoid!");
2711 #endif
2712
2713
2714                                         /* Duh, the following should never happen, but anyway... */
2715                                         if (p_ptr->muta3 & MUT3_FEARLESS)
2716                                         {
2717 #ifdef JP
2718 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2719 #else
2720                                                 msg_print("You are no longer fearless.");
2721 #endif
2722
2723                                                 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2724                                         }
2725
2726                                         p_ptr->muta2 |= MUT2_COWARDICE;
2727                                         happened = TRUE;
2728                                 }
2729                                 break;
2730                         }
2731                         case 3:
2732                         {
2733                                 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2734                                 {
2735 #ifdef JP
2736 msg_print("¸¸³Ð¤ò¤Ò¤­µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2737 #else
2738                                         msg_print("You are afflicted by a hallucinatory insanity!");
2739 #endif
2740
2741                                         p_ptr->muta2 |= MUT2_HALLU;
2742                                         happened = TRUE;
2743                                 }
2744                                 break;
2745                         }
2746                         default:
2747                         {
2748                                 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2749                                 {
2750 #ifdef JP
2751 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2752 #else
2753                                         msg_print("You become subject to fits of berserk rage!");
2754 #endif
2755
2756                                         p_ptr->muta2 |= MUT2_BERS_RAGE;
2757                                         happened = TRUE;
2758                                 }
2759                                 break;
2760                         }
2761                 }
2762         }
2763
2764         p_ptr->update |= PU_BONUS;
2765         handle_stuff();
2766 }
2767
2768
2769 /*
2770  * inn commands
2771  * Note that resting for the night was a perfect way to avoid player
2772  * ghosts in the town *if* you could only make it to the inn in time (-:
2773  * Now that the ghosts are temporarily disabled in 2.8.X, this function
2774  * will not be that useful.  I will keep it in the hopes the player
2775  * ghost code does become a reality again. Does help to avoid filthy urchins.
2776  * Resting at night is also a quick way to restock stores -KMW-
2777  */
2778 static bool inn_comm(int cmd)
2779 {
2780         switch (cmd)
2781         {
2782                 case BACT_FOOD: /* Buy food & drink */
2783                         if (p_ptr->food >= PY_FOOD_FULL)
2784                         {
2785 #ifdef JP
2786                                 msg_print("º£¤ÏËþÊ¢¤À¡£");
2787 #else
2788                                 msg_print("You are full now.");
2789 #endif
2790                                 return FALSE;
2791                         }
2792
2793 #ifdef JP
2794 msg_print("¥Ð¡¼¥Æ¥ó¤Ï¤¤¤¯¤é¤«¤Î¿©¤Ùʪ¤È¥Ó¡¼¥ë¤ò¤¯¤ì¤¿¡£");
2795 #else
2796                         msg_print("The barkeep gives you some gruel and a beer.");
2797 #endif
2798
2799                         (void)set_food(PY_FOOD_MAX - 1);
2800                         break;
2801
2802                 case BACT_REST: /* Rest for the night */
2803                         if ((p_ptr->poisoned) || (p_ptr->cut))
2804                         {
2805 #ifdef JP
2806                                 msg_print("¤¢¤Ê¤¿¤ËɬÍפʤΤÏÉô²°¤Ç¤Ï¤Ê¤¯¡¢¼£ÎżԤǤ¹¡£");
2807 #else
2808                                 msg_print("You need a healer, not a room.");
2809 #endif
2810
2811                                 msg_print(NULL);
2812 #ifdef JP
2813                                 msg_print("¤¹¤ß¤Þ¤»¤ó¡¢¤Ç¤â¤¦¤Á¤Ç狼¤Ë»à¤Ê¤ì¤Á¤ãº¤¤ê¤Þ¤¹¤ó¤Ç¡£");
2814 #else
2815                                 msg_print("Sorry, but don't want anyone dying in here.");
2816 #endif
2817                         }
2818                         else
2819                         {
2820                                 int oldturn = turn;
2821                                 int prev_day, prev_hour, prev_min;
2822
2823                                 extract_day_hour_min(&prev_day, &prev_hour, &prev_min);
2824 #ifdef JP
2825                                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "½É²°¤ËÇñ¤Þ¤Ã¤¿¡£");
2826 #else
2827                                 if ((prev_hour >= 6) && (prev_hour <= 17)) do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over daytime at the inn.");
2828                                 else do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over night at the inn.");
2829 #endif
2830                                 turn = (turn / (TURNS_PER_TICK*TOWN_DAWN/2) + 1) * (TURNS_PER_TICK*TOWN_DAWN/2);
2831                                 if ((prev_hour >= 18) && (prev_hour <= 23)) do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
2832                                 p_ptr->chp = p_ptr->mhp;
2833
2834                                 dungeon_turn += MIN(turn - oldturn, TURNS_PER_TICK*250);
2835
2836                                 if (ironman_nightmare)
2837                                 {
2838 #ifdef JP
2839                                         msg_print("̲¤ê¤Ë½¢¤¯¤È¶²¤í¤·¤¤¸÷·Ê¤¬¿´¤ò¤è¤®¤Ã¤¿¡£");
2840 #else
2841                                         msg_print("Horrible visions flit through your mind as you sleep.");
2842 #endif
2843
2844                                         /* Pick a nightmare */
2845                                         get_mon_num_prep(get_nightmare, NULL);
2846
2847                                         /* Have some nightmares */
2848                                         while(1)
2849                                         {
2850                                                 have_nightmare(get_mon_num(MAX_DEPTH));
2851
2852                                                 if (!one_in_(3)) break;
2853                                         }
2854
2855                                         /* Remove the monster restriction */
2856                                         get_mon_num_prep(NULL, NULL);
2857
2858 #ifdef JP
2859                                         msg_print("¤¢¤Ê¤¿¤ÏÀ䶫¤·¤ÆÌܤò³Ð¤Þ¤·¤¿¡£");
2860                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "°­Ì´¤Ë¤¦¤Ê¤µ¤ì¤Æ¤è¤¯Ì²¤ì¤Ê¤«¤Ã¤¿¡£");
2861 #else
2862                                         msg_print("You awake screaming.");
2863                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "be troubled by a nightmare.");
2864 #endif
2865                                 }
2866                                 else
2867                                 {
2868                                         set_blind(0);
2869                                         set_confused(0);
2870                                         p_ptr->stun = 0;
2871                                         p_ptr->chp = p_ptr->mhp;
2872                                         p_ptr->csp = p_ptr->msp;
2873                                         if (p_ptr->pclass == CLASS_MAGIC_EATER)
2874                                         {
2875                                                 int i;
2876                                                 for (i = 0; i < 72; i++)
2877                                                 {
2878                                                         p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
2879                                                 }
2880                                                 for (; i < 108; i++)
2881                                                 {
2882                                                         p_ptr->magic_num1[i] = 0;
2883                                                 }
2884                                         }
2885
2886                                         if ((prev_hour >= 6) && (prev_hour <= 17))
2887                                         {
2888 #ifdef JP
2889                                                 msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢͼÊý¤ò·Þ¤¨¤¿¡£");
2890                                                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "ͼÊý¤ò·Þ¤¨¤¿¡£");
2891 #else
2892                                                 msg_print("You awake refreshed for the evening.");
2893                                                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "awake refreshed.");
2894 #endif
2895                                         }
2896                                         else
2897                                         {
2898 #ifdef JP
2899                                                 msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢ¿·¤¿¤ÊÆü¤ò·Þ¤¨¤¿¡£");
2900                                                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¤¹¤¬¤¹¤¬¤·¤¤Ä«¤ò·Þ¤¨¤¿¡£");
2901 #else
2902                                                 msg_print("You awake refreshed for the new day.");
2903                                                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "awake refreshed.");
2904 #endif
2905                                         }
2906                                 }
2907
2908                                 p_ptr->leftbldg = TRUE;
2909                         }
2910                         break;
2911
2912                 case BACT_RUMORS: /* Listen for rumors */
2913                         {
2914                                 char Rumor[1024];
2915
2916 #ifdef JP
2917                                 if (!get_rnd_line_jonly("rumors_j.txt", 0, Rumor, 10))
2918 #else
2919                                 if (!get_rnd_line("rumors.txt", 0, Rumor))
2920 #endif
2921
2922                                         msg_format("%s", Rumor);
2923                                 break;
2924                         }
2925         }
2926
2927         return (TRUE);
2928 }
2929
2930
2931 /*
2932  * Share gold for thieves
2933  */
2934 static void share_gold(void)
2935 {
2936         int i = (p_ptr->lev * 2) * 10;
2937 #ifdef JP
2938 msg_format("¡ð%d ¤ò¼ê¤ËÆþ¤ì¤¿¡£", i);
2939 #else
2940         msg_format("You collect %d gold pieces", i);
2941 #endif
2942
2943         p_ptr->au += i;
2944 }
2945
2946
2947 /*
2948  * Display quest information
2949  */
2950 static void get_questinfo(int questnum)
2951 {
2952         int     i;
2953         int     old_quest;
2954         char    tmp_str[80];
2955
2956
2957         /* Clear the text */
2958         for (i = 0; i < 10; i++)
2959         {
2960                 quest_text[i][0] = '\0';
2961         }
2962
2963         quest_text_line = 0;
2964
2965         /* Set the quest number temporary */
2966         old_quest = p_ptr->inside_quest;
2967         p_ptr->inside_quest = questnum;
2968
2969         /* Get the quest text */
2970         init_flags = INIT_SHOW_TEXT | INIT_ASSIGN;
2971
2972         process_dungeon_file("q_info.txt", 0, 0, 0, 0);
2973
2974         /* Reset the old quest number */
2975         p_ptr->inside_quest = old_quest;
2976
2977         /* Print the quest info */
2978 #ifdef JP
2979 sprintf(tmp_str, "¥¯¥¨¥¹¥È¾ðÊó (´í¸±ÅÙ: %d ³¬ÁêÅö)", quest[questnum].level);
2980 #else
2981         sprintf(tmp_str, "Quest Information (Danger level: %d)", quest[questnum].level);
2982 #endif
2983
2984         prt(tmp_str, 5, 0);
2985
2986         prt(quest[questnum].name, 7, 0);
2987
2988         for (i = 0; i < 10; i++)
2989         {
2990                 c_put_str(TERM_YELLOW, quest_text[i], i + 8, 0);
2991         }
2992 }
2993
2994
2995 /*
2996  * Request a quest from the Lord.
2997  */
2998 static void castle_quest(void)
2999 {
3000         int             q_index = 0;
3001         monster_race    *r_ptr;
3002         quest_type      *q_ptr;
3003         cptr            name;
3004
3005
3006         clear_bldg(4, 18);
3007
3008         /* Current quest of the building */
3009         q_index = cave[py][px].special;
3010
3011         /* Is there a quest available at the building? */
3012         if (!q_index)
3013         {
3014 #ifdef JP
3015 put_str("º£¤Î¤È¤³¤í¥¯¥¨¥¹¥È¤Ï¤¢¤ê¤Þ¤»¤ó¡£", 8, 0);
3016 #else
3017                 put_str("I don't have a quest for you at the moment.", 8, 0);
3018 #endif
3019
3020                 return;
3021         }
3022
3023         q_ptr = &quest[q_index];
3024
3025         /* Quest is completed */
3026         if (q_ptr->status == QUEST_STATUS_COMPLETED)
3027         {
3028                 /* Rewarded quest */
3029                 q_ptr->status = QUEST_STATUS_REWARDED;
3030
3031                 get_questinfo(q_index);
3032
3033                 reinit_wilderness = TRUE;
3034         }
3035         /* Failed quest */
3036         else if (q_ptr->status == QUEST_STATUS_FAILED)
3037         {
3038                 get_questinfo(q_index);
3039
3040                 /* Mark quest as done (but failed) */
3041                 q_ptr->status = QUEST_STATUS_FAILED_DONE;
3042
3043                 reinit_wilderness = TRUE;
3044         }
3045         /* Quest is still unfinished */
3046         else if (q_ptr->status == QUEST_STATUS_TAKEN)
3047         {
3048 #ifdef JP
3049 put_str("¤¢¤Ê¤¿¤Ï¸½ºß¤Î¥¯¥¨¥¹¥È¤ò½ªÎ»¤µ¤»¤Æ¤¤¤Þ¤»¤ó¡ª", 8, 0);
3050 #else
3051                 put_str("You have not completed your current quest yet!", 8, 0);
3052 #endif
3053
3054 #ifdef JP
3055 put_str("CTRL-Q¤ò»È¤¨¤Ð¥¯¥¨¥¹¥È¤Î¾õÂÖ¤¬¥Á¥§¥Ã¥¯¤Ç¤­¤Þ¤¹¡£", 9, 0);
3056 #else
3057                 put_str("Use CTRL-Q to check the status of your quest.", 9, 0);
3058 #endif
3059
3060 #ifdef JP
3061 put_str("¥¯¥¨¥¹¥È¤ò½ª¤ï¤é¤»¤¿¤éÌá¤Ã¤ÆÍè¤Æ²¼¤µ¤¤¡£", 12, 0);
3062 #else
3063                 put_str("Return when you have completed your quest.", 12, 0);
3064 #endif
3065
3066         }
3067         /* No quest yet */
3068         else if (q_ptr->status == QUEST_STATUS_UNTAKEN)
3069         {
3070                 q_ptr->status = QUEST_STATUS_TAKEN;
3071
3072                 reinit_wilderness = TRUE;
3073
3074                 /* Assign a new quest */
3075                 if (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL)
3076                 {
3077                         if (q_ptr->r_idx == 0)
3078                         {
3079                                 /* Random monster at least 5 - 10 levels out of deep */
3080                                 q_ptr->r_idx = get_mon_num(q_ptr->level + 4 + randint1(6));
3081                         }
3082
3083                         r_ptr = &r_info[q_ptr->r_idx];
3084
3085                         while ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->rarity != 1))
3086                         {
3087                                 q_ptr->r_idx = get_mon_num(q_ptr->level) + 4 + randint1(6);
3088                                 r_ptr = &r_info[q_ptr->r_idx];
3089                         }
3090
3091                         if (q_ptr->max_num == 0)
3092                         {
3093                                 /* Random monster number */
3094                                 if (randint1(10) > 7)
3095                                         q_ptr->max_num = 1;
3096                                 else
3097                                         q_ptr->max_num = randint1(3) + 1;
3098                         }
3099
3100                         q_ptr->cur_num = 0;
3101                         name = (r_name + r_ptr->name);
3102 #ifdef JP
3103 msg_format("¥¯¥¨¥¹¥È: %s¤ò %dÂÎÅݤ¹", name,q_ptr->max_num);
3104 #else
3105                         msg_format("Your quest: kill %d %s", q_ptr->max_num, name);
3106 #endif
3107
3108                 }
3109                 else
3110                 {
3111                         get_questinfo(q_index);
3112                 }
3113         }
3114 }
3115
3116
3117 /*
3118  * Display town history
3119  */
3120 static void town_history(void)
3121 {
3122         /* Save screen */
3123         screen_save();
3124
3125         /* Peruse the building help file */
3126 #ifdef JP
3127 (void)show_file(TRUE, "jbldg.txt", NULL, 0, 0);
3128 #else
3129         (void)show_file(TRUE, "bldg.txt", NULL, 0, 0);
3130 #endif
3131
3132
3133         /* Load screen */
3134         screen_load();
3135 }
3136
3137
3138 /*
3139  * Display the damage figure of an object
3140  * (used by compare_weapon_aux1)
3141  *
3142  * Only accurate for the current weapon, because it includes
3143  * the current +dam of the player.
3144  */
3145 static void compare_weapon_aux2(object_type *o_ptr, int numblows,
3146                                 int r, int c, int mult, cptr attr,
3147                                 byte color)
3148 {
3149         char tmp_str[80];
3150
3151         /* Effective dices */
3152         int eff_dd = o_ptr->dd + p_ptr->to_dd[0];
3153         int eff_ds = o_ptr->ds + p_ptr->to_ds[0];
3154
3155         /* Print the intro text */
3156         c_put_str(color, attr, r, c);
3157
3158         /* Calculate the min and max damage figures */
3159 #ifdef JP
3160 sprintf(tmp_str, "£±¥¿¡¼¥ó: %d-%d ¥À¥á¡¼¥¸",
3161 #else
3162         sprintf(tmp_str, "Attack: %d-%d damage",
3163 #endif
3164
3165             (numblows * (mult * eff_dd / 60 + o_ptr->to_d + p_ptr->to_d[0])),
3166             (numblows * (mult * eff_ds * eff_dd / 60 + o_ptr->to_d + p_ptr->to_d[0])));
3167
3168         /* Print the damage */
3169         put_str(tmp_str, r, c + 8);
3170 }
3171
3172
3173 /*
3174  * Show the damage figures for the various monster types
3175  *
3176  * Only accurate for the current weapon, because it includes
3177  * the current number of blows for the player.
3178  */
3179 static void compare_weapon_aux1(object_type *o_ptr, int col, int r)
3180 {
3181         int mult = 60;
3182         u32b flgs[TR_FLAG_SIZE];
3183         int blow = p_ptr->num_blow[0];
3184         bool print_force_weapon = FALSE;
3185
3186         /* Get the flags of the weapon */
3187         object_flags(o_ptr, flgs);
3188
3189         if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
3190         {
3191                 mult = mult * 7 / 2;
3192                 print_force_weapon = TRUE;
3193         }
3194
3195         /* Print the relevant lines */
3196 #ifdef JP
3197         if (print_force_weapon)     compare_weapon_aux2(o_ptr, blow, r++, col, 1*mult, "ÍýÎÏ:", TERM_L_BLUE);
3198         if (have_flag(flgs, TR_KILL_ANIMAL)) compare_weapon_aux2(o_ptr, blow, r++, col, 4*mult, "ưʪ:", TERM_YELLOW);
3199          else if (have_flag(flgs, TR_SLAY_ANIMAL)) compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "ưʪ:", TERM_YELLOW);
3200         if (have_flag(flgs, TR_KILL_EVIL))   compare_weapon_aux2(o_ptr, blow, r++, col, 7*mult/2, "¼Ù°­:", TERM_YELLOW);
3201          else if (have_flag(flgs, TR_SLAY_EVIL))   compare_weapon_aux2(o_ptr, blow, r++, col, 2*mult, "¼Ù°­:", TERM_YELLOW);
3202         if (have_flag(flgs, TR_KILL_HUMAN))   compare_weapon_aux2(o_ptr, blow, r++, col, 4*mult, "¿Í´Ö:", TERM_YELLOW);
3203          else if (have_flag(flgs, TR_SLAY_HUMAN))   compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "¿Í´Ö:", TERM_YELLOW);
3204         if (have_flag(flgs, TR_KILL_UNDEAD)) compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "ÉÔ»à:", TERM_YELLOW);
3205          else if (have_flag(flgs, TR_SLAY_UNDEAD)) compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "ÉÔ»à:", TERM_YELLOW);
3206         if (have_flag(flgs, TR_KILL_DEMON))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "°­Ëâ:", TERM_YELLOW);
3207          else if (have_flag(flgs, TR_SLAY_DEMON))  compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "°­Ëâ:", TERM_YELLOW);
3208         if (have_flag(flgs, TR_KILL_ORC))    compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "¥ª¡¼¥¯:", TERM_YELLOW);
3209          else if (have_flag(flgs, TR_SLAY_ORC))    compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "¥ª¡¼¥¯:", TERM_YELLOW);
3210         if (have_flag(flgs, TR_KILL_TROLL))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "¥È¥í¥ë:", TERM_YELLOW);
3211          else if (have_flag(flgs, TR_SLAY_TROLL))  compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "¥È¥í¥ë:", TERM_YELLOW);
3212         if (have_flag(flgs, TR_KILL_GIANT))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "µð¿Í:", TERM_YELLOW);
3213          else if (have_flag(flgs, TR_SLAY_GIANT))  compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "µð¿Í:", TERM_YELLOW);
3214         if (have_flag(flgs, TR_KILL_DRAGON)) compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "ε:", TERM_YELLOW);
3215         else if (have_flag(flgs, TR_SLAY_DRAGON)) compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "ε:", TERM_YELLOW);
3216         if (have_flag(flgs, TR_BRAND_ACID))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "»À°À­:", TERM_RED);
3217         if (have_flag(flgs, TR_BRAND_ELEC))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "ÅÅ°À­:", TERM_RED);
3218         if (have_flag(flgs, TR_BRAND_FIRE))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "±ê°À­:", TERM_RED);
3219         if (have_flag(flgs, TR_BRAND_COLD))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Îä°À­:", TERM_RED);
3220         if (have_flag(flgs, TR_BRAND_POIS))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "ÆÇ°À­:", TERM_RED);
3221 #else
3222         if (print_force_weapon)     compare_weapon_aux2(o_ptr, blow, r++, col, 1*mult, "Force  :", TERM_L_BLUE);
3223         if (have_flag(flgs, TR_KILL_ANIMAL)) compare_weapon_aux2(o_ptr, blow, r++, col, 4*mult, "Animals:", TERM_YELLOW);
3224         else if (have_flag(flgs, TR_SLAY_ANIMAL)) compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Animals:", TERM_YELLOW);
3225         if (have_flag(flgs, TR_KILL_EVIL))   compare_weapon_aux2(o_ptr, blow, r++, col, 7*mult/2, "Evil:", TERM_YELLOW);
3226         else if (have_flag(flgs, TR_SLAY_EVIL))   compare_weapon_aux2(o_ptr, blow, r++, col, 2*mult, "Evil:", TERM_YELLOW);
3227         if (have_flag(flgs, TR_KILL_HUMAN))   compare_weapon_aux2(o_ptr, blow, r++, col, 4*mult, "Human:", TERM_YELLOW);
3228         else if (have_flag(flgs, TR_SLAY_HUMAN))   compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Human:", TERM_YELLOW);
3229         if (have_flag(flgs, TR_KILL_UNDEAD)) compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "Undead:", TERM_YELLOW);
3230         else if (have_flag(flgs, TR_SLAY_UNDEAD)) compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "Undead:", TERM_YELLOW);
3231         if (have_flag(flgs, TR_KILL_DEMON))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "Demons:", TERM_YELLOW);
3232         else if (have_flag(flgs, TR_SLAY_DEMON))  compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "Demons:", TERM_YELLOW);
3233         if (have_flag(flgs, TR_KILL_ORC))    compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "Orcs:", TERM_YELLOW);
3234         else if (have_flag(flgs, TR_SLAY_ORC))    compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "Orcs:", TERM_YELLOW);
3235         if (have_flag(flgs, TR_KILL_TROLL))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "Trolls:", TERM_YELLOW);
3236         else if (have_flag(flgs, TR_SLAY_TROLL))  compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "Trolls:", TERM_YELLOW);
3237         if (have_flag(flgs, TR_KILL_GIANT))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "Giants:", TERM_YELLOW);
3238         else if (have_flag(flgs, TR_SLAY_GIANT))  compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "Giants:", TERM_YELLOW);
3239         if (have_flag(flgs, TR_KILL_DRAGON)) compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult, "Dragons:", TERM_YELLOW);
3240         else if (have_flag(flgs, TR_SLAY_DRAGON)) compare_weapon_aux2(o_ptr, blow, r++, col, 3*mult, "Dragons:", TERM_YELLOW);
3241         if (have_flag(flgs, TR_BRAND_ACID))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Acid:", TERM_RED);
3242         if (have_flag(flgs, TR_BRAND_ELEC))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Elec:", TERM_RED);
3243         if (have_flag(flgs, TR_BRAND_FIRE))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Fire:", TERM_RED);
3244         if (have_flag(flgs, TR_BRAND_COLD))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Cold:", TERM_RED);
3245         if (have_flag(flgs, TR_BRAND_POIS))  compare_weapon_aux2(o_ptr, blow, r++, col, 5*mult/2, "Poison:", TERM_RED);
3246 #endif
3247
3248 }
3249
3250 static int hit_chance(int to_h, int ac)
3251 {
3252         int chance = 0;
3253         int meichuu = p_ptr->skill_thn + (p_ptr->to_h[0] + to_h) * BTH_PLUS_ADJ;
3254
3255         if (meichuu <= 0) return 5;
3256
3257         chance = 100 - ((ac * 75) / meichuu);
3258
3259         if (chance > 95) chance = 95;
3260         if (chance < 5) chance = 5;
3261         if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
3262                 chance = (chance*19+9)/20;
3263         return chance;
3264 }
3265
3266 /*
3267  * Displays all info about a weapon
3268  *
3269  * Only accurate for the current weapon, because it includes
3270  * various info about the player's +to_dam and number of blows.
3271  */
3272 static void list_weapon(object_type *o_ptr, int row, int col)
3273 {
3274         char o_name[MAX_NLEN];
3275         char tmp_str[80];
3276
3277         /* Effective dices */
3278         int eff_dd = o_ptr->dd + p_ptr->to_dd[0];
3279         int eff_ds = o_ptr->ds + p_ptr->to_ds[0];
3280
3281         /* Print the weapon name */
3282         object_desc(o_name, o_ptr, TRUE, 0);
3283         c_put_str(TERM_YELLOW, o_name, row, col);
3284
3285         /* Print the player's number of blows */
3286 #ifdef JP
3287 sprintf(tmp_str, "¹¶·â²ó¿ô: %d", p_ptr->num_blow[0]);
3288 #else
3289         sprintf(tmp_str, "Number of Blows: %d", p_ptr->num_blow[0]);
3290 #endif
3291
3292         put_str(tmp_str, row+1, col);
3293
3294         /* Print to_hit and to_dam of the weapon */
3295 #ifdef JP
3296 sprintf(tmp_str, "Ì¿ÃæΨ:  0  50 100 150 200 (Ũ¤ÎAC)");
3297 #else
3298 sprintf(tmp_str, "To Hit:  0  50 100 150 200 (AC)");
3299 #endif
3300
3301         put_str(tmp_str, row+2, col);
3302
3303         /* Print the weapons base damage dice */
3304 #ifdef JP
3305 sprintf(tmp_str, "        %2d  %2d  %2d  %2d  %2d (%%)", hit_chance(o_ptr->to_h, 0), hit_chance(o_ptr->to_h, 50), hit_chance(o_ptr->to_h, 100), hit_chance(o_ptr->to_h, 150), hit_chance(o_ptr->to_h, 200));
3306 #else
3307 sprintf(tmp_str, "        %2d  %2d  %2d  %2d  %2d (%%)", hit_chance(o_ptr->to_h, 0), hit_chance(o_ptr->to_h, 50), hit_chance(o_ptr->to_h, 100), hit_chance(o_ptr->to_h, 150), hit_chance(o_ptr->to_h, 200));
3308 #endif
3309
3310         put_str(tmp_str, row+3, col);
3311
3312 #ifdef JP
3313 c_put_str(TERM_YELLOW, "²Äǽ¤Ê¥À¥á¡¼¥¸:", row+5, col);
3314 #else
3315         c_put_str(TERM_YELLOW, "Possible Damage:", row+5, col);
3316 #endif
3317
3318
3319         /* Damage for one blow (if it hits) */
3320 #ifdef JP
3321 sprintf(tmp_str, "¹¶·â°ì²ó¤Ë¤Ä¤­ %d-%d",
3322 #else
3323         sprintf(tmp_str, "One Strike: %d-%d damage",
3324 #endif
3325
3326             eff_dd + o_ptr->to_d + p_ptr->to_d[0],
3327             eff_ds * eff_dd + o_ptr->to_d + p_ptr->to_d[0]);
3328         put_str(tmp_str, row+6, col+1);
3329
3330         /* Damage for the complete attack (if all blows hit) */
3331 #ifdef JP
3332 sprintf(tmp_str, "£±¥¿¡¼¥ó¤Ë¤Ä¤­ %d-%d",
3333 #else
3334         sprintf(tmp_str, "One Attack: %d-%d damage",
3335 #endif
3336
3337             p_ptr->num_blow[0] * (eff_dd + o_ptr->to_d + p_ptr->to_d[0]),
3338             p_ptr->num_blow[0] * (eff_ds * eff_dd + o_ptr->to_d + p_ptr->to_d[0]));
3339         put_str(tmp_str, row+7, col+1);
3340 }
3341
3342
3343 /*
3344  * Hook to specify "weapon"
3345  */
3346 static bool item_tester_hook_melee_weapon(object_type *o_ptr)
3347 {
3348         switch (o_ptr->tval)
3349         {
3350                 case TV_HAFTED:
3351                 case TV_POLEARM:
3352                 case TV_DIGGING:
3353                 {
3354                         return (TRUE);
3355                 }
3356                 case TV_SWORD:
3357                 {
3358                         if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
3359                 }
3360         }
3361
3362         return (FALSE);
3363 }
3364
3365
3366 /*
3367  * Hook to specify "ammo"
3368  */
3369 static bool item_tester_hook_ammo(object_type *o_ptr)
3370 {
3371         switch (o_ptr->tval)
3372         {
3373                 case TV_SHOT:
3374                 case TV_ARROW:
3375                 case TV_BOLT:
3376                 {
3377                         return (TRUE);
3378                 }
3379         }
3380
3381         return (FALSE);
3382 }
3383
3384
3385 /*
3386  * Compare weapons
3387  *
3388  * Copies the weapons to compare into the weapon-slot and
3389  * compares the values for both weapons.
3390  */
3391 static bool compare_weapons(void)
3392 {
3393         int item, item2;
3394         object_type *o1_ptr, *o2_ptr;
3395         object_type orig_weapon;
3396         object_type *i_ptr;
3397         cptr q, s;
3398         int row = 2;
3399         bool old_character_xtra = character_xtra;
3400
3401         screen_save();
3402         /* Clear the screen */
3403         clear_bldg(0, 22);
3404
3405         /* Store copy of original wielded weapon */
3406         i_ptr = &inventory[INVEN_RARM];
3407         object_copy(&orig_weapon, i_ptr);
3408
3409         item_tester_no_ryoute = TRUE;
3410         /* Only compare melee weapons */
3411         item_tester_hook = item_tester_hook_melee_weapon;
3412
3413         /* Get the first weapon */
3414 #ifdef JP
3415 q = "Âè°ì¤ÎÉð´ï¤Ï¡©";
3416 s = "Èæ¤Ù¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3417 #else
3418         q = "What is your first weapon? ";
3419         s = "You have nothing to compare.";
3420 #endif
3421
3422         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN)))
3423         {
3424                 screen_load();
3425                 return (FALSE);
3426         }
3427
3428         /* Get the item (in the pack) */
3429         o1_ptr = &inventory[item];
3430
3431         /* Clear the screen */
3432         clear_bldg(0, 22);
3433
3434         item_tester_no_ryoute = TRUE;
3435         /* Only compare melee weapons */
3436         item_tester_hook = item_tester_hook_melee_weapon;
3437
3438         /* Get the second weapon */
3439 #ifdef JP
3440 q = "ÂèÆó¤ÎÉð´ï¤Ï¡©";
3441 s = "Èæ¤Ù¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3442 #else
3443         q = "What is your second weapon? ";
3444         s = "You have nothing to compare.";
3445 #endif
3446
3447         if (!get_item(&item2, q, s, (USE_EQUIP | USE_INVEN)))
3448         {
3449                 screen_load();
3450                 return (FALSE);
3451         }
3452
3453         /* Get the item (in the pack) */
3454         o2_ptr = &inventory[item2];
3455
3456         /* Clear the screen */
3457         clear_bldg(0, 22);
3458
3459         /* Copy first weapon into the weapon slot (if it's not already there) */
3460         if (o1_ptr != i_ptr)
3461                 object_copy(i_ptr, o1_ptr);
3462
3463         /* Hack -- prevent "icky" message */
3464         character_xtra = TRUE;
3465
3466         /* Get the new values */
3467         calc_bonuses();
3468
3469         character_xtra = old_character_xtra;
3470
3471         /* List the new values */
3472         list_weapon(o1_ptr, row, 2);
3473         compare_weapon_aux1(o1_ptr, 2, row + 8);
3474
3475         /* Copy second weapon into the weapon slot (if it's not already there) */
3476         if (o2_ptr != i_ptr)
3477                 object_copy(i_ptr, o2_ptr);
3478         else
3479                 object_copy(i_ptr, &orig_weapon);
3480
3481         /* Hack -- prevent "icky" message */
3482         character_xtra = TRUE;
3483
3484         /* Get the new values */
3485         calc_bonuses();
3486
3487         character_xtra = old_character_xtra;
3488
3489         /* List the new values */
3490         list_weapon(o2_ptr, row, 40);
3491         compare_weapon_aux1(o2_ptr, 40, row + 8);
3492
3493         /* Copy back the original weapon into the weapon slot */
3494         object_copy(i_ptr, &orig_weapon);
3495
3496         /* Reset the values for the old weapon */
3497         calc_bonuses();
3498
3499 #ifdef JP
3500 put_str("(°ìÈֹ⤤¥À¥á¡¼¥¸¤¬Å¬ÍѤµ¤ì¤Þ¤¹¡£Ê£¿ô¤ÎÇÜÂǸú²Ì¤Ï­¤·»»¤µ¤ì¤Þ¤»¤ó¡£)", row + 4, 0);
3501 #else
3502         put_str("(Only highest damage applies per monster. Special damage not cumulative.)", row + 4, 0);
3503 #endif
3504
3505 #ifdef JP
3506 msg_print("¸½ºß¤Îµ»Î̤«¤éȽÃǤ¹¤ë¤È¡¢¤¢¤Ê¤¿¤ÎÉð´ï¤Ï°Ê²¼¤Î¤è¤¦¤Ê°ÒÎϤòȯ´ø¤·¤Þ¤¹:");
3507 #else
3508         msg_print("Based on your current abilities, here is what your weapons will do");
3509 #endif
3510
3511
3512         flush();
3513         (void)inkey();
3514         screen_load();
3515
3516         /* Done */
3517         return (TRUE);
3518 }
3519
3520
3521 /*
3522  * Evaluate AC
3523  *
3524  * AC¤«¤é²óÈòΨ¡¢¥À¥á¡¼¥¸¸º¾¯Î¨¤ò·×»»¤·É½¼¨¤¹¤ë
3525  * Calculate and display the dodge-rate and the protection-rate
3526  * based on AC
3527  */
3528 static bool eval_ac(int iAC)
3529 {
3530 #ifdef JP
3531         const char memo[] =
3532                 "¥À¥á¡¼¥¸·Ú¸ºÎ¨¤È¤Ï¡¢Å¨¤Î¹¶·â¤¬Åö¤¿¤Ã¤¿»þ¤½¤Î¥À¥á¡¼¥¸¤ò\n"
3533                 "²¿¥Ñ¡¼¥»¥ó¥È·Ú¸º¤¹¤ë¤«¤ò¼¨¤·¤Þ¤¹¡£\n"
3534                 "¥À¥á¡¼¥¸·Ú¸º¤ÏÄ̾ï¤ÎľÀܹ¶·â(¼ïÎब¡Ö¹¶·â¤¹¤ë¡×¤È¡ÖÊ´ºÕ¤¹¤ë¡×¤Îʪ)\n"
3535                 "¤ËÂФ·¤Æ¤Î¤ß¸ú²Ì¤¬¤¢¤ê¤Þ¤¹¡£\n \n"
3536                 "Ũ¤Î¥ì¥Ù¥ë¤È¤Ï¡¢¤½¤ÎŨ¤¬Ä̾ﲿ³¬¤Ë¸½¤ì¤ë¤«¤ò¼¨¤·¤Þ¤¹¡£\n \n"
3537                 "²óÈòΨ¤ÏŨ¤ÎľÀܹ¶·â¤ò²¿¥Ñ¡¼¥»¥ó¥È¤Î³ÎΨ¤ÇÈò¤±¤ë¤«¤ò¼¨¤·¡¢\n"
3538                 "Ũ¤Î¥ì¥Ù¥ë¤È¤¢¤Ê¤¿¤ÎAC¤Ë¤è¤Ã¤Æ·èÄꤵ¤ì¤Þ¤¹¡£\n \n"
3539                 "¥À¥á¡¼¥¸´üÂÔÃͤȤϡ¢Å¨¤Î£±£°£°¥Ý¥¤¥ó¥È¤ÎÄ̾ﹶ·â¤ËÂФ·¡¢\n"
3540                 "²óÈòΨ¤È¥À¥á¡¼¥¸·Ú¸ºÎ¨¤ò¹Íθ¤·¤¿¥À¥á¡¼¥¸¤Î´üÂÔÃͤò¼¨¤·¤Þ¤¹¡£\n";
3541 #else
3542         const char memo[] =
3543                 "'Protection Rate' means how much damage is reduced by your armor.\n"
3544                 "Note that the Protection rate is effective only against normal "
3545                 "'attack' and 'shatter' type melee attacks, "
3546                 "and has no effect against any other types such as 'poison'.\n \n"
3547                 "'Dodge Rate' indicates the success rate on dodging the "
3548                 "monster's melee attacks.  "
3549                 "It is depend on the level of the monster and your AC.\n \n"
3550                 "'Average Damage' indicates the expected amount of damage "
3551                 "when you are attacked by normal melee attacks with power=100.";
3552 #endif
3553
3554         int protection;
3555         int col, row = 2;
3556         int lvl;
3557         char buf[80*20], *t;
3558
3559         /* AC lower than zero has no effect */
3560         if (iAC < 0) iAC = 0;
3561
3562         /* ¥À¥á¡¼¥¸·Ú¸ºÎ¨¤ò·×»» */
3563         protection = 100 * MIN(iAC, 150) / 250;
3564
3565         screen_save();
3566         clear_bldg(0, 22);
3567
3568 #ifdef JP
3569         put_str(format("¤¢¤Ê¤¿¤Î¸½ºß¤ÎAC: %3d", iAC), row++, 0);
3570         put_str(format("¥À¥á¡¼¥¸·Ú¸ºÎ¨  : %3d%%", protection), row++, 0);
3571         row++;
3572
3573         put_str("Ũ¤Î¥ì¥Ù¥ë      :", row + 0, 0);
3574         put_str("²óÈòΨ          :", row + 1, 0);
3575         put_str("¥À¥á¡¼¥¸´üÂÔÃÍ  :", row + 2, 0);
3576 #else
3577         put_str(format("Your current AC : %3d", iAC), row++, 0);
3578         put_str(format("Protection rate : %3d%%", protection), row++, 0);
3579         row++;
3580
3581         put_str("Level of Monster:", row + 0, 0);
3582         put_str("Dodge Rate      :", row + 1, 0);
3583         put_str("Average Damage  :", row + 2, 0);
3584 #endif
3585     
3586         for (col = 17 + 1, lvl = 0; lvl <= 100; lvl += 10, col += 5)
3587         {
3588                 int quality = 60 + lvl * 3; /* attack quality with power 60 */
3589                 int dodge;   /* ²óÈòΨ(%) */
3590                 int average; /* ¥À¥á¡¼¥¸´üÂÔÃÍ */
3591
3592                 put_str(format("%3d", lvl), row + 0, col);
3593
3594                 /* ²óÈòΨ¤ò·×»» */
3595                 dodge = 5 + (MIN(100, 100 * (iAC * 3 / 4) / quality) * 9 + 5) / 10;
3596                 put_str(format("%3d%%", dodge), row + 1, col);
3597
3598                 /* 100ÅÀ¤Î¹¶·â¤ËÂФ·¤Æ¤Î¥À¥á¡¼¥¸´üÂÔÃͤò·×»» */
3599                 average = (100 - dodge) * (100 - protection) / 100;
3600                 put_str(format("%3d", average), row + 2, col);
3601         }
3602
3603         /* Display note */
3604         roff_to_buf(memo, 70, buf, sizeof(buf));
3605         for (t = buf; t[0]; t += strlen(t) + 1)
3606                 put_str(t, (row++) + 4, 4);
3607
3608 #ifdef JP
3609         prt("¸½ºß¤Î¤¢¤Ê¤¿¤ÎÁõÈ÷¤«¤é¤¹¤ë¤È¡¢¤¢¤Ê¤¿¤ÎËɸæÎϤÏ"
3610                    "¤³¤ì¤¯¤é¤¤¤Ç¤¹:", 0, 0);
3611 #else
3612         prt("Defense abilities from your current Armor Class are evaluated below.", 0, 0);
3613 #endif
3614   
3615         flush();
3616         (void)inkey();
3617         screen_load();
3618
3619         /* Done */
3620         return (TRUE);
3621 }
3622
3623
3624 /*
3625  * Enchant item
3626  */
3627 static bool enchant_item(int cost, int to_hit, int to_dam, int to_ac)
3628 {
3629         int         i, item;
3630         bool        okay = FALSE;
3631         object_type *o_ptr;
3632         cptr        q, s;
3633         int         maxenchant = (p_ptr->lev / 5);
3634         char        tmp_str[MAX_NLEN];
3635
3636
3637         clear_bldg(4, 18);
3638 #ifdef JP
3639 prt(format("¸½ºß¤Î¤¢¤Ê¤¿¤Îµ»Î̤À¤È¡¢+%d ¤Þ¤Ç²þÎɤǤ­¤Þ¤¹¡£", maxenchant), 5, 0);
3640 prt(format(" ²þÎɤÎÎÁ¶â¤Ï°ì¸Ä¤Ë¤Ä¤­¡ð%d ¤Ç¤¹¡£", cost), 7, 0);
3641 #else
3642         prt(format("  Based on your skill, we can improve up to +%d.", maxenchant), 5, 0);
3643         prt(format("  The price for the service is %d gold per item.", cost), 7, 0);
3644 #endif
3645
3646         item_tester_no_ryoute = TRUE;
3647
3648         /* Get an item */
3649 #ifdef JP
3650 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
3651 s = "²þÎɤǤ­¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3652 #else
3653         q = "Improve which item? ";
3654         s = "You have nothing to improve.";
3655 #endif
3656
3657         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) return (FALSE);
3658
3659         /* Get the item (in the pack) */
3660         o_ptr = &inventory[item];
3661
3662         /* Check if the player has enough money */
3663         if (p_ptr->au < (cost * o_ptr->number))
3664         {
3665                 object_desc(tmp_str, o_ptr, TRUE, 0);
3666 #ifdef JP
3667 msg_format("%s¤ò²þÎɤ¹¤ë¤À¤±¤Î¥´¡¼¥ë¥É¤¬¤¢¤ê¤Þ¤»¤ó¡ª", tmp_str);
3668 #else
3669                 msg_format("You do not have the gold to improve %s!", tmp_str);
3670 #endif
3671
3672                 return (FALSE);
3673         }
3674
3675         /* Enchant to hit */
3676         for (i = 0; i < to_hit; i++)
3677         {
3678                 if (o_ptr->to_h < maxenchant)
3679                 {
3680                         if (enchant(o_ptr, 1, (ENCH_TOHIT | ENCH_FORCE)))
3681                         {
3682                                 okay = TRUE;
3683                                 break;
3684                         }
3685                 }
3686         }
3687
3688         /* Enchant to damage */
3689         for (i = 0; i < to_dam; i++)
3690         {
3691                 if (o_ptr->to_d < maxenchant)
3692                 {
3693                         if (enchant(o_ptr, 1, (ENCH_TODAM | ENCH_FORCE)))
3694                         {
3695                                 okay = TRUE;
3696                                 break;
3697                         }
3698                 }
3699         }
3700
3701         /* Enchant to AC */
3702         for (i = 0; i < to_ac; i++)
3703         {
3704                 if (o_ptr->to_a < maxenchant)
3705                 {
3706                         if (enchant(o_ptr, 1, (ENCH_TOAC | ENCH_FORCE)))
3707                         {
3708                                 okay = TRUE;
3709                                 break;
3710                         }
3711                 }
3712         }
3713
3714         /* Failure */
3715         if (!okay)
3716         {
3717                 /* Flush */
3718                 if (flush_failure) flush();
3719
3720                 /* Message */
3721 #ifdef JP
3722 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
3723 #else
3724                 msg_print("The improvement failed.");
3725 #endif
3726
3727
3728                 return (FALSE);
3729         }
3730         else
3731         {
3732                 object_desc(tmp_str, o_ptr, TRUE, 1);
3733 #ifdef JP
3734 msg_format("¡ð%d ¤Ç%s¤ò²þÎɤ·¤Þ¤·¤¿¡£", cost * o_ptr->number, tmp_str );
3735 #else
3736                 msg_format("Improved %s for %d gold.", tmp_str, cost * o_ptr->number);
3737 #endif
3738
3739                 /* Charge the money */
3740                 p_ptr->au -= (cost * o_ptr->number);
3741
3742                 if (item >= INVEN_RARM) calc_android_exp();
3743
3744                 /* Something happened */
3745                 return (TRUE);
3746         }
3747 }
3748
3749
3750 /*
3751  * Recharge rods, wands and staves
3752  *
3753  * The player can select the number of charges to add
3754  * (up to a limit), and the recharge never fails.
3755  *
3756  * The cost for rods depends on the level of the rod. The prices
3757  * for recharging wands and staves are dependent on the cost of
3758  * the base-item.
3759  */
3760 static void building_recharge(void)
3761 {
3762         int         item, lev;
3763         object_type *o_ptr;
3764         object_kind *k_ptr;
3765         cptr        q, s;
3766         int         price;
3767         int         charges;
3768         int         max_charges;
3769         char        tmp_str[MAX_NLEN];
3770
3771         msg_flag = FALSE;
3772
3773         /* Display some info */
3774         clear_bldg(4, 18);
3775 #ifdef JP
3776 prt("  ºÆ½¼Å¶¤ÎÈñÍѤϥ¢¥¤¥Æ¥à¤Î¼ïÎà¤Ë¤è¤ê¤Þ¤¹¡£", 6, 0);
3777 #else
3778         prt("  The prices of recharge depend on the type.", 6, 0);
3779 #endif
3780
3781
3782         /* Only accept legal items */
3783         item_tester_hook = item_tester_hook_recharge;
3784
3785         /* Get an item */
3786 #ifdef JP
3787 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3788 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤­¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3789 #else
3790         q = "Recharge which item? ";
3791         s = "You have nothing to recharge.";
3792 #endif
3793
3794         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3795
3796         /* Get the item (in the pack) */
3797         if (item >= 0)
3798         {
3799                 o_ptr = &inventory[item];
3800         }
3801
3802         /* Get the item (on the floor) */
3803         else
3804         {
3805                 o_ptr = &o_list[0 - item];
3806         }
3807
3808         k_ptr = &k_info[o_ptr->k_idx];
3809
3810         /*
3811          * We don't want to give the player free info about
3812          * the level of the item or the number of charges.
3813          */
3814         /* The item must be "known" */
3815         if (!object_known_p(o_ptr))
3816         {
3817 #ifdef JP
3818 msg_format("½¼Å¶¤¹¤ëÁ°¤Ë´ÕÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡ª");
3819 #else
3820                 msg_format("The item must be identified first!");
3821 #endif
3822
3823                 msg_print(NULL);
3824
3825                 if ((p_ptr->au >= 50) &&
3826 #ifdef JP
3827 get_check("¡ð50¤Ç´ÕÄꤷ¤Þ¤¹¤«¡© "))
3828 #else
3829                         get_check("Identify for 50 gold? "))
3830 #endif
3831
3832                 {
3833                         /* Pay the price */
3834                         p_ptr->au -= 50;
3835
3836                         /* Identify it */
3837                         identify_item(o_ptr);
3838
3839                         /* Description */
3840                         object_desc(tmp_str, o_ptr, TRUE, 3);
3841
3842 #ifdef JP
3843 msg_format("%s ¤Ç¤¹¡£", tmp_str);
3844 #else
3845                         msg_format("You have: %s.", tmp_str);
3846 #endif
3847
3848                         /* Auto-inscription */
3849                         auto_inscribe_item(item, is_autopick(o_ptr));
3850
3851                         /* Update the gold display */
3852                         building_prt_gold();
3853                 }
3854                 else
3855                 {
3856                         return;
3857                 }
3858         }
3859
3860         /* Extract the object "level" */
3861         lev = get_object_level(o_ptr);
3862
3863         /* Price for a rod */
3864         if (o_ptr->tval == TV_ROD)
3865         {
3866                 if (o_ptr->timeout > 0)
3867                 {
3868                         /* Fully recharge */
3869                         price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
3870                 }
3871                 else
3872                 {
3873                         /* No recharge necessary */
3874                         price = 0;
3875 #ifdef JP
3876 msg_format("¤½¤ì¤ÏºÆ½¼Å¶¤¹¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó¡£");
3877 #else
3878                         msg_format("That doesn't need to be recharged.");
3879 #endif
3880
3881                         return;
3882                 }
3883         }
3884         else if (o_ptr->tval == TV_STAFF)
3885         {
3886                 /* Price per charge ( = double the price paid by shopkeepers for the charge) */
3887                 price = (get_object_cost(o_ptr) / 10) * o_ptr->number;
3888
3889                 /* Pay at least 10 gold per charge */
3890                 price = MAX(10, price);
3891         }
3892         else
3893         {
3894                 /* Price per charge ( = double the price paid by shopkeepers for the charge) */
3895                 price = (get_object_cost(o_ptr) / 10);
3896
3897                 /* Pay at least 10 gold per charge */
3898                 price = MAX(10, price);
3899         }
3900
3901         /* Limit the number of charges for wands and staffs */
3902         if (o_ptr->tval == TV_WAND
3903                 && (o_ptr->pval / o_ptr->number >= k_ptr->pval))
3904         {
3905                 if (o_ptr->number > 1)
3906                 {
3907 #ifdef JP
3908 msg_print("¤³¤ÎËâË¡ËÀ¤Ï¤â¤¦½¼Ê¬¤Ë½¼Å¶¤µ¤ì¤Æ¤¤¤Þ¤¹¡£");
3909 #else
3910                         msg_print("These wands are already fully charged.");
3911 #endif
3912                 }
3913                 else
3914                 {
3915 #ifdef JP
3916 msg_print("¤³¤ÎËâË¡ËÀ¤Ï¤â¤¦½¼Ê¬¤Ë½¼Å¶¤µ¤ì¤Æ¤¤¤Þ¤¹¡£");
3917 #else
3918                         msg_print("This wand is already fully charged.");
3919 #endif
3920                 }
3921                 return;
3922         }
3923         else if (o_ptr->tval == TV_STAFF && o_ptr->pval >= k_ptr->pval)
3924         {
3925                 if (o_ptr->number > 1)
3926                 {
3927 #ifdef JP
3928 msg_print("¤³¤Î¾ó¤Ï¤â¤¦½¼Ê¬¤Ë½¼Å¶¤µ¤ì¤Æ¤¤¤Þ¤¹¡£");
3929 #else
3930                         msg_print("These staffs are already fully charged.");
3931 #endif
3932                 }
3933                 else
3934                 {
3935 #ifdef JP
3936 msg_print("¤³¤Î¾ó¤Ï¤â¤¦½¼Ê¬¤Ë½¼Å¶¤µ¤ì¤Æ¤¤¤Þ¤¹¡£");
3937 #else
3938                         msg_print("This staff is already fully charged.");
3939 #endif
3940                 }
3941                 return;
3942         }
3943
3944         /* Check if the player has enough money */
3945         if (p_ptr->au < price)
3946         {
3947                 object_desc(tmp_str, o_ptr, TRUE, 0);
3948 #ifdef JP
3949 msg_format("%s¤òºÆ½¼Å¶¤¹¤ë¤Ë¤Ï¡ð%d É¬ÍפǤ¹¡ª", tmp_str,price );
3950 #else
3951                 msg_format("You need %d gold to recharge %s!", price, tmp_str);
3952 #endif
3953
3954                 return;
3955         }
3956
3957         if (o_ptr->tval == TV_ROD)
3958         {
3959 #ifdef JP
3960 if (get_check(format("¤½¤Î¥í¥Ã¥É¤ò¡ð%d ¤ÇºÆ½¼Å¶¤·¤Þ¤¹¤«¡©",
3961  price)))
3962 #else
3963                 if (get_check(format("Recharge the %s for %d gold? ",
3964                         ((o_ptr->number > 1) ? "rods" : "rod"), price)))
3965 #endif
3966
3967                 {
3968                         /* Recharge fully */
3969                         o_ptr->timeout = 0;
3970                 }
3971                 else
3972                 {
3973                         return;
3974                 }
3975         }
3976         else
3977         {
3978                 if (o_ptr->tval == TV_STAFF)
3979                         max_charges = k_ptr->pval - o_ptr->pval;
3980                 else
3981                         max_charges = o_ptr->number * k_ptr->pval - o_ptr->pval;
3982
3983                 /* Get the quantity for staves and wands */
3984 #ifdef JP
3985 charges = get_quantity(format("°ì²óʬ¡ð%d ¤Ç²¿²óʬ½¼Å¶¤·¤Þ¤¹¤«¡©",
3986 #else
3987                 charges = get_quantity(format("Add how many charges for %d gold? ",
3988 #endif
3989
3990                               price), MIN(p_ptr->au / price, max_charges));
3991
3992                 /* Do nothing */
3993                 if (charges < 1) return;
3994
3995                 /* Get the new price */
3996                 price *= charges;
3997
3998                 /* Recharge */
3999                 o_ptr->pval += charges;
4000
4001                 /* We no longer think the item is empty */
4002                 o_ptr->ident &= ~(IDENT_EMPTY);
4003         }
4004
4005         /* Give feedback */
4006         object_desc(tmp_str, o_ptr, TRUE, 3);
4007 #ifdef JP
4008 msg_format("%s¤ò¡ð%d ¤ÇºÆ½¼Å¶¤·¤Þ¤·¤¿¡£", tmp_str, price);
4009 #else
4010         msg_format("%^s %s recharged for %d gold.", tmp_str, ((o_ptr->number > 1) ? "were" : "was"), price);
4011 #endif
4012
4013         /* Combine / Reorder the pack (later) */
4014         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
4015
4016         /* Window stuff */
4017         p_ptr->window |= (PW_INVEN);
4018
4019         /* Pay the price */
4020         p_ptr->au -= price;
4021
4022         /* Finished */
4023         return;
4024 }
4025
4026
4027 /*
4028  * Recharge rods, wands and staves
4029  *
4030  * The player can select the number of charges to add
4031  * (up to a limit), and the recharge never fails.
4032  *
4033  * The cost for rods depends on the level of the rod. The prices
4034  * for recharging wands and staves are dependent on the cost of
4035  * the base-item.
4036  */
4037 static void building_recharge_all(void)
4038 {
4039         int         i;
4040         int         lev;
4041         object_type *o_ptr;
4042         object_kind *k_ptr;
4043         int         price = 0;
4044         int         total_cost = 0;
4045
4046
4047         /* Display some info */
4048         msg_flag = FALSE;
4049         clear_bldg(4, 18);
4050 #ifdef JP
4051         prt("  ºÆ½¼Å¶¤ÎÈñÍѤϥ¢¥¤¥Æ¥à¤Î¼ïÎà¤Ë¤è¤ê¤Þ¤¹¡£", 6, 0);
4052 #else
4053         prt("  The prices of recharge depend on the type.", 6, 0);
4054 #endif
4055
4056         /* Calculate cost */
4057         for ( i = 0; i < INVEN_PACK; i++)
4058         {
4059                 o_ptr = &inventory[i];
4060                                 
4061                 /* skip non magic device */
4062                 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
4063
4064                 /* need identified */
4065                 if (!object_known_p(o_ptr)) total_cost += 50;
4066
4067                 /* Extract the object "level" */
4068                 lev = get_object_level(o_ptr);
4069
4070                 k_ptr = &k_info[o_ptr->k_idx];
4071
4072                 switch (o_ptr->tval)
4073                 {
4074                 case TV_ROD:
4075                         price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
4076                         break;
4077
4078                 case TV_STAFF:
4079                         /* Price per charge ( = double the price paid by shopkeepers for the charge) */
4080                         price = (get_object_cost(o_ptr) / 10) * o_ptr->number;
4081
4082                         /* Pay at least 10 gold per charge */
4083                         price = MAX(10, price);
4084
4085                         /* Fully charge */
4086                         price = (k_ptr->pval - o_ptr->pval) * price;
4087                         break;
4088
4089                 case TV_WAND:
4090                         /* Price per charge ( = double the price paid by shopkeepers for the charge) */
4091                         price = (get_object_cost(o_ptr) / 10);
4092
4093                         /* Pay at least 10 gold per charge */
4094                         price = MAX(10, price);
4095
4096                         /* Fully charge */
4097                         price = (o_ptr->number * k_ptr->pval - o_ptr->pval) * price;
4098                         break;
4099                 }
4100
4101                 /* if price <= 0 then item have enough charge */
4102                 if (price > 0) total_cost += price;
4103         }
4104
4105         if (!total_cost)
4106         {
4107 #ifdef JP
4108                 msg_print("½¼Å¶¤¹¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó¡£");
4109 #else
4110                 msg_print("No need to recharge.");
4111 #endif
4112
4113                 msg_print(NULL);
4114                 return;
4115         }
4116
4117         /* Check if the player has enough money */
4118         if (p_ptr->au < total_cost)
4119         {
4120 #ifdef JP
4121                 msg_format("¤¹¤Ù¤Æ¤Î¥¢¥¤¥Æ¥à¤òºÆ½¼Å¶¤¹¤ë¤Ë¤Ï¡ð%d É¬ÍפǤ¹¡ª", total_cost );
4122 #else
4123                 msg_format("You need %d gold to recharge all items!",total_cost);
4124 #endif
4125
4126                 msg_print(NULL);
4127                 return;
4128         }
4129
4130 #ifdef JP
4131         if (!get_check(format("¤¹¤Ù¤Æ¤Î¥¢¥¤¥Æ¥à¤ò ¡ð%d ¤ÇºÆ½¼Å¶¤·¤Þ¤¹¤«¡©",  total_cost))) return;
4132 #else
4133         if (!get_check(format("Recharge all items for %d gold? ", total_cost))) return;
4134 #endif
4135
4136         for (i = 0; i < INVEN_PACK; i++)
4137         {
4138                 o_ptr = &inventory[i];
4139                 k_ptr = &k_info[o_ptr->k_idx];
4140
4141                 /* skip non magic device */
4142                 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
4143
4144                 /* Identify it */
4145                 if (!object_known_p(o_ptr))
4146                 {
4147                         identify_item(o_ptr);
4148
4149                         /* Auto-inscription */
4150                         auto_inscribe_item(i, is_autopick(o_ptr));
4151                 }
4152
4153                 /* Recharge */
4154                 switch (o_ptr->tval)
4155                 {
4156                 case TV_ROD:
4157                         o_ptr->timeout = 0;
4158                         break;
4159                 case TV_STAFF:
4160                         if (o_ptr->pval < k_ptr->pval) o_ptr->pval = k_ptr->pval;
4161                         /* We no longer think the item is empty */
4162                         o_ptr->ident &= ~(IDENT_EMPTY);
4163                         break;
4164                 case TV_WAND:
4165                         if (o_ptr->pval < o_ptr->number * k_ptr->pval)
4166                                 o_ptr->pval = o_ptr->number * k_ptr->pval;
4167                         /* We no longer think the item is empty */
4168                         o_ptr->ident &= ~(IDENT_EMPTY);
4169                         break;
4170                 }
4171         }
4172
4173         /* Give feedback */
4174 #ifdef JP
4175         msg_format("¡ð%d ¤ÇºÆ½¼Å¶¤·¤Þ¤·¤¿¡£", total_cost);
4176 #else
4177         msg_format("You pay %d gold.", total_cost);
4178 #endif
4179
4180         msg_print(NULL);
4181
4182         /* Combine / Reorder the pack (later) */
4183         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
4184
4185         /* Window stuff */
4186         p_ptr->window |= (PW_INVEN);
4187
4188         /* Pay the price */
4189         p_ptr->au -= total_cost;
4190
4191         /* Finished */
4192         return;
4193 }
4194
4195
4196 bool tele_town(void)
4197 {
4198         int i, x, y;
4199         int num = 0;
4200
4201         if (dun_level)
4202         {
4203 #ifdef JP
4204                 msg_print("¤³¤ÎËâË¡¤ÏÃϾå¤Ç¤·¤«»È¤¨¤Ê¤¤¡ª");
4205 #else
4206                 msg_print("This spell can only be used on the surface!");
4207 #endif
4208                 return FALSE;
4209         }
4210
4211         if (p_ptr->inside_arena || p_ptr->inside_battle)
4212         {
4213 #ifdef JP
4214                 msg_print("¤³¤ÎËâË¡¤Ï³°¤Ç¤·¤«»È¤¨¤Ê¤¤¡ª");
4215 #else
4216                 msg_print("This spell can only be used outside!");
4217 #endif
4218                 return FALSE;
4219         }
4220
4221         screen_save();
4222         clear_bldg(4, 10);
4223
4224         for (i=1;i<max_towns;i++)
4225         {
4226                 char buf[80];
4227
4228                 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i-1)))) continue;
4229
4230                 sprintf(buf,"%c) %-20s", I2A(i-1), town[i].name);
4231                 prt(buf, 5+i, 5);
4232                 num++;
4233         }
4234
4235         if (!num)
4236         {
4237 #ifdef JP
4238                 msg_print("¤Þ¤À¹Ô¤±¤ë¤È¤³¤í¤¬¤Ê¤¤¡£");
4239 #else
4240                 msg_print("You have not yet visited any town.");
4241 #endif
4242
4243                 msg_print(NULL);
4244                 screen_load();
4245                 return FALSE;
4246         }
4247
4248 #ifdef JP
4249         prt("¤É¤³¤Ë¹Ô¤­¤Þ¤¹¤«:", 0, 0);
4250 #else
4251         prt("Which town you go: ", 0, 0);
4252 #endif
4253         while(1)
4254         {
4255                 i = inkey();
4256
4257                 if (i == ESCAPE)
4258                 {
4259                         screen_load();
4260                         return FALSE;
4261                 }
4262                 else if ((i < 'a') || (i > ('a'+max_towns-2))) continue;
4263                 else if (((i-'a'+1) == p_ptr->town_num) || ((i-'a'+1) == NO_TOWN) || ((i-'a'+1) == SECRET_TOWN) || !(p_ptr->visit & (1L << (i-'a')))) continue;
4264                 break;
4265         }
4266
4267         for (y = 0; y < max_wild_y; y++)
4268         {
4269                 for (x = 0; x < max_wild_x; x++)
4270                 {
4271                         if(wilderness[y][x].town == (i-'a'+1))
4272                         {
4273                                 p_ptr->wilderness_y = y;
4274                                 p_ptr->wilderness_x = x;
4275                         }
4276                 }
4277         }
4278         p_ptr->leftbldg = TRUE;
4279         p_ptr->leaving = TRUE;
4280         leave_bldg = TRUE;
4281         p_ptr->teleport_town = TRUE;
4282         screen_load();
4283         return TRUE;
4284 }
4285
4286
4287 /*
4288  *  research_mon
4289  *  -KMW-
4290  */
4291 static bool research_mon(void)
4292 {
4293         int i, n, r_idx;
4294         char sym, query;
4295         char buf[128];
4296
4297         bool notpicked;
4298
4299         bool recall = FALSE;
4300
4301         u16b why = 0;
4302
4303         u16b    *who;
4304
4305         /* XTRA HACK WHATSEARCH */
4306         bool    all = FALSE;
4307         bool    uniq = FALSE;
4308         bool    norm = FALSE;
4309         char temp[80] = "";
4310
4311         /* XTRA HACK REMEMBER_IDX */
4312         static int old_sym = '\0';
4313         static int old_i = 0;
4314
4315
4316         /* Save the screen */
4317         screen_save();
4318
4319         /* Get a character, or abort */
4320 #ifdef JP
4321 if (!get_com("¥â¥ó¥¹¥¿¡¼¤Îʸ»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^M̾Á°):", &sym, FALSE)) 
4322 #else
4323         if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE))
4324 #endif
4325
4326         {
4327                 /* Restore */
4328                 screen_load();
4329
4330                 return (FALSE);
4331         }
4332
4333         /* Find that character info, and describe it */
4334         for (i = 0; ident_info[i]; ++i)
4335         {
4336                 if (sym == ident_info[i][0]) break;
4337         }
4338
4339                 /* XTRA HACK WHATSEARCH */
4340         if (sym == KTRL('A'))
4341         {
4342                 all = TRUE;
4343 #ifdef JP
4344                 strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
4345 #else
4346                 strcpy(buf, "Full monster list.");
4347 #endif
4348         }
4349         else if (sym == KTRL('U'))
4350         {
4351                 all = uniq = TRUE;
4352 #ifdef JP
4353                 strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
4354 #else
4355                 strcpy(buf, "Unique monster list.");
4356 #endif
4357         }
4358         else if (sym == KTRL('N'))
4359         {
4360                 all = norm = TRUE;
4361 #ifdef JP
4362                 strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
4363 #else
4364                 strcpy(buf, "Non-unique monster list.");
4365 #endif
4366         }
4367         else if (sym == KTRL('M'))
4368         {
4369                 all = TRUE;
4370 #ifdef JP
4371                 if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
4372 #else
4373                 if (!get_string("Enter name:",temp, 70))
4374 #endif
4375                 {
4376                         temp[0]=0;
4377
4378                         /* Restore */
4379                         screen_load();
4380
4381                         return FALSE;
4382                 }
4383 #ifdef JP
4384                 sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
4385 #else
4386                 sprintf(buf, "Monsters with a name \"%s\"",temp);
4387 #endif
4388         }
4389         else if (ident_info[i])
4390         {
4391                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
4392         }
4393         else
4394         {
4395 #ifdef JP
4396 sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
4397 #else
4398                 sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
4399 #endif
4400
4401         }
4402
4403         /* Display the result */
4404         prt(buf, 16, 10);
4405
4406
4407         /* Allocate the "who" array */
4408         C_MAKE(who, max_r_idx, u16b);
4409
4410         /* Collect matching monsters */
4411         for (n = 0, i = 1; i < max_r_idx; i++)
4412         {
4413                 monster_race *r_ptr = &r_info[i];
4414
4415                 /* Empty monster */
4416                 if (!r_ptr->name) continue;
4417
4418                 /* XTRA HACK WHATSEARCH */
4419                 /* Require non-unique monsters if needed */
4420                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
4421
4422                 /* Require unique monsters if needed */
4423                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
4424
4425                 /* Ì¾Á°¸¡º÷ */
4426                 if (temp[0])
4427                 {
4428                         int xx;
4429                         char temp2[80];
4430
4431                         for (xx = 0; temp[xx] && xx < 80; xx++)
4432                         {
4433 #ifdef JP
4434                                 if (iskanji(temp[xx]))
4435                                 {
4436                                         xx++;
4437                                         continue;
4438                                 }
4439 #endif
4440                                 if (isupper(temp[xx])) temp[xx] = tolower(temp[xx]);
4441                         }
4442   
4443 #ifdef JP
4444                         strcpy(temp2, r_name + r_ptr->E_name);
4445 #else
4446                         strcpy(temp2, r_name + r_ptr->name);
4447 #endif
4448                         for (xx = 0; temp2[xx] && xx < 80; xx++)
4449                                 if (isupper(temp2[xx])) temp2[xx] = tolower(temp2[xx]);
4450
4451 #ifdef JP
4452                         if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp))
4453 #else
4454                         if (strstr(temp2, temp))
4455 #endif
4456                                 who[n++] = i;
4457                 }
4458                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
4459         }
4460
4461         /* Nothing to recall */
4462         if (!n)
4463         {
4464                 /* Free the "who" array */
4465                 C_KILL(who, max_r_idx, u16b);
4466
4467                 /* Restore */
4468                 screen_load();
4469
4470                 return (FALSE);
4471         }
4472
4473         /* Sort by level */
4474         why = 2;
4475         query = 'y';
4476
4477         /* Sort if needed */
4478         if (why)
4479         {
4480                 /* Select the sort method */
4481                 ang_sort_comp = ang_sort_comp_hook;
4482                 ang_sort_swap = ang_sort_swap_hook;
4483
4484                 /* Sort the array */
4485                 ang_sort(who, &why, n);
4486         }
4487
4488
4489         /* Start at the end */
4490         /* XTRA HACK REMEMBER_IDX */
4491         if (old_sym == sym && old_i < n) i = old_i;
4492         else i = n - 1;
4493
4494         notpicked = TRUE;
4495
4496         /* Scan the monster memory */
4497         while (notpicked)
4498         {
4499                 /* Extract a race */
4500                 r_idx = who[i];
4501
4502                 /* Hack -- Begin the prompt */
4503                 roff_top(r_idx);
4504
4505                 /* Hack -- Complete the prompt */
4506 #ifdef JP
4507 Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ' '¤Ç³¹Ô, ESC]");
4508 #else
4509                 Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC, space to continue]");
4510 #endif
4511
4512
4513                 /* Interact */
4514                 while (1)
4515                 {
4516                         /* Recall */
4517                         if (recall)
4518                         {
4519                                 /*** Recall on screen ***/
4520
4521                                 /* Get maximal info about this monster */
4522                                 lore_do_probe(r_idx);
4523
4524                                 /* Save this monster ID */
4525                                 monster_race_track(r_idx);
4526
4527                                 /* Hack -- Handle stuff */
4528                                 handle_stuff();
4529
4530                                 /* know every thing mode */
4531                                 screen_roff(r_idx, 0x01);
4532                                 notpicked = FALSE;
4533
4534                                 /* XTRA HACK REMEMBER_IDX */
4535                                 old_sym = sym;
4536                                 old_i = i;
4537                         }
4538
4539                         /* Command */
4540                         query = inkey();
4541
4542                         /* Normal commands */
4543                         if (query != 'r') break;
4544
4545                         /* Toggle recall */
4546                         recall = !recall;
4547                 }
4548
4549                 /* Stop scanning */
4550                 if (query == ESCAPE) break;
4551
4552                 /* Move to "prev" monster */
4553                 if (query == '-')
4554                 {
4555                         if (++i == n)
4556                         {
4557                                 i = 0;
4558                                 if (!expand_list) break;
4559                         }
4560                 }
4561
4562                 /* Move to "next" monster */
4563                 else
4564                 {
4565                         if (i-- == 0)
4566                         {
4567                                 i = n - 1;
4568                                 if (!expand_list) break;
4569                         }
4570                 }
4571         }
4572
4573
4574         /* Re-display the identity */
4575         /* prt(buf, 5, 5);*/
4576
4577         /* Free the "who" array */
4578         C_KILL(who, max_r_idx, u16b);
4579
4580         /* Restore */
4581         screen_load();
4582
4583         return (!notpicked);
4584 }
4585
4586
4587 /*
4588  * Execute a building command
4589  */
4590 static void bldg_process_command(building_type *bldg, int i)
4591 {
4592         int bact = bldg->actions[i];
4593         int bcost;
4594         bool paid = FALSE;
4595         int amt;
4596
4597         /* Flush messages XXX XXX XXX */
4598         msg_flag = FALSE;
4599         msg_print(NULL);
4600
4601         if (is_owner(bldg))
4602                 bcost = bldg->member_costs[i];
4603         else
4604                 bcost = bldg->other_costs[i];
4605
4606         /* action restrictions */
4607         if (((bldg->action_restr[i] == 1) && !is_member(bldg)) ||
4608             ((bldg->action_restr[i] == 2) && !is_owner(bldg)))
4609         {
4610 #ifdef JP
4611 msg_print("¤½¤ì¤òÁªÂò¤¹¤ë¸¢Íø¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
4612 #else
4613                 msg_print("You have no right to choose that!");
4614 #endif
4615                 return;
4616         }
4617
4618         /* check gold (HACK - Recharge uses variable costs) */
4619         if ((bact != BACT_RECHARGE) &&
4620             (((bldg->member_costs[i] > p_ptr->au) && is_owner(bldg)) ||
4621              ((bldg->other_costs[i] > p_ptr->au) && !is_owner(bldg))))
4622         {
4623 #ifdef JP
4624 msg_print("¤ª¶â¤¬Â­¤ê¤Þ¤»¤ó¡ª");
4625 #else
4626                 msg_print("You do not have the gold!");
4627 #endif
4628                 return;
4629         }
4630
4631         switch (bact)
4632         {
4633         case BACT_NOTHING:
4634                 /* Do nothing */
4635                 break;
4636         case BACT_RESEARCH_ITEM:
4637                 paid = identify_fully(FALSE);
4638                 break;
4639         case BACT_TOWN_HISTORY:
4640                 town_history();
4641                 break;
4642         case BACT_RACE_LEGENDS:
4643                 race_legends();
4644                 break;
4645         case BACT_QUEST:
4646                 castle_quest();
4647                 break;
4648         case BACT_KING_LEGENDS:
4649         case BACT_ARENA_LEGENDS:
4650         case BACT_LEGENDS:
4651                 show_highclass();
4652                 break;
4653         case BACT_POSTER:
4654         case BACT_ARENA_RULES:
4655         case BACT_ARENA:
4656                 arena_comm(bact);
4657                 break;
4658         case BACT_IN_BETWEEN:
4659         case BACT_CRAPS:
4660         case BACT_SPIN_WHEEL:
4661         case BACT_DICE_SLOTS:
4662         case BACT_GAMBLE_RULES:
4663         case BACT_POKER:
4664                 gamble_comm(bact);
4665                 break;
4666         case BACT_REST:
4667         case BACT_RUMORS:
4668         case BACT_FOOD:
4669                 paid = inn_comm(bact);
4670                 break;
4671         case BACT_RESEARCH_MONSTER:
4672                 paid = research_mon();
4673                 break;
4674         case BACT_COMPARE_WEAPONS:
4675                 paid = compare_weapons();
4676                 break;
4677         case BACT_ENCHANT_WEAPON:
4678                 item_tester_hook = item_tester_hook_melee_weapon;
4679                 enchant_item(bcost, 1, 1, 0);
4680                 break;
4681         case BACT_ENCHANT_ARMOR:
4682                 item_tester_hook = item_tester_hook_armour;
4683                 enchant_item(bcost, 0, 0, 1);
4684                 break;
4685         case BACT_RECHARGE:
4686                 building_recharge();
4687                 break;
4688         case BACT_RECHARGE_ALL:
4689                 building_recharge_all();
4690                 break;
4691         case BACT_IDENTS: /* needs work */
4692 #ifdef JP
4693                 if (!get_check("»ý¤Áʪ¤òÁ´¤Æ´ÕÄꤷ¤Æ¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
4694                 identify_pack();
4695                 msg_print(" »ý¤ÁʪÁ´¤Æ¤¬´ÕÄꤵ¤ì¤Þ¤·¤¿¡£");
4696 #else
4697                 if (!get_check("Do you pay for identify all your possession? ")) break;
4698                 identify_pack();
4699                 msg_print("Your possessions have been identified.");
4700 #endif
4701
4702                 paid = TRUE;
4703                 break;
4704         case BACT_IDENT_ONE: /* needs work */
4705                 paid = ident_spell(FALSE);
4706                 break;
4707         case BACT_LEARN:
4708                 do_cmd_study();
4709                 break;
4710         case BACT_HEALING: /* needs work */
4711                 hp_player(200);
4712                 set_poisoned(0);
4713                 set_blind(0);
4714                 set_confused(0);
4715                 set_cut(0);
4716                 set_stun(0);
4717                 paid = TRUE;
4718                 break;
4719         case BACT_RESTORE: /* needs work */
4720                 if (do_res_stat(A_STR)) paid = TRUE;
4721                 if (do_res_stat(A_INT)) paid = TRUE;
4722                 if (do_res_stat(A_WIS)) paid = TRUE;
4723                 if (do_res_stat(A_DEX)) paid = TRUE;
4724                 if (do_res_stat(A_CON)) paid = TRUE;
4725                 if (do_res_stat(A_CHR)) paid = TRUE;
4726                 break;
4727         case BACT_GOLD: /* set timed reward flag */
4728                 if (!p_ptr->rewards[BACT_GOLD])
4729                 {
4730                         share_gold();
4731                         p_ptr->rewards[BACT_GOLD] = TRUE;
4732                 }
4733                 else
4734                 {
4735 #ifdef JP
4736                         msg_print("º£Æü¤Îʬ¤±Á°¤Ï¤¹¤Ç¤Ë»Ùʧ¤Ã¤¿¤¾¡ª");
4737 #else
4738                         msg_print("You just had your daily allowance!");
4739 #endif
4740                 }
4741                 break;
4742         case BACT_ENCHANT_ARROWS:
4743                 item_tester_hook = item_tester_hook_ammo;
4744                 enchant_item(bcost, 1, 1, 0);
4745                 break;
4746         case BACT_ENCHANT_BOW:
4747                 item_tester_tval = TV_BOW;
4748                 enchant_item(bcost, 1, 1, 0);
4749                 break;
4750         case BACT_RECALL:
4751                 if (recall_player(1)) paid = TRUE;
4752                 break;
4753         case BACT_TELEPORT_LEVEL:
4754         {
4755                 int select_dungeon;
4756                 int max_depth;
4757
4758                 clear_bldg(4, 20);
4759 #ifdef JP
4760                 select_dungeon = choose_dungeon("¤Ë¥Æ¥ì¥Ý¡¼¥È", 4, 0);
4761 #else
4762                 select_dungeon = choose_dungeon("teleport", 4, 0);
4763 #endif
4764                 show_building(bldg);
4765                 if (!select_dungeon) return;
4766
4767                 max_depth = d_info[select_dungeon].maxdepth;
4768
4769                 /* Limit depth in Angband */
4770                 if (select_dungeon == DUNGEON_ANGBAND)
4771                 {
4772                         if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
4773                         else if(quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
4774                 }
4775
4776 #ifdef JP
4777                 amt = get_quantity(format("%s¤Î²¿³¬¤Ë¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©", d_name + d_info[select_dungeon].name), max_depth);
4778 #else
4779                 amt = get_quantity(format("Teleport to which level of %s? ", d_name + d_info[select_dungeon].name), max_depth);
4780 #endif
4781
4782                 if (amt > 0)
4783                 {
4784                         p_ptr->word_recall = 1;
4785                         p_ptr->recall_dungeon = select_dungeon;
4786                         max_dlv[p_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
4787                         if (record_maxdeapth)
4788 #ifdef JP
4789                                 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥È¥é¥ó¥×¥¿¥ï¡¼¤Ç");
4790 #else
4791                         do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "at Trump Tower");
4792 #endif
4793 #ifdef JP
4794                         msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤­¤¿...");
4795 #else
4796                         msg_print("The air about you becomes charged...");
4797 #endif
4798
4799                         paid = TRUE;
4800                         p_ptr->redraw |= (PR_STATUS);
4801                 }
4802                 break;
4803         }
4804         case BACT_LOSE_MUTATION:
4805                 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4806                 {
4807                         while(!lose_mutation(0));
4808                         paid = TRUE;
4809                 }
4810                 else
4811                 {
4812 #ifdef JP
4813                         msg_print("¼£¤¹¤Ù¤­ÆÍÁ³ÊÑ°Û¤¬Ìµ¤¤¡£");
4814 #else
4815                         msg_print("You have no mutations.");
4816 #endif
4817                         msg_print(NULL);
4818                 }
4819                 break;
4820         case BACT_BATTLE:
4821                 kakutoujou();
4822                 break;
4823         case BACT_TSUCHINOKO:
4824                 tsuchinoko();
4825                 break;
4826         case BACT_KUBI:
4827                 shoukinkubi();
4828                 break;
4829         case BACT_TARGET:
4830                 today_target();
4831                 break;
4832         case BACT_KANKIN:
4833                 kankin();
4834                 break;
4835         case BACT_HEIKOUKA:
4836 #ifdef JP
4837                 msg_print("Ê¿¹Õ²½¤Îµ·¼°¤ò¹Ô¤Ê¤Ã¤¿¡£");
4838 #else
4839                 msg_print("You received an equalization ritual.");
4840 #endif
4841                 set_virtue(V_COMPASSION, 0);
4842                 set_virtue(V_HONOUR, 0);
4843                 set_virtue(V_JUSTICE, 0);
4844                 set_virtue(V_SACRIFICE, 0);
4845                 set_virtue(V_KNOWLEDGE, 0);
4846                 set_virtue(V_FAITH, 0);
4847                 set_virtue(V_ENLIGHTEN, 0);
4848                 set_virtue(V_ENCHANT, 0);
4849                 set_virtue(V_CHANCE, 0);
4850                 set_virtue(V_NATURE, 0);
4851                 set_virtue(V_HARMONY, 0);
4852                 set_virtue(V_VITALITY, 0);
4853                 set_virtue(V_UNLIFE, 0);
4854                 set_virtue(V_PATIENCE, 0);
4855                 set_virtue(V_TEMPERANCE, 0);
4856                 set_virtue(V_DILIGENCE, 0);
4857                 set_virtue(V_VALOUR, 0);
4858                 set_virtue(V_INDIVIDUALISM, 0);
4859                 get_virtues();
4860                 paid = TRUE;
4861                 break;
4862         case BACT_TELE_TOWN:
4863                 paid = tele_town();
4864                 break;
4865         case BACT_EVAL_AC:
4866                 paid = eval_ac(p_ptr->dis_ac + p_ptr->dis_to_a);
4867                 break;
4868         }
4869
4870         if (paid)
4871         {
4872                 p_ptr->au -= bcost;
4873         }
4874 }
4875
4876
4877 /*
4878  * Enter quest level
4879  */
4880 void do_cmd_quest(void)
4881 {
4882         energy_use = 100;
4883
4884         if (cave[py][px].feat != FEAT_QUEST_ENTER)
4885         {
4886 #ifdef JP
4887 msg_print("¤³¤³¤Ë¤Ï¥¯¥¨¥¹¥È¤ÎÆþ¸ý¤Ï¤Ê¤¤¡£");
4888 #else
4889                 msg_print("You see no quest level here.");
4890 #endif
4891
4892                 return;
4893         }
4894         else
4895         {
4896 #ifdef JP
4897                 msg_print("¤³¤³¤Ë¤Ï¥¯¥¨¥¹¥È¤Ø¤ÎÆþ¸ý¤¬¤¢¤ê¤Þ¤¹¡£");
4898                 if (!get_check("¥¯¥¨¥¹¥È¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
4899                 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4900                         msg_print("¡Ø¤È¤Ë¤«¤¯Æþ¤Ã¤Æ¤ß¤è¤¦¤¼¤§¡£¡Ù");
4901 #else
4902                 msg_print("There is an entry of a quest.");
4903                 if (!get_check("Do you enter? ")) return;
4904 #endif
4905
4906                 /* Player enters a new quest */
4907                 p_ptr->oldpy = 0;
4908                 p_ptr->oldpx = 0;
4909
4910                 leave_quest_check();
4911
4912                 p_ptr->inside_quest = cave[py][px].special;
4913                 if(quest[leaving_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
4914                 p_ptr->leftbldg = TRUE;
4915                 p_ptr->leaving = TRUE;
4916         }
4917 }
4918
4919
4920 /*
4921  * Do building commands
4922  */
4923 void do_cmd_bldg(void)
4924 {
4925         int             i, which;
4926         char            command;
4927         bool            validcmd;
4928         building_type   *bldg;
4929
4930
4931         energy_use = 100;
4932
4933         if (!((cave[py][px].feat >= FEAT_BLDG_HEAD) &&
4934                   (cave[py][px].feat <= FEAT_BLDG_TAIL)))
4935         {
4936 #ifdef JP
4937 msg_print("¤³¤³¤Ë¤Ï·úʪ¤Ï¤Ê¤¤¡£");
4938 #else
4939                 msg_print("You see no building here.");
4940 #endif
4941
4942                 return;
4943         }
4944
4945         which = (cave[py][px].feat - FEAT_BLDG_HEAD);
4946
4947         bldg = &building[which];
4948
4949         /* Don't re-init the wilderness */
4950         reinit_wilderness = FALSE;
4951
4952         if ((which == 2) && (p_ptr->arena_number < 0))
4953         {
4954 #ifdef JP
4955 msg_print("¡ÖÇÔ¼Ô¤ËÍѤϤʤ¤¡£¡×");
4956 #else
4957                 msg_print("'There's no place here for a LOSER like you!'");
4958 #endif
4959                 return;
4960         }
4961         else if ((which == 2) && p_ptr->inside_arena && !p_ptr->exit_bldg)
4962         {
4963 #ifdef JP
4964 prt("¥²¡¼¥È¤ÏÊĤޤäƤ¤¤ë¡£¥â¥ó¥¹¥¿¡¼¤¬¤¢¤Ê¤¿¤òÂԤäƤ¤¤ë¡ª",0,0);
4965 #else
4966                 prt("The gates are closed.  The monster awaits!", 0, 0);
4967 #endif
4968
4969                 return;
4970         }
4971         else if ((which == 2) && p_ptr->inside_arena)
4972         {
4973                 /* Restore the surface floor to preserve pets */
4974                 prepare_change_floor_mode(CFM_SAVE_SURFACE | CFM_NO_RETURN);
4975
4976                 p_ptr->inside_arena = FALSE;
4977                 p_ptr->leaving = TRUE;
4978
4979                 /* Re-enter the arena */
4980                 command_new = SPECIAL_KEY_BUILDING;
4981
4982                 return;
4983         }
4984         else if (p_ptr->inside_battle)
4985         {
4986                 /* Restore the surface floor to preserve pets */
4987                 prepare_change_floor_mode(CFM_SAVE_SURFACE | CFM_NO_RETURN);
4988
4989                 p_ptr->leaving = TRUE;
4990                 p_ptr->inside_battle = FALSE;
4991
4992                 /* Re-enter the monster arena */
4993                 command_new = SPECIAL_KEY_BUILDING;
4994
4995                 return;
4996         }
4997         else
4998         {
4999                 p_ptr->oldpy = py;
5000                 p_ptr->oldpx = px;
5001         }
5002
5003         /* Forget the lite */
5004         forget_lite();
5005
5006         /* Forget the view */
5007         forget_view();
5008
5009         /* Hack -- Increase "icky" depth */
5010         character_icky++;
5011
5012         command_arg = 0;
5013         command_rep = 0;
5014         command_new = 0;
5015
5016         show_building(bldg);
5017         leave_bldg = FALSE;
5018
5019         while (!leave_bldg)
5020         {
5021                 validcmd = FALSE;
5022                 prt("", 1, 0);
5023
5024                 building_prt_gold();
5025
5026                 command = inkey();
5027
5028                 if (command == ESCAPE)
5029                 {
5030                         leave_bldg = TRUE;
5031                         p_ptr->inside_arena = FALSE;
5032                         p_ptr->inside_battle = FALSE;
5033                         break;
5034                 }
5035
5036                 for (i = 0; i < 8; i++)
5037                 {
5038                         if (bldg->letters[i])
5039                         {
5040                                 if (bldg->letters[i] == command)
5041                                 {
5042                                         validcmd = TRUE;
5043                                         break;
5044                                 }
5045                         }
5046                 }
5047
5048                 if (validcmd)
5049                         bldg_process_command(bldg, i);
5050
5051                 /* Notice stuff */
5052                 notice_stuff();
5053
5054                 /* Handle stuff */
5055                 handle_stuff();
5056         }
5057
5058         /* Flush messages XXX XXX XXX */
5059         msg_flag = FALSE;
5060         msg_print(NULL);
5061
5062         /* Reinit wilderness to activate quests ... */
5063         if (reinit_wilderness)
5064                 p_ptr->leaving = TRUE;
5065
5066         /* Hack -- Decrease "icky" depth */
5067         character_icky--;
5068
5069         /* Clear the screen */
5070         Term_clear();
5071
5072         /* Update the visuals */
5073         p_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
5074
5075         /* Redraw entire screen */
5076         p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
5077
5078         /* Window stuff */
5079         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5080 }
5081
5082
5083 /* Array of places to find an inscription */
5084 static cptr find_quest[] =
5085 {
5086 #ifdef JP
5087 "¾²¤Ë¥á¥Ã¥»¡¼¥¸¤¬¹ï¤Þ¤ì¤Æ¤¤¤ë:",
5088 #else
5089         "You find the following inscription in the floor",
5090 #endif
5091
5092 #ifdef JP
5093 "Êɤ˥á¥Ã¥»¡¼¥¸¤¬¹ï¤Þ¤ì¤Æ¤¤¤ë:",
5094 #else
5095         "You see a message inscribed in the wall",
5096 #endif
5097
5098 #ifdef JP
5099 "¥á¥Ã¥»¡¼¥¸¤ò¸«¤Ä¤±¤¿:",
5100 #else
5101         "There is a sign saying",
5102 #endif
5103
5104 #ifdef JP
5105 "²¿¤«¤¬³¬Ãʤξå¤Ë½ñ¤¤¤Æ¤¢¤ë:",
5106 #else
5107         "Something is written on the staircase",
5108 #endif
5109
5110 #ifdef JP
5111 "´¬Êª¤ò¸«¤Ä¤±¤¿¡£¥á¥Ã¥»¡¼¥¸¤¬½ñ¤¤¤Æ¤¢¤ë:",
5112 #else
5113         "You find a scroll with the following message",
5114 #endif
5115
5116 };
5117
5118
5119 /*
5120  * Discover quest
5121  */
5122 void quest_discovery(int q_idx)
5123 {
5124         quest_type      *q_ptr = &quest[q_idx];
5125         monster_race    *r_ptr = &r_info[q_ptr->r_idx];
5126         int             q_num = q_ptr->max_num;
5127         char            name[80];
5128
5129         /* No quest index */
5130         if (!q_idx) return;
5131
5132         strcpy(name, (r_name + r_ptr->name));
5133
5134         msg_print(find_quest[rand_range(0, 4)]);
5135         msg_print(NULL);
5136
5137         if (q_num == 1)
5138         {
5139                 /* Unique */
5140
5141                 /* Hack -- "unique" monsters must be "unique" */
5142                 if ((r_ptr->flags1 & RF1_UNIQUE) &&
5143                     (0 == r_ptr->max_num))
5144                 {
5145 #ifdef JP
5146                         msg_print("¤³¤Î³¬¤Ï°ÊÁ°¤Ï狼¤Ë¤è¤Ã¤Æ¼é¤é¤ì¤Æ¤¤¤¿¤è¤¦¤À¡Ä¡£");
5147 #else
5148                         msg_print("It seems that this level was protected by someone before...");
5149 #endif
5150                         /* The unique is already dead */
5151                         quest[q_idx].status = QUEST_STATUS_FINISHED;
5152                 }
5153                 else
5154                 {
5155 #ifdef JP
5156                         msg_format("Ãí°Õ¤»¤è¡ª¤³¤Î³¬¤Ï%s¤Ë¤è¤Ã¤Æ¼é¤é¤ì¤Æ¤¤¤ë¡ª", name);
5157 #else
5158                         msg_format("Beware, this level is protected by %s!", name);
5159 #endif
5160                 }
5161         }
5162         else
5163         {
5164                 /* Normal monsters */
5165 #ifdef JP
5166 msg_format("Ãí°Õ¤·¤í¡ª¤³¤Î³¬¤Ï%dÂΤÎ%s¤Ë¤è¤Ã¤Æ¼é¤é¤ì¤Æ¤¤¤ë¡ª", q_num, name);
5167 #else
5168                 plural_aux(name);
5169                 msg_format("Be warned, this level is guarded by %d %s!", q_num, name);
5170 #endif
5171
5172         }
5173 }
5174
5175
5176 /*
5177  * Hack -- Check if a level is a "quest" level
5178  */
5179 int quest_number(int level)
5180 {
5181         int i;
5182
5183         /* Check quests */
5184         if (p_ptr->inside_quest)
5185                 return (p_ptr->inside_quest);
5186
5187         for (i = 0; i < max_quests; i++)
5188         {
5189                 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
5190
5191                 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
5192                         !(quest[i].flags & QUEST_FLAG_PRESET) &&
5193                     (quest[i].level == level) &&
5194                     (quest[i].dungeon == dungeon_type))
5195                         return (i);
5196         }
5197
5198         /* Check for random quest */
5199         return (random_quest_number(level));
5200 }
5201
5202
5203 /*
5204  * Return the index of the random quest on this level
5205  * (or zero)
5206  */
5207 int random_quest_number(int level)
5208 {
5209         int i;
5210
5211         if (dungeon_type != DUNGEON_ANGBAND) return 0;
5212
5213         for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
5214         {
5215                 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
5216                     (quest[i].status == QUEST_STATUS_TAKEN) &&
5217                     (quest[i].level == level) &&
5218                     (quest[i].dungeon == DUNGEON_ANGBAND))
5219                 {
5220                         return i;
5221                 }
5222         }
5223
5224         /* Nope */
5225         return 0;
5226 }