OSDN Git Service

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