OSDN Git Service

9e696515c56ce8aef5b4adaf632624bd82829a05
[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 + randint(4));
31         if (o_ptr->to_a > 0) o_ptr->to_a = 0 - (o_ptr->to_a + randint(4));
32         if (o_ptr->to_h > 0) o_ptr->to_h = 0 - (o_ptr->to_h + randint(4));
33         if (o_ptr->to_d > 0) o_ptr->to_d = 0 - (o_ptr->to_d + randint(4));
34
35         o_ptr->art_flags3 |= (TR3_HEAVY_CURSE | TR3_CURSED);
36
37         if (randint(4) == 1) o_ptr->art_flags3 |= TR3_PERMA_CURSE;
38         if (randint(3) == 1) o_ptr->art_flags3 |= TR3_TY_CURSE;
39         if (randint(2) == 1) o_ptr->art_flags3 |= TR3_AGGRAVATE;
40         if (randint(3) == 1) o_ptr->art_flags3 |= TR3_DRAIN_EXP;
41         if (randint(2) == 1) o_ptr->art_flags3 |= TR3_TELEPORT;
42         else if (randint(3) == 1) 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) && (randint(3) == 1))
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 (randint(2) == 1) 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 (randint(2) == 1) return;
67                 }
68
69                 if (!(o_ptr->art_flags1 & TR1_DEX))
70                 {
71                         o_ptr->art_flags1 |= TR1_DEX;
72                         if (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) return;
102                 }
103
104                 if (!(o_ptr->art_flags1 & TR1_CON))
105                 {
106                         o_ptr->art_flags1 |= TR1_CON;
107                         if (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) return;
122                 }
123                 if (!(o_ptr->art_flags1 & TR1_SEARCH))
124                 {
125                         o_ptr->art_flags1 |= TR1_SEARCH;
126                         if (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) return;
184                 }
185         }
186
187         switch (randint(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 && randint(13) != 1)
193                         artifact_bias = BIAS_STR;
194                 else if (!artifact_bias && randint(7) == 1)
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 && randint(13) != 1)
201                         artifact_bias = BIAS_INT;
202                 else if (!artifact_bias && randint(7) == 1)
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 && randint(13) != 1)
209                         artifact_bias = BIAS_WIS;
210                 else if (!artifact_bias && randint(7) == 1)
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 && randint(13) != 1)
217                         artifact_bias = BIAS_DEX;
218                 else if (!artifact_bias && randint(7) == 1)
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 && randint(13) != 1)
225                         artifact_bias = BIAS_CON;
226                 else if (!artifact_bias && randint(9) == 1)
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 && randint(13) != 1)
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 && randint(3) == 1)
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 && randint(9) == 1)
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 && randint(11) == 1)
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 && randint(11) == 1)
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 (randint(2) == 1) return;
285                         }
286                         if ((randint(BIAS_LUCK) == 1) && !(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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) return;
305                         }
306                         if (randint(BIAS_LUCK) == 1 && !(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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) return;
326                         }
327                         if ((randint(BIAS_LUCK) == 1) &&
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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) return;
348                         }
349                         if (randint(BIAS_LUCK) == 1 && !(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 (randint(2) == 1) 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 (randint(2) == 1) return;
362                         }
363                 }
364                 else if (artifact_bias == BIAS_WARRIOR)
365                 {
366                         if (randint(3) != 1 && (!(o_ptr->art_flags2 & TR2_RES_FEAR)))
367                         {
368                                 o_ptr->art_flags2 |= TR2_RES_FEAR;
369                                 if (randint(2) == 1) return;
370                         }
371                         if ((randint(3) == 1) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC)))
372                         {
373                                 o_ptr->art_flags3 |= TR3_NO_MAGIC;
374                                 if (randint(2) == 1) 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 (randint(2) == 1) return;
383                         }
384                         if (!(o_ptr->art_flags2 & TR2_RES_POIS))
385                         {
386                                 o_ptr->art_flags2 |= TR2_RES_POIS;
387                                 if (randint(2) == 1) return;
388                         }
389                         if (!(o_ptr->art_flags2 & TR2_RES_DARK))
390                         {
391                                 o_ptr->art_flags2 |= TR2_RES_DARK;
392                                 if (randint(2) == 1) 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 (randint(2) == 1) return;
401                         }
402                         if (!(o_ptr->art_flags2 & TR2_RES_CONF))
403                         {
404                                 o_ptr->art_flags2 |= TR2_RES_CONF;
405                                 if (randint(2) == 1) return;
406                         }
407                         if (!(o_ptr->art_flags2 & TR2_RES_DISEN))
408                         {
409                                 o_ptr->art_flags2 |= TR2_RES_DISEN;
410                                 if (randint(2) == 1) return;
411                         }
412                 }
413         }
414
415         switch (specific ? specific : randint(42))
416         {
417                 case 1:
418                         if (randint(WEIRD_LUCK) != 1)
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 (randint(WEIRD_LUCK) != 1)
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 (randint(WEIRD_LUCK) != 1)
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 (randint(WEIRD_LUCK) != 1)
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 && randint(4) != 1)
498                                 artifact_bias = BIAS_POIS;
499                         else if (!artifact_bias && randint(2) == 1)
500                                 artifact_bias = BIAS_NECROMANTIC;
501                         else if (!artifact_bias && randint(2) == 1)
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 && randint(3) == 1)
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 && randint(6) == 1)
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 && randint(3) == 1)
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 && randint(2) == 1)
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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(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 && (randint(5) == 1))
723                                 artifact_bias = BIAS_PRIESTLY;
724                         else if (!artifact_bias && (randint(6) == 1))
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 (randint(3) == 1) 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 && (randint(9) == 1))
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 + randint(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 + (randint(11));
781                         bonus_d = 4 + (randint(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 (randint(2) == 1) 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 (randint(2) == 1) return;
826                 }
827                 if (!(o_ptr->art_flags1 & TR1_BRAND_POIS) && (randint(2) == 1))
828                 {
829                         o_ptr->art_flags1 |= TR1_BRAND_POIS;
830                         if (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) 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 (randint(2) == 1) return;
910                 }
911                 if (!(o_ptr->art_flags1 & TR1_SLAY_UNDEAD))
912                 {
913                         o_ptr->art_flags1 |= TR1_SLAY_UNDEAD;
914                         if (randint(2) == 1) return;
915                 }
916                 if (!(o_ptr->art_flags1 & TR1_SLAY_DEMON))
917                 {
918                         o_ptr->art_flags1 |= TR1_SLAY_DEMON;
919                         if (randint(2) == 1) return;
920                 }
921         }
922
923         if (o_ptr->tval != TV_BOW)
924         {
925                 switch (randint(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 && (randint(2) == 1))
937                                         artifact_bias = BIAS_LAW;
938                                 else if (!artifact_bias && (randint(9) == 1))
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 && (randint(9) == 1))
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 && (randint(9) == 1))
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 && (randint(9) == 1))
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 && (randint(3) != 1))
1028                                         artifact_bias = BIAS_POIS;
1029                                 else if (!artifact_bias && randint(6) == 1)
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_WEPON;
1042                                 /*  if (is_scroll) msg_print("It looks consuming your MP!");*/
1043                                 if (!artifact_bias)
1044                                         artifact_bias = ((randint(2)==1) ? 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 (randint(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 && randint(9) == 1)
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 && randint(9) == 1)
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 (randint(3) != 1)
1088                         {
1089                                 type = ACT_BO_ELEC_1;
1090                         }
1091                         else if (randint(5) != 1)
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 (randint(3) != 1)
1109                         {
1110                                 type = ACT_BO_FIRE_1;
1111                         }
1112                         else if (randint(5) != 1)
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 (randint(3) != 1)
1126                                 type = ACT_BO_COLD_1;
1127                         else if (randint(3) != 1)
1128                                 type = ACT_BA_COLD_1;
1129                         else if (randint(3) != 1)
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 (randint(6) == 1)
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 (randint(13) == 1)
1147                                 type = ACT_CHARM_UNDEAD;
1148                         else if (randint(12) == 1)
1149                                 type = ACT_BANISH_EVIL;
1150                         else if (randint(11) == 1)
1151                                 type = ACT_DISP_EVIL;
1152                         else if (randint(10) == 1)
1153                                 type = ACT_PROT_EVIL;
1154                         else if (randint(9) == 1)
1155                                 type = ACT_CURE_1000;
1156                         else if (randint(8) == 1)
1157                                 type = ACT_CURE_700;
1158                         else if (randint(7) == 1)
1159                                 type = ACT_REST_ALL;
1160                         else if (randint(6) == 1)
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 (randint(66) == 1)
1169                                 type = ACT_WRAITH;
1170                         else if (randint(13) == 1)
1171                                 type = ACT_DISP_GOOD;
1172                         else if (randint(9) == 1)
1173                                 type = ACT_MASS_GENO;
1174                         else if (randint(8) == 1)
1175                                 type = ACT_GENOCIDE;
1176                         else if (randint(13) == 1)
1177                                 type = ACT_SUMMON_UNDEAD;
1178                         else if (randint(9) == 1)
1179                                 type = ACT_VAMPIRE_2;
1180                         else if (randint(6) == 1)
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 (randint(8) == 1)
1189                                 type = ACT_BANISH_EVIL;
1190                         else if (randint(4) == 1)
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 (randint(50) == 1)
1199                                 type = ACT_SPEED;
1200                         else if (randint(4) == 1)
1201                                 type = ACT_SLEEP;
1202                         else if (randint(3) == 1)
1203                                 type = ACT_DETECT_ALL;
1204                         else if (randint(8) == 1)
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 (randint(20) == 1)
1213                                 type = ACT_SUMMON_ELEMENTAL;
1214                         else if (randint(10) == 1)
1215                                 type = ACT_SUMMON_PHANTOM;
1216                         else if (randint(5) == 1)
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 (randint(100) == 1)
1225                                 type = ACT_INVULN;
1226                         else
1227                                 type = ACT_BERSERK;
1228                 }
1229                 else if (artifact_bias == BIAS_RANGER)
1230                 {
1231                         chance = 101;
1232                         if (randint(20) == 1)
1233                                 type = ACT_CHARM_ANIMALS;
1234                         else if (randint(7) == 1)
1235                                 type = ACT_SUMMON_ANIMAL;
1236                         else if (randint(6) == 1)
1237                                 type = ACT_CHARM_ANIMAL;
1238                         else if (randint(4) == 1)
1239                                 type = ACT_RESIST_ALL;
1240                         else if (randint(3) == 1)
1241                                 type = ACT_SATIATE;
1242                         else
1243                                 type = ACT_CURE_POISON;
1244                 }
1245         }
1246
1247         while (!type || (randint(100) >= chance))
1248         {
1249                 type = randint(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 (randint(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 = randint(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 && (randint(4) == 1))
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 (randint(5) > 2) artifact_bias = BIAS_PRIESTLY;
1523                                 break;
1524                         case CLASS_TOURIST:
1525                                 if (randint(5) > 2) artifact_bias = BIAS_WARRIOR;
1526                                 break;
1527                         case CLASS_IMITATOR:
1528                                 if (randint(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 (randint(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 && (randint(100) <= warrior_artifact_bias))
1548                 artifact_bias = BIAS_WARRIOR;
1549
1550         strcpy(new_name, "");
1551
1552         if (!a_scroll && (randint(A_CURSED) == 1))
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 ((randint(powers) == 1) || (randint(7) == 1) || (randint(10) == 1))
1558                 powers++;
1559
1560         if (!a_cursed && (randint(WEIRD_LUCK) == 1))
1561                 powers *= 2;
1562
1563         if (a_cursed) powers /= 2;
1564
1565         /* Main loop */
1566         while (powers--)
1567         {
1568                 switch (randint(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 = randint(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 < randint(5) || randint(o_ptr->pval) == 1);
1625                 }
1626
1627                 if ((o_ptr->pval > 4) && (randint(WEIRD_LUCK) != 1))
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 += randint(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 += randint(o_ptr->to_h > 19 ? 1 : 20 - o_ptr->to_h);
1637                 o_ptr->to_d += randint(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             (randint((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)rand_int(3);
1664                         o_ptr->to_h -= (s16b)rand_int(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)rand_int(3);
1670                         o_ptr->to_h -= (s16b)rand_int(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_WEPON);
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                 strcpy(dummy_name, "");
1719                 (void)identify_fully_aux(o_ptr);
1720
1721 #ifdef JP
1722                 if (!(get_string("¤³¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ò²¿¤È̾ÉÕ¤±¤Þ¤¹¤«¡©", dummy_name, 80)))
1723 #else
1724                 if (!(get_string("What do you want to call the artifact? ", dummy_name, 80)))
1725 #endif
1726
1727                 {
1728                         get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level);
1729                 }
1730                 else
1731                 {
1732 #ifdef JP
1733                         strcpy(new_name, "¡Ô");
1734 #else
1735                         strcpy(new_name, "'");
1736 #endif
1737
1738                         strcat(new_name, dummy_name);
1739 #ifdef JP
1740                         strcat(new_name, "¡Õ¤È¤¤¤¦Ì¾¤Î");
1741 #else
1742                         strcat(new_name, "'");
1743 #endif
1744
1745                 }
1746                 /* Identify it fully */
1747                 object_aware(o_ptr);
1748                 object_known(o_ptr);
1749
1750                 /* Mark the item as fully known */
1751                 o_ptr->ident |= (IDENT_MENTAL);
1752
1753                 chg_virtue(V_INDIVIDUALISM, 2);
1754                 chg_virtue(V_ENCHANT, 5);
1755
1756         }
1757         else
1758         {
1759                 get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level);
1760         }
1761
1762         if (cheat_xtra)
1763         {
1764                 if (artifact_bias)
1765 #ifdef JP
1766 msg_format("±¿¤ÎÊФä¿¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È: %d¡£", artifact_bias);
1767 #else
1768                         msg_format("Biased artifact: %d.", artifact_bias);
1769 #endif
1770
1771                 else
1772 #ifdef JP
1773 msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ë±¿¤ÎÊФê¤Ê¤·¡£");
1774 #else
1775                         msg_print("No bias in artifact.");
1776 #endif
1777
1778         }
1779
1780         /* Save the inscription */
1781         o_ptr->art_name = quark_add(new_name);
1782
1783         /* Window stuff */
1784         p_ptr->window |= (PW_INVEN | PW_EQUIP);
1785
1786         return TRUE;
1787 }
1788
1789
1790 bool activate_random_artifact(object_type * o_ptr)
1791 {
1792         int plev = p_ptr->lev;
1793         int k, dir, dummy = 0;
1794
1795         if (!o_ptr->art_name) return FALSE; /* oops? */
1796
1797         /* Activate for attack */
1798         switch (o_ptr->xtra2)
1799         {
1800                 case ACT_SUNLIGHT:
1801                 {
1802                         if (!get_aim_dir(&dir)) return FALSE;
1803 #ifdef JP
1804                         msg_print("ÂÀÍÛ¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
1805 #else
1806                         msg_print("A line of sunlight appears.");
1807 #endif
1808
1809                         (void)lite_line(dir);
1810                         o_ptr->timeout = 10;
1811                         break;
1812                 }
1813
1814                 case ACT_BO_MISS_1:
1815                 {
1816 #ifdef JP
1817                         msg_print("¤½¤ì¤ÏâÁ¤·¤¤¤¯¤é¤¤¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
1818 #else
1819                         msg_print("It glows extremely brightly...");
1820 #endif
1821
1822                         if (!get_aim_dir(&dir)) return FALSE;
1823                         fire_bolt(GF_MISSILE, dir, damroll(2, 6));
1824                         o_ptr->timeout = 2;
1825                         break;
1826                 }
1827
1828                 case ACT_BA_POIS_1:
1829                 {
1830 #ifdef JP
1831                         msg_print("¤½¤ì¤ÏÇ»Î理Ë̮ư¤·¤Æ¤¤¤ë...");
1832 #else
1833                         msg_print("It throbs deep green...");
1834 #endif
1835
1836                         if (!get_aim_dir(&dir)) return FALSE;
1837                         fire_ball(GF_POIS, dir, 12, 3);
1838                         o_ptr->timeout = rand_int(4) + 4;
1839                         break;
1840                 }
1841
1842                 case ACT_BO_ELEC_1:
1843                 {
1844 #ifdef JP
1845                         msg_print("¤½¤ì¤Ï²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
1846 #else
1847                         msg_print("It is covered in sparks...");
1848 #endif
1849
1850                         if (!get_aim_dir(&dir)) return FALSE;
1851                         fire_bolt(GF_ELEC, dir, damroll(4, 8));
1852                         o_ptr->timeout = rand_int(5) + 5;
1853                         break;
1854                 }
1855
1856                 case ACT_BO_ACID_1:
1857                 {
1858 #ifdef JP
1859                         msg_print("¤½¤ì¤Ï»À¤Ëʤ¤ï¤ì¤¿...");
1860 #else
1861                         msg_print("It is covered in acid...");
1862 #endif
1863
1864                         if (!get_aim_dir(&dir)) return FALSE;
1865                         fire_bolt(GF_ACID, dir, damroll(5, 8));
1866                         o_ptr->timeout = rand_int(6) + 6;
1867                         break;
1868                 }
1869
1870                 case ACT_BO_COLD_1:
1871                 {
1872 #ifdef JP
1873                         msg_print("¤½¤ì¤ÏÁú¤Ëʤ¤ï¤ì¤¿...");
1874 #else
1875                         msg_print("It is covered in frost...");
1876 #endif
1877
1878                         if (!get_aim_dir(&dir)) return FALSE;
1879                         fire_bolt(GF_COLD, dir, damroll(6, 8));
1880                         o_ptr->timeout = rand_int(7) + 7;
1881                         break;
1882                 }
1883
1884                 case ACT_BO_FIRE_1:
1885                 {
1886 #ifdef JP
1887                         msg_print("¤½¤ì¤Ï±ê¤Ëʤ¤ï¤ì¤¿...");
1888 #else
1889                         msg_print("It is covered in fire...");
1890 #endif
1891
1892                         if (!get_aim_dir(&dir)) return FALSE;
1893                         fire_bolt(GF_FIRE, dir, damroll(9, 8));
1894                         o_ptr->timeout = rand_int(8) + 8;
1895                         break;
1896                 }
1897
1898                 case ACT_BA_COLD_1:
1899                 {
1900 #ifdef JP
1901                         msg_print("¤½¤ì¤ÏÁú¤Ëʤ¤ï¤ì¤¿...");
1902 #else
1903                         msg_print("It is covered in frost...");
1904 #endif
1905
1906                         if (!get_aim_dir(&dir)) return FALSE;
1907                         fire_ball(GF_COLD, dir, 48, 2);
1908                         o_ptr->timeout = 400;
1909                         break;
1910                 }
1911
1912                 case ACT_BA_FIRE_1:
1913                 {
1914 #ifdef JP
1915                         msg_print("¤½¤ì¤ÏÀÖ¤¯·ã¤·¤¯µ±¤¤¤¿...");
1916 #else
1917                         msg_print("It glows an intense red...");
1918 #endif
1919
1920                         if (!get_aim_dir(&dir)) return FALSE;
1921                         fire_ball(GF_FIRE, dir, 72, 2);
1922                         o_ptr->timeout = 400;
1923                         break;
1924                 }
1925
1926                 case ACT_DRAIN_1:
1927                 {
1928 #ifdef JP
1929                         msg_print("¤½¤ì¤Ï¹õ¤¯µ±¤¤¤¿...");
1930 #else
1931                         msg_print("It glows black...");
1932 #endif
1933
1934                         if (!get_aim_dir(&dir)) return FALSE;
1935                         if (drain_life(dir, 100))
1936                         o_ptr->timeout = rand_int(100) + 100;
1937                         break;
1938                 }
1939
1940                 case ACT_BA_COLD_2:
1941                 {
1942 #ifdef JP
1943                         msg_print("¤½¤ì¤ÏÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
1944 #else
1945                         msg_print("It glows an intense blue...");
1946 #endif
1947
1948                         if (!get_aim_dir(&dir)) return FALSE;
1949                         fire_ball(GF_COLD, dir, 100, 2);
1950                         o_ptr->timeout = 300;
1951                         break;
1952                 }
1953
1954                 case ACT_BA_ELEC_2:
1955                 {
1956 #ifdef JP
1957                         msg_print("Åŵ¤¤¬¥Ñ¥Á¥Ñ¥Á²»¤òΩ¤Æ¤¿...");
1958 #else
1959                         msg_print("It crackles with electricity...");
1960 #endif
1961
1962                         if (!get_aim_dir(&dir)) return FALSE;
1963                         fire_ball(GF_ELEC, dir, 100, 3);
1964                         o_ptr->timeout = 500;
1965                         break;
1966                 }
1967
1968                 case ACT_DRAIN_2:
1969                 {
1970 #ifdef JP
1971                         msg_print("¹õ¤¯µ±¤¤¤Æ¤¤¤ë...");
1972 #else
1973                         msg_print("It glows black...");
1974 #endif
1975
1976                         if (!get_aim_dir(&dir)) return FALSE;
1977                         drain_life(dir, 120);
1978                         o_ptr->timeout = 400;
1979                         break;
1980                 }
1981
1982                 case ACT_VAMPIRE_1:
1983                 {
1984                         if (!get_aim_dir(&dir)) return FALSE;
1985                         for (dummy = 0; dummy < 3; dummy++)
1986                         {
1987                                 if (drain_life(dir, 50))
1988                                 hp_player(50);
1989                         }
1990                         o_ptr->timeout = 400;
1991                         break;
1992                 }
1993
1994                 case ACT_BO_MISS_2:
1995                 {
1996 #ifdef JP
1997                         msg_print("ËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
1998 #else
1999                         msg_print("It grows magical spikes...");
2000 #endif
2001
2002                         if (!get_aim_dir(&dir)) return FALSE;
2003                         fire_bolt(GF_ARROW, dir, 150);
2004                         o_ptr->timeout = rand_int(90) + 90;
2005                         break;
2006                 }
2007
2008                 case ACT_BA_FIRE_2:
2009                 {
2010 #ifdef JP
2011                         msg_print("¿¼ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2012 #else
2013                         msg_print("It glows deep red...");
2014 #endif
2015
2016                         if (!get_aim_dir(&dir)) return FALSE;
2017                         fire_ball(GF_FIRE, dir, 120, 3);
2018                         o_ptr->timeout = rand_int(225) + 225;
2019                         break;
2020                 }
2021
2022                 case ACT_BA_COLD_3:
2023                 {
2024 #ifdef JP
2025                         msg_print("ÌÀ¤ë¤¯Çò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2026 #else
2027                         msg_print("It glows bright white...");
2028 #endif
2029
2030                         if (!get_aim_dir(&dir)) return FALSE;
2031                         fire_ball(GF_COLD, dir, 200, 3);
2032                         o_ptr->timeout = rand_int(325) + 325;
2033                         break;
2034                 }
2035
2036                 case ACT_BA_ELEC_3:
2037                 {
2038 #ifdef JP
2039                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2040 #else
2041                         msg_print("It glows deep blue...");
2042 #endif
2043
2044                         if (!get_aim_dir(&dir)) return FALSE;
2045                         fire_ball(GF_ELEC, dir, 250, 3);
2046                         o_ptr->timeout = rand_int(425) + 425;
2047                         break;
2048                 }
2049
2050                 case ACT_WHIRLWIND:
2051                 {
2052                         {
2053                                 int y = 0, x = 0;
2054                                 cave_type       *c_ptr;
2055                                 monster_type    *m_ptr;
2056
2057                                 for (dir = 0; dir <= 9; dir++)
2058                                 {
2059                                         y = py + ddy[dir];
2060                                         x = px + ddx[dir];
2061                                         c_ptr = &cave[y][x];
2062
2063                                         /* Get the monster */
2064                                         m_ptr = &m_list[c_ptr->m_idx];
2065
2066                                         /* Hack -- attack monsters */
2067                                         if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x)))
2068                                                 py_attack(y, x, 0);
2069                                 }
2070                         }
2071                         o_ptr->timeout = 250;
2072                         break;
2073                 }
2074
2075                 case ACT_VAMPIRE_2:
2076                 {
2077                         if (!get_aim_dir(&dir)) return FALSE;
2078                         for (dummy = 0; dummy < 3; dummy++)
2079                         {
2080                                 if (drain_life(dir, 100))
2081                                 hp_player(100);
2082                         }
2083
2084                         o_ptr->timeout = 400;
2085                         break;
2086                 }
2087
2088
2089                 case ACT_CALL_CHAOS:
2090                 {
2091 #ifdef JP
2092                         msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
2093 #else
2094                         msg_print("It glows in scintillating colours...");
2095 #endif
2096
2097                         call_chaos();
2098                         o_ptr->timeout = 350;
2099                         break;
2100                 }
2101
2102                 case ACT_ROCKET:
2103                 {
2104                         if (!get_aim_dir(&dir)) return FALSE;
2105 #ifdef JP
2106                         msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
2107 #else
2108                         msg_print("You launch a rocket!");
2109 #endif
2110
2111                         fire_ball(GF_ROCKET, dir, 250 + plev*3, 2);
2112                         o_ptr->timeout = 400;
2113                         break;
2114                 }
2115
2116                 case ACT_DISP_EVIL:
2117                 {
2118 #ifdef JP
2119                         msg_print("¿ÀÀ»¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
2120 #else
2121                         msg_print("It floods the area with goodness...");
2122 #endif
2123
2124                         dispel_evil(p_ptr->lev * 5);
2125                         o_ptr->timeout = rand_int(300) + 300;
2126                         break;
2127                 }
2128
2129                 case ACT_DISP_GOOD:
2130                 {
2131 #ifdef JP
2132                         msg_print("¼Ù°­¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
2133 #else
2134                         msg_print("It floods the area with evil...");
2135 #endif
2136
2137                         dispel_good(p_ptr->lev * 5);
2138                         o_ptr->timeout = rand_int(300) + 300;
2139                         break;
2140                 }
2141
2142                 case ACT_BA_MISS_3:
2143                 {
2144                         if (!get_aim_dir(&dir)) return FALSE;
2145 #ifdef JP
2146                         msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
2147 #else
2148                         msg_print("You breathe the elements.");
2149 #endif
2150
2151                         fire_ball(GF_MISSILE, dir, 300, 4);
2152                         o_ptr->timeout = 500;
2153                         break;
2154                 }
2155
2156                 /* Activate for other offensive action */
2157
2158                 case ACT_CONFUSE:
2159                 {
2160 #ifdef JP
2161                         msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
2162 #else
2163                         msg_print("It glows in scintillating colours...");
2164 #endif
2165
2166                         if (!get_aim_dir(&dir)) return FALSE;
2167                         confuse_monster(dir, 20);
2168                         o_ptr->timeout = 15;
2169                         break;
2170                 }
2171
2172                 case ACT_SLEEP:
2173                 {
2174 #ifdef JP
2175                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2176 #else
2177                         msg_print("It glows deep blue...");
2178 #endif
2179
2180                         sleep_monsters_touch();
2181                         o_ptr->timeout = 55;
2182                         break;
2183                 }
2184
2185                 case ACT_QUAKE:
2186                 {
2187                         earthquake(py, px, 10);
2188                         o_ptr->timeout = 50;
2189                         break;
2190                 }
2191
2192                 case ACT_TERROR:
2193                 {
2194                         turn_monsters(40 + p_ptr->lev);
2195                         o_ptr->timeout = 3 * (p_ptr->lev + 10);
2196                         break;
2197                 }
2198
2199                 case ACT_TELE_AWAY:
2200                 {
2201                         if (!get_aim_dir(&dir)) return FALSE;
2202                         (void)fire_beam(GF_AWAY_ALL, dir, plev);
2203                         o_ptr->timeout = 200;
2204                         break;
2205                 }
2206
2207                 case ACT_BANISH_EVIL:
2208                 {
2209                         if (banish_evil(100))
2210                         {
2211 #ifdef JP
2212                                 msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÎϤ¬¼Ù°­¤òÂǤÁÅݤ·¤¿¡ª");
2213 #else
2214                                 msg_print("The power of the artifact banishes evil!");
2215 #endif
2216
2217                         }
2218                         o_ptr->timeout = 250 + randint(250);
2219                         break;
2220                 }
2221
2222                 case ACT_GENOCIDE:
2223                 {
2224 #ifdef JP
2225                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2226 #else
2227                         msg_print("It glows deep blue...");
2228 #endif
2229
2230                         (void)symbol_genocide(200, TRUE);
2231                         o_ptr->timeout = 500;
2232                         break;
2233                 }
2234
2235                 case ACT_MASS_GENO:
2236                 {
2237 #ifdef JP
2238                         msg_print("¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
2239 #else
2240                         msg_print("It lets out a long, shrill note...");
2241 #endif
2242
2243                         (void)mass_genocide(200, TRUE);
2244                         o_ptr->timeout = 1000;
2245                         break;
2246                 }
2247
2248                 /* Activate for summoning / charming */
2249
2250                 case ACT_CHARM_ANIMAL:
2251                 {
2252                         if (!get_aim_dir(&dir)) return FALSE;
2253                         (void)charm_animal(dir, plev);
2254                         o_ptr->timeout = 300;
2255                         break;
2256                 }
2257
2258                 case ACT_CHARM_UNDEAD:
2259                 {
2260                         if (!get_aim_dir(&dir)) return FALSE;
2261                         (void)control_one_undead(dir, plev);
2262                         o_ptr->timeout = 333;
2263                         break;
2264                 }
2265
2266                 case ACT_CHARM_OTHER:
2267                 {
2268                         if (!get_aim_dir(&dir)) return FALSE;
2269                         (void)charm_monster(dir, plev);
2270                         o_ptr->timeout = 400;
2271                         break;
2272                 }
2273
2274                 case ACT_CHARM_ANIMALS:
2275                 {
2276                         (void)charm_animals(plev * 2);
2277                         o_ptr->timeout = 500;
2278                         break;
2279                 }
2280
2281                 case ACT_CHARM_OTHERS:
2282                 {
2283                         charm_monsters(plev * 2);
2284                         o_ptr->timeout = 750;
2285                         break;
2286                 }
2287
2288                 case ACT_SUMMON_ANIMAL:
2289                 {
2290                         (void)summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, TRUE, TRUE, TRUE, FALSE, FALSE);
2291                         o_ptr->timeout = 200 + randint(300);
2292                         break;
2293                 }
2294
2295                 case ACT_SUMMON_PHANTOM:
2296                 {
2297 #ifdef JP
2298                         msg_print("¸¸Îî¤ò¾¤´­¤·¤¿¡£");
2299 #else
2300                         msg_print("You summon a phantasmal servant.");
2301 #endif
2302
2303                         (void)summon_specific(-1, py, px, dun_level, SUMMON_PHANTOM, TRUE, TRUE, TRUE, FALSE, FALSE);
2304                         o_ptr->timeout = 200 + randint(200);
2305                         break;
2306                 }
2307
2308                 case ACT_SUMMON_ELEMENTAL:
2309                 {
2310                         bool pet = (randint(3) == 1);
2311                         bool group = !(pet && (plev < 50));
2312
2313                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, group, FALSE, pet, FALSE, (bool)(!pet)))
2314                         {
2315 #ifdef JP
2316                                 msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿...");
2317 #else
2318                                 msg_print("An elemental materializes...");
2319 #endif
2320
2321
2322                                 if (pet)
2323 #ifdef JP
2324                                         msg_print("¤¢¤Ê¤¿¤ËÉþ½¾¤·¤Æ¤¤¤ë¤è¤¦¤À¡£");
2325 #else
2326                                         msg_print("It seems obedient to you.");
2327 #endif
2328
2329                                 else
2330 #ifdef JP
2331                                         msg_print("¤½¤ì¤ò¥³¥ó¥È¥í¡¼¥ë¤Ç¤­¤Ê¤«¤Ã¤¿¡ª");
2332 #else
2333                                         msg_print("You fail to control it!");
2334 #endif
2335
2336                         }
2337
2338                         o_ptr->timeout = 750;
2339                         break;
2340                 }
2341
2342                 case ACT_SUMMON_DEMON:
2343                 {
2344                         bool pet = (randint(3) == 1);
2345                         bool group = !(pet && (plev < 50));
2346
2347                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, group, FALSE, pet, FALSE, (bool)(!pet)))
2348                         {
2349 #ifdef JP
2350                                 msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
2351 #else
2352                                 msg_print("The area fills with a stench of sulphur and brimstone.");
2353 #endif
2354
2355                                 if (pet)
2356 #ifdef JP
2357                                         msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
2358 #else
2359                                         msg_print("'What is thy bidding... Master?'");
2360 #endif
2361
2362                                 else
2363 #ifdef JP
2364                                         msg_print("¡ÖNON SERVIAM! Wretch! ¤ªÁ°¤Îº²¤òĺ¤¯¤¾¡ª¡×");
2365 #else
2366                                         msg_print("'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'");
2367 #endif
2368
2369                         }
2370
2371                         o_ptr->timeout = 666 + randint(333);
2372                         break;
2373                 }
2374
2375                 case ACT_SUMMON_UNDEAD:
2376                 {
2377                         bool pet = (randint(3) == 1);
2378                         bool group;
2379                         bool unique_okay;
2380                         int type;
2381
2382                         type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
2383                         if (pet)
2384                         {
2385                                 group = (((plev > 24) && (randint(3) == 1)) ? TRUE : FALSE);
2386                                 unique_okay = FALSE;
2387                         }
2388                         else
2389                         {
2390                                 group = TRUE;
2391                                 unique_okay = TRUE;
2392                         }
2393
2394                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), type,
2395                                             group, FALSE, pet, unique_okay, (bool)(!pet)))
2396                         {
2397 #ifdef JP
2398                                 msg_print("Î䤿¤¤É÷¤¬¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¿á¤­»Ï¤á¤¿¡£¤½¤ì¤ÏÉåÇÔ½­¤ò±¿¤ó¤Ç¤¤¤ë...");
2399 #else
2400                                 msg_print("Cold winds begin to blow around you, carrying with them the stench of decay...");
2401 #endif
2402
2403                                 if (pet)
2404 #ifdef JP
2405                                         msg_print("¸Å¤¨¤Î»à¤»¤ë¼Ô¶¦¤¬¤¢¤Ê¤¿¤Ë»Å¤¨¤ë¤¿¤áÅÚ¤«¤éᴤä¿¡ª");
2406 #else
2407                                         msg_print("Ancient, long-dead forms arise from the ground to serve you!");
2408 #endif
2409
2410                                 else
2411 #ifdef JP
2412                                         msg_print("»à¼Ô¤¬á´¤Ã¤¿¡£Ì²¤ê¤ò˸¤²¤ë¤¢¤Ê¤¿¤òȳ¤¹¤ë¤¿¤á¤Ë¡ª");
2413 #else
2414                                         msg_print("'The dead arise... to punish you for disturbing them!'");
2415 #endif
2416
2417                         }
2418
2419                         o_ptr->timeout = 666 + randint(333);
2420                         break;
2421                 }
2422
2423                 /* Activate for healing */
2424
2425                 case ACT_CURE_LW:
2426                 {
2427                         (void)set_afraid(0);
2428                         (void)hp_player(30);
2429                         o_ptr->timeout = 10;
2430                         break;
2431                 }
2432
2433                 case ACT_CURE_MW:
2434                 {
2435 #ifdef JP
2436                         msg_print("¿¼»ç¿§¤Î¸÷¤òȯ¤·¤Æ¤¤¤ë...");
2437 #else
2438                         msg_print("It radiates deep purple...");
2439 #endif
2440
2441                         hp_player(damroll(4, 8));
2442                         (void)set_cut((p_ptr->cut / 2) - 50);
2443                         o_ptr->timeout = rand_int(3) + 3;
2444                         break;
2445                 }
2446
2447                 case ACT_CURE_POISON:
2448                 {
2449 #ifdef JP
2450                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2451 #else
2452                         msg_print("It glows deep blue...");
2453 #endif
2454
2455                         (void)set_afraid(0);
2456                         (void)set_poisoned(0);
2457                         o_ptr->timeout = 5;
2458                         break;
2459                 }
2460
2461                 case ACT_REST_LIFE:
2462                 {
2463 #ifdef JP
2464                         msg_print("¿¼¹È¤Ëµ±¤¤¤Æ¤¤¤ë...");
2465 #else
2466                         msg_print("It glows a deep red...");
2467 #endif
2468
2469                         restore_level();
2470                         o_ptr->timeout = 450;
2471                         break;
2472                 }
2473
2474                 case ACT_REST_ALL:
2475                 {
2476 #ifdef JP
2477                         msg_print("Ç»Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2478 #else
2479                         msg_print("It glows a deep green...");
2480 #endif
2481
2482                         (void)do_res_stat(A_STR);
2483                         (void)do_res_stat(A_INT);
2484                         (void)do_res_stat(A_WIS);
2485                         (void)do_res_stat(A_DEX);
2486                         (void)do_res_stat(A_CON);
2487                         (void)do_res_stat(A_CHR);
2488                         (void)restore_level();
2489                         o_ptr->timeout = 750;
2490                         break;
2491                 }
2492
2493                 case ACT_CURE_700:
2494                 {
2495 #ifdef JP
2496                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2497 #else
2498                         msg_print("It glows deep blue...");
2499 #endif
2500
2501 #ifdef JP
2502                         msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
2503 #else
2504                         msg_print("You feel a warm tingling inside...");
2505 #endif
2506
2507                         (void)hp_player(700);
2508                         (void)set_cut(0);
2509                         o_ptr->timeout = 250;
2510                         break;
2511                 }
2512
2513                 case ACT_CURE_1000:
2514                 {
2515 #ifdef JP
2516                         msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2517 #else
2518                         msg_print("It glows a bright white...");
2519 #endif
2520
2521 #ifdef JP
2522                         msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
2523 #else
2524                         msg_print("You feel much better...");
2525 #endif
2526
2527                         (void)hp_player(1000);
2528                         (void)set_cut(0);
2529                         o_ptr->timeout = 888;
2530                         break;
2531                 }
2532
2533                 /* Activate for timed effect */
2534
2535                 case ACT_ESP:
2536                 {
2537                         (void)set_tim_esp(randint(30) + 25, FALSE);
2538                         o_ptr->timeout = 200;
2539                         break;
2540                 }
2541
2542                 case ACT_BERSERK:
2543                 {
2544                         (void)set_hero(randint(50) + 50, FALSE);
2545                         (void)set_blessed(randint(50) + 50, FALSE);
2546                         o_ptr->timeout = 100 + randint(100);
2547                         break;
2548                 }
2549
2550                 case ACT_PROT_EVIL:
2551                 {
2552 #ifdef JP
2553                         msg_print("±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
2554 #else
2555                         msg_print("It lets out a shrill wail...");
2556 #endif
2557
2558                         k = 3 * p_ptr->lev;
2559                         (void)set_protevil(randint(25) + k, FALSE);
2560                         o_ptr->timeout = rand_int(225) + 225;
2561                         break;
2562                 }
2563
2564                 case ACT_RESIST_ALL:
2565                 {
2566 #ifdef JP
2567                         msg_print("ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2568 #else
2569                         msg_print("It glows many colours...");
2570 #endif
2571
2572                         (void)set_oppose_acid(randint(40) + 40, FALSE);
2573                         (void)set_oppose_elec(randint(40) + 40, FALSE);
2574                         (void)set_oppose_fire(randint(40) + 40, FALSE);
2575                         (void)set_oppose_cold(randint(40) + 40, FALSE);
2576                         (void)set_oppose_pois(randint(40) + 40, FALSE);
2577                         o_ptr->timeout = 200;
2578                         break;
2579                 }
2580
2581                 case ACT_SPEED:
2582                 {
2583 #ifdef JP
2584                         msg_print("ÌÀ¤ë¤¯Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2585 #else
2586                         msg_print("It glows bright green...");
2587 #endif
2588
2589                         (void)set_fast(randint(20) + 20, FALSE);
2590                         o_ptr->timeout = 250;
2591                         break;
2592                 }
2593
2594                 case ACT_XTRA_SPEED:
2595                 {
2596 #ifdef JP
2597                         msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2598 #else
2599                         msg_print("It glows brightly...");
2600 #endif
2601
2602                         (void)set_fast(randint(75) + 75, FALSE);
2603                         o_ptr->timeout = rand_int(200) + 200;
2604                         break;
2605                 }
2606
2607                 case ACT_WRAITH:
2608                 {
2609                         set_wraith_form(randint(plev / 2) + (plev / 2), FALSE);
2610                         o_ptr->timeout = 1000;
2611                         break;
2612                 }
2613
2614                 case ACT_INVULN:
2615                 {
2616                         (void)set_invuln(randint(8) + 8, FALSE);
2617                         o_ptr->timeout = 1000;
2618                         break;
2619                 }
2620
2621                 /* Activate for general purpose effect (detection etc.) */
2622
2623                 case ACT_LIGHT:
2624                 {
2625 #ifdef JP
2626                         msg_print("À¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
2627 #else
2628                         msg_print("It wells with clear light...");
2629 #endif
2630
2631                         lite_area(damroll(2, 15), 3);
2632                         o_ptr->timeout = rand_int(10) + 10;
2633                         break;
2634                 }
2635
2636                 case ACT_MAP_LIGHT:
2637                 {
2638 #ifdef JP
2639                         msg_print("âÁ¤·¤¯µ±¤¤¤¿...");
2640 #else
2641                         msg_print("It shines brightly...");
2642 #endif
2643
2644                         map_area(DETECT_RAD_MAP);
2645                         lite_area(damroll(2, 15), 3);
2646                         o_ptr->timeout = rand_int(50) + 50;
2647                         break;
2648                 }
2649
2650                 case ACT_DETECT_ALL:
2651                 {
2652 #ifdef JP
2653                         msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2654 #else
2655                         msg_print("It glows bright white...");
2656 #endif
2657
2658 #ifdef JP
2659                         msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
2660 #else
2661                         msg_print("An image forms in your mind...");
2662 #endif
2663
2664                         detect_all(DETECT_RAD_DEFAULT);
2665                         o_ptr->timeout = rand_int(55) + 55;
2666                         break;
2667                 }
2668
2669                 case ACT_DETECT_XTRA:
2670                 {
2671 #ifdef JP
2672                         msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2673 #else
2674                         msg_print("It glows brightly...");
2675 #endif
2676
2677                         detect_all(DETECT_RAD_DEFAULT);
2678                         probing();
2679                         identify_fully(FALSE);
2680                         o_ptr->timeout = 1000;
2681                         break;
2682                 }
2683
2684                 case ACT_ID_FULL:
2685                 {
2686 #ifdef JP
2687                         msg_print("²«¿§¤¯µ±¤¤¤Æ¤¤¤ë...");
2688 #else
2689                         msg_print("It glows yellow...");
2690 #endif
2691
2692                         identify_fully(FALSE);
2693                         o_ptr->timeout = 750;
2694                         break;
2695                 }
2696
2697                 case ACT_ID_PLAIN:
2698                 {
2699                         if (!ident_spell(FALSE)) return FALSE;
2700                         o_ptr->timeout = 10;
2701                         break;
2702                 }
2703
2704                 case ACT_RUNE_EXPLO:
2705                 {
2706 #ifdef JP
2707                         msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2708 #else
2709                         msg_print("It glows bright red...");
2710 #endif
2711
2712                         explosive_rune();
2713                         o_ptr->timeout = 200;
2714                         break;
2715                 }
2716
2717                 case ACT_RUNE_PROT:
2718                 {
2719 #ifdef JP
2720                         msg_print("¥Ö¥ë¡¼¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2721 #else
2722                         msg_print("It glows light blue...");
2723 #endif
2724
2725                         warding_glyph();
2726                         o_ptr->timeout = 400;
2727                         break;
2728                 }
2729
2730                 case ACT_SATIATE:
2731                 {
2732                         (void)set_food(PY_FOOD_MAX - 1);
2733                         o_ptr->timeout = 200;
2734                         break;
2735                 }
2736
2737                 case ACT_DEST_DOOR:
2738                 {
2739 #ifdef JP
2740                         msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2741 #else
2742                         msg_print("It glows bright red...");
2743 #endif
2744
2745                         destroy_doors_touch();
2746                         o_ptr->timeout = 10;
2747                         break;
2748                 }
2749
2750                 case ACT_STONE_MUD:
2751                 {
2752 #ifdef JP
2753                         msg_print("¸ÝÆ°¤·¤Æ¤¤¤ë...");
2754 #else
2755                         msg_print("It pulsates...");
2756 #endif
2757
2758                         if (!get_aim_dir(&dir)) return FALSE;
2759                         wall_to_mud(dir);
2760                         o_ptr->timeout = 5;
2761                         break;
2762                 }
2763
2764                 case ACT_RECHARGE:
2765                 {
2766                         recharge(130);
2767                         o_ptr->timeout = 70;
2768                         break;
2769                 }
2770
2771                 case ACT_ALCHEMY:
2772                 {
2773 #ifdef JP
2774                         msg_print("ÌÀ¤ë¤¤²«¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2775 #else
2776                         msg_print("It glows bright yellow...");
2777 #endif
2778
2779                         (void)alchemy();
2780                         o_ptr->timeout = 500;
2781                         break;
2782                 }
2783
2784                 case ACT_DIM_DOOR:
2785                 {
2786 #ifdef JP
2787                         msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
2788 #else
2789                         msg_print("You open a dimensional gate. Choose a destination.");
2790 #endif
2791
2792                         if (!dimension_door()) return FALSE;
2793                         o_ptr->timeout = 100;
2794                         break;
2795                 }
2796
2797
2798                 case ACT_TELEPORT:
2799                 {
2800 #ifdef JP
2801                         msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ë...");
2802 #else
2803                         msg_print("It twists space around you...");
2804 #endif
2805
2806                         teleport_player(100);
2807                         o_ptr->timeout = 45;
2808                         break;
2809                 }
2810
2811                 case ACT_RECALL:
2812                 {
2813 #ifdef JP
2814                         msg_print("¤ä¤ï¤é¤«¤ÊÇò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2815 #else
2816                         msg_print("It glows soft white...");
2817 #endif
2818                         if (!word_of_recall()) return FALSE;
2819                         o_ptr->timeout = 200;
2820                         break;
2821                 }
2822
2823                 default:
2824                 {
2825 #ifdef JP
2826                         msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
2827 #else
2828                         msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
2829 #endif
2830
2831                         return FALSE;
2832                 }
2833         }
2834
2835         return TRUE;
2836 }
2837
2838
2839 void random_artifact_resistance(object_type * o_ptr)
2840 {
2841         bool give_resistance = FALSE, give_power = FALSE;
2842
2843         if (o_ptr->name1 == ART_TERROR) /* Terror Mask is for warriors... */
2844         {
2845                 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_ARCHER || p_ptr->pclass == CLASS_CAVALRY || p_ptr->pclass == CLASS_BERSERKER)
2846                 {
2847                         give_power = TRUE;
2848                         give_resistance = TRUE;
2849                 }
2850                 else
2851                 {
2852                         o_ptr->art_flags3 |=
2853                             (TR3_CURSED | TR3_HEAVY_CURSE | TR3_AGGRAVATE | TR3_TY_CURSE);
2854                         o_ptr->ident |= IDENT_CURSED;
2855                         return;
2856                 }
2857         }
2858         if (o_ptr->name1 == ART_MURAMASA)
2859         {
2860                 if (p_ptr->pclass != CLASS_SAMURAI)
2861                 {
2862                         o_ptr->art_flags3 |= (TR3_NO_TELE | TR3_NO_MAGIC | TR3_HEAVY_CURSE);
2863                         o_ptr->ident |= IDENT_CURSED;
2864                 }
2865         }
2866
2867         if (o_ptr->name1 == ART_XIAOLONG)
2868         {
2869                 if (p_ptr->pclass == CLASS_MONK)
2870                         o_ptr->art_flags1 |= TR1_BLOWS;
2871         }
2872
2873         if (o_ptr->name1 == ART_BLOOD)
2874         {
2875                 int dummy, i;
2876                 dummy = randint(2)+randint(2);
2877                 for (i = 0; i < dummy; i++)
2878                         o_ptr->art_flags1 |= (TR1_CHAOTIC << rand_int(18));
2879                 dummy = randint(2);
2880                 for (i = 0; i < dummy; i++)
2881                         random_resistance(o_ptr, FALSE, randint(34) + 4);
2882                 dummy = 2;
2883                 for (i = 0; i < dummy; i++)
2884                 {
2885                         int tmp = rand_int(11);
2886                         if (tmp < 6) o_ptr->art_flags1 |= (TR1_STR << tmp);
2887                         else o_ptr->art_flags1 |= (TR1_STEALTH << (tmp - 6));
2888                 }
2889         }
2890
2891         switch (o_ptr->name1)
2892         {
2893                 case ART_CELEBORN:
2894                 case ART_ARVEDUI:
2895                 case ART_CASPANION:
2896                 case ART_HITHLOMIR:
2897                 case ART_ROHIRRIM:
2898                 case ART_CELEGORM:
2899                 case ART_ANARION:
2900                 case ART_THRANDUIL:
2901                 case ART_LUTHIEN:
2902                 case ART_THROR:
2903                 case ART_THORIN:
2904                 case ART_NIMTHANC:
2905                 case ART_DETHANC:
2906                 case ART_NARTHANC:
2907                 case ART_STING:
2908                 case ART_TURMIL:
2909                 case ART_THALKETTOTH:
2910                 case ART_JIZO:
2911                         {
2912                                 /* Give a resistance */
2913                                 give_resistance = TRUE;
2914                         }
2915                         break;
2916                 case ART_MAEDHROS:
2917                 case ART_GLAMDRING:
2918                 case ART_ORCRIST:
2919                 case ART_ANDURIL:
2920                 case ART_ZARCUTHRA:
2921                 case ART_GURTHANG:
2922                 case ART_HARADEKKET:
2923                 case ART_BRAND:
2924                 case ART_DAWN:
2925                 case ART_BUCKLAND:
2926                 case ART_AZAGHAL:
2927                         {
2928                                 /* Give a resistance OR a power */
2929                                 if (randint(2) == 1) give_resistance = TRUE;
2930                                 else give_power = TRUE;
2931                         }
2932                         break;
2933                 case ART_NENYA:
2934                 case ART_VILYA:
2935                 case ART_BERUTHIEL:
2936                 case ART_THINGOL:
2937                 case ART_ULMO:
2938                 case ART_OLORIN:
2939                         {
2940                                 /* Give a power */
2941                                 give_power = TRUE;
2942                         }
2943                         break;
2944                 case ART_CRIMSON:
2945                 case ART_POWER:
2946                 case ART_GONDOR:
2947                 case ART_AULE:
2948                         {
2949                                 /* Give both */
2950                                 give_power = TRUE;
2951                                 give_resistance = TRUE;
2952                         }
2953                         break;
2954         }
2955
2956         if (give_power)
2957         {
2958                 o_ptr->xtra1 = EGO_XTRA_ABILITY;
2959
2960                 /* Randomize the "xtra" power */
2961                 if (o_ptr->xtra1) o_ptr->xtra2 = randint(256);
2962         }
2963
2964         artifact_bias = 0;
2965
2966         if (give_resistance)
2967         {
2968                 random_resistance(o_ptr, FALSE, randint(22) + 16);
2969         }
2970 }
2971
2972
2973 /*
2974  * Create the artifact of the specified number
2975  */
2976 void create_named_art(int a_idx, int y, int x)
2977 {
2978         object_type forge;
2979         object_type *q_ptr;
2980         int i;
2981
2982         artifact_type *a_ptr = &a_info[a_idx];
2983
2984         /* Get local object */
2985         q_ptr = &forge;
2986
2987         /* Ignore "empty" artifacts */
2988         if (!a_ptr->name) return;
2989
2990         /* Acquire the "kind" index */
2991         i = lookup_kind(a_ptr->tval, a_ptr->sval);
2992
2993         /* Oops */
2994         if (!i) return;
2995
2996         /* Create the artifact */
2997         object_prep(q_ptr, i);
2998
2999         /* Save the name */
3000         q_ptr->name1 = a_idx;
3001
3002         /* Extract the fields */
3003         q_ptr->pval = a_ptr->pval;
3004         q_ptr->ac = a_ptr->ac;
3005         q_ptr->dd = a_ptr->dd;
3006         q_ptr->ds = a_ptr->ds;
3007         q_ptr->to_a = a_ptr->to_a;
3008         q_ptr->to_h = a_ptr->to_h;
3009         q_ptr->to_d = a_ptr->to_d;
3010         q_ptr->weight = a_ptr->weight;
3011
3012         /* Hack -- acquire "cursed" flag */
3013         if (a_ptr->flags3 & TR3_CURSED) q_ptr->ident |= (IDENT_CURSED);
3014
3015         random_artifact_resistance(q_ptr);
3016
3017         /* Drop the artifact from heaven */
3018         (void)drop_near(q_ptr, -1, y, x);
3019 }