OSDN Git Service

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