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 maxd = 1, maxr = 1, maxt = 1;
198 u32b rarity[K_MAX_DEPTH];
199 u32b total[K_MAX_DEPTH];
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, u32b);
214 /* Scan all entries */
215 for (i = 0; i < K_MAX_DEPTH; i++)
217 for (j = 0; j < alloc_kind_size; j++)
221 if (table[j].level <= i)
223 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
225 else if (table[j].level - 1 > 0)
227 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
230 /* Acquire this kind */
231 k_ptr = &k_info[table[j].index];
233 /* Accumulate probabilities */
236 /* Accumulate probabilities */
237 if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
246 for (i = 0; i < K_MAX_DEPTH; i++)
248 if (rarity[i] > maxr) maxr = rarity[i];
249 if (total[i] > maxt) maxt = total[i];
252 /* Simulate a log graph */
253 if (maxt / maxr > 32)
258 if (maxt / maxr > 1024)
263 if (maxt / maxr > 32768L)
269 /* Calculate probabilities for each range */
270 for (i = 0; i < 22; i++)
272 /* Shift the values into view */
273 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
275 display[i] += rarity[j] * (100 * maxt / total[j]);
278 /* Correct proportions */
282 if (display[i] > maxd) maxd = display[i];
286 for (i = 0; i < 22; i++)
288 display[i] = display[i] * 10 / maxd;
291 /* Graph the rarities */
292 for (i = 0; i < 22; i++)
294 Term_putch(col, row + i + 1, TERM_WHITE, '|');
296 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
299 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
301 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
305 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
309 /* Make it look nice */
315 * Hack -- Teleport to the target
317 static void do_cmd_wiz_bamf(void)
319 /* Must have a target */
320 if (!target_who) return;
322 /* Teleport to the target */
323 teleport_player_to(target_row, target_col, FALSE);
328 * Aux function for "do_cmd_wiz_change()". -RAK-
330 static void do_cmd_wiz_change_aux(void)
340 /* Query the stats */
341 for (i = 0; i < 6; i++)
344 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
347 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
350 if (!get_string(ppp, tmp_val, 3)) return;
353 tmp_int = atoi(tmp_val);
356 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
357 else if (tmp_int < 3) tmp_int = 3;
360 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
365 sprintf(tmp_val, "8000");
369 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
371 if (!get_string("Proficiency: ", tmp_val, 9)) return;
375 tmp_s16b = atoi(tmp_val);
378 if (tmp_s16b < 0) tmp_s16b = 0L;
379 if (tmp_s16b > 8000) tmp_s16b = 8000L;
381 for (j = 0; j <= TV_SWORD - TV_BOW;j++)
383 for (i = 0;i < 64;i++)
385 weapon_exp[j][i] = tmp_s16b;
386 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];
390 for (j = 0; j < 10; j++)
392 skill_exp[j] = tmp_s16b;
393 if (skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
396 for (j = 0; j < 32; j++)
397 spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
399 spell_exp[j] = (tmp_s16b > 1400 ? 1400 : tmp_s16b);
402 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
405 if (!get_string("Gold: ", tmp_val, 9)) return;
408 tmp_long = atol(tmp_val);
411 if (tmp_long < 0) tmp_long = 0L;
414 p_ptr->au = tmp_long;
418 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
421 if (!get_string("Experience: ", tmp_val, 9)) return;
424 tmp_long = atol(tmp_val);
427 if (tmp_long < 0) tmp_long = 0L;
429 if (p_ptr->prace != RACE_ANDROID)
432 p_ptr->max_exp = tmp_long;
433 p_ptr->exp = tmp_long;
442 * Change various "permanent" player variables.
444 static void do_cmd_wiz_change(void)
447 do_cmd_wiz_change_aux();
449 /* Redraw everything */
455 * Wizard routines for creating objects -RAK-
456 * And for manipulating them! -Bernd-
458 * This has been rewritten to make the whole procedure
459 * of debugging objects much easier and more comfortable.
461 * The following functions are meant to play with objects:
462 * Create, modify, roll for them (for statistic purposes) and more.
463 * The original functions were by RAK.
464 * The function to show an item's debug information was written
465 * by David Reeve Sward <sward+@CMU.EDU>.
466 * Bernd (wiebelt@mathematik.hu-berlin.de)
468 * Here are the low-level functions
469 * - wiz_display_item()
470 * display an item's debug-info
471 * - wiz_create_itemtype()
472 * specify tval and sval (type and subtype of object)
474 * specify pval, +AC, +tohit, +todam
475 * Note that the wizard can leave this function anytime,
476 * thus accepting the default-values for the remaining values.
477 * pval comes first now, since it is most important.
478 * - wiz_reroll_item()
479 * apply some magic to the item or turn it into an artifact.
481 * Get some statistics about the rarity of an item:
482 * We create a lot of fake items and see if they are of the
483 * same type (tval and sval), then we compare pval and +AC.
484 * If the fake-item is better or equal it is counted.
485 * Note that cursed items that are better or equal (absolute values)
487 * HINT: This is *very* useful for balancing the game!
488 * - wiz_quantity_item()
489 * change the quantity of an item, but be sane about it.
491 * And now the high-level functions
492 * - do_cmd_wiz_play()
493 * play with an existing object
494 * - wiz_create_item()
495 * create a new object
497 * Note -- You do not have to specify "pval" and other item-properties
498 * directly. Just apply magic until you are satisfied with the item.
500 * Note -- For some items (such as wands, staffs, some rings, etc), you
501 * must apply magic, or you will get "broken" or "uncharged" objects.
503 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
504 * the artifact. Be careful.
506 * Hack -- this function will allow you to create multiple artifacts.
507 * This "feature" may induce crashes or other nasty effects.
511 * Just display an item's properties (debug-info)
512 * Originally by David Reeve Sward <sward+@CMU.EDU>
513 * Verbose item flags by -Bernd-
515 static void wiz_display_item(object_type *o_ptr)
521 /* Extract the flags */
522 object_flags(o_ptr, &f1, &f2, &f3);
524 /* Clear the screen */
525 for (i = 1; i <= 23; i++) prt("", i, j - 2);
527 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
530 object_desc_store(buf, o_ptr, TRUE, 3);
534 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
535 o_ptr->k_idx, get_object_level(o_ptr),
536 o_ptr->tval, o_ptr->sval), 4, j);
538 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
539 o_ptr->number, o_ptr->weight,
540 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
542 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
543 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
545 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
546 o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
548 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
549 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
551 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d",
552 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5), 9, j);
554 prt("+------------FLAGS1------------+", 10, j);
555 prt("AFFECT........SLAY........BRAND.", 11, j);
556 prt(" mr cvae xsqpaefc", 12, j);
557 prt("siwdccsissidsahanvudotgddhuoclio", 13, j);
558 prt("tnieohtrtrnipttmiinmrrnrrraiierl", 14, j);
559 prt("rtsxnarylcfgdkcpmldncltggpksdced", 15, j);
560 prt_binary(f1, 16, j);
562 prt("+------------FLAGS2------------+", 17, j);
563 prt("SUST....IMMUN.RESIST............", 18, j);
564 prt(" aefctrpsaefcpfldbc sn ", 19, j);
565 prt("siwdcc clioheatcliooeialoshtncd", 20, j);
566 prt("tnieoh ierlrfraierliatrnnnrhehi", 21, j);
567 prt("rtsxna..dcedwlatdcedsrekdfddrxss", 22, j);
568 prt_binary(f2, 23, j);
570 prt("+------------FLAGS3------------+", 10, j+32);
571 prt("fe cnn t i stdrmsiiii d abchp", 11, j+32);
572 prt("aa aoomyehsnlleeieihgggg rtgluvr", 12, j+32);
573 prt("uu utmacaihseielgggonnnnaaerercc", 13, j+32);
574 prt("rr reanusdotvtieeehtrrrrcilassuu", 14, j+32);
575 prt("aa algaryewaienpsntsaefctnevserr", 15, j+32);
576 prt_binary(f3, 16, j+32);
581 * A structure to hold a tval and its description
583 typedef struct tval_desc
590 * A list of tvals and their textual names
592 static tval_desc tvals[] =
594 { TV_SWORD, "Sword" },
595 { TV_POLEARM, "Polearm" },
596 { TV_HAFTED, "Hafted Weapon" },
598 { TV_ARROW, "Arrows" },
599 { TV_BOLT, "Bolts" },
600 { TV_SHOT, "Shots" },
601 { TV_SHIELD, "Shield" },
602 { TV_CROWN, "Crown" },
604 { TV_GLOVES, "Gloves" },
605 { TV_BOOTS, "Boots" },
606 { TV_CLOAK, "Cloak" },
607 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
608 { TV_HARD_ARMOR, "Hard Armor" },
609 { TV_SOFT_ARMOR, "Soft Armor" },
611 { TV_AMULET, "Amulet" },
613 { TV_POTION, "Potion" },
614 { TV_SCROLL, "Scroll" },
616 { TV_STAFF, "Staff" },
618 { TV_LIFE_BOOK, "Life Spellbook" },
619 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
620 { TV_NATURE_BOOK, "Nature Spellbook" },
621 { TV_CHAOS_BOOK, "Chaos Spellbook" },
622 { TV_DEATH_BOOK, "Death Spellbook" },
623 { TV_TRUMP_BOOK, "Trump Spellbook" },
624 { TV_ARCANE_BOOK, "Arcane Spellbook" },
625 { TV_ENCHANT_BOOK, "Craft Spellbook"},
626 { TV_DAEMON_BOOK, "Daemon Spellbook"},
627 { TV_MUSIC_BOOK, "Music Spellbook" },
628 { TV_HISSATSU_BOOK, "Book of Kendo" },
629 { TV_PARCHEMENT, "Parchement" },
630 { TV_WHISTLE, "Whistle" },
631 { TV_SPIKE, "Spikes" },
632 { TV_DIGGING, "Digger" },
633 { TV_CHEST, "Chest" },
634 { TV_CAPTURE, "Capture Ball" },
635 { TV_CARD, "Express Card" },
636 { TV_FIGURINE, "Magical Figurine" },
637 { TV_STATUE, "Statue" },
638 { TV_CORPSE, "Corpse" },
640 { TV_FLASK, "Flask" },
642 { TV_SKELETON, "Skeleton" },
648 * Strip an "object name" into a buffer
650 void strip_name(char *buf, int k_idx)
654 object_kind *k_ptr = &k_info[k_idx];
656 cptr str = (k_name + k_ptr->name);
659 /* Skip past leading characters */
660 while ((*str == ' ') || (*str == '&')) str++;
662 /* Copy useful chars */
663 for (t = buf; *str; str++)
666 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
668 if (*str != '~') *t++ = *str;
671 /* Terminate the new name */
677 * Specify tval and sval (type and subtype of object) originally
678 * by RAK, heavily modified by -Bernd-
680 * This function returns the k_idx of an object type, or zero if failed
682 * List up to 50 choices in three columns
684 static int wiz_create_itemtype(void)
701 /* Print all tval's and their descriptions */
702 for (num = 0; (num < 80) && tvals[num].tval; num++)
704 row = 2 + (num % 20);
705 col = 20 * (num / 20);
707 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
710 /* Me need to know the maximal possible tval_index */
714 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
717 for (num = 0; num < max_num; num++)
719 if (listsym[num] == ch) break;
722 /* Bail out if choice is illegal */
723 if ((num < 0) || (num >= max_num)) return (0);
725 /* Base object type chosen, fill in tval */
726 tval = tvals[num].tval;
727 tval_desc = tvals[num].desc;
730 /*** And now we go for k_idx ***/
735 /* We have to search the whole itemlist. */
736 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
738 object_kind *k_ptr = &k_info[i];
740 /* Analyze matching items */
741 if (k_ptr->tval == tval)
744 row = 2 + (num % 20);
745 col = 20 * (num / 20);
749 /* Acquire the "name" of object "i" */
753 prt(format("[%c] %s", ch, buf), row, col);
755 /* Remember the object index */
760 /* Me need to know the maximal possible remembered object_index */
764 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
767 for (num = 0; num < max_num; num++)
769 if (listsym[num] == ch) break;
772 /* Bail out if choice is "illegal" */
773 if ((num < 0) || (num >= max_num)) return (0);
775 /* And return successful */
776 return (choice[num]);
783 static void wiz_tweak_item(object_type *o_ptr)
789 /* Hack -- leave artifacts alone */
790 if (artifact_p(o_ptr) || o_ptr->art_name) return;
792 p = "Enter new 'pval' setting: ";
793 sprintf(tmp_val, "%d", o_ptr->pval);
794 if (!get_string(p, tmp_val, 5)) return;
795 o_ptr->pval = atoi(tmp_val);
796 wiz_display_item(o_ptr);
798 p = "Enter new 'to_a' setting: ";
799 sprintf(tmp_val, "%d", o_ptr->to_a);
800 if (!get_string(p, tmp_val, 5)) return;
801 o_ptr->to_a = atoi(tmp_val);
802 wiz_display_item(o_ptr);
804 p = "Enter new 'to_h' setting: ";
805 sprintf(tmp_val, "%d", o_ptr->to_h);
806 if (!get_string(p, tmp_val, 5)) return;
807 o_ptr->to_h = atoi(tmp_val);
808 wiz_display_item(o_ptr);
810 p = "Enter new 'to_d' setting: ";
811 sprintf(tmp_val, "%d", o_ptr->to_d);
812 if (!get_string(p, tmp_val, 5)) return;
813 o_ptr->to_d = atoi(tmp_val);
814 wiz_display_item(o_ptr);
819 * Apply magic to an item or turn it into an artifact. -Bernd-
821 static void wiz_reroll_item(object_type *o_ptr)
828 bool changed = FALSE;
831 /* Hack -- leave artifacts alone */
832 if (artifact_p(o_ptr) || o_ptr->art_name) return;
835 /* Get local object */
838 /* Copy the object */
839 object_copy(q_ptr, o_ptr);
842 /* Main loop. Ask for magification and artifactification */
845 /* Display full item debug information */
846 wiz_display_item(q_ptr);
848 /* Ask wizard what to do. */
849 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
851 /* Preserve wizard-generated artifacts */
852 if (artifact_p(q_ptr))
854 a_info[q_ptr->name1].cur_num = 0;
862 /* Create/change it! */
863 if (ch == 'A' || ch == 'a')
869 /* Preserve wizard-generated artifacts */
870 if (artifact_p(q_ptr))
872 a_info[q_ptr->name1].cur_num = 0;
878 /* Apply bad magic, but first clear object */
881 object_prep(q_ptr, o_ptr->k_idx);
882 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
885 /* Apply bad magic, but first clear object */
888 object_prep(q_ptr, o_ptr->k_idx);
889 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
892 /* Apply normal magic, but first clear object */
895 object_prep(q_ptr, o_ptr->k_idx);
896 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
899 /* Apply good magic, but first clear object */
902 object_prep(q_ptr, o_ptr->k_idx);
903 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
906 /* Apply great magic, but first clear object */
909 object_prep(q_ptr, o_ptr->k_idx);
910 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
915 object_prep(q_ptr, o_ptr->k_idx);
916 apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
918 /* Failed to create normal artifact; make a random one */
919 if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
923 q_ptr->iy = o_ptr->iy;
924 q_ptr->ix = o_ptr->ix;
925 q_ptr->next_o_idx = o_ptr->next_o_idx;
926 q_ptr->marked = o_ptr->marked;
934 object_copy(o_ptr, q_ptr);
936 /* Recalculate bonuses */
937 p_ptr->update |= (PU_BONUS);
939 /* Combine / Reorder the pack (later) */
940 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
943 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
950 * Try to create an item again. Output some statistics. -Bernd-
952 * The statistics are correct now. We acquire a clean grid, and then
953 * repeatedly place an object in this grid, copying it into an item
954 * holder, and then deleting the object. We fiddle with the artifact
955 * counter flags to prevent weirdness. We use the items to collect
956 * statistics on item creation relative to the initial item.
958 static void wiz_statistics(object_type *o_ptr)
960 u32b i, matches, better, worse, other, correct;
962 u32b test_roll = 1000000;
972 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
974 cptr p = "Enter number of items to roll: ";
978 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
979 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
985 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
988 wiz_display_item(o_ptr);
991 if (!get_com(pmt, &ch, FALSE)) break;
993 if (ch == 'n' || ch == 'N')
999 else if (ch == 'g' || ch == 'G')
1005 else if (ch == 'e' || ch == 'E')
1009 quality = "excellent";
1018 sprintf(tmp_val, "%ld", test_roll);
1019 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1020 test_roll = MAX(1, test_roll);
1022 /* Let us know what we are doing */
1023 msg_format("Creating a lot of %s items. Base level = %d.",
1024 quality, dun_level);
1027 /* Set counters to zero */
1028 correct = matches = better = worse = other = 0;
1030 /* Let's rock and roll */
1031 for (i = 0; i <= test_roll; i++)
1033 /* Output every few rolls */
1034 if ((i < 100) || (i % 100 == 0))
1039 /* Allow interupt */
1049 /* Dump the stats */
1050 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1055 /* Get local object */
1058 /* Wipe the object */
1061 /* Create an object */
1062 make_object(q_ptr, good, great);
1065 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1066 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1069 /* Test for the same tval and sval. */
1070 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1071 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1073 /* One more correct item */
1076 /* Check for match */
1077 if ((q_ptr->pval == o_ptr->pval) &&
1078 (q_ptr->to_a == o_ptr->to_a) &&
1079 (q_ptr->to_h == o_ptr->to_h) &&
1080 (q_ptr->to_d == o_ptr->to_d) &&
1081 (q_ptr->name1 == o_ptr->name1))
1086 /* Check for better */
1087 else if ((q_ptr->pval >= o_ptr->pval) &&
1088 (q_ptr->to_a >= o_ptr->to_a) &&
1089 (q_ptr->to_h >= o_ptr->to_h) &&
1090 (q_ptr->to_d >= o_ptr->to_d))
1095 /* Check for worse */
1096 else 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))
1104 /* Assume different */
1112 msg_format(q, i, correct, matches, better, worse, other);
1117 /* Hack -- Normally only make a single artifact */
1118 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1123 * Change the quantity of a the item
1125 static void wiz_quantity_item(object_type *o_ptr)
1127 int tmp_int, tmp_qnt;
1132 /* Never duplicate artifacts */
1133 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1135 /* Store old quantity. -LM- */
1136 tmp_qnt = o_ptr->number;
1139 sprintf(tmp_val, "%d", o_ptr->number);
1142 if (get_string("Quantity: ", tmp_val, 2))
1145 tmp_int = atoi(tmp_val);
1148 if (tmp_int < 1) tmp_int = 1;
1149 if (tmp_int > 99) tmp_int = 99;
1151 /* Accept modifications */
1152 o_ptr->number = tmp_int;
1154 /* Hack -- rod pvals must change if the number in the stack does. -LM- */
1155 if (o_ptr->tval == TV_ROD)
1156 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1163 * Play with an item. Options include:
1164 * - Output statistics (via wiz_roll_item)
1165 * - Reroll item (via wiz_reroll_item)
1166 * - Change properties (via wiz_tweak_item)
1167 * - Change the number of items (via wiz_quantity_item)
1169 static void do_cmd_wiz_play(void)
1184 item_tester_no_ryoute = TRUE;
1186 q = "Play with which object? ";
1187 s = "You have nothing to play with.";
1188 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1190 /* Get the item (in the pack) */
1193 o_ptr = &inventory[item];
1196 /* Get the item (on the floor) */
1199 o_ptr = &o_list[0 - item];
1203 /* The item was not changed */
1207 /* Save the screen */
1211 /* Get local object */
1215 object_copy(q_ptr, o_ptr);
1221 /* Display the item */
1222 wiz_display_item(q_ptr);
1225 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1231 if (ch == 'A' || ch == 'a')
1237 if (ch == 's' || ch == 'S')
1239 wiz_statistics(q_ptr);
1242 if (ch == 'r' || ch == 'r')
1244 wiz_reroll_item(q_ptr);
1247 if (ch == 't' || ch == 'T')
1249 wiz_tweak_item(q_ptr);
1252 if (ch == 'q' || ch == 'Q')
1254 wiz_quantity_item(q_ptr);
1259 /* Restore the screen */
1267 msg_print("Changes accepted.");
1270 object_copy(o_ptr, q_ptr);
1272 /* Recalculate bonuses */
1273 p_ptr->update |= (PU_BONUS);
1275 /* Combine / Reorder the pack (later) */
1276 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1279 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1285 msg_print("Changes ignored.");
1291 * Wizard routine for creating objects -RAK-
1292 * Heavily modified to allow magification and artifactification -Bernd-
1294 * Note that wizards cannot create objects on top of other objects.
1296 * Hack -- this routine always makes a "dungeon object", and applies
1297 * magic to it, and attempts to decline cursed items.
1299 static void wiz_create_item(void)
1307 /* Save the screen */
1310 /* Get object base type */
1311 k_idx = wiz_create_itemtype();
1313 /* Restore the screen */
1317 /* Return if failed */
1320 /* Get local object */
1323 /* Create the item */
1324 object_prep(q_ptr, k_idx);
1326 if (k_info[k_idx].flags3 & TR3_INSTA_ART)
1331 for (i = 1; i < max_a_idx; i++)
1333 /* Ignore incorrect tval */
1334 if (a_info[i].tval != q_ptr->tval) continue;
1336 /* Ignore incorrect sval */
1337 if (a_info[i].sval != q_ptr->sval) continue;
1339 /* Choose this artifact */
1345 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1350 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
1353 /* Drop the object from heaven */
1354 (void)drop_near(q_ptr, -1, py, px);
1357 msg_print("Allocated.");
1362 * Cure everything instantly
1364 static void do_cmd_wiz_cure_all(void)
1367 (void)remove_all_curse();
1370 (void)res_stat(A_STR);
1371 (void)res_stat(A_INT);
1372 (void)res_stat(A_WIS);
1373 (void)res_stat(A_CON);
1374 (void)res_stat(A_DEX);
1375 (void)res_stat(A_CHR);
1377 /* Restore the level */
1378 (void)restore_level();
1380 /* Heal the player */
1381 p_ptr->chp = p_ptr->mhp;
1382 p_ptr->chp_frac = 0;
1385 if (p_ptr->csp < p_ptr->msp)
1387 p_ptr->csp = p_ptr->msp;
1388 p_ptr->csp_frac = 0;
1393 (void)set_confused(0);
1394 (void)set_poisoned(0);
1395 (void)set_afraid(0);
1396 (void)set_paralyzed(0);
1400 (void)set_slow(0, TRUE);
1402 /* No longer hungry */
1403 (void)set_food(PY_FOOD_MAX - 1);
1405 /* Redraw everything */
1413 static void do_cmd_wiz_jump(void)
1416 if (command_arg <= 0)
1423 sprintf(ppp, "Jump which dungeon : ");
1426 sprintf(tmp_val, "%d", dungeon_type);
1428 /* Ask for a level */
1429 if (!get_string(ppp, tmp_val, 2)) return;
1431 dungeon_type = atoi(tmp_val);
1432 if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
1435 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
1438 sprintf(tmp_val, "%d", dun_level);
1440 /* Ask for a level */
1441 if (!get_string(ppp, tmp_val, 10)) return;
1443 /* Extract request */
1444 command_arg = atoi(tmp_val);
1448 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1451 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1453 /* Accept request */
1454 msg_format("You jump to dungeon level %d.", command_arg);
1456 if (autosave_l) do_cmd_save_game(TRUE);
1459 dun_level = command_arg;
1461 if (!dun_level) dungeon_type = 0;
1462 p_ptr->inside_arena = FALSE;
1463 leaving_quest = p_ptr->inside_quest;
1465 /* Leaving an 'only once' quest marks it as failed */
1466 if (leaving_quest &&
1467 (quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
1468 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
1470 quest[leaving_quest].status = QUEST_STATUS_FAILED;
1471 quest[leaving_quest].complev = (byte)p_ptr->lev;
1472 if (record_fix_quest)
1473 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1476 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1478 p_ptr->inside_quest = 0;
1479 p_ptr->leftbldg = FALSE;
1483 p_ptr->leaving = TRUE;
1488 * Become aware of a lot of objects
1490 static void do_cmd_wiz_learn(void)
1497 /* Scan every object */
1498 for (i = 1; i < max_k_idx; i++)
1500 object_kind *k_ptr = &k_info[i];
1502 /* Induce awareness */
1503 if (k_ptr->level <= command_arg)
1505 /* Get local object */
1508 /* Prepare object */
1509 object_prep(q_ptr, i);
1512 object_aware(q_ptr);
1519 * Summon some creatures
1521 static void do_cmd_wiz_summon(int num)
1525 for (i = 0; i < num; i++)
1527 (void)summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, FALSE);
1533 * Summon a creature of the specified type
1535 * XXX XXX XXX This function is rather dangerous
1537 static void do_cmd_wiz_named(int r_idx, bool slp)
1542 /* if (!r_idx) return; */
1544 /* Prevent illegal monsters */
1545 if (r_idx >= max_r_idx) return;
1548 for (i = 0; i < 10; i++)
1552 /* Pick a location */
1553 scatter(&y, &x, py, px, d, 0);
1555 /* Require empty grids */
1556 if (!cave_empty_bold(y, x)) continue;
1558 /* Place it (allow groups) */
1559 if (place_monster_aux(y, x, r_idx, slp, TRUE, FALSE, FALSE, FALSE, FALSE)) break;
1565 * Summon a creature of the specified type
1567 * XXX XXX XXX This function is rather dangerous
1569 static void do_cmd_wiz_named_friendly(int r_idx, bool slp)
1571 (void) summon_named_creature(py, px, r_idx, slp, TRUE, TRUE, TRUE);
1577 * Hack -- Delete all nearby monsters
1579 static void do_cmd_wiz_zap(void)
1584 /* Genocide everyone nearby */
1585 for (i = 1; i < m_max; i++)
1587 monster_type *m_ptr = &m_list[i];
1589 /* Paranoia -- Skip dead monsters */
1590 if (!m_ptr->r_idx) continue;
1592 /* Delete nearby monsters */
1593 if (m_ptr->cdis <= MAX_SIGHT)
1595 if (i == p_ptr->riding)
1598 p_ptr->redraw |= (PR_EXTRA);
1600 delete_monster_idx(i);
1607 * Hack -- Delete all monsters
1609 static void do_cmd_wiz_zap_all(void)
1613 /* Genocide everyone */
1614 for (i = 1; i < m_max; i++)
1616 monster_type *m_ptr = &m_list[i];
1618 /* Paranoia -- Skip dead monsters */
1619 if (!m_ptr->r_idx) continue;
1621 if (i == p_ptr->riding)
1624 p_ptr->redraw |= (PR_EXTRA);
1627 /* Delete this monster */
1628 delete_monster_idx(i);
1633 #ifdef ALLOW_SPOILERS
1638 extern void do_cmd_spoilers(void);
1640 #endif /* ALLOW_SPOILERS */
1645 * Hack -- declare external function
1647 extern void do_cmd_debug(void);
1652 * Ask for and parse a "debug command"
1653 * The "command_arg" may have been set.
1655 void do_cmd_debug(void)
1661 /* Get a "debug command" */
1662 get_com("Debug Command: ", &cmd, FALSE);
1664 /* Analyze the command */
1675 #ifdef ALLOW_SPOILERS
1677 /* Hack -- Generate Spoilers */
1682 #endif /* ALLOW_SPOILERS */
1691 /* Cure all maladies */
1693 do_cmd_wiz_cure_all();
1696 /* Know alignment */
1698 msg_format("Your alignment is %d.", p_ptr->align);
1701 /* Teleport to target */
1710 /* Create any object */
1715 /* Create a named artifact */
1717 wiz_create_named_art(command_arg);
1720 /* Detect everything */
1722 detect_all(DETECT_RAD_ALL*3);
1725 /* Dimension_door */
1727 wiz_dimension_door();
1730 /* Edit character */
1732 do_cmd_wiz_change();
1735 /* View item info */
1737 identify_fully(FALSE);
1742 if (command_arg <= 0) command_arg = 1;
1743 acquirement(py, px, command_arg, FALSE, TRUE);
1746 /* Hitpoint rerating */
1748 do_cmd_rerate(TRUE); break;
1750 #ifdef MONSTER_HORDES
1752 do_cmd_summon_horde(); break;
1753 #endif /* MONSTER_HORDES */
1757 (void)ident_spell(FALSE);
1760 /* Go up or down in the dungeon */
1765 /* Self-Knowledge */
1770 /* Learn about objects */
1777 map_area(DETECT_RAD_ALL);
1782 (void)gain_random_mutation(command_arg);
1785 /* Specific reward */
1787 (void)gain_level_reward(command_arg);
1790 /* Summon _friendly_ named monster */
1792 do_cmd_wiz_named_friendly(command_arg, TRUE);
1795 /* Summon Named Monster */
1797 do_cmd_wiz_named(command_arg, TRUE);
1800 /* Object playing routines */
1807 teleport_player(10);
1811 /* Complete a Quest -KMW- */
1814 for (i = 0; i < max_quests; i++)
1816 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1818 p_ptr->quest[i].status++;
1819 msg_print("Completed Quest");
1824 if (i == max_quests)
1826 msg_print("No current quest");
1833 /* Make every dungeon square "known" to test streamers -KMW- */
1836 for(y = 0; y < cur_hgt; y++)
1838 for(x = 0; x < cur_wid; x++)
1840 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1843 wiz_lite(TRUE, FALSE);
1847 /* Summon Random Monster(s) */
1849 if (command_arg <= 0) command_arg = 1;
1850 do_cmd_wiz_summon(command_arg);
1855 teleport_player(100);
1858 /* Very Good Objects */
1860 if (command_arg <= 0) command_arg = 1;
1861 acquirement(py, px, command_arg, TRUE, TRUE);
1864 /* Wizard Light the Level */
1866 wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
1869 /* Increase Experience */
1873 gain_exp(command_arg);
1877 gain_exp(p_ptr->exp + 1);
1881 /* Zap Monsters (Genocide) */
1887 do_cmd_wiz_zap_all();
1890 /* Hack -- whatever I desire */
1892 do_cmd_wiz_hack_ben();
1895 /* Not a Wizard Command */
1897 msg_print("That is not a valid debug command.");