OSDN Git Service

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