OSDN Git Service

Merge pull request #1124 from habu1010/feature/fix-item-combine-when-auto-inscription
[hengbandforosx/hengbandosx.git] / src / wizard / wizard-special-process.cpp
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 "birth/inventory-initializer.h"
15 #include "cmd-io/cmd-dump.h"
16 #include "cmd-io/cmd-help.h"
17 #include "cmd-io/cmd-save.h"
18 #include "cmd-visual/cmd-draw.h"
19 #include "core/asking-player.h"
20 #include "core/player-redraw-types.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/object-flavor.h"
27 #include "floor/floor-leaver.h"
28 #include "floor/floor-mode-changer.h"
29 #include "floor/floor-object.h"
30 #include "game-option/birth-options.h"
31 #include "game-option/option-types-table.h"
32 #include "game-option/play-record-options.h"
33 #include "game-option/special-options.h"
34 #include "grid/feature.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-requester.h"
41 #include "io/write-diary.h"
42 #include "market/arena.h"
43 #include "monster-floor/monster-remover.h"
44 #include "monster-floor/monster-summon.h"
45 #include "monster/monster-describer.h"
46 #include "monster/monster-description-types.h"
47 #include "monster/monster-info.h"
48 #include "monster/monster-status.h"
49 #include "monster/smart-learn-types.h"
50 #include "mutation/mutation-investor-remover.h"
51 #include "object-enchant/apply-magic.h"
52 #include "object-enchant/item-apply-magic.h"
53 #include "object-enchant/trc-types.h"
54 #include "object-enchant/trg-types.h"
55 #include "object/object-kind.h"
56 #include "perception/object-perception.h"
57 #include "player-info/self-info.h"
58 #include "player-status/player-energy.h"
59 #include "player/digestion-processor.h"
60 #include "player/patron.h"
61 #include "player/player-class.h"
62 #include "player/player-race.h"
63 #include "player/player-race-types.h"
64 #include "player/player-skill.h"
65 #include "player/player-status-table.h"
66 #include "player/player-status.h"
67 #include "player/race-info-table.h"
68 #include "spell-kind/spells-detection.h"
69 #include "spell-kind/spells-sight.h"
70 #include "spell-kind/spells-teleport.h"
71 #include "spell-kind/spells-world.h"
72 #include "spell/spells-object.h"
73 #include "spell/spells-status.h"
74 #include "spell/spells-summon.h"
75 #include "status/experience.h"
76 #include "system/angband-version.h"
77 #include "system/artifact-type-definition.h"
78 #include "system/floor-type-definition.h"
79 #include "system/monster-type-definition.h"
80 #include "system/player-type-definition.h"
81 #include "target/grid-selector.h"
82 #include "term/screen-processor.h"
83 #include "util/angband-files.h"
84 #include "util/bit-flags-calculator.h"
85 #include "util/int-char-converter.h"
86 #include "view/display-messages.h"
87 #include "wizard/tval-descriptions-table.h"
88 #include "wizard/wizard-spells.h"
89 #include "wizard/wizard-spoiler.h"
90 #include "world/world.h"
91 #define NUM_O_SET 8
92 #define NUM_O_BIT 32
93
94 /*!
95  * @brief プレイヤーを完全回復する /
96  * Cure everything instantly
97  */
98 void wiz_cure_all(player_type *creature_ptr)
99 {
100     (void)life_stream(creature_ptr, FALSE, FALSE);
101     (void)restore_mana(creature_ptr, TRUE);
102     (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
103 }
104
105 /*!
106  * @brief ベースアイテムのウィザード生成のために大項目IDと小項目IDを取得する /
107  * Specify tval and sval (type and subtype of object) originally
108  * @return ベースアイテムID
109  * @details
110  * by RAK, heavily modified by -Bernd-
111  * This function returns the k_idx of an object type, or zero if failed
112  * List up to 50 choices in three columns
113  */
114 KIND_OBJECT_IDX wiz_create_itemtype(void)
115 {
116     term_clear();
117     int num;
118     TERM_LEN col, row;
119     char ch;
120     for (num = 0; (num < 80) && tvals[num].tval; num++) {
121         row = 2 + (num % 20);
122         col = 20 * (num / 20);
123         ch = listsym[num];
124         prt(format("[%c] %s", ch, tvals[num].desc), row, col);
125     }
126
127     int max_num = num;
128     if (!get_com("Get what type of object? ", &ch, FALSE))
129         return 0;
130
131     for (num = 0; num < max_num; num++)
132         if (listsym[num] == ch)
133             break;
134
135     if ((num < 0) || (num >= max_num))
136         return 0;
137
138     tval_type tval = static_cast<tval_type>(tvals[num].tval);
139     concptr tval_desc = tvals[num].desc;
140     term_clear();
141     num = 0;
142     KIND_OBJECT_IDX choice[80];
143     char buf[160];
144     for (KIND_OBJECT_IDX i = 1; (num < 80) && (i < max_k_idx); i++) {
145         object_kind *k_ptr = &k_info[i];
146         if (k_ptr->tval != tval)
147             continue;
148
149         row = 2 + (num % 20);
150         col = 20 * (num / 20);
151         ch = listsym[num];
152         strcpy(buf, "                    ");
153         strip_name(buf, i);
154         prt(format("[%c] %s", ch, buf), row, col);
155         choice[num++] = i;
156     }
157
158     max_num = num;
159     if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE))
160         return 0;
161
162     for (num = 0; num < max_num; num++)
163         if (listsym[num] == ch)
164             break;
165
166     if ((num < 0) || (num >= max_num))
167         return 0;
168
169     return choice[num];
170 }
171
172 /*!
173  * @brief 任意のベースアイテム生成のメインルーチン /
174  * Wizard routine for creating objects          -RAK-
175  * @details
176  * Heavily modified to allow magification and artifactification  -Bernd-
177  *
178  * Note that wizards cannot create objects on top of other objects.
179  *
180  * Hack -- this routine always makes a "dungeon object", and applies
181  * magic to it, and attempts to decline cursed items.
182  */
183 void wiz_create_item(player_type *caster_ptr)
184 {
185     screen_save();
186     OBJECT_IDX k_idx = wiz_create_itemtype();
187     screen_load();
188     if (!k_idx)
189         return;
190
191     if (k_info[k_idx].gen_flags.has(TRG::INSTA_ART)) {
192         for (ARTIFACT_IDX i = 1; i < max_a_idx; i++) {
193             if ((a_info[i].tval != k_info[k_idx].tval) || (a_info[i].sval != k_info[k_idx].sval))
194                 continue;
195
196             (void)create_named_art(caster_ptr, i, caster_ptr->y, caster_ptr->x);
197             msg_print("Allocated(INSTA_ART).");
198             return;
199         }
200     }
201
202     object_type forge;
203     object_type *q_ptr;
204     q_ptr = &forge;
205     q_ptr->prep(caster_ptr, k_idx);
206     apply_magic_to_object(caster_ptr, q_ptr, caster_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
207     (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x);
208     msg_print("Allocated.");
209 }
210
211 /*!
212  * @brief 指定されたIDの固定アーティファクトを生成する / Create the artifact of the specified number
213  * @param caster_ptr プレーヤーへの参照ポインタ
214  */
215 void wiz_create_named_art(player_type *caster_ptr, ARTIFACT_IDX a_idx)
216 {
217     if (a_idx <= 0) {
218         char tmp[80] = "";
219         sprintf(tmp, "Artifact ID (1-%d): ", max_a_idx - 1);
220         char tmp_val[10] = "";
221         if (!get_string(tmp, tmp_val, 3))
222             return;
223     
224         a_idx = (ARTIFACT_IDX)atoi(tmp_val);
225     }
226
227     if (a_idx <= 0 || a_idx >= max_a_idx) {
228         msg_format(_("番号は1から%dの間で指定して下さい。", "ID must be between 1 to %d."), max_a_idx - 1);
229         return;
230     }
231
232     (void)create_named_art(caster_ptr, a_idx, caster_ptr->y, caster_ptr->x);
233     msg_print("Allocated.");
234 }
235
236 /*!
237  * @brief プレイヤーの現能力値を調整する / Change various "permanent" player variables.
238  * @param creature_ptr プレーヤーへの参照ポインタ
239  */
240 void wiz_change_status(player_type *creature_ptr)
241 {
242     int tmp_int;
243     char tmp_val[160];
244     char ppp[80];
245     for (int i = 0; i < A_MAX; i++) {
246         sprintf(ppp, "%s (3-%d): ", stat_names[i], creature_ptr->stat_max_max[i]);
247         sprintf(tmp_val, "%d", creature_ptr->stat_max[i]);
248         if (!get_string(ppp, tmp_val, 3))
249             return;
250
251         tmp_int = atoi(tmp_val);
252         if (tmp_int > creature_ptr->stat_max_max[i])
253             tmp_int = creature_ptr->stat_max_max[i];
254         else if (tmp_int < 3)
255             tmp_int = 3;
256
257         creature_ptr->stat_cur[i] = creature_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
258     }
259
260     sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
261     if (!get_string(_("熟練度: ", "Proficiency: "), tmp_val, 4))
262         return;
263
264     s16b tmp_s16b = (s16b)atoi(tmp_val);
265     if (tmp_s16b < WEAPON_EXP_UNSKILLED)
266         tmp_s16b = WEAPON_EXP_UNSKILLED;
267
268     if (tmp_s16b > WEAPON_EXP_MASTER)
269         tmp_s16b = WEAPON_EXP_MASTER;
270
271     for (int j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++) {
272         for (int i = 0; i < 64; i++) {
273             creature_ptr->weapon_exp[j][i] = tmp_s16b;
274             if (creature_ptr->weapon_exp[j][i] > s_info[creature_ptr->pclass].w_max[j][i])
275                 creature_ptr->weapon_exp[j][i] = s_info[creature_ptr->pclass].w_max[j][i];
276         }
277     }
278
279     for (int j = 0; j < 10; j++) {
280         creature_ptr->skill_exp[j] = tmp_s16b;
281         if (creature_ptr->skill_exp[j] > s_info[creature_ptr->pclass].s_max[j])
282             creature_ptr->skill_exp[j] = s_info[creature_ptr->pclass].s_max[j];
283     }
284
285     int k;
286     for (k = 0; k < 32; k++)
287         creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
288
289     for (; k < 64; k++)
290         creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
291
292     sprintf(tmp_val, "%ld", (long)(creature_ptr->au));
293     if (!get_string("Gold: ", tmp_val, 9))
294         return;
295
296     long tmp_long = atol(tmp_val);
297     if (tmp_long < 0)
298         tmp_long = 0L;
299
300     creature_ptr->au = tmp_long;
301     sprintf(tmp_val, "%ld", (long)(creature_ptr->max_exp));
302     if (!get_string("Experience: ", tmp_val, 9))
303         return;
304
305     tmp_long = atol(tmp_val);
306     if (tmp_long < 0)
307         tmp_long = 0L;
308
309     if (creature_ptr->prace == RACE_ANDROID)
310         return;
311
312     creature_ptr->max_exp = tmp_long;
313     creature_ptr->exp = tmp_long;
314     check_experience(creature_ptr);
315     do_cmd_redraw(creature_ptr);
316 }
317
318 /*!
319  * @brief 指定された地点の地形IDを変更する /
320  * Create desired feature
321  * @param creaturer_ptr プレーヤーへの参照ポインタ
322  */
323 void wiz_create_feature(player_type *creature_ptr)
324 {
325     POSITION y, x;
326     if (!tgt_pt(creature_ptr, &x, &y))
327         return;
328
329     grid_type *g_ptr;
330     g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
331     static int prev_feat = 0;
332     char tmp_val[160];
333     sprintf(tmp_val, "%d", prev_feat);
334
335     if (!get_string(_("地形: ", "Feature: "), tmp_val, 3))
336         return;
337
338     FEAT_IDX tmp_feat = (FEAT_IDX)atoi(tmp_val);
339     if (tmp_feat < 0)
340         tmp_feat = 0;
341     else if (tmp_feat >= max_f_idx)
342         tmp_feat = max_f_idx - 1;
343
344     static int prev_mimic = 0;
345     sprintf(tmp_val, "%d", prev_mimic);
346
347     if (!get_string(_("地形 (mimic): ", "Feature (mimic): "), tmp_val, 3))
348         return;
349
350     FEAT_IDX tmp_mimic = (FEAT_IDX)atoi(tmp_val);
351     if (tmp_mimic < 0)
352         tmp_mimic = 0;
353     else if (tmp_mimic >= max_f_idx)
354         tmp_mimic = max_f_idx - 1;
355
356     cave_set_feat(creature_ptr, y, x, tmp_feat);
357     g_ptr->mimic = (s16b)tmp_mimic;
358     feature_type *f_ptr;
359     f_ptr = &f_info[get_feat_mimic(g_ptr)];
360
361     if (has_flag(f_ptr->flags, FF_RUNE_PROTECTION) || has_flag(f_ptr->flags, FF_RUNE_EXPLOSION))
362         g_ptr->info |= CAVE_OBJECT;
363     else if (has_flag(f_ptr->flags, FF_MIRROR))
364         g_ptr->info |= CAVE_GLOW | CAVE_OBJECT;
365
366     note_spot(creature_ptr, y, x);
367     lite_spot(creature_ptr, y, x);
368     creature_ptr->update |= PU_FLOW;
369     prev_feat = tmp_feat;
370     prev_mimic = tmp_mimic;
371 }
372
373 /*
374  * @brief 選択したダンジョンの任意フロアを選択する
375  * @param creature_ptr プレーヤーへの参照ポインタ
376  * @param dungeon_type ダンジョン番号
377  * @return フロアを選択したらtrue、キャンセルならfalse
378  * @details 0を指定すると地上に飛ぶが、元いた場所にしか飛ばない
379  * @todo 可能ならダンジョンの入口 (例:ルルイエなら大洋の真ん中)へ飛べるようにしたい
380  */
381 static bool select_debugging_floor(player_type *creature_ptr, int dungeon_type)
382 {
383     auto max_depth = d_info[dungeon_type].maxdepth;
384     if ((max_depth == 0) || (dungeon_type > current_world_ptr->max_d_idx)) {
385         dungeon_type = DUNGEON_ANGBAND;
386     }
387
388     auto min_depth = (int)d_info[dungeon_type].mindepth;
389     while (true) {
390         char ppp[80];
391         char tmp_val[160];
392         sprintf(ppp, "Jump to level (0, %d-%d): ", min_depth, max_depth);
393         sprintf(tmp_val, "%d", (int)creature_ptr->current_floor_ptr->dun_level);
394         if (!get_string(ppp, tmp_val, 10)) {
395             return false;
396         }
397
398         auto tmp_command_arg = (COMMAND_ARG)atoi(tmp_val);
399         if (tmp_command_arg == 0) {
400             command_arg = tmp_command_arg;
401             break;
402         }
403
404         auto is_valid_floor = tmp_command_arg > 0;
405         is_valid_floor &= tmp_command_arg >= min_depth;
406         is_valid_floor &= tmp_command_arg <= max_depth;
407         if (is_valid_floor) {
408             command_arg = tmp_command_arg;
409             break;
410         }
411
412         msg_print("Invalid floor. Please re-input.");
413         continue;
414     }
415
416     creature_ptr->dungeon_idx = (DUNGEON_IDX)dungeon_type;
417     return true;
418 }
419
420 /*!
421  * @brief デバッグ帰還のダンジョンを選ぶ
422  * @param creature_ptr プレーヤーへの参照ポインタ
423  * @details 範囲外の値が選択されたら再入力を促す
424  */
425 static bool select_debugging_dungeon(player_type *creature_ptr, int *dungeon_type)
426 {
427     if (command_arg > 0) {
428         return true;    
429     }
430
431     while (true) {
432         char ppp[80];
433         char tmp_val[160];
434         sprintf(ppp, "Jump which dungeon : ");
435         sprintf(tmp_val, "%d", creature_ptr->dungeon_idx);
436         if (!get_string(ppp, tmp_val, 2)) {
437             return false;
438         }
439
440         *dungeon_type = atoi(tmp_val);
441         if ((*dungeon_type < DUNGEON_ANGBAND) || (*dungeon_type > DUNGEON_MAX)) {
442             msg_print("Invalid dungeon. Please re-input.");
443             continue;
444         }
445
446         return true;
447     }
448 }
449
450 /*!
451  * @brief 任意のダンジョン及び階層に飛ぶ /
452  * Go to any level
453  */
454 void wiz_jump_to_dungeon(player_type *creature_ptr)
455 {
456     int dungeon_type;
457     if (!select_debugging_dungeon(creature_ptr, &dungeon_type)) {
458         return;
459     }
460
461     if (!select_debugging_floor(creature_ptr, dungeon_type)) {
462         return;
463     }
464
465     if (command_arg < d_info[creature_ptr->dungeon_idx].mindepth)
466         command_arg = 0;
467
468     if (command_arg > d_info[creature_ptr->dungeon_idx].maxdepth)
469         command_arg = (COMMAND_ARG)d_info[creature_ptr->dungeon_idx].maxdepth;
470
471     msg_format("You jump to dungeon level %d.", command_arg);
472     if (autosave_l)
473         do_cmd_save_game(creature_ptr, TRUE);
474
475     creature_ptr->current_floor_ptr->dun_level = command_arg;
476     prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
477     if (!is_in_dungeon(creature_ptr))
478         creature_ptr->dungeon_idx = 0;
479
480     creature_ptr->current_floor_ptr->inside_arena = FALSE;
481     creature_ptr->wild_mode = FALSE;
482     leave_quest_check(creature_ptr);
483     if (record_stair)
484         exe_write_diary(creature_ptr, DIARY_WIZ_TELE, 0, NULL);
485
486     creature_ptr->current_floor_ptr->inside_quest = 0;
487     PlayerEnergy(creature_ptr).reset_player_turn();
488     creature_ptr->energy_need = 0;
489     prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
490     creature_ptr->leaving = TRUE;
491 }
492
493 /*!
494  * @brief 全ベースアイテムを鑑定済みにする /
495  * Become aware of a lot of objects
496  * @param caster_ptr プレーヤーへの参照ポインタ
497  */
498 void wiz_learn_items_all(player_type *caster_ptr)
499 {
500     object_type forge;
501     object_type *q_ptr;
502     for (KIND_OBJECT_IDX i = 1; i < max_k_idx; i++) {
503         object_kind *k_ptr = &k_info[i];
504         if (k_ptr->level <= command_arg) {
505             q_ptr = &forge;
506             q_ptr->prep(caster_ptr, i);
507             object_aware(caster_ptr, q_ptr);
508         }
509     }
510 }
511
512 /*!
513  * @brief プレイヤーの種族を変更する
514  */
515 void wiz_reset_race(player_type *creature_ptr)
516 {
517     char ppp[80];
518     sprintf(ppp, "Race (0-%d): ", MAX_RACES - 1);
519
520     char tmp_val[160];
521     sprintf(tmp_val, "%d", creature_ptr->prace);
522
523     if (!get_string(ppp, tmp_val, 2))
524         return;
525
526     int tmp_int = atoi(tmp_val);
527     if (tmp_int < 0 || tmp_int >= MAX_RACES)
528         return;
529
530     creature_ptr->prace = static_cast<player_race_type>(tmp_int);
531     rp_ptr = &race_info[creature_ptr->prace];
532
533     creature_ptr->window_flags |= PW_PLAYER;
534     creature_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
535     creature_ptr->redraw |= PR_BASIC | PR_HP | PR_MANA | PR_STATS;
536     handle_stuff(creature_ptr);
537 }
538
539 /*!
540  * @brief プレイヤーの職業を変更する
541  * @todo 魔法領域の再選択などがまだ不完全、要実装。
542  */
543 void wiz_reset_class(player_type *creature_ptr)
544 {
545     char ppp[80];
546     sprintf(ppp, "Class (0-%d): ", MAX_CLASS - 1);
547
548     char tmp_val[160];
549     sprintf(tmp_val, "%d", creature_ptr->pclass);
550
551     if (!get_string(ppp, tmp_val, 2))
552         return;
553
554     int tmp_int = atoi(tmp_val);
555     if (tmp_int < 0 || tmp_int >= MAX_CLASS)
556         return;
557
558     creature_ptr->pclass = static_cast<player_class_type>(tmp_int);
559     cp_ptr = &class_info[creature_ptr->pclass];
560     mp_ptr = &m_info[creature_ptr->pclass];
561     creature_ptr->window_flags |= PW_PLAYER;
562     creature_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
563     creature_ptr->redraw |= PR_BASIC | PR_HP | PR_MANA | PR_STATS;
564     handle_stuff(creature_ptr);
565 }
566
567 /*!
568  * @brief プレイヤーの領域を変更する
569  * @todo 存在有無などは未判定。そのうちすべき。
570  */
571 void wiz_reset_realms(player_type *creature_ptr)
572 {
573     char ppp[80];
574     char tmp_val[160];
575
576     sprintf(ppp, "1st Realm (None=0, 1-%d): ", MAX_REALM - 1);
577     sprintf(tmp_val, "%d", creature_ptr->realm1);
578     if (!get_string(ppp, tmp_val, 2))
579         return;
580
581     creature_ptr->realm1 = static_cast<REALM_IDX>(atoi(tmp_val));
582
583     sprintf(ppp, "2st Realm (None=0, 1-%d): ", MAX_REALM - 1);
584     sprintf(tmp_val, "%d", creature_ptr->realm2);
585     if (!get_string(ppp, tmp_val, 2))
586         return;
587
588     creature_ptr->realm2 = static_cast<REALM_IDX>(atoi(tmp_val));
589     creature_ptr->window_flags |= PW_PLAYER;
590     creature_ptr->update |= PU_BONUS | PU_HP | PU_MANA | PU_SPELLS;
591     creature_ptr->redraw |= PR_BASIC;
592     handle_stuff(creature_ptr);
593 }
594
595 /*!
596  * @brief 現在のオプション設定をダンプ出力する /
597  * @param creature_ptr プレーヤーへの参照ポインタ
598  * Hack -- Dump option bits usage
599  */
600 void wiz_dump_options(void)
601 {
602     char buf[1024];
603     path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "opt_info.txt");
604     FILE *fff;
605     fff = angband_fopen(buf, "a");
606     if (fff == NULL) {
607         msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
608         msg_print(NULL);
609         return;
610     }
611
612     int **exist;
613     C_MAKE(exist, NUM_O_SET, int *);
614     C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
615     for (int i = 1; i < NUM_O_SET; i++)
616         exist[i] = *exist + i * NUM_O_BIT;
617
618     for (int i = 0; option_info[i].o_desc; i++) {
619         const option_type *ot_ptr = &option_info[i];
620         if (ot_ptr->o_var)
621             exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
622     }
623
624     char title[200];
625     put_version(title);
626     fprintf(fff, "[Option bits usage on %s\n]", title);
627     fputs("Set - Bit (Page) Option Name\n", fff);
628     fputs("------------------------------------------------\n", fff);
629     for (int i = 0; i < NUM_O_SET; i++) {
630         for (int j = 0; j < NUM_O_BIT; j++) {
631             if (exist[i][j]) {
632                 const option_type *ot_ptr = &option_info[exist[i][j] - 1];
633                 fprintf(fff, "  %d -  %02d (%4d) %s\n", i, j, ot_ptr->o_page, ot_ptr->o_text);
634             } else {
635                 fprintf(fff, "  %d -  %02d\n", i, j);
636             }
637         }
638
639         fputc('\n', fff);
640     }
641
642     C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
643     C_KILL(exist, NUM_O_SET, int *);
644     angband_fclose(fff);
645     msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), buf);
646 }
647
648 /*!
649  * @brief プレイ日数を変更する / Set gametime.
650  * @return 実際に変更を行ったらTRUEを返す
651  */
652 void set_gametime(void)
653 {
654     int tmp_int = 0;
655     char ppp[80], tmp_val[40];
656     sprintf(ppp, "Dungeon Turn (0-%ld): ", (long)current_world_ptr->dungeon_turn_limit);
657     sprintf(tmp_val, "%ld", (long)current_world_ptr->dungeon_turn);
658     if (!get_string(ppp, tmp_val, 10))
659         return;
660
661     tmp_int = atoi(tmp_val);
662     if (tmp_int >= current_world_ptr->dungeon_turn_limit)
663         tmp_int = current_world_ptr->dungeon_turn_limit - 1;
664     else if (tmp_int < 0)
665         tmp_int = 0;
666
667     current_world_ptr->dungeon_turn = current_world_ptr->game_turn = tmp_int;
668 }
669
670 /*!
671  * @brief プレイヤー近辺の全モンスターを消去する / Delete all nearby monsters
672  */
673 void wiz_zap_surrounding_monsters(player_type *caster_ptr)
674 {
675     for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
676         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
677         if (!monster_is_valid(m_ptr) || (i == caster_ptr->riding) || (m_ptr->cdis > MAX_SIGHT))
678             continue;
679
680         if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
681             GAME_TEXT m_name[MAX_NLEN];
682
683             monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
684             exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
685         }
686
687         delete_monster_idx(caster_ptr, i);
688     }
689 }
690
691 /*!
692  * @brief フロアに存在する全モンスターを消去する / Delete all monsters
693  * @param caster_ptr 術者の参照ポインタ
694  */
695 void wiz_zap_floor_monsters(player_type *caster_ptr)
696 {
697     for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
698         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
699         if (!monster_is_valid(m_ptr) || (i == caster_ptr->riding))
700             continue;
701
702         if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
703             GAME_TEXT m_name[MAX_NLEN];
704             monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
705             exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
706         }
707
708         delete_monster_idx(caster_ptr, i);
709     }
710 }
711
712 void cheat_death(player_type *creature_ptr)
713 {
714     if (creature_ptr->sc)
715         creature_ptr->sc = creature_ptr->age = 0;
716     creature_ptr->age++;
717
718     current_world_ptr->noscore |= 0x0001;
719     msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
720     msg_print(NULL);
721
722     creature_ptr->is_dead = FALSE;
723     (void)life_stream(creature_ptr, FALSE, FALSE);
724     (void)restore_mana(creature_ptr, TRUE);
725     (void)recall_player(creature_ptr, 0);
726     reserve_alter_reality(creature_ptr, 0);
727
728     (void)strcpy(creature_ptr->died_from, _("死の欺き", "Cheating death"));
729     (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
730
731     floor_type *floor_ptr = creature_ptr->current_floor_ptr;
732     floor_ptr->dun_level = 0;
733     floor_ptr->inside_arena = FALSE;
734     creature_ptr->phase_out = FALSE;
735     leaving_quest = 0;
736     floor_ptr->inside_quest = 0;
737     if (creature_ptr->dungeon_idx)
738         creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
739     creature_ptr->dungeon_idx = 0;
740     if (lite_town || vanilla_town) {
741         creature_ptr->wilderness_y = 1;
742         creature_ptr->wilderness_x = 1;
743         if (vanilla_town) {
744             creature_ptr->oldpy = 10;
745             creature_ptr->oldpx = 34;
746         } else {
747             creature_ptr->oldpy = 33;
748             creature_ptr->oldpx = 131;
749         }
750     } else {
751         creature_ptr->wilderness_y = 48;
752         creature_ptr->wilderness_x = 5;
753         creature_ptr->oldpy = 33;
754         creature_ptr->oldpx = 131;
755     }
756
757     creature_ptr->wild_mode = FALSE;
758     creature_ptr->leaving = TRUE;
759
760     exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, _("                            しかし、生き返った。", "                            but revived."));
761     leave_floor(creature_ptr);
762 }