4 * Copyright (c) 1997 Ben Harrison, and others
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.
11 /* Purpose: Wizard commands */
17 * Roll the hitdie -- aux of do_cmd_rerate()
19 void do_cmd_rerate_aux(void)
21 /* Minimum hitpoints at highest level */
22 int min_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 3 / 8;
24 /* Maximum hitpoints at highest level */
25 int max_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 5 / 8;
32 /* Pre-calculate level 1 hitdice */
33 p_ptr->player_hp[0] = p_ptr->hitdie;
35 for (i = 1; i < 4; i++)
37 p_ptr->player_hp[0] += randint1(p_ptr->hitdie);
40 /* Roll the hitpoint values */
41 for (i = 1; i < PY_MAX_LEVEL; i++)
43 p_ptr->player_hp[i] = p_ptr->player_hp[i - 1] + randint1(p_ptr->hitdie);
46 /* Require "valid" hitpoints at highest level */
47 if ((p_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
48 (p_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
54 * Hack -- Rerate Hitpoints
56 void do_cmd_rerate(bool display)
63 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
65 ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
68 /* Update and redraw hitpoints */
69 p_ptr->update |= (PU_HP);
70 p_ptr->redraw |= (PR_HP);
73 p_ptr->window |= (PW_PLAYER);
82 msg_format("¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯¤Ï %d/100 ¤Ç¤¹¡£", percent);
84 msg_format("Your life rate is %d/100 now.", percent);
86 p_ptr->knowledge |= KNOW_HPRATE;
91 msg_print("ÂÎÎÏ¥é¥ó¥¯¤¬ÊѤï¤Ã¤¿¡£");
93 msg_print("Life rate is changed.");
95 p_ptr->knowledge &= ~(KNOW_HPRATE);
105 static bool wiz_dimension_door(void)
109 if (!tgt_pt(&x, &y)) return FALSE;
111 if (!cave_empty_bold(y, x))
114 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
116 msg_print("You fail to exit the astral plane correctly!");
121 else teleport_player_to(y, x, FALSE);
128 * Create the artifact of the specified number -- DAN
131 static void wiz_create_named_art(int a_idx)
133 /* Create the artifact */
134 create_named_art(a_idx, py, px);
137 msg_print("Allocated.");
142 * Hack -- quick debugging hook
144 static void do_cmd_wiz_hack_ben(void)
153 #ifdef MONSTER_HORDES
155 /* Summon a horde of monsters */
156 static void do_cmd_summon_horde(void)
158 int wy = py, wx = px;
163 scatter(&wy, &wx, py, px, 3, 0);
164 if (cave_naked_bold(wy, wx)) break;
167 (void)alloc_horde(wy, wx);
170 #endif /* MONSTER_HORDES */
174 * Output a long int in binary format.
176 static void prt_binary(u32b flags, int row, int col)
182 for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
187 Term_putch(col++, row, TERM_BLUE, '*');
190 /* Dump unset bits */
193 Term_putch(col++, row, TERM_WHITE, '-');
199 #define K_MAX_DEPTH 110
202 * Output a rarity graph for a type of object.
204 static void prt_alloc(byte tval, byte sval, int row, int col)
208 u32b maxr = 1, maxt = 1, ratio;
209 u32b rarity[K_MAX_DEPTH];
210 u32b total[K_MAX_DEPTH];
211 s32b maxd = 1, display[22];
213 cptr r = "+--common--+";
218 alloc_entry *table = alloc_kind_table;
220 /* Wipe the tables */
221 (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
222 (void)C_WIPE(total, K_MAX_DEPTH, u32b);
223 (void)C_WIPE(display, 22, s32b);
225 /* Scan all entries */
226 for (i = 0; i < K_MAX_DEPTH; i++)
229 for (j = 0; j < alloc_kind_size; j++)
233 if (table[j].level <= i)
235 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
237 else if (table[j].level - 1 > 0)
239 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
242 /* Acquire this kind */
243 k_ptr = &k_info[table[j].index];
245 /* Accumulate probabilities */
246 total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
247 total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
249 /* Accumulate probabilities */
250 if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
256 total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
260 for (i = 0; i < K_MAX_DEPTH; i++)
262 if (rarity[i] > maxr) maxr = rarity[i];
263 if (total[i] > maxt) maxt = total[i];
266 if (maxr / (GREAT_OBJ * K_MAX_DEPTH) != 0)
267 ratio = maxt / (maxr / (GREAT_OBJ * K_MAX_DEPTH));
271 /* Simulate a log graph */
288 /* Calculate probabilities for each range */
289 for (i = 0; i < 22; i++)
291 /* Shift the values into view */
294 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
295 possibility += rarity[j] * (100 * maxt / total[j]);
297 possibility = possibility / maxr;
299 /* display[i] = log_{sqrt(2)}(possibility) */
304 possibility = possibility * 1000 / 1414;
308 if (display[i] > maxd) maxd = display[i];
312 if (maxd > 10) for (i = 0; i < 22; i++)
314 display[i] = display[i] - maxd + 10;
317 /* Graph the rarities */
318 for (i = 0; i < 22; i++)
320 Term_putch(col, row + i + 1, TERM_WHITE, '|');
322 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
328 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
330 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
334 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
338 /* Make it look nice */
344 * Hack -- Teleport to the target
346 static void do_cmd_wiz_bamf(void)
348 /* Must have a target */
349 if (!target_who) return;
351 /* Teleport to the target */
352 teleport_player_to(target_row, target_col, FALSE);
357 * Aux function for "do_cmd_wiz_change()". -RAK-
359 static void do_cmd_wiz_change_aux(void)
369 /* Query the stats */
370 for (i = 0; i < 6; i++)
373 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
376 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
379 if (!get_string(ppp, tmp_val, 3)) return;
382 tmp_int = atoi(tmp_val);
385 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
386 else if (tmp_int < 3) tmp_int = 3;
389 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
394 sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
398 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
400 if (!get_string("Proficiency: ", tmp_val, 9)) return;
404 tmp_s16b = atoi(tmp_val);
407 if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED;
408 if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER;
410 for (j = 0; j <= TV_SWORD - TV_BOW; j++)
412 for (i = 0;i < 64;i++)
414 p_ptr->weapon_exp[j][i] = tmp_s16b;
415 if (p_ptr->weapon_exp[j][i] > s_info[p_ptr->pclass].w_max[j][i]) p_ptr->weapon_exp[j][i] = s_info[p_ptr->pclass].w_max[j][i];
419 for (j = 0; j < 10; j++)
421 p_ptr->skill_exp[j] = tmp_s16b;
422 if (p_ptr->skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) p_ptr->skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
425 for (j = 0; j < 32; j++)
426 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
428 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
431 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
434 if (!get_string("Gold: ", tmp_val, 9)) return;
437 tmp_long = atol(tmp_val);
440 if (tmp_long < 0) tmp_long = 0L;
443 p_ptr->au = tmp_long;
447 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
450 if (!get_string("Experience: ", tmp_val, 9)) return;
453 tmp_long = atol(tmp_val);
456 if (tmp_long < 0) tmp_long = 0L;
458 if (p_ptr->prace != RACE_ANDROID)
461 p_ptr->max_exp = tmp_long;
462 p_ptr->exp = tmp_long;
471 * Change various "permanent" player variables.
473 static void do_cmd_wiz_change(void)
476 do_cmd_wiz_change_aux();
478 /* Redraw everything */
484 * Wizard routines for creating objects -RAK-
485 * And for manipulating them! -Bernd-
487 * This has been rewritten to make the whole procedure
488 * of debugging objects much easier and more comfortable.
490 * The following functions are meant to play with objects:
491 * Create, modify, roll for them (for statistic purposes) and more.
492 * The original functions were by RAK.
493 * The function to show an item's debug information was written
494 * by David Reeve Sward <sward+@CMU.EDU>.
495 * Bernd (wiebelt@mathematik.hu-berlin.de)
497 * Here are the low-level functions
498 * - wiz_display_item()
499 * display an item's debug-info
500 * - wiz_create_itemtype()
501 * specify tval and sval (type and subtype of object)
503 * specify pval, +AC, +tohit, +todam
504 * Note that the wizard can leave this function anytime,
505 * thus accepting the default-values for the remaining values.
506 * pval comes first now, since it is most important.
507 * - wiz_reroll_item()
508 * apply some magic to the item or turn it into an artifact.
510 * Get some statistics about the rarity of an item:
511 * We create a lot of fake items and see if they are of the
512 * same type (tval and sval), then we compare pval and +AC.
513 * If the fake-item is better or equal it is counted.
514 * Note that cursed items that are better or equal (absolute values)
516 * HINT: This is *very* useful for balancing the game!
517 * - wiz_quantity_item()
518 * change the quantity of an item, but be sane about it.
520 * And now the high-level functions
521 * - do_cmd_wiz_play()
522 * play with an existing object
523 * - wiz_create_item()
524 * create a new object
526 * Note -- You do not have to specify "pval" and other item-properties
527 * directly. Just apply magic until you are satisfied with the item.
529 * Note -- For some items (such as wands, staffs, some rings, etc), you
530 * must apply magic, or you will get "broken" or "uncharged" objects.
532 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
533 * the artifact. Be careful.
535 * Hack -- this function will allow you to create multiple artifacts.
536 * This "feature" may induce crashes or other nasty effects.
540 * Just display an item's properties (debug-info)
541 * Originally by David Reeve Sward <sward+@CMU.EDU>
542 * Verbose item flags by -Bernd-
544 static void wiz_display_item(object_type *o_ptr)
547 u32b flgs[TR_FLAG_SIZE];
550 /* Extract the flags */
551 object_flags(o_ptr, flgs);
553 /* Clear the screen */
554 for (i = 1; i <= 23; i++) prt("", i, j - 2);
556 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
559 object_desc_store(buf, o_ptr, TRUE, 3);
563 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
564 o_ptr->k_idx, get_object_level(o_ptr),
565 o_ptr->tval, o_ptr->sval), 4, j);
567 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
568 o_ptr->number, o_ptr->weight,
569 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
571 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
572 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
574 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
575 o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
577 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
578 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
580 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d cursed = %-d",
581 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
583 prt("+------------FLAGS1------------+", 10, j);
584 prt("AFFECT........SLAY........BRAND.", 11, j);
585 prt(" mf cvae xsqpaefc", 12, j);
586 prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
587 prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
588 prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
589 prt_binary(flgs[0], 16, j);
591 prt("+------------FLAGS2------------+", 17, j);
592 prt("SUST....IMMUN.RESIST............", 18, j);
593 prt(" reaefctrpsaefcpfldbc sn ", 19, j);
594 prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
595 prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
596 prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
597 prt_binary(flgs[1], 23, j);
599 prt("+------------FLAGS3------------+", 10, j+32);
600 prt("fe cnn t stdrmsiiii d ab ", 11, j+32);
601 prt("aa aoomywhs lleeieihgggg rtgl ", 12, j+32);
602 prt("uu utmacaih eielgggonnnnaaere ", 13, j+32);
603 prt("rr reanurdo vtieeehtrrrrcilas ", 14, j+32);
604 prt("aa algarnew ienpsntsaefctnevs ", 15, j+32);
605 prt_binary(flgs[2], 16, j+32);
607 prt("+------------FLAGS4------------+", 17, j+32);
608 prt("KILL....ESP......... ", 18, j+32);
609 prt("aeud tghaud tgdhegnu ", 19, j+32);
610 prt("nvneoriunneoriruvoon ", 20, j+32);
611 prt("iidmroamidmroagmionq ", 21, j+32);
612 prt("mlenclnmmenclnnnldlu ", 22, j+32);
613 prt_binary(flgs[3], 23, j+32);
618 * A structure to hold a tval and its description
620 typedef struct tval_desc
627 * A list of tvals and their textual names
629 static tval_desc tvals[] =
631 { TV_SWORD, "Sword" },
632 { TV_POLEARM, "Polearm" },
633 { TV_HAFTED, "Hafted Weapon" },
635 { TV_ARROW, "Arrows" },
636 { TV_BOLT, "Bolts" },
637 { TV_SHOT, "Shots" },
638 { TV_SHIELD, "Shield" },
639 { TV_CROWN, "Crown" },
641 { TV_GLOVES, "Gloves" },
642 { TV_BOOTS, "Boots" },
643 { TV_CLOAK, "Cloak" },
644 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
645 { TV_HARD_ARMOR, "Hard Armor" },
646 { TV_SOFT_ARMOR, "Soft Armor" },
648 { TV_AMULET, "Amulet" },
650 { TV_POTION, "Potion" },
651 { TV_SCROLL, "Scroll" },
653 { TV_STAFF, "Staff" },
655 { TV_LIFE_BOOK, "Life Spellbook" },
656 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
657 { TV_NATURE_BOOK, "Nature Spellbook" },
658 { TV_CHAOS_BOOK, "Chaos Spellbook" },
659 { TV_DEATH_BOOK, "Death Spellbook" },
660 { TV_TRUMP_BOOK, "Trump Spellbook" },
661 { TV_ARCANE_BOOK, "Arcane Spellbook" },
662 { TV_ENCHANT_BOOK, "Craft Spellbook"},
663 { TV_DAEMON_BOOK, "Daemon Spellbook"},
664 { TV_CRUSADE_BOOK, "Crusade Spellbook"},
665 { TV_MUSIC_BOOK, "Music Spellbook" },
666 { TV_HISSATSU_BOOK, "Book of Kendo" },
667 { TV_PARCHEMENT, "Parchement" },
668 { TV_WHISTLE, "Whistle" },
669 { TV_SPIKE, "Spikes" },
670 { TV_DIGGING, "Digger" },
671 { TV_CHEST, "Chest" },
672 { TV_CAPTURE, "Capture Ball" },
673 { TV_CARD, "Express Card" },
674 { TV_FIGURINE, "Magical Figurine" },
675 { TV_STATUE, "Statue" },
676 { TV_CORPSE, "Corpse" },
678 { TV_FLASK, "Flask" },
680 { TV_SKELETON, "Skeleton" },
686 * Strip an "object name" into a buffer
688 void strip_name(char *buf, int k_idx)
692 object_kind *k_ptr = &k_info[k_idx];
694 cptr str = (k_name + k_ptr->name);
697 /* Skip past leading characters */
698 while ((*str == ' ') || (*str == '&')) str++;
700 /* Copy useful chars */
701 for (t = buf; *str; str++)
704 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
706 if (*str != '~') *t++ = *str;
709 /* Terminate the new name */
715 * Specify tval and sval (type and subtype of object) originally
716 * by RAK, heavily modified by -Bernd-
718 * This function returns the k_idx of an object type, or zero if failed
720 * List up to 50 choices in three columns
722 static int wiz_create_itemtype(void)
739 /* Print all tval's and their descriptions */
740 for (num = 0; (num < 80) && tvals[num].tval; num++)
742 row = 2 + (num % 20);
743 col = 20 * (num / 20);
745 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
748 /* Me need to know the maximal possible tval_index */
752 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
755 for (num = 0; num < max_num; num++)
757 if (listsym[num] == ch) break;
760 /* Bail out if choice is illegal */
761 if ((num < 0) || (num >= max_num)) return (0);
763 /* Base object type chosen, fill in tval */
764 tval = tvals[num].tval;
765 tval_desc = tvals[num].desc;
768 /*** And now we go for k_idx ***/
773 /* We have to search the whole itemlist. */
774 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
776 object_kind *k_ptr = &k_info[i];
778 /* Analyze matching items */
779 if (k_ptr->tval == tval)
782 row = 2 + (num % 20);
783 col = 20 * (num / 20);
787 /* Acquire the "name" of object "i" */
791 prt(format("[%c] %s", ch, buf), row, col);
793 /* Remember the object index */
798 /* Me need to know the maximal possible remembered object_index */
802 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
805 for (num = 0; num < max_num; num++)
807 if (listsym[num] == ch) break;
810 /* Bail out if choice is "illegal" */
811 if ((num < 0) || (num >= max_num)) return (0);
813 /* And return successful */
814 return (choice[num]);
821 static void wiz_tweak_item(object_type *o_ptr)
827 /* Hack -- leave artifacts alone */
828 if (artifact_p(o_ptr) || o_ptr->art_name) return;
830 p = "Enter new 'pval' setting: ";
831 sprintf(tmp_val, "%d", o_ptr->pval);
832 if (!get_string(p, tmp_val, 5)) return;
833 o_ptr->pval = atoi(tmp_val);
834 wiz_display_item(o_ptr);
836 p = "Enter new 'to_a' setting: ";
837 sprintf(tmp_val, "%d", o_ptr->to_a);
838 if (!get_string(p, tmp_val, 5)) return;
839 o_ptr->to_a = atoi(tmp_val);
840 wiz_display_item(o_ptr);
842 p = "Enter new 'to_h' setting: ";
843 sprintf(tmp_val, "%d", o_ptr->to_h);
844 if (!get_string(p, tmp_val, 5)) return;
845 o_ptr->to_h = atoi(tmp_val);
846 wiz_display_item(o_ptr);
848 p = "Enter new 'to_d' setting: ";
849 sprintf(tmp_val, "%d", o_ptr->to_d);
850 if (!get_string(p, tmp_val, 5)) return;
851 o_ptr->to_d = atoi(tmp_val);
852 wiz_display_item(o_ptr);
857 * Apply magic to an item or turn it into an artifact. -Bernd-
859 static void wiz_reroll_item(object_type *o_ptr)
866 bool changed = FALSE;
869 /* Hack -- leave artifacts alone */
870 if (artifact_p(o_ptr) || o_ptr->art_name) return;
873 /* Get local object */
876 /* Copy the object */
877 object_copy(q_ptr, o_ptr);
880 /* Main loop. Ask for magification and artifactification */
883 /* Display full item debug information */
884 wiz_display_item(q_ptr);
886 /* Ask wizard what to do. */
887 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
889 /* Preserve wizard-generated artifacts */
890 if (artifact_p(q_ptr))
892 a_info[q_ptr->name1].cur_num = 0;
900 /* Create/change it! */
901 if (ch == 'A' || ch == 'a')
907 /* Preserve wizard-generated artifacts */
908 if (artifact_p(q_ptr))
910 a_info[q_ptr->name1].cur_num = 0;
916 /* Apply bad magic, but first clear object */
919 object_prep(q_ptr, o_ptr->k_idx);
920 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
923 /* Apply bad magic, but first clear object */
926 object_prep(q_ptr, o_ptr->k_idx);
927 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
930 /* Apply normal magic, but first clear object */
933 object_prep(q_ptr, o_ptr->k_idx);
934 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
937 /* Apply good magic, but first clear object */
940 object_prep(q_ptr, o_ptr->k_idx);
941 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD);
944 /* Apply great magic, but first clear object */
947 object_prep(q_ptr, o_ptr->k_idx);
948 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
951 /* Apply special magic, but first clear object */
954 object_prep(q_ptr, o_ptr->k_idx);
955 apply_magic(q_ptr, dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
957 /* Failed to create artifact; make a random one */
958 if (!artifact_p(q_ptr) && !q_ptr->art_name) create_artifact(q_ptr, FALSE);
962 q_ptr->iy = o_ptr->iy;
963 q_ptr->ix = o_ptr->ix;
964 q_ptr->next_o_idx = o_ptr->next_o_idx;
965 q_ptr->marked = o_ptr->marked;
973 object_copy(o_ptr, q_ptr);
975 /* Recalculate bonuses */
976 p_ptr->update |= (PU_BONUS);
978 /* Combine / Reorder the pack (later) */
979 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
982 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
989 * Try to create an item again. Output some statistics. -Bernd-
991 * The statistics are correct now. We acquire a clean grid, and then
992 * repeatedly place an object in this grid, copying it into an item
993 * holder, and then deleting the object. We fiddle with the artifact
994 * counter flags to prevent weirdness. We use the items to collect
995 * statistics on item creation relative to the initial item.
997 static void wiz_statistics(object_type *o_ptr)
999 u32b i, matches, better, worse, other, correct;
1001 u32b test_roll = 1000000;
1011 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
1013 cptr p = "Enter number of items to roll: ";
1017 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1018 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
1024 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
1027 wiz_display_item(o_ptr);
1030 if (!get_com(pmt, &ch, FALSE)) break;
1032 if (ch == 'n' || ch == 'N')
1037 else if (ch == 'g' || ch == 'G')
1042 else if (ch == 'e' || ch == 'E')
1044 mode = AM_GOOD | AM_GREAT;
1045 quality = "excellent";
1052 sprintf(tmp_val, "%ld", test_roll);
1053 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1054 test_roll = MAX(1, test_roll);
1056 /* Let us know what we are doing */
1057 msg_format("Creating a lot of %s items. Base level = %d.",
1058 quality, dun_level);
1061 /* Set counters to zero */
1062 correct = matches = better = worse = other = 0;
1064 /* Let's rock and roll */
1065 for (i = 0; i <= test_roll; i++)
1067 /* Output every few rolls */
1068 if ((i < 100) || (i % 100 == 0))
1073 /* Allow interupt */
1083 /* Dump the stats */
1084 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1089 /* Get local object */
1092 /* Wipe the object */
1095 /* Create an object */
1096 make_object(q_ptr, mode);
1099 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1100 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1103 /* Test for the same tval and sval. */
1104 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1105 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1107 /* One more correct item */
1110 /* Check for match */
1111 if ((q_ptr->pval == o_ptr->pval) &&
1112 (q_ptr->to_a == o_ptr->to_a) &&
1113 (q_ptr->to_h == o_ptr->to_h) &&
1114 (q_ptr->to_d == o_ptr->to_d) &&
1115 (q_ptr->name1 == o_ptr->name1))
1120 /* Check for better */
1121 else if ((q_ptr->pval >= o_ptr->pval) &&
1122 (q_ptr->to_a >= o_ptr->to_a) &&
1123 (q_ptr->to_h >= o_ptr->to_h) &&
1124 (q_ptr->to_d >= o_ptr->to_d))
1129 /* Check for worse */
1130 else if ((q_ptr->pval <= o_ptr->pval) &&
1131 (q_ptr->to_a <= o_ptr->to_a) &&
1132 (q_ptr->to_h <= o_ptr->to_h) &&
1133 (q_ptr->to_d <= o_ptr->to_d))
1138 /* Assume different */
1146 msg_format(q, i, correct, matches, better, worse, other);
1151 /* Hack -- Normally only make a single artifact */
1152 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1157 * Change the quantity of a the item
1159 static void wiz_quantity_item(object_type *o_ptr)
1161 int tmp_int, tmp_qnt;
1166 /* Never duplicate artifacts */
1167 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1169 /* Store old quantity. -LM- */
1170 tmp_qnt = o_ptr->number;
1173 sprintf(tmp_val, "%d", o_ptr->number);
1176 if (get_string("Quantity: ", tmp_val, 2))
1179 tmp_int = atoi(tmp_val);
1182 if (tmp_int < 1) tmp_int = 1;
1183 if (tmp_int > 99) tmp_int = 99;
1185 /* Accept modifications */
1186 o_ptr->number = tmp_int;
1189 if (o_ptr->tval == TV_ROD)
1191 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1195 /* debug command for blue mage */
1196 static void do_cmd_wiz_blue_mage(void)
1201 s32b f4 = 0, f5 = 0, f6 = 0;
1206 set_rf_masks(&f4, &f5, &f6, j);
1208 for (i = 0; i < 32; i++)
1210 if ((0x00000001 << i) & f4) p_ptr->magic_num2[i] = 1;
1214 if ((0x00000001 << (i - 32)) & f5) p_ptr->magic_num2[i] = 1;
1218 if ((0x00000001 << (i - 64)) & f6) p_ptr->magic_num2[i] = 1;
1225 * Play with an item. Options include:
1226 * - Output statistics (via wiz_roll_item)
1227 * - Reroll item (via wiz_reroll_item)
1228 * - Change properties (via wiz_tweak_item)
1229 * - Change the number of items (via wiz_quantity_item)
1231 static void do_cmd_wiz_play(void)
1246 item_tester_no_ryoute = TRUE;
1248 q = "Play with which object? ";
1249 s = "You have nothing to play with.";
1250 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1252 /* Get the item (in the pack) */
1255 o_ptr = &inventory[item];
1258 /* Get the item (on the floor) */
1261 o_ptr = &o_list[0 - item];
1264 /* The item was not changed */
1268 /* Save the screen */
1272 /* Get local object */
1276 object_copy(q_ptr, o_ptr);
1282 /* Display the item */
1283 wiz_display_item(q_ptr);
1286 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1292 if (ch == 'A' || ch == 'a')
1298 if (ch == 's' || ch == 'S')
1300 wiz_statistics(q_ptr);
1303 if (ch == 'r' || ch == 'r')
1305 wiz_reroll_item(q_ptr);
1308 if (ch == 't' || ch == 'T')
1310 wiz_tweak_item(q_ptr);
1313 if (ch == 'q' || ch == 'Q')
1315 wiz_quantity_item(q_ptr);
1320 /* Restore the screen */
1328 msg_print("Changes accepted.");
1330 /* Recalcurate object's weight */
1333 p_ptr->total_weight += (q_ptr->weight * q_ptr->number)
1334 - (o_ptr->weight * o_ptr->number);
1338 object_copy(o_ptr, q_ptr);
1341 /* Recalculate bonuses */
1342 p_ptr->update |= (PU_BONUS);
1344 /* Combine / Reorder the pack (later) */
1345 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1348 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1354 msg_print("Changes ignored.");
1360 * Wizard routine for creating objects -RAK-
1361 * Heavily modified to allow magification and artifactification -Bernd-
1363 * Note that wizards cannot create objects on top of other objects.
1365 * Hack -- this routine always makes a "dungeon object", and applies
1366 * magic to it, and attempts to decline cursed items.
1368 static void wiz_create_item(void)
1376 /* Save the screen */
1379 /* Get object base type */
1380 k_idx = wiz_create_itemtype();
1382 /* Restore the screen */
1386 /* Return if failed */
1389 if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
1394 for (i = 1; i < max_a_idx; i++)
1396 /* Ignore incorrect tval */
1397 if (a_info[i].tval != k_info[k_idx].tval) continue;
1399 /* Ignore incorrect sval */
1400 if (a_info[i].sval != k_info[k_idx].sval) continue;
1402 /* Create this artifact */
1403 create_named_art(i, py, px);
1406 msg_print("Allocated(INSTA_ART).");
1412 /* Get local object */
1415 /* Create the item */
1416 object_prep(q_ptr, k_idx);
1419 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
1421 /* Drop the object from heaven */
1422 (void)drop_near(q_ptr, -1, py, px);
1425 msg_print("Allocated.");
1430 * Cure everything instantly
1432 static void do_cmd_wiz_cure_all(void)
1435 (void)res_stat(A_STR);
1436 (void)res_stat(A_INT);
1437 (void)res_stat(A_WIS);
1438 (void)res_stat(A_CON);
1439 (void)res_stat(A_DEX);
1440 (void)res_stat(A_CHR);
1442 /* Restore the level */
1443 (void)restore_level();
1445 /* Heal the player */
1446 p_ptr->chp = p_ptr->mhp;
1447 p_ptr->chp_frac = 0;
1450 if (p_ptr->csp < p_ptr->msp)
1452 p_ptr->csp = p_ptr->msp;
1453 p_ptr->csp_frac = 0;
1458 (void)set_confused(0);
1459 (void)set_poisoned(0);
1460 (void)set_afraid(0);
1461 (void)set_paralyzed(0);
1465 (void)set_slow(0, TRUE);
1467 /* No longer hungry */
1468 (void)set_food(PY_FOOD_MAX - 1);
1470 /* Redraw everything */
1478 static void do_cmd_wiz_jump(void)
1481 if (command_arg <= 0)
1486 int tmp_dungeon_type;
1489 sprintf(ppp, "Jump which dungeon : ");
1492 sprintf(tmp_val, "%d", dungeon_type);
1494 /* Ask for a level */
1495 if (!get_string(ppp, tmp_val, 2)) return;
1497 tmp_dungeon_type = atoi(tmp_val);
1498 if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
1501 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[tmp_dungeon_type].mindepth, d_info[tmp_dungeon_type].maxdepth);
1504 sprintf(tmp_val, "%d", dun_level);
1506 /* Ask for a level */
1507 if (!get_string(ppp, tmp_val, 10)) return;
1509 /* Extract request */
1510 command_arg = atoi(tmp_val);
1512 dungeon_type = tmp_dungeon_type;
1516 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1519 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1521 /* Accept request */
1522 msg_format("You jump to dungeon level %d.", command_arg);
1524 if (autosave_l) do_cmd_save_game(TRUE);
1527 dun_level = command_arg;
1529 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
1531 if (!dun_level) dungeon_type = 0;
1532 p_ptr->inside_arena = FALSE;
1533 p_ptr->wild_mode = FALSE;
1535 leave_quest_check();
1537 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1539 p_ptr->inside_quest = 0;
1540 p_ptr->leftbldg = FALSE;
1543 /* Prevent energy_need from being too lower than 0 */
1544 p_ptr->energy_need = 0;
1547 p_ptr->leaving = TRUE;
1552 * Become aware of a lot of objects
1554 static void do_cmd_wiz_learn(void)
1561 /* Scan every object */
1562 for (i = 1; i < max_k_idx; i++)
1564 object_kind *k_ptr = &k_info[i];
1566 /* Induce awareness */
1567 if (k_ptr->level <= command_arg)
1569 /* Get local object */
1572 /* Prepare object */
1573 object_prep(q_ptr, i);
1576 object_aware(q_ptr);
1583 * Summon some creatures
1585 static void do_cmd_wiz_summon(int num)
1589 for (i = 0; i < num; i++)
1591 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1597 * Summon a creature of the specified type
1599 * XXX XXX XXX This function is rather dangerous
1601 static void do_cmd_wiz_named(int r_idx)
1606 /* if (!r_idx) return; */
1608 /* Prevent illegal monsters */
1609 if (r_idx >= max_r_idx) return;
1612 for (i = 0; i < 10; i++)
1616 /* Pick a location */
1617 scatter(&y, &x, py, px, d, 0);
1619 /* Require empty grids */
1620 if (!cave_empty_bold(y, x)) continue;
1622 /* Place it (allow groups) */
1623 if (place_monster_aux(0, y, x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP))) break;
1629 * Summon a creature of the specified type
1631 * XXX XXX XXX This function is rather dangerous
1633 static void do_cmd_wiz_named_friendly(int r_idx)
1635 (void) summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
1641 * Hack -- Delete all nearby monsters
1643 static void do_cmd_wiz_zap(void)
1648 /* Genocide everyone nearby */
1649 for (i = 1; i < m_max; i++)
1651 monster_type *m_ptr = &m_list[i];
1653 /* Paranoia -- Skip dead monsters */
1654 if (!m_ptr->r_idx) continue;
1656 /* Delete nearby monsters */
1657 if (m_ptr->cdis <= MAX_SIGHT)
1659 if (i == p_ptr->riding)
1662 p_ptr->redraw |= (PR_EXTRA);
1664 delete_monster_idx(i);
1671 * Hack -- Delete all monsters
1673 static void do_cmd_wiz_zap_all(void)
1677 /* Genocide everyone */
1678 for (i = 1; i < m_max; i++)
1680 monster_type *m_ptr = &m_list[i];
1682 /* Paranoia -- Skip dead monsters */
1683 if (!m_ptr->r_idx) continue;
1685 if (i == p_ptr->riding)
1688 p_ptr->redraw |= (PR_EXTRA);
1691 /* Delete this monster */
1692 delete_monster_idx(i);
1698 #define NUM_O_BIT 32
1701 * Hack -- Dump option bits usage
1703 static void do_cmd_dump_options(void)
1710 /* Build the filename */
1711 path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
1713 /* File type is "TEXT" */
1714 FILE_TYPE(FILE_TYPE_TEXT);
1717 fff = my_fopen(buf, "a");
1723 msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
1725 msg_format("Failed to open file %s.", buf);
1731 /* Allocate the "exist" array (2-dimension) */
1732 C_MAKE(exist, NUM_O_SET, int *);
1733 C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
1734 for (i = 1; i < NUM_O_SET; i++) exist[i] = *exist + i * NUM_O_BIT;
1736 /* Check for exist option bits */
1737 for (i = 0; option_info[i].o_desc; i++)
1739 option_type *ot_ptr = &option_info[i];
1740 if (ot_ptr->o_var) exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
1743 fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n",
1744 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1746 fputs("Set - Bit (Page) Option Name\n", fff);
1747 fputs("------------------------------------------------\n", fff);
1748 /* Dump option bits usage */
1749 for (i = 0; i < NUM_O_SET; i++)
1751 for (j = 0; j < NUM_O_BIT; j++)
1755 option_type *ot_ptr = &option_info[exist[i][j] - 1];
1756 fprintf(fff, " %d - %02d (%4d) %s\n",
1757 i, j, ot_ptr->o_page, ot_ptr->o_text);
1761 fprintf(fff, " %d - %02d\n", i, j);
1767 /* Free the "exist" array (2-dimension) */
1768 C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
1769 C_KILL(exist, NUM_O_SET, int *);
1775 msg_format("¥ª¥×¥·¥ç¥óbit»ÈÍѾõ¶·¤ò¥Õ¥¡¥¤¥ë %s ¤Ë½ñ¤½Ð¤·¤Þ¤·¤¿¡£", buf);
1777 msg_format("Option bits usage dump saved to file %s.", buf);
1782 #ifdef ALLOW_SPOILERS
1787 extern void do_cmd_spoilers(void);
1789 #endif /* ALLOW_SPOILERS */
1794 * Hack -- declare external function
1796 extern void do_cmd_debug(void);
1801 * Ask for and parse a "debug command"
1802 * The "command_arg" may have been set.
1804 void do_cmd_debug(void)
1810 /* Get a "debug command" */
1811 get_com("Debug Command: ", &cmd, FALSE);
1813 /* Analyze the command */
1823 #ifdef ALLOW_SPOILERS
1825 /* Hack -- Generate Spoilers */
1830 #endif /* ALLOW_SPOILERS */
1837 /* Cure all maladies */
1839 do_cmd_wiz_cure_all();
1842 /* Know alignment */
1844 msg_format("Your alignment is %d.", p_ptr->align);
1847 /* Teleport to target */
1856 /* Create any object */
1861 /* Create a named artifact */
1863 wiz_create_named_art(command_arg);
1866 /* Detect everything */
1868 detect_all(DETECT_RAD_ALL*3);
1871 /* Dimension_door */
1873 wiz_dimension_door();
1876 /* Edit character */
1878 do_cmd_wiz_change();
1881 /* Blue Mage Only */
1883 if (p_ptr->pclass == CLASS_BLUE_MAGE)
1885 do_cmd_wiz_blue_mage();
1889 /* View item info */
1891 identify_fully(FALSE);
1896 if (command_arg <= 0) command_arg = 1;
1897 acquirement(py, px, command_arg, FALSE, TRUE);
1900 /* Hitpoint rerating */
1902 do_cmd_rerate(TRUE);
1905 #ifdef MONSTER_HORDES
1907 do_cmd_summon_horde();
1909 #endif /* MONSTER_HORDES */
1913 (void)ident_spell(FALSE);
1916 /* Go up or down in the dungeon */
1921 /* Self-Knowledge */
1926 /* Learn about objects */
1933 map_area(DETECT_RAD_ALL);
1938 (void)gain_random_mutation(command_arg);
1941 /* Specific reward */
1943 (void)gain_level_reward(command_arg);
1946 /* Summon _friendly_ named monster */
1948 do_cmd_wiz_named_friendly(command_arg);
1951 /* Summon Named Monster */
1953 do_cmd_wiz_named(command_arg);
1956 /* Dump option bits usage */
1958 do_cmd_dump_options();
1961 /* Object playing routines */
1968 teleport_player(10);
1972 /* Complete a Quest -KMW- */
1974 for (i = 0; i < max_quests; i++)
1976 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1978 p_ptr->quest[i].status++;
1979 msg_print("Completed Quest");
1984 if (i == max_quests)
1986 msg_print("No current quest");
1992 /* Make every dungeon square "known" to test streamers -KMW- */
1994 for (y = 0; y < cur_hgt; y++)
1996 for (x = 0; x < cur_wid; x++)
1998 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
2004 /* Summon Random Monster(s) */
2006 if (command_arg <= 0) command_arg = 1;
2007 do_cmd_wiz_summon(command_arg);
2012 teleport_player(100);
2015 /* Very Good Objects */
2017 if (command_arg <= 0) command_arg = 1;
2018 acquirement(py, px, command_arg, TRUE, TRUE);
2021 /* Wizard Light the Level */
2023 wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
2026 /* Increase Experience */
2028 gain_exp(command_arg ? command_arg : (p_ptr->exp + 1));
2031 /* Zap Monsters (Genocide) */
2036 /* Zap Monsters (Omnicide) */
2038 do_cmd_wiz_zap_all();
2041 /* Hack -- whatever I desire */
2043 do_cmd_wiz_hack_ben();
2046 /* Not a Wizard Command */
2048 msg_print("That is not a valid debug command.");