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 p_ptr->player_hp[0] = p_ptr->hitdie;
34 for (i = 1; i < 4; i++)
36 j = randint1(p_ptr->hitdie);
37 p_ptr->player_hp[0] += j;
41 for (i = 1; i < PY_MAX_LEVEL; i++)
43 p_ptr->player_hp[i] = randint1(p_ptr->hitdie);
44 p_ptr->player_hp[i] += p_ptr->player_hp[i - 1];
48 if ((p_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
49 (p_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
52 percent = (int)(((long)p_ptr->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 p_ptr->weapon_exp[j][i] = tmp_s16b;
404 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];
408 for (j = 0; j < 10; j++)
410 p_ptr->skill_exp[j] = tmp_s16b;
411 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];
414 for (j = 0; j < 32; j++)
415 p_ptr->spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
417 p_ptr->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)
536 u32b flgs[TR_FLAG_SIZE];
539 /* Extract the flags */
540 object_flags(o_ptr, flgs);
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(flgs[0], 16, j);
580 prt("+------------FLAGS2------------+", 17, j);
581 prt("SUST....IMMUN.RESIST............", 18, j);
582 prt(" reaefctrpsaefcpfldbc sn ", 19, j);
583 prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
584 prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
585 prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
586 prt_binary(flgs[1], 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(flgs[2], 16, j+32);
596 prt("+------------FLAGS4------------+", 17, j+32);
597 prt("KILL....ESP......... ", 18, j+32);
598 prt("aeud tghaud tgdhegnu ", 19, j+32);
599 prt("nvneoriunneoriruvoon ", 20, j+32);
600 prt("iidmroamidmroagmionq ", 21, j+32);
601 prt("mlenclnmmenclnnnldlu ", 22, j+32);
602 prt_binary(flgs[3], 23, j+32);
607 * A structure to hold a tval and its description
609 typedef struct tval_desc
616 * A list of tvals and their textual names
618 static tval_desc tvals[] =
620 { TV_SWORD, "Sword" },
621 { TV_POLEARM, "Polearm" },
622 { TV_HAFTED, "Hafted Weapon" },
624 { TV_ARROW, "Arrows" },
625 { TV_BOLT, "Bolts" },
626 { TV_SHOT, "Shots" },
627 { TV_SHIELD, "Shield" },
628 { TV_CROWN, "Crown" },
630 { TV_GLOVES, "Gloves" },
631 { TV_BOOTS, "Boots" },
632 { TV_CLOAK, "Cloak" },
633 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
634 { TV_HARD_ARMOR, "Hard Armor" },
635 { TV_SOFT_ARMOR, "Soft Armor" },
637 { TV_AMULET, "Amulet" },
639 { TV_POTION, "Potion" },
640 { TV_SCROLL, "Scroll" },
642 { TV_STAFF, "Staff" },
644 { TV_LIFE_BOOK, "Life Spellbook" },
645 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
646 { TV_NATURE_BOOK, "Nature Spellbook" },
647 { TV_CHAOS_BOOK, "Chaos Spellbook" },
648 { TV_DEATH_BOOK, "Death Spellbook" },
649 { TV_TRUMP_BOOK, "Trump Spellbook" },
650 { TV_ARCANE_BOOK, "Arcane Spellbook" },
651 { TV_ENCHANT_BOOK, "Craft Spellbook"},
652 { TV_DAEMON_BOOK, "Daemon Spellbook"},
653 { TV_CRUSADE_BOOK, "Crusade Spellbook"},
654 { TV_MUSIC_BOOK, "Music Spellbook" },
655 { TV_HISSATSU_BOOK, "Book of Kendo" },
656 { TV_PARCHEMENT, "Parchement" },
657 { TV_WHISTLE, "Whistle" },
658 { TV_SPIKE, "Spikes" },
659 { TV_DIGGING, "Digger" },
660 { TV_CHEST, "Chest" },
661 { TV_CAPTURE, "Capture Ball" },
662 { TV_CARD, "Express Card" },
663 { TV_FIGURINE, "Magical Figurine" },
664 { TV_STATUE, "Statue" },
665 { TV_CORPSE, "Corpse" },
667 { TV_FLASK, "Flask" },
669 { TV_SKELETON, "Skeleton" },
675 * Strip an "object name" into a buffer
677 void strip_name(char *buf, int k_idx)
681 object_kind *k_ptr = &k_info[k_idx];
683 cptr str = (k_name + k_ptr->name);
686 /* Skip past leading characters */
687 while ((*str == ' ') || (*str == '&')) str++;
689 /* Copy useful chars */
690 for (t = buf; *str; str++)
693 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
695 if (*str != '~') *t++ = *str;
698 /* Terminate the new name */
704 * Specify tval and sval (type and subtype of object) originally
705 * by RAK, heavily modified by -Bernd-
707 * This function returns the k_idx of an object type, or zero if failed
709 * List up to 50 choices in three columns
711 static int wiz_create_itemtype(void)
728 /* Print all tval's and their descriptions */
729 for (num = 0; (num < 80) && tvals[num].tval; num++)
731 row = 2 + (num % 20);
732 col = 20 * (num / 20);
734 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
737 /* Me need to know the maximal possible tval_index */
741 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
744 for (num = 0; num < max_num; num++)
746 if (listsym[num] == ch) break;
749 /* Bail out if choice is illegal */
750 if ((num < 0) || (num >= max_num)) return (0);
752 /* Base object type chosen, fill in tval */
753 tval = tvals[num].tval;
754 tval_desc = tvals[num].desc;
757 /*** And now we go for k_idx ***/
762 /* We have to search the whole itemlist. */
763 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
765 object_kind *k_ptr = &k_info[i];
767 /* Analyze matching items */
768 if (k_ptr->tval == tval)
771 row = 2 + (num % 20);
772 col = 20 * (num / 20);
776 /* Acquire the "name" of object "i" */
780 prt(format("[%c] %s", ch, buf), row, col);
782 /* Remember the object index */
787 /* Me need to know the maximal possible remembered object_index */
791 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
794 for (num = 0; num < max_num; num++)
796 if (listsym[num] == ch) break;
799 /* Bail out if choice is "illegal" */
800 if ((num < 0) || (num >= max_num)) return (0);
802 /* And return successful */
803 return (choice[num]);
810 static void wiz_tweak_item(object_type *o_ptr)
816 /* Hack -- leave artifacts alone */
817 if (artifact_p(o_ptr) || o_ptr->art_name) return;
819 p = "Enter new 'pval' setting: ";
820 sprintf(tmp_val, "%d", o_ptr->pval);
821 if (!get_string(p, tmp_val, 5)) return;
822 o_ptr->pval = atoi(tmp_val);
823 wiz_display_item(o_ptr);
825 p = "Enter new 'to_a' setting: ";
826 sprintf(tmp_val, "%d", o_ptr->to_a);
827 if (!get_string(p, tmp_val, 5)) return;
828 o_ptr->to_a = atoi(tmp_val);
829 wiz_display_item(o_ptr);
831 p = "Enter new 'to_h' setting: ";
832 sprintf(tmp_val, "%d", o_ptr->to_h);
833 if (!get_string(p, tmp_val, 5)) return;
834 o_ptr->to_h = atoi(tmp_val);
835 wiz_display_item(o_ptr);
837 p = "Enter new 'to_d' setting: ";
838 sprintf(tmp_val, "%d", o_ptr->to_d);
839 if (!get_string(p, tmp_val, 5)) return;
840 o_ptr->to_d = atoi(tmp_val);
841 wiz_display_item(o_ptr);
846 * Apply magic to an item or turn it into an artifact. -Bernd-
848 static void wiz_reroll_item(object_type *o_ptr)
855 bool changed = FALSE;
858 /* Hack -- leave artifacts alone */
859 if (artifact_p(o_ptr) || o_ptr->art_name) return;
862 /* Get local object */
865 /* Copy the object */
866 object_copy(q_ptr, o_ptr);
869 /* Main loop. Ask for magification and artifactification */
872 /* Display full item debug information */
873 wiz_display_item(q_ptr);
875 /* Ask wizard what to do. */
876 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
878 /* Preserve wizard-generated artifacts */
879 if (artifact_p(q_ptr))
881 a_info[q_ptr->name1].cur_num = 0;
889 /* Create/change it! */
890 if (ch == 'A' || ch == 'a')
896 /* Preserve wizard-generated artifacts */
897 if (artifact_p(q_ptr))
899 a_info[q_ptr->name1].cur_num = 0;
905 /* Apply bad magic, but first clear object */
908 object_prep(q_ptr, o_ptr->k_idx);
909 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
912 /* Apply bad magic, but first clear object */
915 object_prep(q_ptr, o_ptr->k_idx);
916 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
919 /* Apply normal magic, but first clear object */
922 object_prep(q_ptr, o_ptr->k_idx);
923 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
926 /* Apply good magic, but first clear object */
929 object_prep(q_ptr, o_ptr->k_idx);
930 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
933 /* Apply great magic, but first clear object */
936 object_prep(q_ptr, o_ptr->k_idx);
937 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
942 object_prep(q_ptr, o_ptr->k_idx);
943 apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
945 /* Failed to create normal artifact; make a random one */
946 if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
950 q_ptr->iy = o_ptr->iy;
951 q_ptr->ix = o_ptr->ix;
952 q_ptr->next_o_idx = o_ptr->next_o_idx;
953 q_ptr->marked = o_ptr->marked;
961 object_copy(o_ptr, q_ptr);
963 /* Recalculate bonuses */
964 p_ptr->update |= (PU_BONUS);
966 /* Combine / Reorder the pack (later) */
967 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
970 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
977 * Try to create an item again. Output some statistics. -Bernd-
979 * The statistics are correct now. We acquire a clean grid, and then
980 * repeatedly place an object in this grid, copying it into an item
981 * holder, and then deleting the object. We fiddle with the artifact
982 * counter flags to prevent weirdness. We use the items to collect
983 * statistics on item creation relative to the initial item.
985 static void wiz_statistics(object_type *o_ptr)
987 u32b i, matches, better, worse, other, correct;
989 u32b test_roll = 1000000;
999 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
1001 cptr p = "Enter number of items to roll: ";
1005 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1006 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
1012 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
1015 wiz_display_item(o_ptr);
1018 if (!get_com(pmt, &ch, FALSE)) break;
1020 if (ch == 'n' || ch == 'N')
1026 else if (ch == 'g' || ch == 'G')
1032 else if (ch == 'e' || ch == 'E')
1036 quality = "excellent";
1045 sprintf(tmp_val, "%ld", test_roll);
1046 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1047 test_roll = MAX(1, test_roll);
1049 /* Let us know what we are doing */
1050 msg_format("Creating a lot of %s items. Base level = %d.",
1051 quality, dun_level);
1054 /* Set counters to zero */
1055 correct = matches = better = worse = other = 0;
1057 /* Let's rock and roll */
1058 for (i = 0; i <= test_roll; i++)
1060 /* Output every few rolls */
1061 if ((i < 100) || (i % 100 == 0))
1066 /* Allow interupt */
1076 /* Dump the stats */
1077 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1082 /* Get local object */
1085 /* Wipe the object */
1088 /* Create an object */
1089 make_object(q_ptr, good, great);
1092 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1093 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1096 /* Test for the same tval and sval. */
1097 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1098 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1100 /* One more correct item */
1103 /* Check for match */
1104 if ((q_ptr->pval == o_ptr->pval) &&
1105 (q_ptr->to_a == o_ptr->to_a) &&
1106 (q_ptr->to_h == o_ptr->to_h) &&
1107 (q_ptr->to_d == o_ptr->to_d) &&
1108 (q_ptr->name1 == o_ptr->name1))
1113 /* Check for better */
1114 else if ((q_ptr->pval >= o_ptr->pval) &&
1115 (q_ptr->to_a >= o_ptr->to_a) &&
1116 (q_ptr->to_h >= o_ptr->to_h) &&
1117 (q_ptr->to_d >= o_ptr->to_d))
1122 /* Check for worse */
1123 else if ((q_ptr->pval <= o_ptr->pval) &&
1124 (q_ptr->to_a <= o_ptr->to_a) &&
1125 (q_ptr->to_h <= o_ptr->to_h) &&
1126 (q_ptr->to_d <= o_ptr->to_d))
1131 /* Assume different */
1139 msg_format(q, i, correct, matches, better, worse, other);
1144 /* Hack -- Normally only make a single artifact */
1145 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1150 * Change the quantity of a the item
1152 static void wiz_quantity_item(object_type *o_ptr)
1154 int tmp_int, tmp_qnt;
1159 /* Never duplicate artifacts */
1160 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1162 /* Store old quantity. -LM- */
1163 tmp_qnt = o_ptr->number;
1166 sprintf(tmp_val, "%d", o_ptr->number);
1169 if (get_string("Quantity: ", tmp_val, 2))
1172 tmp_int = atoi(tmp_val);
1175 if (tmp_int < 1) tmp_int = 1;
1176 if (tmp_int > 99) tmp_int = 99;
1178 /* Accept modifications */
1179 o_ptr->number = tmp_int;
1181 /* Hack -- rod pvals must change if the number in the stack does. -LM- */
1182 if (o_ptr->tval == TV_ROD)
1183 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1190 * Play with an item. Options include:
1191 * - Output statistics (via wiz_roll_item)
1192 * - Reroll item (via wiz_reroll_item)
1193 * - Change properties (via wiz_tweak_item)
1194 * - Change the number of items (via wiz_quantity_item)
1196 static void do_cmd_wiz_play(void)
1211 item_tester_no_ryoute = TRUE;
1213 q = "Play with which object? ";
1214 s = "You have nothing to play with.";
1215 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1217 /* Get the item (in the pack) */
1220 o_ptr = &inventory[item];
1223 /* Get the item (on the floor) */
1226 o_ptr = &o_list[0 - item];
1229 /* The item was not changed */
1233 /* Save the screen */
1237 /* Get local object */
1241 object_copy(q_ptr, o_ptr);
1247 /* Display the item */
1248 wiz_display_item(q_ptr);
1251 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1257 if (ch == 'A' || ch == 'a')
1263 if (ch == 's' || ch == 'S')
1265 wiz_statistics(q_ptr);
1268 if (ch == 'r' || ch == 'r')
1270 wiz_reroll_item(q_ptr);
1273 if (ch == 't' || ch == 'T')
1275 wiz_tweak_item(q_ptr);
1278 if (ch == 'q' || ch == 'Q')
1280 wiz_quantity_item(q_ptr);
1285 /* Restore the screen */
1293 msg_print("Changes accepted.");
1295 /* Recalcurate object's weight */
1298 p_ptr->total_weight += (q_ptr->weight * q_ptr->number)
1299 - (o_ptr->weight * o_ptr->number);
1303 object_copy(o_ptr, q_ptr);
1306 /* Recalculate bonuses */
1307 p_ptr->update |= (PU_BONUS);
1309 /* Combine / Reorder the pack (later) */
1310 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1313 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1319 msg_print("Changes ignored.");
1325 * Wizard routine for creating objects -RAK-
1326 * Heavily modified to allow magification and artifactification -Bernd-
1328 * Note that wizards cannot create objects on top of other objects.
1330 * Hack -- this routine always makes a "dungeon object", and applies
1331 * magic to it, and attempts to decline cursed items.
1333 static void wiz_create_item(void)
1341 /* Save the screen */
1344 /* Get object base type */
1345 k_idx = wiz_create_itemtype();
1347 /* Restore the screen */
1351 /* Return if failed */
1354 if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
1359 for (i = 1; i < max_a_idx; i++)
1361 /* Ignore incorrect tval */
1362 if (a_info[i].tval != k_info[k_idx].tval) continue;
1364 /* Ignore incorrect sval */
1365 if (a_info[i].sval != k_info[k_idx].sval) continue;
1367 /* Create this artifact */
1368 create_named_art(i, py, px);
1371 msg_print("Allocated(INSTA_ART).");
1377 /* Get local object */
1380 /* Create the item */
1381 object_prep(q_ptr, k_idx);
1384 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
1386 /* Drop the object from heaven */
1387 (void)drop_near(q_ptr, -1, py, px);
1390 msg_print("Allocated.");
1395 * Cure everything instantly
1397 static void do_cmd_wiz_cure_all(void)
1400 (void)res_stat(A_STR);
1401 (void)res_stat(A_INT);
1402 (void)res_stat(A_WIS);
1403 (void)res_stat(A_CON);
1404 (void)res_stat(A_DEX);
1405 (void)res_stat(A_CHR);
1407 /* Restore the level */
1408 (void)restore_level();
1410 /* Heal the player */
1411 p_ptr->chp = p_ptr->mhp;
1412 p_ptr->chp_frac = 0;
1415 if (p_ptr->csp < p_ptr->msp)
1417 p_ptr->csp = p_ptr->msp;
1418 p_ptr->csp_frac = 0;
1423 (void)set_confused(0);
1424 (void)set_poisoned(0);
1425 (void)set_afraid(0);
1426 (void)set_paralyzed(0);
1430 (void)set_slow(0, TRUE);
1432 /* No longer hungry */
1433 (void)set_food(PY_FOOD_MAX - 1);
1435 /* Redraw everything */
1443 static void do_cmd_wiz_jump(void)
1446 if (command_arg <= 0)
1453 sprintf(ppp, "Jump which dungeon : ");
1456 sprintf(tmp_val, "%d", dungeon_type);
1458 /* Ask for a level */
1459 if (!get_string(ppp, tmp_val, 2)) return;
1461 dungeon_type = atoi(tmp_val);
1462 if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
1465 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
1468 sprintf(tmp_val, "%d", dun_level);
1470 /* Ask for a level */
1471 if (!get_string(ppp, tmp_val, 10)) return;
1473 /* Extract request */
1474 command_arg = atoi(tmp_val);
1478 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1481 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1483 /* Accept request */
1484 msg_format("You jump to dungeon level %d.", command_arg);
1486 if (autosave_l) do_cmd_save_game(TRUE);
1489 dun_level = command_arg;
1491 if (!dun_level) dungeon_type = 0;
1492 p_ptr->inside_arena = FALSE;
1494 leave_quest_check();
1496 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1498 p_ptr->inside_quest = 0;
1499 p_ptr->leftbldg = FALSE;
1502 /* Prevent energy_need from being too lower than 0 */
1503 p_ptr->energy_need = 0;
1506 p_ptr->leaving = TRUE;
1511 * Become aware of a lot of objects
1513 static void do_cmd_wiz_learn(void)
1520 /* Scan every object */
1521 for (i = 1; i < max_k_idx; i++)
1523 object_kind *k_ptr = &k_info[i];
1525 /* Induce awareness */
1526 if (k_ptr->level <= command_arg)
1528 /* Get local object */
1531 /* Prepare object */
1532 object_prep(q_ptr, i);
1535 object_aware(q_ptr);
1542 * Summon some creatures
1544 static void do_cmd_wiz_summon(int num)
1548 for (i = 0; i < num; i++)
1550 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1556 * Summon a creature of the specified type
1558 * XXX XXX XXX This function is rather dangerous
1560 static void do_cmd_wiz_named(int r_idx)
1565 /* if (!r_idx) return; */
1567 /* Prevent illegal monsters */
1568 if (r_idx >= max_r_idx) return;
1571 for (i = 0; i < 10; i++)
1575 /* Pick a location */
1576 scatter(&y, &x, py, px, d, 0);
1578 /* Require empty grids */
1579 if (!cave_empty_bold(y, x)) continue;
1581 /* Place it (allow groups) */
1582 if (place_monster_aux(0, y, x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP))) break;
1588 * Summon a creature of the specified type
1590 * XXX XXX XXX This function is rather dangerous
1592 static void do_cmd_wiz_named_friendly(int r_idx)
1594 (void) summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
1600 * Hack -- Delete all nearby monsters
1602 static void do_cmd_wiz_zap(void)
1607 /* Genocide everyone nearby */
1608 for (i = 1; i < m_max; i++)
1610 monster_type *m_ptr = &m_list[i];
1612 /* Paranoia -- Skip dead monsters */
1613 if (!m_ptr->r_idx) continue;
1615 /* Delete nearby monsters */
1616 if (m_ptr->cdis <= MAX_SIGHT)
1618 if (i == p_ptr->riding)
1621 p_ptr->redraw |= (PR_EXTRA);
1623 delete_monster_idx(i);
1630 * Hack -- Delete all monsters
1632 static void do_cmd_wiz_zap_all(void)
1636 /* Genocide everyone */
1637 for (i = 1; i < m_max; i++)
1639 monster_type *m_ptr = &m_list[i];
1641 /* Paranoia -- Skip dead monsters */
1642 if (!m_ptr->r_idx) continue;
1644 if (i == p_ptr->riding)
1647 p_ptr->redraw |= (PR_EXTRA);
1650 /* Delete this monster */
1651 delete_monster_idx(i);
1656 #ifdef ALLOW_SPOILERS
1661 extern void do_cmd_spoilers(void);
1663 #endif /* ALLOW_SPOILERS */
1668 * Hack -- declare external function
1670 extern void do_cmd_debug(void);
1675 * Ask for and parse a "debug command"
1676 * The "command_arg" may have been set.
1678 void do_cmd_debug(void)
1684 /* Get a "debug command" */
1685 get_com("Debug Command: ", &cmd, FALSE);
1687 /* Analyze the command */
1698 #ifdef ALLOW_SPOILERS
1700 /* Hack -- Generate Spoilers */
1705 #endif /* ALLOW_SPOILERS */
1714 /* Cure all maladies */
1716 do_cmd_wiz_cure_all();
1719 /* Know alignment */
1721 msg_format("Your alignment is %d.", p_ptr->align);
1724 /* Teleport to target */
1733 /* Create any object */
1738 /* Create a named artifact */
1740 wiz_create_named_art(command_arg);
1743 /* Detect everything */
1745 detect_all(DETECT_RAD_ALL*3);
1748 /* Dimension_door */
1750 wiz_dimension_door();
1753 /* Edit character */
1755 do_cmd_wiz_change();
1758 /* View item info */
1760 identify_fully(FALSE);
1765 if (command_arg <= 0) command_arg = 1;
1766 acquirement(py, px, command_arg, FALSE, TRUE);
1769 /* Hitpoint rerating */
1771 do_cmd_rerate(TRUE); break;
1773 #ifdef MONSTER_HORDES
1775 do_cmd_summon_horde(); break;
1776 #endif /* MONSTER_HORDES */
1780 (void)ident_spell(FALSE);
1783 /* Go up or down in the dungeon */
1788 /* Self-Knowledge */
1793 /* Learn about objects */
1800 map_area(DETECT_RAD_ALL);
1805 (void)gain_random_mutation(command_arg);
1808 /* Specific reward */
1810 (void)gain_level_reward(command_arg);
1813 /* Summon _friendly_ named monster */
1815 do_cmd_wiz_named_friendly(command_arg);
1818 /* Summon Named Monster */
1820 do_cmd_wiz_named(command_arg);
1823 /* Object playing routines */
1830 teleport_player(10);
1834 /* Complete a Quest -KMW- */
1837 for (i = 0; i < max_quests; i++)
1839 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1841 p_ptr->quest[i].status++;
1842 msg_print("Completed Quest");
1847 if (i == max_quests)
1849 msg_print("No current quest");
1856 /* Make every dungeon square "known" to test streamers -KMW- */
1859 for(y = 0; y < cur_hgt; y++)
1861 for(x = 0; x < cur_wid; x++)
1863 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1866 wiz_lite(TRUE, FALSE);
1870 /* Summon Random Monster(s) */
1872 if (command_arg <= 0) command_arg = 1;
1873 do_cmd_wiz_summon(command_arg);
1878 teleport_player(100);
1881 /* Very Good Objects */
1883 if (command_arg <= 0) command_arg = 1;
1884 acquirement(py, px, command_arg, TRUE, TRUE);
1887 /* Wizard Light the Level */
1889 wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
1892 /* Increase Experience */
1896 gain_exp(command_arg);
1900 gain_exp(p_ptr->exp + 1);
1904 /* Zap Monsters (Genocide) */
1910 do_cmd_wiz_zap_all();
1913 /* Hack -- whatever I desire */
1915 do_cmd_wiz_hack_ben();
1918 /* Not a Wizard Command */
1920 msg_print("That is not a valid debug command.");