OSDN Git Service

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