OSDN Git Service

[Refactor] #40460 Renamed dungeon-file.c/h to fixed-map-parser.c/h
[hengband/hengband.git] / src / wizard / wizard-special-process.c
1 /*!
2  * @file wizard2.c
3  * @brief ウィザードモードの処理(特別処理中心) / Wizard commands
4  * @date 2014/09/07
5  * @author
6  * Copyright (c) 1997 Ben Harrison, and others<br>
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.<br>
10  * 2014 Deskull rearranged comment for Doxygen.<br>
11  */
12
13 #include "wizard/wizard-special-process.h"
14 #include "birth/inventory-initializer.h"
15 #include "cmd-io/cmd-dump.h"
16 #include "cmd-io/cmd-help.h"
17 #include "cmd-io/cmd-save.h"
18 #include "cmd/cmd-draw.h"
19 #include "core/stuff-handler.h"
20 #include "info-reader/fixed-map-parser.h"
21 #include "dungeon/dungeon.h"
22 #include "dungeon/quest.h"
23 #include "floor/floor-object.h"
24 #include "floor/floor-save.h"
25 #include "floor/floor.h"
26 #include "grid/grid.h"
27 #include "inventory/inventory-object.h"
28 #include "inventory/player-inventory.h"
29 #include "io/files-util.h"
30 #include "io/targeting.h"
31 #include "io/write-diary.h"
32 #include "market/arena.h"
33 #include "monster/monster-status.h"
34 #include "mspell/monster-spell.h"
35 #include "mutation/mutation.h"
36 #include "object-enchant/apply-magic.h"
37 #include "object-enchant/artifact.h"
38 #include "object-enchant/item-apply-magic.h"
39 #include "object/item-use-flags.h"
40 #include "perception/object-perception.h"
41 #include "object/object-flavor.h"
42 #include "object/object-generator.h"
43 #include "object/object-hook.h"
44 #include "object/object-kind.h"
45 #include "object/object-value.h"
46 #include "object-enchant/trc-types.h"
47 #include "player/patron.h"
48 #include "player/player-class.h"
49 #include "player/player-effects.h"
50 #include "player/player-races-table.h"
51 #include "player/player-skill.h"
52 #include "player/player-status.h"
53 #include "player/selfinfo.h"
54 #include "spell-kind/spells-detection.h"
55 #include "spell-kind/spells-floor.h"
56 #include "spell/spells-object.h"
57 #include "spell-kind/spells-sight.h"
58 #include "spell/spells-status.h"
59 #include "spell/spells-summon.h"
60 #include "spell-kind/spells-teleport.h"
61 #include "spell/spells-util.h"
62 #include "spell-kind/spells-world.h"
63 #include "spell/spells3.h"
64 #include "system/angband-version.h"
65 #include "term/term-color-types.h"
66 #include "util/util.h"
67 #include "view/display-main-window.h"
68 #include "wizard/wizard-spoiler.h"
69 #include "world/world.h"
70
71 #define NUM_O_SET 8
72 #define NUM_O_BIT 32
73
74 typedef union spell_functions {
75         struct debug_spell_type1 { bool(*spell_function)(player_type *, floor_type *); } spell1;
76         struct debug_spell_type2 { bool(*spell_function)(player_type *); } spell2;
77         struct debug_spell_type3 { bool(*spell_function)(player_type *, HIT_POINT); } spell3;
78 } spell_functions;
79
80 typedef struct debug_spell_command
81 {
82         int type;
83         char *command_name;
84         spell_functions command_function;
85 } debug_spell_command;
86
87 #define SPELL_MAX 3
88 debug_spell_command debug_spell_commands_list[SPELL_MAX] =
89 {
90         { 2, "vanish dungeon", {.spell2 = { vanish_dungeon } } },
91         { 3, "true healing", {.spell3 = { true_healing } } },
92         { 2, "drop weapons", {.spell2 = { drop_weapons } } }
93 };
94
95 /*!
96  * @brief コマンド入力により任意にスペル効果を起こす / Wizard spells
97  * @return 実際にテレポートを行ったらTRUEを返す
98  */
99 static bool do_cmd_debug_spell(player_type *creature_ptr)
100 {
101         char tmp_val[50] = "\0";
102         int tmp_int;
103
104         if (!get_string("SPELL: ", tmp_val, 32)) return FALSE;
105
106         for (int i = 0; i < SPELL_MAX; i++)
107         {
108                 if (strcmp(tmp_val, debug_spell_commands_list[i].command_name) != 0)
109                         continue;
110                 switch (debug_spell_commands_list[i].type)
111                 {
112                 case 2:
113                         (*(debug_spell_commands_list[i].command_function.spell2.spell_function))(creature_ptr);
114                         return TRUE;
115                         break;
116                 case 3:
117                         tmp_val[0] = '\0';
118                         if (!get_string("POWER:", tmp_val, 32)) return FALSE;
119                         tmp_int = atoi(tmp_val);
120                         (*(debug_spell_commands_list[i].command_function.spell3.spell_function))(creature_ptr, tmp_int);
121                         return TRUE;
122                         break;
123                 default:
124                         break;
125                 }
126         }
127
128         msg_format("Command not found.");
129
130         return FALSE;
131 }
132
133
134 /*!
135  * @brief 必ず成功するウィザードモード用次元の扉処理 / Wizard Dimension Door
136  * @param caster_ptr プレーヤーへの参照ポインタ
137  * @return 実際にテレポートを行ったらTRUEを返す
138  */
139 static bool wiz_dimension_door(player_type *caster_ptr)
140 {
141         POSITION x = 0, y = 0;
142         if (!tgt_pt(caster_ptr, &x, &y)) return FALSE;
143         teleport_player_to(caster_ptr, y, x, TELEPORT_NONMAGICAL);
144         return TRUE;
145 }
146
147 /*!
148  * @brief 指定されたIDの固定アーティファクトを生成する / Create the artifact of the specified number
149  * @param caster_ptr プレーヤーへの参照ポインタ
150  * @return なし
151  */
152 static void wiz_create_named_art(player_type *caster_ptr)
153 {
154         char tmp_val[10] = "";
155         ARTIFACT_IDX a_idx;
156
157         /* Query */
158         if (!get_string("Artifact ID:", tmp_val, 3)) return;
159
160         /* Extract */
161         a_idx = (ARTIFACT_IDX)atoi(tmp_val);
162         if (a_idx < 0) a_idx = 0;
163         if (a_idx >= max_a_idx) a_idx = 0;
164
165         (void)create_named_art(caster_ptr, a_idx, caster_ptr->y, caster_ptr->x);
166
167         /* All done */
168         msg_print("Allocated.");
169 }
170
171 /*!
172  * @brief ウィザードモード用モンスターの群れ生成 / Summon a horde of monsters
173  * @param caster_ptr プレーヤーへの参照ポインタ
174  * @return なし
175  */
176 static void do_cmd_summon_horde(player_type *caster_ptr)
177 {
178         POSITION wy = caster_ptr->y, wx = caster_ptr->x;
179         int attempts = 1000;
180
181         while (--attempts)
182         {
183                 scatter(caster_ptr, &wy, &wx, caster_ptr->y, caster_ptr->x, 3, 0);
184                 if (is_cave_empty_bold(caster_ptr, wy, wx)) break;
185         }
186
187         (void)alloc_horde(caster_ptr, wy, wx);
188 }
189
190 /*!
191  * @brief 32ビット変数のビット配列を並べて描画する / Output a long int in binary format.
192  * @return なし
193  */
194 static void prt_binary(BIT_FLAGS flags, int row, int col)
195 {
196         int i;
197         u32b bitmask;
198
199         /* Scan the flags */
200         for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
201         {
202                 /* Dump set bits */
203                 if (flags & bitmask)
204                 {
205                         Term_putch(col++, row, TERM_BLUE, '*');
206                 }
207
208                 /* Dump unset bits */
209                 else
210                 {
211                         Term_putch(col++, row, TERM_WHITE, '-');
212                 }
213         }
214 }
215
216
217 #define K_MAX_DEPTH 110 /*!< アイテムの階層毎生成率を表示する最大階 */
218
219 /*!
220  * @brief アイテムの階層毎生成率を表示する / Output a rarity graph for a type of object.
221  * @param tval ベースアイテムの大項目ID
222  * @param sval ベースアイテムの小項目ID
223  * @param row 表示列
224  * @param col 表示行
225  * @return なし
226  */
227 static void prt_alloc(tval_type tval, OBJECT_SUBTYPE_VALUE sval, TERM_LEN row, TERM_LEN col)
228 {
229         u32b rarity[K_MAX_DEPTH];
230         (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
231         u32b total[K_MAX_DEPTH];
232         (void)C_WIPE(total, K_MAX_DEPTH, u32b);
233         s32b display[22];
234         (void)C_WIPE(display, 22, s32b);
235
236         /* Scan all entries */
237         int home = 0;
238         for (int i = 0; i < K_MAX_DEPTH; i++)
239         {
240                 int total_frac = 0;
241                 object_kind *k_ptr;
242                 alloc_entry *table = alloc_kind_table;
243                 for (int j = 0; j < alloc_kind_size; j++)
244                 {
245                         PERCENTAGE prob = 0;
246
247                         if (table[j].level <= i)
248                         {
249                                 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
250                         }
251                         else if (table[j].level - 1 > 0)
252                         {
253                                 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
254                         }
255
256                         /* Acquire this kind */
257                         k_ptr = &k_info[table[j].index];
258
259                         /* Accumulate probabilities */
260                         total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
261                         total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
262
263                         /* Accumulate probabilities */
264                         if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
265                         {
266                                 home = k_ptr->level;
267                                 rarity[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
268                         }
269                 }
270                 total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
271         }
272
273         /* Calculate probabilities for each range */
274         for (int i = 0; i < 22; i++)
275         {
276                 /* Shift the values into view */
277                 int possibility = 0;
278                 for (int j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
279                         possibility += rarity[j] * 100000 / total[j];
280                 display[i] = possibility / 5;
281         }
282
283         /* Graph the rarities */
284         for (int i = 0; i < 22; i++)
285         {
286                 Term_putch(col, row + i + 1, TERM_WHITE, '|');
287
288                 prt(format("%2dF", (i * 5)), row + i + 1, col);
289
290
291                 /* Note the level */
292                 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
293                 {
294                         c_prt(TERM_RED, format("%3d.%04d%%", display[i] / 1000, display[i] % 1000), row + i + 1, col + 3);
295                 }
296                 else
297                 {
298                         c_prt(TERM_WHITE, format("%3d.%04d%%", display[i] / 1000, display[i] % 1000), row + i + 1, col + 3);
299                 }
300         }
301
302         /* Make it look nice */
303         concptr r = "+---Rate---+";
304         prt(r, row, col);
305 }
306
307 /*!
308  * @brief プレイヤーの職業を変更する
309  * @return なし
310  * @todo 魔法領域の再選択などがまだ不完全、要実装。
311  */
312 static void do_cmd_wiz_reset_class(player_type *creature_ptr)
313 {
314         /* Prompt */
315         char ppp[80];
316         sprintf(ppp, "Class (0-%d): ", MAX_CLASS - 1);
317
318         /* Default */
319         char tmp_val[160];
320         sprintf(tmp_val, "%d", creature_ptr->pclass);
321
322         /* Query */
323         if (!get_string(ppp, tmp_val, 2)) return;
324
325         /* Extract */
326         int tmp_int = atoi(tmp_val);
327
328         /* Verify */
329         if (tmp_int < 0 || tmp_int >= MAX_CLASS) return;
330
331         /* Save it */
332         creature_ptr->pclass = (byte)tmp_int;
333
334         /* Redraw inscription */
335         creature_ptr->window |= (PW_PLAYER);
336
337         /* {.} and {$} effect creature_ptr->warning and TRC_TELEPORT_SELF */
338         creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
339
340         handle_stuff(creature_ptr);
341 }
342
343
344 /*!
345  * @brief ウィザードモード用処理としてターゲット中の相手をテレポートバックする / Hack -- Teleport to the target
346  * @return なし
347  */
348 static void do_cmd_wiz_bamf(player_type *caster_ptr)
349 {
350         /* Must have a target */
351         if (!target_who) return;
352
353         /* Teleport to the target */
354         teleport_player_to(caster_ptr, target_row, target_col, TELEPORT_NONMAGICAL);
355 }
356
357
358 /*!
359  * @brief プレイヤーの現能力値を調整する
360  * Aux function for "do_cmd_wiz_change()".      -RAK-
361  * @return なし
362  */
363 static void do_cmd_wiz_change_aux(player_type *creature_ptr)
364 {
365         int tmp_int;
366         long tmp_long;
367         s16b tmp_s16b;
368         char tmp_val[160];
369         char ppp[80];
370
371         /* Query the stats */
372         for (int i = 0; i < A_MAX; i++)
373         {
374                 /* Prompt */
375                 sprintf(ppp, "%s (3-%d): ", stat_names[i], creature_ptr->stat_max_max[i]);
376
377                 /* Default */
378                 sprintf(tmp_val, "%d", creature_ptr->stat_max[i]);
379
380                 /* Query */
381                 if (!get_string(ppp, tmp_val, 3)) return;
382
383                 /* Extract */
384                 tmp_int = atoi(tmp_val);
385
386                 /* Verify */
387                 if (tmp_int > creature_ptr->stat_max_max[i]) tmp_int = creature_ptr->stat_max_max[i];
388                 else if (tmp_int < 3) tmp_int = 3;
389
390                 /* Save it */
391                 creature_ptr->stat_cur[i] = creature_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
392         }
393
394
395         /* Default */
396         sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
397
398         /* Query */
399         if (!get_string(_("熟練度: ", "Proficiency: "), tmp_val, 9)) return;
400
401         /* Extract */
402         tmp_s16b = (s16b)atoi(tmp_val);
403
404         /* Verify */
405         if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED;
406         if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER;
407
408         for (int j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++)
409         {
410                 for (int i = 0; i < 64; i++)
411                 {
412                         creature_ptr->weapon_exp[j][i] = tmp_s16b;
413                         if (creature_ptr->weapon_exp[j][i] > s_info[creature_ptr->pclass].w_max[j][i]) creature_ptr->weapon_exp[j][i] = s_info[creature_ptr->pclass].w_max[j][i];
414                 }
415         }
416
417         for (int j = 0; j < 10; j++)
418         {
419                 creature_ptr->skill_exp[j] = tmp_s16b;
420                 if (creature_ptr->skill_exp[j] > s_info[creature_ptr->pclass].s_max[j]) creature_ptr->skill_exp[j] = s_info[creature_ptr->pclass].s_max[j];
421         }
422
423         int k;
424         for (k = 0; k < 32; k++)
425                 creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
426         for (; k < 64; k++)
427                 creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
428
429         /* Default */
430         sprintf(tmp_val, "%ld", (long)(creature_ptr->au));
431
432         /* Query */
433         if (!get_string("Gold: ", tmp_val, 9)) return;
434
435         /* Extract */
436         tmp_long = atol(tmp_val);
437
438         /* Verify */
439         if (tmp_long < 0) tmp_long = 0L;
440
441         /* Save */
442         creature_ptr->au = tmp_long;
443
444         /* Default */
445         sprintf(tmp_val, "%ld", (long)(creature_ptr->max_exp));
446
447         /* Query */
448         if (!get_string("Experience: ", tmp_val, 9)) return;
449
450         /* Extract */
451         tmp_long = atol(tmp_val);
452
453         /* Verify */
454         if (tmp_long < 0) tmp_long = 0L;
455
456         if (creature_ptr->prace == RACE_ANDROID) return;
457
458         /* Save */
459         creature_ptr->max_exp = tmp_long;
460         creature_ptr->exp = tmp_long;
461
462         /* Update */
463         check_experience(creature_ptr);
464 }
465
466
467 /*!
468  * @brief プレイヤーの現能力値を調整する(メインルーチン)
469  * Change various "permanent" player variables.
470  * @return なし
471  */
472 static void do_cmd_wiz_change(player_type *creature_ptr)
473 {
474         /* Interact */
475         do_cmd_wiz_change_aux(creature_ptr);
476         do_cmd_redraw(creature_ptr);
477 }
478
479
480 /*!
481  * @brief アイテムの詳細ステータスを表示する /
482  * Change various "permanent" player variables.
483  * @param player_ptr プレーヤーへの参照ポインタ
484  * @param o_ptr 詳細を表示するアイテム情報の参照ポインタ
485  * @return なし
486  * @details
487  * Wizard routines for creating objects         -RAK-
488  * And for manipulating them!                   -Bernd-
489  *
490  * This has been rewritten to make the whole procedure
491  * of debugging objects much easier and more comfortable.
492  *
493  * The following functions are meant to play with objects:
494  * Create, modify, roll for them (for statistic purposes) and more.
495  * The original functions were by RAK.
496  * The function to show an item's debug information was written
497  * by David Reeve Sward <sward+@CMU.EDU>.
498  *                             Bernd (wiebelt@mathematik.hu-berlin.de)
499  *
500  * Here are the low-level functions
501  * - wiz_display_item()
502  *     display an item's debug-info
503  * - wiz_create_itemtype()
504  *     specify tval and sval (type and subtype of object)
505  * - wiz_tweak_item()
506  *     specify pval, +AC, +tohit, +todam
507  *     Note that the wizard can leave this function anytime,
508  *     thus accepting the default-values for the remaining values.
509  *     pval comes first now, since it is most important.
510  * - wiz_reroll_item()
511  *     apply some magic to the item or turn it into an artifact.
512  * - wiz_roll_item()
513  *     Get some statistics about the rarity of an item:
514  *     We create a lot of fake items and see if they are of the
515  *     same type (tval and sval), then we compare pval and +AC.
516  *     If the fake-item is better or equal it is counted.
517  *     Note that cursed items that are better or equal (absolute values)
518  *     are counted, too.
519  *     HINT: This is *very* useful for balancing the game!
520  * - wiz_quantity_item()
521  *     change the quantity of an item, but be sane about it.
522  *
523  * And now the high-level functions
524  * - do_cmd_wiz_play()
525  *     play with an existing object
526  * - wiz_create_item()
527  *     create a new object
528  *
529  * Note -- You do not have to specify "pval" and other item-properties
530  * directly. Just apply magic until you are satisfied with the item.
531  *
532  * Note -- For some items (such as wands, staffs, some rings, etc), you
533  * must apply magic, or you will get "broken" or "uncharged" objects.
534  *
535  * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
536  * the artifact.  Be careful.
537  *
538  * Hack -- this function will allow you to create multiple artifacts.
539  * This "feature" may induce crashes or other nasty effects.
540  * Just display an item's properties (debug-info)
541  * Originally by David Reeve Sward <sward+@CMU.EDU>
542  * Verbose item flags by -Bernd-
543  */
544 static void wiz_display_item(player_type *player_ptr, object_type *o_ptr)
545 {
546         BIT_FLAGS flgs[TR_FLAG_SIZE];
547         object_flags(o_ptr, flgs);
548
549         /* Clear the screen */
550         int j = 13;
551         for (int i = 1; i <= 23; i++) prt("", i, j - 2);
552
553         prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
554
555         /* Describe fully */
556         char buf[256];
557         object_desc(player_ptr, buf, o_ptr, OD_STORE);
558
559         prt(buf, 2, j);
560
561         prt(format("kind = %-5d  level = %-4d  tval = %-5d  sval = %-5d",
562                 o_ptr->k_idx, k_info[o_ptr->k_idx].level,
563                 o_ptr->tval, o_ptr->sval), 4, j);
564
565         prt(format("number = %-3d  wgt = %-6d  ac = %-5d    damage = %dd%d",
566                 o_ptr->number, o_ptr->weight,
567                 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
568
569         prt(format("pval = %-5d  toac = %-5d  tohit = %-4d  todam = %-4d",
570                 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
571
572         prt(format("name1 = %-4d  name2 = %-4d  cost = %ld",
573                 o_ptr->name1, o_ptr->name2, (long)object_value_real(o_ptr)), 7, j);
574
575         prt(format("ident = %04x  xtra1 = %-4d  xtra2 = %-4d  timeout = %-d",
576                 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
577
578         prt(format("xtra3 = %-4d  xtra4 = %-4d  xtra5 = %-4d  cursed  = %-d",
579                 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
580
581         prt("+------------FLAGS1------------+", 10, j);
582         prt("AFFECT........SLAY........BRAND.", 11, j);
583         prt("      mf      cvae      xsqpaefc", 12, j);
584         prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
585         prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
586         prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
587         prt_binary(flgs[0], 16, j);
588
589         prt("+------------FLAGS2------------+", 17, j);
590         prt("SUST....IMMUN.RESIST............", 18, j);
591         prt("      reaefctrpsaefcpfldbc sn   ", 19, j);
592         prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
593         prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
594         prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
595         prt_binary(flgs[1], 23, j);
596
597         prt("+------------FLAGS3------------+", 10, j + 32);
598         prt("fe cnn t      stdrmsiiii d ab   ", 11, j + 32);
599         prt("aa aoomywhs lleeieihgggg rtgl   ", 12, j + 32);
600         prt("uu utmacaih eielgggonnnnaaere   ", 13, j + 32);
601         prt("rr reanurdo vtieeehtrrrrcilas   ", 14, j + 32);
602         prt("aa algarnew ienpsntsaefctnevs   ", 15, j + 32);
603         prt_binary(flgs[2], 16, j + 32);
604
605         prt("+------------FLAGS4------------+", 17, j + 32);
606         prt("KILL....ESP.........            ", 18, j + 32);
607         prt("aeud tghaud tgdhegnu            ", 19, j + 32);
608         prt("nvneoriunneoriruvoon            ", 20, j + 32);
609         prt("iidmroamidmroagmionq            ", 21, j + 32);
610         prt("mlenclnmmenclnnnldlu            ", 22, j + 32);
611         prt_binary(flgs[3], 23, j + 32);
612 }
613
614
615 /*!
616  * ベースアイテムの大項目IDの種別名をまとめる構造体 / A structure to hold a tval and its description
617  */
618 typedef struct tval_desc
619 {
620         int        tval; /*!< 大項目のID */
621         concptr       desc; /*!< 大項目名 */
622 } tval_desc;
623
624 /*!
625  * ベースアイテムの大項目IDの種別名定義 / A list of tvals and their textual names
626  */
627 static tval_desc tvals[] =
628 {
629         { TV_SWORD,             "Sword"                },
630         { TV_POLEARM,           "Polearm"              },
631         { TV_HAFTED,            "Hafted Weapon"        },
632         { TV_BOW,               "Bow"                  },
633         { TV_ARROW,             "Arrows"               },
634         { TV_BOLT,              "Bolts"                },
635         { TV_SHOT,              "Shots"                },
636         { TV_SHIELD,            "Shield"               },
637         { TV_CROWN,             "Crown"                },
638         { TV_HELM,              "Helm"                 },
639         { TV_GLOVES,            "Gloves"               },
640         { TV_BOOTS,             "Boots"                },
641         { TV_CLOAK,             "Cloak"                },
642         { TV_DRAG_ARMOR,        "Dragon Scale Mail"    },
643         { TV_HARD_ARMOR,        "Hard Armor"           },
644         { TV_SOFT_ARMOR,        "Soft Armor"           },
645         { TV_RING,              "Ring"                 },
646         { TV_AMULET,            "Amulet"               },
647         { TV_LITE,              "Lite"                 },
648         { TV_POTION,            "Potion"               },
649         { TV_SCROLL,            "Scroll"               },
650         { TV_WAND,              "Wand"                 },
651         { TV_STAFF,             "Staff"                },
652         { TV_ROD,               "Rod"                  },
653         { TV_LIFE_BOOK,         "Life Spellbook"       },
654         { TV_SORCERY_BOOK,      "Sorcery Spellbook"    },
655         { TV_NATURE_BOOK,       "Nature Spellbook"     },
656         { TV_CHAOS_BOOK,        "Chaos Spellbook"      },
657         { TV_DEATH_BOOK,        "Death Spellbook"      },
658         { TV_TRUMP_BOOK,        "Trump Spellbook"      },
659         { TV_ARCANE_BOOK,       "Arcane Spellbook"     },
660         { TV_CRAFT_BOOK,      "Craft Spellbook"},
661         { TV_DAEMON_BOOK,       "Daemon Spellbook"},
662         { TV_CRUSADE_BOOK,      "Crusade Spellbook"},
663         { TV_MUSIC_BOOK,        "Music Spellbook"      },
664         { TV_HISSATSU_BOOK,     "Book of Kendo" },
665         { TV_HEX_BOOK,          "Hex Spellbook"        },
666         { TV_PARCHMENT,         "Parchment" },
667         { TV_WHISTLE,           "Whistle"       },
668         { TV_SPIKE,             "Spikes"               },
669         { TV_DIGGING,           "Digger"               },
670         { TV_CHEST,             "Chest"                },
671         { TV_CAPTURE,           "Capture Ball"         },
672         { TV_CARD,              "Express Card"         },
673         { TV_FIGURINE,          "Magical Figurine"     },
674         { TV_STATUE,            "Statue"               },
675         { TV_CORPSE,            "Corpse"               },
676         { TV_FOOD,              "Food"                 },
677         { TV_FLASK,             "Flask"                },
678         { TV_JUNK,              "Junk"                 },
679         { TV_SKELETON,          "Skeleton"             },
680         { 0,                    NULL                   }
681 };
682
683
684 /*!
685  * 選択処理用キーコード /
686  * Global array for converting numbers to a logical list symbol
687  */
688 static const char listsym[] =
689 {
690         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
691         'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
692         'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
693         'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
694         'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
695         '\0'
696 };
697
698 /*!
699  * @brief ベースアイテムのウィザード生成のために大項目IDと小項目IDを取得する /
700  * Specify tval and sval (type and subtype of object) originally
701  * @return ベースアイテムID
702  * @details
703  * by RAK, heavily modified by -Bernd-
704  * This function returns the k_idx of an object type, or zero if failed
705  * List up to 50 choices in three columns
706  */
707 static KIND_OBJECT_IDX wiz_create_itemtype(void)
708 {
709         KIND_OBJECT_IDX i;
710         int num, max_num;
711         TERM_LEN col, row;
712         tval_type tval;
713
714         concptr tval_desc;
715         char ch;
716
717         KIND_OBJECT_IDX choice[80];
718
719         char buf[160];
720
721         Term_clear();
722
723         /* Print all tval's and their descriptions */
724         for (num = 0; (num < 80) && tvals[num].tval; num++)
725         {
726                 row = 2 + (num % 20);
727                 col = 20 * (num / 20);
728                 ch = listsym[num];
729                 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
730         }
731
732         /* Me need to know the maximal possible tval_index */
733         max_num = num;
734
735         /* Choose! */
736         if (!get_com("Get what type of object? ", &ch, FALSE)) return 0;
737
738         /* Analyze choice */
739         for (num = 0; num < max_num; num++)
740         {
741                 if (listsym[num] == ch) break;
742         }
743
744         /* Bail out if choice is illegal */
745         if ((num < 0) || (num >= max_num)) return 0;
746
747         /* Base object type chosen, fill in tval */
748         tval = tvals[num].tval;
749         tval_desc = tvals[num].desc;
750
751         /*** And now we go for k_idx ***/
752         Term_clear();
753
754         /* We have to search the whole itemlist. */
755         for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
756         {
757                 object_kind *k_ptr = &k_info[i];
758
759                 /* Analyze matching items */
760                 if (k_ptr->tval != tval) continue;
761
762                 /* Prepare it */
763                 row = 2 + (num % 20);
764                 col = 20 * (num / 20);
765                 ch = listsym[num];
766                 strcpy(buf, "                    ");
767
768                 /* Acquire the "name" of object "i" */
769                 strip_name(buf, i);
770
771                 /* Print it */
772                 prt(format("[%c] %s", ch, buf), row, col);
773
774                 /* Remember the object index */
775                 choice[num++] = i;
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  * @briefアイテムの基礎能力値を調整する / Tweak an item
800  * @param player_ptr プレーヤーへの参照ポインタ
801  * @param o_ptr 調整するアイテムの参照ポインタ
802  * @return なし
803  */
804 static void wiz_tweak_item(player_type *player_ptr, object_type *o_ptr)
805 {
806         if (object_is_artifact(o_ptr)) return;
807
808         concptr p = "Enter new 'pval' setting: ";
809         char tmp_val[80];
810         sprintf(tmp_val, "%d", o_ptr->pval);
811         if (!get_string(p, tmp_val, 5)) return;
812         o_ptr->pval = (s16b)atoi(tmp_val);
813         wiz_display_item(player_ptr, o_ptr);
814
815         p = "Enter new 'to_a' setting: ";
816         sprintf(tmp_val, "%d", o_ptr->to_a);
817         if (!get_string(p, tmp_val, 5)) return;
818         o_ptr->to_a = (s16b)atoi(tmp_val);
819         wiz_display_item(player_ptr, o_ptr);
820
821         p = "Enter new 'to_h' setting: ";
822         sprintf(tmp_val, "%d", o_ptr->to_h);
823         if (!get_string(p, tmp_val, 5)) return;
824         o_ptr->to_h = (s16b)atoi(tmp_val);
825         wiz_display_item(player_ptr, o_ptr);
826
827         p = "Enter new 'to_d' setting: ";
828         sprintf(tmp_val, "%d", (int)o_ptr->to_d);
829         if (!get_string(p, tmp_val, 5)) return;
830         o_ptr->to_d = (s16b)atoi(tmp_val);
831         wiz_display_item(player_ptr, o_ptr);
832 }
833
834
835 /*!
836  * @brief アイテムの質を選択して再生成する /
837  * Apply magic to an item or turn it into an artifact. -Bernd-
838  * @param o_ptr 再生成の対象となるアイテム情報の参照ポインタ
839  * @return なし
840  */
841 static void wiz_reroll_item(player_type *owner_ptr, object_type *o_ptr)
842 {
843         if (object_is_artifact(o_ptr)) return;
844
845         object_type forge;
846         object_type *q_ptr;
847         q_ptr = &forge;
848         object_copy(q_ptr, o_ptr);
849
850         /* Main loop. Ask for magification and artifactification */
851         char ch;
852         bool changed = FALSE;
853         while (TRUE)
854         {
855                 /* Display full item debug information */
856                 wiz_display_item(owner_ptr, q_ptr);
857
858                 /* Ask wizard what to do. */
859                 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
860                 {
861                         /* Preserve wizard-generated artifacts */
862                         if (object_is_fixed_artifact(q_ptr))
863                         {
864                                 a_info[q_ptr->name1].cur_num = 0;
865                                 q_ptr->name1 = 0;
866                         }
867
868                         changed = FALSE;
869                         break;
870                 }
871
872                 /* Create/change it! */
873                 if (ch == 'A' || ch == 'a')
874                 {
875                         changed = TRUE;
876                         break;
877                 }
878
879                 /* Preserve wizard-generated artifacts */
880                 if (object_is_fixed_artifact(q_ptr))
881                 {
882                         a_info[q_ptr->name1].cur_num = 0;
883                         q_ptr->name1 = 0;
884                 }
885
886                 switch (ch)
887                 {
888                         /* Apply bad magic, but first clear object */
889                 case 'w': case 'W':
890                 {
891                         object_prep(q_ptr, o_ptr->k_idx);
892                         apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
893                         break;
894                 }
895                 /* Apply bad magic, but first clear object */
896                 case 'c': case 'C':
897                 {
898                         object_prep(q_ptr, o_ptr->k_idx);
899                         apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
900                         break;
901                 }
902                 /* Apply normal magic, but first clear object */
903                 case 'n': case 'N':
904                 {
905                         object_prep(q_ptr, o_ptr->k_idx);
906                         apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
907                         break;
908                 }
909                 /* Apply good magic, but first clear object */
910                 case 'g': case 'G':
911                 {
912                         object_prep(q_ptr, o_ptr->k_idx);
913                         apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD);
914                         break;
915                 }
916                 /* Apply great magic, but first clear object */
917                 case 'e': case 'E':
918                 {
919                         object_prep(q_ptr, o_ptr->k_idx);
920                         apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
921                         break;
922                 }
923                 /* Apply special magic, but first clear object */
924                 case 's': case 'S':
925                 {
926                         object_prep(q_ptr, o_ptr->k_idx);
927                         apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
928
929                         /* Failed to create artifact; make a random one */
930                         if (!object_is_artifact(q_ptr)) become_random_artifact(owner_ptr, q_ptr, FALSE);
931                         break;
932                 }
933                 }
934
935                 q_ptr->iy = o_ptr->iy;
936                 q_ptr->ix = o_ptr->ix;
937                 q_ptr->next_o_idx = o_ptr->next_o_idx;
938                 q_ptr->marked = o_ptr->marked;
939         }
940
941         /* Notice change */
942         if (changed)
943         {
944                 object_copy(o_ptr, q_ptr);
945                 owner_ptr->update |= (PU_BONUS);
946                 owner_ptr->update |= (PU_COMBINE | PU_REORDER);
947                 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
948         }
949 }
950
951
952 /*!
953  * @brief 検査対象のアイテムを基準とした生成テストを行う /
954  * Try to create an item again. Output some statistics.    -Bernd-
955  * @param caster_ptr プレーヤーへの参照ポインタ
956  * @param o_ptr 生成テストの基準となるアイテム情報の参照ポインタ
957  * @return なし
958  * The statistics are correct now.  We acquire a clean grid, and then
959  * repeatedly place an object in this grid, copying it into an item
960  * holder, and then deleting the object.  We fiddle with the artifact
961  * counter flags to prevent weirdness.  We use the items to collect
962  * statistics on item creation relative to the initial item.
963  */
964 static void wiz_statistics(player_type *caster_ptr, object_type *o_ptr)
965 {
966         object_type forge;
967         object_type     *q_ptr;
968
969         concptr q = "Rolls: %ld  Correct: %ld  Matches: %ld  Better: %ld  Worse: %ld  Other: %ld";
970         concptr p = "Enter number of items to roll: ";
971         char tmp_val[80];
972
973         /* Mega-Hack -- allow multiple artifacts */
974         if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
975
976         /* Interact */
977         u32b i, matches, better, worse, other, correct;
978         u32b test_roll = 1000000;
979         char ch;
980         concptr quality;
981         BIT_FLAGS mode;
982         while (TRUE)
983         {
984                 concptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
985
986                 /* Display item */
987                 wiz_display_item(caster_ptr, o_ptr);
988
989                 /* Get choices */
990                 if (!get_com(pmt, &ch, FALSE)) break;
991
992                 if (ch == 'n' || ch == 'N')
993                 {
994                         mode = 0L;
995                         quality = "normal";
996                 }
997                 else if (ch == 'g' || ch == 'G')
998                 {
999                         mode = AM_GOOD;
1000                         quality = "good";
1001                 }
1002                 else if (ch == 'e' || ch == 'E')
1003                 {
1004                         mode = AM_GOOD | AM_GREAT;
1005                         quality = "excellent";
1006                 }
1007                 else
1008                 {
1009                         break;
1010                 }
1011
1012                 sprintf(tmp_val, "%ld", (long int)test_roll);
1013                 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1014                 test_roll = MAX(1, test_roll);
1015
1016                 /* Let us know what we are doing */
1017                 msg_format("Creating a lot of %s items. Base level = %d.",
1018                         quality, caster_ptr->current_floor_ptr->dun_level);
1019                 msg_print(NULL);
1020
1021                 /* Set counters to zero */
1022                 correct = matches = better = worse = other = 0;
1023
1024                 /* Let's rock and roll */
1025                 for (i = 0; i <= test_roll; i++)
1026                 {
1027                         /* Output every few rolls */
1028                         if ((i < 100) || (i % 100 == 0))
1029                         {
1030                                 /* Do not wait */
1031                                 inkey_scan = TRUE;
1032
1033                                 /* Allow interupt */
1034                                 if (inkey())
1035                                 {
1036                                         flush();
1037                                         break; // stop rolling
1038                                 }
1039
1040                                 /* Dump the stats */
1041                                 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1042                                 Term_fresh();
1043                         }
1044                         q_ptr = &forge;
1045                         object_wipe(q_ptr);
1046
1047                         /* Create an object */
1048                         make_object(caster_ptr, q_ptr, mode);
1049
1050
1051                         /* Mega-Hack -- allow multiple artifacts */
1052                         if (object_is_fixed_artifact(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1053
1054
1055                         /* Test for the same tval and sval. */
1056                         if ((o_ptr->tval) != (q_ptr->tval)) continue;
1057                         if ((o_ptr->sval) != (q_ptr->sval)) continue;
1058
1059                         /* One more correct item */
1060                         correct++;
1061
1062                         /* Check for match */
1063                         if ((q_ptr->pval == o_ptr->pval) &&
1064                                 (q_ptr->to_a == o_ptr->to_a) &&
1065                                 (q_ptr->to_h == o_ptr->to_h) &&
1066                                 (q_ptr->to_d == o_ptr->to_d) &&
1067                                 (q_ptr->name1 == o_ptr->name1))
1068                         {
1069                                 matches++;
1070                         }
1071
1072                         /* Check for better */
1073                         else if ((q_ptr->pval >= o_ptr->pval) &&
1074                                 (q_ptr->to_a >= o_ptr->to_a) &&
1075                                 (q_ptr->to_h >= o_ptr->to_h) &&
1076                                 (q_ptr->to_d >= o_ptr->to_d))
1077                         {
1078                                 better++;
1079                         }
1080
1081                         /* Check for worse */
1082                         else if ((q_ptr->pval <= o_ptr->pval) &&
1083                                 (q_ptr->to_a <= o_ptr->to_a) &&
1084                                 (q_ptr->to_h <= o_ptr->to_h) &&
1085                                 (q_ptr->to_d <= o_ptr->to_d))
1086                         {
1087                                 worse++;
1088                         }
1089
1090                         /* Assume different */
1091                         else
1092                         {
1093                                 other++;
1094                         }
1095                 }
1096
1097                 /* Final dump */
1098                 msg_format(q, i, correct, matches, better, worse, other);
1099                 msg_print(NULL);
1100         }
1101
1102         /* Hack -- Normally only make a single artifact */
1103         if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1104 }
1105
1106
1107 /*!
1108  * @brief 検査対象のアイテムの数を変更する /
1109  * Change the quantity of a the item
1110  * @param caster_ptr プレーヤーへの参照ポインタ
1111  * @param o_ptr 変更するアイテム情報構造体の参照ポインタ
1112  * @return なし
1113  */
1114 static void wiz_quantity_item(object_type *o_ptr)
1115 {
1116         /* Never duplicate artifacts */
1117         if (object_is_artifact(o_ptr)) return;
1118
1119         /* Store old quantity. -LM- */
1120         int tmp_qnt = o_ptr->number;
1121
1122         /* Default */
1123         char tmp_val[100];
1124         sprintf(tmp_val, "%d", (int)o_ptr->number);
1125
1126         /* Query */
1127         if (get_string("Quantity: ", tmp_val, 2))
1128         {
1129                 /* Extract */
1130                 int tmp_int = atoi(tmp_val);
1131                 if (tmp_int < 1) tmp_int = 1;
1132                 if (tmp_int > 99) tmp_int = 99;
1133
1134                 /* Accept modifications */
1135                 o_ptr->number = (byte)tmp_int;
1136         }
1137
1138         if (o_ptr->tval == TV_ROD)
1139         {
1140                 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1141         }
1142 }
1143
1144
1145 /*!
1146  * @brief 青魔導師の魔法を全て習得済みにする /
1147  * debug command for blue mage
1148  * @return なし
1149  */
1150 static void do_cmd_wiz_blue_mage(player_type *caster_ptr)
1151 {
1152         BIT_FLAGS f4 = 0L, f5 = 0L, f6 = 0L;
1153         for (int j = 1; j < A_MAX; j++)
1154         {
1155                 set_rf_masks(&f4, &f5, &f6, j);
1156
1157                 int i;
1158                 for (i = 0; i < 32; i++)
1159                 {
1160                         if ((0x00000001 << i) & f4) caster_ptr->magic_num2[i] = 1;
1161                 }
1162
1163                 for (; i < 64; i++)
1164                 {
1165                         if ((0x00000001 << (i - 32)) & f5) caster_ptr->magic_num2[i] = 1;
1166                 }
1167
1168                 for (; i < 96; i++)
1169                 {
1170                         if ((0x00000001 << (i - 64)) & f6) caster_ptr->magic_num2[i] = 1;
1171                 }
1172         }
1173 }
1174
1175
1176 /*!
1177  * @brief アイテム検査のメインルーチン /
1178  * Play with an item. Options include:
1179  * @return なし
1180  * @details
1181  *   - Output statistics (via wiz_roll_item)<br>
1182  *   - Reroll item (via wiz_reroll_item)<br>
1183  *   - Change properties (via wiz_tweak_item)<br>
1184  *   - Change the number of items (via wiz_quantity_item)<br>
1185  */
1186 static void do_cmd_wiz_play(player_type *creature_ptr)
1187 {
1188         concptr q = "Play with which object? ";
1189         concptr s = "You have nothing to play with.";
1190
1191         OBJECT_IDX item;
1192         object_type *o_ptr;
1193         o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1194
1195         if (!o_ptr) return;
1196
1197         screen_save(creature_ptr);
1198
1199         object_type     forge;
1200         object_type *q_ptr;
1201         q_ptr = &forge;
1202         object_copy(q_ptr, o_ptr);
1203
1204         /* The main loop */
1205         char ch;
1206         bool changed = FALSE;
1207         while (TRUE)
1208         {
1209                 /* Display the item */
1210                 wiz_display_item(creature_ptr, q_ptr);
1211
1212                 /* Get choice */
1213                 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1214                 {
1215                         changed = FALSE;
1216                         break;
1217                 }
1218
1219                 if (ch == 'A' || ch == 'a')
1220                 {
1221                         changed = TRUE;
1222                         break;
1223                 }
1224
1225                 if (ch == 's' || ch == 'S')
1226                 {
1227                         wiz_statistics(creature_ptr, q_ptr);
1228                 }
1229
1230                 if (ch == 'r' || ch == 'r')
1231                 {
1232                         wiz_reroll_item(creature_ptr, q_ptr);
1233                 }
1234
1235                 if (ch == 't' || ch == 'T')
1236                 {
1237                         wiz_tweak_item(creature_ptr, q_ptr);
1238                 }
1239
1240                 if (ch == 'q' || ch == 'Q')
1241                 {
1242                         wiz_quantity_item(q_ptr);
1243                 }
1244         }
1245
1246         screen_load(creature_ptr);
1247
1248         /* Accept change */
1249         if (changed)
1250         {
1251                 msg_print("Changes accepted.");
1252
1253                 /* Recalcurate object's weight */
1254                 if (item >= 0)
1255                 {
1256                         creature_ptr->total_weight += (q_ptr->weight * q_ptr->number)
1257                                 - (o_ptr->weight * o_ptr->number);
1258                 }
1259
1260                 /* Change */
1261                 object_copy(o_ptr, q_ptr);
1262
1263                 creature_ptr->update |= (PU_BONUS);
1264                 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
1265
1266                 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1267         }
1268
1269         /* Ignore change */
1270         else
1271         {
1272                 msg_print("Changes ignored.");
1273         }
1274 }
1275
1276
1277 /*!
1278  * @brief 任意のベースアイテム生成のメインルーチン /
1279  * Wizard routine for creating objects          -RAK-
1280  * @return なし
1281  * @details
1282  * Heavily modified to allow magification and artifactification  -Bernd-
1283  *
1284  * Note that wizards cannot create objects on top of other objects.
1285  *
1286  * Hack -- this routine always makes a "dungeon object", and applies
1287  * magic to it, and attempts to decline cursed items.
1288  */
1289 static void wiz_create_item(player_type *caster_ptr)
1290 {
1291         screen_save(caster_ptr);
1292
1293         /* Get object base type */
1294         OBJECT_IDX k_idx = wiz_create_itemtype();
1295
1296         screen_load(caster_ptr);
1297
1298         /* Return if failed */
1299         if (!k_idx) return;
1300
1301         if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
1302         {
1303                 ARTIFACT_IDX i;
1304
1305                 /* Artifactify */
1306                 for (i = 1; i < max_a_idx; i++)
1307                 {
1308                         /* Ignore incorrect tval */
1309                         if (a_info[i].tval != k_info[k_idx].tval) continue;
1310
1311                         /* Ignore incorrect sval */
1312                         if (a_info[i].sval != k_info[k_idx].sval) continue;
1313
1314                         /* Create this artifact */
1315                         (void)create_named_art(caster_ptr, i, caster_ptr->y, caster_ptr->x);
1316
1317                         /* All done */
1318                         msg_print("Allocated(INSTA_ART).");
1319
1320                         return;
1321                 }
1322         }
1323
1324         object_type     forge;
1325         object_type *q_ptr;
1326         q_ptr = &forge;
1327         object_prep(q_ptr, k_idx);
1328
1329         apply_magic(caster_ptr, q_ptr, caster_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
1330
1331         /* Drop the object from heaven */
1332         (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x);
1333
1334         /* All done */
1335         msg_print("Allocated.");
1336 }
1337
1338
1339 /*!
1340  * @brief プレイヤーを完全回復する /
1341  * Cure everything instantly
1342  * @return なし
1343  */
1344 static void do_cmd_wiz_cure_all(player_type *creature_ptr)
1345 {
1346         (void)life_stream(creature_ptr, FALSE, FALSE);
1347         (void)restore_mana(creature_ptr, TRUE);
1348         (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
1349 }
1350
1351
1352 /*!
1353  * @brief 任意のダンジョン及び階層に飛ぶ /
1354  * Go to any level
1355  * @return なし
1356  */
1357 static void do_cmd_wiz_jump(player_type *creature_ptr)
1358 {
1359         /* Ask for level */
1360         if (command_arg <= 0)
1361         {
1362                 char    ppp[80];
1363                 char    tmp_val[160];
1364                 DUNGEON_IDX tmp_dungeon_type;
1365
1366                 /* Prompt */
1367                 sprintf(ppp, "Jump which dungeon : ");
1368
1369                 /* Default */
1370                 sprintf(tmp_val, "%d", creature_ptr->dungeon_idx);
1371
1372                 /* Ask for a level */
1373                 if (!get_string(ppp, tmp_val, 2)) return;
1374
1375                 tmp_dungeon_type = (DUNGEON_IDX)atoi(tmp_val);
1376                 if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > current_world_ptr->max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
1377
1378                 /* Prompt */
1379                 sprintf(ppp, "Jump to level (0, %d-%d): ",
1380                         (int)d_info[tmp_dungeon_type].mindepth, (int)d_info[tmp_dungeon_type].maxdepth);
1381
1382                 /* Default */
1383                 sprintf(tmp_val, "%d", (int)creature_ptr->current_floor_ptr->dun_level);
1384
1385                 /* Ask for a level */
1386                 if (!get_string(ppp, tmp_val, 10)) return;
1387
1388                 /* Extract request */
1389                 command_arg = (COMMAND_ARG)atoi(tmp_val);
1390
1391                 creature_ptr->dungeon_idx = tmp_dungeon_type;
1392         }
1393
1394         if (command_arg < d_info[creature_ptr->dungeon_idx].mindepth) command_arg = 0;
1395         if (command_arg > d_info[creature_ptr->dungeon_idx].maxdepth) command_arg = (COMMAND_ARG)d_info[creature_ptr->dungeon_idx].maxdepth;
1396
1397         /* Accept request */
1398         msg_format("You jump to dungeon level %d.", command_arg);
1399
1400         if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
1401
1402         /* Change level */
1403         creature_ptr->current_floor_ptr->dun_level = command_arg;
1404
1405         prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
1406
1407         if (!creature_ptr->current_floor_ptr->dun_level) creature_ptr->dungeon_idx = 0;
1408         creature_ptr->current_floor_ptr->inside_arena = FALSE;
1409         creature_ptr->wild_mode = FALSE;
1410
1411         leave_quest_check(creature_ptr);
1412
1413         if (record_stair) exe_write_diary(creature_ptr, DIARY_WIZ_TELE, 0, NULL);
1414
1415         creature_ptr->current_floor_ptr->inside_quest = 0;
1416         free_turn(creature_ptr);
1417
1418         /* Prevent energy_need from being too lower than 0 */
1419         creature_ptr->energy_need = 0;
1420
1421         /*
1422          * Clear all saved floors
1423          * and create a first saved floor
1424          */
1425         prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
1426         creature_ptr->leaving = TRUE;
1427 }
1428
1429
1430 /*!
1431  * @brief 全ベースアイテムを鑑定済みにする /
1432  * Become aware of a lot of objects
1433  * @param caster_ptr プレーヤーへの参照ポインタ
1434  * @return なし
1435  */
1436 static void do_cmd_wiz_learn(player_type *caster_ptr)
1437 {
1438         /* Scan every object */
1439         object_type forge;
1440         object_type *q_ptr;
1441         for (KIND_OBJECT_IDX i = 1; i < max_k_idx; i++)
1442         {
1443                 object_kind *k_ptr = &k_info[i];
1444
1445                 /* Induce awareness */
1446                 if (k_ptr->level <= command_arg)
1447                 {
1448                         q_ptr = &forge;
1449                         object_prep(q_ptr, i);
1450                         object_aware(caster_ptr, q_ptr);
1451                 }
1452         }
1453 }
1454
1455
1456 /*!
1457  * @brief 現在のフロアに合ったモンスターをランダムに召喚する /
1458  * Summon some creatures
1459  * @param caster_ptr プレーヤーへの参照ポインタ
1460  * @param num 生成処理回数
1461  * @return なし
1462  */
1463 static void do_cmd_wiz_summon(player_type *caster_ptr, int num)
1464 {
1465         for (int i = 0; i < num; i++)
1466         {
1467                 (void)summon_specific(caster_ptr, 0, caster_ptr->y, caster_ptr->x, caster_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1468         }
1469 }
1470
1471
1472 /*!
1473  * @brief モンスターを種族IDを指定して敵対的に召喚する /
1474  * Summon a creature of the specified type
1475  * @param r_idx モンスター種族ID
1476  * @return なし
1477  * @details
1478  * This function is rather dangerous
1479  */
1480 static void do_cmd_wiz_named(player_type *summoner_ptr, MONRACE_IDX r_idx)
1481 {
1482         (void)summon_named_creature(summoner_ptr, 0, summoner_ptr->y, summoner_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
1483 }
1484
1485
1486 /*!
1487  * @brief モンスターを種族IDを指定してペット召喚する /
1488  * Summon a creature of the specified type
1489  * @param r_idx モンスター種族ID
1490  * @return なし
1491  * @details
1492  * This function is rather dangerous
1493  */
1494 static void do_cmd_wiz_named_friendly(player_type *summoner_ptr, MONRACE_IDX r_idx)
1495 {
1496         (void)summon_named_creature(summoner_ptr, 0, summoner_ptr->y, summoner_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
1497 }
1498
1499
1500 /*!
1501  * @brief プレイヤー近辺の全モンスターを消去する /
1502  * Hack -- Delete all nearby monsters
1503  * @return なし
1504  */
1505 static void do_cmd_wiz_zap(player_type *caster_ptr)
1506 {
1507         /* Genocide everyone nearby */
1508         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1509         {
1510                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1511                 if (!monster_is_valid(m_ptr)) continue;
1512
1513                 /* Skip the mount */
1514                 if (i == caster_ptr->riding) continue;
1515
1516                 /* Delete nearby monsters */
1517                 if (m_ptr->cdis > MAX_SIGHT) continue;
1518
1519                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1520                 {
1521                         GAME_TEXT m_name[MAX_NLEN];
1522
1523                         monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
1524                         exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
1525                 }
1526
1527                 delete_monster_idx(caster_ptr, i);
1528         }
1529 }
1530
1531
1532 /*!
1533  * @brief フロアに存在する全モンスターを消去する /
1534  * Hack -- Delete all monsters
1535  * @param caster_ptr 術者の参照ポインタ
1536  * @return なし
1537  */
1538 static void do_cmd_wiz_zap_all(player_type *caster_ptr)
1539 {
1540         /* Genocide everyone */
1541         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1542         {
1543                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1544                 if (!monster_is_valid(m_ptr)) continue;
1545
1546                 /* Skip the mount */
1547                 if (i == caster_ptr->riding) continue;
1548
1549                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1550                 {
1551                         GAME_TEXT m_name[MAX_NLEN];
1552
1553                         monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
1554                         exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
1555                 }
1556
1557                 /* Delete this monster */
1558                 delete_monster_idx(caster_ptr, i);
1559         }
1560 }
1561
1562
1563 /*!
1564  * @brief 指定された地点の地形IDを変更する /
1565  * Create desired feature
1566  * @param creaturer_ptr プレーヤーへの参照ポインタ
1567  * @return なし
1568  */
1569 static void do_cmd_wiz_create_feature(player_type *creature_ptr)
1570 {
1571         POSITION y, x;
1572         if (!tgt_pt(creature_ptr, &x, &y)) return;
1573
1574         grid_type *g_ptr;
1575         g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1576
1577         /* Default */
1578         static int prev_feat = 0;
1579         char tmp_val[160];
1580         sprintf(tmp_val, "%d", prev_feat);
1581
1582         /* Query */
1583         if (!get_string(_("地形: ", "Feature: "), tmp_val, 3)) return;
1584
1585         /* Extract */
1586         FEAT_IDX tmp_feat = (FEAT_IDX)atoi(tmp_val);
1587         if (tmp_feat < 0) tmp_feat = 0;
1588         else if (tmp_feat >= max_f_idx) tmp_feat = max_f_idx - 1;
1589
1590         /* Default */
1591         static int prev_mimic = 0;
1592         sprintf(tmp_val, "%d", prev_mimic);
1593
1594         /* Query */
1595         if (!get_string(_("地形 (mimic): ", "Feature (mimic): "), tmp_val, 3)) return;
1596
1597         /* Extract */
1598         FEAT_IDX tmp_mimic = (FEAT_IDX)atoi(tmp_val);
1599         if (tmp_mimic < 0) tmp_mimic = 0;
1600         else if (tmp_mimic >= max_f_idx) tmp_mimic = max_f_idx - 1;
1601
1602         cave_set_feat(creature_ptr, y, x, tmp_feat);
1603         g_ptr->mimic = (s16b)tmp_mimic;
1604
1605         feature_type *f_ptr;
1606         f_ptr = &f_info[get_feat_mimic(g_ptr)];
1607
1608         if (have_flag(f_ptr->flags, FF_GLYPH) ||
1609                 have_flag(f_ptr->flags, FF_MINOR_GLYPH))
1610                 g_ptr->info |= (CAVE_OBJECT);
1611         else if (have_flag(f_ptr->flags, FF_MIRROR))
1612                 g_ptr->info |= (CAVE_GLOW | CAVE_OBJECT);
1613
1614         note_spot(creature_ptr, y, x);
1615         lite_spot(creature_ptr, y, x);
1616         creature_ptr->update |= (PU_FLOW);
1617
1618         prev_feat = tmp_feat;
1619         prev_mimic = tmp_mimic;
1620 }
1621
1622
1623 /*!
1624  * @brief 現在のオプション設定をダンプ出力する /
1625  * @param creature_ptr プレーヤーへの参照ポインタ
1626  * Hack -- Dump option bits usage
1627  * @return なし
1628  */
1629 static void do_cmd_dump_options()
1630 {
1631         char buf[1024];
1632         path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
1633
1634         FILE *fff;
1635         fff = my_fopen(buf, "a");
1636
1637         if (!fff)
1638         {
1639                 msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
1640                 msg_print(NULL);
1641                 return;
1642         }
1643
1644         /* Allocate the "exist" array (2-dimension) */
1645         int  **exist;
1646         C_MAKE(exist, NUM_O_SET, int *);
1647         C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
1648         for (int i = 1; i < NUM_O_SET; i++) exist[i] = *exist + i * NUM_O_BIT;
1649
1650         /* Check for exist option bits */
1651         for (int i = 0; option_info[i].o_desc; i++)
1652         {
1653                 const option_type *ot_ptr = &option_info[i];
1654                 if (ot_ptr->o_var) exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
1655         }
1656
1657         fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n",
1658                 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1659
1660         fputs("Set - Bit (Page) Option Name\n", fff);
1661         fputs("------------------------------------------------\n", fff);
1662
1663         /* Dump option bits usage */
1664         for (int i = 0; i < NUM_O_SET; i++)
1665         {
1666                 for (int j = 0; j < NUM_O_BIT; j++)
1667                 {
1668                         if (exist[i][j])
1669                         {
1670                                 const option_type *ot_ptr = &option_info[exist[i][j] - 1];
1671                                 fprintf(fff, "  %d -  %02d (%4d) %s\n",
1672                                         i, j, ot_ptr->o_page, ot_ptr->o_text);
1673                         }
1674                         else
1675                         {
1676                                 fprintf(fff, "  %d -  %02d\n", i, j);
1677                         }
1678                 }
1679
1680                 fputc('\n', fff);
1681         }
1682
1683         /* Free the "exist" array (2-dimension) */
1684         C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
1685         C_KILL(exist, NUM_O_SET, int *);
1686         my_fclose(fff);
1687
1688         msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), buf);
1689 }
1690
1691
1692 /*!
1693  * @brief デバッグコマンドを選択する処理のメインルーチン /
1694  * Ask for and parse a "debug command"
1695  * The "command_arg" may have been set.
1696  * @param creature_ptr プレーヤーへの参照ポインタ
1697  * @return なし
1698  */
1699 void do_cmd_debug(player_type *creature_ptr)
1700 {
1701         char cmd;
1702         get_com("Debug Command: ", &cmd, FALSE);
1703
1704         switch (cmd)
1705         {
1706         case ESCAPE:
1707         case ' ':
1708         case '\n':
1709         case '\r':
1710                 break;
1711
1712                 /* Hack -- Generate Spoilers */
1713         case '"':
1714                 do_cmd_spoilers(creature_ptr);
1715                 break;
1716
1717                 /* Hack -- Help */
1718         case '?':
1719                 do_cmd_help(creature_ptr);
1720                 break;
1721
1722                 /* Cure all maladies */
1723         case 'a':
1724                 do_cmd_wiz_cure_all(creature_ptr);
1725                 break;
1726
1727                 /* Know alignment */
1728         case 'A':
1729                 msg_format("Your alignment is %d.", creature_ptr->align);
1730                 break;
1731
1732                 /* Teleport to target */
1733         case 'b':
1734                 do_cmd_wiz_bamf(creature_ptr);
1735                 break;
1736
1737         case 'B':
1738                 update_gambling_monsters(creature_ptr);
1739                 break;
1740
1741                 /* Create any object */
1742         case 'c':
1743                 wiz_create_item(creature_ptr);
1744                 break;
1745
1746                 /* Create a named artifact */
1747         case 'C':
1748                 wiz_create_named_art(creature_ptr);
1749                 break;
1750
1751                 /* Detect everything */
1752         case 'd':
1753                 detect_all(creature_ptr, DETECT_RAD_ALL * 3);
1754                 break;
1755
1756                 /* Dimension_door */
1757         case 'D':
1758                 wiz_dimension_door(creature_ptr);
1759                 break;
1760
1761                 /* Edit character */
1762         case 'e':
1763                 do_cmd_wiz_change(creature_ptr);
1764                 break;
1765
1766                 /* Blue Mage Only */
1767         case 'E':
1768                 if (creature_ptr->pclass == CLASS_BLUE_MAGE)
1769                 {
1770                         do_cmd_wiz_blue_mage(creature_ptr);
1771                 }
1772                 break;
1773
1774                 /* View item info */
1775         case 'f':
1776                 identify_fully(creature_ptr, FALSE, 0);
1777                 break;
1778
1779                 /* Create desired feature */
1780         case 'F':
1781                 do_cmd_wiz_create_feature(creature_ptr);
1782                 break;
1783
1784                 /* Good Objects */
1785         case 'g':
1786                 if (command_arg <= 0) command_arg = 1;
1787                 acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, FALSE, FALSE, TRUE);
1788                 break;
1789
1790                 /* Hitpoint rerating */
1791         case 'h':
1792                 roll_hitdice(creature_ptr, SPOP_DISPLAY_MES | SPOP_DEBUG);
1793                 break;
1794
1795         case 'H':
1796                 do_cmd_summon_horde(creature_ptr);
1797                 break;
1798
1799                 /* Identify */
1800         case 'i':
1801                 (void)ident_spell(creature_ptr, FALSE, 0);
1802                 break;
1803
1804                 /* Go up or down in the dungeon */
1805         case 'j':
1806                 do_cmd_wiz_jump(creature_ptr);
1807                 break;
1808
1809                 /* Self-Knowledge */
1810         case 'k':
1811                 self_knowledge(creature_ptr);
1812                 break;
1813
1814                 /* Learn about objects */
1815         case 'l':
1816                 do_cmd_wiz_learn(creature_ptr);
1817                 break;
1818
1819                 /* Magic Mapping */
1820         case 'm':
1821                 map_area(creature_ptr, DETECT_RAD_ALL * 3);
1822                 break;
1823
1824                 /* Mutation */
1825         case 'M':
1826                 (void)gain_mutation(creature_ptr, command_arg);
1827                 break;
1828
1829                 /* Reset Class */
1830         case 'R':
1831                 (void)do_cmd_wiz_reset_class(creature_ptr);
1832                 break;
1833
1834                 /* Specific reward */
1835         case 'r':
1836                 (void)gain_level_reward(creature_ptr, command_arg);
1837                 break;
1838
1839                 /* Summon _friendly_ named monster */
1840         case 'N':
1841                 do_cmd_wiz_named_friendly(creature_ptr, command_arg);
1842                 break;
1843
1844                 /* Summon Named Monster */
1845         case 'n':
1846                 do_cmd_wiz_named(creature_ptr, command_arg);
1847                 break;
1848
1849                 /* Dump option bits usage */
1850         case 'O':
1851                 do_cmd_dump_options();
1852                 break;
1853
1854                 /* Object playing routines */
1855         case 'o':
1856                 do_cmd_wiz_play(creature_ptr);
1857                 break;
1858
1859                 /* Phase Door */
1860         case 'p':
1861                 teleport_player(creature_ptr, 10, TELEPORT_SPONTANEOUS);
1862                 break;
1863
1864                 /* Take a Quests */
1865         case 'Q':
1866         {
1867                 char ppp[30];
1868                 char tmp_val[5];
1869                 int tmp_int;
1870                 sprintf(ppp, "QuestID (0-%d):", max_q_idx - 1);
1871                 sprintf(tmp_val, "%d", 0);
1872
1873                 if (!get_string(ppp, tmp_val, 3)) return;
1874                 tmp_int = atoi(tmp_val);
1875
1876                 if (tmp_int < 0) break;
1877                 if (tmp_int >= max_q_idx) break;
1878
1879                 creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)tmp_int;
1880                 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
1881                 quest[tmp_int].status = QUEST_STATUS_TAKEN;
1882                 creature_ptr->current_floor_ptr->inside_quest = 0;
1883         }
1884
1885         break;
1886
1887         /* Complete a Quest -KMW- */
1888         case 'q':
1889                 if (creature_ptr->current_floor_ptr->inside_quest)
1890                 {
1891                         if (quest[creature_ptr->current_floor_ptr->inside_quest].status == QUEST_STATUS_TAKEN)
1892                         {
1893                                 complete_quest(creature_ptr, creature_ptr->current_floor_ptr->inside_quest);
1894                                 break;
1895                         }
1896                 }
1897                 else
1898                 {
1899                         msg_print("No current quest");
1900                         msg_print(NULL);
1901                 }
1902
1903                 break;
1904
1905                 /* Make every dungeon square "known" to test streamers -KMW- */
1906         case 'u':
1907                 for (int y = 0; y < creature_ptr->current_floor_ptr->height; y++)
1908                 {
1909                         for (int x = 0; x < creature_ptr->current_floor_ptr->width; x++)
1910                         {
1911                                 creature_ptr->current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1912                         }
1913                 }
1914
1915                 wiz_lite(creature_ptr, FALSE);
1916                 break;
1917
1918                 /* Summon Random Monster(s) */
1919         case 's':
1920                 if (command_arg <= 0) command_arg = 1;
1921                 do_cmd_wiz_summon(creature_ptr, command_arg);
1922                 break;
1923
1924                 /* Special(Random Artifact) Objects */
1925         case 'S':
1926                 if (command_arg <= 0) command_arg = 1;
1927                 acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, TRUE, TRUE);
1928                 break;
1929
1930                 /* Teleport */
1931         case 't':
1932                 teleport_player(creature_ptr, 100, TELEPORT_SPONTANEOUS);
1933                 break;
1934
1935                 /* Game Time Setting */
1936         case 'T':
1937                 set_gametime();
1938                 break;
1939
1940                 /* Very Good Objects */
1941         case 'v':
1942                 if (command_arg <= 0) command_arg = 1;
1943                 acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, FALSE, TRUE);
1944                 break;
1945
1946                 /* Wizard Light the Level */
1947         case 'w':
1948                 wiz_lite(creature_ptr, (bool)(creature_ptr->pclass == CLASS_NINJA));
1949                 break;
1950
1951                 /* Increase Experience */
1952         case 'x':
1953                 gain_exp(creature_ptr, command_arg ? command_arg : (creature_ptr->exp + 1));
1954                 break;
1955
1956                 /* Zap Monsters (Genocide) */
1957         case 'z':
1958                 do_cmd_wiz_zap(creature_ptr);
1959                 break;
1960
1961                 /* Zap Monsters (Omnicide) */
1962         case 'Z':
1963                 do_cmd_wiz_zap_all(creature_ptr);
1964                 break;
1965
1966                 /* Hack -- whatever I desire */
1967         case '_':
1968                 probing(creature_ptr);
1969                 break;
1970
1971                 /* For temporary test. */
1972         case 'X':
1973         {
1974                 INVENTORY_IDX i;
1975                 for (i = INVEN_TOTAL - 1; i >= 0; i--)
1976                 {
1977                         if (creature_ptr->inventory_list[i].k_idx) drop_from_inventory(creature_ptr, i, 999);
1978                 }
1979                 player_outfit(creature_ptr);
1980                 break;
1981         }
1982
1983         case 'V':
1984                 do_cmd_wiz_reset_class(creature_ptr);
1985                 break;
1986
1987         case '@':
1988                 do_cmd_debug_spell(creature_ptr);
1989                 break;
1990
1991         default:
1992                 msg_print("That is not a valid debug command.");
1993                 break;
1994         }
1995 }