OSDN Git Service

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