OSDN Git Service

7dc62d3b449dd8f9d16be7ba6188fffa61719555
[hengband/hengband.git] / src / wizard / wizard-special-process.c
1 /*!
2  * @brief ウィザードモードの処理(特別処理中心) / Wizard commands
3  * @date 2014/09/07
4  * @author
5  * Copyright (c) 1997 Ben Harrison, and others<br>
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.<br>
9  * 2014 Deskull rearranged comment for Doxygen.<br>
10  */
11
12 #include "wizard/wizard-special-process.h"
13 #include "birth/inventory-initializer.h"
14 #include "cmd-io/cmd-dump.h"
15 #include "cmd-io/cmd-help.h"
16 #include "cmd-io/cmd-save.h"
17 #include "cmd-visual/cmd-draw.h"
18 #include "core/asking-player.h"
19 #include "core/player-update-types.h"
20 #include "core/stuff-handler.h"
21 #include "core/window-redrawer.h"
22 #include "dungeon/dungeon.h"
23 #include "dungeon/quest.h"
24 #include "flavor/flavor-describer.h"
25 #include "flavor/object-flavor-types.h"
26 #include "flavor/object-flavor.h"
27 #include "floor/floor-object.h"
28 #include "floor/floor-save.h"
29 #include "floor/floor.h"
30 #include "game-option/option-types-table.h"
31 #include "game-option/play-record-options.h"
32 #include "game-option/special-options.h"
33 #include "grid/grid.h"
34 #include "info-reader/fixed-map-parser.h"
35 #include "inventory/inventory-object.h"
36 #include "inventory/inventory-slot-types.h"
37 #include "io/files-util.h"
38 #include "io/input-key-acceptor.h"
39 #include "io/input-key-requester.h"
40 #include "io/targeting.h"
41 #include "io/write-diary.h"
42 #include "market/arena.h"
43 #include "monster-floor/monster-remover.h"
44 #include "monster-floor/monster-summon.h"
45 #include "monster/monster-describer.h"
46 #include "monster/monster-description-types.h"
47 #include "monster/monster-info.h"
48 #include "monster/monster-status.h"
49 #include "monster/smart-learn-types.h"
50 #include "mutation/mutation.h"
51 #include "object-enchant/apply-magic.h"
52 #include "object-enchant/artifact.h"
53 #include "object-enchant/item-apply-magic.h"
54 #include "object-enchant/trc-types.h"
55 #include "object-enchant/trg-types.h"
56 #include "object-hook/hook-enchant.h"
57 #include "object/item-use-flags.h"
58 #include "object/object-flags.h"
59 #include "object/object-generator.h"
60 #include "object/object-kind.h"
61 #include "object/object-value.h"
62 #include "perception/object-perception.h"
63 #include "player/digestion-processor.h"
64 #include "player/patron.h"
65 #include "player/player-class.h"
66 #include "player/player-race-types.h"
67 #include "player/player-skill.h"
68 #include "player/player-status.h"
69 #include "player/selfinfo.h"
70 #include "spell-kind/spells-detection.h"
71 #include "spell-kind/spells-floor.h"
72 #include "spell-kind/spells-perception.h"
73 #include "spell-kind/spells-sight.h"
74 #include "spell-kind/spells-teleport.h"
75 #include "spell/spells-object.h"
76 #include "spell/spells-status.h"
77 #include "spell/spells-summon.h"
78 #include "status/experience.h"
79 #include "system/alloc-entries.h"
80 #include "system/angband-version.h"
81 #include "term/screen-processor.h"
82 #include "term/term-color-types.h"
83 #include "util/angband-files.h"
84 #include "util/bit-flags-calculator.h"
85 #include "util/int-char-converter.h"
86 #include "view/display-messages.h"
87 #include "wizard/tval-descriptions-table.h"
88 #include "wizard/wizard-spells.h"
89 #include "wizard/wizard-spoiler.h"
90 #include "world/world.h"
91
92 #define K_MAX_DEPTH 110 /*!< アイテムの階層毎生成率を表示する最大階 */
93
94 #define NUM_O_SET 8
95 #define NUM_O_BIT 32
96
97 /*!
98  * @brief 指定されたIDの固定アーティファクトを生成する / Create the artifact of the specified number
99  * @param caster_ptr プレーヤーへの参照ポインタ
100  * @return なし
101  */
102 static void wiz_create_named_art(player_type *caster_ptr)
103 {
104     char tmp_val[10] = "";
105     if (!get_string("Artifact ID:", tmp_val, 3))
106         return;
107
108     ARTIFACT_IDX a_idx = (ARTIFACT_IDX)atoi(tmp_val);
109     if ((a_idx < 0) || (a_idx >= max_a_idx))
110         a_idx = 0;
111
112     (void)create_named_art(caster_ptr, a_idx, caster_ptr->y, caster_ptr->x);
113     msg_print("Allocated.");
114 }
115
116 /*!
117  * @brief 32ビット変数のビット配列を並べて描画する / Output a long int in binary format.
118  * @return なし
119  */
120 static void prt_binary(BIT_FLAGS flags, int row, int col)
121 {
122     u32b bitmask;
123     for (int i = bitmask = 1; i <= 32; i++, bitmask *= 2) {
124         if (flags & bitmask) {
125             Term_putch(col++, row, TERM_BLUE, '*');
126         } else {
127             Term_putch(col++, row, TERM_WHITE, '-');
128         }
129     }
130 }
131
132 /*!
133  * @brief アイテムの階層毎生成率を表示する / Output a rarity graph for a type of object.
134  * @param tval ベースアイテムの大項目ID
135  * @param sval ベースアイテムの小項目ID
136  * @param row 表示列
137  * @param col 表示行
138  * @return なし
139  */
140 static void prt_alloc(tval_type tval, OBJECT_SUBTYPE_VALUE sval, TERM_LEN row, TERM_LEN col)
141 {
142     u32b rarity[K_MAX_DEPTH];
143     (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
144     u32b total[K_MAX_DEPTH];
145     (void)C_WIPE(total, K_MAX_DEPTH, u32b);
146     s32b display[22];
147     (void)C_WIPE(display, 22, s32b);
148
149     int home = 0;
150     for (int i = 0; i < K_MAX_DEPTH; i++) {
151         int total_frac = 0;
152         object_kind *k_ptr;
153         alloc_entry *table = alloc_kind_table;
154         for (int j = 0; j < alloc_kind_size; j++) {
155             PERCENTAGE prob = 0;
156
157             if (table[j].level <= i) {
158                 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
159             } else if (table[j].level - 1 > 0) {
160                 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
161             }
162
163             k_ptr = &k_info[table[j].index];
164
165             total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
166             total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
167
168             if ((k_ptr->tval == tval) && (k_ptr->sval == sval)) {
169                 home = k_ptr->level;
170                 rarity[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
171             }
172         }
173
174         total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
175     }
176
177     for (int i = 0; i < 22; i++) {
178         int possibility = 0;
179         for (int j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
180             possibility += rarity[j] * 100000 / total[j];
181
182         display[i] = possibility / 5;
183     }
184
185     for (int i = 0; i < 22; i++) {
186         Term_putch(col, row + i + 1, TERM_WHITE, '|');
187         prt(format("%2dF", (i * 5)), row + i + 1, col);
188         if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
189             c_prt(TERM_RED, format("%3d.%04d%%", display[i] / 1000, display[i] % 1000), row + i + 1, col + 3);
190         else
191             c_prt(TERM_WHITE, format("%3d.%04d%%", display[i] / 1000, display[i] % 1000), row + i + 1, col + 3);
192     }
193
194     concptr r = "+---Rate---+";
195     prt(r, row, col);
196 }
197
198 /*!
199  * @brief プレイヤーの職業を変更する
200  * @return なし
201  * @todo 魔法領域の再選択などがまだ不完全、要実装。
202  */
203 static void do_cmd_wiz_reset_class(player_type *creature_ptr)
204 {
205     char ppp[80];
206     sprintf(ppp, "Class (0-%d): ", MAX_CLASS - 1);
207
208     char tmp_val[160];
209     sprintf(tmp_val, "%d", creature_ptr->pclass);
210
211     if (!get_string(ppp, tmp_val, 2))
212         return;
213
214     int tmp_int = atoi(tmp_val);
215     if (tmp_int < 0 || tmp_int >= MAX_CLASS)
216         return;
217
218     creature_ptr->pclass = (byte)tmp_int;
219     creature_ptr->window |= (PW_PLAYER);
220     creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
221     handle_stuff(creature_ptr);
222 }
223
224 /*!
225  * @brief プレイヤーの現能力値を調整する
226  * Aux function for "do_cmd_wiz_change()".      -RAK-
227  * @return なし
228  */
229 static void do_cmd_wiz_change_aux(player_type *creature_ptr)
230 {
231     int tmp_int;
232     long tmp_long;
233     s16b tmp_s16b;
234     char tmp_val[160];
235     char ppp[80];
236
237     for (int i = 0; i < A_MAX; i++) {
238         sprintf(ppp, "%s (3-%d): ", stat_names[i], creature_ptr->stat_max_max[i]);
239         sprintf(tmp_val, "%d", creature_ptr->stat_max[i]);
240         if (!get_string(ppp, tmp_val, 3))
241             return;
242
243         tmp_int = atoi(tmp_val);
244         if (tmp_int > creature_ptr->stat_max_max[i])
245             tmp_int = creature_ptr->stat_max_max[i];
246         else if (tmp_int < 3)
247             tmp_int = 3;
248
249         creature_ptr->stat_cur[i] = creature_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
250     }
251
252     sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
253     if (!get_string(_("熟練度: ", "Proficiency: "), tmp_val, 9))
254         return;
255
256     tmp_s16b = (s16b)atoi(tmp_val);
257     if (tmp_s16b < WEAPON_EXP_UNSKILLED)
258         tmp_s16b = WEAPON_EXP_UNSKILLED;
259     if (tmp_s16b > WEAPON_EXP_MASTER)
260         tmp_s16b = WEAPON_EXP_MASTER;
261
262     for (int j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++) {
263         for (int i = 0; i < 64; i++) {
264             creature_ptr->weapon_exp[j][i] = tmp_s16b;
265             if (creature_ptr->weapon_exp[j][i] > s_info[creature_ptr->pclass].w_max[j][i])
266                 creature_ptr->weapon_exp[j][i] = s_info[creature_ptr->pclass].w_max[j][i];
267         }
268     }
269
270     for (int j = 0; j < 10; j++) {
271         creature_ptr->skill_exp[j] = tmp_s16b;
272         if (creature_ptr->skill_exp[j] > s_info[creature_ptr->pclass].s_max[j])
273             creature_ptr->skill_exp[j] = s_info[creature_ptr->pclass].s_max[j];
274     }
275
276     int k;
277     for (k = 0; k < 32; k++)
278         creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
279
280     for (; k < 64; k++)
281         creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
282
283     sprintf(tmp_val, "%ld", (long)(creature_ptr->au));
284     if (!get_string("Gold: ", tmp_val, 9))
285         return;
286
287     tmp_long = atol(tmp_val);
288     if (tmp_long < 0)
289         tmp_long = 0L;
290
291     creature_ptr->au = tmp_long;
292     sprintf(tmp_val, "%ld", (long)(creature_ptr->max_exp));
293     if (!get_string("Experience: ", tmp_val, 9))
294         return;
295
296     tmp_long = atol(tmp_val);
297     if (tmp_long < 0)
298         tmp_long = 0L;
299
300     if (creature_ptr->prace == RACE_ANDROID)
301         return;
302
303     creature_ptr->max_exp = tmp_long;
304     creature_ptr->exp = tmp_long;
305     check_experience(creature_ptr);
306 }
307
308 /*!
309  * @brief プレイヤーの現能力値を調整する(メインルーチン)
310  * Change various "permanent" player variables.
311  * @return なし
312  */
313 static void do_cmd_wiz_change(player_type *creature_ptr)
314 {
315     do_cmd_wiz_change_aux(creature_ptr);
316     do_cmd_redraw(creature_ptr);
317 }
318
319 /*!
320  * @brief アイテムの詳細ステータスを表示する /
321  * Change various "permanent" player variables.
322  * @param player_ptr プレーヤーへの参照ポインタ
323  * @param o_ptr 詳細を表示するアイテム情報の参照ポインタ
324  * @return なし
325  */
326 static void wiz_display_item(player_type *player_ptr, object_type *o_ptr)
327 {
328     BIT_FLAGS flgs[TR_FLAG_SIZE];
329     object_flags(player_ptr, o_ptr, flgs);
330
331     int j = 13;
332     for (int i = 1; i <= 23; i++)
333         prt("", i, j - 2);
334
335     prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
336     char buf[256];
337     describe_flavor(player_ptr, buf, o_ptr, OD_STORE);
338     prt(buf, 2, j);
339     prt(format("kind = %-5d  level = %-4d  tval = %-5d  sval = %-5d", o_ptr->k_idx, k_info[o_ptr->k_idx].level, o_ptr->tval, o_ptr->sval), 4, j);
340     prt(format("number = %-3d  wgt = %-6d  ac = %-5d    damage = %dd%d", o_ptr->number, o_ptr->weight, o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
341     prt(format("pval = %-5d  toac = %-5d  tohit = %-4d  todam = %-4d", o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
342     prt(format("name1 = %-4d  name2 = %-4d  cost = %ld", o_ptr->name1, o_ptr->name2, (long)object_value_real(player_ptr, o_ptr)), 7, j);
343     prt(format("ident = %04x  xtra1 = %-4d  xtra2 = %-4d  timeout = %-d", o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
344     prt(format("xtra3 = %-4d  xtra4 = %-4d  xtra5 = %-4d  cursed  = %-d", o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
345
346     prt("+------------FLAGS1------------+", 10, j);
347     prt("AFFECT........SLAY........BRAND.", 11, j);
348     prt("      mf      cvae      xsqpaefc", 12, j);
349     prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
350     prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
351     prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
352     prt_binary(flgs[0], 16, j);
353
354     prt("+------------FLAGS2------------+", 17, j);
355     prt("SUST....IMMUN.RESIST............", 18, j);
356     prt("      reaefctrpsaefcpfldbc sn   ", 19, j);
357     prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
358     prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
359     prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
360     prt_binary(flgs[1], 23, j);
361
362     prt("+------------FLAGS3------------+", 10, j + 32);
363     prt("fe cnn t      stdrmsiiii d ab   ", 11, j + 32);
364     prt("aa aoomywhs lleeieihgggg rtgl   ", 12, j + 32);
365     prt("uu utmacaih eielgggonnnnaaere   ", 13, j + 32);
366     prt("rr reanurdo vtieeehtrrrrcilas   ", 14, j + 32);
367     prt("aa algarnew ienpsntsaefctnevs   ", 15, j + 32);
368     prt_binary(flgs[2], 16, j + 32);
369
370     prt("+------------FLAGS4------------+", 17, j + 32);
371     prt("KILL....ESP.........            ", 18, j + 32);
372     prt("aeud tghaud tgdhegnu            ", 19, j + 32);
373     prt("nvneoriunneoriruvoon            ", 20, j + 32);
374     prt("iidmroamidmroagmionq            ", 21, j + 32);
375     prt("mlenclnmmenclnnnldlu            ", 22, j + 32);
376     prt_binary(flgs[3], 23, j + 32);
377 }
378
379 /*!
380  * @brief ベースアイテムのウィザード生成のために大項目IDと小項目IDを取得する /
381  * Specify tval and sval (type and subtype of object) originally
382  * @return ベースアイテムID
383  * @details
384  * by RAK, heavily modified by -Bernd-
385  * This function returns the k_idx of an object type, or zero if failed
386  * List up to 50 choices in three columns
387  */
388 static KIND_OBJECT_IDX wiz_create_itemtype(void)
389 {
390     KIND_OBJECT_IDX i;
391     int num;
392     TERM_LEN col, row;
393     char ch;
394     KIND_OBJECT_IDX choice[80];
395     char buf[160];
396
397     Term_clear();
398     for (num = 0; (num < 80) && tvals[num].tval; num++) {
399         row = 2 + (num % 20);
400         col = 20 * (num / 20);
401         ch = listsym[num];
402         prt(format("[%c] %s", ch, tvals[num].desc), row, col);
403     }
404
405     int max_num = num;
406     if (!get_com("Get what type of object? ", &ch, FALSE))
407         return 0;
408
409     for (num = 0; num < max_num; num++) {
410         if (listsym[num] == ch)
411             break;
412     }
413
414     if ((num < 0) || (num >= max_num))
415         return 0;
416
417     tval_type tval = tvals[num].tval;
418     concptr tval_desc = tvals[num].desc;
419     Term_clear();
420     for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++) {
421         object_kind *k_ptr = &k_info[i];
422         if (k_ptr->tval != tval)
423             continue;
424
425         row = 2 + (num % 20);
426         col = 20 * (num / 20);
427         ch = listsym[num];
428         strcpy(buf, "                    ");
429         strip_name(buf, i);
430         prt(format("[%c] %s", ch, buf), row, col);
431         choice[num++] = i;
432     }
433
434     max_num = num;
435     if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE))
436         return 0;
437
438     for (num = 0; num < max_num; num++)
439         if (listsym[num] == ch)
440             break;
441
442     if ((num < 0) || (num >= max_num))
443         return 0;
444
445     return choice[num];
446 }
447
448 /*!
449  * @briefアイテムの基礎能力値を調整する / Tweak an item
450  * @param player_ptr プレーヤーへの参照ポインタ
451  * @param o_ptr 調整するアイテムの参照ポインタ
452  * @return なし
453  */
454 static void wiz_tweak_item(player_type *player_ptr, object_type *o_ptr)
455 {
456     if (object_is_artifact(o_ptr))
457         return;
458
459     concptr p = "Enter new 'pval' setting: ";
460     char tmp_val[80];
461     sprintf(tmp_val, "%d", o_ptr->pval);
462     if (!get_string(p, tmp_val, 5))
463         return;
464     o_ptr->pval = (s16b)atoi(tmp_val);
465     wiz_display_item(player_ptr, o_ptr);
466
467     p = "Enter new 'to_a' setting: ";
468     sprintf(tmp_val, "%d", o_ptr->to_a);
469     if (!get_string(p, tmp_val, 5))
470         return;
471     o_ptr->to_a = (s16b)atoi(tmp_val);
472     wiz_display_item(player_ptr, o_ptr);
473
474     p = "Enter new 'to_h' setting: ";
475     sprintf(tmp_val, "%d", o_ptr->to_h);
476     if (!get_string(p, tmp_val, 5))
477         return;
478     o_ptr->to_h = (s16b)atoi(tmp_val);
479     wiz_display_item(player_ptr, o_ptr);
480
481     p = "Enter new 'to_d' setting: ";
482     sprintf(tmp_val, "%d", (int)o_ptr->to_d);
483     if (!get_string(p, tmp_val, 5))
484         return;
485     o_ptr->to_d = (s16b)atoi(tmp_val);
486     wiz_display_item(player_ptr, o_ptr);
487 }
488
489 /*!
490  * @brief アイテムの質を選択して再生成する /
491  * Apply magic to an item or turn it into an artifact. -Bernd-
492  * @param o_ptr 再生成の対象となるアイテム情報の参照ポインタ
493  * @return なし
494  */
495 static void wiz_reroll_item(player_type *owner_ptr, object_type *o_ptr)
496 {
497     if (object_is_artifact(o_ptr))
498         return;
499
500     object_type forge;
501     object_type *q_ptr;
502     q_ptr = &forge;
503     object_copy(q_ptr, o_ptr);
504
505     char ch;
506     bool changed = FALSE;
507     while (TRUE) {
508         wiz_display_item(owner_ptr, q_ptr);
509         if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE)) {
510             if (object_is_fixed_artifact(q_ptr)) {
511                 a_info[q_ptr->name1].cur_num = 0;
512                 q_ptr->name1 = 0;
513             }
514
515             changed = FALSE;
516             break;
517         }
518
519         if (ch == 'A' || ch == 'a') {
520             changed = TRUE;
521             break;
522         }
523
524         if (object_is_fixed_artifact(q_ptr)) {
525             a_info[q_ptr->name1].cur_num = 0;
526             q_ptr->name1 = 0;
527         }
528
529         switch (ch) {
530         /* Apply bad magic, but first clear object */
531         case 'w':
532         case 'W': {
533             object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
534             apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
535             break;
536         }
537         /* Apply bad magic, but first clear object */
538         case 'c':
539         case 'C': {
540             object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
541             apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
542             break;
543         }
544         /* Apply normal magic, but first clear object */
545         case 'n':
546         case 'N': {
547             object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
548             apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
549             break;
550         }
551         /* Apply good magic, but first clear object */
552         case 'g':
553         case 'G': {
554             object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
555             apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD);
556             break;
557         }
558         /* Apply great magic, but first clear object */
559         case 'e':
560         case 'E': {
561             object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
562             apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
563             break;
564         }
565         /* Apply special magic, but first clear object */
566         case 's':
567         case 'S': {
568             object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
569             apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
570
571             if (!object_is_artifact(q_ptr))
572                 become_random_artifact(owner_ptr, q_ptr, FALSE);
573
574             break;
575         }
576         }
577
578         q_ptr->iy = o_ptr->iy;
579         q_ptr->ix = o_ptr->ix;
580         q_ptr->next_o_idx = o_ptr->next_o_idx;
581         q_ptr->marked = o_ptr->marked;
582     }
583
584     if (changed) {
585         object_copy(o_ptr, q_ptr);
586         owner_ptr->update |= (PU_BONUS);
587         owner_ptr->update |= (PU_COMBINE | PU_REORDER);
588         owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
589     }
590 }
591
592 /*!
593  * @brief 検査対象のアイテムを基準とした生成テストを行う /
594  * Try to create an item again. Output some statistics.    -Bernd-
595  * @param caster_ptr プレーヤーへの参照ポインタ
596  * @param o_ptr 生成テストの基準となるアイテム情報の参照ポインタ
597  * @return なし
598  * The statistics are correct now.  We acquire a clean grid, and then
599  * repeatedly place an object in this grid, copying it into an item
600  * holder, and then deleting the object.  We fiddle with the artifact
601  * counter flags to prevent weirdness.  We use the items to collect
602  * statistics on item creation relative to the initial item.
603  */
604 static void wiz_statistics(player_type *caster_ptr, object_type *o_ptr)
605 {
606     object_type forge;
607     object_type *q_ptr;
608
609     concptr q = "Rolls: %ld  Correct: %ld  Matches: %ld  Better: %ld  Worse: %ld  Other: %ld";
610     concptr p = "Enter number of items to roll: ";
611     char tmp_val[80];
612
613     if (object_is_fixed_artifact(o_ptr))
614         a_info[o_ptr->name1].cur_num = 0;
615
616     u32b i, matches, better, worse, other, correct;
617     u32b test_roll = 1000000;
618     char ch;
619     concptr quality;
620     BIT_FLAGS mode;
621     while (TRUE) {
622         concptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
623         wiz_display_item(caster_ptr, o_ptr);
624         if (!get_com(pmt, &ch, FALSE))
625             break;
626
627         if (ch == 'n' || ch == 'N') {
628             mode = 0L;
629             quality = "normal";
630         } else if (ch == 'g' || ch == 'G') {
631             mode = AM_GOOD;
632             quality = "good";
633         } else if (ch == 'e' || ch == 'E') {
634             mode = AM_GOOD | AM_GREAT;
635             quality = "excellent";
636         } else {
637             break;
638         }
639
640         sprintf(tmp_val, "%ld", (long int)test_roll);
641         if (get_string(p, tmp_val, 10))
642             test_roll = atol(tmp_val);
643         test_roll = MAX(1, test_roll);
644         msg_format("Creating a lot of %s items. Base level = %d.", quality, caster_ptr->current_floor_ptr->dun_level);
645         msg_print(NULL);
646
647         correct = matches = better = worse = other = 0;
648         for (i = 0; i <= test_roll; i++) {
649             if ((i < 100) || (i % 100 == 0)) {
650                 inkey_scan = TRUE;
651                 if (inkey()) {
652                     flush();
653                     break; // stop rolling
654                 }
655
656                 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
657                 Term_fresh();
658             }
659
660             q_ptr = &forge;
661             object_wipe(q_ptr);
662             make_object(caster_ptr, q_ptr, mode);
663             if (object_is_fixed_artifact(q_ptr))
664                 a_info[q_ptr->name1].cur_num = 0;
665
666             if ((o_ptr->tval != q_ptr->tval) || (o_ptr->sval != q_ptr->sval))
667                 continue;
668
669             correct++;
670             if ((q_ptr->pval == o_ptr->pval) && (q_ptr->to_a == o_ptr->to_a) && (q_ptr->to_h == o_ptr->to_h) && (q_ptr->to_d == o_ptr->to_d)
671                 && (q_ptr->name1 == o_ptr->name1)) {
672                 matches++;
673             } else if ((q_ptr->pval >= o_ptr->pval) && (q_ptr->to_a >= o_ptr->to_a) && (q_ptr->to_h >= o_ptr->to_h) && (q_ptr->to_d >= o_ptr->to_d)) {
674                 better++;
675             } else if ((q_ptr->pval <= o_ptr->pval) && (q_ptr->to_a <= o_ptr->to_a) && (q_ptr->to_h <= o_ptr->to_h) && (q_ptr->to_d <= o_ptr->to_d)) {
676                 worse++;
677             } else {
678                 other++;
679             }
680         }
681
682         msg_format(q, i, correct, matches, better, worse, other);
683         msg_print(NULL);
684     }
685
686     if (object_is_fixed_artifact(o_ptr))
687         a_info[o_ptr->name1].cur_num = 1;
688 }
689
690 /*!
691  * @brief 検査対象のアイテムの数を変更する /
692  * Change the quantity of a the item
693  * @param caster_ptr プレーヤーへの参照ポインタ
694  * @param o_ptr 変更するアイテム情報構造体の参照ポインタ
695  * @return なし
696  */
697 static void wiz_quantity_item(object_type *o_ptr)
698 {
699     if (object_is_artifact(o_ptr))
700         return;
701
702     int tmp_qnt = o_ptr->number;
703     char tmp_val[100];
704     sprintf(tmp_val, "%d", (int)o_ptr->number);
705     if (get_string("Quantity: ", tmp_val, 2)) {
706         int tmp_int = atoi(tmp_val);
707         if (tmp_int < 1)
708             tmp_int = 1;
709
710         if (tmp_int > 99)
711             tmp_int = 99;
712
713         o_ptr->number = (byte)tmp_int;
714     }
715
716     if (o_ptr->tval == TV_ROD)
717         o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
718 }
719
720 /*!
721  * @brief アイテム検査のメインルーチン /
722  * Play with an item. Options include:
723  * @return なし
724  * @details
725  *   - Output statistics (via wiz_roll_item)<br>
726  *   - Reroll item (via wiz_reroll_item)<br>
727  *   - Change properties (via wiz_tweak_item)<br>
728  *   - Change the number of items (via wiz_quantity_item)<br>
729  */
730 static void do_cmd_wiz_play(player_type *creature_ptr)
731 {
732     concptr q = "Play with which object? ";
733     concptr s = "You have nothing to play with.";
734
735     OBJECT_IDX item;
736     object_type *o_ptr;
737     o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
738     if (!o_ptr)
739         return;
740
741     screen_save(creature_ptr);
742
743     object_type forge;
744     object_type *q_ptr;
745     q_ptr = &forge;
746     object_copy(q_ptr, o_ptr);
747     char ch;
748     bool changed = FALSE;
749     while (TRUE) {
750         wiz_display_item(creature_ptr, q_ptr);
751         if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE)) {
752             changed = FALSE;
753             break;
754         }
755
756         if (ch == 'A' || ch == 'a') {
757             changed = TRUE;
758             break;
759         }
760
761         if (ch == 's' || ch == 'S') {
762             wiz_statistics(creature_ptr, q_ptr);
763         }
764
765         if (ch == 'r' || ch == 'R') {
766             wiz_reroll_item(creature_ptr, q_ptr);
767         }
768
769         if (ch == 't' || ch == 'T') {
770             wiz_tweak_item(creature_ptr, q_ptr);
771         }
772
773         if (ch == 'q' || ch == 'Q') {
774             wiz_quantity_item(q_ptr);
775         }
776     }
777
778     screen_load(creature_ptr);
779     if (changed) {
780         msg_print("Changes accepted.");
781         if (item >= 0) {
782             creature_ptr->total_weight += (q_ptr->weight * q_ptr->number) - (o_ptr->weight * o_ptr->number);
783         }
784
785         object_copy(o_ptr, q_ptr);
786         creature_ptr->update |= (PU_BONUS);
787         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
788         creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
789     } else {
790         msg_print("Changes ignored.");
791     }
792 }
793
794 /*!
795  * @brief 任意のベースアイテム生成のメインルーチン /
796  * Wizard routine for creating objects          -RAK-
797  * @return なし
798  * @details
799  * Heavily modified to allow magification and artifactification  -Bernd-
800  *
801  * Note that wizards cannot create objects on top of other objects.
802  *
803  * Hack -- this routine always makes a "dungeon object", and applies
804  * magic to it, and attempts to decline cursed items.
805  */
806 static void wiz_create_item(player_type *caster_ptr)
807 {
808     screen_save(caster_ptr);
809     OBJECT_IDX k_idx = wiz_create_itemtype();
810     screen_load(caster_ptr);
811     if (!k_idx)
812         return;
813
814     if (k_info[k_idx].gen_flags & TRG_INSTA_ART) {
815         for (ARTIFACT_IDX i = 1; i < max_a_idx; i++) {
816             if ((a_info[i].tval != k_info[k_idx].tval) || (a_info[i].sval != k_info[k_idx].sval))
817                 continue;
818
819             (void)create_named_art(caster_ptr, i, caster_ptr->y, caster_ptr->x);
820             msg_print("Allocated(INSTA_ART).");
821             return;
822         }
823     }
824
825     object_type forge;
826     object_type *q_ptr;
827     q_ptr = &forge;
828     object_prep(caster_ptr, q_ptr, k_idx);
829     apply_magic(caster_ptr, q_ptr, caster_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
830     (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x);
831     msg_print("Allocated.");
832 }
833
834 /*!
835  * @brief プレイヤーを完全回復する /
836  * Cure everything instantly
837  * @return なし
838  */
839 static void do_cmd_wiz_cure_all(player_type *creature_ptr)
840 {
841     (void)life_stream(creature_ptr, FALSE, FALSE);
842     (void)restore_mana(creature_ptr, TRUE);
843     (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
844 }
845
846 /*!
847  * @brief 任意のダンジョン及び階層に飛ぶ /
848  * Go to any level
849  * @return なし
850  */
851 static void do_cmd_wiz_jump(player_type *creature_ptr)
852 {
853     if (command_arg <= 0) {
854         char ppp[80];
855         char tmp_val[160];
856         DUNGEON_IDX tmp_dungeon_type;
857         sprintf(ppp, "Jump which dungeon : ");
858         sprintf(tmp_val, "%d", creature_ptr->dungeon_idx);
859         if (!get_string(ppp, tmp_val, 2))
860             return;
861
862         tmp_dungeon_type = (DUNGEON_IDX)atoi(tmp_val);
863         if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > current_world_ptr->max_d_idx))
864             tmp_dungeon_type = DUNGEON_ANGBAND;
865
866         sprintf(ppp, "Jump to level (0, %d-%d): ", (int)d_info[tmp_dungeon_type].mindepth, (int)d_info[tmp_dungeon_type].maxdepth);
867         sprintf(tmp_val, "%d", (int)creature_ptr->current_floor_ptr->dun_level);
868         if (!get_string(ppp, tmp_val, 10))
869             return;
870
871         command_arg = (COMMAND_ARG)atoi(tmp_val);
872         creature_ptr->dungeon_idx = tmp_dungeon_type;
873     }
874
875     if (command_arg < d_info[creature_ptr->dungeon_idx].mindepth)
876         command_arg = 0;
877
878     if (command_arg > d_info[creature_ptr->dungeon_idx].maxdepth)
879         command_arg = (COMMAND_ARG)d_info[creature_ptr->dungeon_idx].maxdepth;
880
881     msg_format("You jump to dungeon level %d.", command_arg);
882     if (autosave_l)
883         do_cmd_save_game(creature_ptr, TRUE);
884
885     creature_ptr->current_floor_ptr->dun_level = command_arg;
886     prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
887     if (!creature_ptr->current_floor_ptr->dun_level)
888         creature_ptr->dungeon_idx = 0;
889
890     creature_ptr->current_floor_ptr->inside_arena = FALSE;
891     creature_ptr->wild_mode = FALSE;
892     leave_quest_check(creature_ptr);
893     if (record_stair)
894         exe_write_diary(creature_ptr, DIARY_WIZ_TELE, 0, NULL);
895
896     creature_ptr->current_floor_ptr->inside_quest = 0;
897     free_turn(creature_ptr);
898     creature_ptr->energy_need = 0;
899     prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
900     creature_ptr->leaving = TRUE;
901 }
902
903 /*!
904  * @brief 全ベースアイテムを鑑定済みにする /
905  * Become aware of a lot of objects
906  * @param caster_ptr プレーヤーへの参照ポインタ
907  * @return なし
908  */
909 static void do_cmd_wiz_learn(player_type *caster_ptr)
910 {
911     object_type forge;
912     object_type *q_ptr;
913     for (KIND_OBJECT_IDX i = 1; i < max_k_idx; i++) {
914         object_kind *k_ptr = &k_info[i];
915         if (k_ptr->level <= command_arg) {
916             q_ptr = &forge;
917             object_prep(caster_ptr, q_ptr, i);
918             object_aware(caster_ptr, q_ptr);
919         }
920     }
921 }
922
923 /*!
924  * @brief プレイヤー近辺の全モンスターを消去する /
925  * Hack -- Delete all nearby monsters
926  * @return なし
927  */
928 static void do_cmd_wiz_zap(player_type *caster_ptr)
929 {
930     for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
931         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
932         if (!monster_is_valid(m_ptr) || (i == caster_ptr->riding) || (m_ptr->cdis > MAX_SIGHT))
933             continue;
934
935         if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
936             GAME_TEXT m_name[MAX_NLEN];
937
938             monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
939             exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
940         }
941
942         delete_monster_idx(caster_ptr, i);
943     }
944 }
945
946 /*!
947  * @brief フロアに存在する全モンスターを消去する /
948  * Hack -- Delete all monsters
949  * @param caster_ptr 術者の参照ポインタ
950  * @return なし
951  */
952 static void do_cmd_wiz_zap_all(player_type *caster_ptr)
953 {
954     for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
955         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
956         if (!monster_is_valid(m_ptr) || (i == caster_ptr->riding))
957             continue;
958
959         if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
960             GAME_TEXT m_name[MAX_NLEN];
961             monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
962             exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
963         }
964
965         delete_monster_idx(caster_ptr, i);
966     }
967 }
968
969 /*!
970  * @brief 指定された地点の地形IDを変更する /
971  * Create desired feature
972  * @param creaturer_ptr プレーヤーへの参照ポインタ
973  * @return なし
974  */
975 static void do_cmd_wiz_create_feature(player_type *creature_ptr)
976 {
977     POSITION y, x;
978     if (!tgt_pt(creature_ptr, &x, &y))
979         return;
980
981     grid_type *g_ptr;
982     g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
983     static int prev_feat = 0;
984     char tmp_val[160];
985     sprintf(tmp_val, "%d", prev_feat);
986
987     if (!get_string(_("地形: ", "Feature: "), tmp_val, 3))
988         return;
989
990     FEAT_IDX tmp_feat = (FEAT_IDX)atoi(tmp_val);
991     if (tmp_feat < 0)
992         tmp_feat = 0;
993     else if (tmp_feat >= max_f_idx)
994         tmp_feat = max_f_idx - 1;
995
996     static int prev_mimic = 0;
997     sprintf(tmp_val, "%d", prev_mimic);
998
999     if (!get_string(_("地形 (mimic): ", "Feature (mimic): "), tmp_val, 3))
1000         return;
1001
1002     FEAT_IDX tmp_mimic = (FEAT_IDX)atoi(tmp_val);
1003     if (tmp_mimic < 0)
1004         tmp_mimic = 0;
1005     else if (tmp_mimic >= max_f_idx)
1006         tmp_mimic = max_f_idx - 1;
1007
1008     cave_set_feat(creature_ptr, y, x, tmp_feat);
1009     g_ptr->mimic = (s16b)tmp_mimic;
1010     feature_type *f_ptr;
1011     f_ptr = &f_info[get_feat_mimic(g_ptr)];
1012
1013     if (have_flag(f_ptr->flags, FF_GLYPH) || have_flag(f_ptr->flags, FF_MINOR_GLYPH))
1014         g_ptr->info |= (CAVE_OBJECT);
1015     else if (have_flag(f_ptr->flags, FF_MIRROR))
1016         g_ptr->info |= (CAVE_GLOW | CAVE_OBJECT);
1017
1018     note_spot(creature_ptr, y, x);
1019     lite_spot(creature_ptr, y, x);
1020     creature_ptr->update |= (PU_FLOW);
1021     prev_feat = tmp_feat;
1022     prev_mimic = tmp_mimic;
1023 }
1024
1025 /*!
1026  * @brief 現在のオプション設定をダンプ出力する /
1027  * @param creature_ptr プレーヤーへの参照ポインタ
1028  * Hack -- Dump option bits usage
1029  * @return なし
1030  */
1031 static void do_cmd_dump_options()
1032 {
1033     char buf[1024];
1034     path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
1035     FILE *fff;
1036     fff = angband_fopen(buf, "a");
1037     if (fff == NULL) {
1038         msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
1039         msg_print(NULL);
1040         return;
1041     }
1042
1043     int **exist;
1044     C_MAKE(exist, NUM_O_SET, int *);
1045     C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
1046     for (int i = 1; i < NUM_O_SET; i++)
1047         exist[i] = *exist + i * NUM_O_BIT;
1048
1049     for (int i = 0; option_info[i].o_desc; i++) {
1050         const option_type *ot_ptr = &option_info[i];
1051         if (ot_ptr->o_var)
1052             exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
1053     }
1054
1055     fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1056     fputs("Set - Bit (Page) Option Name\n", fff);
1057     fputs("------------------------------------------------\n", fff);
1058     for (int i = 0; i < NUM_O_SET; i++) {
1059         for (int j = 0; j < NUM_O_BIT; j++) {
1060             if (exist[i][j]) {
1061                 const option_type *ot_ptr = &option_info[exist[i][j] - 1];
1062                 fprintf(fff, "  %d -  %02d (%4d) %s\n", i, j, ot_ptr->o_page, ot_ptr->o_text);
1063             } else {
1064                 fprintf(fff, "  %d -  %02d\n", i, j);
1065             }
1066         }
1067
1068         fputc('\n', fff);
1069     }
1070
1071     C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
1072     C_KILL(exist, NUM_O_SET, int *);
1073     angband_fclose(fff);
1074     msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), buf);
1075 }
1076
1077 /*!
1078  * @brief プレイ日数を変更する / Set gametime.
1079  * @return 実際に変更を行ったらTRUEを返す
1080  */
1081 static void set_gametime(void)
1082 {
1083     int tmp_int = 0;
1084     char ppp[80], tmp_val[40];
1085
1086     sprintf(ppp, "Dungeon Turn (0-%ld): ", (long)current_world_ptr->dungeon_turn_limit);
1087     sprintf(tmp_val, "%ld", (long)current_world_ptr->dungeon_turn);
1088     if (!get_string(ppp, tmp_val, 10))
1089         return;
1090
1091     tmp_int = atoi(tmp_val);
1092
1093     /* Verify */
1094     if (tmp_int >= current_world_ptr->dungeon_turn_limit)
1095         tmp_int = current_world_ptr->dungeon_turn_limit - 1;
1096     else if (tmp_int < 0)
1097         tmp_int = 0;
1098     current_world_ptr->dungeon_turn = current_world_ptr->game_turn = tmp_int;
1099 }
1100
1101 /*!
1102  * @brief デバッグコマンドを選択する処理のメインルーチン /
1103  * Ask for and parse a "debug command"
1104  * The "command_arg" may have been set.
1105  * @param creature_ptr プレーヤーへの参照ポインタ
1106  * @return なし
1107  * @details
1108  * 番号を指定するには、それをN及びデバッグコマンドをXとしてとして「0N^aX」とする
1109  * a:全状態回復 / Cure all maladies
1110  * A:善悪の属性表示 / Know alignment
1111  * b:相手をテレポバック / Teleport to target
1112  * B:モンスター闘技場のモンスターを更新する / Update gambling monster
1113  * c:アイテム生成 / Create any object
1114  * C:指定番号の固定アーティファクトを生成する / Create a named artifact
1115  * d:全感知 / Detect everything
1116  * D:次元の扉 / Dimension_door
1117  * e:能力変更 / Edit character
1118  * E:全てのスペルをラーニング状態にする / Blue Mage Only
1119  * f:*鑑定* / Fully identification
1120  * F:地形ID変更 / Create desired feature
1121  * g:上質なアイテムを生成 / Good Objects
1122  * G:なし / Nothing
1123  * h:新生 / Hitpoint rerating
1124  * H:モンスターの群れ生成 / Generate monster group
1125  * i:鑑定 / Identification
1126  * I:なし / Nothing
1127  * j:ダンジョンの指定フロアへテレポート (ウィザードあり) / Jump to dungeon
1128  * J:なし / Nothing
1129  * k:自己分析 / Self info
1130  * K:なし / Nothing
1131  * l:番号指定したアイテムまで鑑定済にする / Learn about objects
1132  * L:なし / Nothing
1133  * m:魔法の地図 / Magic Mapping
1134  * M:突然変異 / Mutation / TODO: 指定した突然変異の除外機能を追加したい
1135  * n:番号指定したモンスターを生成 / Generate a monster
1136  * N:番号指定したペットを生成 / Generate a pet
1137  * o:アイテムのtval等を編集する / Edit object
1138  * O:現在のオプション設定をダンプ出力 / Output option settings
1139  * p:ショートテレポ / Blink
1140  * P:なし / Nothing
1141  * q:クエストを完了させる / Finish quest
1142  * Q:クエストに突入する (ウィザードあり) / Jump to quest
1143  * r:カオスパトロンから報酬を貰う / Gain reward from chaos patron
1144  * R:クラス変更 / Change class
1145  * s:フロア相応のモンスター召喚 / Summon a monster
1146  * S:高級品獲得ドロップ / Get a great item
1147  * t:テレポート / Teleport
1148  * T:プレイ日時変更 / Change time
1149  * u:啓蒙 (強制的に忍者以外) / Lite floor without ninja classified
1150  * U:なし / Nothing
1151  * v:特別品獲得ドロップ / Get a special item
1152  * V:クラス変更 / Change class / TODO: Rと同じなので何か変えたい
1153  * w:啓蒙 (忍者かどうか考慮) / Lite floor with ninja classified
1154  * W:なし / Nothing
1155  * x:経験値を得る / Gain experience
1156  * X:アイテムを初期状態に戻す / Return items to the initial ones
1157  * y:なし / Nothing
1158  * Y:なし / Nothing
1159  * z:近隣のモンスター消去 / Zap monsters around
1160  * Z:フロア中のモンスター消去 / Zap all monsters in the floor
1161  * @:特殊スペルの発動 / Special spell
1162  * ":スポイラーのダンプ / Dump spoiler
1163  * ?:ヘルプ表示 (通常の?と同じ) / Show help (same as normal help)
1164  */
1165 void do_cmd_debug(player_type *creature_ptr)
1166 {
1167     char cmd;
1168     get_com("Debug Command: ", &cmd, FALSE);
1169     switch (cmd) {
1170     case ESCAPE:
1171     case ' ':
1172     case '\n':
1173     case '\r':
1174         break;
1175     case 'a':
1176         do_cmd_wiz_cure_all(creature_ptr);
1177         break;
1178     case 'A':
1179         msg_format("Your alignment is %d.", creature_ptr->align);
1180         break;
1181     case 'b':
1182         do_cmd_wiz_bamf(creature_ptr);
1183         break;
1184     case 'B':
1185         update_gambling_monsters(creature_ptr);
1186         break;
1187     case 'c':
1188         wiz_create_item(creature_ptr);
1189         break;
1190     case 'C':
1191         wiz_create_named_art(creature_ptr);
1192         break;
1193     case 'd':
1194         detect_all(creature_ptr, DETECT_RAD_ALL * 3);
1195         break;
1196     case 'D':
1197         wiz_dimension_door(creature_ptr);
1198         break;
1199     case 'e':
1200         do_cmd_wiz_change(creature_ptr);
1201         break;
1202     case 'E':
1203         if (creature_ptr->pclass == CLASS_BLUE_MAGE) {
1204             do_cmd_wiz_blue_mage(creature_ptr);
1205         }
1206
1207         break;
1208     case 'f':
1209         identify_fully(creature_ptr, FALSE, 0);
1210         break;
1211     case 'F':
1212         do_cmd_wiz_create_feature(creature_ptr);
1213         break;
1214     case 'g':
1215         if (command_arg <= 0)
1216             command_arg = 1;
1217
1218         acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, FALSE, FALSE, TRUE);
1219         break;
1220     case 'h':
1221         roll_hitdice(creature_ptr, SPOP_DISPLAY_MES | SPOP_DEBUG);
1222         break;
1223     case 'H':
1224         do_cmd_summon_horde(creature_ptr);
1225         break;
1226     case 'i':
1227         (void)ident_spell(creature_ptr, FALSE, 0);
1228         break;
1229     case 'j':
1230         do_cmd_wiz_jump(creature_ptr);
1231         break;
1232     case 'k':
1233         self_knowledge(creature_ptr);
1234         break;
1235     case 'l':
1236         do_cmd_wiz_learn(creature_ptr);
1237         break;
1238     case 'm':
1239         map_area(creature_ptr, DETECT_RAD_ALL * 3);
1240         break;
1241     case 'M':
1242         (void)gain_mutation(creature_ptr, command_arg);
1243         break;
1244     case 'R':
1245         (void)do_cmd_wiz_reset_class(creature_ptr);
1246         break;
1247     case 'r':
1248         (void)gain_level_reward(creature_ptr, command_arg);
1249         break;
1250     case 'N':
1251         do_cmd_wiz_named_friendly(creature_ptr, command_arg);
1252         break;
1253     case 'n':
1254         do_cmd_wiz_named(creature_ptr, command_arg);
1255         break;
1256     case 'O':
1257         do_cmd_dump_options();
1258         break;
1259     case 'o':
1260         do_cmd_wiz_play(creature_ptr);
1261         break;
1262     case 'p':
1263         teleport_player(creature_ptr, 10, TELEPORT_SPONTANEOUS);
1264         break;
1265     case 'Q': {
1266         char ppp[30];
1267         char tmp_val[5];
1268         int tmp_int;
1269         sprintf(ppp, "QuestID (0-%d):", max_q_idx - 1);
1270         sprintf(tmp_val, "%d", 0);
1271
1272         if (!get_string(ppp, tmp_val, 3))
1273             return;
1274         tmp_int = atoi(tmp_val);
1275
1276         if (tmp_int < 0)
1277             break;
1278         if (tmp_int >= max_q_idx)
1279             break;
1280
1281         creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)tmp_int;
1282         parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
1283         quest[tmp_int].status = QUEST_STATUS_TAKEN;
1284         creature_ptr->current_floor_ptr->inside_quest = 0;
1285         break;
1286     }
1287     case 'q':
1288         if (creature_ptr->current_floor_ptr->inside_quest) {
1289             if (quest[creature_ptr->current_floor_ptr->inside_quest].status == QUEST_STATUS_TAKEN) {
1290                 complete_quest(creature_ptr, creature_ptr->current_floor_ptr->inside_quest);
1291                 break;
1292             }
1293         } else {
1294             msg_print("No current quest");
1295             msg_print(NULL);
1296         }
1297
1298         break;
1299     case 's':
1300         if (command_arg <= 0)
1301             command_arg = 1;
1302         do_cmd_wiz_summon(creature_ptr, command_arg);
1303         break;
1304     case 'S':
1305         if (command_arg <= 0)
1306             command_arg = 1;
1307
1308         acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, TRUE, TRUE);
1309         break;
1310     case 't':
1311         teleport_player(creature_ptr, 100, TELEPORT_SPONTANEOUS);
1312         break;
1313     case 'T':
1314         set_gametime();
1315         break;
1316     case 'u':
1317         for (int y = 0; y < creature_ptr->current_floor_ptr->height; y++) {
1318             for (int x = 0; x < creature_ptr->current_floor_ptr->width; x++) {
1319                 creature_ptr->current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1320             }
1321         }
1322
1323         wiz_lite(creature_ptr, FALSE);
1324         break;
1325     case 'v':
1326         if (command_arg <= 0)
1327             command_arg = 1;
1328         acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, FALSE, TRUE);
1329         break;
1330     case 'V':
1331         do_cmd_wiz_reset_class(creature_ptr);
1332         break;
1333     case 'w':
1334         wiz_lite(creature_ptr, (bool)(creature_ptr->pclass == CLASS_NINJA));
1335         break;
1336     case 'x':
1337         gain_exp(creature_ptr, command_arg ? command_arg : (creature_ptr->exp + 1));
1338         break;
1339     case 'X': {
1340         INVENTORY_IDX i;
1341         for (i = INVEN_TOTAL - 1; i >= 0; i--) {
1342             if (creature_ptr->inventory_list[i].k_idx)
1343                 drop_from_inventory(creature_ptr, i, 999);
1344         }
1345
1346         player_outfit(creature_ptr);
1347         break;
1348     }
1349     case 'z':
1350         do_cmd_wiz_zap(creature_ptr);
1351         break;
1352     case 'Z':
1353         do_cmd_wiz_zap_all(creature_ptr);
1354         break;
1355     case '_':
1356         probing(creature_ptr);
1357         break;
1358     case '@':
1359         do_cmd_debug_spell(creature_ptr);
1360         break;
1361     case '"':
1362         do_cmd_spoilers(creature_ptr);
1363         break;
1364     case '?':
1365         do_cmd_help(creature_ptr);
1366         break;
1367     default:
1368         msg_print("That is not a valid debug command.");
1369         break;
1370     }
1371 }