OSDN Git Service

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