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, maxr0 = 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 */
234 total[i] += prob / GREAT_OBJ / K_MAX_DEPTH;
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] > maxr0) maxr0 = rarity[i];
249 if (total[i] > maxt) maxt = total[i];
251 maxr = maxr0 / GREAT_OBJ / K_MAX_DEPTH;
252 if (maxr == 0) maxr = 1;
254 /* Simulate a log graph */
255 if (maxt / maxr > 32)
260 if (maxt / maxr > 1024)
265 if (maxt / maxr > 32768L)
271 /* Calculate probabilities for each range */
272 for (i = 0; i < 22; i++)
274 /* Shift the values into view */
275 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
279 display[i] += rarity[j] * maxt / total[j];
283 if (display[i] > maxd) maxd = display[i];
287 for (i = 0; i < 22; i++)
289 display[i] = display[i] * 10 / maxd;
292 /* Graph the rarities */
293 for (i = 0; i < 22; i++)
295 Term_putch(col, row + i + 1, TERM_WHITE, '|');
297 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
300 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
302 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
306 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
310 /* Make it look nice */
316 * Hack -- Teleport to the target
318 static void do_cmd_wiz_bamf(void)
320 /* Must have a target */
321 if (!target_who) return;
323 /* Teleport to the target */
324 teleport_player_to(target_row, target_col, FALSE);
329 * Aux function for "do_cmd_wiz_change()". -RAK-
331 static void do_cmd_wiz_change_aux(void)
341 /* Query the stats */
342 for (i = 0; i < 6; i++)
345 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
348 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
351 if (!get_string(ppp, tmp_val, 3)) return;
354 tmp_int = atoi(tmp_val);
357 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
358 else if (tmp_int < 3) tmp_int = 3;
361 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
366 sprintf(tmp_val, "8000");
370 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
372 if (!get_string("Proficiency: ", tmp_val, 9)) return;
376 tmp_s16b = atoi(tmp_val);
379 if (tmp_s16b < 0) tmp_s16b = 0L;
380 if (tmp_s16b > 8000) tmp_s16b = 8000L;
382 for (j = 0; j <= TV_SWORD - TV_BOW;j++)
384 for (i = 0;i < 64;i++)
386 weapon_exp[j][i] = tmp_s16b;
387 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];
391 for (j = 0; j < 10; j++)
393 skill_exp[j] = tmp_s16b;
394 if (skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
397 for (j = 0; j < 32; j++)
398 spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
400 spell_exp[j] = (tmp_s16b > 1400 ? 1400 : tmp_s16b);
403 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
406 if (!get_string("Gold: ", tmp_val, 9)) return;
409 tmp_long = atol(tmp_val);
412 if (tmp_long < 0) tmp_long = 0L;
415 p_ptr->au = tmp_long;
419 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
422 if (!get_string("Experience: ", tmp_val, 9)) return;
425 tmp_long = atol(tmp_val);
428 if (tmp_long < 0) tmp_long = 0L;
430 if (p_ptr->prace != RACE_ANDROID)
433 p_ptr->max_exp = tmp_long;
434 p_ptr->exp = tmp_long;
443 * Change various "permanent" player variables.
445 static void do_cmd_wiz_change(void)
448 do_cmd_wiz_change_aux();
450 /* Redraw everything */
456 * Wizard routines for creating objects -RAK-
457 * And for manipulating them! -Bernd-
459 * This has been rewritten to make the whole procedure
460 * of debugging objects much easier and more comfortable.
462 * The following functions are meant to play with objects:
463 * Create, modify, roll for them (for statistic purposes) and more.
464 * The original functions were by RAK.
465 * The function to show an item's debug information was written
466 * by David Reeve Sward <sward+@CMU.EDU>.
467 * Bernd (wiebelt@mathematik.hu-berlin.de)
469 * Here are the low-level functions
470 * - wiz_display_item()
471 * display an item's debug-info
472 * - wiz_create_itemtype()
473 * specify tval and sval (type and subtype of object)
475 * specify pval, +AC, +tohit, +todam
476 * Note that the wizard can leave this function anytime,
477 * thus accepting the default-values for the remaining values.
478 * pval comes first now, since it is most important.
479 * - wiz_reroll_item()
480 * apply some magic to the item or turn it into an artifact.
482 * Get some statistics about the rarity of an item:
483 * We create a lot of fake items and see if they are of the
484 * same type (tval and sval), then we compare pval and +AC.
485 * If the fake-item is better or equal it is counted.
486 * Note that cursed items that are better or equal (absolute values)
488 * HINT: This is *very* useful for balancing the game!
489 * - wiz_quantity_item()
490 * change the quantity of an item, but be sane about it.
492 * And now the high-level functions
493 * - do_cmd_wiz_play()
494 * play with an existing object
495 * - wiz_create_item()
496 * create a new object
498 * Note -- You do not have to specify "pval" and other item-properties
499 * directly. Just apply magic until you are satisfied with the item.
501 * Note -- For some items (such as wands, staffs, some rings, etc), you
502 * must apply magic, or you will get "broken" or "uncharged" objects.
504 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
505 * the artifact. Be careful.
507 * Hack -- this function will allow you to create multiple artifacts.
508 * This "feature" may induce crashes or other nasty effects.
512 * Just display an item's properties (debug-info)
513 * Originally by David Reeve Sward <sward+@CMU.EDU>
514 * Verbose item flags by -Bernd-
516 static void wiz_display_item(object_type *o_ptr)
522 /* Extract the flags */
523 object_flags(o_ptr, &f1, &f2, &f3);
525 /* Clear the screen */
526 for (i = 1; i <= 23; i++) prt("", i, j - 2);
528 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
531 object_desc_store(buf, o_ptr, TRUE, 3);
535 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
536 o_ptr->k_idx, get_object_level(o_ptr),
537 o_ptr->tval, o_ptr->sval), 4, j);
539 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
540 o_ptr->number, o_ptr->weight,
541 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
543 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
544 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
546 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
547 o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
549 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
550 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
552 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d",
553 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5), 9, j);
555 prt("+------------FLAGS1------------+", 10, j);
556 prt("AFFECT........SLAY........BRAND.", 11, j);
557 prt(" mr cvae xsqpaefc", 12, j);
558 prt("siwdccsissidsahanvudotgddhuoclio", 13, j);
559 prt("tnieohtrtrnipttmiinmrrnrrraiierl", 14, j);
560 prt("rtsxnarylcfgdkcpmldncltggpksdced", 15, j);
561 prt_binary(f1, 16, j);
563 prt("+------------FLAGS2------------+", 17, j);
564 prt("SUST....IMMUN.RESIST............", 18, j);
565 prt(" aefctrpsaefcpfldbc sn ", 19, j);
566 prt("siwdcc clioheatcliooeialoshtncd", 20, j);
567 prt("tnieoh ierlrfraierliatrnnnrhehi", 21, j);
568 prt("rtsxna..dcedwlatdcedsrekdfddrxss", 22, j);
569 prt_binary(f2, 23, j);
571 prt("+------------FLAGS3------------+", 10, j+32);
572 prt("fe cnn t i stdrmsiiii d abchp", 11, j+32);
573 prt("aa aoomyehsnlleeieihgggg rtgluvr", 12, j+32);
574 prt("uu utmacaihseielgggonnnnaaerercc", 13, j+32);
575 prt("rr reanusdotvtieeehtrrrrcilassuu", 14, j+32);
576 prt("aa algaryewaienpsntsaefctnevserr", 15, j+32);
577 prt_binary(f3, 16, j+32);
582 * A structure to hold a tval and its description
584 typedef struct tval_desc
591 * A list of tvals and their textual names
593 static tval_desc tvals[] =
595 { TV_SWORD, "Sword" },
596 { TV_POLEARM, "Polearm" },
597 { TV_HAFTED, "Hafted Weapon" },
599 { TV_ARROW, "Arrows" },
600 { TV_BOLT, "Bolts" },
601 { TV_SHOT, "Shots" },
602 { TV_SHIELD, "Shield" },
603 { TV_CROWN, "Crown" },
605 { TV_GLOVES, "Gloves" },
606 { TV_BOOTS, "Boots" },
607 { TV_CLOAK, "Cloak" },
608 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
609 { TV_HARD_ARMOR, "Hard Armor" },
610 { TV_SOFT_ARMOR, "Soft Armor" },
612 { TV_AMULET, "Amulet" },
614 { TV_POTION, "Potion" },
615 { TV_SCROLL, "Scroll" },
617 { TV_STAFF, "Staff" },
619 { TV_LIFE_BOOK, "Life Spellbook" },
620 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
621 { TV_NATURE_BOOK, "Nature Spellbook" },
622 { TV_CHAOS_BOOK, "Chaos Spellbook" },
623 { TV_DEATH_BOOK, "Death Spellbook" },
624 { TV_TRUMP_BOOK, "Trump Spellbook" },
625 { TV_ARCANE_BOOK, "Arcane Spellbook" },
626 { TV_ENCHANT_BOOK, "Craft Spellbook"},
627 { TV_DAEMON_BOOK, "Daemon Spellbook"},
628 { TV_MUSIC_BOOK, "Music Spellbook" },
629 { TV_HISSATSU_BOOK, "Book of Kendo" },
630 { TV_PARCHEMENT, "Parchement" },
631 { TV_WHISTLE, "Whistle" },
632 { TV_SPIKE, "Spikes" },
633 { TV_DIGGING, "Digger" },
634 { TV_CHEST, "Chest" },
635 { TV_CAPTURE, "Capture Ball" },
636 { TV_CARD, "Express Card" },
637 { TV_FIGURINE, "Magical Figurine" },
638 { TV_STATUE, "Statue" },
639 { TV_CORPSE, "Corpse" },
641 { TV_FLASK, "Flask" },
643 { TV_SKELETON, "Skeleton" },
649 * Strip an "object name" into a buffer
651 void strip_name(char *buf, int k_idx)
655 object_kind *k_ptr = &k_info[k_idx];
657 cptr str = (k_name + k_ptr->name);
660 /* Skip past leading characters */
661 while ((*str == ' ') || (*str == '&')) str++;
663 /* Copy useful chars */
664 for (t = buf; *str; str++)
667 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
669 if (*str != '~') *t++ = *str;
672 /* Terminate the new name */
678 * Specify tval and sval (type and subtype of object) originally
679 * by RAK, heavily modified by -Bernd-
681 * This function returns the k_idx of an object type, or zero if failed
683 * List up to 50 choices in three columns
685 static int wiz_create_itemtype(void)
702 /* Print all tval's and their descriptions */
703 for (num = 0; (num < 80) && tvals[num].tval; num++)
705 row = 2 + (num % 20);
706 col = 20 * (num / 20);
708 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
711 /* Me need to know the maximal possible tval_index */
715 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
718 for (num = 0; num < max_num; num++)
720 if (listsym[num] == ch) break;
723 /* Bail out if choice is illegal */
724 if ((num < 0) || (num >= max_num)) return (0);
726 /* Base object type chosen, fill in tval */
727 tval = tvals[num].tval;
728 tval_desc = tvals[num].desc;
731 /*** And now we go for k_idx ***/
736 /* We have to search the whole itemlist. */
737 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
739 object_kind *k_ptr = &k_info[i];
741 /* Analyze matching items */
742 if (k_ptr->tval == tval)
745 row = 2 + (num % 20);
746 col = 20 * (num / 20);
750 /* Acquire the "name" of object "i" */
754 prt(format("[%c] %s", ch, buf), row, col);
756 /* Remember the object index */
761 /* Me need to know the maximal possible remembered object_index */
765 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
768 for (num = 0; num < max_num; num++)
770 if (listsym[num] == ch) break;
773 /* Bail out if choice is "illegal" */
774 if ((num < 0) || (num >= max_num)) return (0);
776 /* And return successful */
777 return (choice[num]);
784 static void wiz_tweak_item(object_type *o_ptr)
790 /* Hack -- leave artifacts alone */
791 if (artifact_p(o_ptr) || o_ptr->art_name) return;
793 p = "Enter new 'pval' setting: ";
794 sprintf(tmp_val, "%d", o_ptr->pval);
795 if (!get_string(p, tmp_val, 5)) return;
796 o_ptr->pval = atoi(tmp_val);
797 wiz_display_item(o_ptr);
799 p = "Enter new 'to_a' setting: ";
800 sprintf(tmp_val, "%d", o_ptr->to_a);
801 if (!get_string(p, tmp_val, 5)) return;
802 o_ptr->to_a = atoi(tmp_val);
803 wiz_display_item(o_ptr);
805 p = "Enter new 'to_h' setting: ";
806 sprintf(tmp_val, "%d", o_ptr->to_h);
807 if (!get_string(p, tmp_val, 5)) return;
808 o_ptr->to_h = atoi(tmp_val);
809 wiz_display_item(o_ptr);
811 p = "Enter new 'to_d' setting: ";
812 sprintf(tmp_val, "%d", o_ptr->to_d);
813 if (!get_string(p, tmp_val, 5)) return;
814 o_ptr->to_d = atoi(tmp_val);
815 wiz_display_item(o_ptr);
820 * Apply magic to an item or turn it into an artifact. -Bernd-
822 static void wiz_reroll_item(object_type *o_ptr)
829 bool changed = FALSE;
832 /* Hack -- leave artifacts alone */
833 if (artifact_p(o_ptr) || o_ptr->art_name) return;
836 /* Get local object */
839 /* Copy the object */
840 object_copy(q_ptr, o_ptr);
843 /* Main loop. Ask for magification and artifactification */
846 /* Display full item debug information */
847 wiz_display_item(q_ptr);
849 /* Ask wizard what to do. */
850 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
852 /* Preserve wizard-generated artifacts */
853 if (artifact_p(q_ptr))
855 a_info[q_ptr->name1].cur_num = 0;
863 /* Create/change it! */
864 if (ch == 'A' || ch == 'a')
870 /* Preserve wizard-generated artifacts */
871 if (artifact_p(q_ptr))
873 a_info[q_ptr->name1].cur_num = 0;
879 /* Apply bad magic, but first clear object */
882 object_prep(q_ptr, o_ptr->k_idx);
883 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
886 /* Apply bad magic, but first clear object */
889 object_prep(q_ptr, o_ptr->k_idx);
890 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
893 /* Apply normal magic, but first clear object */
896 object_prep(q_ptr, o_ptr->k_idx);
897 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
900 /* Apply good magic, but first clear object */
903 object_prep(q_ptr, o_ptr->k_idx);
904 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
907 /* Apply great magic, but first clear object */
910 object_prep(q_ptr, o_ptr->k_idx);
911 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
916 object_prep(q_ptr, o_ptr->k_idx);
917 apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
919 /* Failed to create normal artifact; make a random one */
920 if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
924 q_ptr->iy = o_ptr->iy;
925 q_ptr->ix = o_ptr->ix;
926 q_ptr->next_o_idx = o_ptr->next_o_idx;
927 q_ptr->marked = o_ptr->marked;
935 object_copy(o_ptr, q_ptr);
937 /* Recalculate bonuses */
938 p_ptr->update |= (PU_BONUS);
940 /* Combine / Reorder the pack (later) */
941 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
944 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
951 * Try to create an item again. Output some statistics. -Bernd-
953 * The statistics are correct now. We acquire a clean grid, and then
954 * repeatedly place an object in this grid, copying it into an item
955 * holder, and then deleting the object. We fiddle with the artifact
956 * counter flags to prevent weirdness. We use the items to collect
957 * statistics on item creation relative to the initial item.
959 static void wiz_statistics(object_type *o_ptr)
961 u32b i, matches, better, worse, other, correct;
963 u32b test_roll = 1000000;
973 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
975 cptr p = "Enter number of items to roll: ";
979 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
980 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
986 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
989 wiz_display_item(o_ptr);
992 if (!get_com(pmt, &ch, FALSE)) break;
994 if (ch == 'n' || ch == 'N')
1000 else if (ch == 'g' || ch == 'G')
1006 else if (ch == 'e' || ch == 'E')
1010 quality = "excellent";
1019 sprintf(tmp_val, "%ld", test_roll);
1020 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1021 test_roll = MAX(1, test_roll);
1023 /* Let us know what we are doing */
1024 msg_format("Creating a lot of %s items. Base level = %d.",
1025 quality, dun_level);
1028 /* Set counters to zero */
1029 correct = matches = better = worse = other = 0;
1031 /* Let's rock and roll */
1032 for (i = 0; i <= test_roll; i++)
1034 /* Output every few rolls */
1035 if ((i < 100) || (i % 100 == 0))
1040 /* Allow interupt */
1050 /* Dump the stats */
1051 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1056 /* Get local object */
1059 /* Wipe the object */
1062 /* Create an object */
1063 make_object(q_ptr, good, great);
1066 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1067 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1070 /* Test for the same tval and sval. */
1071 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1072 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1074 /* One more correct item */
1077 /* Check for match */
1078 if ((q_ptr->pval == o_ptr->pval) &&
1079 (q_ptr->to_a == o_ptr->to_a) &&
1080 (q_ptr->to_h == o_ptr->to_h) &&
1081 (q_ptr->to_d == o_ptr->to_d) &&
1082 (q_ptr->name1 == o_ptr->name1))
1087 /* Check for better */
1088 else if ((q_ptr->pval >= o_ptr->pval) &&
1089 (q_ptr->to_a >= o_ptr->to_a) &&
1090 (q_ptr->to_h >= o_ptr->to_h) &&
1091 (q_ptr->to_d >= o_ptr->to_d))
1096 /* Check for worse */
1097 else if ((q_ptr->pval <= o_ptr->pval) &&
1098 (q_ptr->to_a <= o_ptr->to_a) &&
1099 (q_ptr->to_h <= o_ptr->to_h) &&
1100 (q_ptr->to_d <= o_ptr->to_d))
1105 /* Assume different */
1113 msg_format(q, i, correct, matches, better, worse, other);
1118 /* Hack -- Normally only make a single artifact */
1119 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1124 * Change the quantity of a the item
1126 static void wiz_quantity_item(object_type *o_ptr)
1128 int tmp_int, tmp_qnt;
1133 /* Never duplicate artifacts */
1134 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1136 /* Store old quantity. -LM- */
1137 tmp_qnt = o_ptr->number;
1140 sprintf(tmp_val, "%d", o_ptr->number);
1143 if (get_string("Quantity: ", tmp_val, 2))
1146 tmp_int = atoi(tmp_val);
1149 if (tmp_int < 1) tmp_int = 1;
1150 if (tmp_int > 99) tmp_int = 99;
1152 /* Accept modifications */
1153 o_ptr->number = tmp_int;
1155 /* Hack -- rod pvals must change if the number in the stack does. -LM- */
1156 if (o_ptr->tval == TV_ROD)
1157 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1164 * Play with an item. Options include:
1165 * - Output statistics (via wiz_roll_item)
1166 * - Reroll item (via wiz_reroll_item)
1167 * - Change properties (via wiz_tweak_item)
1168 * - Change the number of items (via wiz_quantity_item)
1170 static void do_cmd_wiz_play(void)
1185 item_tester_no_ryoute = TRUE;
1187 q = "Play with which object? ";
1188 s = "You have nothing to play with.";
1189 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1191 /* Get the item (in the pack) */
1194 o_ptr = &inventory[item];
1197 /* Get the item (on the floor) */
1200 o_ptr = &o_list[0 - item];
1204 /* The item was not changed */
1208 /* Save the screen */
1212 /* Get local object */
1216 object_copy(q_ptr, o_ptr);
1222 /* Display the item */
1223 wiz_display_item(q_ptr);
1226 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1232 if (ch == 'A' || ch == 'a')
1238 if (ch == 's' || ch == 'S')
1240 wiz_statistics(q_ptr);
1243 if (ch == 'r' || ch == 'r')
1245 wiz_reroll_item(q_ptr);
1248 if (ch == 't' || ch == 'T')
1250 wiz_tweak_item(q_ptr);
1253 if (ch == 'q' || ch == 'Q')
1255 wiz_quantity_item(q_ptr);
1260 /* Restore the screen */
1268 msg_print("Changes accepted.");
1271 object_copy(o_ptr, q_ptr);
1273 /* Recalculate bonuses */
1274 p_ptr->update |= (PU_BONUS);
1276 /* Combine / Reorder the pack (later) */
1277 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1280 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1286 msg_print("Changes ignored.");
1292 * Wizard routine for creating objects -RAK-
1293 * Heavily modified to allow magification and artifactification -Bernd-
1295 * Note that wizards cannot create objects on top of other objects.
1297 * Hack -- this routine always makes a "dungeon object", and applies
1298 * magic to it, and attempts to decline cursed items.
1300 static void wiz_create_item(void)
1308 /* Save the screen */
1311 /* Get object base type */
1312 k_idx = wiz_create_itemtype();
1314 /* Restore the screen */
1318 /* Return if failed */
1321 /* Get local object */
1324 /* Create the item */
1325 object_prep(q_ptr, k_idx);
1327 if (k_info[k_idx].flags3 & TR3_INSTA_ART)
1332 for (i = 1; i < max_a_idx; i++)
1334 /* Ignore incorrect tval */
1335 if (a_info[i].tval != q_ptr->tval) continue;
1337 /* Ignore incorrect sval */
1338 if (a_info[i].sval != q_ptr->sval) continue;
1340 /* Choose this artifact */
1346 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1351 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
1354 /* Drop the object from heaven */
1355 (void)drop_near(q_ptr, -1, py, px);
1358 msg_print("Allocated.");
1363 * Cure everything instantly
1365 static void do_cmd_wiz_cure_all(void)
1368 (void)remove_all_curse();
1371 (void)res_stat(A_STR);
1372 (void)res_stat(A_INT);
1373 (void)res_stat(A_WIS);
1374 (void)res_stat(A_CON);
1375 (void)res_stat(A_DEX);
1376 (void)res_stat(A_CHR);
1378 /* Restore the level */
1379 (void)restore_level();
1381 /* Heal the player */
1382 p_ptr->chp = p_ptr->mhp;
1383 p_ptr->chp_frac = 0;
1386 if (p_ptr->csp < p_ptr->msp)
1388 p_ptr->csp = p_ptr->msp;
1389 p_ptr->csp_frac = 0;
1394 (void)set_confused(0);
1395 (void)set_poisoned(0);
1396 (void)set_afraid(0);
1397 (void)set_paralyzed(0);
1401 (void)set_slow(0, TRUE);
1403 /* No longer hungry */
1404 (void)set_food(PY_FOOD_MAX - 1);
1406 /* Redraw everything */
1414 static void do_cmd_wiz_jump(void)
1417 if (command_arg <= 0)
1424 sprintf(ppp, "Jump which dungeon : ");
1427 sprintf(tmp_val, "%d", dungeon_type);
1429 /* Ask for a level */
1430 if (!get_string(ppp, tmp_val, 2)) return;
1432 dungeon_type = atoi(tmp_val);
1433 if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
1436 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
1439 sprintf(tmp_val, "%d", dun_level);
1441 /* Ask for a level */
1442 if (!get_string(ppp, tmp_val, 10)) return;
1444 /* Extract request */
1445 command_arg = atoi(tmp_val);
1449 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1452 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1454 /* Accept request */
1455 msg_format("You jump to dungeon level %d.", command_arg);
1457 if (autosave_l) do_cmd_save_game(TRUE);
1460 dun_level = command_arg;
1462 if (!dun_level) dungeon_type = 0;
1463 p_ptr->inside_arena = FALSE;
1464 leaving_quest = p_ptr->inside_quest;
1466 /* Leaving an 'only once' quest marks it as failed */
1467 if (leaving_quest &&
1468 (quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
1469 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
1471 quest[leaving_quest].status = QUEST_STATUS_FAILED;
1472 quest[leaving_quest].complev = (byte)p_ptr->lev;
1473 if (record_fix_quest)
1474 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1477 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1479 p_ptr->inside_quest = 0;
1480 p_ptr->leftbldg = FALSE;
1484 p_ptr->leaving = TRUE;
1489 * Become aware of a lot of objects
1491 static void do_cmd_wiz_learn(void)
1498 /* Scan every object */
1499 for (i = 1; i < max_k_idx; i++)
1501 object_kind *k_ptr = &k_info[i];
1503 /* Induce awareness */
1504 if (k_ptr->level <= command_arg)
1506 /* Get local object */
1509 /* Prepare object */
1510 object_prep(q_ptr, i);
1513 object_aware(q_ptr);
1520 * Summon some creatures
1522 static void do_cmd_wiz_summon(int num)
1526 for (i = 0; i < num; i++)
1528 (void)summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, FALSE);
1534 * Summon a creature of the specified type
1536 * XXX XXX XXX This function is rather dangerous
1538 static void do_cmd_wiz_named(int r_idx, bool slp)
1543 /* if (!r_idx) return; */
1545 /* Prevent illegal monsters */
1546 if (r_idx >= max_r_idx) return;
1549 for (i = 0; i < 10; i++)
1553 /* Pick a location */
1554 scatter(&y, &x, py, px, d, 0);
1556 /* Require empty grids */
1557 if (!cave_empty_bold(y, x)) continue;
1559 /* Place it (allow groups) */
1560 if (place_monster_aux(y, x, r_idx, slp, TRUE, FALSE, FALSE, FALSE, FALSE)) break;
1566 * Summon a creature of the specified type
1568 * XXX XXX XXX This function is rather dangerous
1570 static void do_cmd_wiz_named_friendly(int r_idx, bool slp)
1572 (void) summon_named_creature(py, px, r_idx, slp, TRUE, TRUE, TRUE);
1578 * Hack -- Delete all nearby monsters
1580 static void do_cmd_wiz_zap(void)
1585 /* Genocide everyone nearby */
1586 for (i = 1; i < m_max; i++)
1588 monster_type *m_ptr = &m_list[i];
1590 /* Paranoia -- Skip dead monsters */
1591 if (!m_ptr->r_idx) continue;
1593 /* Delete nearby monsters */
1594 if (m_ptr->cdis <= MAX_SIGHT)
1596 if (i == p_ptr->riding)
1599 p_ptr->redraw |= (PR_EXTRA);
1601 delete_monster_idx(i);
1608 * Hack -- Delete all monsters
1610 static void do_cmd_wiz_zap_all(void)
1614 /* Genocide everyone */
1615 for (i = 1; i < m_max; i++)
1617 monster_type *m_ptr = &m_list[i];
1619 /* Paranoia -- Skip dead monsters */
1620 if (!m_ptr->r_idx) continue;
1622 if (i == p_ptr->riding)
1625 p_ptr->redraw |= (PR_EXTRA);
1628 /* Delete this monster */
1629 delete_monster_idx(i);
1634 #ifdef ALLOW_SPOILERS
1639 extern void do_cmd_spoilers(void);
1641 #endif /* ALLOW_SPOILERS */
1646 * Hack -- declare external function
1648 extern void do_cmd_debug(void);
1653 * Ask for and parse a "debug command"
1654 * The "command_arg" may have been set.
1656 void do_cmd_debug(void)
1662 /* Get a "debug command" */
1663 get_com("Debug Command: ", &cmd, FALSE);
1665 /* Analyze the command */
1676 #ifdef ALLOW_SPOILERS
1678 /* Hack -- Generate Spoilers */
1683 #endif /* ALLOW_SPOILERS */
1692 /* Cure all maladies */
1694 do_cmd_wiz_cure_all();
1697 /* Know alignment */
1699 msg_format("Your alignment is %d.", p_ptr->align);
1702 /* Teleport to target */
1711 /* Create any object */
1716 /* Create a named artifact */
1718 wiz_create_named_art(command_arg);
1721 /* Detect everything */
1723 detect_all(DETECT_RAD_ALL*3);
1726 /* Dimension_door */
1728 wiz_dimension_door();
1731 /* Edit character */
1733 do_cmd_wiz_change();
1736 /* View item info */
1738 identify_fully(FALSE);
1743 if (command_arg <= 0) command_arg = 1;
1744 acquirement(py, px, command_arg, FALSE, TRUE);
1747 /* Hitpoint rerating */
1749 do_cmd_rerate(TRUE); break;
1751 #ifdef MONSTER_HORDES
1753 do_cmd_summon_horde(); break;
1754 #endif /* MONSTER_HORDES */
1758 (void)ident_spell(FALSE);
1761 /* Go up or down in the dungeon */
1766 /* Self-Knowledge */
1771 /* Learn about objects */
1778 map_area(DETECT_RAD_ALL);
1783 (void)gain_random_mutation(command_arg);
1786 /* Specific reward */
1788 (void)gain_level_reward(command_arg);
1791 /* Summon _friendly_ named monster */
1793 do_cmd_wiz_named_friendly(command_arg, TRUE);
1796 /* Summon Named Monster */
1798 do_cmd_wiz_named(command_arg, TRUE);
1801 /* Object playing routines */
1808 teleport_player(10);
1812 /* Complete a Quest -KMW- */
1815 for (i = 0; i < max_quests; i++)
1817 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1819 p_ptr->quest[i].status++;
1820 msg_print("Completed Quest");
1825 if (i == max_quests)
1827 msg_print("No current quest");
1834 /* Make every dungeon square "known" to test streamers -KMW- */
1837 for(y = 0; y < cur_hgt; y++)
1839 for(x = 0; x < cur_wid; x++)
1841 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1844 wiz_lite(TRUE, FALSE);
1848 /* Summon Random Monster(s) */
1850 if (command_arg <= 0) command_arg = 1;
1851 do_cmd_wiz_summon(command_arg);
1856 teleport_player(100);
1859 /* Very Good Objects */
1861 if (command_arg <= 0) command_arg = 1;
1862 acquirement(py, px, command_arg, TRUE, TRUE);
1865 /* Wizard Light the Level */
1867 wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
1870 /* Increase Experience */
1874 gain_exp(command_arg);
1878 gain_exp(p_ptr->exp + 1);
1882 /* Zap Monsters (Genocide) */
1888 do_cmd_wiz_zap_all();
1891 /* Hack -- whatever I desire */
1893 do_cmd_wiz_hack_ben();
1896 /* Not a Wizard Command */
1898 msg_print("That is not a valid debug command.");