OSDN Git Service

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