OSDN Git Service

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