OSDN Git Service

再び修正。boost効果は1/20の確率でしか起きないので小さすぎて見えない方が
[hengband/hengband.git] / src / wizard2.c
1 /* File: wizard2.c */
2
3 /* Purpose: Wizard commands */
4
5 /*
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research, and
9  * not for profit purposes provided that this copyright and statement are
10  * included in all such copies.
11  */
12
13 #include "angband.h"
14
15
16 /*
17  * Hack -- Rerate Hitpoints
18  */
19 void do_cmd_rerate(bool display)
20 {
21         int min_value, max_value, i, percent, j;
22
23         min_value = ((PY_MAX_LEVEL+2) * (p_ptr->hitdie + 1)) * 3 / 8;
24         min_value += p_ptr->hitdie;
25
26         max_value = ((PY_MAX_LEVEL+2) * (p_ptr->hitdie + 1)) * 5 / 8;
27         max_value += p_ptr->hitdie;
28
29         /* Rerate */
30         while (1)
31         {
32                 player_hp[0] = p_ptr->hitdie;
33
34                 for (i = 1; i < 4; i++)
35                 {
36                         j = randint1(p_ptr->hitdie);
37                         player_hp[0] += j;
38                 }
39
40                 /* Collect values */
41                 for (i = 1; i < PY_MAX_LEVEL; i++)
42                 {
43                         player_hp[i] = randint1(p_ptr->hitdie);
44                         player_hp[i] += player_hp[i - 1];
45                 }
46
47                 /* Legal values */
48                 if ((player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
49                     (player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
50         }
51
52         percent = (int)(((long)player_hp[PY_MAX_LEVEL - 1] * 200L) /
53                 (2 * p_ptr->hitdie +
54                 ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
55
56
57         /* Update and redraw hitpoints */
58         p_ptr->update |= (PU_HP);
59         p_ptr->redraw |= (PR_HP);
60
61         /* Window stuff */
62         p_ptr->window |= (PW_PLAYER);
63
64         /* Handle stuff */
65         handle_stuff();
66
67         /* Message */
68         if (display)
69         {
70 #ifdef JP
71                 msg_format("¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯¤Ï %d/100 ¤Ç¤¹¡£", percent);
72 #else
73                 msg_format("Your life rate is %d/100 now.", percent);
74 #endif
75                 p_ptr->knowledge |= KNOW_HPRATE;
76         }
77         else
78         {
79 #ifdef JP
80                 msg_print("ÂÎÎÏ¥é¥ó¥¯¤¬ÊѤï¤Ã¤¿¡£");
81 #else
82                 msg_print("Life rate is changed.");
83 #endif
84                 p_ptr->knowledge &= ~(KNOW_HPRATE);
85         }
86 }
87
88
89 #ifdef ALLOW_WIZARD
90
91 /*
92  * Dimension Door
93  */
94 static bool wiz_dimension_door(void)
95 {
96         int     x = 0, y = 0;
97
98         if (!tgt_pt(&x, &y)) return FALSE;
99
100         if (!cave_empty_bold(y, x))
101         {
102 #ifdef JP
103 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
104 #else
105                 msg_print("You fail to exit the astral plane correctly!");
106 #endif
107
108                 teleport_player(10);
109         }
110         else teleport_player_to(y, x, FALSE);
111
112         return (TRUE);
113 }
114
115
116 /*
117  * Create the artifact of the specified number -- DAN
118  *
119  */
120 static void wiz_create_named_art(int a_idx)
121 {
122         /* Create the artifact */
123         create_named_art(a_idx, py, px);
124
125         /* All done */
126         msg_print("Allocated.");
127 }
128
129
130 /*
131  * Hack -- quick debugging hook
132  */
133 static void do_cmd_wiz_hack_ben(void)
134 {
135         /* Oops */
136         msg_print("Oops.");
137         (void)probing();
138 }
139
140
141
142 #ifdef MONSTER_HORDES
143
144 /* Summon a horde of monsters */
145 static void do_cmd_summon_horde(void)
146 {
147         int wy = py, wx = px;
148         int attempts = 1000;
149
150         while (--attempts)
151         {
152                 scatter(&wy, &wx, py, px, 3, 0);
153                 if (cave_naked_bold(wy, wx)) break;
154         }
155
156         (void)alloc_horde(wy, wx);
157 }
158
159 #endif /* MONSTER_HORDES */
160
161
162 /*
163  * Output a long int in binary format.
164  */
165 static void prt_binary(u32b flags, int row, int col)
166 {
167         int             i;
168         u32b        bitmask;
169
170         /* Scan the flags */
171         for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
172         {
173                 /* Dump set bits */
174                 if (flags & bitmask)
175                 {
176                         Term_putch(col++, row, TERM_BLUE, '*');
177                 }
178
179                 /* Dump unset bits */
180                 else
181                 {
182                         Term_putch(col++, row, TERM_WHITE, '-');
183                 }
184         }
185 }
186
187
188 #define K_MAX_DEPTH 110
189
190 /*
191  * Output a rarity graph for a type of object.
192  */
193 static void prt_alloc(byte tval, byte sval, int row, int col)
194 {
195         int i, j;
196         int home = 0;
197         u32b maxd = 1, maxr = 1, maxt = 1;
198         u32b rarity[K_MAX_DEPTH];
199         u32b total[K_MAX_DEPTH];
200         u32b display[22];
201         byte c = TERM_WHITE;
202         cptr r = "+--common--+";
203         object_kind *k_ptr;
204
205
206         /* Get the entry */
207         alloc_entry *table = alloc_kind_table;
208
209         /* Wipe the tables */
210         (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
211         (void)C_WIPE(total, K_MAX_DEPTH, u32b);
212         (void)C_WIPE(display, 22, u32b);
213
214         /* Scan all entries */
215         for (i = 0; i < K_MAX_DEPTH; i++)
216         {
217                 for (j = 0; j < alloc_kind_size; j++)
218                 {
219                         int prob = 0;
220
221                         if (table[j].level <= i)
222                         {
223                                 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
224                         }
225                         else if (table[j].level - 1 > 0)
226                         {
227                                 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
228                         }
229
230                         /* Acquire this kind */
231                         k_ptr = &k_info[table[j].index];
232
233                         /* Accumulate probabilities */
234                         total[i] += prob;
235
236                         /* Accumulate probabilities */
237                         if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
238                         {
239                                 home = k_ptr->level;
240                                 rarity[i] += prob;
241                         }
242                 }
243         }
244
245         /* Find maxima */
246         for (i = 0; i < K_MAX_DEPTH; i++)
247         {
248                 if (rarity[i] > maxr) maxr = rarity[i];
249                 if (total[i] > maxt) maxt = total[i];
250         }
251
252         /* Simulate a log graph */
253         if (maxt / maxr > 32)
254         {
255                 c = TERM_L_WHITE;
256                 r = "+-uncommon-+";
257         }
258         if (maxt / maxr > 1024)
259         {
260                 c = TERM_SLATE;
261                 r = "+---rare---+";
262         }
263         if (maxt / maxr > 32768L)
264         {
265                 c = TERM_L_DARK;
266                 r = "+--unique--+";
267         }
268
269         /* Calculate probabilities for each range */
270         for (i = 0; i < 22; i++)
271         {
272                 /* Shift the values into view */
273                 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
274                 {
275                         display[i] += rarity[j] * (100 * maxt / total[j]);
276                 }
277
278                 /* Correct proportions */
279                 display[i] /= maxr;
280
281                 /* Track maximum */
282                 if (display[i] > maxd) maxd = display[i];
283         }
284
285         /* Normalize */
286         for (i = 0; i < 22; i++)
287         {
288                 display[i] = display[i] * 10 / maxd;
289         }
290
291         /* Graph the rarities */
292         for (i = 0; i < 22; i++)
293         {
294                 Term_putch(col, row + i + 1, TERM_WHITE,  '|');
295
296                 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
297
298                 /* Note the level */
299                 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
300                 {
301                         c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
302                 }
303                 else
304                 {
305                         c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
306                 }
307         }
308
309         /* Make it look nice */
310         prt(r, row, col);
311 }
312
313
314 /*
315  * Hack -- Teleport to the target
316  */
317 static void do_cmd_wiz_bamf(void)
318 {
319         /* Must have a target */
320         if (!target_who) return;
321
322         /* Teleport to the target */
323         teleport_player_to(target_row, target_col, FALSE);
324 }
325
326
327 /*
328  * Aux function for "do_cmd_wiz_change()".      -RAK-
329  */
330 static void do_cmd_wiz_change_aux(void)
331 {
332         int i, j;
333         int tmp_int;
334         long tmp_long;
335         s16b tmp_s16b;
336         char tmp_val[160];
337         char ppp[80];
338
339
340         /* Query the stats */
341         for (i = 0; i < 6; i++)
342         {
343                 /* Prompt */
344                 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
345
346                 /* Default */
347                 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
348
349                 /* Query */
350                 if (!get_string(ppp, tmp_val, 3)) return;
351
352                 /* Extract */
353                 tmp_int = atoi(tmp_val);
354
355                 /* Verify */
356                 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
357                 else if (tmp_int < 3) tmp_int = 3;
358
359                 /* Save it */
360                 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
361         }
362
363
364         /* Default */
365         sprintf(tmp_val, "8000");
366
367         /* Query */
368 #ifdef JP
369         if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
370 #else
371         if (!get_string("Proficiency: ", tmp_val, 9)) return;
372 #endif
373
374         /* Extract */
375         tmp_s16b = atoi(tmp_val);
376
377         /* Verify */
378         if (tmp_s16b < 0) tmp_s16b = 0L;
379         if (tmp_s16b > 8000) tmp_s16b = 8000L;
380
381         for (j = 0; j <= TV_SWORD - TV_BOW;j++)
382         {
383                 for (i = 0;i < 64;i++)
384                 {
385                         weapon_exp[j][i] = tmp_s16b;
386                         if (weapon_exp[j][i] > s_info[p_ptr->pclass].w_max[j][i]) weapon_exp[j][i] = s_info[p_ptr->pclass].w_max[j][i];
387                 }
388         }
389
390         for (j = 0; j < 10; j++)
391         {
392                 skill_exp[j] = tmp_s16b;
393                 if (skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
394         }
395
396         for (j = 0; j < 32; j++)
397                 spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
398         for (; j < 64; j++)
399                 spell_exp[j] = (tmp_s16b > 1400 ? 1400 : tmp_s16b);
400
401         /* Default */
402         sprintf(tmp_val, "%ld", (long)(p_ptr->au));
403
404         /* Query */
405         if (!get_string("Gold: ", tmp_val, 9)) return;
406
407         /* Extract */
408         tmp_long = atol(tmp_val);
409
410         /* Verify */
411         if (tmp_long < 0) tmp_long = 0L;
412
413         /* Save */
414         p_ptr->au = tmp_long;
415
416
417         /* Default */
418         sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
419
420         /* Query */
421         if (!get_string("Experience: ", tmp_val, 9)) return;
422
423         /* Extract */
424         tmp_long = atol(tmp_val);
425
426         /* Verify */
427         if (tmp_long < 0) tmp_long = 0L;
428
429         if (p_ptr->prace != RACE_ANDROID)
430         {
431                 /* Save */
432                 p_ptr->max_exp = tmp_long;
433                 p_ptr->exp = tmp_long;
434
435                 /* Update */
436                 check_experience();
437         }
438 }
439
440
441 /*
442  * Change various "permanent" player variables.
443  */
444 static void do_cmd_wiz_change(void)
445 {
446         /* Interact */
447         do_cmd_wiz_change_aux();
448
449         /* Redraw everything */
450         do_cmd_redraw();
451 }
452
453
454 /*
455  * Wizard routines for creating objects         -RAK-
456  * And for manipulating them!                   -Bernd-
457  *
458  * This has been rewritten to make the whole procedure
459  * of debugging objects much easier and more comfortable.
460  *
461  * The following functions are meant to play with objects:
462  * Create, modify, roll for them (for statistic purposes) and more.
463  * The original functions were by RAK.
464  * The function to show an item's debug information was written
465  * by David Reeve Sward <sward+@CMU.EDU>.
466  *                             Bernd (wiebelt@mathematik.hu-berlin.de)
467  *
468  * Here are the low-level functions
469  * - wiz_display_item()
470  *     display an item's debug-info
471  * - wiz_create_itemtype()
472  *     specify tval and sval (type and subtype of object)
473  * - wiz_tweak_item()
474  *     specify pval, +AC, +tohit, +todam
475  *     Note that the wizard can leave this function anytime,
476  *     thus accepting the default-values for the remaining values.
477  *     pval comes first now, since it is most important.
478  * - wiz_reroll_item()
479  *     apply some magic to the item or turn it into an artifact.
480  * - wiz_roll_item()
481  *     Get some statistics about the rarity of an item:
482  *     We create a lot of fake items and see if they are of the
483  *     same type (tval and sval), then we compare pval and +AC.
484  *     If the fake-item is better or equal it is counted.
485  *     Note that cursed items that are better or equal (absolute values)
486  *     are counted, too.
487  *     HINT: This is *very* useful for balancing the game!
488  * - wiz_quantity_item()
489  *     change the quantity of an item, but be sane about it.
490  *
491  * And now the high-level functions
492  * - do_cmd_wiz_play()
493  *     play with an existing object
494  * - wiz_create_item()
495  *     create a new object
496  *
497  * Note -- You do not have to specify "pval" and other item-properties
498  * directly. Just apply magic until you are satisfied with the item.
499  *
500  * Note -- For some items (such as wands, staffs, some rings, etc), you
501  * must apply magic, or you will get "broken" or "uncharged" objects.
502  *
503  * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
504  * the artifact.  Be careful.
505  *
506  * Hack -- this function will allow you to create multiple artifacts.
507  * This "feature" may induce crashes or other nasty effects.
508  */
509
510 /*
511  * Just display an item's properties (debug-info)
512  * Originally by David Reeve Sward <sward+@CMU.EDU>
513  * Verbose item flags by -Bernd-
514  */
515 static void wiz_display_item(object_type *o_ptr)
516 {
517         int i, j = 13;
518         u32b f1, f2, f3;
519         char buf[256];
520
521         /* Extract the flags */
522         object_flags(o_ptr, &f1, &f2, &f3);
523
524         /* Clear the screen */
525         for (i = 1; i <= 23; i++) prt("", i, j - 2);
526
527         prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
528
529         /* Describe fully */
530         object_desc_store(buf, o_ptr, TRUE, 3);
531
532         prt(buf, 2, j);
533
534         prt(format("kind = %-5d  level = %-4d  tval = %-5d  sval = %-5d",
535                    o_ptr->k_idx, get_object_level(o_ptr),
536                    o_ptr->tval, o_ptr->sval), 4, j);
537
538         prt(format("number = %-3d  wgt = %-6d  ac = %-5d    damage = %dd%d",
539                    o_ptr->number, o_ptr->weight,
540                    o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
541
542         prt(format("pval = %-5d  toac = %-5d  tohit = %-4d  todam = %-4d",
543                    o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
544
545         prt(format("name1 = %-4d  name2 = %-4d  cost = %ld",
546                    o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
547
548         prt(format("ident = %04x  xtra1 = %-4d  xtra2 = %-4d  timeout = %-d",
549                    o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
550
551         prt(format("xtra3 = %-4d  xtra4 = %-4d  xtra5 = %-4d",
552                    o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5), 9, j);
553
554         prt("+------------FLAGS1------------+", 10, j);
555         prt("AFFECT........SLAY........BRAND.", 11, j);
556         prt("      mr      cvae      xsqpaefc", 12, j);
557         prt("siwdccsissidsahanvudotgddhuoclio", 13, j);
558         prt("tnieohtrtrnipttmiinmrrnrrraiierl", 14, j);
559         prt("rtsxnarylcfgdkcpmldncltggpksdced", 15, j);
560         prt_binary(f1, 16, j);
561
562         prt("+------------FLAGS2------------+", 17, j);
563         prt("SUST....IMMUN.RESIST............", 18, j);
564         prt("        aefctrpsaefcpfldbc sn   ", 19, j);
565         prt("siwdcc  clioheatcliooeialoshtncd", 20, j);
566         prt("tnieoh  ierlrfraierliatrnnnrhehi", 21, j);
567         prt("rtsxna..dcedwlatdcedsrekdfddrxss", 22, j);
568         prt_binary(f2, 23, j);
569
570         prt("+------------FLAGS3------------+", 10, j+32);
571         prt("fe cnn t   i  stdrmsiiii d abchp", 11, j+32);
572         prt("aa aoomyehsnlleeieihgggg rtgluvr", 12, j+32);
573         prt("uu utmacaihseielgggonnnnaaerercc", 13, j+32);
574         prt("rr reanusdotvtieeehtrrrrcilassuu", 14, j+32);
575         prt("aa algaryewaienpsntsaefctnevserr", 15, j+32);
576         prt_binary(f3, 16, j+32);
577 }
578
579
580 /*
581  * A structure to hold a tval and its description
582  */
583 typedef struct tval_desc
584 {
585         int        tval;
586         cptr       desc;
587 } tval_desc;
588
589 /*
590  * A list of tvals and their textual names
591  */
592 static tval_desc tvals[] =
593 {
594         { TV_SWORD,             "Sword"                },
595         { TV_POLEARM,           "Polearm"              },
596         { TV_HAFTED,            "Hafted Weapon"        },
597         { TV_BOW,               "Bow"                  },
598         { TV_ARROW,             "Arrows"               },
599         { TV_BOLT,              "Bolts"                },
600         { TV_SHOT,              "Shots"                },
601         { TV_SHIELD,            "Shield"               },
602         { TV_CROWN,             "Crown"                },
603         { TV_HELM,              "Helm"                 },
604         { TV_GLOVES,            "Gloves"               },
605         { TV_BOOTS,             "Boots"                },
606         { TV_CLOAK,             "Cloak"                },
607         { TV_DRAG_ARMOR,        "Dragon Scale Mail"    },
608         { TV_HARD_ARMOR,        "Hard Armor"           },
609         { TV_SOFT_ARMOR,        "Soft Armor"           },
610         { TV_RING,              "Ring"                 },
611         { TV_AMULET,            "Amulet"               },
612         { TV_LITE,              "Lite"                 },
613         { TV_POTION,            "Potion"               },
614         { TV_SCROLL,            "Scroll"               },
615         { TV_WAND,              "Wand"                 },
616         { TV_STAFF,             "Staff"                },
617         { TV_ROD,               "Rod"                  },
618         { TV_LIFE_BOOK,         "Life Spellbook"       },
619         { TV_SORCERY_BOOK,      "Sorcery Spellbook"    },
620         { TV_NATURE_BOOK,       "Nature Spellbook"     },
621         { TV_CHAOS_BOOK,        "Chaos Spellbook"      },
622         { TV_DEATH_BOOK,        "Death Spellbook"      },
623         { TV_TRUMP_BOOK,        "Trump Spellbook"      },
624         { TV_ARCANE_BOOK,       "Arcane Spellbook"     },
625         { TV_ENCHANT_BOOK,      "Craft Spellbook"},
626         { TV_DAEMON_BOOK,       "Daemon Spellbook"},
627         { TV_MUSIC_BOOK,        "Music Spellbook"      },
628         { TV_HISSATSU_BOOK,     "Book of Kendo" },
629         { TV_PARCHEMENT,        "Parchement" },
630         { TV_WHISTLE,           "Whistle"       },
631         { TV_SPIKE,             "Spikes"               },
632         { TV_DIGGING,           "Digger"               },
633         { TV_CHEST,             "Chest"                },
634         { TV_CAPTURE,           "Capture Ball"         },
635         { TV_CARD,              "Express Card"         },
636         { TV_FIGURINE,          "Magical Figurine"     },
637         { TV_STATUE,            "Statue"               },
638         { TV_CORPSE,            "Corpse"               },
639         { TV_FOOD,              "Food"                 },
640         { TV_FLASK,             "Flask"                },
641         { TV_JUNK,              "Junk"                 },
642         { TV_SKELETON,          "Skeleton"             },
643         { 0,                    NULL                   }
644 };
645
646
647 /*
648  * Strip an "object name" into a buffer
649  */
650 void strip_name(char *buf, int k_idx)
651 {
652         char *t;
653
654         object_kind *k_ptr = &k_info[k_idx];
655
656         cptr str = (k_name + k_ptr->name);
657
658
659         /* Skip past leading characters */
660         while ((*str == ' ') || (*str == '&')) str++;
661
662         /* Copy useful chars */
663         for (t = buf; *str; str++)
664         {
665 #ifdef JP
666                 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
667 #endif
668                 if (*str != '~') *t++ = *str;
669         }
670
671         /* Terminate the new name */
672         *t = '\0';
673 }
674
675
676 /*
677  * Specify tval and sval (type and subtype of object) originally
678  * by RAK, heavily modified by -Bernd-
679  *
680  * This function returns the k_idx of an object type, or zero if failed
681  *
682  * List up to 50 choices in three columns
683  */
684 static int wiz_create_itemtype(void)
685 {
686         int i, num, max_num;
687         int col, row;
688         int tval;
689
690         cptr tval_desc;
691         char ch;
692
693         int choice[80];
694
695         char buf[160];
696
697
698         /* Clear screen */
699         Term_clear();
700
701         /* Print all tval's and their descriptions */
702         for (num = 0; (num < 80) && tvals[num].tval; num++)
703         {
704                 row = 2 + (num % 20);
705                 col = 20 * (num / 20);
706                 ch = listsym[num];
707                 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
708         }
709
710         /* Me need to know the maximal possible tval_index */
711         max_num = num;
712
713         /* Choose! */
714         if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
715
716         /* Analyze choice */
717         for (num = 0; num < max_num; num++)
718         {
719                 if (listsym[num] == ch) break;
720         }
721
722         /* Bail out if choice is illegal */
723         if ((num < 0) || (num >= max_num)) return (0);
724
725         /* Base object type chosen, fill in tval */
726         tval = tvals[num].tval;
727         tval_desc = tvals[num].desc;
728
729
730         /*** And now we go for k_idx ***/
731
732         /* Clear screen */
733         Term_clear();
734
735         /* We have to search the whole itemlist. */
736         for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
737         {
738                 object_kind *k_ptr = &k_info[i];
739
740                 /* Analyze matching items */
741                 if (k_ptr->tval == tval)
742                 {
743                         /* Prepare it */
744                         row = 2 + (num % 20);
745                         col = 20 * (num / 20);
746                         ch = listsym[num];
747                         strcpy(buf,"                    ");
748
749                         /* Acquire the "name" of object "i" */
750                         strip_name(buf, i);
751
752                         /* Print it */
753                         prt(format("[%c] %s", ch, buf), row, col);
754
755                         /* Remember the object index */
756                         choice[num++] = i;
757                 }
758         }
759
760         /* Me need to know the maximal possible remembered object_index */
761         max_num = num;
762
763         /* Choose! */
764         if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
765
766         /* Analyze choice */
767         for (num = 0; num < max_num; num++)
768         {
769                 if (listsym[num] == ch) break;
770         }
771
772         /* Bail out if choice is "illegal" */
773         if ((num < 0) || (num >= max_num)) return (0);
774
775         /* And return successful */
776         return (choice[num]);
777 }
778
779
780 /*
781  * Tweak an item
782  */
783 static void wiz_tweak_item(object_type *o_ptr)
784 {
785         cptr p;
786         char tmp_val[80];
787
788
789         /* Hack -- leave artifacts alone */
790         if (artifact_p(o_ptr) || o_ptr->art_name) return;
791
792         p = "Enter new 'pval' setting: ";
793         sprintf(tmp_val, "%d", o_ptr->pval);
794         if (!get_string(p, tmp_val, 5)) return;
795         o_ptr->pval = atoi(tmp_val);
796         wiz_display_item(o_ptr);
797
798         p = "Enter new 'to_a' setting: ";
799         sprintf(tmp_val, "%d", o_ptr->to_a);
800         if (!get_string(p, tmp_val, 5)) return;
801         o_ptr->to_a = atoi(tmp_val);
802         wiz_display_item(o_ptr);
803
804         p = "Enter new 'to_h' setting: ";
805         sprintf(tmp_val, "%d", o_ptr->to_h);
806         if (!get_string(p, tmp_val, 5)) return;
807         o_ptr->to_h = atoi(tmp_val);
808         wiz_display_item(o_ptr);
809
810         p = "Enter new 'to_d' setting: ";
811         sprintf(tmp_val, "%d", o_ptr->to_d);
812         if (!get_string(p, tmp_val, 5)) return;
813         o_ptr->to_d = atoi(tmp_val);
814         wiz_display_item(o_ptr);
815 }
816
817
818 /*
819  * Apply magic to an item or turn it into an artifact. -Bernd-
820  */
821 static void wiz_reroll_item(object_type *o_ptr)
822 {
823         object_type forge;
824         object_type *q_ptr;
825
826         char ch;
827
828         bool changed = FALSE;
829
830
831         /* Hack -- leave artifacts alone */
832         if (artifact_p(o_ptr) || o_ptr->art_name) return;
833
834
835         /* Get local object */
836         q_ptr = &forge;
837
838         /* Copy the object */
839         object_copy(q_ptr, o_ptr);
840
841
842         /* Main loop. Ask for magification and artifactification */
843         while (TRUE)
844         {
845                 /* Display full item debug information */
846                 wiz_display_item(q_ptr);
847
848                 /* Ask wizard what to do. */
849                 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
850                 {
851                         /* Preserve wizard-generated artifacts */
852                         if (artifact_p(q_ptr))
853                         {
854                                 a_info[q_ptr->name1].cur_num = 0;
855                                 q_ptr->name1 = 0;
856                         }
857
858                         changed = FALSE;
859                         break;
860                 }
861
862                 /* Create/change it! */
863                 if (ch == 'A' || ch == 'a')
864                 {
865                         changed = TRUE;
866                         break;
867                 }
868
869                 /* Preserve wizard-generated artifacts */
870                 if (artifact_p(q_ptr))
871                 {
872                         a_info[q_ptr->name1].cur_num = 0;
873                         q_ptr->name1 = 0;
874                 }
875
876                 switch(ch)
877                 {
878                         /* Apply bad magic, but first clear object */
879                         case 'w': case 'W':
880                         {
881                                 object_prep(q_ptr, o_ptr->k_idx);
882                                 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
883                                 break;
884                         }
885                         /* Apply bad magic, but first clear object */
886                         case 'c': case 'C':
887                         {
888                                 object_prep(q_ptr, o_ptr->k_idx);
889                                 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
890                                 break;
891                         }
892                         /* Apply normal magic, but first clear object */
893                         case 'n': case 'N':
894                         {
895                                 object_prep(q_ptr, o_ptr->k_idx);
896                                 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
897                                 break;
898                         }
899                         /* Apply good magic, but first clear object */
900                         case 'g': case 'G':
901                         {
902                                 object_prep(q_ptr, o_ptr->k_idx);
903                                 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
904                                 break;
905                         }
906                         /* Apply great magic, but first clear object */
907                         case 'e': case 'E':
908                         {
909                                 object_prep(q_ptr, o_ptr->k_idx);
910                                 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
911                                 break;
912                         }
913                         case 's': case 'S':
914                         {
915                                 object_prep(q_ptr, o_ptr->k_idx);
916                                 apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
917
918                                 /* Failed to create normal artifact; make a random one */
919                                 if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
920                                 break;
921                         }
922                 }
923                 q_ptr->iy = o_ptr->iy;
924                 q_ptr->ix = o_ptr->ix;
925                 q_ptr->next_o_idx = o_ptr->next_o_idx;
926                 q_ptr->marked = o_ptr->marked;
927         }
928
929
930         /* Notice change */
931         if (changed)
932         {
933                 /* Apply changes */
934                 object_copy(o_ptr, q_ptr);
935
936                 /* Recalculate bonuses */
937                 p_ptr->update |= (PU_BONUS);
938
939                 /* Combine / Reorder the pack (later) */
940                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
941
942                 /* Window stuff */
943                 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
944         }
945 }
946
947
948
949 /*
950  * Try to create an item again. Output some statistics.    -Bernd-
951  *
952  * The statistics are correct now.  We acquire a clean grid, and then
953  * repeatedly place an object in this grid, copying it into an item
954  * holder, and then deleting the object.  We fiddle with the artifact
955  * counter flags to prevent weirdness.  We use the items to collect
956  * statistics on item creation relative to the initial item.
957  */
958 static void wiz_statistics(object_type *o_ptr)
959 {
960         u32b i, matches, better, worse, other, correct;
961
962         u32b test_roll = 1000000;
963
964         char ch;
965         char *quality;
966
967         bool good, great;
968
969         object_type forge;
970         object_type     *q_ptr;
971
972         cptr q = "Rolls: %ld  Correct: %ld  Matches: %ld  Better: %ld  Worse: %ld  Other: %ld";
973
974         cptr p = "Enter number of items to roll: ";
975         char tmp_val[80];
976
977
978         /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
979         if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
980
981
982         /* Interact */
983         while (TRUE)
984         {
985                 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
986
987                 /* Display item */
988                 wiz_display_item(o_ptr);
989
990                 /* Get choices */
991                 if (!get_com(pmt, &ch, FALSE)) break;
992
993                 if (ch == 'n' || ch == 'N')
994                 {
995                         good = FALSE;
996                         great = FALSE;
997                         quality = "normal";
998                 }
999                 else if (ch == 'g' || ch == 'G')
1000                 {
1001                         good = TRUE;
1002                         great = FALSE;
1003                         quality = "good";
1004                 }
1005                 else if (ch == 'e' || ch == 'E')
1006                 {
1007                         good = TRUE;
1008                         great = TRUE;
1009                         quality = "excellent";
1010                 }
1011                 else
1012                 {
1013                         good = FALSE;
1014                         great = FALSE;
1015                         break;
1016                 }
1017
1018                 sprintf(tmp_val, "%ld", test_roll);
1019                 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1020                 test_roll = MAX(1, test_roll);
1021
1022                 /* Let us know what we are doing */
1023                 msg_format("Creating a lot of %s items. Base level = %d.",
1024                                           quality, dun_level);
1025                 msg_print(NULL);
1026
1027                 /* Set counters to zero */
1028                 correct = matches = better = worse = other = 0;
1029
1030                 /* Let's rock and roll */
1031                 for (i = 0; i <= test_roll; i++)
1032                 {
1033                         /* Output every few rolls */
1034                         if ((i < 100) || (i % 100 == 0))
1035                         {
1036                                 /* Do not wait */
1037                                 inkey_scan = TRUE;
1038
1039                                 /* Allow interupt */
1040                                 if (inkey())
1041                                 {
1042                                         /* Flush */
1043                                         flush();
1044
1045                                         /* Stop rolling */
1046                                         break;
1047                                 }
1048
1049                                 /* Dump the stats */
1050                                 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1051                                 Term_fresh();
1052                         }
1053
1054
1055                         /* Get local object */
1056                         q_ptr = &forge;
1057
1058                         /* Wipe the object */
1059                         object_wipe(q_ptr);
1060
1061                         /* Create an object */
1062                         make_object(q_ptr, good, great);
1063
1064
1065                         /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1066                         if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1067
1068
1069                         /* Test for the same tval and sval. */
1070                         if ((o_ptr->tval) != (q_ptr->tval)) continue;
1071                         if ((o_ptr->sval) != (q_ptr->sval)) continue;
1072
1073                         /* One more correct item */
1074                         correct++;
1075
1076                         /* Check for match */
1077                         if ((q_ptr->pval == o_ptr->pval) &&
1078                                  (q_ptr->to_a == o_ptr->to_a) &&
1079                                  (q_ptr->to_h == o_ptr->to_h) &&
1080                                  (q_ptr->to_d == o_ptr->to_d) &&
1081                                  (q_ptr->name1 == o_ptr->name1))
1082                         {
1083                                 matches++;
1084                         }
1085
1086                         /* Check for better */
1087                         else if ((q_ptr->pval >= o_ptr->pval) &&
1088                                                 (q_ptr->to_a >= o_ptr->to_a) &&
1089                                                 (q_ptr->to_h >= o_ptr->to_h) &&
1090                                                 (q_ptr->to_d >= o_ptr->to_d))
1091                         {
1092                                 better++;
1093                         }
1094
1095                         /* Check for worse */
1096                         else if ((q_ptr->pval <= o_ptr->pval) &&
1097                                                 (q_ptr->to_a <= o_ptr->to_a) &&
1098                                                 (q_ptr->to_h <= o_ptr->to_h) &&
1099                                                 (q_ptr->to_d <= o_ptr->to_d))
1100                         {
1101                                 worse++;
1102                         }
1103
1104                         /* Assume different */
1105                         else
1106                         {
1107                                 other++;
1108                         }
1109                 }
1110
1111                 /* Final dump */
1112                 msg_format(q, i, correct, matches, better, worse, other);
1113                 msg_print(NULL);
1114         }
1115
1116
1117         /* Hack -- Normally only make a single artifact */
1118         if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1119 }
1120
1121
1122 /*
1123  * Change the quantity of a the item
1124  */
1125 static void wiz_quantity_item(object_type *o_ptr)
1126 {
1127         int         tmp_int, tmp_qnt;
1128
1129         char        tmp_val[100];
1130
1131
1132         /* Never duplicate artifacts */
1133         if (artifact_p(o_ptr) || o_ptr->art_name) return;
1134
1135         /* Store old quantity. -LM- */
1136         tmp_qnt = o_ptr->number;
1137
1138         /* Default */
1139         sprintf(tmp_val, "%d", o_ptr->number);
1140
1141         /* Query */
1142         if (get_string("Quantity: ", tmp_val, 2))
1143         {
1144                 /* Extract */
1145                 tmp_int = atoi(tmp_val);
1146
1147                 /* Paranoia */
1148                 if (tmp_int < 1) tmp_int = 1;
1149                 if (tmp_int > 99) tmp_int = 99;
1150
1151                 /* Accept modifications */
1152                 o_ptr->number = tmp_int;
1153
1154                 /* Hack -- rod pvals must change if the number in the stack does. -LM- */
1155                 if (o_ptr->tval == TV_ROD)
1156                         o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1157         }
1158 }
1159
1160
1161
1162 /*
1163  * Play with an item. Options include:
1164  *   - Output statistics (via wiz_roll_item)
1165  *   - Reroll item (via wiz_reroll_item)
1166  *   - Change properties (via wiz_tweak_item)
1167  *   - Change the number of items (via wiz_quantity_item)
1168  */
1169 static void do_cmd_wiz_play(void)
1170 {
1171         int item;
1172
1173         object_type     forge;
1174         object_type *q_ptr;
1175
1176         object_type *o_ptr;
1177
1178         char ch;
1179
1180         bool changed;
1181
1182         cptr q, s;
1183
1184         item_tester_no_ryoute = TRUE;
1185         /* Get an item */
1186         q = "Play with which object? ";
1187         s = "You have nothing to play with.";
1188         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1189
1190         /* Get the item (in the pack) */
1191         if (item >= 0)
1192         {
1193                 o_ptr = &inventory[item];
1194         }
1195
1196         /* Get the item (on the floor) */
1197         else
1198         {
1199                 o_ptr = &o_list[0 - item];
1200         }
1201
1202
1203         /* The item was not changed */
1204         changed = FALSE;
1205
1206
1207         /* Save the screen */
1208         screen_save();
1209
1210
1211         /* Get local object */
1212         q_ptr = &forge;
1213
1214         /* Copy object */
1215         object_copy(q_ptr, o_ptr);
1216
1217
1218         /* The main loop */
1219         while (TRUE)
1220         {
1221                 /* Display the item */
1222                 wiz_display_item(q_ptr);
1223
1224                 /* Get choice */
1225                 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1226                 {
1227                         changed = FALSE;
1228                         break;
1229                 }
1230
1231                 if (ch == 'A' || ch == 'a')
1232                 {
1233                         changed = TRUE;
1234                         break;
1235                 }
1236
1237                 if (ch == 's' || ch == 'S')
1238                 {
1239                         wiz_statistics(q_ptr);
1240                 }
1241
1242                 if (ch == 'r' || ch == 'r')
1243                 {
1244                         wiz_reroll_item(q_ptr);
1245                 }
1246
1247                 if (ch == 't' || ch == 'T')
1248                 {
1249                         wiz_tweak_item(q_ptr);
1250                 }
1251
1252                 if (ch == 'q' || ch == 'Q')
1253                 {
1254                         wiz_quantity_item(q_ptr);
1255                 }
1256         }
1257
1258
1259         /* Restore the screen */
1260         screen_load();
1261
1262
1263         /* Accept change */
1264         if (changed)
1265         {
1266                 /* Message */
1267                 msg_print("Changes accepted.");
1268
1269                 /* Change */
1270                 object_copy(o_ptr, q_ptr);
1271
1272                 /* Recalculate bonuses */
1273                 p_ptr->update |= (PU_BONUS);
1274
1275                 /* Combine / Reorder the pack (later) */
1276                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1277
1278                 /* Window stuff */
1279                 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1280         }
1281
1282         /* Ignore change */
1283         else
1284         {
1285                 msg_print("Changes ignored.");
1286         }
1287 }
1288
1289
1290 /*
1291  * Wizard routine for creating objects          -RAK-
1292  * Heavily modified to allow magification and artifactification  -Bernd-
1293  *
1294  * Note that wizards cannot create objects on top of other objects.
1295  *
1296  * Hack -- this routine always makes a "dungeon object", and applies
1297  * magic to it, and attempts to decline cursed items.
1298  */
1299 static void wiz_create_item(void)
1300 {
1301         object_type     forge;
1302         object_type *q_ptr;
1303
1304         int k_idx;
1305
1306
1307         /* Save the screen */
1308         screen_save();
1309
1310         /* Get object base type */
1311         k_idx = wiz_create_itemtype();
1312
1313         /* Restore the screen */
1314         screen_load();
1315
1316
1317         /* Return if failed */
1318         if (!k_idx) return;
1319
1320         /* Get local object */
1321         q_ptr = &forge;
1322
1323         /* Create the item */
1324         object_prep(q_ptr, k_idx);
1325
1326         if (k_info[k_idx].flags3 & TR3_INSTA_ART)
1327         {
1328                 int i;
1329
1330                 /* Artifactify */
1331                 for (i = 1; i < max_a_idx; i++)
1332                 {
1333                         /* Ignore incorrect tval */
1334                         if (a_info[i].tval != q_ptr->tval) continue;
1335
1336                         /* Ignore incorrect sval */
1337                         if (a_info[i].sval != q_ptr->sval) continue;
1338
1339                         /* Choose this artifact */
1340                         q_ptr->name1 = i;
1341                         break;
1342                 }
1343
1344                 /* Apply magic */
1345                 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1346         }
1347         else
1348         {
1349                 /* Apply magic */
1350                 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
1351         }
1352
1353         /* Drop the object from heaven */
1354         (void)drop_near(q_ptr, -1, py, px);
1355
1356         /* All done */
1357         msg_print("Allocated.");
1358 }
1359
1360
1361 /*
1362  * Cure everything instantly
1363  */
1364 static void do_cmd_wiz_cure_all(void)
1365 {
1366         /* Remove curses */
1367         (void)remove_all_curse();
1368
1369         /* Restore stats */
1370         (void)res_stat(A_STR);
1371         (void)res_stat(A_INT);
1372         (void)res_stat(A_WIS);
1373         (void)res_stat(A_CON);
1374         (void)res_stat(A_DEX);
1375         (void)res_stat(A_CHR);
1376
1377         /* Restore the level */
1378         (void)restore_level();
1379
1380         /* Heal the player */
1381         p_ptr->chp = p_ptr->mhp;
1382         p_ptr->chp_frac = 0;
1383
1384         /* Restore mana */
1385         if (p_ptr->csp < p_ptr->msp)
1386         {
1387                 p_ptr->csp = p_ptr->msp;
1388                 p_ptr->csp_frac = 0;
1389         }
1390
1391         /* Cure stuff */
1392         (void)set_blind(0);
1393         (void)set_confused(0);
1394         (void)set_poisoned(0);
1395         (void)set_afraid(0);
1396         (void)set_paralyzed(0);
1397         (void)set_image(0);
1398         (void)set_stun(0);
1399         (void)set_cut(0);
1400         (void)set_slow(0, TRUE);
1401
1402         /* No longer hungry */
1403         (void)set_food(PY_FOOD_MAX - 1);
1404
1405         /* Redraw everything */
1406         do_cmd_redraw();
1407 }
1408
1409
1410 /*
1411  * Go to any level
1412  */
1413 static void do_cmd_wiz_jump(void)
1414 {
1415         /* Ask for level */
1416         if (command_arg <= 0)
1417         {
1418                 char    ppp[80];
1419
1420                 char    tmp_val[160];
1421
1422                 /* Prompt */
1423                 sprintf(ppp, "Jump which dungeon : ");
1424
1425                 /* Default */
1426                 sprintf(tmp_val, "%d", dungeon_type);
1427
1428                 /* Ask for a level */
1429                 if (!get_string(ppp, tmp_val, 2)) return;
1430
1431                 dungeon_type = atoi(tmp_val);
1432                 if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
1433
1434                 /* Prompt */
1435                 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
1436
1437                 /* Default */
1438                 sprintf(tmp_val, "%d", dun_level);
1439
1440                 /* Ask for a level */
1441                 if (!get_string(ppp, tmp_val, 10)) return;
1442
1443                 /* Extract request */
1444                 command_arg = atoi(tmp_val);
1445         }
1446
1447         /* Paranoia */
1448         if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1449
1450         /* Paranoia */
1451         if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1452
1453         /* Accept request */
1454         msg_format("You jump to dungeon level %d.", command_arg);
1455
1456         if (autosave_l) do_cmd_save_game(TRUE);
1457
1458         /* Change level */
1459         dun_level = command_arg;
1460
1461         if (!dun_level) dungeon_type = 0;
1462         p_ptr->inside_arena = FALSE;
1463         leaving_quest = p_ptr->inside_quest;
1464
1465         /* Leaving an 'only once' quest marks it as failed */
1466         if (leaving_quest &&
1467                 (quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
1468                 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
1469         {
1470                 quest[leaving_quest].status = QUEST_STATUS_FAILED;
1471                 quest[leaving_quest].complev = (byte)p_ptr->lev;
1472                 if (record_fix_quest)
1473                         do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1474         }
1475
1476         if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1477
1478         p_ptr->inside_quest = 0;
1479         p_ptr->leftbldg = FALSE;
1480         energy_use = 0;
1481
1482         /* Leaving */
1483         p_ptr->leaving = TRUE;
1484 }
1485
1486
1487 /*
1488  * Become aware of a lot of objects
1489  */
1490 static void do_cmd_wiz_learn(void)
1491 {
1492         int i;
1493
1494         object_type forge;
1495         object_type *q_ptr;
1496
1497         /* Scan every object */
1498         for (i = 1; i < max_k_idx; i++)
1499         {
1500                 object_kind *k_ptr = &k_info[i];
1501
1502                 /* Induce awareness */
1503                 if (k_ptr->level <= command_arg)
1504                 {
1505                         /* Get local object */
1506                         q_ptr = &forge;
1507
1508                         /* Prepare object */
1509                         object_prep(q_ptr, i);
1510
1511                         /* Awareness */
1512                         object_aware(q_ptr);
1513                 }
1514         }
1515 }
1516
1517
1518 /*
1519  * Summon some creatures
1520  */
1521 static void do_cmd_wiz_summon(int num)
1522 {
1523         int i;
1524
1525         for (i = 0; i < num; i++)
1526         {
1527                 (void)summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, FALSE);
1528         }
1529 }
1530
1531
1532 /*
1533  * Summon a creature of the specified type
1534  *
1535  * XXX XXX XXX This function is rather dangerous
1536  */
1537 static void do_cmd_wiz_named(int r_idx, bool slp)
1538 {
1539         int i, x, y;
1540
1541         /* Paranoia */
1542         /* if (!r_idx) return; */
1543
1544         /* Prevent illegal monsters */
1545         if (r_idx >= max_r_idx) return;
1546
1547         /* Try 10 times */
1548         for (i = 0; i < 10; i++)
1549         {
1550                 int d = 1;
1551
1552                 /* Pick a location */
1553                 scatter(&y, &x, py, px, d, 0);
1554
1555                 /* Require empty grids */
1556                 if (!cave_empty_bold(y, x)) continue;
1557
1558                 /* Place it (allow groups) */
1559                 if (place_monster_aux(y, x, r_idx, slp, TRUE, FALSE, FALSE, FALSE, FALSE)) break;
1560         }
1561 }
1562
1563
1564 /*
1565  * Summon a creature of the specified type
1566  *
1567  * XXX XXX XXX This function is rather dangerous
1568  */
1569 static void do_cmd_wiz_named_friendly(int r_idx, bool slp)
1570 {
1571         (void) summon_named_creature(py, px, r_idx, slp, TRUE, TRUE, TRUE);
1572 }
1573
1574
1575
1576 /*
1577  * Hack -- Delete all nearby monsters
1578  */
1579 static void do_cmd_wiz_zap(void)
1580 {
1581         int i;
1582
1583
1584         /* Genocide everyone nearby */
1585         for (i = 1; i < m_max; i++)
1586         {
1587                 monster_type *m_ptr = &m_list[i];
1588
1589                 /* Paranoia -- Skip dead monsters */
1590                 if (!m_ptr->r_idx) continue;
1591
1592                 /* Delete nearby monsters */
1593                 if (m_ptr->cdis <= MAX_SIGHT)
1594                 {
1595                         if (i == p_ptr->riding)
1596                         {
1597                                 rakuba(-1, FALSE);
1598                                 p_ptr->redraw |= (PR_EXTRA);
1599                         }
1600                         delete_monster_idx(i);
1601                 }
1602         }
1603 }
1604
1605
1606 /*
1607  * Hack -- Delete all monsters
1608  */
1609 static void do_cmd_wiz_zap_all(void)
1610 {
1611         int i;
1612
1613         /* Genocide everyone */
1614         for (i = 1; i < m_max; i++)
1615         {
1616                 monster_type *m_ptr = &m_list[i];
1617
1618                 /* Paranoia -- Skip dead monsters */
1619                 if (!m_ptr->r_idx) continue;
1620
1621                 if (i == p_ptr->riding)
1622                 {
1623                         rakuba(-1, FALSE);
1624                         p_ptr->redraw |= (PR_EXTRA);
1625                 }
1626
1627                 /* Delete this monster */
1628                 delete_monster_idx(i);
1629         }
1630 }
1631
1632
1633 #ifdef ALLOW_SPOILERS
1634
1635 /*
1636  * External function
1637  */
1638 extern void do_cmd_spoilers(void);
1639
1640 #endif /* ALLOW_SPOILERS */
1641
1642
1643
1644 /*
1645  * Hack -- declare external function
1646  */
1647 extern void do_cmd_debug(void);
1648
1649
1650
1651 /*
1652  * Ask for and parse a "debug command"
1653  * The "command_arg" may have been set.
1654  */
1655 void do_cmd_debug(void)
1656 {
1657         int     x, y;
1658         char    cmd;
1659
1660
1661         /* Get a "debug command" */
1662         get_com("Debug Command: ", &cmd, FALSE);
1663
1664         /* Analyze the command */
1665         switch (cmd)
1666         {
1667                 /* Nothing */
1668                 case ESCAPE:
1669                 case ' ':
1670                 case '\n':
1671                 case '\r':
1672                 break;
1673
1674
1675 #ifdef ALLOW_SPOILERS
1676
1677                 /* Hack -- Generate Spoilers */
1678                 case '"':
1679                 do_cmd_spoilers();
1680                 break;
1681
1682 #endif /* ALLOW_SPOILERS */
1683
1684
1685                 /* Hack -- Help */
1686                 case '?':
1687                 do_cmd_help();
1688                 break;
1689
1690
1691                 /* Cure all maladies */
1692                 case 'a':
1693                 do_cmd_wiz_cure_all();
1694                 break;
1695
1696                 /* Know alignment */
1697                 case 'A':
1698                 msg_format("Your alignment is %d.", p_ptr->align);
1699                 break;
1700
1701                 /* Teleport to target */
1702                 case 'b':
1703                 do_cmd_wiz_bamf();
1704                 break;
1705
1706                 case 'B':
1707                 battle_monsters();
1708                 break;
1709
1710                 /* Create any object */
1711                 case 'c':
1712                 wiz_create_item();
1713                 break;
1714
1715                 /* Create a named artifact */
1716                 case 'C':
1717                 wiz_create_named_art(command_arg);
1718                 break;
1719
1720                 /* Detect everything */
1721                 case 'd':
1722                 detect_all(DETECT_RAD_ALL*3);
1723                 break;
1724
1725                 /* Dimension_door */
1726                 case 'D':
1727                 wiz_dimension_door();
1728                 break;
1729
1730                 /* Edit character */
1731                 case 'e':
1732                 do_cmd_wiz_change();
1733                 break;
1734
1735                 /* View item info */
1736                 case 'f':
1737                 identify_fully(FALSE);
1738                 break;
1739
1740                 /* Good Objects */
1741                 case 'g':
1742                 if (command_arg <= 0) command_arg = 1;
1743                 acquirement(py, px, command_arg, FALSE, TRUE);
1744                 break;
1745
1746                 /* Hitpoint rerating */
1747                 case 'h':
1748                 do_cmd_rerate(TRUE); break;
1749
1750 #ifdef MONSTER_HORDES
1751                 case 'H':
1752                 do_cmd_summon_horde(); break;
1753 #endif /* MONSTER_HORDES */
1754
1755                 /* Identify */
1756                 case 'i':
1757                 (void)ident_spell(FALSE);
1758                 break;
1759
1760                 /* Go up or down in the dungeon */
1761                 case 'j':
1762                 do_cmd_wiz_jump();
1763                 break;
1764
1765                 /* Self-Knowledge */
1766                 case 'k':
1767                         self_knowledge();
1768                         break;
1769
1770                 /* Learn about objects */
1771                 case 'l':
1772                         do_cmd_wiz_learn();
1773                         break;
1774
1775                 /* Magic Mapping */
1776                 case 'm':
1777                         map_area(DETECT_RAD_ALL);
1778                         break;
1779
1780                 /* Mutation */
1781                 case 'M':
1782                         (void)gain_random_mutation(command_arg);
1783                         break;
1784
1785                 /* Specific reward */
1786                 case 'r':
1787                         (void)gain_level_reward(command_arg);
1788                         break;
1789
1790                 /* Summon _friendly_ named monster */
1791                 case 'N':
1792                         do_cmd_wiz_named_friendly(command_arg, TRUE);
1793                         break;
1794
1795                 /* Summon Named Monster */
1796                 case 'n':
1797                         do_cmd_wiz_named(command_arg, TRUE);
1798                         break;
1799
1800                 /* Object playing routines */
1801                 case 'o':
1802                         do_cmd_wiz_play();
1803                         break;
1804
1805                 /* Phase Door */
1806                 case 'p':
1807                         teleport_player(10);
1808                         break;
1809
1810 #if 0
1811                 /* Complete a Quest -KMW- */
1812                 case 'q':
1813                 {
1814                         for (i = 0; i < max_quests; i++)
1815                         {
1816                                 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1817                                 {
1818                                         p_ptr->quest[i].status++;
1819                                         msg_print("Completed Quest");
1820                                         msg_print(NULL);
1821                                         break;
1822                                 }
1823                         }
1824                         if (i == max_quests)
1825                         {
1826                                 msg_print("No current quest");
1827                                 msg_print(NULL);
1828                         }
1829                         break;
1830                 }
1831 #endif
1832
1833                 /* Make every dungeon square "known" to test streamers -KMW- */
1834                 case 'u':
1835                 {
1836                         for(y = 0; y < cur_hgt; y++)
1837                         {
1838                                 for(x = 0; x < cur_wid; x++)
1839                                 {
1840                                         cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1841                                 }
1842                         }
1843                         wiz_lite(TRUE, FALSE);
1844                         break;
1845                 }
1846
1847                 /* Summon Random Monster(s) */
1848                 case 's':
1849                         if (command_arg <= 0) command_arg = 1;
1850                         do_cmd_wiz_summon(command_arg);
1851                         break;
1852
1853                 /* Teleport */
1854                 case 't':
1855                         teleport_player(100);
1856                         break;
1857
1858                 /* Very Good Objects */
1859                 case 'v':
1860                         if (command_arg <= 0) command_arg = 1;
1861                         acquirement(py, px, command_arg, TRUE, TRUE);
1862                         break;
1863
1864                 /* Wizard Light the Level */
1865                 case 'w':
1866                 wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
1867                 break;
1868
1869                 /* Increase Experience */
1870                 case 'x':
1871                 if (command_arg)
1872                 {
1873                         gain_exp(command_arg);
1874                 }
1875                 else
1876                 {
1877                         gain_exp(p_ptr->exp + 1);
1878                 }
1879                 break;
1880
1881                 /* Zap Monsters (Genocide) */
1882                 case 'z':
1883                 do_cmd_wiz_zap();
1884                 break;
1885
1886                 case 'Z':
1887                 do_cmd_wiz_zap_all();
1888                 break;
1889
1890                 /* Hack -- whatever I desire */
1891                 case '_':
1892                 do_cmd_wiz_hack_ben();
1893                 break;
1894
1895                 /* Not a Wizard Command */
1896                 default:
1897                 msg_print("That is not a valid debug command.");
1898                 break;
1899         }
1900 }
1901
1902
1903 #else
1904
1905 #ifdef MACINTOSH
1906 static int i = 0;
1907 #endif
1908
1909 #endif
1910