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 teleport_player_to(y, x, TELEPORT_NONMAGICAL);
118 * Create the artifact of the specified number -- DAN
121 static void wiz_create_named_art(int a_idx)
123 /* Create the artifact */
124 (void)create_named_art(a_idx, py, px);
127 msg_print("Allocated.");
132 * Hack -- quick debugging hook
134 static void do_cmd_wiz_hack_ben(void)
143 #ifdef MONSTER_HORDES
145 /* Summon a horde of monsters */
146 static void do_cmd_summon_horde(void)
148 int wy = py, wx = px;
153 scatter(&wy, &wx, py, px, 3, 0);
154 if (cave_empty_bold(wy, wx)) break;
157 (void)alloc_horde(wy, wx);
160 #endif /* MONSTER_HORDES */
164 * Output a long int in binary format.
166 static void prt_binary(u32b flags, int row, int col)
172 for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
177 Term_putch(col++, row, TERM_BLUE, '*');
180 /* Dump unset bits */
183 Term_putch(col++, row, TERM_WHITE, '-');
189 #define K_MAX_DEPTH 110
192 * Output a rarity graph for a type of object.
194 static void prt_alloc(byte tval, byte sval, int row, int col)
198 u32b maxr = 1, maxt = 1, ratio;
199 u32b rarity[K_MAX_DEPTH];
200 u32b total[K_MAX_DEPTH];
201 s32b maxd = 1, display[22];
203 cptr r = "+--common--+";
208 alloc_entry *table = alloc_kind_table;
210 /* Wipe the tables */
211 (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
212 (void)C_WIPE(total, K_MAX_DEPTH, u32b);
213 (void)C_WIPE(display, 22, s32b);
215 /* Scan all entries */
216 for (i = 0; i < K_MAX_DEPTH; i++)
219 for (j = 0; j < alloc_kind_size; j++)
223 if (table[j].level <= i)
225 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
227 else if (table[j].level - 1 > 0)
229 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
232 /* Acquire this kind */
233 k_ptr = &k_info[table[j].index];
235 /* Accumulate probabilities */
236 total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
237 total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
239 /* Accumulate probabilities */
240 if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
246 total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
250 for (i = 0; i < K_MAX_DEPTH; i++)
252 if (rarity[i] > maxr) maxr = rarity[i];
253 if (total[i] > maxt) maxt = total[i];
256 if (maxr / (GREAT_OBJ * K_MAX_DEPTH) != 0)
257 ratio = maxt / (maxr / (GREAT_OBJ * K_MAX_DEPTH));
261 /* Simulate a log graph */
278 /* Calculate probabilities for each range */
279 for (i = 0; i < 22; i++)
281 /* Shift the values into view */
284 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
285 possibility += rarity[j] * (100 * maxt / total[j]);
287 possibility = possibility / maxr;
289 /* display[i] = log_{sqrt(2)}(possibility) */
294 possibility = possibility * 1000 / 1414;
298 if (display[i] > maxd) maxd = display[i];
302 if (maxd > 10) for (i = 0; i < 22; i++)
304 display[i] = display[i] - maxd + 10;
307 /* Graph the rarities */
308 for (i = 0; i < 22; i++)
310 Term_putch(col, row + i + 1, TERM_WHITE, '|');
312 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
318 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
320 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
324 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
328 /* Make it look nice */
334 * Hack -- Teleport to the target
336 static void do_cmd_wiz_bamf(void)
338 /* Must have a target */
339 if (!target_who) return;
341 /* Teleport to the target */
342 teleport_player_to(target_row, target_col, TELEPORT_NONMAGICAL);
347 * Aux function for "do_cmd_wiz_change()". -RAK-
349 static void do_cmd_wiz_change_aux(void)
359 /* Query the stats */
360 for (i = 0; i < 6; i++)
363 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
366 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
369 if (!get_string(ppp, tmp_val, 3)) return;
372 tmp_int = atoi(tmp_val);
375 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
376 else if (tmp_int < 3) tmp_int = 3;
379 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
384 sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
388 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
390 if (!get_string("Proficiency: ", tmp_val, 9)) return;
394 tmp_s16b = atoi(tmp_val);
397 if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED;
398 if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER;
400 for (j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++)
402 for (i = 0;i < 64;i++)
404 p_ptr->weapon_exp[j][i] = tmp_s16b;
405 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];
409 for (j = 0; j < 10; j++)
411 p_ptr->skill_exp[j] = tmp_s16b;
412 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];
415 for (j = 0; j < 32; j++)
416 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
418 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
421 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
424 if (!get_string("Gold: ", tmp_val, 9)) return;
427 tmp_long = atol(tmp_val);
430 if (tmp_long < 0) tmp_long = 0L;
433 p_ptr->au = tmp_long;
437 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
440 if (!get_string("Experience: ", tmp_val, 9)) return;
443 tmp_long = atol(tmp_val);
446 if (tmp_long < 0) tmp_long = 0L;
448 if (p_ptr->prace != RACE_ANDROID)
451 p_ptr->max_exp = tmp_long;
452 p_ptr->exp = tmp_long;
461 * Change various "permanent" player variables.
463 static void do_cmd_wiz_change(void)
466 do_cmd_wiz_change_aux();
468 /* Redraw everything */
474 * Wizard routines for creating objects -RAK-
475 * And for manipulating them! -Bernd-
477 * This has been rewritten to make the whole procedure
478 * of debugging objects much easier and more comfortable.
480 * The following functions are meant to play with objects:
481 * Create, modify, roll for them (for statistic purposes) and more.
482 * The original functions were by RAK.
483 * The function to show an item's debug information was written
484 * by David Reeve Sward <sward+@CMU.EDU>.
485 * Bernd (wiebelt@mathematik.hu-berlin.de)
487 * Here are the low-level functions
488 * - wiz_display_item()
489 * display an item's debug-info
490 * - wiz_create_itemtype()
491 * specify tval and sval (type and subtype of object)
493 * specify pval, +AC, +tohit, +todam
494 * Note that the wizard can leave this function anytime,
495 * thus accepting the default-values for the remaining values.
496 * pval comes first now, since it is most important.
497 * - wiz_reroll_item()
498 * apply some magic to the item or turn it into an artifact.
500 * Get some statistics about the rarity of an item:
501 * We create a lot of fake items and see if they are of the
502 * same type (tval and sval), then we compare pval and +AC.
503 * If the fake-item is better or equal it is counted.
504 * Note that cursed items that are better or equal (absolute values)
506 * HINT: This is *very* useful for balancing the game!
507 * - wiz_quantity_item()
508 * change the quantity of an item, but be sane about it.
510 * And now the high-level functions
511 * - do_cmd_wiz_play()
512 * play with an existing object
513 * - wiz_create_item()
514 * create a new object
516 * Note -- You do not have to specify "pval" and other item-properties
517 * directly. Just apply magic until you are satisfied with the item.
519 * Note -- For some items (such as wands, staffs, some rings, etc), you
520 * must apply magic, or you will get "broken" or "uncharged" objects.
522 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
523 * the artifact. Be careful.
525 * Hack -- this function will allow you to create multiple artifacts.
526 * This "feature" may induce crashes or other nasty effects.
530 * Just display an item's properties (debug-info)
531 * Originally by David Reeve Sward <sward+@CMU.EDU>
532 * Verbose item flags by -Bernd-
534 static void wiz_display_item(object_type *o_ptr)
537 u32b flgs[TR_FLAG_SIZE];
540 /* Extract the flags */
541 object_flags(o_ptr, flgs);
543 /* Clear the screen */
544 for (i = 1; i <= 23; i++) prt("", i, j - 2);
546 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
549 object_desc(buf, o_ptr, OD_STORE);
553 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
554 o_ptr->k_idx, k_info[o_ptr->k_idx].level,
555 o_ptr->tval, o_ptr->sval), 4, j);
557 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
558 o_ptr->number, o_ptr->weight,
559 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
561 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
562 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
564 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
565 o_ptr->name1, o_ptr->name2, (long)object_value_real(o_ptr)), 7, j);
567 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
568 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
570 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d cursed = %-d",
571 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
573 prt("+------------FLAGS1------------+", 10, j);
574 prt("AFFECT........SLAY........BRAND.", 11, j);
575 prt(" mf cvae xsqpaefc", 12, j);
576 prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
577 prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
578 prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
579 prt_binary(flgs[0], 16, j);
581 prt("+------------FLAGS2------------+", 17, j);
582 prt("SUST....IMMUN.RESIST............", 18, j);
583 prt(" reaefctrpsaefcpfldbc sn ", 19, j);
584 prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
585 prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
586 prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
587 prt_binary(flgs[1], 23, j);
589 prt("+------------FLAGS3------------+", 10, j+32);
590 prt("fe cnn t stdrmsiiii d ab ", 11, j+32);
591 prt("aa aoomywhs lleeieihgggg rtgl ", 12, j+32);
592 prt("uu utmacaih eielgggonnnnaaere ", 13, j+32);
593 prt("rr reanurdo vtieeehtrrrrcilas ", 14, j+32);
594 prt("aa algarnew ienpsntsaefctnevs ", 15, j+32);
595 prt_binary(flgs[2], 16, j+32);
597 prt("+------------FLAGS4------------+", 17, j+32);
598 prt("KILL....ESP......... ", 18, j+32);
599 prt("aeud tghaud tgdhegnu ", 19, j+32);
600 prt("nvneoriunneoriruvoon ", 20, j+32);
601 prt("iidmroamidmroagmionq ", 21, j+32);
602 prt("mlenclnmmenclnnnldlu ", 22, j+32);
603 prt_binary(flgs[3], 23, j+32);
608 * A structure to hold a tval and its description
610 typedef struct tval_desc
617 * A list of tvals and their textual names
619 static tval_desc tvals[] =
621 { TV_SWORD, "Sword" },
622 { TV_POLEARM, "Polearm" },
623 { TV_HAFTED, "Hafted Weapon" },
625 { TV_ARROW, "Arrows" },
626 { TV_BOLT, "Bolts" },
627 { TV_SHOT, "Shots" },
628 { TV_SHIELD, "Shield" },
629 { TV_CROWN, "Crown" },
631 { TV_GLOVES, "Gloves" },
632 { TV_BOOTS, "Boots" },
633 { TV_CLOAK, "Cloak" },
634 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
635 { TV_HARD_ARMOR, "Hard Armor" },
636 { TV_SOFT_ARMOR, "Soft Armor" },
638 { TV_AMULET, "Amulet" },
640 { TV_POTION, "Potion" },
641 { TV_SCROLL, "Scroll" },
643 { TV_STAFF, "Staff" },
645 { TV_LIFE_BOOK, "Life Spellbook" },
646 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
647 { TV_NATURE_BOOK, "Nature Spellbook" },
648 { TV_CHAOS_BOOK, "Chaos Spellbook" },
649 { TV_DEATH_BOOK, "Death Spellbook" },
650 { TV_TRUMP_BOOK, "Trump Spellbook" },
651 { TV_ARCANE_BOOK, "Arcane Spellbook" },
652 { TV_CRAFT_BOOK, "Craft Spellbook"},
653 { TV_DAEMON_BOOK, "Daemon Spellbook"},
654 { TV_CRUSADE_BOOK, "Crusade Spellbook"},
655 { TV_MUSIC_BOOK, "Music Spellbook" },
656 { TV_HISSATSU_BOOK, "Book of Kendo" },
657 { TV_HEX_BOOK, "Hex Spellbook" },
658 { TV_PARCHMENT, "Parchment" },
659 { TV_WHISTLE, "Whistle" },
660 { TV_SPIKE, "Spikes" },
661 { TV_DIGGING, "Digger" },
662 { TV_CHEST, "Chest" },
663 { TV_CAPTURE, "Capture Ball" },
664 { TV_CARD, "Express Card" },
665 { TV_FIGURINE, "Magical Figurine" },
666 { TV_STATUE, "Statue" },
667 { TV_CORPSE, "Corpse" },
669 { TV_FLASK, "Flask" },
671 { TV_SKELETON, "Skeleton" },
677 * Strip an "object name" into a buffer
679 void strip_name(char *buf, int k_idx)
683 object_kind *k_ptr = &k_info[k_idx];
685 cptr str = (k_name + k_ptr->name);
688 /* Skip past leading characters */
689 while ((*str == ' ') || (*str == '&')) str++;
691 /* Copy useful chars */
692 for (t = buf; *str; str++)
695 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
697 if (*str != '~') *t++ = *str;
700 /* Terminate the new name */
706 * Specify tval and sval (type and subtype of object) originally
707 * by RAK, heavily modified by -Bernd-
709 * This function returns the k_idx of an object type, or zero if failed
711 * List up to 50 choices in three columns
713 static int wiz_create_itemtype(void)
730 /* Print all tval's and their descriptions */
731 for (num = 0; (num < 80) && tvals[num].tval; num++)
733 row = 2 + (num % 20);
734 col = 20 * (num / 20);
736 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
739 /* Me need to know the maximal possible tval_index */
743 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
746 for (num = 0; num < max_num; num++)
748 if (listsym[num] == ch) break;
751 /* Bail out if choice is illegal */
752 if ((num < 0) || (num >= max_num)) return (0);
754 /* Base object type chosen, fill in tval */
755 tval = tvals[num].tval;
756 tval_desc = tvals[num].desc;
759 /*** And now we go for k_idx ***/
764 /* We have to search the whole itemlist. */
765 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
767 object_kind *k_ptr = &k_info[i];
769 /* Analyze matching items */
770 if (k_ptr->tval == tval)
773 row = 2 + (num % 20);
774 col = 20 * (num / 20);
778 /* Acquire the "name" of object "i" */
782 prt(format("[%c] %s", ch, buf), row, col);
784 /* Remember the object index */
789 /* Me need to know the maximal possible remembered object_index */
793 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
796 for (num = 0; num < max_num; num++)
798 if (listsym[num] == ch) break;
801 /* Bail out if choice is "illegal" */
802 if ((num < 0) || (num >= max_num)) return (0);
804 /* And return successful */
805 return (choice[num]);
812 static void wiz_tweak_item(object_type *o_ptr)
818 /* Hack -- leave artifacts alone */
819 if (object_is_artifact(o_ptr)) return;
821 p = "Enter new 'pval' setting: ";
822 sprintf(tmp_val, "%d", o_ptr->pval);
823 if (!get_string(p, tmp_val, 5)) return;
824 o_ptr->pval = atoi(tmp_val);
825 wiz_display_item(o_ptr);
827 p = "Enter new 'to_a' setting: ";
828 sprintf(tmp_val, "%d", o_ptr->to_a);
829 if (!get_string(p, tmp_val, 5)) return;
830 o_ptr->to_a = atoi(tmp_val);
831 wiz_display_item(o_ptr);
833 p = "Enter new 'to_h' setting: ";
834 sprintf(tmp_val, "%d", o_ptr->to_h);
835 if (!get_string(p, tmp_val, 5)) return;
836 o_ptr->to_h = atoi(tmp_val);
837 wiz_display_item(o_ptr);
839 p = "Enter new 'to_d' setting: ";
840 sprintf(tmp_val, "%d", o_ptr->to_d);
841 if (!get_string(p, tmp_val, 5)) return;
842 o_ptr->to_d = atoi(tmp_val);
843 wiz_display_item(o_ptr);
848 * Apply magic to an item or turn it into an artifact. -Bernd-
850 static void wiz_reroll_item(object_type *o_ptr)
857 bool changed = FALSE;
860 /* Hack -- leave artifacts alone */
861 if (object_is_artifact(o_ptr)) return;
864 /* Get local object */
867 /* Copy the object */
868 object_copy(q_ptr, o_ptr);
871 /* Main loop. Ask for magification and artifactification */
874 /* Display full item debug information */
875 wiz_display_item(q_ptr);
877 /* Ask wizard what to do. */
878 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
880 /* Preserve wizard-generated artifacts */
881 if (object_is_fixed_artifact(q_ptr))
883 a_info[q_ptr->name1].cur_num = 0;
891 /* Create/change it! */
892 if (ch == 'A' || ch == 'a')
898 /* Preserve wizard-generated artifacts */
899 if (object_is_fixed_artifact(q_ptr))
901 a_info[q_ptr->name1].cur_num = 0;
907 /* Apply bad magic, but first clear object */
910 object_prep(q_ptr, o_ptr->k_idx);
911 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
914 /* Apply bad magic, but first clear object */
917 object_prep(q_ptr, o_ptr->k_idx);
918 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
921 /* Apply normal magic, but first clear object */
924 object_prep(q_ptr, o_ptr->k_idx);
925 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
928 /* Apply good magic, but first clear object */
931 object_prep(q_ptr, o_ptr->k_idx);
932 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD);
935 /* Apply great magic, but first clear object */
938 object_prep(q_ptr, o_ptr->k_idx);
939 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
942 /* Apply special magic, but first clear object */
945 object_prep(q_ptr, o_ptr->k_idx);
946 apply_magic(q_ptr, dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
948 /* Failed to create artifact; make a random one */
949 if (!object_is_artifact(q_ptr)) create_artifact(q_ptr, FALSE);
953 q_ptr->iy = o_ptr->iy;
954 q_ptr->ix = o_ptr->ix;
955 q_ptr->next_o_idx = o_ptr->next_o_idx;
956 q_ptr->marked = o_ptr->marked;
964 object_copy(o_ptr, q_ptr);
966 /* Recalculate bonuses */
967 p_ptr->update |= (PU_BONUS);
969 /* Combine / Reorder the pack (later) */
970 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
973 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
980 * Try to create an item again. Output some statistics. -Bernd-
982 * The statistics are correct now. We acquire a clean grid, and then
983 * repeatedly place an object in this grid, copying it into an item
984 * holder, and then deleting the object. We fiddle with the artifact
985 * counter flags to prevent weirdness. We use the items to collect
986 * statistics on item creation relative to the initial item.
988 static void wiz_statistics(object_type *o_ptr)
990 u32b i, matches, better, worse, other, correct;
992 u32b test_roll = 1000000;
1002 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
1004 cptr p = "Enter number of items to roll: ";
1008 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1009 if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
1015 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
1018 wiz_display_item(o_ptr);
1021 if (!get_com(pmt, &ch, FALSE)) break;
1023 if (ch == 'n' || ch == 'N')
1028 else if (ch == 'g' || ch == 'G')
1033 else if (ch == 'e' || ch == 'E')
1035 mode = AM_GOOD | AM_GREAT;
1036 quality = "excellent";
1043 sprintf(tmp_val, "%ld", (long int)test_roll);
1044 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1045 test_roll = MAX(1, test_roll);
1047 /* Let us know what we are doing */
1048 msg_format("Creating a lot of %s items. Base level = %d.",
1049 quality, dun_level);
1052 /* Set counters to zero */
1053 correct = matches = better = worse = other = 0;
1055 /* Let's rock and roll */
1056 for (i = 0; i <= test_roll; i++)
1058 /* Output every few rolls */
1059 if ((i < 100) || (i % 100 == 0))
1064 /* Allow interupt */
1074 /* Dump the stats */
1075 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1080 /* Get local object */
1083 /* Wipe the object */
1086 /* Create an object */
1087 make_object(q_ptr, mode);
1090 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1091 if (object_is_fixed_artifact(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1094 /* Test for the same tval and sval. */
1095 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1096 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1098 /* One more correct item */
1101 /* Check for match */
1102 if ((q_ptr->pval == o_ptr->pval) &&
1103 (q_ptr->to_a == o_ptr->to_a) &&
1104 (q_ptr->to_h == o_ptr->to_h) &&
1105 (q_ptr->to_d == o_ptr->to_d) &&
1106 (q_ptr->name1 == o_ptr->name1))
1111 /* Check for better */
1112 else if ((q_ptr->pval >= o_ptr->pval) &&
1113 (q_ptr->to_a >= o_ptr->to_a) &&
1114 (q_ptr->to_h >= o_ptr->to_h) &&
1115 (q_ptr->to_d >= o_ptr->to_d))
1120 /* Check for worse */
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 /* Assume different */
1137 msg_format(q, i, correct, matches, better, worse, other);
1142 /* Hack -- Normally only make a single artifact */
1143 if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1148 * Change the quantity of a the item
1150 static void wiz_quantity_item(object_type *o_ptr)
1152 int tmp_int, tmp_qnt;
1157 /* Never duplicate artifacts */
1158 if (object_is_artifact(o_ptr)) return;
1160 /* Store old quantity. -LM- */
1161 tmp_qnt = o_ptr->number;
1164 sprintf(tmp_val, "%d", o_ptr->number);
1167 if (get_string("Quantity: ", tmp_val, 2))
1170 tmp_int = atoi(tmp_val);
1173 if (tmp_int < 1) tmp_int = 1;
1174 if (tmp_int > 99) tmp_int = 99;
1176 /* Accept modifications */
1177 o_ptr->number = tmp_int;
1180 if (o_ptr->tval == TV_ROD)
1182 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1186 /* debug command for blue mage */
1187 static void do_cmd_wiz_blue_mage(void)
1192 s32b f4 = 0, f5 = 0, f6 = 0;
1197 set_rf_masks(&f4, &f5, &f6, j);
1199 for (i = 0; i < 32; i++)
1201 if ((0x00000001 << i) & f4) p_ptr->magic_num2[i] = 1;
1205 if ((0x00000001 << (i - 32)) & f5) p_ptr->magic_num2[i] = 1;
1209 if ((0x00000001 << (i - 64)) & f6) p_ptr->magic_num2[i] = 1;
1216 * Play with an item. Options include:
1217 * - Output statistics (via wiz_roll_item)
1218 * - Reroll item (via wiz_reroll_item)
1219 * - Change properties (via wiz_tweak_item)
1220 * - Change the number of items (via wiz_quantity_item)
1222 static void do_cmd_wiz_play(void)
1237 item_tester_no_ryoute = TRUE;
1239 q = "Play with which object? ";
1240 s = "You have nothing to play with.";
1241 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1243 /* Get the item (in the pack) */
1246 o_ptr = &inventory[item];
1249 /* Get the item (on the floor) */
1252 o_ptr = &o_list[0 - item];
1255 /* The item was not changed */
1259 /* Save the screen */
1263 /* Get local object */
1267 object_copy(q_ptr, o_ptr);
1273 /* Display the item */
1274 wiz_display_item(q_ptr);
1277 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1283 if (ch == 'A' || ch == 'a')
1289 if (ch == 's' || ch == 'S')
1291 wiz_statistics(q_ptr);
1294 if (ch == 'r' || ch == 'r')
1296 wiz_reroll_item(q_ptr);
1299 if (ch == 't' || ch == 'T')
1301 wiz_tweak_item(q_ptr);
1304 if (ch == 'q' || ch == 'Q')
1306 wiz_quantity_item(q_ptr);
1311 /* Restore the screen */
1319 msg_print("Changes accepted.");
1321 /* Recalcurate object's weight */
1324 p_ptr->total_weight += (q_ptr->weight * q_ptr->number)
1325 - (o_ptr->weight * o_ptr->number);
1329 object_copy(o_ptr, q_ptr);
1332 /* Recalculate bonuses */
1333 p_ptr->update |= (PU_BONUS);
1335 /* Combine / Reorder the pack (later) */
1336 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1339 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1345 msg_print("Changes ignored.");
1351 * Wizard routine for creating objects -RAK-
1352 * Heavily modified to allow magification and artifactification -Bernd-
1354 * Note that wizards cannot create objects on top of other objects.
1356 * Hack -- this routine always makes a "dungeon object", and applies
1357 * magic to it, and attempts to decline cursed items.
1359 static void wiz_create_item(void)
1367 /* Save the screen */
1370 /* Get object base type */
1371 k_idx = wiz_create_itemtype();
1373 /* Restore the screen */
1377 /* Return if failed */
1380 if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
1385 for (i = 1; i < max_a_idx; i++)
1387 /* Ignore incorrect tval */
1388 if (a_info[i].tval != k_info[k_idx].tval) continue;
1390 /* Ignore incorrect sval */
1391 if (a_info[i].sval != k_info[k_idx].sval) continue;
1393 /* Create this artifact */
1394 (void)create_named_art(i, py, px);
1397 msg_print("Allocated(INSTA_ART).");
1403 /* Get local object */
1406 /* Create the item */
1407 object_prep(q_ptr, k_idx);
1410 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
1412 /* Drop the object from heaven */
1413 (void)drop_near(q_ptr, -1, py, px);
1416 msg_print("Allocated.");
1421 * Cure everything instantly
1423 static void do_cmd_wiz_cure_all(void)
1426 (void)res_stat(A_STR);
1427 (void)res_stat(A_INT);
1428 (void)res_stat(A_WIS);
1429 (void)res_stat(A_CON);
1430 (void)res_stat(A_DEX);
1431 (void)res_stat(A_CHR);
1433 /* Restore the level */
1434 (void)restore_level();
1436 /* Heal the player */
1437 if (p_ptr->chp < p_ptr->mhp)
1439 p_ptr->chp = p_ptr->mhp;
1440 p_ptr->chp_frac = 0;
1443 p_ptr->redraw |= (PR_HP);
1446 p_ptr->window |= (PW_PLAYER);
1450 if (p_ptr->csp < p_ptr->msp)
1452 p_ptr->csp = p_ptr->msp;
1453 p_ptr->csp_frac = 0;
1455 p_ptr->redraw |= (PR_MANA);
1456 p_ptr->window |= (PW_PLAYER);
1457 p_ptr->window |= (PW_SPELL);
1462 (void)set_confused(0);
1463 (void)set_poisoned(0);
1464 (void)set_afraid(0);
1465 (void)set_paralyzed(0);
1469 (void)set_slow(0, TRUE);
1471 /* No longer hungry */
1472 (void)set_food(PY_FOOD_MAX - 1);
1479 static void do_cmd_wiz_jump(void)
1482 if (command_arg <= 0)
1487 int tmp_dungeon_type;
1490 sprintf(ppp, "Jump which dungeon : ");
1493 sprintf(tmp_val, "%d", dungeon_type);
1495 /* Ask for a level */
1496 if (!get_string(ppp, tmp_val, 2)) return;
1498 tmp_dungeon_type = atoi(tmp_val);
1499 if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
1502 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[tmp_dungeon_type].mindepth, d_info[tmp_dungeon_type].maxdepth);
1505 sprintf(tmp_val, "%d", dun_level);
1507 /* Ask for a level */
1508 if (!get_string(ppp, tmp_val, 10)) return;
1510 /* Extract request */
1511 command_arg = atoi(tmp_val);
1513 dungeon_type = tmp_dungeon_type;
1517 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1520 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1522 /* Accept request */
1523 msg_format("You jump to dungeon level %d.", command_arg);
1525 if (autosave_l) do_cmd_save_game(TRUE);
1528 dun_level = command_arg;
1530 prepare_change_floor_mode(CFM_RAND_PLACE);
1532 if (!dun_level) dungeon_type = 0;
1533 p_ptr->inside_arena = FALSE;
1534 p_ptr->wild_mode = FALSE;
1536 leave_quest_check();
1538 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1540 p_ptr->inside_quest = 0;
1543 /* Prevent energy_need from being too lower than 0 */
1544 p_ptr->energy_need = 0;
1547 * Clear all saved floors
1548 * and create a first saved floor
1550 prepare_change_floor_mode(CFM_FIRST_FLOOR);
1553 p_ptr->leaving = TRUE;
1558 * Become aware of a lot of objects
1560 static void do_cmd_wiz_learn(void)
1567 /* Scan every object */
1568 for (i = 1; i < max_k_idx; i++)
1570 object_kind *k_ptr = &k_info[i];
1572 /* Induce awareness */
1573 if (k_ptr->level <= command_arg)
1575 /* Get local object */
1578 /* Prepare object */
1579 object_prep(q_ptr, i);
1582 object_aware(q_ptr);
1589 * Summon some creatures
1591 static void do_cmd_wiz_summon(int num)
1595 for (i = 0; i < num; i++)
1597 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1603 * Summon a creature of the specified type
1605 * XXX XXX XXX This function is rather dangerous
1607 static void do_cmd_wiz_named(int r_idx)
1609 (void)summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
1614 * Summon a creature of the specified type
1616 * XXX XXX XXX This function is rather dangerous
1618 static void do_cmd_wiz_named_friendly(int r_idx)
1620 (void)summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
1626 * Hack -- Delete all nearby monsters
1628 static void do_cmd_wiz_zap(void)
1633 /* Genocide everyone nearby */
1634 for (i = 1; i < m_max; i++)
1636 monster_type *m_ptr = &m_list[i];
1638 /* Paranoia -- Skip dead monsters */
1639 if (!m_ptr->r_idx) continue;
1641 /* Skip the mount */
1642 if (i == p_ptr->riding) continue;
1644 /* Delete nearby monsters */
1645 if (m_ptr->cdis <= MAX_SIGHT)
1647 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1651 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1652 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
1655 delete_monster_idx(i);
1662 * Hack -- Delete all monsters
1664 static void do_cmd_wiz_zap_all(void)
1668 /* Genocide everyone */
1669 for (i = 1; i < m_max; i++)
1671 monster_type *m_ptr = &m_list[i];
1673 /* Paranoia -- Skip dead monsters */
1674 if (!m_ptr->r_idx) continue;
1676 /* Skip the mount */
1677 if (i == p_ptr->riding) continue;
1679 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1683 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1684 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
1687 /* Delete this monster */
1688 delete_monster_idx(i);
1694 * Create desired feature
1696 static void do_cmd_wiz_create_feature(void)
1698 static int prev_feat = 0;
1699 static int prev_mimic = 0;
1701 feature_type *f_ptr;
1703 int tmp_feat, tmp_mimic;
1706 if (!tgt_pt(&x, &y)) return;
1708 c_ptr = &cave[y][x];
1711 sprintf(tmp_val, "%d", prev_feat);
1715 if (!get_string("ÃÏ·Á: ", tmp_val, 3)) return;
1717 if (!get_string("Feature: ", tmp_val, 3)) return;
1721 tmp_feat = atoi(tmp_val);
1722 if (tmp_feat < 0) tmp_feat = 0;
1723 else if (tmp_feat >= max_f_idx) tmp_feat = max_f_idx - 1;
1726 sprintf(tmp_val, "%d", prev_mimic);
1730 if (!get_string("ÃÏ·Á (mimic): ", tmp_val, 3)) return;
1732 if (!get_string("Feature (mimic): ", tmp_val, 3)) return;
1736 tmp_mimic = atoi(tmp_val);
1737 if (tmp_mimic < 0) tmp_mimic = 0;
1738 else if (tmp_mimic >= max_f_idx) tmp_mimic = max_f_idx - 1;
1740 cave_set_feat(y, x, tmp_feat);
1741 c_ptr->mimic = tmp_mimic;
1743 f_ptr = &f_info[get_feat_mimic(c_ptr)];
1745 if (have_flag(f_ptr->flags, FF_GLYPH) ||
1746 have_flag(f_ptr->flags, FF_MINOR_GLYPH))
1747 c_ptr->info |= (CAVE_OBJECT);
1748 else if (have_flag(f_ptr->flags, FF_MIRROR))
1749 c_ptr->info |= (CAVE_GLOW | CAVE_OBJECT);
1757 /* Update some things */
1758 p_ptr->update |= (PU_FLOW);
1760 prev_feat = tmp_feat;
1761 prev_mimic = tmp_mimic;
1766 #define NUM_O_BIT 32
1769 * Hack -- Dump option bits usage
1771 static void do_cmd_dump_options(void)
1778 /* Build the filename */
1779 path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
1781 /* File type is "TEXT" */
1782 FILE_TYPE(FILE_TYPE_TEXT);
1785 fff = my_fopen(buf, "a");
1791 msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
1793 msg_format("Failed to open file %s.", buf);
1799 /* Allocate the "exist" array (2-dimension) */
1800 C_MAKE(exist, NUM_O_SET, int *);
1801 C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
1802 for (i = 1; i < NUM_O_SET; i++) exist[i] = *exist + i * NUM_O_BIT;
1804 /* Check for exist option bits */
1805 for (i = 0; option_info[i].o_desc; i++)
1807 option_type *ot_ptr = &option_info[i];
1808 if (ot_ptr->o_var) exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
1811 fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n",
1812 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1814 fputs("Set - Bit (Page) Option Name\n", fff);
1815 fputs("------------------------------------------------\n", fff);
1816 /* Dump option bits usage */
1817 for (i = 0; i < NUM_O_SET; i++)
1819 for (j = 0; j < NUM_O_BIT; j++)
1823 option_type *ot_ptr = &option_info[exist[i][j] - 1];
1824 fprintf(fff, " %d - %02d (%4d) %s\n",
1825 i, j, ot_ptr->o_page, ot_ptr->o_text);
1829 fprintf(fff, " %d - %02d\n", i, j);
1835 /* Free the "exist" array (2-dimension) */
1836 C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
1837 C_KILL(exist, NUM_O_SET, int *);
1843 msg_format("¥ª¥×¥·¥ç¥óbit»ÈÍѾõ¶·¤ò¥Õ¥¡¥¤¥ë %s ¤Ë½ñ¤½Ð¤·¤Þ¤·¤¿¡£", buf);
1845 msg_format("Option bits usage dump saved to file %s.", buf);
1850 #ifdef ALLOW_SPOILERS
1855 extern void do_cmd_spoilers(void);
1857 #endif /* ALLOW_SPOILERS */
1862 * Hack -- declare external function
1864 extern void do_cmd_debug(void);
1869 * Ask for and parse a "debug command"
1870 * The "command_arg" may have been set.
1872 void do_cmd_debug(void)
1878 /* Get a "debug command" */
1879 get_com("Debug Command: ", &cmd, FALSE);
1881 /* Analyze the command */
1891 #ifdef ALLOW_SPOILERS
1893 /* Hack -- Generate Spoilers */
1898 #endif /* ALLOW_SPOILERS */
1905 /* Cure all maladies */
1907 do_cmd_wiz_cure_all();
1910 /* Know alignment */
1912 msg_format("Your alignment is %d.", p_ptr->align);
1915 /* Teleport to target */
1924 /* Create any object */
1929 /* Create a named artifact */
1931 wiz_create_named_art(command_arg);
1934 /* Detect everything */
1936 detect_all(DETECT_RAD_ALL * 3);
1939 /* Dimension_door */
1941 wiz_dimension_door();
1944 /* Edit character */
1946 do_cmd_wiz_change();
1949 /* Blue Mage Only */
1951 if (p_ptr->pclass == CLASS_BLUE_MAGE)
1953 do_cmd_wiz_blue_mage();
1957 /* View item info */
1959 identify_fully(FALSE);
1962 /* Create desired feature */
1964 do_cmd_wiz_create_feature();
1969 if (command_arg <= 0) command_arg = 1;
1970 acquirement(py, px, command_arg, FALSE, TRUE);
1973 /* Hitpoint rerating */
1975 do_cmd_rerate(TRUE);
1978 #ifdef MONSTER_HORDES
1980 do_cmd_summon_horde();
1982 #endif /* MONSTER_HORDES */
1986 (void)ident_spell(FALSE);
1989 /* Go up or down in the dungeon */
1994 /* Self-Knowledge */
1999 /* Learn about objects */
2006 map_area(DETECT_RAD_ALL * 3);
2011 (void)gain_random_mutation(command_arg);
2014 /* Specific reward */
2016 (void)gain_level_reward(command_arg);
2019 /* Summon _friendly_ named monster */
2021 do_cmd_wiz_named_friendly(command_arg);
2024 /* Summon Named Monster */
2026 do_cmd_wiz_named(command_arg);
2029 /* Dump option bits usage */
2031 do_cmd_dump_options();
2034 /* Object playing routines */
2041 teleport_player(10, 0L);
2045 /* Complete a Quest -KMW- */
2047 for (i = 0; i < max_quests; i++)
2049 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
2051 p_ptr->quest[i].status++;
2052 msg_print("Completed Quest");
2057 if (i == max_quests)
2059 msg_print("No current quest");
2065 /* Make every dungeon square "known" to test streamers -KMW- */
2067 for (y = 0; y < cur_hgt; y++)
2069 for (x = 0; x < cur_wid; x++)
2071 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
2077 /* Summon Random Monster(s) */
2079 if (command_arg <= 0) command_arg = 1;
2080 do_cmd_wiz_summon(command_arg);
2085 teleport_player(100, 0L);
2088 /* Very Good Objects */
2090 if (command_arg <= 0) command_arg = 1;
2091 acquirement(py, px, command_arg, TRUE, TRUE);
2094 /* Wizard Light the Level */
2096 wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
2099 /* Increase Experience */
2101 gain_exp(command_arg ? command_arg : (p_ptr->exp + 1));
2104 /* Zap Monsters (Genocide) */
2109 /* Zap Monsters (Omnicide) */
2111 do_cmd_wiz_zap_all();
2114 /* Hack -- whatever I desire */
2116 do_cmd_wiz_hack_ben();
2119 /* Not a Wizard Command */
2121 msg_print("That is not a valid debug command.");