OSDN Git Service

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