OSDN Git Service

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