OSDN Git Service

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