OSDN Git Service

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