2 * @brief ウィザードモードの処理(特別処理中心) / Wizard commands
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>
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/player-update-types.h"
20 #include "core/stuff-handler.h"
21 #include "core/window-redrawer.h"
22 #include "dungeon/dungeon.h"
23 #include "dungeon/quest.h"
24 #include "flavor/flavor-describer.h"
25 #include "flavor/object-flavor-types.h"
26 #include "flavor/object-flavor.h"
27 #include "floor/floor-object.h"
28 #include "floor/floor-save.h"
29 #include "floor/floor.h"
30 #include "game-option/option-types-table.h"
31 #include "game-option/play-record-options.h"
32 #include "game-option/special-options.h"
33 #include "grid/grid.h"
34 #include "info-reader/fixed-map-parser.h"
35 #include "inventory/inventory-object.h"
36 #include "inventory/inventory-slot-types.h"
37 #include "io/files-util.h"
38 #include "io/input-key-acceptor.h"
39 #include "io/input-key-requester.h"
40 #include "io/targeting.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.h"
51 #include "object-enchant/apply-magic.h"
52 #include "object-enchant/artifact.h"
53 #include "object-enchant/item-apply-magic.h"
54 #include "object-enchant/trc-types.h"
55 #include "object-enchant/trg-types.h"
56 #include "object-hook/hook-enchant.h"
57 #include "object/item-use-flags.h"
58 #include "object/object-flags.h"
59 #include "object/object-generator.h"
60 #include "object/object-kind.h"
61 #include "object/object-value.h"
62 #include "perception/object-perception.h"
63 #include "player/digestion-processor.h"
64 #include "player/patron.h"
65 #include "player/player-class.h"
66 #include "player/player-race-types.h"
67 #include "player/player-skill.h"
68 #include "player/player-status.h"
69 #include "player/selfinfo.h"
70 #include "spell-kind/spells-detection.h"
71 #include "spell-kind/spells-floor.h"
72 #include "spell-kind/spells-perception.h"
73 #include "spell-kind/spells-sight.h"
74 #include "spell-kind/spells-teleport.h"
75 #include "spell/spells-object.h"
76 #include "spell/spells-status.h"
77 #include "spell/spells-summon.h"
78 #include "status/experience.h"
79 #include "system/alloc-entries.h"
80 #include "system/angband-version.h"
81 #include "term/screen-processor.h"
82 #include "term/term-color-types.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"
92 #define K_MAX_DEPTH 110 /*!< アイテムの階層毎生成率を表示する最大階 */
98 * @brief 指定されたIDの固定アーティファクトを生成する / Create the artifact of the specified number
99 * @param caster_ptr プレーヤーへの参照ポインタ
102 static void wiz_create_named_art(player_type *caster_ptr)
104 char tmp_val[10] = "";
105 if (!get_string("Artifact ID:", tmp_val, 3))
108 ARTIFACT_IDX a_idx = (ARTIFACT_IDX)atoi(tmp_val);
109 if ((a_idx < 0) || (a_idx >= max_a_idx))
112 (void)create_named_art(caster_ptr, a_idx, caster_ptr->y, caster_ptr->x);
113 msg_print("Allocated.");
117 * @brief 32ビット変数のビット配列を並べて描画する / Output a long int in binary format.
120 static void prt_binary(BIT_FLAGS flags, int row, int col)
123 for (int i = bitmask = 1; i <= 32; i++, bitmask *= 2) {
124 if (flags & bitmask) {
125 Term_putch(col++, row, TERM_BLUE, '*');
127 Term_putch(col++, row, TERM_WHITE, '-');
133 * @brief アイテムの階層毎生成率を表示する / Output a rarity graph for a type of object.
134 * @param tval ベースアイテムの大項目ID
135 * @param sval ベースアイテムの小項目ID
140 static void prt_alloc(tval_type tval, OBJECT_SUBTYPE_VALUE sval, TERM_LEN row, TERM_LEN col)
142 u32b rarity[K_MAX_DEPTH];
143 (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
144 u32b total[K_MAX_DEPTH];
145 (void)C_WIPE(total, K_MAX_DEPTH, u32b);
147 (void)C_WIPE(display, 22, s32b);
150 for (int i = 0; i < K_MAX_DEPTH; i++) {
153 alloc_entry *table = alloc_kind_table;
154 for (int j = 0; j < alloc_kind_size; j++) {
157 if (table[j].level <= i) {
158 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
159 } else if (table[j].level - 1 > 0) {
160 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
163 k_ptr = &k_info[table[j].index];
165 total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
166 total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
168 if ((k_ptr->tval == tval) && (k_ptr->sval == sval)) {
170 rarity[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
174 total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
177 for (int i = 0; i < 22; i++) {
179 for (int j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
180 possibility += rarity[j] * 100000 / total[j];
182 display[i] = possibility / 5;
185 for (int i = 0; i < 22; i++) {
186 Term_putch(col, row + i + 1, TERM_WHITE, '|');
187 prt(format("%2dF", (i * 5)), row + i + 1, col);
188 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
189 c_prt(TERM_RED, format("%3d.%04d%%", display[i] / 1000, display[i] % 1000), row + i + 1, col + 3);
191 c_prt(TERM_WHITE, format("%3d.%04d%%", display[i] / 1000, display[i] % 1000), row + i + 1, col + 3);
194 concptr r = "+---Rate---+";
199 * @brief プレイヤーの職業を変更する
201 * @todo 魔法領域の再選択などがまだ不完全、要実装。
203 static void do_cmd_wiz_reset_class(player_type *creature_ptr)
206 sprintf(ppp, "Class (0-%d): ", MAX_CLASS - 1);
209 sprintf(tmp_val, "%d", creature_ptr->pclass);
211 if (!get_string(ppp, tmp_val, 2))
214 int tmp_int = atoi(tmp_val);
215 if (tmp_int < 0 || tmp_int >= MAX_CLASS)
218 creature_ptr->pclass = (byte)tmp_int;
219 creature_ptr->window |= (PW_PLAYER);
220 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
221 handle_stuff(creature_ptr);
225 * @brief プレイヤーの現能力値を調整する
226 * Aux function for "do_cmd_wiz_change()". -RAK-
229 static void do_cmd_wiz_change_aux(player_type *creature_ptr)
237 for (int i = 0; i < A_MAX; i++) {
238 sprintf(ppp, "%s (3-%d): ", stat_names[i], creature_ptr->stat_max_max[i]);
239 sprintf(tmp_val, "%d", creature_ptr->stat_max[i]);
240 if (!get_string(ppp, tmp_val, 3))
243 tmp_int = atoi(tmp_val);
244 if (tmp_int > creature_ptr->stat_max_max[i])
245 tmp_int = creature_ptr->stat_max_max[i];
246 else if (tmp_int < 3)
249 creature_ptr->stat_cur[i] = creature_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
252 sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
253 if (!get_string(_("熟練度: ", "Proficiency: "), tmp_val, 9))
256 tmp_s16b = (s16b)atoi(tmp_val);
257 if (tmp_s16b < WEAPON_EXP_UNSKILLED)
258 tmp_s16b = WEAPON_EXP_UNSKILLED;
259 if (tmp_s16b > WEAPON_EXP_MASTER)
260 tmp_s16b = WEAPON_EXP_MASTER;
262 for (int j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++) {
263 for (int i = 0; i < 64; i++) {
264 creature_ptr->weapon_exp[j][i] = tmp_s16b;
265 if (creature_ptr->weapon_exp[j][i] > s_info[creature_ptr->pclass].w_max[j][i])
266 creature_ptr->weapon_exp[j][i] = s_info[creature_ptr->pclass].w_max[j][i];
270 for (int j = 0; j < 10; j++) {
271 creature_ptr->skill_exp[j] = tmp_s16b;
272 if (creature_ptr->skill_exp[j] > s_info[creature_ptr->pclass].s_max[j])
273 creature_ptr->skill_exp[j] = s_info[creature_ptr->pclass].s_max[j];
277 for (k = 0; k < 32; k++)
278 creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
281 creature_ptr->spell_exp[k] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
283 sprintf(tmp_val, "%ld", (long)(creature_ptr->au));
284 if (!get_string("Gold: ", tmp_val, 9))
287 tmp_long = atol(tmp_val);
291 creature_ptr->au = tmp_long;
292 sprintf(tmp_val, "%ld", (long)(creature_ptr->max_exp));
293 if (!get_string("Experience: ", tmp_val, 9))
296 tmp_long = atol(tmp_val);
300 if (creature_ptr->prace == RACE_ANDROID)
303 creature_ptr->max_exp = tmp_long;
304 creature_ptr->exp = tmp_long;
305 check_experience(creature_ptr);
309 * @brief プレイヤーの現能力値を調整する(メインルーチン)
310 * Change various "permanent" player variables.
313 static void do_cmd_wiz_change(player_type *creature_ptr)
315 do_cmd_wiz_change_aux(creature_ptr);
316 do_cmd_redraw(creature_ptr);
320 * @brief アイテムの詳細ステータスを表示する /
321 * Change various "permanent" player variables.
322 * @param player_ptr プレーヤーへの参照ポインタ
323 * @param o_ptr 詳細を表示するアイテム情報の参照ポインタ
326 static void wiz_display_item(player_type *player_ptr, object_type *o_ptr)
328 BIT_FLAGS flgs[TR_FLAG_SIZE];
329 object_flags(player_ptr, o_ptr, flgs);
332 for (int i = 1; i <= 23; i++)
335 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
337 describe_flavor(player_ptr, buf, o_ptr, OD_STORE);
339 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);
340 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);
341 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);
342 prt(format("name1 = %-4d name2 = %-4d cost = %ld", o_ptr->name1, o_ptr->name2, (long)object_value_real(player_ptr, o_ptr)), 7, j);
343 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d", o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
344 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);
346 prt("+------------FLAGS1------------+", 10, j);
347 prt("AFFECT........SLAY........BRAND.", 11, j);
348 prt(" mf cvae xsqpaefc", 12, j);
349 prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
350 prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
351 prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
352 prt_binary(flgs[0], 16, j);
354 prt("+------------FLAGS2------------+", 17, j);
355 prt("SUST....IMMUN.RESIST............", 18, j);
356 prt(" reaefctrpsaefcpfldbc sn ", 19, j);
357 prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
358 prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
359 prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
360 prt_binary(flgs[1], 23, j);
362 prt("+------------FLAGS3------------+", 10, j + 32);
363 prt("fe cnn t stdrmsiiii d ab ", 11, j + 32);
364 prt("aa aoomywhs lleeieihgggg rtgl ", 12, j + 32);
365 prt("uu utmacaih eielgggonnnnaaere ", 13, j + 32);
366 prt("rr reanurdo vtieeehtrrrrcilas ", 14, j + 32);
367 prt("aa algarnew ienpsntsaefctnevs ", 15, j + 32);
368 prt_binary(flgs[2], 16, j + 32);
370 prt("+------------FLAGS4------------+", 17, j + 32);
371 prt("KILL....ESP......... ", 18, j + 32);
372 prt("aeud tghaud tgdhegnu ", 19, j + 32);
373 prt("nvneoriunneoriruvoon ", 20, j + 32);
374 prt("iidmroamidmroagmionq ", 21, j + 32);
375 prt("mlenclnmmenclnnnldlu ", 22, j + 32);
376 prt_binary(flgs[3], 23, j + 32);
380 * @brief ベースアイテムのウィザード生成のために大項目IDと小項目IDを取得する /
381 * Specify tval and sval (type and subtype of object) originally
384 * by RAK, heavily modified by -Bernd-
385 * This function returns the k_idx of an object type, or zero if failed
386 * List up to 50 choices in three columns
388 static KIND_OBJECT_IDX wiz_create_itemtype(void)
394 KIND_OBJECT_IDX choice[80];
398 for (num = 0; (num < 80) && tvals[num].tval; num++) {
399 row = 2 + (num % 20);
400 col = 20 * (num / 20);
402 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
406 if (!get_com("Get what type of object? ", &ch, FALSE))
409 for (num = 0; num < max_num; num++) {
410 if (listsym[num] == ch)
414 if ((num < 0) || (num >= max_num))
417 tval_type tval = tvals[num].tval;
418 concptr tval_desc = tvals[num].desc;
420 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++) {
421 object_kind *k_ptr = &k_info[i];
422 if (k_ptr->tval != tval)
425 row = 2 + (num % 20);
426 col = 20 * (num / 20);
430 prt(format("[%c] %s", ch, buf), row, col);
435 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE))
438 for (num = 0; num < max_num; num++)
439 if (listsym[num] == ch)
442 if ((num < 0) || (num >= max_num))
449 * @briefアイテムの基礎能力値を調整する / Tweak an item
450 * @param player_ptr プレーヤーへの参照ポインタ
451 * @param o_ptr 調整するアイテムの参照ポインタ
454 static void wiz_tweak_item(player_type *player_ptr, object_type *o_ptr)
456 if (object_is_artifact(o_ptr))
459 concptr p = "Enter new 'pval' setting: ";
461 sprintf(tmp_val, "%d", o_ptr->pval);
462 if (!get_string(p, tmp_val, 5))
464 o_ptr->pval = (s16b)atoi(tmp_val);
465 wiz_display_item(player_ptr, o_ptr);
467 p = "Enter new 'to_a' setting: ";
468 sprintf(tmp_val, "%d", o_ptr->to_a);
469 if (!get_string(p, tmp_val, 5))
471 o_ptr->to_a = (s16b)atoi(tmp_val);
472 wiz_display_item(player_ptr, o_ptr);
474 p = "Enter new 'to_h' setting: ";
475 sprintf(tmp_val, "%d", o_ptr->to_h);
476 if (!get_string(p, tmp_val, 5))
478 o_ptr->to_h = (s16b)atoi(tmp_val);
479 wiz_display_item(player_ptr, o_ptr);
481 p = "Enter new 'to_d' setting: ";
482 sprintf(tmp_val, "%d", (int)o_ptr->to_d);
483 if (!get_string(p, tmp_val, 5))
485 o_ptr->to_d = (s16b)atoi(tmp_val);
486 wiz_display_item(player_ptr, o_ptr);
490 * @brief アイテムの質を選択して再生成する /
491 * Apply magic to an item or turn it into an artifact. -Bernd-
492 * @param o_ptr 再生成の対象となるアイテム情報の参照ポインタ
495 static void wiz_reroll_item(player_type *owner_ptr, object_type *o_ptr)
497 if (object_is_artifact(o_ptr))
503 object_copy(q_ptr, o_ptr);
506 bool changed = FALSE;
508 wiz_display_item(owner_ptr, q_ptr);
509 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE)) {
510 if (object_is_fixed_artifact(q_ptr)) {
511 a_info[q_ptr->name1].cur_num = 0;
519 if (ch == 'A' || ch == 'a') {
524 if (object_is_fixed_artifact(q_ptr)) {
525 a_info[q_ptr->name1].cur_num = 0;
530 /* Apply bad magic, but first clear object */
533 object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
534 apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
537 /* Apply bad magic, but first clear object */
540 object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
541 apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
544 /* Apply normal magic, but first clear object */
547 object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
548 apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
551 /* Apply good magic, but first clear object */
554 object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
555 apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD);
558 /* Apply great magic, but first clear object */
561 object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
562 apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
565 /* Apply special magic, but first clear object */
568 object_prep(owner_ptr, q_ptr, o_ptr->k_idx);
569 apply_magic(owner_ptr, q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
571 if (!object_is_artifact(q_ptr))
572 become_random_artifact(owner_ptr, q_ptr, FALSE);
578 q_ptr->iy = o_ptr->iy;
579 q_ptr->ix = o_ptr->ix;
580 q_ptr->next_o_idx = o_ptr->next_o_idx;
581 q_ptr->marked = o_ptr->marked;
585 object_copy(o_ptr, q_ptr);
586 owner_ptr->update |= (PU_BONUS);
587 owner_ptr->update |= (PU_COMBINE | PU_REORDER);
588 owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
593 * @brief 検査対象のアイテムを基準とした生成テストを行う /
594 * Try to create an item again. Output some statistics. -Bernd-
595 * @param caster_ptr プレーヤーへの参照ポインタ
596 * @param o_ptr 生成テストの基準となるアイテム情報の参照ポインタ
598 * The statistics are correct now. We acquire a clean grid, and then
599 * repeatedly place an object in this grid, copying it into an item
600 * holder, and then deleting the object. We fiddle with the artifact
601 * counter flags to prevent weirdness. We use the items to collect
602 * statistics on item creation relative to the initial item.
604 static void wiz_statistics(player_type *caster_ptr, object_type *o_ptr)
609 concptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
610 concptr p = "Enter number of items to roll: ";
613 if (object_is_fixed_artifact(o_ptr))
614 a_info[o_ptr->name1].cur_num = 0;
616 u32b i, matches, better, worse, other, correct;
617 u32b test_roll = 1000000;
622 concptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
623 wiz_display_item(caster_ptr, o_ptr);
624 if (!get_com(pmt, &ch, FALSE))
627 if (ch == 'n' || ch == 'N') {
630 } else if (ch == 'g' || ch == 'G') {
633 } else if (ch == 'e' || ch == 'E') {
634 mode = AM_GOOD | AM_GREAT;
635 quality = "excellent";
640 sprintf(tmp_val, "%ld", (long int)test_roll);
641 if (get_string(p, tmp_val, 10))
642 test_roll = atol(tmp_val);
643 test_roll = MAX(1, test_roll);
644 msg_format("Creating a lot of %s items. Base level = %d.", quality, caster_ptr->current_floor_ptr->dun_level);
647 correct = matches = better = worse = other = 0;
648 for (i = 0; i <= test_roll; i++) {
649 if ((i < 100) || (i % 100 == 0)) {
653 break; // stop rolling
656 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
662 make_object(caster_ptr, q_ptr, mode);
663 if (object_is_fixed_artifact(q_ptr))
664 a_info[q_ptr->name1].cur_num = 0;
666 if ((o_ptr->tval != q_ptr->tval) || (o_ptr->sval != q_ptr->sval))
670 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)
671 && (q_ptr->name1 == o_ptr->name1)) {
673 } 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)) {
675 } 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)) {
682 msg_format(q, i, correct, matches, better, worse, other);
686 if (object_is_fixed_artifact(o_ptr))
687 a_info[o_ptr->name1].cur_num = 1;
691 * @brief 検査対象のアイテムの数を変更する /
692 * Change the quantity of a the item
693 * @param caster_ptr プレーヤーへの参照ポインタ
694 * @param o_ptr 変更するアイテム情報構造体の参照ポインタ
697 static void wiz_quantity_item(object_type *o_ptr)
699 if (object_is_artifact(o_ptr))
702 int tmp_qnt = o_ptr->number;
704 sprintf(tmp_val, "%d", (int)o_ptr->number);
705 if (get_string("Quantity: ", tmp_val, 2)) {
706 int tmp_int = atoi(tmp_val);
713 o_ptr->number = (byte)tmp_int;
716 if (o_ptr->tval == TV_ROD)
717 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
721 * @brief アイテム検査のメインルーチン /
722 * Play with an item. Options include:
725 * - Output statistics (via wiz_roll_item)<br>
726 * - Reroll item (via wiz_reroll_item)<br>
727 * - Change properties (via wiz_tweak_item)<br>
728 * - Change the number of items (via wiz_quantity_item)<br>
730 static void do_cmd_wiz_play(player_type *creature_ptr)
732 concptr q = "Play with which object? ";
733 concptr s = "You have nothing to play with.";
737 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
741 screen_save(creature_ptr);
746 object_copy(q_ptr, o_ptr);
748 bool changed = FALSE;
750 wiz_display_item(creature_ptr, q_ptr);
751 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE)) {
756 if (ch == 'A' || ch == 'a') {
761 if (ch == 's' || ch == 'S') {
762 wiz_statistics(creature_ptr, q_ptr);
765 if (ch == 'r' || ch == 'R') {
766 wiz_reroll_item(creature_ptr, q_ptr);
769 if (ch == 't' || ch == 'T') {
770 wiz_tweak_item(creature_ptr, q_ptr);
773 if (ch == 'q' || ch == 'Q') {
774 wiz_quantity_item(q_ptr);
778 screen_load(creature_ptr);
780 msg_print("Changes accepted.");
782 creature_ptr->total_weight += (q_ptr->weight * q_ptr->number) - (o_ptr->weight * o_ptr->number);
785 object_copy(o_ptr, q_ptr);
786 creature_ptr->update |= (PU_BONUS);
787 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
788 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
790 msg_print("Changes ignored.");
795 * @brief 任意のベースアイテム生成のメインルーチン /
796 * Wizard routine for creating objects -RAK-
799 * Heavily modified to allow magification and artifactification -Bernd-
801 * Note that wizards cannot create objects on top of other objects.
803 * Hack -- this routine always makes a "dungeon object", and applies
804 * magic to it, and attempts to decline cursed items.
806 static void wiz_create_item(player_type *caster_ptr)
808 screen_save(caster_ptr);
809 OBJECT_IDX k_idx = wiz_create_itemtype();
810 screen_load(caster_ptr);
814 if (k_info[k_idx].gen_flags & TRG_INSTA_ART) {
815 for (ARTIFACT_IDX i = 1; i < max_a_idx; i++) {
816 if ((a_info[i].tval != k_info[k_idx].tval) || (a_info[i].sval != k_info[k_idx].sval))
819 (void)create_named_art(caster_ptr, i, caster_ptr->y, caster_ptr->x);
820 msg_print("Allocated(INSTA_ART).");
828 object_prep(caster_ptr, q_ptr, k_idx);
829 apply_magic(caster_ptr, q_ptr, caster_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
830 (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x);
831 msg_print("Allocated.");
835 * @brief プレイヤーを完全回復する /
836 * Cure everything instantly
839 static void do_cmd_wiz_cure_all(player_type *creature_ptr)
841 (void)life_stream(creature_ptr, FALSE, FALSE);
842 (void)restore_mana(creature_ptr, TRUE);
843 (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
847 * @brief 任意のダンジョン及び階層に飛ぶ /
851 static void do_cmd_wiz_jump(player_type *creature_ptr)
853 if (command_arg <= 0) {
856 DUNGEON_IDX tmp_dungeon_type;
857 sprintf(ppp, "Jump which dungeon : ");
858 sprintf(tmp_val, "%d", creature_ptr->dungeon_idx);
859 if (!get_string(ppp, tmp_val, 2))
862 tmp_dungeon_type = (DUNGEON_IDX)atoi(tmp_val);
863 if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > current_world_ptr->max_d_idx))
864 tmp_dungeon_type = DUNGEON_ANGBAND;
866 sprintf(ppp, "Jump to level (0, %d-%d): ", (int)d_info[tmp_dungeon_type].mindepth, (int)d_info[tmp_dungeon_type].maxdepth);
867 sprintf(tmp_val, "%d", (int)creature_ptr->current_floor_ptr->dun_level);
868 if (!get_string(ppp, tmp_val, 10))
871 command_arg = (COMMAND_ARG)atoi(tmp_val);
872 creature_ptr->dungeon_idx = tmp_dungeon_type;
875 if (command_arg < d_info[creature_ptr->dungeon_idx].mindepth)
878 if (command_arg > d_info[creature_ptr->dungeon_idx].maxdepth)
879 command_arg = (COMMAND_ARG)d_info[creature_ptr->dungeon_idx].maxdepth;
881 msg_format("You jump to dungeon level %d.", command_arg);
883 do_cmd_save_game(creature_ptr, TRUE);
885 creature_ptr->current_floor_ptr->dun_level = command_arg;
886 prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
887 if (!creature_ptr->current_floor_ptr->dun_level)
888 creature_ptr->dungeon_idx = 0;
890 creature_ptr->current_floor_ptr->inside_arena = FALSE;
891 creature_ptr->wild_mode = FALSE;
892 leave_quest_check(creature_ptr);
894 exe_write_diary(creature_ptr, DIARY_WIZ_TELE, 0, NULL);
896 creature_ptr->current_floor_ptr->inside_quest = 0;
897 free_turn(creature_ptr);
898 creature_ptr->energy_need = 0;
899 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
900 creature_ptr->leaving = TRUE;
904 * @brief 全ベースアイテムを鑑定済みにする /
905 * Become aware of a lot of objects
906 * @param caster_ptr プレーヤーへの参照ポインタ
909 static void do_cmd_wiz_learn(player_type *caster_ptr)
913 for (KIND_OBJECT_IDX i = 1; i < max_k_idx; i++) {
914 object_kind *k_ptr = &k_info[i];
915 if (k_ptr->level <= command_arg) {
917 object_prep(caster_ptr, q_ptr, i);
918 object_aware(caster_ptr, q_ptr);
924 * @brief プレイヤー近辺の全モンスターを消去する /
925 * Hack -- Delete all nearby monsters
928 static void do_cmd_wiz_zap(player_type *caster_ptr)
930 for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
931 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
932 if (!monster_is_valid(m_ptr) || (i == caster_ptr->riding) || (m_ptr->cdis > MAX_SIGHT))
935 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
936 GAME_TEXT m_name[MAX_NLEN];
938 monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
939 exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
942 delete_monster_idx(caster_ptr, i);
947 * @brief フロアに存在する全モンスターを消去する /
948 * Hack -- Delete all monsters
949 * @param caster_ptr 術者の参照ポインタ
952 static void do_cmd_wiz_zap_all(player_type *caster_ptr)
954 for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
955 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
956 if (!monster_is_valid(m_ptr) || (i == caster_ptr->riding))
959 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
960 GAME_TEXT m_name[MAX_NLEN];
961 monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
962 exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
965 delete_monster_idx(caster_ptr, i);
970 * @brief 指定された地点の地形IDを変更する /
971 * Create desired feature
972 * @param creaturer_ptr プレーヤーへの参照ポインタ
975 static void do_cmd_wiz_create_feature(player_type *creature_ptr)
978 if (!tgt_pt(creature_ptr, &x, &y))
982 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
983 static int prev_feat = 0;
985 sprintf(tmp_val, "%d", prev_feat);
987 if (!get_string(_("地形: ", "Feature: "), tmp_val, 3))
990 FEAT_IDX tmp_feat = (FEAT_IDX)atoi(tmp_val);
993 else if (tmp_feat >= max_f_idx)
994 tmp_feat = max_f_idx - 1;
996 static int prev_mimic = 0;
997 sprintf(tmp_val, "%d", prev_mimic);
999 if (!get_string(_("地形 (mimic): ", "Feature (mimic): "), tmp_val, 3))
1002 FEAT_IDX tmp_mimic = (FEAT_IDX)atoi(tmp_val);
1005 else if (tmp_mimic >= max_f_idx)
1006 tmp_mimic = max_f_idx - 1;
1008 cave_set_feat(creature_ptr, y, x, tmp_feat);
1009 g_ptr->mimic = (s16b)tmp_mimic;
1010 feature_type *f_ptr;
1011 f_ptr = &f_info[get_feat_mimic(g_ptr)];
1013 if (have_flag(f_ptr->flags, FF_GLYPH) || have_flag(f_ptr->flags, FF_MINOR_GLYPH))
1014 g_ptr->info |= (CAVE_OBJECT);
1015 else if (have_flag(f_ptr->flags, FF_MIRROR))
1016 g_ptr->info |= (CAVE_GLOW | CAVE_OBJECT);
1018 note_spot(creature_ptr, y, x);
1019 lite_spot(creature_ptr, y, x);
1020 creature_ptr->update |= (PU_FLOW);
1021 prev_feat = tmp_feat;
1022 prev_mimic = tmp_mimic;
1026 * @brief 現在のオプション設定をダンプ出力する /
1027 * @param creature_ptr プレーヤーへの参照ポインタ
1028 * Hack -- Dump option bits usage
1031 static void do_cmd_dump_options()
1034 path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
1036 fff = angband_fopen(buf, "a");
1038 msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
1044 C_MAKE(exist, NUM_O_SET, int *);
1045 C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
1046 for (int i = 1; i < NUM_O_SET; i++)
1047 exist[i] = *exist + i * NUM_O_BIT;
1049 for (int i = 0; option_info[i].o_desc; i++) {
1050 const option_type *ot_ptr = &option_info[i];
1052 exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
1055 fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1056 fputs("Set - Bit (Page) Option Name\n", fff);
1057 fputs("------------------------------------------------\n", fff);
1058 for (int i = 0; i < NUM_O_SET; i++) {
1059 for (int j = 0; j < NUM_O_BIT; j++) {
1061 const option_type *ot_ptr = &option_info[exist[i][j] - 1];
1062 fprintf(fff, " %d - %02d (%4d) %s\n", i, j, ot_ptr->o_page, ot_ptr->o_text);
1064 fprintf(fff, " %d - %02d\n", i, j);
1071 C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
1072 C_KILL(exist, NUM_O_SET, int *);
1073 angband_fclose(fff);
1074 msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), buf);
1078 * @brief プレイ日数を変更する / Set gametime.
1079 * @return 実際に変更を行ったらTRUEを返す
1081 static void set_gametime(void)
1084 char ppp[80], tmp_val[40];
1086 sprintf(ppp, "Dungeon Turn (0-%ld): ", (long)current_world_ptr->dungeon_turn_limit);
1087 sprintf(tmp_val, "%ld", (long)current_world_ptr->dungeon_turn);
1088 if (!get_string(ppp, tmp_val, 10))
1091 tmp_int = atoi(tmp_val);
1094 if (tmp_int >= current_world_ptr->dungeon_turn_limit)
1095 tmp_int = current_world_ptr->dungeon_turn_limit - 1;
1096 else if (tmp_int < 0)
1098 current_world_ptr->dungeon_turn = current_world_ptr->game_turn = tmp_int;
1102 * @brief デバッグコマンドを選択する処理のメインルーチン /
1103 * Ask for and parse a "debug command"
1104 * The "command_arg" may have been set.
1105 * @param creature_ptr プレーヤーへの参照ポインタ
1108 * 番号を指定するには、それをN及びデバッグコマンドをXとしてとして「0N^aX」とする
1109 * a:全状態回復 / Cure all maladies
1110 * A:善悪の属性表示 / Know alignment
1111 * b:相手をテレポバック / Teleport to target
1112 * B:モンスター闘技場のモンスターを更新する / Update gambling monster
1113 * c:アイテム生成 / Create any object
1114 * C:指定番号の固定アーティファクトを生成する / Create a named artifact
1115 * d:全感知 / Detect everything
1116 * D:次元の扉 / Dimension_door
1117 * e:能力変更 / Edit character
1118 * E:全てのスペルをラーニング状態にする / Blue Mage Only
1119 * f:*鑑定* / Fully identification
1120 * F:地形ID変更 / Create desired feature
1121 * g:上質なアイテムを生成 / Good Objects
1123 * h:新生 / Hitpoint rerating
1124 * H:モンスターの群れ生成 / Generate monster group
1125 * i:鑑定 / Identification
1127 * j:ダンジョンの指定フロアへテレポート (ウィザードあり) / Jump to dungeon
1129 * k:自己分析 / Self info
1131 * l:番号指定したアイテムまで鑑定済にする / Learn about objects
1133 * m:魔法の地図 / Magic Mapping
1134 * M:突然変異 / Mutation / TODO: 指定した突然変異の除外機能を追加したい
1135 * n:番号指定したモンスターを生成 / Generate a monster
1136 * N:番号指定したペットを生成 / Generate a pet
1137 * o:アイテムのtval等を編集する / Edit object
1138 * O:現在のオプション設定をダンプ出力 / Output option settings
1141 * q:クエストを完了させる / Finish quest
1142 * Q:クエストに突入する (ウィザードあり) / Jump to quest
1143 * r:カオスパトロンから報酬を貰う / Gain reward from chaos patron
1144 * R:クラス変更 / Change class
1145 * s:フロア相応のモンスター召喚 / Summon a monster
1146 * S:高級品獲得ドロップ / Get a great item
1147 * t:テレポート / Teleport
1148 * T:プレイ日時変更 / Change time
1149 * u:啓蒙 (強制的に忍者以外) / Lite floor without ninja classified
1151 * v:特別品獲得ドロップ / Get a special item
1152 * V:クラス変更 / Change class / TODO: Rと同じなので何か変えたい
1153 * w:啓蒙 (忍者かどうか考慮) / Lite floor with ninja classified
1155 * x:経験値を得る / Gain experience
1156 * X:アイテムを初期状態に戻す / Return items to the initial ones
1159 * z:近隣のモンスター消去 / Zap monsters around
1160 * Z:フロア中のモンスター消去 / Zap all monsters in the floor
1161 * @:特殊スペルの発動 / Special spell
1162 * ":スポイラーのダンプ / Dump spoiler
1163 * ?:ヘルプ表示 (通常の?と同じ) / Show help (same as normal help)
1165 void do_cmd_debug(player_type *creature_ptr)
1168 get_com("Debug Command: ", &cmd, FALSE);
1176 do_cmd_wiz_cure_all(creature_ptr);
1179 msg_format("Your alignment is %d.", creature_ptr->align);
1182 do_cmd_wiz_bamf(creature_ptr);
1185 update_gambling_monsters(creature_ptr);
1188 wiz_create_item(creature_ptr);
1191 wiz_create_named_art(creature_ptr);
1194 detect_all(creature_ptr, DETECT_RAD_ALL * 3);
1197 wiz_dimension_door(creature_ptr);
1200 do_cmd_wiz_change(creature_ptr);
1203 if (creature_ptr->pclass == CLASS_BLUE_MAGE) {
1204 do_cmd_wiz_blue_mage(creature_ptr);
1209 identify_fully(creature_ptr, FALSE, 0);
1212 do_cmd_wiz_create_feature(creature_ptr);
1215 if (command_arg <= 0)
1218 acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, FALSE, FALSE, TRUE);
1221 roll_hitdice(creature_ptr, SPOP_DISPLAY_MES | SPOP_DEBUG);
1224 do_cmd_summon_horde(creature_ptr);
1227 (void)ident_spell(creature_ptr, FALSE, 0);
1230 do_cmd_wiz_jump(creature_ptr);
1233 self_knowledge(creature_ptr);
1236 do_cmd_wiz_learn(creature_ptr);
1239 map_area(creature_ptr, DETECT_RAD_ALL * 3);
1242 (void)gain_mutation(creature_ptr, command_arg);
1245 (void)do_cmd_wiz_reset_class(creature_ptr);
1248 (void)gain_level_reward(creature_ptr, command_arg);
1251 do_cmd_wiz_named_friendly(creature_ptr, command_arg);
1254 do_cmd_wiz_named(creature_ptr, command_arg);
1257 do_cmd_dump_options();
1260 do_cmd_wiz_play(creature_ptr);
1263 teleport_player(creature_ptr, 10, TELEPORT_SPONTANEOUS);
1269 sprintf(ppp, "QuestID (0-%d):", max_q_idx - 1);
1270 sprintf(tmp_val, "%d", 0);
1272 if (!get_string(ppp, tmp_val, 3))
1274 tmp_int = atoi(tmp_val);
1278 if (tmp_int >= max_q_idx)
1281 creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)tmp_int;
1282 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
1283 quest[tmp_int].status = QUEST_STATUS_TAKEN;
1284 creature_ptr->current_floor_ptr->inside_quest = 0;
1288 if (creature_ptr->current_floor_ptr->inside_quest) {
1289 if (quest[creature_ptr->current_floor_ptr->inside_quest].status == QUEST_STATUS_TAKEN) {
1290 complete_quest(creature_ptr, creature_ptr->current_floor_ptr->inside_quest);
1294 msg_print("No current quest");
1300 if (command_arg <= 0)
1302 do_cmd_wiz_summon(creature_ptr, command_arg);
1305 if (command_arg <= 0)
1308 acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, TRUE, TRUE);
1311 teleport_player(creature_ptr, 100, TELEPORT_SPONTANEOUS);
1317 for (int y = 0; y < creature_ptr->current_floor_ptr->height; y++) {
1318 for (int x = 0; x < creature_ptr->current_floor_ptr->width; x++) {
1319 creature_ptr->current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1323 wiz_lite(creature_ptr, FALSE);
1326 if (command_arg <= 0)
1328 acquirement(creature_ptr, creature_ptr->y, creature_ptr->x, command_arg, TRUE, FALSE, TRUE);
1331 do_cmd_wiz_reset_class(creature_ptr);
1334 wiz_lite(creature_ptr, (bool)(creature_ptr->pclass == CLASS_NINJA));
1337 gain_exp(creature_ptr, command_arg ? command_arg : (creature_ptr->exp + 1));
1341 for (i = INVEN_TOTAL - 1; i >= 0; i--) {
1342 if (creature_ptr->inventory_list[i].k_idx)
1343 drop_from_inventory(creature_ptr, i, 999);
1346 player_outfit(creature_ptr);
1350 do_cmd_wiz_zap(creature_ptr);
1353 do_cmd_wiz_zap_all(creature_ptr);
1356 probing(creature_ptr);
1359 do_cmd_debug_spell(creature_ptr);
1362 do_cmd_spoilers(creature_ptr);
1365 do_cmd_help(creature_ptr);
1368 msg_print("That is not a valid debug command.");