OSDN Git Service

無駄に残ってソース汚しになっていたPython関係のコードを削除。script.cと、z-config.hの中のUSE_SCRIPT辺りの記述は一応残している。
[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                         case CLASS_MIRROR_MASTER:
1501                                 artifact_bias = BIAS_RANGER;
1502                                 warrior_artifact_bias = 30;
1503                                 break;
1504                         case CLASS_PALADIN:
1505                                 artifact_bias = BIAS_PRIESTLY;
1506                                 warrior_artifact_bias = 40;
1507                                 break;
1508                         case CLASS_WARRIOR_MAGE:
1509                         case CLASS_RED_MAGE:
1510                                 artifact_bias = BIAS_MAGE;
1511                                 warrior_artifact_bias = 40;
1512                                 break;
1513                         case CLASS_CHAOS_WARRIOR:
1514                                 artifact_bias = BIAS_CHAOS;
1515                                 warrior_artifact_bias = 40;
1516                                 break;
1517                         case CLASS_MONK:
1518                         case CLASS_FORCETRAINER:
1519                                 artifact_bias = BIAS_PRIESTLY;
1520                                 break;
1521                         case CLASS_MINDCRAFTER:
1522                         case CLASS_BARD:
1523                                 if (randint(5) > 2) artifact_bias = BIAS_PRIESTLY;
1524                                 break;
1525                         case CLASS_TOURIST:
1526                                 if (randint(5) > 2) artifact_bias = BIAS_WARRIOR;
1527                                 break;
1528                         case CLASS_IMITATOR:
1529                                 if (randint(2) > 1) artifact_bias = BIAS_RANGER;
1530                                 break;
1531                         case CLASS_BEASTMASTER:
1532                                 artifact_bias = BIAS_CHR;
1533                                 warrior_artifact_bias = 50;
1534                                 break;
1535                 }
1536         }
1537
1538         if (a_scroll && (randint(100) <= warrior_artifact_bias))
1539                 artifact_bias = BIAS_WARRIOR;
1540
1541         strcpy(new_name, "");
1542
1543         if (!a_scroll && (randint(A_CURSED) == 1))
1544                 a_cursed = TRUE;
1545         if (((o_ptr->tval == TV_AMULET) || (o_ptr->tval == TV_RING)) && cursed_p(o_ptr))
1546                 a_cursed = TRUE;
1547
1548         while ((randint(powers) == 1) || (randint(7) == 1) || (randint(10) == 1))
1549                 powers++;
1550
1551         if (!a_cursed && (randint(WEIRD_LUCK) == 1))
1552                 powers *= 2;
1553
1554         if (a_cursed) powers /= 2;
1555
1556         /* Main loop */
1557         while (powers--)
1558         {
1559                 switch (randint(max_type))
1560                 {
1561                         case 1: case 2:
1562                                 random_plus(o_ptr, a_scroll);
1563                                 has_pval = TRUE;
1564                                 break;
1565                         case 3: case 4:
1566                                 if (one_in_(2) && (o_ptr->tval < TV_BOOTS) && (o_ptr->tval != TV_BOW))
1567                                 {
1568                                         if (a_cursed && !one_in_(13)) break;
1569                                         if (one_in_(13))
1570                                         {
1571                                                 if (one_in_(o_ptr->ds+4)) o_ptr->ds++;
1572                                         }
1573                                         else
1574                                         {
1575                                                 if (one_in_(o_ptr->dd+1)) o_ptr->dd++;
1576                                         }
1577                                 }
1578                                 else
1579                                         random_resistance(o_ptr, a_scroll, FALSE);
1580                                 break;
1581                         case 5:
1582                                 random_misc(o_ptr, a_scroll);
1583                                 break;
1584                         case 6: case 7:
1585                                 random_slay(o_ptr, a_scroll);
1586                                 break;
1587                         default:
1588                                 if (wizard) msg_print("Switch error in create_artifact!");
1589                                 powers++;
1590                 }
1591         };
1592
1593         if (has_pval)
1594         {
1595 #if 0
1596                 o_ptr->art_flags3 |= TR3_SHOW_MODS;
1597
1598                 /* This one commented out by gw's request... */
1599                 if (!a_scroll)
1600                         o_ptr->art_flags3 |= TR3_HIDE_TYPE;
1601 #endif
1602
1603                 if (o_ptr->art_flags1 & TR1_BLOWS)
1604                 {
1605                         o_ptr->pval = randint(2);
1606                         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
1607                                 o_ptr->pval++;
1608                 }
1609                 else
1610                 {
1611                         do
1612                         {
1613                                 o_ptr->pval++;
1614                         }
1615                         while (o_ptr->pval < randint(5) || randint(o_ptr->pval) == 1);
1616                 }
1617
1618                 if ((o_ptr->pval > 4) && (randint(WEIRD_LUCK) != 1))
1619                         o_ptr->pval = 4;
1620         }
1621
1622         /* give it some plusses... */
1623         if (o_ptr->tval >= TV_BOOTS && o_ptr->tval <= TV_DRAG_ARMOR)
1624                 o_ptr->to_a += randint(o_ptr->to_a > 19 ? 1 : 20 - o_ptr->to_a);
1625         else if (o_ptr->tval <= TV_SWORD)
1626         {
1627                 o_ptr->to_h += randint(o_ptr->to_h > 19 ? 1 : 20 - o_ptr->to_h);
1628                 o_ptr->to_d += randint(o_ptr->to_d > 19 ? 1 : 20 - o_ptr->to_d);
1629                 if ((o_ptr->art_flags1 & TR1_WIS) && (o_ptr->pval > 0)) o_ptr->art_flags3 |= TR3_BLESSED;
1630         }
1631
1632         /* Just to be sure */
1633         o_ptr->art_flags3 |= (TR3_IGNORE_ACID | TR3_IGNORE_ELEC |
1634                               TR3_IGNORE_FIRE | TR3_IGNORE_COLD);
1635
1636         total_flags = flag_cost(o_ptr, o_ptr->pval);
1637         if (cheat_peek) msg_format("%ld", total_flags);
1638
1639         if (a_cursed) curse_artifact(o_ptr);
1640
1641         if (!a_cursed &&
1642             (randint((o_ptr->tval >= TV_BOOTS)
1643             ? ACTIVATION_CHANCE * 2 : ACTIVATION_CHANCE) == 1))
1644         {
1645                 o_ptr->xtra2 = 0;
1646                 give_activation_power(o_ptr);
1647         }
1648
1649         if ((o_ptr->tval >= TV_BOOTS) && (o_ptr->tval <= TV_DRAG_ARMOR))
1650         {
1651                 while ((o_ptr->to_d+o_ptr->to_h) > 20)
1652                 {
1653                         if (one_in_(o_ptr->to_d) && one_in_(o_ptr->to_h)) break;
1654                         o_ptr->to_d -= (s16b)rand_int(3);
1655                         o_ptr->to_h -= (s16b)rand_int(3);
1656                 }
1657                 while ((o_ptr->to_d+o_ptr->to_h) > 10)
1658                 {
1659                         if (one_in_(o_ptr->to_d) || one_in_(o_ptr->to_h)) break;
1660                         o_ptr->to_d -= (s16b)rand_int(3);
1661                         o_ptr->to_h -= (s16b)rand_int(3);
1662                 }
1663         }
1664
1665         if (((artifact_bias == BIAS_MAGE) || (artifact_bias == BIAS_INT)) && (o_ptr->tval == TV_GLOVES)) o_ptr->art_flags2 |= TR2_FREE_ACT;
1666
1667         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
1668         {
1669                 o_ptr->to_h = 0;
1670                 o_ptr->to_d = 0;
1671                 o_ptr->art_flags1 &= ~(TR1_BLOWS);
1672                 o_ptr->art_flags1 &= ~(TR1_FORCE_WEPON);
1673                 o_ptr->art_flags1 &= ~(TR1_SLAY_ANIMAL);
1674                 o_ptr->art_flags1 &= ~(TR1_SLAY_EVIL);
1675                 o_ptr->art_flags1 &= ~(TR1_SLAY_UNDEAD);
1676                 o_ptr->art_flags1 &= ~(TR1_SLAY_DEMON);
1677                 o_ptr->art_flags1 &= ~(TR1_SLAY_ORC);
1678                 o_ptr->art_flags1 &= ~(TR1_SLAY_TROLL);
1679                 o_ptr->art_flags1 &= ~(TR1_SLAY_GIANT);
1680                 o_ptr->art_flags1 &= ~(TR1_SLAY_DRAGON);
1681                 o_ptr->art_flags1 &= ~(TR1_KILL_DRAGON);
1682                 o_ptr->art_flags1 &= ~(TR1_VORPAL);
1683                 o_ptr->art_flags1 &= ~(TR1_BRAND_POIS);
1684                 o_ptr->art_flags1 &= ~(TR1_BRAND_ACID);
1685                 o_ptr->art_flags1 &= ~(TR1_BRAND_ELEC);
1686                 o_ptr->art_flags1 &= ~(TR1_BRAND_FIRE);
1687                 o_ptr->art_flags1 &= ~(TR1_BRAND_COLD);
1688         }
1689
1690         if (o_ptr->tval >= TV_BOOTS)
1691         {
1692                 if (a_cursed) power_level = 0;
1693                 else if (total_flags < 15000) power_level = 1;
1694                 else if (total_flags < 25000) power_level = 2;
1695                 else power_level = 3;
1696         }
1697
1698         else
1699         {
1700                 if (a_cursed) power_level = 0;
1701                 else if (total_flags < 20000) power_level = 1;
1702                 else if (total_flags < 35000) power_level = 2;
1703                 else power_level = 3;
1704         }
1705
1706         if (a_scroll)
1707         {
1708                 char dummy_name[80];
1709                 strcpy(dummy_name, "");
1710                 (void)identify_fully_aux(o_ptr);
1711
1712 #ifdef JP
1713                 if (!(get_string("¤³¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ò²¿¤È̾ÉÕ¤±¤Þ¤¹¤«¡©", dummy_name, 80)))
1714 #else
1715                 if (!(get_string("What do you want to call the artifact? ", dummy_name, 80)))
1716 #endif
1717
1718                 {
1719                         get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level);
1720                 }
1721                 else
1722                 {
1723 #ifdef JP
1724                         strcpy(new_name, "¡Ô");
1725 #else
1726                         strcpy(new_name, "'");
1727 #endif
1728
1729                         strcat(new_name, dummy_name);
1730 #ifdef JP
1731                         strcat(new_name, "¡Õ¤È¤¤¤¦Ì¾¤Î");
1732 #else
1733                         strcat(new_name, "'");
1734 #endif
1735
1736                 }
1737                 /* Identify it fully */
1738                 object_aware(o_ptr);
1739                 object_known(o_ptr);
1740
1741                 /* Mark the item as fully known */
1742                 o_ptr->ident |= (IDENT_MENTAL);
1743
1744                 chg_virtue(V_INDIVIDUALISM, 2);
1745                 chg_virtue(V_ENCHANT, 5);
1746
1747         }
1748         else
1749         {
1750                 get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level);
1751         }
1752
1753         if (cheat_xtra)
1754         {
1755                 if (artifact_bias)
1756 #ifdef JP
1757 msg_format("±¿¤ÎÊФä¿¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È: %d¡£", artifact_bias);
1758 #else
1759                         msg_format("Biased artifact: %d.", artifact_bias);
1760 #endif
1761
1762                 else
1763 #ifdef JP
1764 msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ë±¿¤ÎÊФê¤Ê¤·¡£");
1765 #else
1766                         msg_print("No bias in artifact.");
1767 #endif
1768
1769         }
1770
1771         /* Save the inscription */
1772         o_ptr->art_name = quark_add(new_name);
1773
1774         /* Window stuff */
1775         p_ptr->window |= (PW_INVEN | PW_EQUIP);
1776
1777         return TRUE;
1778 }
1779
1780
1781 bool activate_random_artifact(object_type * o_ptr)
1782 {
1783         int plev = p_ptr->lev;
1784         int k, dir, dummy = 0;
1785
1786         if (!o_ptr->art_name) return FALSE; /* oops? */
1787
1788         /* Activate for attack */
1789         switch (o_ptr->xtra2)
1790         {
1791                 case ACT_SUNLIGHT:
1792                 {
1793                         if (!get_aim_dir(&dir)) return FALSE;
1794 #ifdef JP
1795                         msg_print("ÂÀÍÛ¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
1796 #else
1797                         msg_print("A line of sunlight appears.");
1798 #endif
1799
1800                         (void)lite_line(dir);
1801                         o_ptr->timeout = 10;
1802                         break;
1803                 }
1804
1805                 case ACT_BO_MISS_1:
1806                 {
1807 #ifdef JP
1808                         msg_print("¤½¤ì¤ÏâÁ¤·¤¤¤¯¤é¤¤¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
1809 #else
1810                         msg_print("It glows extremely brightly...");
1811 #endif
1812
1813                         if (!get_aim_dir(&dir)) return FALSE;
1814                         fire_bolt(GF_MISSILE, dir, damroll(2, 6));
1815                         o_ptr->timeout = 2;
1816                         break;
1817                 }
1818
1819                 case ACT_BA_POIS_1:
1820                 {
1821 #ifdef JP
1822                         msg_print("¤½¤ì¤ÏÇ»Î理Ë̮ư¤·¤Æ¤¤¤ë...");
1823 #else
1824                         msg_print("It throbs deep green...");
1825 #endif
1826
1827                         if (!get_aim_dir(&dir)) return FALSE;
1828                         fire_ball(GF_POIS, dir, 12, 3);
1829                         o_ptr->timeout = rand_int(4) + 4;
1830                         break;
1831                 }
1832
1833                 case ACT_BO_ELEC_1:
1834                 {
1835 #ifdef JP
1836                         msg_print("¤½¤ì¤Ï²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
1837 #else
1838                         msg_print("It is covered in sparks...");
1839 #endif
1840
1841                         if (!get_aim_dir(&dir)) return FALSE;
1842                         fire_bolt(GF_ELEC, dir, damroll(4, 8));
1843                         o_ptr->timeout = rand_int(5) + 5;
1844                         break;
1845                 }
1846
1847                 case ACT_BO_ACID_1:
1848                 {
1849 #ifdef JP
1850                         msg_print("¤½¤ì¤Ï»À¤Ëʤ¤ï¤ì¤¿...");
1851 #else
1852                         msg_print("It is covered in acid...");
1853 #endif
1854
1855                         if (!get_aim_dir(&dir)) return FALSE;
1856                         fire_bolt(GF_ACID, dir, damroll(5, 8));
1857                         o_ptr->timeout = rand_int(6) + 6;
1858                         break;
1859                 }
1860
1861                 case ACT_BO_COLD_1:
1862                 {
1863 #ifdef JP
1864                         msg_print("¤½¤ì¤ÏÁú¤Ëʤ¤ï¤ì¤¿...");
1865 #else
1866                         msg_print("It is covered in frost...");
1867 #endif
1868
1869                         if (!get_aim_dir(&dir)) return FALSE;
1870                         fire_bolt(GF_COLD, dir, damroll(6, 8));
1871                         o_ptr->timeout = rand_int(7) + 7;
1872                         break;
1873                 }
1874
1875                 case ACT_BO_FIRE_1:
1876                 {
1877 #ifdef JP
1878                         msg_print("¤½¤ì¤Ï±ê¤Ëʤ¤ï¤ì¤¿...");
1879 #else
1880                         msg_print("It is covered in fire...");
1881 #endif
1882
1883                         if (!get_aim_dir(&dir)) return FALSE;
1884                         fire_bolt(GF_FIRE, dir, damroll(9, 8));
1885                         o_ptr->timeout = rand_int(8) + 8;
1886                         break;
1887                 }
1888
1889                 case ACT_BA_COLD_1:
1890                 {
1891 #ifdef JP
1892                         msg_print("¤½¤ì¤ÏÁú¤Ëʤ¤ï¤ì¤¿...");
1893 #else
1894                         msg_print("It is covered in frost...");
1895 #endif
1896
1897                         if (!get_aim_dir(&dir)) return FALSE;
1898                         fire_ball(GF_COLD, dir, 48, 2);
1899                         o_ptr->timeout = 400;
1900                         break;
1901                 }
1902
1903                 case ACT_BA_FIRE_1:
1904                 {
1905 #ifdef JP
1906                         msg_print("¤½¤ì¤ÏÀÖ¤¯·ã¤·¤¯µ±¤¤¤¿...");
1907 #else
1908                         msg_print("It glows an intense red...");
1909 #endif
1910
1911                         if (!get_aim_dir(&dir)) return FALSE;
1912                         fire_ball(GF_FIRE, dir, 72, 2);
1913                         o_ptr->timeout = 400;
1914                         break;
1915                 }
1916
1917                 case ACT_DRAIN_1:
1918                 {
1919 #ifdef JP
1920                         msg_print("¤½¤ì¤Ï¹õ¤¯µ±¤¤¤¿...");
1921 #else
1922                         msg_print("It glows black...");
1923 #endif
1924
1925                         if (!get_aim_dir(&dir)) return FALSE;
1926                         if (drain_life(dir, 100))
1927                         o_ptr->timeout = rand_int(100) + 100;
1928                         break;
1929                 }
1930
1931                 case ACT_BA_COLD_2:
1932                 {
1933 #ifdef JP
1934                         msg_print("¤½¤ì¤ÏÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
1935 #else
1936                         msg_print("It glows an intense blue...");
1937 #endif
1938
1939                         if (!get_aim_dir(&dir)) return FALSE;
1940                         fire_ball(GF_COLD, dir, 100, 2);
1941                         o_ptr->timeout = 300;
1942                         break;
1943                 }
1944
1945                 case ACT_BA_ELEC_2:
1946                 {
1947 #ifdef JP
1948                         msg_print("Åŵ¤¤¬¥Ñ¥Á¥Ñ¥Á²»¤òΩ¤Æ¤¿...");
1949 #else
1950                         msg_print("It crackles with electricity...");
1951 #endif
1952
1953                         if (!get_aim_dir(&dir)) return FALSE;
1954                         fire_ball(GF_ELEC, dir, 100, 3);
1955                         o_ptr->timeout = 500;
1956                         break;
1957                 }
1958
1959                 case ACT_DRAIN_2:
1960                 {
1961 #ifdef JP
1962                         msg_print("¹õ¤¯µ±¤¤¤Æ¤¤¤ë...");
1963 #else
1964                         msg_print("It glows black...");
1965 #endif
1966
1967                         if (!get_aim_dir(&dir)) return FALSE;
1968                         drain_life(dir, 120);
1969                         o_ptr->timeout = 400;
1970                         break;
1971                 }
1972
1973                 case ACT_VAMPIRE_1:
1974                 {
1975                         if (!get_aim_dir(&dir)) return FALSE;
1976                         for (dummy = 0; dummy < 3; dummy++)
1977                         {
1978                                 if (drain_life(dir, 50))
1979                                 hp_player(50);
1980                         }
1981                         o_ptr->timeout = 400;
1982                         break;
1983                 }
1984
1985                 case ACT_BO_MISS_2:
1986                 {
1987 #ifdef JP
1988                         msg_print("ËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
1989 #else
1990                         msg_print("It grows magical spikes...");
1991 #endif
1992
1993                         if (!get_aim_dir(&dir)) return FALSE;
1994                         fire_bolt(GF_ARROW, dir, 150);
1995                         o_ptr->timeout = rand_int(90) + 90;
1996                         break;
1997                 }
1998
1999                 case ACT_BA_FIRE_2:
2000                 {
2001 #ifdef JP
2002                         msg_print("¿¼ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2003 #else
2004                         msg_print("It glows deep red...");
2005 #endif
2006
2007                         if (!get_aim_dir(&dir)) return FALSE;
2008                         fire_ball(GF_FIRE, dir, 120, 3);
2009                         o_ptr->timeout = rand_int(225) + 225;
2010                         break;
2011                 }
2012
2013                 case ACT_BA_COLD_3:
2014                 {
2015 #ifdef JP
2016                         msg_print("ÌÀ¤ë¤¯Çò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2017 #else
2018                         msg_print("It glows bright white...");
2019 #endif
2020
2021                         if (!get_aim_dir(&dir)) return FALSE;
2022                         fire_ball(GF_COLD, dir, 200, 3);
2023                         o_ptr->timeout = rand_int(325) + 325;
2024                         break;
2025                 }
2026
2027                 case ACT_BA_ELEC_3:
2028                 {
2029 #ifdef JP
2030                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2031 #else
2032                         msg_print("It glows deep blue...");
2033 #endif
2034
2035                         if (!get_aim_dir(&dir)) return FALSE;
2036                         fire_ball(GF_ELEC, dir, 250, 3);
2037                         o_ptr->timeout = rand_int(425) + 425;
2038                         break;
2039                 }
2040
2041                 case ACT_WHIRLWIND:
2042                 {
2043                         {
2044                                 int y = 0, x = 0;
2045                                 cave_type       *c_ptr;
2046                                 monster_type    *m_ptr;
2047
2048                                 for (dir = 0; dir <= 9; dir++)
2049                                 {
2050                                         y = py + ddy[dir];
2051                                         x = px + ddx[dir];
2052                                         c_ptr = &cave[y][x];
2053
2054                                         /* Get the monster */
2055                                         m_ptr = &m_list[c_ptr->m_idx];
2056
2057                                         /* Hack -- attack monsters */
2058                                         if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x)))
2059                                                 py_attack(y, x, 0);
2060                                 }
2061                         }
2062                         o_ptr->timeout = 250;
2063                         break;
2064                 }
2065
2066                 case ACT_VAMPIRE_2:
2067                 {
2068                         if (!get_aim_dir(&dir)) return FALSE;
2069                         for (dummy = 0; dummy < 3; dummy++)
2070                         {
2071                                 if (drain_life(dir, 100))
2072                                 hp_player(100);
2073                         }
2074
2075                         o_ptr->timeout = 400;
2076                         break;
2077                 }
2078
2079
2080                 case ACT_CALL_CHAOS:
2081                 {
2082 #ifdef JP
2083                         msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
2084 #else
2085                         msg_print("It glows in scintillating colours...");
2086 #endif
2087
2088                         call_chaos();
2089                         o_ptr->timeout = 350;
2090                         break;
2091                 }
2092
2093                 case ACT_ROCKET:
2094                 {
2095                         if (!get_aim_dir(&dir)) return FALSE;
2096 #ifdef JP
2097                         msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
2098 #else
2099                         msg_print("You launch a rocket!");
2100 #endif
2101
2102                         fire_ball(GF_ROCKET, dir, 120 + plev, 2);
2103                         o_ptr->timeout = 400;
2104                         break;
2105                 }
2106
2107                 case ACT_DISP_EVIL:
2108                 {
2109 #ifdef JP
2110                         msg_print("¿ÀÀ»¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
2111 #else
2112                         msg_print("It floods the area with goodness...");
2113 #endif
2114
2115                         dispel_evil(p_ptr->lev * 5);
2116                         o_ptr->timeout = rand_int(300) + 300;
2117                         break;
2118                 }
2119
2120                 case ACT_DISP_GOOD:
2121                 {
2122 #ifdef JP
2123                         msg_print("¼Ù°­¤ÊÊ·°Ïµ¤¤¬½¼Ëþ¤·¤¿...");
2124 #else
2125                         msg_print("It floods the area with evil...");
2126 #endif
2127
2128                         dispel_good(p_ptr->lev * 5);
2129                         o_ptr->timeout = rand_int(300) + 300;
2130                         break;
2131                 }
2132
2133                 case ACT_BA_MISS_3:
2134                 {
2135                         if (!get_aim_dir(&dir)) return FALSE;
2136 #ifdef JP
2137                         msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
2138 #else
2139                         msg_print("You breathe the elements.");
2140 #endif
2141
2142                         fire_ball(GF_MISSILE, dir, 300, 4);
2143                         o_ptr->timeout = 500;
2144                         break;
2145                 }
2146
2147                 /* Activate for other offensive action */
2148
2149                 case ACT_CONFUSE:
2150                 {
2151 #ifdef JP
2152                         msg_print("ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤Æ¤¤¤ë...");
2153 #else
2154                         msg_print("It glows in scintillating colours...");
2155 #endif
2156
2157                         if (!get_aim_dir(&dir)) return FALSE;
2158                         confuse_monster(dir, 20);
2159                         o_ptr->timeout = 15;
2160                         break;
2161                 }
2162
2163                 case ACT_SLEEP:
2164                 {
2165 #ifdef JP
2166                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2167 #else
2168                         msg_print("It glows deep blue...");
2169 #endif
2170
2171                         sleep_monsters_touch();
2172                         o_ptr->timeout = 55;
2173                         break;
2174                 }
2175
2176                 case ACT_QUAKE:
2177                 {
2178                         earthquake(py, px, 10);
2179                         o_ptr->timeout = 50;
2180                         break;
2181                 }
2182
2183                 case ACT_TERROR:
2184                 {
2185                         turn_monsters(40 + p_ptr->lev);
2186                         o_ptr->timeout = 3 * (p_ptr->lev + 10);
2187                         break;
2188                 }
2189
2190                 case ACT_TELE_AWAY:
2191                 {
2192                         if (!get_aim_dir(&dir)) return FALSE;
2193                         (void)fire_beam(GF_AWAY_ALL, dir, plev);
2194                         o_ptr->timeout = 200;
2195                         break;
2196                 }
2197
2198                 case ACT_BANISH_EVIL:
2199                 {
2200                         if (banish_evil(100))
2201                         {
2202 #ifdef JP
2203                                 msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÎϤ¬¼Ù°­¤òÂǤÁÅݤ·¤¿¡ª");
2204 #else
2205                                 msg_print("The power of the artifact banishes evil!");
2206 #endif
2207
2208                         }
2209                         o_ptr->timeout = 250 + randint(250);
2210                         break;
2211                 }
2212
2213                 case ACT_GENOCIDE:
2214                 {
2215 #ifdef JP
2216                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2217 #else
2218                         msg_print("It glows deep blue...");
2219 #endif
2220
2221                         (void)symbol_genocide(200, TRUE);
2222                         o_ptr->timeout = 500;
2223                         break;
2224                 }
2225
2226                 case ACT_MASS_GENO:
2227                 {
2228 #ifdef JP
2229                         msg_print("¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
2230 #else
2231                         msg_print("It lets out a long, shrill note...");
2232 #endif
2233
2234                         (void)mass_genocide(200, TRUE);
2235                         o_ptr->timeout = 1000;
2236                         break;
2237                 }
2238
2239                 /* Activate for summoning / charming */
2240
2241                 case ACT_CHARM_ANIMAL:
2242                 {
2243                         if (!get_aim_dir(&dir)) return FALSE;
2244                         (void)charm_animal(dir, plev);
2245                         o_ptr->timeout = 300;
2246                         break;
2247                 }
2248
2249                 case ACT_CHARM_UNDEAD:
2250                 {
2251                         if (!get_aim_dir(&dir)) return FALSE;
2252                         (void)control_one_undead(dir, plev);
2253                         o_ptr->timeout = 333;
2254                         break;
2255                 }
2256
2257                 case ACT_CHARM_OTHER:
2258                 {
2259                         if (!get_aim_dir(&dir)) return FALSE;
2260                         (void)charm_monster(dir, plev);
2261                         o_ptr->timeout = 400;
2262                         break;
2263                 }
2264
2265                 case ACT_CHARM_ANIMALS:
2266                 {
2267                         (void)charm_animals(plev * 2);
2268                         o_ptr->timeout = 500;
2269                         break;
2270                 }
2271
2272                 case ACT_CHARM_OTHERS:
2273                 {
2274                         charm_monsters(plev * 2);
2275                         o_ptr->timeout = 750;
2276                         break;
2277                 }
2278
2279                 case ACT_SUMMON_ANIMAL:
2280                 {
2281                         (void)summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, TRUE, TRUE, TRUE, FALSE, FALSE);
2282                         o_ptr->timeout = 200 + randint(300);
2283                         break;
2284                 }
2285
2286                 case ACT_SUMMON_PHANTOM:
2287                 {
2288 #ifdef JP
2289                         msg_print("¸¸Îî¤ò¾¤´­¤·¤¿¡£");
2290 #else
2291                         msg_print("You summon a phantasmal servant.");
2292 #endif
2293
2294                         (void)summon_specific(-1, py, px, dun_level, SUMMON_PHANTOM, TRUE, TRUE, TRUE, FALSE, FALSE);
2295                         o_ptr->timeout = 200 + randint(200);
2296                         break;
2297                 }
2298
2299                 case ACT_SUMMON_ELEMENTAL:
2300                 {
2301                         bool pet = (randint(3) == 1);
2302                         bool group = !(pet && (plev < 50));
2303
2304                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, group, FALSE, pet, FALSE, (bool)(!pet)))
2305                         {
2306 #ifdef JP
2307                                 msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿...");
2308 #else
2309                                 msg_print("An elemental materializes...");
2310 #endif
2311
2312
2313                                 if (pet)
2314 #ifdef JP
2315                                         msg_print("¤¢¤Ê¤¿¤ËÉþ½¾¤·¤Æ¤¤¤ë¤è¤¦¤À¡£");
2316 #else
2317                                         msg_print("It seems obedient to you.");
2318 #endif
2319
2320                                 else
2321 #ifdef JP
2322                                         msg_print("¤½¤ì¤ò¥³¥ó¥È¥í¡¼¥ë¤Ç¤­¤Ê¤«¤Ã¤¿¡ª");
2323 #else
2324                                         msg_print("You fail to control it!");
2325 #endif
2326
2327                         }
2328
2329                         o_ptr->timeout = 750;
2330                         break;
2331                 }
2332
2333                 case ACT_SUMMON_DEMON:
2334                 {
2335                         bool pet = (randint(3) == 1);
2336                         bool group = !(pet && (plev < 50));
2337
2338                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, group, FALSE, pet, FALSE, (bool)(!pet)))
2339                         {
2340 #ifdef JP
2341                                 msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
2342 #else
2343                                 msg_print("The area fills with a stench of sulphur and brimstone.");
2344 #endif
2345
2346                                 if (pet)
2347 #ifdef JP
2348                                         msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
2349 #else
2350                                         msg_print("'What is thy bidding... Master?'");
2351 #endif
2352
2353                                 else
2354 #ifdef JP
2355                                         msg_print("¡ÖNON SERVIAM! Wretch! ¤ªÁ°¤Îº²¤òĺ¤¯¤¾¡ª¡×");
2356 #else
2357                                         msg_print("'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'");
2358 #endif
2359
2360                         }
2361
2362                         o_ptr->timeout = 666 + randint(333);
2363                         break;
2364                 }
2365
2366                 case ACT_SUMMON_UNDEAD:
2367                 {
2368                         bool pet = (randint(3) == 1);
2369                         bool group;
2370                         bool unique_okay;
2371                         int type;
2372
2373                         type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
2374                         if (pet)
2375                         {
2376                                 group = (((plev > 24) && (randint(3) == 1)) ? TRUE : FALSE);
2377                                 unique_okay = FALSE;
2378                         }
2379                         else
2380                         {
2381                                 group = TRUE;
2382                                 unique_okay = TRUE;
2383                         }
2384
2385                         if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), type,
2386                                             group, FALSE, pet, unique_okay, (bool)(!pet)))
2387                         {
2388 #ifdef JP
2389                                 msg_print("Î䤿¤¤É÷¤¬¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¿á¤­»Ï¤á¤¿¡£¤½¤ì¤ÏÉåÇÔ½­¤ò±¿¤ó¤Ç¤¤¤ë...");
2390 #else
2391                                 msg_print("Cold winds begin to blow around you, carrying with them the stench of decay...");
2392 #endif
2393
2394                                 if (pet)
2395 #ifdef JP
2396                                         msg_print("¸Å¤¨¤Î»à¤»¤ë¼Ô¶¦¤¬¤¢¤Ê¤¿¤Ë»Å¤¨¤ë¤¿¤áÅÚ¤«¤éᴤä¿¡ª");
2397 #else
2398                                         msg_print("Ancient, long-dead forms arise from the ground to serve you!");
2399 #endif
2400
2401                                 else
2402 #ifdef JP
2403                                         msg_print("»à¼Ô¤¬á´¤Ã¤¿¡£Ì²¤ê¤ò˸¤²¤ë¤¢¤Ê¤¿¤òȳ¤¹¤ë¤¿¤á¤Ë¡ª");
2404 #else
2405                                         msg_print("'The dead arise... to punish you for disturbing them!'");
2406 #endif
2407
2408                         }
2409
2410                         o_ptr->timeout = 666 + randint(333);
2411                         break;
2412                 }
2413
2414                 /* Activate for healing */
2415
2416                 case ACT_CURE_LW:
2417                 {
2418                         (void)set_afraid(0);
2419                         (void)hp_player(30);
2420                         o_ptr->timeout = 10;
2421                         break;
2422                 }
2423
2424                 case ACT_CURE_MW:
2425                 {
2426 #ifdef JP
2427                         msg_print("¿¼»ç¿§¤Î¸÷¤òȯ¤·¤Æ¤¤¤ë...");
2428 #else
2429                         msg_print("It radiates deep purple...");
2430 #endif
2431
2432                         hp_player(damroll(4, 8));
2433                         (void)set_cut((p_ptr->cut / 2) - 50);
2434                         o_ptr->timeout = rand_int(3) + 3;
2435                         break;
2436                 }
2437
2438                 case ACT_CURE_POISON:
2439                 {
2440 #ifdef JP
2441                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2442 #else
2443                         msg_print("It glows deep blue...");
2444 #endif
2445
2446                         (void)set_afraid(0);
2447                         (void)set_poisoned(0);
2448                         o_ptr->timeout = 5;
2449                         break;
2450                 }
2451
2452                 case ACT_REST_LIFE:
2453                 {
2454 #ifdef JP
2455                         msg_print("¿¼¹È¤Ëµ±¤¤¤Æ¤¤¤ë...");
2456 #else
2457                         msg_print("It glows a deep red...");
2458 #endif
2459
2460                         restore_level();
2461                         o_ptr->timeout = 450;
2462                         break;
2463                 }
2464
2465                 case ACT_REST_ALL:
2466                 {
2467 #ifdef JP
2468                         msg_print("Ç»Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2469 #else
2470                         msg_print("It glows a deep green...");
2471 #endif
2472
2473                         (void)do_res_stat(A_STR);
2474                         (void)do_res_stat(A_INT);
2475                         (void)do_res_stat(A_WIS);
2476                         (void)do_res_stat(A_DEX);
2477                         (void)do_res_stat(A_CON);
2478                         (void)do_res_stat(A_CHR);
2479                         (void)restore_level();
2480                         o_ptr->timeout = 750;
2481                         break;
2482                 }
2483
2484                 case ACT_CURE_700:
2485                 {
2486 #ifdef JP
2487                         msg_print("¿¼ÀÄ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2488 #else
2489                         msg_print("It glows deep blue...");
2490 #endif
2491
2492 #ifdef JP
2493                         msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
2494 #else
2495                         msg_print("You feel a warm tingling inside...");
2496 #endif
2497
2498                         (void)hp_player(700);
2499                         (void)set_cut(0);
2500                         o_ptr->timeout = 250;
2501                         break;
2502                 }
2503
2504                 case ACT_CURE_1000:
2505                 {
2506 #ifdef JP
2507                         msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2508 #else
2509                         msg_print("It glows a bright white...");
2510 #endif
2511
2512 #ifdef JP
2513                         msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
2514 #else
2515                         msg_print("You feel much better...");
2516 #endif
2517
2518                         (void)hp_player(1000);
2519                         (void)set_cut(0);
2520                         o_ptr->timeout = 888;
2521                         break;
2522                 }
2523
2524                 /* Activate for timed effect */
2525
2526                 case ACT_ESP:
2527                 {
2528                         (void)set_tim_esp(randint(30) + 25, FALSE);
2529                         o_ptr->timeout = 200;
2530                         break;
2531                 }
2532
2533                 case ACT_BERSERK:
2534                 {
2535                         (void)set_hero(randint(50) + 50, FALSE);
2536                         (void)set_blessed(randint(50) + 50, FALSE);
2537                         o_ptr->timeout = 100 + randint(100);
2538                         break;
2539                 }
2540
2541                 case ACT_PROT_EVIL:
2542                 {
2543 #ifdef JP
2544                         msg_print("±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
2545 #else
2546                         msg_print("It lets out a shrill wail...");
2547 #endif
2548
2549                         k = 3 * p_ptr->lev;
2550                         (void)set_protevil(randint(25) + k, FALSE);
2551                         o_ptr->timeout = rand_int(225) + 225;
2552                         break;
2553                 }
2554
2555                 case ACT_RESIST_ALL:
2556                 {
2557 #ifdef JP
2558                         msg_print("ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2559 #else
2560                         msg_print("It glows many colours...");
2561 #endif
2562
2563                         (void)set_oppose_acid(randint(40) + 40, FALSE);
2564                         (void)set_oppose_elec(randint(40) + 40, FALSE);
2565                         (void)set_oppose_fire(randint(40) + 40, FALSE);
2566                         (void)set_oppose_cold(randint(40) + 40, FALSE);
2567                         (void)set_oppose_pois(randint(40) + 40, FALSE);
2568                         o_ptr->timeout = 200;
2569                         break;
2570                 }
2571
2572                 case ACT_SPEED:
2573                 {
2574 #ifdef JP
2575                         msg_print("ÌÀ¤ë¤¯Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2576 #else
2577                         msg_print("It glows bright green...");
2578 #endif
2579
2580                         (void)set_fast(randint(20) + 20, FALSE);
2581                         o_ptr->timeout = 250;
2582                         break;
2583                 }
2584
2585                 case ACT_XTRA_SPEED:
2586                 {
2587 #ifdef JP
2588                         msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2589 #else
2590                         msg_print("It glows brightly...");
2591 #endif
2592
2593                         (void)set_fast(randint(75) + 75, FALSE);
2594                         o_ptr->timeout = rand_int(200) + 200;
2595                         break;
2596                 }
2597
2598                 case ACT_WRAITH:
2599                 {
2600                         set_wraith_form(randint(plev / 2) + (plev / 2), FALSE);
2601                         o_ptr->timeout = 1000;
2602                         break;
2603                 }
2604
2605                 case ACT_INVULN:
2606                 {
2607                         (void)set_invuln(randint(8) + 8, FALSE);
2608                         o_ptr->timeout = 1000;
2609                         break;
2610                 }
2611
2612                 /* Activate for general purpose effect (detection etc.) */
2613
2614                 case ACT_LIGHT:
2615                 {
2616 #ifdef JP
2617                         msg_print("À¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
2618 #else
2619                         msg_print("It wells with clear light...");
2620 #endif
2621
2622                         lite_area(damroll(2, 15), 3);
2623                         o_ptr->timeout = rand_int(10) + 10;
2624                         break;
2625                 }
2626
2627                 case ACT_MAP_LIGHT:
2628                 {
2629 #ifdef JP
2630                         msg_print("âÁ¤·¤¯µ±¤¤¤¿...");
2631 #else
2632                         msg_print("It shines brightly...");
2633 #endif
2634
2635                         map_area(DETECT_RAD_MAP);
2636                         lite_area(damroll(2, 15), 3);
2637                         o_ptr->timeout = rand_int(50) + 50;
2638                         break;
2639                 }
2640
2641                 case ACT_DETECT_ALL:
2642                 {
2643 #ifdef JP
2644                         msg_print("Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2645 #else
2646                         msg_print("It glows bright white...");
2647 #endif
2648
2649 #ifdef JP
2650                         msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
2651 #else
2652                         msg_print("An image forms in your mind...");
2653 #endif
2654
2655                         detect_all(DETECT_RAD_DEFAULT);
2656                         o_ptr->timeout = rand_int(55) + 55;
2657                         break;
2658                 }
2659
2660                 case ACT_DETECT_XTRA:
2661                 {
2662 #ifdef JP
2663                         msg_print("ÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2664 #else
2665                         msg_print("It glows brightly...");
2666 #endif
2667
2668                         detect_all(DETECT_RAD_DEFAULT);
2669                         probing();
2670                         identify_fully(FALSE);
2671                         o_ptr->timeout = 1000;
2672                         break;
2673                 }
2674
2675                 case ACT_ID_FULL:
2676                 {
2677 #ifdef JP
2678                         msg_print("²«¿§¤¯µ±¤¤¤Æ¤¤¤ë...");
2679 #else
2680                         msg_print("It glows yellow...");
2681 #endif
2682
2683                         identify_fully(FALSE);
2684                         o_ptr->timeout = 750;
2685                         break;
2686                 }
2687
2688                 case ACT_ID_PLAIN:
2689                 {
2690                         if (!ident_spell(FALSE)) return FALSE;
2691                         o_ptr->timeout = 10;
2692                         break;
2693                 }
2694
2695                 case ACT_RUNE_EXPLO:
2696                 {
2697 #ifdef JP
2698                         msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2699 #else
2700                         msg_print("It glows bright red...");
2701 #endif
2702
2703                         explosive_rune();
2704                         o_ptr->timeout = 200;
2705                         break;
2706                 }
2707
2708                 case ACT_RUNE_PROT:
2709                 {
2710 #ifdef JP
2711                         msg_print("¥Ö¥ë¡¼¤ËÌÀ¤ë¤¯µ±¤¤¤Æ¤¤¤ë...");
2712 #else
2713                         msg_print("It glows light blue...");
2714 #endif
2715
2716                         warding_glyph();
2717                         o_ptr->timeout = 400;
2718                         break;
2719                 }
2720
2721                 case ACT_SATIATE:
2722                 {
2723                         (void)set_food(PY_FOOD_MAX - 1);
2724                         o_ptr->timeout = 200;
2725                         break;
2726                 }
2727
2728                 case ACT_DEST_DOOR:
2729                 {
2730 #ifdef JP
2731                         msg_print("ÌÀ¤ë¤¤ÀÖ¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2732 #else
2733                         msg_print("It glows bright red...");
2734 #endif
2735
2736                         destroy_doors_touch();
2737                         o_ptr->timeout = 10;
2738                         break;
2739                 }
2740
2741                 case ACT_STONE_MUD:
2742                 {
2743 #ifdef JP
2744                         msg_print("¸ÝÆ°¤·¤Æ¤¤¤ë...");
2745 #else
2746                         msg_print("It pulsates...");
2747 #endif
2748
2749                         if (!get_aim_dir(&dir)) return FALSE;
2750                         wall_to_mud(dir);
2751                         o_ptr->timeout = 5;
2752                         break;
2753                 }
2754
2755                 case ACT_RECHARGE:
2756                 {
2757                         recharge(130);
2758                         o_ptr->timeout = 70;
2759                         break;
2760                 }
2761
2762                 case ACT_ALCHEMY:
2763                 {
2764 #ifdef JP
2765                         msg_print("ÌÀ¤ë¤¤²«¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2766 #else
2767                         msg_print("It glows bright yellow...");
2768 #endif
2769
2770                         (void)alchemy();
2771                         o_ptr->timeout = 500;
2772                         break;
2773                 }
2774
2775                 case ACT_DIM_DOOR:
2776                 {
2777 #ifdef JP
2778                         msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
2779 #else
2780                         msg_print("You open a dimensional gate. Choose a destination.");
2781 #endif
2782
2783                         if (!dimension_door()) return FALSE;
2784                         o_ptr->timeout = 100;
2785                         break;
2786                 }
2787
2788
2789                 case ACT_TELEPORT:
2790                 {
2791 #ifdef JP
2792                         msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ë...");
2793 #else
2794                         msg_print("It twists space around you...");
2795 #endif
2796
2797                         teleport_player(100);
2798                         o_ptr->timeout = 45;
2799                         break;
2800                 }
2801
2802                 case ACT_RECALL:
2803                 {
2804 #ifdef JP
2805                         msg_print("¤ä¤ï¤é¤«¤ÊÇò¿§¤Ëµ±¤¤¤Æ¤¤¤ë...");
2806 #else
2807                         msg_print("It glows soft white...");
2808 #endif
2809                         if (!word_of_recall()) return FALSE;
2810                         o_ptr->timeout = 200;
2811                         break;
2812                 }
2813
2814                 default:
2815                 {
2816 #ifdef JP
2817                         msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
2818 #else
2819                         msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
2820 #endif
2821
2822                         return FALSE;
2823                 }
2824         }
2825
2826         return TRUE;
2827 }
2828
2829
2830 void random_artifact_resistance(object_type * o_ptr)
2831 {
2832         bool give_resistance = FALSE, give_power = FALSE;
2833
2834         if (o_ptr->name1 == ART_TERROR) /* Terror Mask is for warriors... */
2835         {
2836                 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_ARCHER || p_ptr->pclass == CLASS_CAVALRY || p_ptr->pclass == CLASS_BERSERKER)
2837                 {
2838                         give_power = TRUE;
2839                         give_resistance = TRUE;
2840                 }
2841                 else
2842                 {
2843                         o_ptr->art_flags3 |=
2844                             (TR3_CURSED | TR3_HEAVY_CURSE | TR3_AGGRAVATE | TR3_TY_CURSE);
2845                         o_ptr->ident |= IDENT_CURSED;
2846                         return;
2847                 }
2848         }
2849         if (o_ptr->name1 == ART_MURAMASA)
2850         {
2851                 if (p_ptr->pclass != CLASS_SAMURAI)
2852                 {
2853                         o_ptr->art_flags3 |= (TR3_NO_TELE | TR3_NO_MAGIC | TR3_HEAVY_CURSE);
2854                         o_ptr->ident |= IDENT_CURSED;
2855                 }
2856         }
2857
2858         if (o_ptr->name1 == ART_XIAOLONG)
2859         {
2860                 if (p_ptr->pclass == CLASS_MONK)
2861                         o_ptr->art_flags1 |= TR1_BLOWS;
2862         }
2863
2864         if (o_ptr->name1 == ART_BLOOD)
2865         {
2866                 int dummy, i;
2867                 dummy = randint(2)+randint(2);
2868                 for (i = 0; i < dummy; i++)
2869                         o_ptr->art_flags1 |= (TR1_CHAOTIC << rand_int(18));
2870                 dummy = randint(2);
2871                 for (i = 0; i < dummy; i++)
2872                         random_resistance(o_ptr, FALSE, randint(34) + 4);
2873                 dummy = 2;
2874                 for (i = 0; i < dummy; i++)
2875                 {
2876                         int tmp = rand_int(11);
2877                         if (tmp < 6) o_ptr->art_flags1 |= (TR1_STR << tmp);
2878                         else o_ptr->art_flags1 |= (TR1_STEALTH << (tmp - 6));
2879                 }
2880         }
2881
2882         switch (o_ptr->name1)
2883         {
2884                 case ART_CELEBORN:
2885                 case ART_ARVEDUI:
2886                 case ART_CASPANION:
2887                 case ART_HITHLOMIR:
2888                 case ART_ROHIRRIM:
2889                 case ART_CELEGORM:
2890                 case ART_ANARION:
2891                 case ART_THRANDUIL:
2892                 case ART_LUTHIEN:
2893                 case ART_THROR:
2894                 case ART_THORIN:
2895                 case ART_NIMTHANC:
2896                 case ART_DETHANC:
2897                 case ART_NARTHANC:
2898                 case ART_STING:
2899                 case ART_TURMIL:
2900                 case ART_THALKETTOTH:
2901                 case ART_JIZO:
2902                         {
2903                                 /* Give a resistance */
2904                                 give_resistance = TRUE;
2905                         }
2906                         break;
2907                 case ART_MAEDHROS:
2908                 case ART_GLAMDRING:
2909                 case ART_ORCRIST:
2910                 case ART_ANDURIL:
2911                 case ART_ZARCUTHRA:
2912                 case ART_GURTHANG:
2913                 case ART_HARADEKKET:
2914                 case ART_BRAND:
2915                 case ART_DAWN:
2916                 case ART_BUCKLAND:
2917                 case ART_AZAGHAL:
2918                         {
2919                                 /* Give a resistance OR a power */
2920                                 if (randint(2) == 1) give_resistance = TRUE;
2921                                 else give_power = TRUE;
2922                         }
2923                         break;
2924                 case ART_NENYA:
2925                 case ART_VILYA:
2926                 case ART_BERUTHIEL:
2927                 case ART_THINGOL:
2928                 case ART_ULMO:
2929                 case ART_OLORIN:
2930                         {
2931                                 /* Give a power */
2932                                 give_power = TRUE;
2933                         }
2934                         break;
2935                 case ART_CRIMSON:
2936                 case ART_POWER:
2937                 case ART_GONDOR:
2938                 case ART_AULE:
2939                         {
2940                                 /* Give both */
2941                                 give_power = TRUE;
2942                                 give_resistance = TRUE;
2943                         }
2944                         break;
2945         }
2946
2947         if (give_power)
2948         {
2949                 o_ptr->xtra1 = EGO_XTRA_ABILITY;
2950
2951                 /* Randomize the "xtra" power */
2952                 if (o_ptr->xtra1) o_ptr->xtra2 = randint(256);
2953         }
2954
2955         artifact_bias = 0;
2956
2957         if (give_resistance)
2958         {
2959                 random_resistance(o_ptr, FALSE, randint(22) + 16);
2960         }
2961 }
2962
2963
2964 /*
2965  * Create the artifact of the specified number
2966  */
2967 void create_named_art(int a_idx, int y, int x)
2968 {
2969         object_type forge;
2970         object_type *q_ptr;
2971         int i;
2972
2973         artifact_type *a_ptr = &a_info[a_idx];
2974
2975         /* Get local object */
2976         q_ptr = &forge;
2977
2978         /* Ignore "empty" artifacts */
2979         if (!a_ptr->name) return;
2980
2981         /* Acquire the "kind" index */
2982         i = lookup_kind(a_ptr->tval, a_ptr->sval);
2983
2984         /* Oops */
2985         if (!i) return;
2986
2987         /* Create the artifact */
2988         object_prep(q_ptr, i);
2989
2990         /* Save the name */
2991         q_ptr->name1 = a_idx;
2992
2993         /* Extract the fields */
2994         q_ptr->pval = a_ptr->pval;
2995         q_ptr->ac = a_ptr->ac;
2996         q_ptr->dd = a_ptr->dd;
2997         q_ptr->ds = a_ptr->ds;
2998         q_ptr->to_a = a_ptr->to_a;
2999         q_ptr->to_h = a_ptr->to_h;
3000         q_ptr->to_d = a_ptr->to_d;
3001         q_ptr->weight = a_ptr->weight;
3002
3003         /* Hack -- acquire "cursed" flag */
3004         if (a_ptr->flags3 & TR3_CURSED) q_ptr->ident |= (IDENT_CURSED);
3005
3006         random_artifact_resistance(q_ptr);
3007
3008         /* Drop the artifact from heaven */
3009         (void)drop_near(q_ptr, -1, y, x);
3010 }