OSDN Git Service

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