OSDN Git Service

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