3 /* Purpose: Wizard commands */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
17 * Hack -- Rerate Hitpoints
19 void do_cmd_rerate(bool display)
21 int min_value, max_value, i, percent, j;
23 min_value = ((PY_MAX_LEVEL+2) * (p_ptr->hitdie + 1)) * 3 / 8;
24 min_value += p_ptr->hitdie;
26 max_value = ((PY_MAX_LEVEL+2) * (p_ptr->hitdie + 1)) * 5 / 8;
27 max_value += p_ptr->hitdie;
32 player_hp[0] = p_ptr->hitdie;
34 for (i = 1; i < 4; i++)
36 j = randint1(p_ptr->hitdie);
41 for (i = 1; i < PY_MAX_LEVEL; i++)
43 player_hp[i] = randint1(p_ptr->hitdie);
44 player_hp[i] += player_hp[i - 1];
48 if ((player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
49 (player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
52 percent = (int)(((long)player_hp[PY_MAX_LEVEL - 1] * 200L) /
54 ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
57 /* Update and redraw hitpoints */
58 p_ptr->update |= (PU_HP);
59 p_ptr->redraw |= (PR_HP);
62 p_ptr->window |= (PW_PLAYER);
71 msg_format("¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯¤Ï %d/100 ¤Ç¤¹¡£", percent);
73 msg_format("Your life rate is %d/100 now.", percent);
75 p_ptr->knowledge |= KNOW_HPRATE;
80 msg_print("ÂÎÎÏ¥é¥ó¥¯¤¬ÊѤï¤Ã¤¿¡£");
82 msg_print("Life rate is changed.");
84 p_ptr->knowledge &= ~(KNOW_HPRATE);
94 static bool wiz_dimension_door(void)
98 if (!tgt_pt(&x, &y)) return FALSE;
100 if (!cave_empty_bold(y, x))
103 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
105 msg_print("You fail to exit the astral plane correctly!");
110 else teleport_player_to(y, x, FALSE);
117 * Create the artifact of the specified number -- DAN
120 static void wiz_create_named_art(int a_idx)
122 /* Create the artifact */
123 create_named_art(a_idx, py, px);
126 msg_print("Allocated.");
131 * Hack -- quick debugging hook
133 static void do_cmd_wiz_hack_ben(void)
142 #ifdef MONSTER_HORDES
144 /* Summon a horde of monsters */
145 static void do_cmd_summon_horde(void)
147 int wy = py, wx = px;
152 scatter(&wy, &wx, py, px, 3, 0);
153 if (cave_naked_bold(wy, wx)) break;
156 (void)alloc_horde(wy, wx);
159 #endif /* MONSTER_HORDES */
163 * Output a long int in binary format.
165 static void prt_binary(u32b flags, int row, int col)
171 for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
176 Term_putch(col++, row, TERM_BLUE, '*');
179 /* Dump unset bits */
182 Term_putch(col++, row, TERM_WHITE, '-');
188 #define K_MAX_DEPTH 110
191 * Output a rarity graph for a type of object.
193 static void prt_alloc(byte tval, byte sval, int row, int col)
197 u32b maxr = 1, maxt = 1, ratio;
198 u32b rarity[K_MAX_DEPTH];
199 u32b total[K_MAX_DEPTH];
200 s32b maxd = 1, display[22];
202 cptr r = "+--common--+";
207 alloc_entry *table = alloc_kind_table;
209 /* Wipe the tables */
210 (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
211 (void)C_WIPE(total, K_MAX_DEPTH, u32b);
212 (void)C_WIPE(display, 22, s32b);
214 /* Scan all entries */
215 for (i = 0; i < K_MAX_DEPTH; i++)
218 for (j = 0; j < alloc_kind_size; j++)
222 if (table[j].level <= i)
224 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
226 else if (table[j].level - 1 > 0)
228 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
231 /* Acquire this kind */
232 k_ptr = &k_info[table[j].index];
234 /* Accumulate probabilities */
235 total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
236 total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
238 /* Accumulate probabilities */
239 if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
245 total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
249 for (i = 0; i < K_MAX_DEPTH; i++)
251 if (rarity[i] > maxr) maxr = rarity[i];
252 if (total[i] > maxt) maxt = total[i];
255 if (maxr / (GREAT_OBJ * K_MAX_DEPTH) != 0)
256 ratio = maxt / (maxr / (GREAT_OBJ * K_MAX_DEPTH));
260 /* Simulate a log graph */
277 /* Calculate probabilities for each range */
278 for (i = 0; i < 22; i++)
280 /* Shift the values into view */
283 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
284 possibility += rarity[j] * (100 * maxt / total[j]);
286 possibility = possibility / maxr;
288 /* display[i] = log_{sqrt(2)}(possibility) */
293 possibility = possibility * 1000 / 1414;
297 if (display[i] > maxd) maxd = display[i];
301 if (maxd > 10) for (i = 0; i < 22; i++)
303 display[i] = display[i] - maxd + 10;
306 /* Graph the rarities */
307 for (i = 0; i < 22; i++)
309 Term_putch(col, row + i + 1, TERM_WHITE, '|');
311 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
317 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
319 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
323 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
327 /* Make it look nice */
333 * Hack -- Teleport to the target
335 static void do_cmd_wiz_bamf(void)
337 /* Must have a target */
338 if (!target_who) return;
340 /* Teleport to the target */
341 teleport_player_to(target_row, target_col, FALSE);
346 * Aux function for "do_cmd_wiz_change()". -RAK-
348 static void do_cmd_wiz_change_aux(void)
358 /* Query the stats */
359 for (i = 0; i < 6; i++)
362 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
365 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
368 if (!get_string(ppp, tmp_val, 3)) return;
371 tmp_int = atoi(tmp_val);
374 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
375 else if (tmp_int < 3) tmp_int = 3;
378 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
383 sprintf(tmp_val, "8000");
387 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
389 if (!get_string("Proficiency: ", tmp_val, 9)) return;
393 tmp_s16b = atoi(tmp_val);
396 if (tmp_s16b < 0) tmp_s16b = 0L;
397 if (tmp_s16b > 8000) tmp_s16b = 8000L;
399 for (j = 0; j <= TV_SWORD - TV_BOW;j++)
401 for (i = 0;i < 64;i++)
403 weapon_exp[j][i] = tmp_s16b;
404 if (weapon_exp[j][i] > s_info[p_ptr->pclass].w_max[j][i]) weapon_exp[j][i] = s_info[p_ptr->pclass].w_max[j][i];
408 for (j = 0; j < 10; j++)
410 skill_exp[j] = tmp_s16b;
411 if (skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
414 for (j = 0; j < 32; j++)
415 spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
417 spell_exp[j] = (tmp_s16b > 1400 ? 1400 : tmp_s16b);
420 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
423 if (!get_string("Gold: ", tmp_val, 9)) return;
426 tmp_long = atol(tmp_val);
429 if (tmp_long < 0) tmp_long = 0L;
432 p_ptr->au = tmp_long;
436 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
439 if (!get_string("Experience: ", tmp_val, 9)) return;
442 tmp_long = atol(tmp_val);
445 if (tmp_long < 0) tmp_long = 0L;
447 if (p_ptr->prace != RACE_ANDROID)
450 p_ptr->max_exp = tmp_long;
451 p_ptr->exp = tmp_long;
460 * Change various "permanent" player variables.
462 static void do_cmd_wiz_change(void)
465 do_cmd_wiz_change_aux();
467 /* Redraw everything */
473 * Wizard routines for creating objects -RAK-
474 * And for manipulating them! -Bernd-
476 * This has been rewritten to make the whole procedure
477 * of debugging objects much easier and more comfortable.
479 * The following functions are meant to play with objects:
480 * Create, modify, roll for them (for statistic purposes) and more.
481 * The original functions were by RAK.
482 * The function to show an item's debug information was written
483 * by David Reeve Sward <sward+@CMU.EDU>.
484 * Bernd (wiebelt@mathematik.hu-berlin.de)
486 * Here are the low-level functions
487 * - wiz_display_item()
488 * display an item's debug-info
489 * - wiz_create_itemtype()
490 * specify tval and sval (type and subtype of object)
492 * specify pval, +AC, +tohit, +todam
493 * Note that the wizard can leave this function anytime,
494 * thus accepting the default-values for the remaining values.
495 * pval comes first now, since it is most important.
496 * - wiz_reroll_item()
497 * apply some magic to the item or turn it into an artifact.
499 * Get some statistics about the rarity of an item:
500 * We create a lot of fake items and see if they are of the
501 * same type (tval and sval), then we compare pval and +AC.
502 * If the fake-item is better or equal it is counted.
503 * Note that cursed items that are better or equal (absolute values)
505 * HINT: This is *very* useful for balancing the game!
506 * - wiz_quantity_item()
507 * change the quantity of an item, but be sane about it.
509 * And now the high-level functions
510 * - do_cmd_wiz_play()
511 * play with an existing object
512 * - wiz_create_item()
513 * create a new object
515 * Note -- You do not have to specify "pval" and other item-properties
516 * directly. Just apply magic until you are satisfied with the item.
518 * Note -- For some items (such as wands, staffs, some rings, etc), you
519 * must apply magic, or you will get "broken" or "uncharged" objects.
521 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
522 * the artifact. Be careful.
524 * Hack -- this function will allow you to create multiple artifacts.
525 * This "feature" may induce crashes or other nasty effects.
529 * Just display an item's properties (debug-info)
530 * Originally by David Reeve Sward <sward+@CMU.EDU>
531 * Verbose item flags by -Bernd-
533 static void wiz_display_item(object_type *o_ptr)
539 /* Extract the flags */
540 object_flags(o_ptr, &f1, &f2, &f3);
542 /* Clear the screen */
543 for (i = 1; i <= 23; i++) prt("", i, j - 2);
545 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
548 object_desc_store(buf, o_ptr, TRUE, 3);
552 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
553 o_ptr->k_idx, get_object_level(o_ptr),
554 o_ptr->tval, o_ptr->sval), 4, j);
556 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
557 o_ptr->number, o_ptr->weight,
558 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
560 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
561 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
563 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
564 o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
566 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
567 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
569 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d cursed = %-d",
570 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
572 prt("+------------FLAGS1------------+", 10, j);
573 prt("AFFECT........SLAY........BRAND.", 11, j);
574 prt(" mf cvae xsqpaefc", 12, j);
575 prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
576 prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
577 prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
578 prt_binary(f1, 16, j);
580 prt("+------------FLAGS2------------+", 17, j);
581 prt("SUST....IMMUN.RESIST............", 18, j);
582 prt(" r aefctrpsaefcpfldbc sn ", 19, j);
583 prt("siwdcci clioheatcliooeialoshtncd", 20, j);
584 prt("tnieohd ierlrfraierliatrnnnrhehi", 21, j);
585 prt("rtsxnae.dcedwlatdcedsrekdfddrxss", 22, j);
586 prt_binary(f2, 23, j);
588 prt("+------------FLAGS3------------+", 10, j+32);
589 prt("fe cnn t stdrmsiiii d ab ", 11, j+32);
590 prt("aa aoomywhs lleeieihgggg rtgl ", 12, j+32);
591 prt("uu utmacaih eielgggonnnnaaere ", 13, j+32);
592 prt("rr reanurdo vtieeehtrrrrcilas ", 14, j+32);
593 prt("aa algarnew ienpsntsaefctnevs ", 15, j+32);
594 prt_binary(f3, 16, j+32);
599 * A structure to hold a tval and its description
601 typedef struct tval_desc
608 * A list of tvals and their textual names
610 static tval_desc tvals[] =
612 { TV_SWORD, "Sword" },
613 { TV_POLEARM, "Polearm" },
614 { TV_HAFTED, "Hafted Weapon" },
616 { TV_ARROW, "Arrows" },
617 { TV_BOLT, "Bolts" },
618 { TV_SHOT, "Shots" },
619 { TV_SHIELD, "Shield" },
620 { TV_CROWN, "Crown" },
622 { TV_GLOVES, "Gloves" },
623 { TV_BOOTS, "Boots" },
624 { TV_CLOAK, "Cloak" },
625 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
626 { TV_HARD_ARMOR, "Hard Armor" },
627 { TV_SOFT_ARMOR, "Soft Armor" },
629 { TV_AMULET, "Amulet" },
631 { TV_POTION, "Potion" },
632 { TV_SCROLL, "Scroll" },
634 { TV_STAFF, "Staff" },
636 { TV_LIFE_BOOK, "Life Spellbook" },
637 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
638 { TV_NATURE_BOOK, "Nature Spellbook" },
639 { TV_CHAOS_BOOK, "Chaos Spellbook" },
640 { TV_DEATH_BOOK, "Death Spellbook" },
641 { TV_TRUMP_BOOK, "Trump Spellbook" },
642 { TV_ARCANE_BOOK, "Arcane Spellbook" },
643 { TV_ENCHANT_BOOK, "Craft Spellbook"},
644 { TV_DAEMON_BOOK, "Daemon Spellbook"},
645 { TV_HAJA_BOOK, "Crusade Spellbook"},
646 { TV_MUSIC_BOOK, "Music Spellbook" },
647 { TV_HISSATSU_BOOK, "Book of Kendo" },
648 { TV_PARCHEMENT, "Parchement" },
649 { TV_WHISTLE, "Whistle" },
650 { TV_SPIKE, "Spikes" },
651 { TV_DIGGING, "Digger" },
652 { TV_CHEST, "Chest" },
653 { TV_CAPTURE, "Capture Ball" },
654 { TV_CARD, "Express Card" },
655 { TV_FIGURINE, "Magical Figurine" },
656 { TV_STATUE, "Statue" },
657 { TV_CORPSE, "Corpse" },
659 { TV_FLASK, "Flask" },
661 { TV_SKELETON, "Skeleton" },
667 * Strip an "object name" into a buffer
669 void strip_name(char *buf, int k_idx)
673 object_kind *k_ptr = &k_info[k_idx];
675 cptr str = (k_name + k_ptr->name);
678 /* Skip past leading characters */
679 while ((*str == ' ') || (*str == '&')) str++;
681 /* Copy useful chars */
682 for (t = buf; *str; str++)
685 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
687 if (*str != '~') *t++ = *str;
690 /* Terminate the new name */
696 * Specify tval and sval (type and subtype of object) originally
697 * by RAK, heavily modified by -Bernd-
699 * This function returns the k_idx of an object type, or zero if failed
701 * List up to 50 choices in three columns
703 static int wiz_create_itemtype(void)
720 /* Print all tval's and their descriptions */
721 for (num = 0; (num < 80) && tvals[num].tval; num++)
723 row = 2 + (num % 20);
724 col = 20 * (num / 20);
726 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
729 /* Me need to know the maximal possible tval_index */
733 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
736 for (num = 0; num < max_num; num++)
738 if (listsym[num] == ch) break;
741 /* Bail out if choice is illegal */
742 if ((num < 0) || (num >= max_num)) return (0);
744 /* Base object type chosen, fill in tval */
745 tval = tvals[num].tval;
746 tval_desc = tvals[num].desc;
749 /*** And now we go for k_idx ***/
754 /* We have to search the whole itemlist. */
755 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
757 object_kind *k_ptr = &k_info[i];
759 /* Analyze matching items */
760 if (k_ptr->tval == tval)
763 row = 2 + (num % 20);
764 col = 20 * (num / 20);
768 /* Acquire the "name" of object "i" */
772 prt(format("[%c] %s", ch, buf), row, col);
774 /* Remember the object index */
779 /* Me need to know the maximal possible remembered object_index */
783 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
786 for (num = 0; num < max_num; num++)
788 if (listsym[num] == ch) break;
791 /* Bail out if choice is "illegal" */
792 if ((num < 0) || (num >= max_num)) return (0);
794 /* And return successful */
795 return (choice[num]);
802 static void wiz_tweak_item(object_type *o_ptr)
808 /* Hack -- leave artifacts alone */
809 if (artifact_p(o_ptr) || o_ptr->art_name) return;
811 p = "Enter new 'pval' setting: ";
812 sprintf(tmp_val, "%d", o_ptr->pval);
813 if (!get_string(p, tmp_val, 5)) return;
814 o_ptr->pval = atoi(tmp_val);
815 wiz_display_item(o_ptr);
817 p = "Enter new 'to_a' setting: ";
818 sprintf(tmp_val, "%d", o_ptr->to_a);
819 if (!get_string(p, tmp_val, 5)) return;
820 o_ptr->to_a = atoi(tmp_val);
821 wiz_display_item(o_ptr);
823 p = "Enter new 'to_h' setting: ";
824 sprintf(tmp_val, "%d", o_ptr->to_h);
825 if (!get_string(p, tmp_val, 5)) return;
826 o_ptr->to_h = atoi(tmp_val);
827 wiz_display_item(o_ptr);
829 p = "Enter new 'to_d' setting: ";
830 sprintf(tmp_val, "%d", o_ptr->to_d);
831 if (!get_string(p, tmp_val, 5)) return;
832 o_ptr->to_d = atoi(tmp_val);
833 wiz_display_item(o_ptr);
838 * Apply magic to an item or turn it into an artifact. -Bernd-
840 static void wiz_reroll_item(object_type *o_ptr)
847 bool changed = FALSE;
850 /* Hack -- leave artifacts alone */
851 if (artifact_p(o_ptr) || o_ptr->art_name) return;
854 /* Get local object */
857 /* Copy the object */
858 object_copy(q_ptr, o_ptr);
861 /* Main loop. Ask for magification and artifactification */
864 /* Display full item debug information */
865 wiz_display_item(q_ptr);
867 /* Ask wizard what to do. */
868 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
870 /* Preserve wizard-generated artifacts */
871 if (artifact_p(q_ptr))
873 a_info[q_ptr->name1].cur_num = 0;
881 /* Create/change it! */
882 if (ch == 'A' || ch == 'a')
888 /* Preserve wizard-generated artifacts */
889 if (artifact_p(q_ptr))
891 a_info[q_ptr->name1].cur_num = 0;
897 /* Apply bad magic, but first clear object */
900 object_prep(q_ptr, o_ptr->k_idx);
901 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
904 /* Apply bad magic, but first clear object */
907 object_prep(q_ptr, o_ptr->k_idx);
908 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
911 /* Apply normal magic, but first clear object */
914 object_prep(q_ptr, o_ptr->k_idx);
915 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
918 /* Apply good magic, but first clear object */
921 object_prep(q_ptr, o_ptr->k_idx);
922 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
925 /* Apply great magic, but first clear object */
928 object_prep(q_ptr, o_ptr->k_idx);
929 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
934 object_prep(q_ptr, o_ptr->k_idx);
935 apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
937 /* Failed to create normal artifact; make a random one */
938 if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
942 q_ptr->iy = o_ptr->iy;
943 q_ptr->ix = o_ptr->ix;
944 q_ptr->next_o_idx = o_ptr->next_o_idx;
945 q_ptr->marked = o_ptr->marked;
953 object_copy(o_ptr, q_ptr);
955 /* Recalculate bonuses */
956 p_ptr->update |= (PU_BONUS);
958 /* Combine / Reorder the pack (later) */
959 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
962 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
969 * Try to create an item again. Output some statistics. -Bernd-
971 * The statistics are correct now. We acquire a clean grid, and then
972 * repeatedly place an object in this grid, copying it into an item
973 * holder, and then deleting the object. We fiddle with the artifact
974 * counter flags to prevent weirdness. We use the items to collect
975 * statistics on item creation relative to the initial item.
977 static void wiz_statistics(object_type *o_ptr)
979 u32b i, matches, better, worse, other, correct;
981 u32b test_roll = 1000000;
991 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
993 cptr p = "Enter number of items to roll: ";
997 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
998 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
1004 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
1007 wiz_display_item(o_ptr);
1010 if (!get_com(pmt, &ch, FALSE)) break;
1012 if (ch == 'n' || ch == 'N')
1018 else if (ch == 'g' || ch == 'G')
1024 else if (ch == 'e' || ch == 'E')
1028 quality = "excellent";
1037 sprintf(tmp_val, "%ld", test_roll);
1038 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1039 test_roll = MAX(1, test_roll);
1041 /* Let us know what we are doing */
1042 msg_format("Creating a lot of %s items. Base level = %d.",
1043 quality, dun_level);
1046 /* Set counters to zero */
1047 correct = matches = better = worse = other = 0;
1049 /* Let's rock and roll */
1050 for (i = 0; i <= test_roll; i++)
1052 /* Output every few rolls */
1053 if ((i < 100) || (i % 100 == 0))
1058 /* Allow interupt */
1068 /* Dump the stats */
1069 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1074 /* Get local object */
1077 /* Wipe the object */
1080 /* Create an object */
1081 make_object(q_ptr, good, great);
1084 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1085 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1088 /* Test for the same tval and sval. */
1089 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1090 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1092 /* One more correct item */
1095 /* Check for match */
1096 if ((q_ptr->pval == o_ptr->pval) &&
1097 (q_ptr->to_a == o_ptr->to_a) &&
1098 (q_ptr->to_h == o_ptr->to_h) &&
1099 (q_ptr->to_d == o_ptr->to_d) &&
1100 (q_ptr->name1 == o_ptr->name1))
1105 /* Check for better */
1106 else if ((q_ptr->pval >= o_ptr->pval) &&
1107 (q_ptr->to_a >= o_ptr->to_a) &&
1108 (q_ptr->to_h >= o_ptr->to_h) &&
1109 (q_ptr->to_d >= o_ptr->to_d))
1114 /* Check for worse */
1115 else if ((q_ptr->pval <= o_ptr->pval) &&
1116 (q_ptr->to_a <= o_ptr->to_a) &&
1117 (q_ptr->to_h <= o_ptr->to_h) &&
1118 (q_ptr->to_d <= o_ptr->to_d))
1123 /* Assume different */
1131 msg_format(q, i, correct, matches, better, worse, other);
1136 /* Hack -- Normally only make a single artifact */
1137 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1142 * Change the quantity of a the item
1144 static void wiz_quantity_item(object_type *o_ptr)
1146 int tmp_int, tmp_qnt;
1151 /* Never duplicate artifacts */
1152 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1154 /* Store old quantity. -LM- */
1155 tmp_qnt = o_ptr->number;
1158 sprintf(tmp_val, "%d", o_ptr->number);
1161 if (get_string("Quantity: ", tmp_val, 2))
1164 tmp_int = atoi(tmp_val);
1167 if (tmp_int < 1) tmp_int = 1;
1168 if (tmp_int > 99) tmp_int = 99;
1170 /* Accept modifications */
1171 o_ptr->number = tmp_int;
1173 /* Hack -- rod pvals must change if the number in the stack does. -LM- */
1174 if (o_ptr->tval == TV_ROD)
1175 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1182 * Play with an item. Options include:
1183 * - Output statistics (via wiz_roll_item)
1184 * - Reroll item (via wiz_reroll_item)
1185 * - Change properties (via wiz_tweak_item)
1186 * - Change the number of items (via wiz_quantity_item)
1188 static void do_cmd_wiz_play(void)
1203 item_tester_no_ryoute = TRUE;
1205 q = "Play with which object? ";
1206 s = "You have nothing to play with.";
1207 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1209 /* Get the item (in the pack) */
1212 o_ptr = &inventory[item];
1215 /* Get the item (on the floor) */
1218 o_ptr = &o_list[0 - item];
1222 /* The item was not changed */
1226 /* Save the screen */
1230 /* Get local object */
1234 object_copy(q_ptr, o_ptr);
1240 /* Display the item */
1241 wiz_display_item(q_ptr);
1244 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1250 if (ch == 'A' || ch == 'a')
1256 if (ch == 's' || ch == 'S')
1258 wiz_statistics(q_ptr);
1261 if (ch == 'r' || ch == 'r')
1263 wiz_reroll_item(q_ptr);
1266 if (ch == 't' || ch == 'T')
1268 wiz_tweak_item(q_ptr);
1271 if (ch == 'q' || ch == 'Q')
1273 wiz_quantity_item(q_ptr);
1278 /* Restore the screen */
1286 msg_print("Changes accepted.");
1289 object_copy(o_ptr, q_ptr);
1291 /* Recalculate bonuses */
1292 p_ptr->update |= (PU_BONUS);
1294 /* Combine / Reorder the pack (later) */
1295 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1298 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1304 msg_print("Changes ignored.");
1310 * Wizard routine for creating objects -RAK-
1311 * Heavily modified to allow magification and artifactification -Bernd-
1313 * Note that wizards cannot create objects on top of other objects.
1315 * Hack -- this routine always makes a "dungeon object", and applies
1316 * magic to it, and attempts to decline cursed items.
1318 static void wiz_create_item(void)
1326 /* Save the screen */
1329 /* Get object base type */
1330 k_idx = wiz_create_itemtype();
1332 /* Restore the screen */
1336 /* Return if failed */
1339 /* Get local object */
1342 /* Create the item */
1343 object_prep(q_ptr, k_idx);
1345 if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
1350 for (i = 1; i < max_a_idx; i++)
1352 /* Ignore incorrect tval */
1353 if (a_info[i].tval != q_ptr->tval) continue;
1355 /* Ignore incorrect sval */
1356 if (a_info[i].sval != q_ptr->sval) continue;
1358 /* Choose this artifact */
1364 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1369 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
1372 /* Drop the object from heaven */
1373 (void)drop_near(q_ptr, -1, py, px);
1376 msg_print("Allocated.");
1381 * Cure everything instantly
1383 static void do_cmd_wiz_cure_all(void)
1386 // (void)remove_all_curse();
1389 (void)res_stat(A_STR);
1390 (void)res_stat(A_INT);
1391 (void)res_stat(A_WIS);
1392 (void)res_stat(A_CON);
1393 (void)res_stat(A_DEX);
1394 (void)res_stat(A_CHR);
1396 /* Restore the level */
1397 (void)restore_level();
1399 /* Heal the player */
1400 p_ptr->chp = p_ptr->mhp;
1401 p_ptr->chp_frac = 0;
1404 if (p_ptr->csp < p_ptr->msp)
1406 p_ptr->csp = p_ptr->msp;
1407 p_ptr->csp_frac = 0;
1412 (void)set_confused(0);
1413 (void)set_poisoned(0);
1414 (void)set_afraid(0);
1415 (void)set_paralyzed(0);
1419 (void)set_slow(0, TRUE);
1421 /* No longer hungry */
1422 (void)set_food(PY_FOOD_MAX - 1);
1424 /* Redraw everything */
1432 static void do_cmd_wiz_jump(void)
1435 if (command_arg <= 0)
1442 sprintf(ppp, "Jump which dungeon : ");
1445 sprintf(tmp_val, "%d", dungeon_type);
1447 /* Ask for a level */
1448 if (!get_string(ppp, tmp_val, 2)) return;
1450 dungeon_type = atoi(tmp_val);
1451 if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
1454 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
1457 sprintf(tmp_val, "%d", dun_level);
1459 /* Ask for a level */
1460 if (!get_string(ppp, tmp_val, 10)) return;
1462 /* Extract request */
1463 command_arg = atoi(tmp_val);
1467 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1470 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1472 /* Accept request */
1473 msg_format("You jump to dungeon level %d.", command_arg);
1475 if (autosave_l) do_cmd_save_game(TRUE);
1478 dun_level = command_arg;
1480 if (!dun_level) dungeon_type = 0;
1481 p_ptr->inside_arena = FALSE;
1483 leave_quest_check();
1485 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1487 p_ptr->inside_quest = 0;
1488 p_ptr->leftbldg = FALSE;
1492 p_ptr->leaving = TRUE;
1497 * Become aware of a lot of objects
1499 static void do_cmd_wiz_learn(void)
1506 /* Scan every object */
1507 for (i = 1; i < max_k_idx; i++)
1509 object_kind *k_ptr = &k_info[i];
1511 /* Induce awareness */
1512 if (k_ptr->level <= command_arg)
1514 /* Get local object */
1517 /* Prepare object */
1518 object_prep(q_ptr, i);
1521 object_aware(q_ptr);
1528 * Summon some creatures
1530 static void do_cmd_wiz_summon(int num)
1534 for (i = 0; i < num; i++)
1536 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1542 * Summon a creature of the specified type
1544 * XXX XXX XXX This function is rather dangerous
1546 static void do_cmd_wiz_named(int r_idx)
1551 /* if (!r_idx) return; */
1553 /* Prevent illegal monsters */
1554 if (r_idx >= max_r_idx) return;
1557 for (i = 0; i < 10; i++)
1561 /* Pick a location */
1562 scatter(&y, &x, py, px, d, 0);
1564 /* Require empty grids */
1565 if (!cave_empty_bold(y, x)) continue;
1567 /* Place it (allow groups) */
1568 if (place_monster_aux(0, y, x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP))) break;
1574 * Summon a creature of the specified type
1576 * XXX XXX XXX This function is rather dangerous
1578 static void do_cmd_wiz_named_friendly(int r_idx)
1580 (void) summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
1586 * Hack -- Delete all nearby monsters
1588 static void do_cmd_wiz_zap(void)
1593 /* Genocide everyone nearby */
1594 for (i = 1; i < m_max; i++)
1596 monster_type *m_ptr = &m_list[i];
1598 /* Paranoia -- Skip dead monsters */
1599 if (!m_ptr->r_idx) continue;
1601 /* Delete nearby monsters */
1602 if (m_ptr->cdis <= MAX_SIGHT)
1604 if (i == p_ptr->riding)
1607 p_ptr->redraw |= (PR_EXTRA);
1609 delete_monster_idx(i);
1616 * Hack -- Delete all monsters
1618 static void do_cmd_wiz_zap_all(void)
1622 /* Genocide everyone */
1623 for (i = 1; i < m_max; i++)
1625 monster_type *m_ptr = &m_list[i];
1627 /* Paranoia -- Skip dead monsters */
1628 if (!m_ptr->r_idx) continue;
1630 if (i == p_ptr->riding)
1633 p_ptr->redraw |= (PR_EXTRA);
1636 /* Delete this monster */
1637 delete_monster_idx(i);
1642 #ifdef ALLOW_SPOILERS
1647 extern void do_cmd_spoilers(void);
1649 #endif /* ALLOW_SPOILERS */
1654 * Hack -- declare external function
1656 extern void do_cmd_debug(void);
1661 * Ask for and parse a "debug command"
1662 * The "command_arg" may have been set.
1664 void do_cmd_debug(void)
1670 /* Get a "debug command" */
1671 get_com("Debug Command: ", &cmd, FALSE);
1673 /* Analyze the command */
1684 #ifdef ALLOW_SPOILERS
1686 /* Hack -- Generate Spoilers */
1691 #endif /* ALLOW_SPOILERS */
1700 /* Cure all maladies */
1702 do_cmd_wiz_cure_all();
1705 /* Know alignment */
1707 msg_format("Your alignment is %d.", p_ptr->align);
1710 /* Teleport to target */
1719 /* Create any object */
1724 /* Create a named artifact */
1726 wiz_create_named_art(command_arg);
1729 /* Detect everything */
1731 detect_all(DETECT_RAD_ALL*3);
1734 /* Dimension_door */
1736 wiz_dimension_door();
1739 /* Edit character */
1741 do_cmd_wiz_change();
1744 /* View item info */
1746 identify_fully(FALSE);
1751 if (command_arg <= 0) command_arg = 1;
1752 acquirement(py, px, command_arg, FALSE, TRUE);
1755 /* Hitpoint rerating */
1757 do_cmd_rerate(TRUE); break;
1759 #ifdef MONSTER_HORDES
1761 do_cmd_summon_horde(); break;
1762 #endif /* MONSTER_HORDES */
1766 (void)ident_spell(FALSE);
1769 /* Go up or down in the dungeon */
1774 /* Self-Knowledge */
1779 /* Learn about objects */
1786 map_area(DETECT_RAD_ALL);
1791 (void)gain_random_mutation(command_arg);
1794 /* Specific reward */
1796 (void)gain_level_reward(command_arg);
1799 /* Summon _friendly_ named monster */
1801 do_cmd_wiz_named_friendly(command_arg);
1804 /* Summon Named Monster */
1806 do_cmd_wiz_named(command_arg);
1809 /* Object playing routines */
1816 teleport_player(10);
1820 /* Complete a Quest -KMW- */
1823 for (i = 0; i < max_quests; i++)
1825 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1827 p_ptr->quest[i].status++;
1828 msg_print("Completed Quest");
1833 if (i == max_quests)
1835 msg_print("No current quest");
1842 /* Make every dungeon square "known" to test streamers -KMW- */
1845 for(y = 0; y < cur_hgt; y++)
1847 for(x = 0; x < cur_wid; x++)
1849 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1852 wiz_lite(TRUE, FALSE);
1856 /* Summon Random Monster(s) */
1858 if (command_arg <= 0) command_arg = 1;
1859 do_cmd_wiz_summon(command_arg);
1864 teleport_player(100);
1867 /* Very Good Objects */
1869 if (command_arg <= 0) command_arg = 1;
1870 acquirement(py, px, command_arg, TRUE, TRUE);
1873 /* Wizard Light the Level */
1875 wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
1878 /* Increase Experience */
1882 gain_exp(command_arg);
1886 gain_exp(p_ptr->exp + 1);
1890 /* Zap Monsters (Genocide) */
1896 do_cmd_wiz_zap_all();
1899 /* Hack -- whatever I desire */
1901 do_cmd_wiz_hack_ben();
1904 /* Not a Wizard Command */
1906 msg_print("That is not a valid debug command.");