OSDN Git Service

さらに続きを実装。
[hengband/hengband.git] / src / artifact.c
1 /* Purpose: Artifact code */
2
3 /*
4  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
5  *
6  * This software may be copied and distributed for educational, research, and
7  * not for profit purposes provided that this copyright and statement are
8  * included in all such copies.
9  */
10
11 #include "angband.h"
12
13
14 /* Chance of using syllables to form the name instead of the "template" files */
15 #define SINDARIN_NAME   10
16 #define TABLE_NAME      20
17 #define A_CURSED        13
18 #define WEIRD_LUCK      12
19 #define BIAS_LUCK       20
20 #define IM_LUCK         7
21
22 /*
23  * Bias luck needs to be higher than weird luck,
24  * since it is usually tested several times...
25  */
26 #define ACTIVATION_CHANCE 3
27
28
29 /*
30  * Use for biased artifact creation
31  */
32 static int artifact_bias;
33
34
35 /*
36  * Choose one random sustain
37  */
38 void one_sustain(object_type *o_ptr)
39 {
40         switch (randint0(6))
41         {
42                 case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
43                 case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
44                 case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
45                 case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
46                 case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
47                 case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
48         }
49 }
50
51
52 /*
53  * Choose one random high resistance
54  */
55 void one_high_resistance(object_type *o_ptr)
56 {
57         switch (randint0(12))
58         {
59                 case  0: add_flag(o_ptr->art_flags, TR_RES_POIS);   break;
60                 case  1: add_flag(o_ptr->art_flags, TR_RES_LITE);   break;
61                 case  2: add_flag(o_ptr->art_flags, TR_RES_DARK);   break;
62                 case  3: add_flag(o_ptr->art_flags, TR_RES_SHARDS); break;
63                 case  4: add_flag(o_ptr->art_flags, TR_RES_BLIND);  break;
64                 case  5: add_flag(o_ptr->art_flags, TR_RES_CONF);   break;
65                 case  6: add_flag(o_ptr->art_flags, TR_RES_SOUND);  break;
66                 case  7: add_flag(o_ptr->art_flags, TR_RES_NETHER); break;
67                 case  8: add_flag(o_ptr->art_flags, TR_RES_NEXUS);  break;
68                 case  9: add_flag(o_ptr->art_flags, TR_RES_CHAOS);  break;
69                 case 10: add_flag(o_ptr->art_flags, TR_RES_DISEN);  break;
70                 case 11: add_flag(o_ptr->art_flags, TR_RES_FEAR);   break;
71         }
72 }
73
74
75 /*
76  * Choose one random high resistance ( except poison and disenchantment )
77  */
78 void one_lordly_high_resistance(object_type *o_ptr)
79 {
80         switch (randint0(10))
81         {
82                 case 0: add_flag(o_ptr->art_flags, TR_RES_LITE);   break;
83                 case 1: add_flag(o_ptr->art_flags, TR_RES_DARK);   break;
84                 case 2: add_flag(o_ptr->art_flags, TR_RES_SHARDS); break;
85                 case 3: add_flag(o_ptr->art_flags, TR_RES_BLIND);  break;
86                 case 4: add_flag(o_ptr->art_flags, TR_RES_CONF);   break;
87                 case 5: add_flag(o_ptr->art_flags, TR_RES_SOUND);  break;
88                 case 6: add_flag(o_ptr->art_flags, TR_RES_NETHER); break;
89                 case 7: add_flag(o_ptr->art_flags, TR_RES_NEXUS);  break;
90                 case 8: add_flag(o_ptr->art_flags, TR_RES_CHAOS);  break;
91                 case 9: add_flag(o_ptr->art_flags, TR_RES_FEAR);   break;
92         }
93 }
94
95
96 /*
97  * Choose one random element resistance
98  */
99 void one_ele_resistance(object_type *o_ptr)
100 {
101         switch (randint0(4))
102         {
103                 case  0: add_flag(o_ptr->art_flags, TR_RES_ACID); break;
104                 case  1: add_flag(o_ptr->art_flags, TR_RES_ELEC); break;
105                 case  2: add_flag(o_ptr->art_flags, TR_RES_COLD); break;
106                 case  3: add_flag(o_ptr->art_flags, TR_RES_FIRE); break;
107         }
108 }
109
110
111 /*
112  * Choose one random element or poison resistance
113  */
114 void one_dragon_ele_resistance(object_type *o_ptr)
115 {
116         if (one_in_(7))
117         {
118                 add_flag(o_ptr->art_flags, TR_RES_POIS);
119         }
120         else
121         {
122                 one_ele_resistance(o_ptr);
123         }
124 }
125
126
127 /*
128  * Choose one lower rank esp
129  */
130 void one_low_esp(object_type *o_ptr)
131 {
132         switch (randint1(10))
133         {
134         case 1:  add_flag(o_ptr->art_flags, TR_ESP_ANIMAL);   break;
135         case 2:  add_flag(o_ptr->art_flags, TR_ESP_UNDEAD);   break;
136         case 3:  add_flag(o_ptr->art_flags, TR_ESP_DEMON);   break;
137         case 4:  add_flag(o_ptr->art_flags, TR_ESP_ORC);   break;
138         case 5:  add_flag(o_ptr->art_flags, TR_ESP_TROLL);   break;
139         case 6:  add_flag(o_ptr->art_flags, TR_ESP_GIANT);   break;
140         case 7:  add_flag(o_ptr->art_flags, TR_ESP_DRAGON);   break;
141         case 8:  add_flag(o_ptr->art_flags, TR_ESP_HUMAN);   break;
142         case 9:  add_flag(o_ptr->art_flags, TR_ESP_GOOD);   break;
143         case 10: add_flag(o_ptr->art_flags, TR_ESP_UNIQUE);   break;
144         }
145 }
146
147
148
149 /*
150  * Choose one random resistance
151  */
152 void one_resistance(object_type *o_ptr)
153 {
154         if (one_in_(3))
155         {
156                 one_ele_resistance(o_ptr);
157         }
158         else
159         {
160                 one_high_resistance(o_ptr);
161         }
162 }
163
164
165 /*
166  * Choose one random ability
167  */
168 void one_ability(object_type *o_ptr)
169 {
170         switch (randint0(10))
171         {
172         case 0: add_flag(o_ptr->art_flags, TR_LEVITATION);     break;
173         case 1: add_flag(o_ptr->art_flags, TR_LITE);        break;
174         case 2: add_flag(o_ptr->art_flags, TR_SEE_INVIS);   break;
175         case 3: add_flag(o_ptr->art_flags, TR_WARNING);     break;
176         case 4: add_flag(o_ptr->art_flags, TR_SLOW_DIGEST); break;
177         case 5: add_flag(o_ptr->art_flags, TR_REGEN);       break;
178         case 6: add_flag(o_ptr->art_flags, TR_FREE_ACT);    break;
179         case 7: add_flag(o_ptr->art_flags, TR_HOLD_LIFE);   break;
180         case 8:
181         case 9:
182                 one_low_esp(o_ptr);
183                 break;
184         }
185 }
186
187
188 static void curse_artifact(object_type * o_ptr)
189 {
190         if (o_ptr->pval > 0) o_ptr->pval = 0 - (o_ptr->pval + randint1(4));
191         if (o_ptr->to_a > 0) o_ptr->to_a = 0 - (o_ptr->to_a + randint1(4));
192         if (o_ptr->to_h > 0) o_ptr->to_h = 0 - (o_ptr->to_h + randint1(4));
193         if (o_ptr->to_d > 0) o_ptr->to_d = 0 - (o_ptr->to_d + randint1(4));
194
195         o_ptr->curse_flags |= (TRC_HEAVY_CURSE | TRC_CURSED);
196         remove_flag(o_ptr->art_flags, TR_BLESSED);
197
198         if (one_in_(4)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
199         if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
200         if (one_in_(2)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
201         if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
202         if (one_in_(2)) add_flag(o_ptr->art_flags, TR_TELEPORT);
203         else if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
204
205         if ((p_ptr->pclass != CLASS_WARRIOR) && (p_ptr->pclass != CLASS_ARCHER) && (p_ptr->pclass != CLASS_CAVALRY) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH) && one_in_(3))
206                 add_flag(o_ptr->art_flags, TR_NO_MAGIC);
207 }
208
209
210 static void random_plus(object_type * o_ptr)
211 {
212         int this_type = (object_is_weapon_ammo(o_ptr) ? 23 : 19);
213
214         switch (artifact_bias)
215         {
216         case BIAS_WARRIOR:
217                 if (!(have_flag(o_ptr->art_flags, TR_STR)))
218                 {
219                         add_flag(o_ptr->art_flags, TR_STR);
220                         if (one_in_(2)) return;
221                 }
222
223                 if (!(have_flag(o_ptr->art_flags, TR_CON)))
224                 {
225                         add_flag(o_ptr->art_flags, TR_CON);
226                         if (one_in_(2)) return;
227                 }
228
229                 if (!(have_flag(o_ptr->art_flags, TR_DEX)))
230                 {
231                         add_flag(o_ptr->art_flags, TR_DEX);
232                         if (one_in_(2)) return;
233                 }
234                 break;
235
236         case BIAS_MAGE:
237                 if (!(have_flag(o_ptr->art_flags, TR_INT)))
238                 {
239                         add_flag(o_ptr->art_flags, TR_INT);
240                         if (one_in_(2)) return;
241                 }
242                 if ((o_ptr->tval == TV_GLOVES) && !(have_flag(o_ptr->art_flags, TR_MAGIC_MASTERY)))
243                 {
244                         add_flag(o_ptr->art_flags, TR_MAGIC_MASTERY);
245                         if (one_in_(2)) return;
246                 }
247                 break;
248
249         case BIAS_PRIESTLY:
250                 if (!(have_flag(o_ptr->art_flags, TR_WIS)))
251                 {
252                         add_flag(o_ptr->art_flags, TR_WIS);
253                         if (one_in_(2)) return;
254                 }
255                 break;
256
257         case BIAS_RANGER:
258                 if (!(have_flag(o_ptr->art_flags, TR_DEX)))
259                 {
260                         add_flag(o_ptr->art_flags, TR_DEX);
261                         if (one_in_(2)) return;
262                 }
263
264                 if (!(have_flag(o_ptr->art_flags, TR_CON)))
265                 {
266                         add_flag(o_ptr->art_flags, TR_CON);
267                         if (one_in_(2)) return;
268                 }
269
270                 if (!(have_flag(o_ptr->art_flags, TR_STR)))
271                 {
272                         add_flag(o_ptr->art_flags, TR_STR);
273                         if (one_in_(2)) return;
274                 }
275                 break;
276
277         case BIAS_ROGUE:
278                 if (!(have_flag(o_ptr->art_flags, TR_STEALTH)))
279                 {
280                         add_flag(o_ptr->art_flags, TR_STEALTH);
281                         if (one_in_(2)) return;
282                 }
283                 if (!(have_flag(o_ptr->art_flags, TR_SEARCH)))
284                 {
285                         add_flag(o_ptr->art_flags, TR_SEARCH);
286                         if (one_in_(2)) return;
287                 }
288                 break;
289
290         case BIAS_STR:
291                 if (!(have_flag(o_ptr->art_flags, TR_STR)))
292                 {
293                         add_flag(o_ptr->art_flags, TR_STR);
294                         if (one_in_(2)) return;
295                 }
296                 break;
297
298         case BIAS_WIS:
299                 if (!(have_flag(o_ptr->art_flags, TR_WIS)))
300                 {
301                         add_flag(o_ptr->art_flags, TR_WIS);
302                         if (one_in_(2)) return;
303                 }
304                 break;
305
306         case BIAS_INT:
307                 if (!(have_flag(o_ptr->art_flags, TR_INT)))
308                 {
309                         add_flag(o_ptr->art_flags, TR_INT);
310                         if (one_in_(2)) return;
311                 }
312                 break;
313
314         case BIAS_DEX:
315                 if (!(have_flag(o_ptr->art_flags, TR_DEX)))
316                 {
317                         add_flag(o_ptr->art_flags, TR_DEX);
318                         if (one_in_(2)) return;
319                 }
320                 break;
321
322         case BIAS_CON:
323                 if (!(have_flag(o_ptr->art_flags, TR_CON)))
324                 {
325                         add_flag(o_ptr->art_flags, TR_CON);
326                         if (one_in_(2)) return;
327                 }
328                 break;
329
330         case BIAS_CHR:
331                 if (!(have_flag(o_ptr->art_flags, TR_CHR)))
332                 {
333                         add_flag(o_ptr->art_flags, TR_CHR);
334                         if (one_in_(2)) return;
335                 }
336                 break;
337         }
338
339         if ((artifact_bias == BIAS_MAGE || artifact_bias == BIAS_PRIESTLY) && (o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ROBE))
340         {
341                 if (!(have_flag(o_ptr->art_flags, TR_DEC_MANA)) && one_in_(3))
342                 {
343                         add_flag(o_ptr->art_flags, TR_DEC_MANA);
344                         if (one_in_(2)) return;
345                 }
346         }
347
348         switch (randint1(this_type))
349         {
350         case 1: case 2:
351                 add_flag(o_ptr->art_flags, TR_STR);
352                 if (!artifact_bias && !one_in_(13))
353                         artifact_bias = BIAS_STR;
354                 else if (!artifact_bias && one_in_(7))
355                         artifact_bias = BIAS_WARRIOR;
356                 break;
357         case 3: case 4:
358                 add_flag(o_ptr->art_flags, TR_INT);
359                 if (!artifact_bias && !one_in_(13))
360                         artifact_bias = BIAS_INT;
361                 else if (!artifact_bias && one_in_(7))
362                         artifact_bias = BIAS_MAGE;
363                 break;
364         case 5: case 6:
365                 add_flag(o_ptr->art_flags, TR_WIS);
366                 if (!artifact_bias && !one_in_(13))
367                         artifact_bias = BIAS_WIS;
368                 else if (!artifact_bias && one_in_(7))
369                         artifact_bias = BIAS_PRIESTLY;
370                 break;
371         case 7: case 8:
372                 add_flag(o_ptr->art_flags, TR_DEX);
373                 if (!artifact_bias && !one_in_(13))
374                         artifact_bias = BIAS_DEX;
375                 else if (!artifact_bias && one_in_(7))
376                         artifact_bias = BIAS_ROGUE;
377                 break;
378         case 9: case 10:
379                 add_flag(o_ptr->art_flags, TR_CON);
380                 if (!artifact_bias && !one_in_(13))
381                         artifact_bias = BIAS_CON;
382                 else if (!artifact_bias && one_in_(9))
383                         artifact_bias = BIAS_RANGER;
384                 break;
385         case 11: case 12:
386                 add_flag(o_ptr->art_flags, TR_CHR);
387                 if (!artifact_bias && !one_in_(13))
388                         artifact_bias = BIAS_CHR;
389                 break;
390         case 13: case 14:
391                 add_flag(o_ptr->art_flags, TR_STEALTH);
392                 if (!artifact_bias && one_in_(3))
393                         artifact_bias = BIAS_ROGUE;
394                 break;
395         case 15: case 16:
396                 add_flag(o_ptr->art_flags, TR_SEARCH);
397                 if (!artifact_bias && one_in_(9))
398                         artifact_bias = BIAS_RANGER;
399                 break;
400         case 17: case 18:
401                 add_flag(o_ptr->art_flags, TR_INFRA);
402                 break;
403         case 19:
404                 add_flag(o_ptr->art_flags, TR_SPEED);
405                 if (!artifact_bias && one_in_(11))
406                         artifact_bias = BIAS_ROGUE;
407                 break;
408         case 20: case 21:
409                 add_flag(o_ptr->art_flags, TR_TUNNEL);
410                 break;
411         case 22: case 23:
412                 if (o_ptr->tval == TV_BOW) random_plus(o_ptr);
413                 else
414                 {
415                         add_flag(o_ptr->art_flags, TR_BLOWS);
416                         if (!artifact_bias && one_in_(11))
417                                 artifact_bias = BIAS_WARRIOR;
418                 }
419                 break;
420         }
421 }
422
423
424 static void random_resistance(object_type * o_ptr)
425 {
426         switch (artifact_bias)
427         {
428         case BIAS_ACID:
429                 if (!(have_flag(o_ptr->art_flags, TR_RES_ACID)))
430                 {
431                         add_flag(o_ptr->art_flags, TR_RES_ACID);
432                         if (one_in_(2)) return;
433                 }
434                 if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_ACID)))
435                 {
436                         add_flag(o_ptr->art_flags, TR_IM_ACID);
437                         if (!one_in_(IM_LUCK))
438                         {
439                                 remove_flag(o_ptr->art_flags, TR_IM_ELEC);
440                                 remove_flag(o_ptr->art_flags, TR_IM_COLD);
441                                 remove_flag(o_ptr->art_flags, TR_IM_FIRE);
442                         }
443                         if (one_in_(2)) return;
444                 }
445                 break;
446
447         case BIAS_ELEC:
448                 if (!(have_flag(o_ptr->art_flags, TR_RES_ELEC)))
449                 {
450                         add_flag(o_ptr->art_flags, TR_RES_ELEC);
451                         if (one_in_(2)) return;
452                 }
453                 if ((o_ptr->tval >= TV_CLOAK) && (o_ptr->tval <= TV_HARD_ARMOR) &&
454                     !(have_flag(o_ptr->art_flags, TR_SH_ELEC)))
455                 {
456                         add_flag(o_ptr->art_flags, TR_SH_ELEC);
457                         if (one_in_(2)) return;
458                 }
459                 if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_ELEC)))
460                 {
461                         add_flag(o_ptr->art_flags, TR_IM_ELEC);
462                         if (!one_in_(IM_LUCK))
463                         {
464                                 remove_flag(o_ptr->art_flags, TR_IM_ACID);
465                                 remove_flag(o_ptr->art_flags, TR_IM_COLD);
466                                 remove_flag(o_ptr->art_flags, TR_IM_FIRE);
467                         }
468
469                         if (one_in_(2)) return;
470                 }
471                 break;
472
473         case BIAS_FIRE:
474                 if (!(have_flag(o_ptr->art_flags, TR_RES_FIRE)))
475                 {
476                         add_flag(o_ptr->art_flags, TR_RES_FIRE);
477                         if (one_in_(2)) return;
478                 }
479                 if ((o_ptr->tval >= TV_CLOAK) &&
480                     (o_ptr->tval <= TV_HARD_ARMOR) &&
481                     !(have_flag(o_ptr->art_flags, TR_SH_FIRE)))
482                 {
483                         add_flag(o_ptr->art_flags, TR_SH_FIRE);
484                         if (one_in_(2)) return;
485                 }
486                 if (one_in_(BIAS_LUCK) &&
487                     !(have_flag(o_ptr->art_flags, TR_IM_FIRE)))
488                 {
489                         add_flag(o_ptr->art_flags, TR_IM_FIRE);
490                         if (!one_in_(IM_LUCK))
491                         {
492                                 remove_flag(o_ptr->art_flags, TR_IM_ELEC);
493                                 remove_flag(o_ptr->art_flags, TR_IM_COLD);
494                                 remove_flag(o_ptr->art_flags, TR_IM_ACID);
495                         }
496                         if (one_in_(2)) return;
497                 }
498                 break;
499
500         case BIAS_COLD:
501                 if (!(have_flag(o_ptr->art_flags, TR_RES_COLD)))
502                 {
503                         add_flag(o_ptr->art_flags, TR_RES_COLD);
504                         if (one_in_(2)) return;
505                 }
506                 if ((o_ptr->tval >= TV_CLOAK) &&
507                     (o_ptr->tval <= TV_HARD_ARMOR) &&
508                     !(have_flag(o_ptr->art_flags, TR_SH_COLD)))
509                 {
510                         add_flag(o_ptr->art_flags, TR_SH_COLD);
511                         if (one_in_(2)) return;
512                 }
513                 if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_COLD)))
514                 {
515                         add_flag(o_ptr->art_flags, TR_IM_COLD);
516                         if (!one_in_(IM_LUCK))
517                         {
518                                 remove_flag(o_ptr->art_flags, TR_IM_ELEC);
519                                 remove_flag(o_ptr->art_flags, TR_IM_ACID);
520                                 remove_flag(o_ptr->art_flags, TR_IM_FIRE);
521                         }
522                         if (one_in_(2)) return;
523                 }
524                 break;
525
526         case BIAS_POIS:
527                 if (!(have_flag(o_ptr->art_flags, TR_RES_POIS)))
528                 {
529                         add_flag(o_ptr->art_flags, TR_RES_POIS);
530                         if (one_in_(2)) return;
531                 }
532                 break;
533
534         case BIAS_WARRIOR:
535                 if (!one_in_(3) && (!(have_flag(o_ptr->art_flags, TR_RES_FEAR))))
536                 {
537                         add_flag(o_ptr->art_flags, TR_RES_FEAR);
538                         if (one_in_(2)) return;
539                 }
540                 if (one_in_(3) && (!(have_flag(o_ptr->art_flags, TR_NO_MAGIC))))
541                 {
542                         add_flag(o_ptr->art_flags, TR_NO_MAGIC);
543                         if (one_in_(2)) return;
544                 }
545                 break;
546
547         case BIAS_NECROMANTIC:
548                 if (!(have_flag(o_ptr->art_flags, TR_RES_NETHER)))
549                 {
550                         add_flag(o_ptr->art_flags, TR_RES_NETHER);
551                         if (one_in_(2)) return;
552                 }
553                 if (!(have_flag(o_ptr->art_flags, TR_RES_POIS)))
554                 {
555                         add_flag(o_ptr->art_flags, TR_RES_POIS);
556                         if (one_in_(2)) return;
557                 }
558                 if (!(have_flag(o_ptr->art_flags, TR_RES_DARK)))
559                 {
560                         add_flag(o_ptr->art_flags, TR_RES_DARK);
561                         if (one_in_(2)) return;
562                 }
563                 break;
564
565         case BIAS_CHAOS:
566                 if (!(have_flag(o_ptr->art_flags, TR_RES_CHAOS)))
567                 {
568                         add_flag(o_ptr->art_flags, TR_RES_CHAOS);
569                         if (one_in_(2)) return;
570                 }
571                 if (!(have_flag(o_ptr->art_flags, TR_RES_CONF)))
572                 {
573                         add_flag(o_ptr->art_flags, TR_RES_CONF);
574                         if (one_in_(2)) return;
575                 }
576                 if (!(have_flag(o_ptr->art_flags, TR_RES_DISEN)))
577                 {
578                         add_flag(o_ptr->art_flags, TR_RES_DISEN);
579                         if (one_in_(2)) return;
580                 }
581                 break;
582         }
583
584         switch (randint1(42))
585         {
586                 case 1:
587                         if (!one_in_(WEIRD_LUCK))
588                                 random_resistance(o_ptr);
589                         else
590                         {
591                                 add_flag(o_ptr->art_flags, TR_IM_ACID);
592                                 if (!artifact_bias)
593                                         artifact_bias = BIAS_ACID;
594                         }
595                         break;
596                 case 2:
597                         if (!one_in_(WEIRD_LUCK))
598                                 random_resistance(o_ptr);
599                         else
600                         {
601                                 add_flag(o_ptr->art_flags, TR_IM_ELEC);
602                                 if (!artifact_bias)
603                                         artifact_bias = BIAS_ELEC;
604                         }
605                         break;
606                 case 3:
607                         if (!one_in_(WEIRD_LUCK))
608                                 random_resistance(o_ptr);
609                         else
610                         {
611                                 add_flag(o_ptr->art_flags, TR_IM_COLD);
612                                 if (!artifact_bias)
613                                         artifact_bias = BIAS_COLD;
614                         }
615                         break;
616                 case 4:
617                         if (!one_in_(WEIRD_LUCK))
618                                 random_resistance(o_ptr);
619                         else
620                         {
621                                 add_flag(o_ptr->art_flags, TR_IM_FIRE);
622                                 if (!artifact_bias)
623                                         artifact_bias = BIAS_FIRE;
624                         }
625                         break;
626                 case 5:
627                 case 6:
628                 case 13:
629                         add_flag(o_ptr->art_flags, TR_RES_ACID);
630                         if (!artifact_bias)
631                                 artifact_bias = BIAS_ACID;
632                         break;
633                 case 7:
634                 case 8:
635                 case 14:
636                         add_flag(o_ptr->art_flags, TR_RES_ELEC);
637                         if (!artifact_bias)
638                                 artifact_bias = BIAS_ELEC;
639                         break;
640                 case 9:
641                 case 10:
642                 case 15:
643                         add_flag(o_ptr->art_flags, TR_RES_FIRE);
644                         if (!artifact_bias)
645                                 artifact_bias = BIAS_FIRE;
646                         break;
647                 case 11:
648                 case 12:
649                 case 16:
650                         add_flag(o_ptr->art_flags, TR_RES_COLD);
651                         if (!artifact_bias)
652                                 artifact_bias = BIAS_COLD;
653                         break;
654                 case 17:
655                 case 18:
656                         add_flag(o_ptr->art_flags, TR_RES_POIS);
657                         if (!artifact_bias && !one_in_(4))
658                                 artifact_bias = BIAS_POIS;
659                         else if (!artifact_bias && one_in_(2))
660                                 artifact_bias = BIAS_NECROMANTIC;
661                         else if (!artifact_bias && one_in_(2))
662                                 artifact_bias = BIAS_ROGUE;
663                         break;
664                 case 19:
665                 case 20:
666                         add_flag(o_ptr->art_flags, TR_RES_FEAR);
667                         if (!artifact_bias && one_in_(3))
668                                 artifact_bias = BIAS_WARRIOR;
669                         break;
670                 case 21:
671                         add_flag(o_ptr->art_flags, TR_RES_LITE);
672                         break;
673                 case 22:
674                         add_flag(o_ptr->art_flags, TR_RES_DARK);
675                         break;
676                 case 23:
677                 case 24:
678                         add_flag(o_ptr->art_flags, TR_RES_BLIND);
679                         break;
680                 case 25:
681                 case 26:
682                         add_flag(o_ptr->art_flags, TR_RES_CONF);
683                         if (!artifact_bias && one_in_(6))
684                                 artifact_bias = BIAS_CHAOS;
685                         break;
686                 case 27:
687                 case 28:
688                         add_flag(o_ptr->art_flags, TR_RES_SOUND);
689                         break;
690                 case 29:
691                 case 30:
692                         add_flag(o_ptr->art_flags, TR_RES_SHARDS);
693                         break;
694                 case 31:
695                 case 32:
696                         add_flag(o_ptr->art_flags, TR_RES_NETHER);
697                         if (!artifact_bias && one_in_(3))
698                                 artifact_bias = BIAS_NECROMANTIC;
699                         break;
700                 case 33:
701                 case 34:
702                         add_flag(o_ptr->art_flags, TR_RES_NEXUS);
703                         break;
704                 case 35:
705                 case 36:
706                         add_flag(o_ptr->art_flags, TR_RES_CHAOS);
707                         if (!artifact_bias && one_in_(2))
708                                 artifact_bias = BIAS_CHAOS;
709                         break;
710                 case 37:
711                 case 38:
712                         add_flag(o_ptr->art_flags, TR_RES_DISEN);
713                         break;
714                 case 39:
715                         if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
716                                 add_flag(o_ptr->art_flags, TR_SH_ELEC);
717                         else
718                                 random_resistance(o_ptr);
719                         if (!artifact_bias)
720                                 artifact_bias = BIAS_ELEC;
721                         break;
722                 case 40:
723                         if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
724                                 add_flag(o_ptr->art_flags, TR_SH_FIRE);
725                         else
726                                 random_resistance(o_ptr);
727                         if (!artifact_bias)
728                                 artifact_bias = BIAS_FIRE;
729                         break;
730                 case 41:
731                         if (o_ptr->tval == TV_SHIELD || o_ptr->tval == TV_CLOAK ||
732                             o_ptr->tval == TV_HELM || o_ptr->tval == TV_HARD_ARMOR)
733                                 add_flag(o_ptr->art_flags, TR_REFLECT);
734                         else
735                                 random_resistance(o_ptr);
736                         break;
737                 case 42:
738                         if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
739                                 add_flag(o_ptr->art_flags, TR_SH_COLD);
740                         else
741                                 random_resistance(o_ptr);
742                         if (!artifact_bias)
743                                 artifact_bias = BIAS_COLD;
744                         break;
745         }
746 }
747
748
749
750 static void random_misc(object_type * o_ptr)
751 {
752         switch (artifact_bias)
753         {
754         case BIAS_RANGER:
755                 if (!(have_flag(o_ptr->art_flags, TR_SUST_CON)))
756                 {
757                         add_flag(o_ptr->art_flags, TR_SUST_CON);
758                         if (one_in_(2)) return;
759                 }
760                 break;
761
762         case BIAS_STR:
763                 if (!(have_flag(o_ptr->art_flags, TR_SUST_STR)))
764                 {
765                         add_flag(o_ptr->art_flags, TR_SUST_STR);
766                         if (one_in_(2)) return;
767                 }
768                 break;
769
770         case BIAS_WIS:
771                 if (!(have_flag(o_ptr->art_flags, TR_SUST_WIS)))
772                 {
773                         add_flag(o_ptr->art_flags, TR_SUST_WIS);
774                         if (one_in_(2)) return;
775                 }
776                 break;
777
778         case BIAS_INT:
779                 if (!(have_flag(o_ptr->art_flags, TR_SUST_INT)))
780                 {
781                         add_flag(o_ptr->art_flags, TR_SUST_INT);
782                         if (one_in_(2)) return;
783                 }
784                 break;
785
786         case BIAS_DEX:
787                 if (!(have_flag(o_ptr->art_flags, TR_SUST_DEX)))
788                 {
789                         add_flag(o_ptr->art_flags, TR_SUST_DEX);
790                         if (one_in_(2)) return;
791                 }
792                 break;
793
794         case BIAS_CON:
795                 if (!(have_flag(o_ptr->art_flags, TR_SUST_CON)))
796                 {
797                         add_flag(o_ptr->art_flags, TR_SUST_CON);
798                         if (one_in_(2)) return;
799                 }
800                 break;
801
802         case BIAS_CHR:
803                 if (!(have_flag(o_ptr->art_flags, TR_SUST_CHR)))
804                 {
805                         add_flag(o_ptr->art_flags, TR_SUST_CHR);
806                         if (one_in_(2)) return;
807                 }
808                 break;
809
810         case BIAS_CHAOS:
811                 if (!(have_flag(o_ptr->art_flags, TR_TELEPORT)))
812                 {
813                         add_flag(o_ptr->art_flags, TR_TELEPORT);
814                         if (one_in_(2)) return;
815                 }
816                 break;
817
818         case BIAS_FIRE:
819                 if (!(have_flag(o_ptr->art_flags, TR_LITE)))
820                 {
821                         add_flag(o_ptr->art_flags, TR_LITE); /* Freebie */
822                 }
823                 break;
824         }
825
826         switch (randint1(33))
827         {
828                 case 1:
829                         add_flag(o_ptr->art_flags, TR_SUST_STR);
830                         if (!artifact_bias)
831                                 artifact_bias = BIAS_STR;
832                         break;
833                 case 2:
834                         add_flag(o_ptr->art_flags, TR_SUST_INT);
835                         if (!artifact_bias)
836                                 artifact_bias = BIAS_INT;
837                         break;
838                 case 3:
839                         add_flag(o_ptr->art_flags, TR_SUST_WIS);
840                         if (!artifact_bias)
841                                 artifact_bias = BIAS_WIS;
842                         break;
843                 case 4:
844                         add_flag(o_ptr->art_flags, TR_SUST_DEX);
845                         if (!artifact_bias)
846                                 artifact_bias = BIAS_DEX;
847                         break;
848                 case 5:
849                         add_flag(o_ptr->art_flags, TR_SUST_CON);
850                         if (!artifact_bias)
851                                 artifact_bias = BIAS_CON;
852                         break;
853                 case 6:
854                         add_flag(o_ptr->art_flags, TR_SUST_CHR);
855                         if (!artifact_bias)
856                                 artifact_bias = BIAS_CHR;
857                         break;
858                 case 7:
859                 case 8:
860                 case 14:
861                         add_flag(o_ptr->art_flags, TR_FREE_ACT);
862                         break;
863                 case 9:
864                         add_flag(o_ptr->art_flags, TR_HOLD_LIFE);
865                         if (!artifact_bias && one_in_(5))
866                                 artifact_bias = BIAS_PRIESTLY;
867                         else if (!artifact_bias && one_in_(6))
868                                 artifact_bias = BIAS_NECROMANTIC;
869                         break;
870                 case 10:
871                 case 11:
872                         add_flag(o_ptr->art_flags, TR_LITE);
873                         break;
874                 case 12:
875                 case 13:
876                         add_flag(o_ptr->art_flags, TR_LEVITATION);
877                         break;
878                 case 15:
879                 case 16:
880                 case 17:
881                         add_flag(o_ptr->art_flags, TR_SEE_INVIS);
882                         break;
883                 case 19:
884                 case 20:
885                         add_flag(o_ptr->art_flags, TR_SLOW_DIGEST);
886                         break;
887                 case 21:
888                 case 22:
889                         add_flag(o_ptr->art_flags, TR_REGEN);
890                         break;
891                 case 23:
892                         add_flag(o_ptr->art_flags, TR_TELEPORT);
893                         break;
894                 case 24:
895                 case 25:
896                 case 26:
897                         if (object_is_armour(o_ptr))
898                                 random_misc(o_ptr);
899                         else
900                         {
901                                 o_ptr->to_a = 4 + randint1(11);
902                         }
903                         break;
904                 case 27:
905                 case 28:
906                 case 29:
907                 {
908                         int bonus_h, bonus_d;
909                         add_flag(o_ptr->art_flags, TR_SHOW_MODS);
910                         bonus_h = 4 + (randint1(11));
911                         bonus_d = 4 + (randint1(11));
912                         if ((o_ptr->tval != TV_SWORD) && (o_ptr->tval != TV_POLEARM) && (o_ptr->tval != TV_HAFTED) && (o_ptr->tval != TV_DIGGING) && (o_ptr->tval != TV_GLOVES) && (o_ptr->tval != TV_RING))
913                         {
914                                 bonus_h /= 2;
915                                 bonus_d /= 2;
916                         }
917                         o_ptr->to_h += bonus_h;
918                         o_ptr->to_d += bonus_d;
919                         break;
920                 }
921                 case 30:
922                         add_flag(o_ptr->art_flags, TR_NO_MAGIC);
923                         break;
924                 case 31:
925                         add_flag(o_ptr->art_flags, TR_NO_TELE);
926                         break;
927                 case 32:
928                         add_flag(o_ptr->art_flags, TR_WARNING);
929                         break;
930
931                 case 18:
932                         switch (randint1(3))
933                         {
934                         case 1:
935                                 add_flag(o_ptr->art_flags, TR_ESP_EVIL);
936                                 if (!artifact_bias && one_in_(3))
937                                         artifact_bias = BIAS_LAW;
938                                 break;
939                         case 2:
940                                 add_flag(o_ptr->art_flags, TR_ESP_NONLIVING);
941                                 if (!artifact_bias && one_in_(3))
942                                         artifact_bias = BIAS_MAGE;
943                                 break;
944                         case 3:
945                                 add_flag(o_ptr->art_flags, TR_TELEPATHY);
946                                 if (!artifact_bias && one_in_(9))
947                                         artifact_bias = BIAS_MAGE;
948                                 break;
949                         }
950                         break;
951
952                 case 33:
953                 {
954                         int idx[3];
955                         int n = randint1(3);
956
957                         idx[0] = randint1(8);
958
959                         idx[1] = randint1(7);
960                         if (idx[1] >= idx[0]) idx[1]++;
961
962                         idx[2] = randint1(6);
963                         if (idx[2] >= idx[0]) idx[2]++;
964                         if (idx[2] >= idx[1]) idx[2]++;
965
966                         while (n--) switch (idx[n])
967                         {
968                         case 1:
969                                 add_flag(o_ptr->art_flags, TR_ESP_ANIMAL);
970                                 if (!artifact_bias && one_in_(4))
971                                         artifact_bias = BIAS_RANGER;
972                                 break;
973                         case 2:
974                                 add_flag(o_ptr->art_flags, TR_ESP_UNDEAD);
975                                 if (!artifact_bias && one_in_(3))
976                                         artifact_bias = BIAS_PRIESTLY;
977                                 else if (!artifact_bias && one_in_(6))
978                                         artifact_bias = BIAS_NECROMANTIC;
979                                 break;
980                         case 3:
981                                 add_flag(o_ptr->art_flags, TR_ESP_DEMON);
982                                 break;
983                         case 4:
984                                 add_flag(o_ptr->art_flags, TR_ESP_ORC);
985                                 break;
986                         case 5:
987                                 add_flag(o_ptr->art_flags, TR_ESP_TROLL);
988                                 break;
989                         case 6:
990                                 add_flag(o_ptr->art_flags, TR_ESP_GIANT);
991                                 break;
992                         case 7:
993                                 add_flag(o_ptr->art_flags, TR_ESP_HUMAN);
994                                 if (!artifact_bias && one_in_(6))
995                                         artifact_bias = BIAS_ROGUE;
996                                 break;
997                         case 8:
998                                 add_flag(o_ptr->art_flags, TR_ESP_GOOD);
999                                 if (!artifact_bias && one_in_(3))
1000                                         artifact_bias = BIAS_LAW;
1001                                 break;
1002                         case 9:
1003                                 add_flag(o_ptr->art_flags, TR_ESP_UNIQUE);
1004                                 if (!artifact_bias && one_in_(3))
1005                                         artifact_bias = BIAS_LAW;
1006                                 break;
1007                         }
1008                         break;
1009                 }
1010         }
1011 }
1012
1013
1014 static void random_slay(object_type *o_ptr)
1015 {
1016         if (o_ptr->tval == TV_BOW)
1017         {
1018                 switch (randint1(6))
1019                 {
1020                         case 1:
1021                         case 2:
1022                         case 3:
1023                                 add_flag(o_ptr->art_flags, TR_XTRA_MIGHT);
1024                                 if (!one_in_(7)) remove_flag(o_ptr->art_flags, TR_XTRA_SHOTS);
1025                                 if (!artifact_bias && one_in_(9))
1026                                         artifact_bias = BIAS_RANGER;
1027                                 break;
1028                         default:
1029                                 add_flag(o_ptr->art_flags, TR_XTRA_SHOTS);
1030                                 if (!one_in_(7)) remove_flag(o_ptr->art_flags, TR_XTRA_MIGHT);
1031                                 if (!artifact_bias && one_in_(9))
1032                                         artifact_bias = BIAS_RANGER;
1033                         break;
1034                 }
1035
1036                 return;
1037         }
1038
1039         switch (artifact_bias)
1040         {
1041         case BIAS_CHAOS:
1042                 if (!(have_flag(o_ptr->art_flags, TR_CHAOTIC)))
1043                 {
1044                         add_flag(o_ptr->art_flags, TR_CHAOTIC);
1045                         if (one_in_(2)) return;
1046                 }
1047                 break;
1048
1049         case BIAS_PRIESTLY:
1050                 if((o_ptr->tval == TV_SWORD || o_ptr->tval == TV_POLEARM) &&
1051                    !(have_flag(o_ptr->art_flags, TR_BLESSED)))
1052                 {
1053                         /* A free power for "priestly" random artifacts */
1054                         add_flag(o_ptr->art_flags, TR_BLESSED);
1055                 }
1056                 break;
1057
1058         case BIAS_NECROMANTIC:
1059                 if (!(have_flag(o_ptr->art_flags, TR_VAMPIRIC)))
1060                 {
1061                         add_flag(o_ptr->art_flags, TR_VAMPIRIC);
1062                         if (one_in_(2)) return;
1063                 }
1064                 if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS)) && one_in_(2))
1065                 {
1066                         add_flag(o_ptr->art_flags, TR_BRAND_POIS);
1067                         if (one_in_(2)) return;
1068                 }
1069                 break;
1070
1071         case BIAS_RANGER:
1072                 if (!(have_flag(o_ptr->art_flags, TR_SLAY_ANIMAL)))
1073                 {
1074                         add_flag(o_ptr->art_flags, TR_SLAY_ANIMAL);
1075                         if (one_in_(2)) return;
1076                 }
1077                 break;
1078
1079         case BIAS_ROGUE:
1080                 if ((((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DAGGER)) ||
1081                      ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_SPEAR))) &&
1082                          !(have_flag(o_ptr->art_flags, TR_THROW)))
1083                 {
1084                         /* Free power for rogues... */
1085                         add_flag(o_ptr->art_flags, TR_THROW);
1086                 }
1087                 if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS)))
1088                 {
1089                         add_flag(o_ptr->art_flags, TR_BRAND_POIS);
1090                         if (one_in_(2)) return;
1091                 }
1092                 break;
1093
1094         case BIAS_POIS:
1095                 if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS)))
1096                 {
1097                         add_flag(o_ptr->art_flags, TR_BRAND_POIS);
1098                         if (one_in_(2)) return;
1099                 }
1100                 break;
1101
1102         case BIAS_FIRE:
1103                 if (!(have_flag(o_ptr->art_flags, TR_BRAND_FIRE)))
1104                 {
1105                         add_flag(o_ptr->art_flags, TR_BRAND_FIRE);
1106                         if (one_in_(2)) return;
1107                 }
1108                 break;
1109
1110         case BIAS_COLD:
1111                 if (!(have_flag(o_ptr->art_flags, TR_BRAND_COLD)))
1112                 {
1113                         add_flag(o_ptr->art_flags, TR_BRAND_COLD);
1114                         if (one_in_(2)) return;
1115                 }
1116                 break;
1117
1118         case BIAS_ELEC:
1119                 if (!(have_flag(o_ptr->art_flags, TR_BRAND_ELEC)))
1120                 {
1121                         add_flag(o_ptr->art_flags, TR_BRAND_ELEC);
1122                         if (one_in_(2)) return;
1123                 }
1124                 break;
1125
1126         case BIAS_ACID:
1127                 if (!(have_flag(o_ptr->art_flags, TR_BRAND_ACID)))
1128                 {
1129                         add_flag(o_ptr->art_flags, TR_BRAND_ACID);
1130                         if (one_in_(2)) return;
1131                 }
1132                 break;
1133
1134         case BIAS_LAW:
1135                 if (!(have_flag(o_ptr->art_flags, TR_SLAY_EVIL)))
1136                 {
1137                         add_flag(o_ptr->art_flags, TR_SLAY_EVIL);
1138                         if (one_in_(2)) return;
1139                 }
1140                 if (!(have_flag(o_ptr->art_flags, TR_SLAY_UNDEAD)))
1141                 {
1142                         add_flag(o_ptr->art_flags, TR_SLAY_UNDEAD);
1143                         if (one_in_(2)) return;
1144                 }
1145                 if (!(have_flag(o_ptr->art_flags, TR_SLAY_DEMON)))
1146                 {
1147                         add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
1148                         if (one_in_(2)) return;
1149                 }
1150                 break;
1151         }
1152
1153         switch (randint1(36))
1154         {
1155                 case 1:
1156                 case 2:
1157                         add_flag(o_ptr->art_flags, TR_SLAY_ANIMAL);
1158                         break;
1159                 case 3:
1160                 case 4:
1161                         add_flag(o_ptr->art_flags, TR_SLAY_EVIL);
1162                         if (!artifact_bias && one_in_(2))
1163                                 artifact_bias = BIAS_LAW;
1164                         else if (!artifact_bias && one_in_(9))
1165                                 artifact_bias = BIAS_PRIESTLY;
1166                         break;
1167                 case 5:
1168                 case 6:
1169                         add_flag(o_ptr->art_flags, TR_SLAY_UNDEAD);
1170                         if (!artifact_bias && one_in_(9))
1171                                 artifact_bias = BIAS_PRIESTLY;
1172                         break;
1173                 case 7:
1174                 case 8:
1175                         add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
1176                         if (!artifact_bias && one_in_(9))
1177                                 artifact_bias = BIAS_PRIESTLY;
1178                         break;
1179                 case 9:
1180                 case 10:
1181                         add_flag(o_ptr->art_flags, TR_SLAY_ORC);
1182                         break;
1183                 case 11:
1184                 case 12:
1185                         add_flag(o_ptr->art_flags, TR_SLAY_TROLL);
1186                         break;
1187                 case 13:
1188                 case 14:
1189                         add_flag(o_ptr->art_flags, TR_SLAY_GIANT);
1190                         break;
1191                 case 15:
1192                 case 16:
1193                         add_flag(o_ptr->art_flags, TR_SLAY_DRAGON);
1194                         break;
1195                 case 17:
1196                         add_flag(o_ptr->art_flags, TR_KILL_DRAGON);
1197                         break;
1198                 case 18:
1199                 case 19:
1200                         if (o_ptr->tval == TV_SWORD)
1201                         {
1202                                 add_flag(o_ptr->art_flags, TR_VORPAL);
1203                                 if (!artifact_bias && one_in_(9))
1204                                         artifact_bias = BIAS_WARRIOR;
1205                         }
1206                         else
1207                                 random_slay(o_ptr);
1208                         break;
1209                 case 20:
1210                         add_flag(o_ptr->art_flags, TR_IMPACT);
1211                         break;
1212                 case 21:
1213                 case 22:
1214                         add_flag(o_ptr->art_flags, TR_BRAND_FIRE);
1215                         if (!artifact_bias)
1216                                 artifact_bias = BIAS_FIRE;
1217                         break;
1218                 case 23:
1219                 case 24:
1220                         add_flag(o_ptr->art_flags, TR_BRAND_COLD);
1221                         if (!artifact_bias)
1222                                 artifact_bias = BIAS_COLD;
1223                         break;
1224                 case 25:
1225                 case 26:
1226                         add_flag(o_ptr->art_flags, TR_BRAND_ELEC);
1227                         if (!artifact_bias)
1228                                 artifact_bias = BIAS_ELEC;
1229                         break;
1230                 case 27:
1231                 case 28:
1232                         add_flag(o_ptr->art_flags, TR_BRAND_ACID);
1233                         if (!artifact_bias)
1234                                 artifact_bias = BIAS_ACID;
1235                         break;
1236                 case 29:
1237                 case 30:
1238                         add_flag(o_ptr->art_flags, TR_BRAND_POIS);
1239                         if (!artifact_bias && !one_in_(3))
1240                                 artifact_bias = BIAS_POIS;
1241                         else if (!artifact_bias && one_in_(6))
1242                                 artifact_bias = BIAS_NECROMANTIC;
1243                         else if (!artifact_bias)
1244                                 artifact_bias = BIAS_ROGUE;
1245                         break;
1246                 case 31:
1247                         add_flag(o_ptr->art_flags, TR_VAMPIRIC);
1248                         if (!artifact_bias)
1249                                 artifact_bias = BIAS_NECROMANTIC;
1250                         break;
1251                 case 32:
1252                         add_flag(o_ptr->art_flags, TR_FORCE_WEAPON);
1253                         if (!artifact_bias)
1254                                 artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY);
1255                         break;
1256                 case 33:
1257                 case 34:
1258                         add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
1259                         break;
1260                 default:
1261                         add_flag(o_ptr->art_flags, TR_CHAOTIC);
1262                         if (!artifact_bias)
1263                                 artifact_bias = BIAS_CHAOS;
1264                         break;
1265         }
1266 }
1267
1268
1269 static void give_activation_power(object_type *o_ptr)
1270 {
1271         int type = 0, chance = 0;
1272
1273         switch (artifact_bias)
1274         {
1275                 case BIAS_ELEC:
1276                         if (!one_in_(3))
1277                         {
1278                                 type = ACT_BO_ELEC_1;
1279                         }
1280                         else if (!one_in_(5))
1281                         {
1282                                 type = ACT_BA_ELEC_2;
1283                         }
1284                         else
1285                         {
1286                                 type = ACT_BA_ELEC_3;
1287                         }
1288                         chance = 101;
1289                         break;
1290
1291                 case BIAS_POIS:
1292                         type = ACT_BA_POIS_1;
1293                         chance = 101;
1294                         break;
1295
1296                 case BIAS_FIRE:
1297                         if (!one_in_(3))
1298                         {
1299                                 type = ACT_BO_FIRE_1;
1300                         }
1301                         else if (!one_in_(5))
1302                         {
1303                                 type = ACT_BA_FIRE_1;
1304                         }
1305                         else
1306                         {
1307                                 type = ACT_BA_FIRE_2;
1308                         }
1309                         chance = 101;
1310                         break;
1311
1312                 case BIAS_COLD:
1313                         chance = 101;
1314                         if (!one_in_(3))
1315                                 type = ACT_BO_COLD_1;
1316                         else if (!one_in_(3))
1317                                 type = ACT_BA_COLD_1;
1318                         else if (!one_in_(3))
1319                                 type = ACT_BA_COLD_2;
1320                         else
1321                                 type = ACT_BA_COLD_3;
1322                         break;
1323
1324                 case BIAS_CHAOS:
1325                         chance = 50;
1326                         if (one_in_(6))
1327                                 type = ACT_SUMMON_DEMON;
1328                         else
1329                                 type = ACT_CALL_CHAOS;
1330                         break;
1331
1332                 case BIAS_PRIESTLY:
1333                         chance = 101;
1334
1335                         if (one_in_(13))
1336                                 type = ACT_CHARM_UNDEAD;
1337                         else if (one_in_(12))
1338                                 type = ACT_BANISH_EVIL;
1339                         else if (one_in_(11))
1340                                 type = ACT_DISP_EVIL;
1341                         else if (one_in_(10))
1342                                 type = ACT_PROT_EVIL;
1343                         else if (one_in_(9))
1344                                 type = ACT_CURE_1000;
1345                         else if (one_in_(8))
1346                                 type = ACT_CURE_700;
1347                         else if (one_in_(7))
1348                                 type = ACT_REST_ALL;
1349                         else if (one_in_(6))
1350                                 type = ACT_REST_LIFE;
1351                         else
1352                                 type = ACT_CURE_MW;
1353                         break;
1354
1355                 case BIAS_NECROMANTIC:
1356                         chance = 101;
1357                         if (one_in_(66))
1358                                 type = ACT_WRAITH;
1359                         else if (one_in_(13))
1360                                 type = ACT_DISP_GOOD;
1361                         else if (one_in_(9))
1362                                 type = ACT_MASS_GENO;
1363                         else if (one_in_(8))
1364                                 type = ACT_GENOCIDE;
1365                         else if (one_in_(13))
1366                                 type = ACT_SUMMON_UNDEAD;
1367                         else if (one_in_(9))
1368                                 type = ACT_VAMPIRE_2;
1369                         else if (one_in_(6))
1370                                 type = ACT_CHARM_UNDEAD;
1371                         else
1372                                 type = ACT_VAMPIRE_1;
1373                         break;
1374
1375                 case BIAS_LAW:
1376                         chance = 101;
1377                         if (one_in_(8))
1378                                 type = ACT_BANISH_EVIL;
1379                         else if (one_in_(4))
1380                                 type = ACT_DISP_EVIL;
1381                         else
1382                                 type = ACT_PROT_EVIL;
1383                         break;
1384
1385                 case BIAS_ROGUE:
1386                         chance = 101;
1387                         if (one_in_(50))
1388                                 type = ACT_SPEED;
1389                         else if (one_in_(4))
1390                                 type = ACT_SLEEP;
1391                         else if (one_in_(3))
1392                                 type = ACT_DETECT_ALL;
1393                         else if (one_in_(8))
1394                                 type = ACT_ID_FULL;
1395                         else
1396                                 type = ACT_ID_PLAIN;
1397                         break;
1398
1399                 case BIAS_MAGE:
1400                         chance = 66;
1401                         if (one_in_(20))
1402                                 type = ACT_SUMMON_ELEMENTAL;
1403                         else if (one_in_(10))
1404                                 type = ACT_SUMMON_PHANTOM;
1405                         else if (one_in_(5))
1406                                 type = ACT_RUNE_EXPLO;
1407                         else
1408                                 type = ACT_ESP;
1409                         break;
1410
1411                 case BIAS_WARRIOR:
1412                         chance = 80;
1413                         if (one_in_(100))
1414                                 type = ACT_INVULN;
1415                         else
1416                                 type = ACT_BERSERK;
1417                         break;
1418
1419                 case BIAS_RANGER:
1420                         chance = 101;
1421                         if (one_in_(20))
1422                                 type = ACT_CHARM_ANIMALS;
1423                         else if (one_in_(7))
1424                                 type = ACT_SUMMON_ANIMAL;
1425                         else if (one_in_(6))
1426                                 type = ACT_CHARM_ANIMAL;
1427                         else if (one_in_(4))
1428                                 type = ACT_RESIST_ALL;
1429                         else if (one_in_(3))
1430                                 type = ACT_SATIATE;
1431                         else
1432                                 type = ACT_CURE_POISON;
1433                         break;
1434         }
1435
1436         while (!type || (randint1(100) >= chance))
1437         {
1438                 type = randint1(255);
1439                 switch (type)
1440                 {
1441                         case ACT_SUNLIGHT:
1442                         case ACT_BO_MISS_1:
1443                         case ACT_BA_POIS_1:
1444                         case ACT_BO_ELEC_1:
1445                         case ACT_BO_ACID_1:
1446                         case ACT_BO_COLD_1:
1447                         case ACT_BO_FIRE_1:
1448                         case ACT_CONFUSE:
1449                         case ACT_SLEEP:
1450                         case ACT_QUAKE:
1451                         case ACT_CURE_LW:
1452                         case ACT_CURE_MW:
1453                         case ACT_CURE_POISON:
1454                         case ACT_BERSERK:
1455                         case ACT_LIGHT:
1456                         case ACT_MAP_LIGHT:
1457                         case ACT_DEST_DOOR:
1458                         case ACT_STONE_MUD:
1459                         case ACT_TELEPORT:
1460                                 chance = 101;
1461                                 break;
1462                         case ACT_BA_COLD_1:
1463                         case ACT_BA_FIRE_1:
1464                         case ACT_DRAIN_1:
1465                         case ACT_TELE_AWAY:
1466                         case ACT_ESP:
1467                         case ACT_RESIST_ALL:
1468                         case ACT_DETECT_ALL:
1469                         case ACT_RECALL:
1470                         case ACT_SATIATE:
1471                         case ACT_RECHARGE:
1472                                 chance = 85;
1473                                 break;
1474                         case ACT_TERROR:
1475                         case ACT_PROT_EVIL:
1476                         case ACT_ID_PLAIN:
1477                                 chance = 75;
1478                                 break;
1479                         case ACT_DRAIN_2:
1480                         case ACT_VAMPIRE_1:
1481                         case ACT_BO_MISS_2:
1482                         case ACT_BA_FIRE_2:
1483                         case ACT_REST_LIFE:
1484                                 chance = 66;
1485                                 break;
1486                         case ACT_BA_FIRE_3:
1487                         case ACT_BA_COLD_3:
1488                         case ACT_BA_ELEC_3:
1489                         case ACT_WHIRLWIND:
1490                         case ACT_VAMPIRE_2:
1491                         case ACT_CHARM_ANIMAL:
1492                                 chance = 50;
1493                                 break;
1494                         case ACT_SUMMON_ANIMAL:
1495                                 chance = 40;
1496                                 break;
1497                         case ACT_DISP_EVIL:
1498                         case ACT_BA_MISS_3:
1499                         case ACT_DISP_GOOD:
1500                         case ACT_BANISH_EVIL:
1501                         case ACT_GENOCIDE:
1502                         case ACT_MASS_GENO:
1503                         case ACT_CHARM_UNDEAD:
1504                         case ACT_CHARM_OTHER:
1505                         case ACT_SUMMON_PHANTOM:
1506                         case ACT_REST_ALL:
1507                         case ACT_RUNE_EXPLO:
1508                                 chance = 33;
1509                                 break;
1510                         case ACT_CALL_CHAOS:
1511                         case ACT_ROCKET:
1512                         case ACT_CHARM_ANIMALS:
1513                         case ACT_CHARM_OTHERS:
1514                         case ACT_SUMMON_ELEMENTAL:
1515                         case ACT_CURE_700:
1516                         case ACT_SPEED:
1517                         case ACT_ID_FULL:
1518                         case ACT_RUNE_PROT:
1519                                 chance = 25;
1520                                 break;
1521                         case ACT_CURE_1000:
1522                         case ACT_XTRA_SPEED:
1523                         case ACT_DETECT_XTRA:
1524                         case ACT_DIM_DOOR:
1525                                 chance = 10;
1526                                 break;
1527                         case ACT_SUMMON_UNDEAD:
1528                         case ACT_SUMMON_DEMON:
1529                         case ACT_WRAITH:
1530                         case ACT_INVULN:
1531                         case ACT_ALCHEMY:
1532                                 chance = 5;
1533                                 break;
1534                         default:
1535                                 chance = 0;
1536                 }
1537         }
1538
1539         /* A type was chosen... */
1540         o_ptr->xtra2 = type;
1541         add_flag(o_ptr->art_flags, TR_ACTIVATE);
1542         o_ptr->timeout = 0;
1543 }
1544
1545
1546 static void get_random_name(char *return_name, bool armour, int power)
1547 {
1548         int prob = randint1(100);
1549
1550         if (prob <= SINDARIN_NAME)
1551         {
1552                 get_table_sindarin(return_name);
1553         }
1554         else if (prob <= TABLE_NAME)
1555         {
1556                 get_table_name(return_name);
1557         }
1558         else
1559         {
1560                 cptr filename;
1561
1562                 switch (armour)
1563                 {
1564                         case 1:
1565                                 switch (power)
1566                                 {
1567                                         case 0:
1568 #ifdef JP
1569                                                 filename = "a_cursed_j.txt";
1570 #else
1571                                                 filename = "a_cursed.txt";
1572 #endif
1573                                                 break;
1574                                         case 1:
1575 #ifdef JP
1576                                                 filename = "a_low_j.txt";
1577 #else
1578                                                 filename = "a_low.txt";
1579 #endif
1580                                                 break;
1581                                         case 2:
1582 #ifdef JP
1583                                                 filename = "a_med_j.txt";
1584 #else
1585                                                 filename = "a_med.txt";
1586 #endif
1587                                                 break;
1588                                         default:
1589 #ifdef JP
1590                                                 filename = "a_high_j.txt";
1591 #else
1592                                                 filename = "a_high.txt";
1593 #endif
1594                                 }
1595                                 break;
1596                         default:
1597                                 switch (power)
1598                                 {
1599                                         case 0:
1600 #ifdef JP
1601                                                 filename = "w_cursed_j.txt";
1602 #else
1603                                                 filename = "w_cursed.txt";
1604 #endif
1605                                                 break;
1606                                         case 1:
1607 #ifdef JP
1608                                                 filename = "w_low_j.txt";
1609 #else
1610                                                 filename = "w_low.txt";
1611 #endif
1612                                                 break;
1613                                         case 2:
1614 #ifdef JP
1615                                                 filename = "w_med_j.txt";
1616 #else
1617                                                 filename = "w_med.txt";
1618 #endif
1619                                                 break;
1620                                         default:
1621 #ifdef JP
1622                                                 filename = "w_high_j.txt";
1623 #else
1624                                                 filename = "w_high.txt";
1625 #endif
1626                                 }
1627                 }
1628
1629                 (void)get_rnd_line(filename, artifact_bias, return_name);
1630 #ifdef JP
1631                  if (return_name[0] == 0) get_table_name(return_name);
1632 #endif
1633         }
1634 }
1635
1636
1637 bool create_artifact(object_type *o_ptr, bool a_scroll)
1638 {
1639         char    new_name[1024];
1640         int     has_pval = 0;
1641         int     powers = randint1(5) + 1;
1642         int     max_type = (object_is_weapon_ammo(o_ptr) ? 7 : 5);
1643         int     power_level;
1644         s32b    total_flags;
1645         bool    a_cursed = FALSE;
1646         int     warrior_artifact_bias = 0;
1647         int i;
1648
1649         /* Reset artifact bias */
1650         artifact_bias = 0;
1651
1652         /* Nuke enchantments */
1653         o_ptr->name1 = 0;
1654         o_ptr->name2 = 0;
1655
1656         for (i = 0; i < TR_FLAG_SIZE; i++)
1657                 o_ptr->art_flags[i] |= k_info[o_ptr->k_idx].flags[i];
1658
1659         if (o_ptr->pval) has_pval = TRUE;
1660
1661         if (a_scroll && one_in_(4))
1662         {
1663                 switch (p_ptr->pclass)
1664                 {
1665                         case CLASS_WARRIOR:
1666                         case CLASS_BERSERKER:
1667                         case CLASS_ARCHER:
1668                         case CLASS_SAMURAI:
1669                         case CLASS_CAVALRY:
1670                         case CLASS_SMITH:
1671                                 artifact_bias = BIAS_WARRIOR;
1672                                 break;
1673                         case CLASS_MAGE:
1674                         case CLASS_HIGH_MAGE:
1675                         case CLASS_SORCERER:
1676                         case CLASS_MAGIC_EATER:
1677                         case CLASS_BLUE_MAGE:
1678                                 artifact_bias = BIAS_MAGE;
1679                                 break;
1680                         case CLASS_PRIEST:
1681                                 artifact_bias = BIAS_PRIESTLY;
1682                                 break;
1683                         case CLASS_ROGUE:
1684                         case CLASS_NINJA:
1685                                 artifact_bias = BIAS_ROGUE;
1686                                 warrior_artifact_bias = 25;
1687                                 break;
1688                         case CLASS_RANGER:
1689                         case CLASS_SNIPER:
1690                                 artifact_bias = BIAS_RANGER;
1691                                 warrior_artifact_bias = 30;
1692                                 break;
1693                         case CLASS_PALADIN:
1694                                 artifact_bias = BIAS_PRIESTLY;
1695                                 warrior_artifact_bias = 40;
1696                                 break;
1697                         case CLASS_WARRIOR_MAGE:
1698                         case CLASS_RED_MAGE:
1699                                 artifact_bias = BIAS_MAGE;
1700                                 warrior_artifact_bias = 40;
1701                                 break;
1702                         case CLASS_CHAOS_WARRIOR:
1703                                 artifact_bias = BIAS_CHAOS;
1704                                 warrior_artifact_bias = 40;
1705                                 break;
1706                         case CLASS_MONK:
1707                         case CLASS_FORCETRAINER:
1708                                 artifact_bias = BIAS_PRIESTLY;
1709                                 break;
1710                         case CLASS_MINDCRAFTER:
1711                         case CLASS_BARD:
1712                                 if (randint1(5) > 2) artifact_bias = BIAS_PRIESTLY;
1713                                 break;
1714                         case CLASS_TOURIST:
1715                                 if (randint1(5) > 2) artifact_bias = BIAS_WARRIOR;
1716                                 break;
1717                         case CLASS_IMITATOR:
1718                                 if (randint1(2) > 1) artifact_bias = BIAS_RANGER;
1719                                 break;
1720                         case CLASS_BEASTMASTER:
1721                                 artifact_bias = BIAS_CHR;
1722                                 warrior_artifact_bias = 50;
1723                                 break;
1724                         case CLASS_MIRROR_MASTER:
1725                                 if (randint1(4) > 1) 
1726                                 {
1727                                     artifact_bias = BIAS_MAGE;
1728                                 }
1729                                 else
1730                                 {
1731                                     artifact_bias = BIAS_ROGUE;
1732                                 }
1733                                 break;
1734                 }
1735         }
1736
1737         if (a_scroll && (randint1(100) <= warrior_artifact_bias))
1738                 artifact_bias = BIAS_WARRIOR;
1739
1740         strcpy(new_name, "");
1741
1742         if (!a_scroll && one_in_(A_CURSED))
1743                 a_cursed = TRUE;
1744         if (((o_ptr->tval == TV_AMULET) || (o_ptr->tval == TV_RING)) && object_is_cursed(o_ptr))
1745                 a_cursed = TRUE;
1746
1747         while (one_in_(powers) || one_in_(7) || one_in_(10))
1748                 powers++;
1749
1750         if (!a_cursed && one_in_(WEIRD_LUCK))
1751                 powers *= 2;
1752
1753         if (a_cursed) powers /= 2;
1754
1755         /* Main loop */
1756         while (powers--)
1757         {
1758                 switch (randint1(max_type))
1759                 {
1760                         case 1: case 2:
1761                                 random_plus(o_ptr);
1762                                 has_pval = TRUE;
1763                                 break;
1764                         case 3: case 4:
1765                                 if (one_in_(2) && object_is_weapon_ammo(o_ptr) && (o_ptr->tval != TV_BOW))
1766                                 {
1767                                         if (a_cursed && !one_in_(13)) break;
1768                                         if (one_in_(13))
1769                                         {
1770                                                 if (one_in_(o_ptr->ds+4)) o_ptr->ds++;
1771                                         }
1772                                         else
1773                                         {
1774                                                 if (one_in_(o_ptr->dd+1)) o_ptr->dd++;
1775                                         }
1776                                 }
1777                                 else
1778                                         random_resistance(o_ptr);
1779                                 break;
1780                         case 5:
1781                                 random_misc(o_ptr);
1782                                 break;
1783                         case 6: case 7:
1784                                 random_slay(o_ptr);
1785                                 break;
1786                         default:
1787                                 if (p_ptr->wizard) msg_print("Switch error in create_artifact!");
1788                                 powers++;
1789                 }
1790         };
1791
1792         if (has_pval)
1793         {
1794 #if 0
1795                 add_flag(o_ptr->art_flags, TR_SHOW_MODS);
1796
1797                 /* This one commented out by gw's request... */
1798                 if (!a_scroll)
1799                         add_flag(o_ptr->art_flags, TR_HIDE_TYPE);
1800 #endif
1801
1802                 if (have_flag(o_ptr->art_flags, TR_BLOWS))
1803                 {
1804                         o_ptr->pval = randint1(2);
1805                         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
1806                                 o_ptr->pval++;
1807                 }
1808                 else
1809                 {
1810                         do
1811                         {
1812                                 o_ptr->pval++;
1813                         }
1814                         while (o_ptr->pval < randint1(5) || one_in_(o_ptr->pval));
1815                 }
1816
1817                 if ((o_ptr->pval > 4) && !one_in_(WEIRD_LUCK))
1818                         o_ptr->pval = 4;
1819         }
1820
1821         /* give it some plusses... */
1822         if (object_is_armour(o_ptr))
1823                 o_ptr->to_a += randint1(o_ptr->to_a > 19 ? 1 : 20 - o_ptr->to_a);
1824         else if (object_is_weapon_ammo(o_ptr))
1825         {
1826                 o_ptr->to_h += randint1(o_ptr->to_h > 19 ? 1 : 20 - o_ptr->to_h);
1827                 o_ptr->to_d += randint1(o_ptr->to_d > 19 ? 1 : 20 - o_ptr->to_d);
1828                 if ((have_flag(o_ptr->art_flags, TR_WIS)) && (o_ptr->pval > 0)) add_flag(o_ptr->art_flags, TR_BLESSED);
1829         }
1830
1831         /* Just to be sure */
1832         add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
1833         add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
1834         add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
1835         add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
1836
1837         total_flags = flag_cost(o_ptr, o_ptr->pval);
1838         if (cheat_peek) msg_format("%ld", total_flags);
1839
1840         if (a_cursed) curse_artifact(o_ptr);
1841
1842         if (!a_cursed &&
1843             one_in_(object_is_armour(o_ptr) ? ACTIVATION_CHANCE * 2 : ACTIVATION_CHANCE))
1844         {
1845                 o_ptr->xtra2 = 0;
1846                 give_activation_power(o_ptr);
1847         }
1848
1849         if (object_is_armour(o_ptr))
1850         {
1851                 while ((o_ptr->to_d+o_ptr->to_h) > 20)
1852                 {
1853                         if (one_in_(o_ptr->to_d) && one_in_(o_ptr->to_h)) break;
1854                         o_ptr->to_d -= (s16b)randint0(3);
1855                         o_ptr->to_h -= (s16b)randint0(3);
1856                 }
1857                 while ((o_ptr->to_d+o_ptr->to_h) > 10)
1858                 {
1859                         if (one_in_(o_ptr->to_d) || one_in_(o_ptr->to_h)) break;
1860                         o_ptr->to_d -= (s16b)randint0(3);
1861                         o_ptr->to_h -= (s16b)randint0(3);
1862                 }
1863         }
1864
1865         if (((artifact_bias == BIAS_MAGE) || (artifact_bias == BIAS_INT)) && (o_ptr->tval == TV_GLOVES)) add_flag(o_ptr->art_flags, TR_FREE_ACT);
1866
1867         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
1868         {
1869                 o_ptr->to_h = 0;
1870                 o_ptr->to_d = 0;
1871                 remove_flag(o_ptr->art_flags, TR_BLOWS);
1872                 remove_flag(o_ptr->art_flags, TR_FORCE_WEAPON);
1873                 remove_flag(o_ptr->art_flags, TR_SLAY_ANIMAL);
1874                 remove_flag(o_ptr->art_flags, TR_SLAY_EVIL);
1875                 remove_flag(o_ptr->art_flags, TR_SLAY_UNDEAD);
1876                 remove_flag(o_ptr->art_flags, TR_SLAY_DEMON);
1877                 remove_flag(o_ptr->art_flags, TR_SLAY_ORC);
1878                 remove_flag(o_ptr->art_flags, TR_SLAY_TROLL);
1879                 remove_flag(o_ptr->art_flags, TR_SLAY_GIANT);
1880                 remove_flag(o_ptr->art_flags, TR_SLAY_DRAGON);
1881                 remove_flag(o_ptr->art_flags, TR_KILL_DRAGON);
1882                 remove_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
1883                 remove_flag(o_ptr->art_flags, TR_VORPAL);
1884                 remove_flag(o_ptr->art_flags, TR_BRAND_POIS);
1885                 remove_flag(o_ptr->art_flags, TR_BRAND_ACID);
1886                 remove_flag(o_ptr->art_flags, TR_BRAND_ELEC);
1887                 remove_flag(o_ptr->art_flags, TR_BRAND_FIRE);
1888                 remove_flag(o_ptr->art_flags, TR_BRAND_COLD);
1889         }
1890
1891         if (!object_is_weapon_ammo(o_ptr))
1892         {
1893                 /* For armors */
1894                 if (a_cursed) power_level = 0;
1895                 else if (total_flags < 15000) power_level = 1;
1896                 else if (total_flags < 35000) power_level = 2;
1897                 else power_level = 3;
1898         }
1899
1900         else
1901         {
1902                 /* For weapons */
1903                 if (a_cursed) power_level = 0;
1904                 else if (total_flags < 20000) power_level = 1;
1905                 else if (total_flags < 45000) power_level = 2;
1906                 else power_level = 3;
1907         }
1908
1909         if (a_scroll)
1910         {
1911                 char dummy_name[80] = "";
1912 #ifdef JP
1913                 cptr ask_msg = "¤³¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ò²¿¤È̾ÉÕ¤±¤Þ¤¹¤«¡©";
1914 #else
1915                 cptr ask_msg = "What do you want to call the artifact? ";
1916 #endif
1917
1918                 /* Identify it fully */
1919                 object_aware(o_ptr);
1920                 object_known(o_ptr);
1921
1922                 /* Mark the item as fully known */
1923                 o_ptr->ident |= (IDENT_MENTAL);
1924
1925                 (void)screen_object(o_ptr, 0L);
1926
1927                 if (!get_string(ask_msg, dummy_name, sizeof dummy_name)
1928                     || !dummy_name[0])
1929                 {
1930                         /* Cancelled */
1931                         if (one_in_(2))
1932                         {
1933                                 get_table_sindarin_aux(dummy_name);
1934                         }
1935                         else
1936                         {
1937                                 get_table_name_aux(dummy_name);
1938                         }
1939                 }
1940
1941 #ifdef JP
1942                 sprintf(new_name, "¡Ô%s¡Õ", dummy_name);
1943 #else
1944                 sprintf(new_name, "'%s'", dummy_name);
1945 #endif
1946
1947                 chg_virtue(V_INDIVIDUALISM, 2);
1948                 chg_virtue(V_ENCHANT, 5);
1949         }
1950         else
1951         {
1952                 get_random_name(new_name, object_is_armour(o_ptr), power_level);
1953         }
1954
1955         if (cheat_xtra)
1956         {
1957 #ifdef JP
1958                 if (artifact_bias) msg_format("±¿¤ÎÊФä¿¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È: %d¡£", artifact_bias);
1959                 else msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ë±¿¤ÎÊФê¤Ê¤·¡£");
1960 #else
1961                 if (artifact_bias) msg_format("Biased artifact: %d.", artifact_bias);
1962                 else msg_print("No bias in artifact.");
1963 #endif
1964         }
1965
1966         /* Save the inscription */
1967         o_ptr->art_name = quark_add(new_name);
1968
1969         /* Window stuff */
1970         p_ptr->window |= (PW_INVEN | PW_EQUIP);
1971
1972         return TRUE;
1973 }
1974
1975
1976 bool activate_random_artifact(object_type *o_ptr)
1977 {
1978         int plev = p_ptr->lev;
1979         int k, dir, dummy = 0;
1980         cptr name = k_name + k_info[o_ptr->k_idx].name;
1981
1982         /* Paranoia */
1983         if (!o_ptr->xtra2) return FALSE;
1984
1985         /* Activate for attack */
1986         switch (o_ptr->xtra2)
1987         {
1988                 case ACT_SUNLIGHT:
1989                 {
1990                         if (!get_aim_dir(&dir)) return FALSE;
1991 #ifdef JP
1992                         msg_print("ÂÀÍÛ¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
1993 #else
1994                         msg_print("A line of sunlight appears.");
1995 #endif
1996                         (void)lite_line(dir);
1997                         o_ptr->timeout = 10;
1998                         break;
1999                 }
2000
2001                 case ACT_BO_MISS_1:
2002                 {
2003 #ifdef JP
2004                         msg_print("¤½¤ì¤ÏâÁ¤·¤¤¤¯¤é¤¤¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2005 #else
2006                         msg_print("It glows extremely brightly...");
2007 #endif
2008                         if (!get_aim_dir(&dir)) return FALSE;
2009                         fire_bolt(GF_MISSILE, dir, damroll(2, 6));
2010                         o_ptr->timeout = 2;
2011                         break;
2012                 }
2013
2014                 case ACT_BA_POIS_1:
2015                 {
2016 #ifdef JP
2017                         msg_print("¤½¤ì¤ÏÇ»Î理Ë̮ư¤·¤Æ¤¤¤ë...");
2018 #else
2019                         msg_print("It throbs deep green...");
2020 #endif
2021                         if (!get_aim_dir(&dir)) return FALSE;
2022                         fire_ball(GF_POIS, dir, 12, 3);
2023                         o_ptr->timeout = randint0(4) + 4;
2024                         break;
2025                 }
2026
2027                 case ACT_BO_ELEC_1:
2028                 {
2029 #ifdef JP
2030                         msg_print("¤½¤ì¤Ï²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
2031 #else
2032                         msg_print("It is covered in sparks...");
2033 #endif
2034                         if (!get_aim_dir(&dir)) return FALSE;
2035                         fire_bolt(GF_ELEC, dir, damroll(4, 8));
2036                         o_ptr->timeout = randint0(5) + 5;
2037                         break;
2038                 }
2039
2040                 case ACT_BO_ACID_1:
2041                 {
2042 #ifdef JP
2043                         msg_print("¤½¤ì¤Ï»À¤Ëʤ¤ï¤ì¤¿...");
2044 #else
2045                         msg_print("It is covered in acid...");
2046 #endif
2047                         if (!get_aim_dir(&dir)) return FALSE;
2048                         fire_bolt(GF_ACID, dir, damroll(5, 8));
2049                         o_ptr->timeout = randint0(6) + 6;
2050                         break;
2051                 }
2052
2053                 case ACT_BO_COLD_1:
2054                 {
2055 #ifdef JP
2056                         msg_print("¤½¤ì¤ÏÁú¤Ëʤ¤ï¤ì¤¿...");
2057 #else
2058                         msg_print("It is covered in frost...");
2059 #endif
2060                         if (!get_aim_dir(&dir)) return FALSE;
2061                         fire_bolt(GF_COLD, dir, damroll(6, 8));
2062                         o_ptr->timeout = randint0(7) + 7;
2063                         break;
2064                 }
2065
2066                 case ACT_BO_FIRE_1:
2067                 {
2068 #ifdef JP
2069                         msg_print("¤½¤ì¤Ï±ê¤Ëʤ¤ï¤ì¤¿...");
2070 #else
2071                         msg_print("It is covered in fire...");
2072 #endif
2073                         if (!get_aim_dir(&dir)) return FALSE;
2074                         fire_bolt(GF_FIRE, dir, damroll(9, 8));
2075                         o_ptr->timeout = randint0(8) + 8;
2076                         break;
2077                 }
2078
2079                 case ACT_BA_COLD_1:
2080                 {
2081 #ifdef JP
2082                         msg_print("¤½¤ì¤ÏÁú¤Ëʤ¤ï¤ì¤¿...");
2083 #else
2084                         msg_print("It is covered in frost...");
2085 #endif
2086                         if (!get_aim_dir(&dir)) return FALSE;
2087                         fire_ball(GF_COLD, dir, 48, 2);
2088                         o_ptr->timeout = randint0(6) + 6;
2089                         break;
2090                 }
2091
2092                 case ACT_BA_FIRE_1:
2093                 {
2094 #ifdef JP
2095                         msg_print("¤½¤ì¤ÏÀÖ¤¯·ã¤·¤¯µ±¤¤¤¿...");
2096 #else
2097                         msg_print("It glows an intense red...");
2098 #endif
2099                         if (!get_aim_dir(&dir)) return FALSE;
2100                         fire_ball(GF_FIRE, dir, 72, 2);
2101                         o_ptr->timeout = randint0(9) + 9;
2102                         break;
2103                 }
2104
2105                 case ACT_DRAIN_1:
2106                 {
2107 #ifdef JP
2108                         msg_format("¤¢¤Ê¤¿¤Ï%s¤ËŨ¤òÄù¤á»¦¤¹¤è¤¦Ì¿¤¸¤¿¡£", name);
2109 #else
2110                         msg_format("You order the %s to strangle your opponent.", name);
2111 #endif
2112                         if (!get_aim_dir(&dir)) return FALSE;
2113                         if (drain_life(dir, 100))
2114                         o_ptr->timeout = randint0(100) + 100;
2115                         break;
2116                 }
2117
2118                 case ACT_BA_COLD_2:
2119                 {
2120 #ifdef JP
2121                         msg_print("¤½¤ì¤ÏÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
2122 #else
2123                         msg_print("It glows an intense blue...");
2124 #endif
2125                         if (!get_aim_dir(&dir)) return FALSE;
2126                         fire_ball(GF_COLD, dir, 100, 2);
2127                         o_ptr->timeout = randint0(12) + 12;
2128                         break;
2129                 }
2130
2131                 case ACT_BA_ELEC_2:
2132                 {
2133 #ifdef JP
2134                         msg_print("Åŵ¤¤¬¥Ñ¥Á¥Ñ¥Á²»¤òΩ¤Æ¤¿...");
2135 #else
2136                         msg_print("It crackles with electricity...");
2137 #endif
2138                         if (!get_aim_dir(&dir)) return FALSE;
2139                         fire_ball(GF_ELEC, dir, 100, 3);
2140                         o_ptr->timeout = randint0(12) + 12;
2141                         break;
2142                 }
2143
2144                 case ACT_BA_FIRE_2:
2145                 {
2146 #ifdef JP
2147                         msg_format("%s¤«¤é±ê¤¬¿á¤­½Ð¤·¤¿...", name);
2148 #else
2149                         msg_format("The %s rages in fire...", name);
2150 #endif
2151                         if (!get_aim_dir(&dir)) return FALSE;
2152                         fire_ball(GF_FIRE, dir, 120, 3);
2153                         o_ptr->timeout = 15;
2154                         break;
2155                 }
2156
2157                 case ACT_DRAIN_2:
2158                 {
2159 #ifdef JP
2160                         msg_print("¹õ¤¯µ±¤¤¤Æ¤¤¤ë...");
2161 #else
2162                         msg_print("It glows black...");
2163 #endif
2164                         if (!get_aim_dir(&dir)) return FALSE;
2165                         drain_life(dir, 120);
2166                         o_ptr->timeout = 400;
2167                         break;
2168                 }
2169
2170                 case ACT_VAMPIRE_1:
2171                 {
2172                         if (!get_aim_dir(&dir)) return FALSE;
2173                         for (dummy = 0; dummy < 3; dummy++)
2174                         {
2175                                 if (drain_life(dir, 50))
2176                                 hp_player(50);
2177                         }
2178                         o_ptr->timeout = 400;
2179                         break;
2180                 }
2181
2182                 case ACT_BO_MISS_2:
2183                 {
2184 #ifdef JP
2185                         msg_print("ËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
2186 #else
2187                         msg_print("It grows magical spikes...");
2188 #endif
2189                         if (!get_aim_dir(&dir)) return FALSE;
2190                         fire_bolt(GF_ARROW, dir, 150);
2191                         o_ptr->timeout = randint0(90) + 90;
2192                         break;
2193                 }
2194
2195                 case ACT_BA_FIRE_3:
2196                 {
2197 #ifdef JP
2198                         msg_print("¿¼ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2199 #else
2200                         msg_print("It glows deep red...");
2201 #endif
2202                         if (!get_aim_dir(&dir)) return FALSE;
2203                         fire_ball(GF_FIRE, dir, 300, 3);
2204                         o_ptr->timeout = randint0(225) + 225;
2205                         break;
2206                 }
2207
2208                 case ACT_BA_COLD_3:
2209                 {
2210 #ifdef JP
2211                         msg_print("ÌÀ¤ë¤¯Çò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2212 #else
2213                         msg_print("It glows bright white...");
2214 #endif
2215                         if (!get_aim_dir(&dir)) return FALSE;
2216                         fire_ball(GF_COLD, dir, 400, 3);
2217                         o_ptr->timeout = randint0(325) + 325;
2218                         break;
2219                 }
2220
2221                 case ACT_BA_ELEC_3:
2222                 {
2223 #ifdef JP
2224                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2225 #else
2226                         msg_print("It glows deep blue...");
2227 #endif
2228                         if (!get_aim_dir(&dir)) return FALSE;
2229                         fire_ball(GF_ELEC, dir, 500, 3);
2230                         o_ptr->timeout = randint0(425) + 425;
2231                         break;
2232                 }
2233
2234                 case ACT_WHIRLWIND:
2235                 {
2236                         {
2237                                 int y = 0, x = 0;
2238                                 cave_type       *c_ptr;
2239                                 monster_type    *m_ptr;
2240
2241                                 for (dir = 0; dir <= 9; dir++)
2242                                 {
2243                                         y = py + ddy[dir];
2244                                         x = px + ddx[dir];
2245                                         c_ptr = &cave[y][x];
2246
2247                                         /* Get the monster */
2248                                         m_ptr = &m_list[c_ptr->m_idx];
2249
2250                                         /* Hack -- attack monsters */
2251                                         if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
2252                                                 py_attack(y, x, 0);
2253                                 }
2254                         }
2255                         o_ptr->timeout = 250;
2256                         break;
2257                 }
2258
2259                 case ACT_VAMPIRE_2:
2260                 {
2261                         if (!get_aim_dir(&dir)) return FALSE;
2262                         for (dummy = 0; dummy < 3; dummy++)
2263                         {
2264                                 if (drain_life(dir, 100))
2265                                 hp_player(100);
2266                         }
2267
2268                         o_ptr->timeout = 400;
2269                         break;
2270                 }
2271
2272
2273                 case ACT_CALL_CHAOS:
2274                 {
2275 #ifdef JP
2276                         msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
2277 #else
2278                         msg_print("It glows in scintillating colours...");
2279 #endif
2280                         call_chaos();
2281                         o_ptr->timeout = 350;
2282                         break;
2283                 }
2284
2285                 case ACT_ROCKET:
2286                 {
2287                         if (!get_aim_dir(&dir)) return FALSE;
2288 #ifdef JP
2289                         msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
2290 #else
2291                         msg_print("You launch a rocket!");
2292 #endif
2293                         fire_ball(GF_ROCKET, dir, 250 + plev*3, 2);
2294                         o_ptr->timeout = 400;
2295                         break;
2296                 }
2297
2298                 case ACT_DISP_EVIL:
2299                 {
2300 #ifdef JP
2301                         msg_print("¿ÀÀ»¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
2302 #else
2303                         msg_print("It floods the area with goodness...");
2304 #endif
2305                         dispel_evil(p_ptr->lev * 5);
2306                         o_ptr->timeout = randint0(100) + 100;
2307                         break;
2308                 }
2309
2310                 case ACT_BA_MISS_3:
2311                 {
2312                         if (!get_aim_dir(&dir)) return FALSE;
2313 #ifdef JP
2314                         msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
2315 #else
2316                         msg_print("You breathe the elements.");
2317 #endif
2318                         fire_ball(GF_MISSILE, dir, 300, 4);
2319                         o_ptr->timeout = 500;
2320                         break;
2321                 }
2322
2323                 case ACT_DISP_GOOD:
2324                 {
2325 #ifdef JP
2326                         msg_print("¼Ù°­¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
2327 #else
2328                         msg_print("It floods the area with evil...");
2329 #endif
2330                         dispel_good(p_ptr->lev * 5);
2331                         o_ptr->timeout = randint0(100) + 100;
2332                         break;
2333                 }
2334
2335                 case ACT_BO_MANA:
2336                 {
2337 #ifdef JP
2338                         msg_format("%s¤ËËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...", name);
2339 #else
2340                         msg_format("The %s grows magical spikes...", name);
2341 #endif
2342                         if (!get_aim_dir(&dir)) return FALSE;
2343                         fire_bolt(GF_ARROW, dir, 150);
2344                         o_ptr->timeout = randint0(90) + 90;
2345                         break;
2346                 }
2347
2348                 case ACT_BA_WATER:
2349                 {
2350 #ifdef JP
2351                         msg_format("%s¤¬¿¼¤¤ÀÄ¿§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...", name);
2352 #else
2353                         msg_format("The %s throbs deep blue...", name);
2354 #endif
2355                         if (!get_aim_dir(&dir)) return FALSE;
2356                         fire_ball(GF_WATER, dir, 200, 3);
2357                         o_ptr->timeout = 250;
2358                         break;
2359                 }
2360
2361                 case ACT_BA_DARK:
2362                 {
2363 #ifdef JP
2364                         msg_format("%s¤¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...", name);
2365 #else
2366                         msg_format("The %s is coverd in pitch-darkness...", name);
2367 #endif
2368                         if (!get_aim_dir(&dir)) return FALSE;
2369                         fire_ball(GF_DARK, dir, 250, 4);
2370                         o_ptr->timeout = randint0(150) + 150;
2371                         break;
2372                 }
2373
2374                 case ACT_BA_MANA:
2375                 {
2376 #ifdef JP
2377                         msg_format("%s¤¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥", name);
2378 #else
2379                         msg_format("The %s glows pale...", name);
2380 #endif
2381                         if (!get_aim_dir(&dir)) return FALSE;
2382                         fire_ball(GF_MANA, dir, 400, 4);
2383                         o_ptr->timeout = randint0(250) + 250;
2384                         break;
2385                 }
2386
2387                 case ACT_PESTICIDE:
2388                 {
2389 #ifdef JP
2390                         msg_print("¤¢¤Ê¤¿¤Ï³²Ãî¤ò°ìÁݤ·¤¿¡£");
2391 #else
2392                         msg_print("You exterminate small life.");
2393 #endif
2394                         (void)dispel_monsters(4);
2395                         o_ptr->timeout = randint0(55) + 55;
2396                         break;
2397                 }
2398
2399                 case ACT_BLINDING_LIGHT:
2400                 {
2401 #ifdef JP
2402                         msg_format("%s¤¬âÁ¤·¤¤¸÷¤Çµ±¤¤¤¿...", name);
2403 #else
2404                         msg_format("The %s gleams with blinding light...", name);
2405 #endif
2406                         fire_ball(GF_LITE, 0, 300, 6);
2407                         confuse_monsters(3 * p_ptr->lev / 2);
2408                         o_ptr->timeout = 250;
2409                         break;
2410                 }
2411
2412                 /* Activate for other offensive action */
2413
2414                 case ACT_CONFUSE:
2415                 {
2416 #ifdef JP
2417                         msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
2418 #else
2419                         msg_print("It glows in scintillating colours...");
2420 #endif
2421                         if (!get_aim_dir(&dir)) return FALSE;
2422                         confuse_monster(dir, 20);
2423                         o_ptr->timeout = 15;
2424                         break;
2425                 }
2426
2427                 case ACT_SLEEP:
2428                 {
2429 #ifdef JP
2430                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2431 #else
2432                         msg_print("It glows deep blue...");
2433 #endif
2434                         sleep_monsters_touch();
2435                         o_ptr->timeout = 55;
2436                         break;
2437                 }
2438
2439                 case ACT_QUAKE:
2440                 {
2441                         earthquake(py, px, 10);
2442                         o_ptr->timeout = 50;
2443                         break;
2444                 }
2445
2446                 case ACT_TERROR:
2447                 {
2448                         turn_monsters(40 + p_ptr->lev);
2449                         o_ptr->timeout = 3 * (p_ptr->lev + 10);
2450                         break;
2451                 }
2452
2453                 case ACT_TELE_AWAY:
2454                 {
2455                         if (!get_aim_dir(&dir)) return FALSE;
2456                         (void)fire_beam(GF_AWAY_ALL, dir, plev);
2457                         o_ptr->timeout = 200;
2458                         break;
2459                 }
2460
2461                 case ACT_BANISH_EVIL:
2462                 {
2463                         if (banish_evil(100))
2464                         {
2465 #ifdef JP
2466                                 msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÎϤ¬¼Ù°­¤òÂǤÁʧ¤Ã¤¿¡ª");
2467 #else
2468                                 msg_print("The power of the artifact banishes evil!");
2469 #endif
2470                         }
2471                         o_ptr->timeout = 250 + randint1(250);
2472                         break;
2473                 }
2474
2475                 case ACT_GENOCIDE:
2476                 {
2477 #ifdef JP
2478                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2479 #else
2480                         msg_print("It glows deep blue...");
2481 #endif
2482                         (void)symbol_genocide(200, TRUE);
2483                         o_ptr->timeout = 500;
2484                         break;
2485                 }
2486
2487                 case ACT_MASS_GENO:
2488                 {
2489 #ifdef JP
2490                         msg_print("¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
2491 #else
2492                         msg_print("It lets out a long, shrill note...");
2493 #endif
2494                         (void)mass_genocide(200, TRUE);
2495                         o_ptr->timeout = 1000;
2496                         break;
2497                 }
2498
2499                 /* Activate for summoning / charming */
2500
2501                 case ACT_CHARM_ANIMAL:
2502                 {
2503                         if (!get_aim_dir(&dir)) return FALSE;
2504                         (void)charm_animal(dir, plev * 2);
2505                         o_ptr->timeout = 200;
2506                         break;
2507                 }
2508
2509                 case ACT_CHARM_UNDEAD:
2510                 {
2511                         if (!get_aim_dir(&dir)) return FALSE;
2512                         (void)control_one_undead(dir, plev * 2);
2513                         o_ptr->timeout = 333;
2514                         break;
2515                 }
2516
2517                 case ACT_CHARM_OTHER:
2518                 {
2519                         if (!get_aim_dir(&dir)) return FALSE;
2520                         (void)charm_monster(dir, plev * 2);
2521                         o_ptr->timeout = 400;
2522                         break;
2523                 }
2524
2525                 case ACT_CHARM_ANIMALS:
2526                 {
2527                         (void)charm_animals(plev * 2);
2528                         o_ptr->timeout = 500;
2529                         break;
2530                 }
2531
2532                 case ACT_CHARM_OTHERS:
2533                 {
2534                         charm_monsters(plev * 2);
2535                         o_ptr->timeout = 750;
2536                         break;
2537                 }
2538
2539                 case ACT_SUMMON_ANIMAL:
2540                 {
2541                         (void)summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET));
2542                         o_ptr->timeout = 200 + randint1(300);
2543                         break;
2544                 }
2545
2546                 case ACT_SUMMON_PHANTOM:
2547                 {
2548 #ifdef JP
2549                         msg_print("¸¸Îî¤ò¾¤´­¤·¤¿¡£");
2550 #else
2551                         msg_print("You summon a phantasmal servant.");
2552 #endif
2553                         (void)summon_specific(-1, py, px, dun_level, SUMMON_PHANTOM, (PM_ALLOW_GROUP | PM_FORCE_PET));
2554                         o_ptr->timeout = 200 + randint1(200);
2555                         break;
2556                 }
2557
2558                 case ACT_SUMMON_ELEMENTAL:
2559                 {
2560                         bool pet = one_in_(3);
2561                         u32b mode = 0L;
2562
2563                         if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
2564                         if (pet) mode |= PM_FORCE_PET;
2565                         else mode |= PM_NO_PET;
2566
2567                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, mode))
2568                         {
2569 #ifdef JP
2570                                 msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿...");
2571 #else
2572                                 msg_print("An elemental materializes...");
2573 #endif
2574                                 if (pet)
2575 #ifdef JP
2576                                         msg_print("¤¢¤Ê¤¿¤ËÉþ½¾¤·¤Æ¤¤¤ë¤è¤¦¤À¡£");
2577 #else
2578                                         msg_print("It seems obedient to you.");
2579 #endif
2580                                 else
2581 #ifdef JP
2582                                         msg_print("¤½¤ì¤ò¥³¥ó¥È¥í¡¼¥ë¤Ç¤­¤Ê¤«¤Ã¤¿¡ª");
2583 #else
2584                                         msg_print("You fail to control it!");
2585 #endif
2586                         }
2587
2588                         o_ptr->timeout = 750;
2589                         break;
2590                 }
2591
2592                 case ACT_SUMMON_DEMON:
2593                 {
2594                         bool pet = one_in_(3);
2595                         u32b mode = 0L;
2596
2597                         if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
2598                         if (pet) mode |= PM_FORCE_PET;
2599                         else mode |= PM_NO_PET;
2600
2601                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, mode))
2602                         {
2603 #ifdef JP
2604                                 msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
2605 #else
2606                                 msg_print("The area fills with a stench of sulphur and brimstone.");
2607 #endif
2608                                 if (pet)
2609 #ifdef JP
2610                                         msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
2611 #else
2612                                         msg_print("'What is thy bidding... Master?'");
2613 #endif
2614                                 else
2615 #ifdef JP
2616                                         msg_print("¡ÖNON SERVIAM! Wretch! ¤ªÁ°¤Îº²¤òĺ¤¯¤¾¡ª¡×");
2617 #else
2618                                         msg_print("'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'");
2619 #endif
2620                         }
2621
2622                         o_ptr->timeout = 666 + randint1(333);
2623                         break;
2624                 }
2625
2626                 case ACT_SUMMON_UNDEAD:
2627                 {
2628                         bool pet = one_in_(3);
2629                         int type;
2630                         u32b mode = 0L;
2631
2632                         type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
2633
2634                         if (!pet || ((plev > 24) && one_in_(3))) mode |= PM_ALLOW_GROUP;
2635                         if (pet) mode |= PM_FORCE_PET;
2636                         else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2637
2638                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), type, mode))
2639                         {
2640 #ifdef JP
2641                                 msg_print("Î䤿¤¤É÷¤¬¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¿á¤­»Ï¤á¤¿¡£¤½¤ì¤ÏÉåÇÔ½­¤ò±¿¤ó¤Ç¤¤¤ë...");
2642 #else
2643                                 msg_print("Cold winds begin to blow around you, carrying with them the stench of decay...");
2644 #endif
2645                                 if (pet)
2646 #ifdef JP
2647                                         msg_print("¸Å¤¨¤Î»à¤»¤ë¼Ô¶¦¤¬¤¢¤Ê¤¿¤Ë»Å¤¨¤ë¤¿¤áÅÚ¤«¤éᴤä¿¡ª");
2648 #else
2649                                         msg_print("Ancient, long-dead forms arise from the ground to serve you!");
2650 #endif
2651                                 else
2652 #ifdef JP
2653                                         msg_print("»à¼Ô¤¬á´¤Ã¤¿¡£Ì²¤ê¤ò˸¤²¤ë¤¢¤Ê¤¿¤òȳ¤¹¤ë¤¿¤á¤Ë¡ª");
2654 #else
2655                                         msg_print("'The dead arise... to punish you for disturbing them!'");
2656 #endif
2657                         }
2658
2659                         o_ptr->timeout = 666 + randint1(333);
2660                         break;
2661                 }
2662
2663                 case ACT_SUMMON_HOUND:
2664                 {
2665                         u32b mode = PM_ALLOW_GROUP;
2666                         bool pet = !one_in_(5);
2667                         if (pet) mode |= PM_FORCE_PET;
2668                         else mode |= PM_NO_PET;
2669
2670                         if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
2671                         {
2672
2673                                 if (pet)
2674 #ifdef JP
2675                                         msg_print("¥Ï¥¦¥ó¥É¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
2676 #else
2677                                 msg_print("A group of hounds appear as your servant.");
2678 #endif
2679
2680                                 else
2681 #ifdef JP
2682                                         msg_print("¥Ï¥¦¥ó¥É¤Ï¤¢¤Ê¤¿¤Ë²ç¤ò¸þ¤±¤Æ¤¤¤ë¡ª");
2683 #else
2684                                         msg_print("A group of hounds appear as your enemy!");
2685 #endif
2686
2687                         }
2688
2689                         o_ptr->timeout = 300 + randint1(150);
2690                         break;
2691                 }
2692
2693                 /* Activate for healing */
2694
2695                 case ACT_CHOIR_SINGS:
2696                 {
2697 #ifdef JP
2698                         msg_print("Å·¹ñ¤Î²Î¤¬Ê¹¤³¤¨¤ë...");
2699 #else
2700                         msg_print("A heavenly choir sings...");
2701 #endif
2702                         (void)set_poisoned(0);
2703                         (void)set_cut(0);
2704                         (void)set_stun(0);
2705                         (void)set_confused(0);
2706                         (void)set_blind(0);
2707                         (void)set_afraid(0);
2708                         (void)set_hero(randint1(25) + 25, FALSE);
2709                         (void)hp_player(777);
2710                         o_ptr->timeout = 300;
2711                         break;
2712                 }
2713
2714                 case ACT_CURE_LW:
2715                 {
2716                         (void)set_afraid(0);
2717                         (void)hp_player(30);
2718                         o_ptr->timeout = 10;
2719                         break;
2720                 }
2721
2722                 case ACT_CURE_MW:
2723                 {
2724 #ifdef JP
2725                         msg_print("¿¼»ç¿§¤Î¸÷¤òȯ¤·¤Æ¤¤¤ë...");
2726 #else
2727                         msg_print("It radiates deep purple...");
2728 #endif
2729                         hp_player(damroll(4, 8));
2730                         (void)set_cut((p_ptr->cut / 2) - 50);
2731                         o_ptr->timeout = randint0(3) + 3;
2732                         break;
2733                 }
2734
2735                 case ACT_CURE_POISON:
2736                 {
2737 #ifdef JP
2738                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2739 #else
2740                         msg_print("It glows deep blue...");
2741 #endif
2742                         (void)set_afraid(0);
2743                         (void)set_poisoned(0);
2744                         o_ptr->timeout = 5;
2745                         break;
2746                 }
2747
2748                 case ACT_REST_LIFE:
2749                 {
2750 #ifdef JP
2751                         msg_print("¿¼¹È¤Ëµ±¤¤¤Æ¤¤¤ë...");
2752 #else
2753                         msg_print("It glows a deep red...");
2754 #endif
2755                         restore_level();
2756                         o_ptr->timeout = 450;
2757                         break;
2758                 }
2759
2760                 case ACT_REST_ALL:
2761                 {
2762 #ifdef JP
2763                         msg_print("Ç»Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2764 #else
2765                         msg_print("It glows a deep green...");
2766 #endif
2767                         (void)do_res_stat(A_STR);
2768                         (void)do_res_stat(A_INT);
2769                         (void)do_res_stat(A_WIS);
2770                         (void)do_res_stat(A_DEX);
2771                         (void)do_res_stat(A_CON);
2772                         (void)do_res_stat(A_CHR);
2773                         (void)restore_level();
2774                         o_ptr->timeout = 750;
2775                         break;
2776                 }
2777
2778                 case ACT_CURE_700:
2779                 {
2780 #ifdef JP
2781                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2782                         msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
2783 #else
2784                         msg_print("It glows deep blue...");
2785                         msg_print("You feel a warm tingling inside...");
2786 #endif
2787                         (void)hp_player(700);
2788                         (void)set_cut(0);
2789                         o_ptr->timeout = 250;
2790                         break;
2791                 }
2792
2793                 case ACT_CURE_1000:
2794                 {
2795 #ifdef JP
2796                         msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2797                         msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
2798 #else
2799                         msg_print("It glows a bright white...");
2800                         msg_print("You feel much better...");
2801 #endif
2802                         (void)hp_player(1000);
2803                         (void)set_cut(0);
2804                         o_ptr->timeout = 888;
2805                         break;
2806                 }
2807
2808                 case ACT_CURING:
2809                 {
2810 #ifdef JP
2811                         msg_format("%s¤ÎÍ¥¤·¤µ¤ËÌþ¤µ¤ì¤ë...", name);
2812 #else
2813                         msg_format("the %s cures you affectionately ...", name);
2814 #endif
2815                         (void)set_poisoned(0);
2816                         (void)set_confused(0);
2817                         (void)set_blind(0);
2818                         (void)set_stun(0);
2819                         (void)set_cut(0);
2820                         (void)set_image(0);
2821
2822                         o_ptr->timeout = 100;
2823                         break;
2824                 }
2825
2826                 case ACT_CURE_MANA_FULL:
2827                 {
2828 #ifdef JP
2829                         msg_format("%s¤¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥", name);
2830 #else
2831                         msg_format("The %s glows pale...", name);
2832 #endif
2833                         if (p_ptr->pclass == CLASS_MAGIC_EATER)
2834                         {
2835                                 int i;
2836                                 for (i = 0; i < EATER_EXT*2; i++)
2837                                 {
2838                                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
2839                                         if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
2840                                 }
2841                                 for (; i < EATER_EXT*3; i++)
2842                                 {
2843                                         int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
2844                                         p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE*3 : p_ptr->magic_num2[i]*EATER_ROD_CHARGE/3)*k_info[k_idx].pval;
2845                                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
2846                                 }
2847 #ifdef JP
2848                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
2849 #else
2850                                 msg_print("You feel your head clear.");
2851 #endif
2852                                 p_ptr->window |= (PW_PLAYER);
2853                         }
2854                         else if (p_ptr->csp < p_ptr->msp)
2855                         {
2856                                 p_ptr->csp = p_ptr->msp;
2857                                 p_ptr->csp_frac = 0;
2858 #ifdef JP
2859                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
2860 #else
2861                                 msg_print("You feel your head clear.");
2862 #endif
2863                                 p_ptr->redraw |= (PR_MANA);
2864                                 p_ptr->window |= (PW_PLAYER);
2865                                 p_ptr->window |= (PW_SPELL);
2866                         }
2867                         o_ptr->timeout = 777;
2868                         break;
2869                 }
2870
2871                 /* Activate for timed effect */
2872
2873                 case ACT_ESP:
2874                 {
2875                         (void)set_tim_esp(randint1(30) + 25, FALSE);
2876                         o_ptr->timeout = 200;
2877                         break;
2878                 }
2879
2880                 case ACT_BERSERK:
2881                 {
2882                         (void)set_afraid(0);
2883                         (void)set_hero(randint1(50) + 50, FALSE);
2884                         (void)set_blessed(randint1(50) + 50, FALSE);
2885                         o_ptr->timeout = 100 + randint1(100);
2886                         break;
2887                 }
2888
2889                 case ACT_PROT_EVIL:
2890                 {
2891 #ifdef JP
2892                         msg_format("%s¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...", name);
2893 #else
2894                         msg_format("The %s lets out a shrill wail...", name);
2895 #endif
2896                         k = 3 * p_ptr->lev;
2897                         (void)set_protevil(randint1(25) + k, FALSE);
2898                         o_ptr->timeout = randint0(200) + 200;
2899                         break;
2900                 }
2901
2902                 case ACT_RESIST_ALL:
2903                 {
2904 #ifdef JP
2905                         msg_print("ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2906 #else
2907                         msg_print("It glows many colours...");
2908 #endif
2909                         (void)set_oppose_acid(randint1(40) + 40, FALSE);
2910                         (void)set_oppose_elec(randint1(40) + 40, FALSE);
2911                         (void)set_oppose_fire(randint1(40) + 40, FALSE);
2912                         (void)set_oppose_cold(randint1(40) + 40, FALSE);
2913                         (void)set_oppose_pois(randint1(40) + 40, FALSE);
2914                         o_ptr->timeout = 200;
2915                         break;
2916                 }
2917
2918                 case ACT_SPEED:
2919                 {
2920 #ifdef JP
2921                         msg_print("ÌÀ¤ë¤¯Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2922 #else
2923                         msg_print("It glows bright green...");
2924 #endif
2925                         (void)set_fast(randint1(20) + 20, FALSE);
2926                         o_ptr->timeout = randint0(100) + 100;
2927                         break;
2928                 }
2929
2930                 case ACT_XTRA_SPEED:
2931                 {
2932 #ifdef JP
2933                         msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2934 #else
2935                         msg_print("It glows brightly...");
2936 #endif
2937                         (void)set_fast(randint1(75) + 75, FALSE);
2938                         o_ptr->timeout = randint0(100) + 100;
2939                         break;
2940                 }
2941
2942                 case ACT_WRAITH:
2943                 {
2944                         set_wraith_form(randint1(plev / 2) + (plev / 2), FALSE);
2945                         o_ptr->timeout = 1000;
2946                         break;
2947                 }
2948
2949                 case ACT_INVULN:
2950                 {
2951                         (void)set_invuln(randint1(8) + 8, FALSE);
2952                         o_ptr->timeout = 1000;
2953                         break;
2954                 }
2955
2956                 case ACT_HELO:
2957                 {
2958                         (void)set_afraid(0);
2959                         set_hero(randint1(25)+25, FALSE);
2960                         hp_player(10);
2961                         o_ptr->timeout = randint0(30) + 30;
2962                         break;
2963                 }
2964
2965                 case ACT_HELO_SPEED:
2966                 {
2967                         (void)set_fast(randint1(50) + 50, FALSE);
2968                         hp_player(10);
2969                         set_afraid(0);
2970                         set_hero(randint1(50) + 50, FALSE);
2971                         o_ptr->timeout = randint0(200) + 100;
2972                         break;
2973                 }
2974
2975                 case ACT_RESIST_ACID:
2976                 {
2977 #ifdef JP
2978                         msg_format("%s¤¬¹õ¤¯µ±¤¤¤¿...", name);
2979 #else
2980                         msg_format("The %s grows black.", name);
2981 #endif
2982                         (void)set_oppose_acid(randint1(20) + 20, FALSE);
2983                         o_ptr->timeout = 40 + randint1(40);
2984                         break;
2985                 }
2986
2987                 case ACT_RESIST_FIRE:
2988                 {
2989 #ifdef JP
2990                         msg_format("%s¤¬ÀÖ¤¯µ±¤¤¤¿...", name);
2991 #else
2992                         msg_format("The %s grows red.", name);
2993 #endif
2994                         (void)set_oppose_fire(randint1(20) + 20, FALSE);
2995                         o_ptr->timeout = 40 + randint1(40);
2996                         break;
2997                 }
2998
2999                 case ACT_RESIST_COLD:
3000                 {
3001 #ifdef JP
3002                         msg_format("%s¤¬Çò¤¯µ±¤¤¤¿...", name);
3003 #else
3004                         msg_format("The %s grows white.", name);
3005 #endif
3006                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
3007                         o_ptr->timeout = 40 + randint1(40);
3008                         break;
3009                 }
3010
3011                 case ACT_RESIST_ELEC:
3012                 {
3013 #ifdef JP
3014                         msg_format("%s¤¬ÀĤ¯µ±¤¤¤¿...", name);
3015 #else
3016                         msg_format("The %s grows blue.", name);
3017 #endif
3018                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
3019                         o_ptr->timeout = 40 + randint1(40);
3020                         break;
3021                 }
3022
3023                 case ACT_RESIST_POIS:
3024                 {
3025 #ifdef JP
3026                         msg_format("%s¤¬ÎФ˵±¤¤¤¿...", name);
3027 #else
3028                         msg_format("The %s grows green.", name);
3029 #endif
3030                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
3031                         o_ptr->timeout = 40 + randint1(40);
3032                         break;
3033                 }
3034
3035                 /* Activate for general purpose effect (detection etc.) */
3036
3037                 case ACT_LIGHT:
3038                 {
3039 #ifdef JP
3040                         msg_format("%s¤«¤éÀ¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...", name);
3041 #else
3042                         msg_format("The %s wells with clear light...", name);
3043 #endif
3044                         lite_area(damroll(2, 15), 3);
3045                         o_ptr->timeout = randint0(10) + 10;
3046                         break;
3047                 }
3048
3049                 case ACT_MAP_LIGHT:
3050                 {
3051 #ifdef JP
3052                         msg_print("âÁ¤·¤¯µ±¤¤¤¿...");
3053 #else
3054                         msg_print("It shines brightly...");
3055 #endif
3056                         map_area(DETECT_RAD_MAP);
3057                         lite_area(damroll(2, 15), 3);
3058                         o_ptr->timeout = randint0(50) + 50;
3059                         break;
3060                 }
3061
3062                 case ACT_DETECT_ALL:
3063                 {
3064 #ifdef JP
3065                         msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
3066                         msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
3067 #else
3068                         msg_print("It glows bright white...");
3069                         msg_print("An image forms in your mind...");
3070 #endif
3071                         detect_all(DETECT_RAD_DEFAULT);
3072                         o_ptr->timeout = randint0(55) + 55;
3073                         break;
3074                 }
3075
3076                 case ACT_DETECT_XTRA:
3077                 {
3078 #ifdef JP
3079                         msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
3080 #else
3081                         msg_print("It glows brightly...");
3082 #endif
3083                         detect_all(DETECT_RAD_DEFAULT);
3084                         probing();
3085                         identify_fully(FALSE);
3086                         o_ptr->timeout = 100;
3087                         break;
3088                 }
3089
3090                 case ACT_ID_FULL:
3091                 {
3092 #ifdef JP
3093                         msg_print("²«¿§¤¯µ±¤¤¤Æ¤¤¤ë...");
3094 #else
3095                         msg_print("It glows yellow...");
3096 #endif
3097                         identify_fully(FALSE);
3098                         o_ptr->timeout = 75;
3099                         break;
3100                 }
3101
3102                 case ACT_ID_PLAIN:
3103                 {
3104                         if (!ident_spell(FALSE)) return FALSE;
3105                         o_ptr->timeout = 10;
3106                         break;
3107                 }
3108
3109                 case ACT_RUNE_EXPLO:
3110                 {
3111 #ifdef JP
3112                         msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
3113 #else
3114                         msg_print("It glows bright red...");
3115 #endif
3116                         explosive_rune();
3117                         o_ptr->timeout = 200;
3118                         break;
3119                 }
3120
3121                 case ACT_RUNE_PROT:
3122                 {
3123 #ifdef JP
3124                         msg_print("¥Ö¥ë¡¼¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
3125 #else
3126                         msg_print("It glows light blue...");
3127 #endif
3128                         warding_glyph();
3129                         o_ptr->timeout = 400;
3130                         break;
3131                 }
3132
3133                 case ACT_SATIATE:
3134                 {
3135                         (void)set_food(PY_FOOD_MAX - 1);
3136                         o_ptr->timeout = 200;
3137                         break;
3138                 }
3139
3140                 case ACT_DEST_DOOR:
3141                 {
3142 #ifdef JP
3143                         msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
3144 #else
3145                         msg_print("It glows bright red...");
3146 #endif
3147                         destroy_doors_touch();
3148                         o_ptr->timeout = 10;
3149                         break;
3150                 }
3151
3152                 case ACT_STONE_MUD:
3153                 {
3154 #ifdef JP
3155                         msg_print("¸ÝÆ°¤·¤Æ¤¤¤ë...");
3156 #else
3157                         msg_print("It pulsates...");
3158 #endif
3159                         if (!get_aim_dir(&dir)) return FALSE;
3160                         wall_to_mud(dir);
3161                         o_ptr->timeout = 3;
3162                         break;
3163                 }
3164
3165                 case ACT_RECHARGE:
3166                 {
3167                         recharge(130);
3168                         o_ptr->timeout = 70;
3169                         break;
3170                 }
3171
3172                 case ACT_ALCHEMY:
3173                 {
3174 #ifdef JP
3175                         msg_print("ÌÀ¤ë¤¤²«¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
3176 #else
3177                         msg_print("It glows bright yellow...");
3178 #endif
3179                         (void)alchemy();
3180                         o_ptr->timeout = 500;
3181                         break;
3182                 }
3183
3184                 case ACT_DIM_DOOR:
3185                 {
3186 #ifdef JP
3187                         msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
3188 #else
3189                         msg_print("You open a dimensional gate. Choose a destination.");
3190 #endif
3191                         if (!dimension_door()) return FALSE;
3192                         o_ptr->timeout = 100;
3193                         break;
3194                 }
3195
3196
3197                 case ACT_TELEPORT:
3198                 {
3199 #ifdef JP
3200                         msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ë...");
3201 #else
3202                         msg_print("It twists space around you...");
3203 #endif
3204                         teleport_player(100, 0L);
3205                         o_ptr->timeout = 25;
3206                         break;
3207                 }
3208
3209                 case ACT_RECALL:
3210                 {
3211 #ifdef JP
3212                         msg_print("¤ä¤ï¤é¤«¤ÊÇò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
3213 #else
3214                         msg_print("It glows soft white...");
3215 #endif
3216                         if (!word_of_recall()) return FALSE;
3217                         o_ptr->timeout = 200;
3218                         break;
3219                 }
3220
3221                 case ACT_TELEKINESIS:
3222                 {
3223                         if (!get_aim_dir(&dir)) return FALSE;
3224 #ifdef JP
3225                         msg_format("%s¤ò¿­¤Ð¤·¤¿¡£", name);
3226 #else
3227                         msg_format("You stretched your %s.", name);
3228 #endif
3229                         fetch(dir, 500, TRUE);
3230                         o_ptr->timeout = randint0(25) + 25;
3231                         break;
3232                 }
3233
3234                 /* Unique activation */
3235                 case ACT_BRAND_FIRE_BOLTS:
3236                 {
3237 #ifdef JP
3238                         msg_format("%s¤¬¿¼¹È¤Ëµ±¤¤¤¿...", name);
3239 #else
3240                         msg_format("Your %s glows deep red...", name);
3241 #endif
3242                         (void)brand_bolts();
3243                         o_ptr->timeout = 999;
3244                         break;
3245                 }
3246
3247                 case ACT_JUDGE:
3248                 {
3249 #ifdef JP
3250                         msg_format("%s¤ÏÀÖ¤¯ÌÀ¤ë¤¯¸÷¤Ã¤¿¡ª", name);
3251 #else
3252                         msg_format("The %s flashes bright red!", name);
3253 #endif
3254                         chg_virtue(V_KNOWLEDGE, 1);
3255                         chg_virtue(V_ENLIGHTEN, 1);
3256                         wiz_lite(FALSE);
3257 #ifdef JP
3258                         msg_format("%s¤Ï¤¢¤Ê¤¿¤ÎÂÎÎϤòÃ¥¤Ã¤¿...", name);
3259                         take_hit(DAMAGE_LOSELIFE, damroll(3,8), "¿³È½¤ÎÊõÀÐ", -1);
3260 #else
3261                         msg_format("The %s drains your vitality...", name);
3262                         take_hit(DAMAGE_LOSELIFE, damroll(3, 8), "the Jewel of Judgement", -1);
3263 #endif
3264                         (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
3265                         (void)detect_doors(DETECT_RAD_DEFAULT);
3266                         (void)detect_stairs(DETECT_RAD_DEFAULT);
3267 #ifdef JP
3268                         if (get_check("µ¢´Ô¤ÎÎϤò»È¤¤¤Þ¤¹¤«¡©"))
3269 #else
3270                         if (get_check("Activate recall? "))
3271 #endif
3272                         {
3273                                 (void)word_of_recall();
3274                         }
3275
3276                         o_ptr->timeout = randint0(20) + 20;
3277                         break;
3278                 }
3279
3280                 case ACT_BIZARRE:
3281                 {
3282 #ifdef JP
3283                         msg_format("%s¤Ï¼¿¹õ¤Ëµ±¤¤¤¿...", name);
3284 #else
3285                         msg_format("The %s glows intensely black...", name);
3286 #endif
3287                         if (!get_aim_dir(&dir)) return FALSE;
3288                         ring_of_power(dir);
3289                         o_ptr->timeout = randint0(450) + 450;
3290                         break;
3291                 }
3292
3293                 case ACT_DETECT_UNIQUE:
3294                 {
3295                         int i;
3296                         monster_type *m_ptr;
3297                         monster_race *r_ptr;
3298 #ifdef JP
3299                         msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
3300 #else
3301                         msg_print("Some strange places show up in your mind. And you see ...");
3302 #endif
3303                         /* Process the monsters (backwards) */
3304                         for (i = m_max - 1; i >= 1; i--)
3305                         {
3306                                 /* Access the monster */
3307                                 m_ptr = &m_list[i];
3308
3309                                 /* Ignore "dead" monsters */
3310                                 if (!m_ptr->r_idx) continue;
3311
3312                                 r_ptr = &r_info[m_ptr->r_idx];
3313
3314                                 if(r_ptr->flags1 & RF1_UNIQUE)
3315                                 {
3316 #ifdef JP
3317                                         msg_format("%s¡¥ ",r_name + r_ptr->name);
3318 #else
3319                                         msg_format("%s. ",r_name + r_ptr->name);
3320 #endif
3321                                 }
3322                         }
3323                         o_ptr->timeout = 200;
3324                         break;
3325                 }
3326
3327                 default:
3328                 {
3329 #ifdef JP
3330                         msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
3331 #else
3332                         msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
3333 #endif
3334                         return FALSE;
3335                 }
3336         }
3337
3338         return TRUE;
3339 }
3340
3341
3342 void get_bloody_moon_flags(object_type *o_ptr)
3343 {
3344         int dummy, i;
3345
3346         for (i = 0; i < TR_FLAG_SIZE; i++)
3347                 o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
3348
3349         dummy = randint1(2) + randint1(2);
3350         for (i = 0; i < dummy; i++)
3351         {
3352                 int flag = randint0(26);
3353                 if (flag >= 20) add_flag(o_ptr->art_flags, TR_KILL_UNDEAD + flag - 20);
3354                 else if (flag == 19) add_flag(o_ptr->art_flags, TR_KILL_ANIMAL);
3355                 else if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
3356                 else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
3357         }
3358
3359         dummy = randint1(2);
3360         for (i = 0; i < dummy; i++) one_resistance(o_ptr);
3361
3362         for (i = 0; i < 2; i++)
3363         {
3364                 int tmp = randint0(11);
3365                 if (tmp < 6) add_flag(o_ptr->art_flags, TR_STR + tmp);
3366                 else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
3367         }
3368 }
3369
3370
3371 void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr)
3372 {
3373         bool give_resistance = FALSE, give_power = FALSE;
3374
3375         if (o_ptr->name1 == ART_TERROR) /* Terror Mask is for warriors... */
3376         {
3377                 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_ARCHER || p_ptr->pclass == CLASS_CAVALRY || p_ptr->pclass == CLASS_BERSERKER)
3378                 {
3379                         give_power = TRUE;
3380                         give_resistance = TRUE;
3381                 }
3382                 else
3383                 {
3384                         add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3385                         add_flag(o_ptr->art_flags, TR_TY_CURSE);
3386                         o_ptr->curse_flags |=
3387                             (TRC_CURSED | TRC_HEAVY_CURSE);
3388                         o_ptr->curse_flags |= get_curse(2, o_ptr);
3389                         return;
3390                 }
3391         }
3392
3393         if (o_ptr->name1 == ART_MURAMASA)
3394         {
3395                 if (p_ptr->pclass != CLASS_SAMURAI)
3396                 {
3397                         add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3398                         o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3399                 }
3400         }
3401
3402         if (o_ptr->name1 == ART_XIAOLONG)
3403         {
3404                 if (p_ptr->pclass == CLASS_MONK)
3405                         add_flag(o_ptr->art_flags, TR_BLOWS);
3406         }
3407
3408         if (o_ptr->name1 == ART_BLOOD)
3409         {
3410                 get_bloody_moon_flags(o_ptr);
3411         }
3412
3413         if (o_ptr->name1 == ART_HEAVENLY_MAIDEN)
3414         {
3415                 if (p_ptr->psex != SEX_FEMALE)
3416                 {
3417                         add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3418                 }
3419         }
3420
3421         if (a_ptr->gen_flags & (TRG_XTRA_POWER)) give_power = TRUE;
3422         if (a_ptr->gen_flags & (TRG_XTRA_H_RES)) give_resistance = TRUE;
3423         if (a_ptr->gen_flags & (TRG_XTRA_RES_OR_POWER))
3424         {
3425                 /* Give a resistance OR a power */
3426                 if (one_in_(2)) give_resistance = TRUE;
3427                 else give_power = TRUE;
3428         }
3429
3430         if (give_power)
3431         {
3432                 one_ability(o_ptr);
3433         }
3434
3435         if (give_resistance)
3436         {
3437                 one_high_resistance(o_ptr);
3438         }
3439 }
3440
3441
3442 /*
3443  * Create the artifact of the specified number
3444  */
3445 bool create_named_art(int a_idx, int y, int x)
3446 {
3447         object_type forge;
3448         object_type *q_ptr;
3449         int i;
3450
3451         artifact_type *a_ptr = &a_info[a_idx];
3452
3453         /* Get local object */
3454         q_ptr = &forge;
3455
3456         /* Ignore "empty" artifacts */
3457         if (!a_ptr->name) return FALSE;
3458
3459         /* Acquire the "kind" index */
3460         i = lookup_kind(a_ptr->tval, a_ptr->sval);
3461
3462         /* Oops */
3463         if (!i) return FALSE;
3464
3465         /* Create the artifact */
3466         object_prep(q_ptr, i);
3467
3468         /* Save the name */
3469         q_ptr->name1 = a_idx;
3470
3471         /* Extract the fields */
3472         q_ptr->pval = a_ptr->pval;
3473         q_ptr->ac = a_ptr->ac;
3474         q_ptr->dd = a_ptr->dd;
3475         q_ptr->ds = a_ptr->ds;
3476         q_ptr->to_a = a_ptr->to_a;
3477         q_ptr->to_h = a_ptr->to_h;
3478         q_ptr->to_d = a_ptr->to_d;
3479         q_ptr->weight = a_ptr->weight;
3480         q_ptr->xtra2 = a_ptr->act_idx;
3481
3482         /* Hack -- extract the "cursed" flag */
3483         if (a_ptr->gen_flags & TRG_CURSED) q_ptr->curse_flags |= (TRC_CURSED);
3484         if (a_ptr->gen_flags & TRG_HEAVY_CURSE) q_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3485         if (a_ptr->gen_flags & TRG_PERMA_CURSE) q_ptr->curse_flags |= (TRC_PERMA_CURSE);
3486         if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) q_ptr->curse_flags |= get_curse(0, q_ptr);
3487         if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) q_ptr->curse_flags |= get_curse(1, q_ptr);
3488         if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) q_ptr->curse_flags |= get_curse(2, q_ptr);
3489
3490         random_artifact_resistance(q_ptr, a_ptr);
3491
3492         /*
3493          * drop_near()Æâ¤ÇÉáÄ̤θÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤¬½Å¤Ê¤é¤Ê¤¤À­¼Á¤Ë°Í¸¤¹¤ë.
3494          * ²¾¤Ë2¸Ä°Ê¾å¸ºß²Äǽ¤«¤ÄÁõÈ÷Éʰʳ°¤Î¸ÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤¬ºîÀ®¤µ¤ì¤ì¤Ð
3495          * ¤³¤Î´Ø¿ô¤ÎÊÖ¤êÃͤϿ®ÍѤǤ­¤Ê¤¯¤Ê¤ë.
3496          */
3497
3498         /* Drop the artifact from heaven */
3499         return drop_near(q_ptr, -1, y, x) ? TRUE : FALSE;
3500 }