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 */
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] / GREAT_OBJ / K_MAX_DEPTH > maxr)
249 maxr = rarity[i] / GREAT_OBJ / K_MAX_DEPTH;
250 if (total[i] > maxt) maxt = total[i];
253 /* Simulate a log graph */
254 if (maxt / maxr > 32)
259 if (maxt / maxr > 1024)
264 if (maxt / maxr > 32768L)
270 /* Calculate probabilities for each range */
271 for (i = 0; i < 22; i++)
273 /* Shift the values into view */
274 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
276 display[i] += rarity[j] * 10 * maxt / total[j];
280 if (display[i] > maxd) maxd = display[i];
284 for (i = 0; i < 22; i++)
286 display[i] = display[i] * 10 / maxd;
289 /* Graph the rarities */
290 for (i = 0; i < 22; i++)
292 Term_putch(col, row + i + 1, TERM_WHITE, '|');
294 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
297 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
299 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
303 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
307 /* Make it look nice */
313 * Hack -- Teleport to the target
315 static void do_cmd_wiz_bamf(void)
317 /* Must have a target */
318 if (!target_who) return;
320 /* Teleport to the target */
321 teleport_player_to(target_row, target_col, FALSE);
326 * Aux function for "do_cmd_wiz_change()". -RAK-
328 static void do_cmd_wiz_change_aux(void)
338 /* Query the stats */
339 for (i = 0; i < 6; i++)
342 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
345 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
348 if (!get_string(ppp, tmp_val, 3)) return;
351 tmp_int = atoi(tmp_val);
354 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
355 else if (tmp_int < 3) tmp_int = 3;
358 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
363 sprintf(tmp_val, "8000");
367 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
369 if (!get_string("Proficiency: ", tmp_val, 9)) return;
373 tmp_s16b = atoi(tmp_val);
376 if (tmp_s16b < 0) tmp_s16b = 0L;
377 if (tmp_s16b > 8000) tmp_s16b = 8000L;
379 for (j = 0; j <= TV_SWORD - TV_BOW;j++)
381 for (i = 0;i < 64;i++)
383 weapon_exp[j][i] = tmp_s16b;
384 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];
388 for (j = 0; j < 10; j++)
390 skill_exp[j] = tmp_s16b;
391 if (skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
394 for (j = 0; j < 32; j++)
395 spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
397 spell_exp[j] = (tmp_s16b > 1400 ? 1400 : tmp_s16b);
400 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
403 if (!get_string("Gold: ", tmp_val, 9)) return;
406 tmp_long = atol(tmp_val);
409 if (tmp_long < 0) tmp_long = 0L;
412 p_ptr->au = tmp_long;
416 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
419 if (!get_string("Experience: ", tmp_val, 9)) return;
422 tmp_long = atol(tmp_val);
425 if (tmp_long < 0) tmp_long = 0L;
427 if (p_ptr->prace != RACE_ANDROID)
430 p_ptr->max_exp = tmp_long;
431 p_ptr->exp = tmp_long;
440 * Change various "permanent" player variables.
442 static void do_cmd_wiz_change(void)
445 do_cmd_wiz_change_aux();
447 /* Redraw everything */
453 * Wizard routines for creating objects -RAK-
454 * And for manipulating them! -Bernd-
456 * This has been rewritten to make the whole procedure
457 * of debugging objects much easier and more comfortable.
459 * The following functions are meant to play with objects:
460 * Create, modify, roll for them (for statistic purposes) and more.
461 * The original functions were by RAK.
462 * The function to show an item's debug information was written
463 * by David Reeve Sward <sward+@CMU.EDU>.
464 * Bernd (wiebelt@mathematik.hu-berlin.de)
466 * Here are the low-level functions
467 * - wiz_display_item()
468 * display an item's debug-info
469 * - wiz_create_itemtype()
470 * specify tval and sval (type and subtype of object)
472 * specify pval, +AC, +tohit, +todam
473 * Note that the wizard can leave this function anytime,
474 * thus accepting the default-values for the remaining values.
475 * pval comes first now, since it is most important.
476 * - wiz_reroll_item()
477 * apply some magic to the item or turn it into an artifact.
479 * Get some statistics about the rarity of an item:
480 * We create a lot of fake items and see if they are of the
481 * same type (tval and sval), then we compare pval and +AC.
482 * If the fake-item is better or equal it is counted.
483 * Note that cursed items that are better or equal (absolute values)
485 * HINT: This is *very* useful for balancing the game!
486 * - wiz_quantity_item()
487 * change the quantity of an item, but be sane about it.
489 * And now the high-level functions
490 * - do_cmd_wiz_play()
491 * play with an existing object
492 * - wiz_create_item()
493 * create a new object
495 * Note -- You do not have to specify "pval" and other item-properties
496 * directly. Just apply magic until you are satisfied with the item.
498 * Note -- For some items (such as wands, staffs, some rings, etc), you
499 * must apply magic, or you will get "broken" or "uncharged" objects.
501 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
502 * the artifact. Be careful.
504 * Hack -- this function will allow you to create multiple artifacts.
505 * This "feature" may induce crashes or other nasty effects.
509 * Just display an item's properties (debug-info)
510 * Originally by David Reeve Sward <sward+@CMU.EDU>
511 * Verbose item flags by -Bernd-
513 static void wiz_display_item(object_type *o_ptr)
519 /* Extract the flags */
520 object_flags(o_ptr, &f1, &f2, &f3);
522 /* Clear the screen */
523 for (i = 1; i <= 23; i++) prt("", i, j - 2);
525 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
528 object_desc_store(buf, o_ptr, TRUE, 3);
532 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
533 o_ptr->k_idx, get_object_level(o_ptr),
534 o_ptr->tval, o_ptr->sval), 4, j);
536 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
537 o_ptr->number, o_ptr->weight,
538 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
540 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
541 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
543 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
544 o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
546 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
547 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
549 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d",
550 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5), 9, j);
552 prt("+------------FLAGS1------------+", 10, j);
553 prt("AFFECT........SLAY........BRAND.", 11, j);
554 prt(" mr cvae xsqpaefc", 12, j);
555 prt("siwdccsissidsahanvudotgddhuoclio", 13, j);
556 prt("tnieohtrtrnipttmiinmrrnrrraiierl", 14, j);
557 prt("rtsxnarylcfgdkcpmldncltggpksdced", 15, j);
558 prt_binary(f1, 16, j);
560 prt("+------------FLAGS2------------+", 17, j);
561 prt("SUST....IMMUN.RESIST............", 18, j);
562 prt(" aefctrpsaefcpfldbc sn ", 19, j);
563 prt("siwdcc clioheatcliooeialoshtncd", 20, j);
564 prt("tnieoh ierlrfraierliatrnnnrhehi", 21, j);
565 prt("rtsxna..dcedwlatdcedsrekdfddrxss", 22, j);
566 prt_binary(f2, 23, j);
568 prt("+------------FLAGS3------------+", 10, j+32);
569 prt("fe cnn t i stdrmsiiii d abchp", 11, j+32);
570 prt("aa aoomyehsnlleeieihgggg rtgluvr", 12, j+32);
571 prt("uu utmacaihseielgggonnnnaaerercc", 13, j+32);
572 prt("rr reanusdotvtieeehtrrrrcilassuu", 14, j+32);
573 prt("aa algaryewaienpsntsaefctnevserr", 15, j+32);
574 prt_binary(f3, 16, j+32);
579 * A structure to hold a tval and its description
581 typedef struct tval_desc
588 * A list of tvals and their textual names
590 static tval_desc tvals[] =
592 { TV_SWORD, "Sword" },
593 { TV_POLEARM, "Polearm" },
594 { TV_HAFTED, "Hafted Weapon" },
596 { TV_ARROW, "Arrows" },
597 { TV_BOLT, "Bolts" },
598 { TV_SHOT, "Shots" },
599 { TV_SHIELD, "Shield" },
600 { TV_CROWN, "Crown" },
602 { TV_GLOVES, "Gloves" },
603 { TV_BOOTS, "Boots" },
604 { TV_CLOAK, "Cloak" },
605 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
606 { TV_HARD_ARMOR, "Hard Armor" },
607 { TV_SOFT_ARMOR, "Soft Armor" },
609 { TV_AMULET, "Amulet" },
611 { TV_POTION, "Potion" },
612 { TV_SCROLL, "Scroll" },
614 { TV_STAFF, "Staff" },
616 { TV_LIFE_BOOK, "Life Spellbook" },
617 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
618 { TV_NATURE_BOOK, "Nature Spellbook" },
619 { TV_CHAOS_BOOK, "Chaos Spellbook" },
620 { TV_DEATH_BOOK, "Death Spellbook" },
621 { TV_TRUMP_BOOK, "Trump Spellbook" },
622 { TV_ARCANE_BOOK, "Arcane Spellbook" },
623 { TV_ENCHANT_BOOK, "Craft Spellbook"},
624 { TV_DAEMON_BOOK, "Daemon Spellbook"},
625 { TV_MUSIC_BOOK, "Music Spellbook" },
626 { TV_HISSATSU_BOOK, "Book of Kendo" },
627 { TV_PARCHEMENT, "Parchement" },
628 { TV_WHISTLE, "Whistle" },
629 { TV_SPIKE, "Spikes" },
630 { TV_DIGGING, "Digger" },
631 { TV_CHEST, "Chest" },
632 { TV_CAPTURE, "Capture Ball" },
633 { TV_CARD, "Express Card" },
634 { TV_FIGURINE, "Magical Figurine" },
635 { TV_STATUE, "Statue" },
636 { TV_CORPSE, "Corpse" },
638 { TV_FLASK, "Flask" },
640 { TV_SKELETON, "Skeleton" },
646 * Strip an "object name" into a buffer
648 void strip_name(char *buf, int k_idx)
652 object_kind *k_ptr = &k_info[k_idx];
654 cptr str = (k_name + k_ptr->name);
657 /* Skip past leading characters */
658 while ((*str == ' ') || (*str == '&')) str++;
660 /* Copy useful chars */
661 for (t = buf; *str; str++)
664 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
666 if (*str != '~') *t++ = *str;
669 /* Terminate the new name */
675 * Specify tval and sval (type and subtype of object) originally
676 * by RAK, heavily modified by -Bernd-
678 * This function returns the k_idx of an object type, or zero if failed
680 * List up to 50 choices in three columns
682 static int wiz_create_itemtype(void)
699 /* Print all tval's and their descriptions */
700 for (num = 0; (num < 80) && tvals[num].tval; num++)
702 row = 2 + (num % 20);
703 col = 20 * (num / 20);
705 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
708 /* Me need to know the maximal possible tval_index */
712 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
715 for (num = 0; num < max_num; num++)
717 if (listsym[num] == ch) break;
720 /* Bail out if choice is illegal */
721 if ((num < 0) || (num >= max_num)) return (0);
723 /* Base object type chosen, fill in tval */
724 tval = tvals[num].tval;
725 tval_desc = tvals[num].desc;
728 /*** And now we go for k_idx ***/
733 /* We have to search the whole itemlist. */
734 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
736 object_kind *k_ptr = &k_info[i];
738 /* Analyze matching items */
739 if (k_ptr->tval == tval)
742 row = 2 + (num % 20);
743 col = 20 * (num / 20);
747 /* Acquire the "name" of object "i" */
751 prt(format("[%c] %s", ch, buf), row, col);
753 /* Remember the object index */
758 /* Me need to know the maximal possible remembered object_index */
762 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
765 for (num = 0; num < max_num; num++)
767 if (listsym[num] == ch) break;
770 /* Bail out if choice is "illegal" */
771 if ((num < 0) || (num >= max_num)) return (0);
773 /* And return successful */
774 return (choice[num]);
781 static void wiz_tweak_item(object_type *o_ptr)
787 /* Hack -- leave artifacts alone */
788 if (artifact_p(o_ptr) || o_ptr->art_name) return;
790 p = "Enter new 'pval' setting: ";
791 sprintf(tmp_val, "%d", o_ptr->pval);
792 if (!get_string(p, tmp_val, 5)) return;
793 o_ptr->pval = atoi(tmp_val);
794 wiz_display_item(o_ptr);
796 p = "Enter new 'to_a' setting: ";
797 sprintf(tmp_val, "%d", o_ptr->to_a);
798 if (!get_string(p, tmp_val, 5)) return;
799 o_ptr->to_a = atoi(tmp_val);
800 wiz_display_item(o_ptr);
802 p = "Enter new 'to_h' setting: ";
803 sprintf(tmp_val, "%d", o_ptr->to_h);
804 if (!get_string(p, tmp_val, 5)) return;
805 o_ptr->to_h = atoi(tmp_val);
806 wiz_display_item(o_ptr);
808 p = "Enter new 'to_d' setting: ";
809 sprintf(tmp_val, "%d", o_ptr->to_d);
810 if (!get_string(p, tmp_val, 5)) return;
811 o_ptr->to_d = atoi(tmp_val);
812 wiz_display_item(o_ptr);
817 * Apply magic to an item or turn it into an artifact. -Bernd-
819 static void wiz_reroll_item(object_type *o_ptr)
826 bool changed = FALSE;
829 /* Hack -- leave artifacts alone */
830 if (artifact_p(o_ptr) || o_ptr->art_name) return;
833 /* Get local object */
836 /* Copy the object */
837 object_copy(q_ptr, o_ptr);
840 /* Main loop. Ask for magification and artifactification */
843 /* Display full item debug information */
844 wiz_display_item(q_ptr);
846 /* Ask wizard what to do. */
847 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
849 /* Preserve wizard-generated artifacts */
850 if (artifact_p(q_ptr))
852 a_info[q_ptr->name1].cur_num = 0;
860 /* Create/change it! */
861 if (ch == 'A' || ch == 'a')
867 /* Preserve wizard-generated artifacts */
868 if (artifact_p(q_ptr))
870 a_info[q_ptr->name1].cur_num = 0;
876 /* Apply bad magic, but first clear object */
879 object_prep(q_ptr, o_ptr->k_idx);
880 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
883 /* Apply bad magic, but first clear object */
886 object_prep(q_ptr, o_ptr->k_idx);
887 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
890 /* Apply normal magic, but first clear object */
893 object_prep(q_ptr, o_ptr->k_idx);
894 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
897 /* Apply good magic, but first clear object */
900 object_prep(q_ptr, o_ptr->k_idx);
901 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
904 /* Apply great magic, but first clear object */
907 object_prep(q_ptr, o_ptr->k_idx);
908 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
913 object_prep(q_ptr, o_ptr->k_idx);
914 apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
916 /* Failed to create normal artifact; make a random one */
917 if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
921 q_ptr->iy = o_ptr->iy;
922 q_ptr->ix = o_ptr->ix;
923 q_ptr->next_o_idx = o_ptr->next_o_idx;
924 q_ptr->marked = o_ptr->marked;
932 object_copy(o_ptr, q_ptr);
934 /* Recalculate bonuses */
935 p_ptr->update |= (PU_BONUS);
937 /* Combine / Reorder the pack (later) */
938 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
941 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
948 * Try to create an item again. Output some statistics. -Bernd-
950 * The statistics are correct now. We acquire a clean grid, and then
951 * repeatedly place an object in this grid, copying it into an item
952 * holder, and then deleting the object. We fiddle with the artifact
953 * counter flags to prevent weirdness. We use the items to collect
954 * statistics on item creation relative to the initial item.
956 static void wiz_statistics(object_type *o_ptr)
958 u32b i, matches, better, worse, other, correct;
960 u32b test_roll = 1000000;
970 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
972 cptr p = "Enter number of items to roll: ";
976 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
977 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
983 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
986 wiz_display_item(o_ptr);
989 if (!get_com(pmt, &ch, FALSE)) break;
991 if (ch == 'n' || ch == 'N')
997 else if (ch == 'g' || ch == 'G')
1003 else if (ch == 'e' || ch == 'E')
1007 quality = "excellent";
1016 sprintf(tmp_val, "%ld", test_roll);
1017 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1018 test_roll = MAX(1, test_roll);
1020 /* Let us know what we are doing */
1021 msg_format("Creating a lot of %s items. Base level = %d.",
1022 quality, dun_level);
1025 /* Set counters to zero */
1026 correct = matches = better = worse = other = 0;
1028 /* Let's rock and roll */
1029 for (i = 0; i <= test_roll; i++)
1031 /* Output every few rolls */
1032 if ((i < 100) || (i % 100 == 0))
1037 /* Allow interupt */
1047 /* Dump the stats */
1048 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1053 /* Get local object */
1056 /* Wipe the object */
1059 /* Create an object */
1060 make_object(q_ptr, good, great);
1063 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1064 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1067 /* Test for the same tval and sval. */
1068 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1069 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1071 /* One more correct item */
1074 /* Check for match */
1075 if ((q_ptr->pval == o_ptr->pval) &&
1076 (q_ptr->to_a == o_ptr->to_a) &&
1077 (q_ptr->to_h == o_ptr->to_h) &&
1078 (q_ptr->to_d == o_ptr->to_d) &&
1079 (q_ptr->name1 == o_ptr->name1))
1084 /* Check for better */
1085 else if ((q_ptr->pval >= o_ptr->pval) &&
1086 (q_ptr->to_a >= o_ptr->to_a) &&
1087 (q_ptr->to_h >= o_ptr->to_h) &&
1088 (q_ptr->to_d >= o_ptr->to_d))
1093 /* Check for worse */
1094 else if ((q_ptr->pval <= o_ptr->pval) &&
1095 (q_ptr->to_a <= o_ptr->to_a) &&
1096 (q_ptr->to_h <= o_ptr->to_h) &&
1097 (q_ptr->to_d <= o_ptr->to_d))
1102 /* Assume different */
1110 msg_format(q, i, correct, matches, better, worse, other);
1115 /* Hack -- Normally only make a single artifact */
1116 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1121 * Change the quantity of a the item
1123 static void wiz_quantity_item(object_type *o_ptr)
1125 int tmp_int, tmp_qnt;
1130 /* Never duplicate artifacts */
1131 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1133 /* Store old quantity. -LM- */
1134 tmp_qnt = o_ptr->number;
1137 sprintf(tmp_val, "%d", o_ptr->number);
1140 if (get_string("Quantity: ", tmp_val, 2))
1143 tmp_int = atoi(tmp_val);
1146 if (tmp_int < 1) tmp_int = 1;
1147 if (tmp_int > 99) tmp_int = 99;
1149 /* Accept modifications */
1150 o_ptr->number = tmp_int;
1152 /* Hack -- rod pvals must change if the number in the stack does. -LM- */
1153 if (o_ptr->tval == TV_ROD)
1154 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1161 * Play with an item. Options include:
1162 * - Output statistics (via wiz_roll_item)
1163 * - Reroll item (via wiz_reroll_item)
1164 * - Change properties (via wiz_tweak_item)
1165 * - Change the number of items (via wiz_quantity_item)
1167 static void do_cmd_wiz_play(void)
1182 item_tester_no_ryoute = TRUE;
1184 q = "Play with which object? ";
1185 s = "You have nothing to play with.";
1186 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1188 /* Get the item (in the pack) */
1191 o_ptr = &inventory[item];
1194 /* Get the item (on the floor) */
1197 o_ptr = &o_list[0 - item];
1201 /* The item was not changed */
1205 /* Save the screen */
1209 /* Get local object */
1213 object_copy(q_ptr, o_ptr);
1219 /* Display the item */
1220 wiz_display_item(q_ptr);
1223 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1229 if (ch == 'A' || ch == 'a')
1235 if (ch == 's' || ch == 'S')
1237 wiz_statistics(q_ptr);
1240 if (ch == 'r' || ch == 'r')
1242 wiz_reroll_item(q_ptr);
1245 if (ch == 't' || ch == 'T')
1247 wiz_tweak_item(q_ptr);
1250 if (ch == 'q' || ch == 'Q')
1252 wiz_quantity_item(q_ptr);
1257 /* Restore the screen */
1265 msg_print("Changes accepted.");
1268 object_copy(o_ptr, q_ptr);
1270 /* Recalculate bonuses */
1271 p_ptr->update |= (PU_BONUS);
1273 /* Combine / Reorder the pack (later) */
1274 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1277 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1283 msg_print("Changes ignored.");
1289 * Wizard routine for creating objects -RAK-
1290 * Heavily modified to allow magification and artifactification -Bernd-
1292 * Note that wizards cannot create objects on top of other objects.
1294 * Hack -- this routine always makes a "dungeon object", and applies
1295 * magic to it, and attempts to decline cursed items.
1297 static void wiz_create_item(void)
1305 /* Save the screen */
1308 /* Get object base type */
1309 k_idx = wiz_create_itemtype();
1311 /* Restore the screen */
1315 /* Return if failed */
1318 /* Get local object */
1321 /* Create the item */
1322 object_prep(q_ptr, k_idx);
1324 if (k_info[k_idx].flags3 & TR3_INSTA_ART)
1329 for (i = 1; i < max_a_idx; i++)
1331 /* Ignore incorrect tval */
1332 if (a_info[i].tval != q_ptr->tval) continue;
1334 /* Ignore incorrect sval */
1335 if (a_info[i].sval != q_ptr->sval) continue;
1337 /* Choose this artifact */
1343 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1348 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
1351 /* Drop the object from heaven */
1352 (void)drop_near(q_ptr, -1, py, px);
1355 msg_print("Allocated.");
1360 * Cure everything instantly
1362 static void do_cmd_wiz_cure_all(void)
1365 (void)remove_all_curse();
1368 (void)res_stat(A_STR);
1369 (void)res_stat(A_INT);
1370 (void)res_stat(A_WIS);
1371 (void)res_stat(A_CON);
1372 (void)res_stat(A_DEX);
1373 (void)res_stat(A_CHR);
1375 /* Restore the level */
1376 (void)restore_level();
1378 /* Heal the player */
1379 p_ptr->chp = p_ptr->mhp;
1380 p_ptr->chp_frac = 0;
1383 if (p_ptr->csp < p_ptr->msp)
1385 p_ptr->csp = p_ptr->msp;
1386 p_ptr->csp_frac = 0;
1391 (void)set_confused(0);
1392 (void)set_poisoned(0);
1393 (void)set_afraid(0);
1394 (void)set_paralyzed(0);
1398 (void)set_slow(0, TRUE);
1400 /* No longer hungry */
1401 (void)set_food(PY_FOOD_MAX - 1);
1403 /* Redraw everything */
1411 static void do_cmd_wiz_jump(void)
1414 if (command_arg <= 0)
1421 sprintf(ppp, "Jump which dungeon : ");
1424 sprintf(tmp_val, "%d", dungeon_type);
1426 /* Ask for a level */
1427 if (!get_string(ppp, tmp_val, 2)) return;
1429 dungeon_type = atoi(tmp_val);
1430 if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
1433 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
1436 sprintf(tmp_val, "%d", dun_level);
1438 /* Ask for a level */
1439 if (!get_string(ppp, tmp_val, 10)) return;
1441 /* Extract request */
1442 command_arg = atoi(tmp_val);
1446 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1449 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1451 /* Accept request */
1452 msg_format("You jump to dungeon level %d.", command_arg);
1454 if (autosave_l) do_cmd_save_game(TRUE);
1457 dun_level = command_arg;
1459 if (!dun_level) dungeon_type = 0;
1460 p_ptr->inside_arena = FALSE;
1461 leaving_quest = p_ptr->inside_quest;
1463 /* Leaving an 'only once' quest marks it as failed */
1464 if (leaving_quest &&
1465 (quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
1466 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
1468 quest[leaving_quest].status = QUEST_STATUS_FAILED;
1469 quest[leaving_quest].complev = (byte)p_ptr->lev;
1470 if (record_fix_quest)
1471 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1474 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1476 p_ptr->inside_quest = 0;
1477 p_ptr->leftbldg = FALSE;
1481 p_ptr->leaving = TRUE;
1486 * Become aware of a lot of objects
1488 static void do_cmd_wiz_learn(void)
1495 /* Scan every object */
1496 for (i = 1; i < max_k_idx; i++)
1498 object_kind *k_ptr = &k_info[i];
1500 /* Induce awareness */
1501 if (k_ptr->level <= command_arg)
1503 /* Get local object */
1506 /* Prepare object */
1507 object_prep(q_ptr, i);
1510 object_aware(q_ptr);
1517 * Summon some creatures
1519 static void do_cmd_wiz_summon(int num)
1523 for (i = 0; i < num; i++)
1525 (void)summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, FALSE);
1531 * Summon a creature of the specified type
1533 * XXX XXX XXX This function is rather dangerous
1535 static void do_cmd_wiz_named(int r_idx, bool slp)
1540 /* if (!r_idx) return; */
1542 /* Prevent illegal monsters */
1543 if (r_idx >= max_r_idx) return;
1546 for (i = 0; i < 10; i++)
1550 /* Pick a location */
1551 scatter(&y, &x, py, px, d, 0);
1553 /* Require empty grids */
1554 if (!cave_empty_bold(y, x)) continue;
1556 /* Place it (allow groups) */
1557 if (place_monster_aux(y, x, r_idx, slp, TRUE, FALSE, FALSE, FALSE, FALSE)) break;
1563 * Summon a creature of the specified type
1565 * XXX XXX XXX This function is rather dangerous
1567 static void do_cmd_wiz_named_friendly(int r_idx, bool slp)
1569 (void) summon_named_creature(py, px, r_idx, slp, TRUE, TRUE, TRUE);
1575 * Hack -- Delete all nearby monsters
1577 static void do_cmd_wiz_zap(void)
1582 /* Genocide everyone nearby */
1583 for (i = 1; i < m_max; i++)
1585 monster_type *m_ptr = &m_list[i];
1587 /* Paranoia -- Skip dead monsters */
1588 if (!m_ptr->r_idx) continue;
1590 /* Delete nearby monsters */
1591 if (m_ptr->cdis <= MAX_SIGHT)
1593 if (i == p_ptr->riding)
1596 p_ptr->redraw |= (PR_EXTRA);
1598 delete_monster_idx(i);
1605 * Hack -- Delete all monsters
1607 static void do_cmd_wiz_zap_all(void)
1611 /* Genocide everyone */
1612 for (i = 1; i < m_max; i++)
1614 monster_type *m_ptr = &m_list[i];
1616 /* Paranoia -- Skip dead monsters */
1617 if (!m_ptr->r_idx) continue;
1619 if (i == p_ptr->riding)
1622 p_ptr->redraw |= (PR_EXTRA);
1625 /* Delete this monster */
1626 delete_monster_idx(i);
1631 #ifdef ALLOW_SPOILERS
1636 extern void do_cmd_spoilers(void);
1638 #endif /* ALLOW_SPOILERS */
1643 * Hack -- declare external function
1645 extern void do_cmd_debug(void);
1650 * Ask for and parse a "debug command"
1651 * The "command_arg" may have been set.
1653 void do_cmd_debug(void)
1659 /* Get a "debug command" */
1660 get_com("Debug Command: ", &cmd, FALSE);
1662 /* Analyze the command */
1673 #ifdef ALLOW_SPOILERS
1675 /* Hack -- Generate Spoilers */
1680 #endif /* ALLOW_SPOILERS */
1689 /* Cure all maladies */
1691 do_cmd_wiz_cure_all();
1694 /* Know alignment */
1696 msg_format("Your alignment is %d.", p_ptr->align);
1699 /* Teleport to target */
1708 /* Create any object */
1713 /* Create a named artifact */
1715 wiz_create_named_art(command_arg);
1718 /* Detect everything */
1720 detect_all(DETECT_RAD_ALL*3);
1723 /* Dimension_door */
1725 wiz_dimension_door();
1728 /* Edit character */
1730 do_cmd_wiz_change();
1733 /* View item info */
1735 identify_fully(FALSE);
1740 if (command_arg <= 0) command_arg = 1;
1741 acquirement(py, px, command_arg, FALSE, TRUE);
1744 /* Hitpoint rerating */
1746 do_cmd_rerate(TRUE); break;
1748 #ifdef MONSTER_HORDES
1750 do_cmd_summon_horde(); break;
1751 #endif /* MONSTER_HORDES */
1755 (void)ident_spell(FALSE);
1758 /* Go up or down in the dungeon */
1763 /* Self-Knowledge */
1768 /* Learn about objects */
1775 map_area(DETECT_RAD_ALL);
1780 (void)gain_random_mutation(command_arg);
1783 /* Specific reward */
1785 (void)gain_level_reward(command_arg);
1788 /* Summon _friendly_ named monster */
1790 do_cmd_wiz_named_friendly(command_arg, TRUE);
1793 /* Summon Named Monster */
1795 do_cmd_wiz_named(command_arg, TRUE);
1798 /* Object playing routines */
1805 teleport_player(10);
1809 /* Complete a Quest -KMW- */
1812 for (i = 0; i < max_quests; i++)
1814 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1816 p_ptr->quest[i].status++;
1817 msg_print("Completed Quest");
1822 if (i == max_quests)
1824 msg_print("No current quest");
1831 /* Make every dungeon square "known" to test streamers -KMW- */
1834 for(y = 0; y < cur_hgt; y++)
1836 for(x = 0; x < cur_wid; x++)
1838 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1841 wiz_lite(TRUE, FALSE);
1845 /* Summon Random Monster(s) */
1847 if (command_arg <= 0) command_arg = 1;
1848 do_cmd_wiz_summon(command_arg);
1853 teleport_player(100);
1856 /* Very Good Objects */
1858 if (command_arg <= 0) command_arg = 1;
1859 acquirement(py, px, command_arg, TRUE, TRUE);
1862 /* Wizard Light the Level */
1864 wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
1867 /* Increase Experience */
1871 gain_exp(command_arg);
1875 gain_exp(p_ptr->exp + 1);
1879 /* Zap Monsters (Genocide) */
1885 do_cmd_wiz_zap_all();
1888 /* Hack -- whatever I desire */
1890 do_cmd_wiz_hack_ben();
1893 /* Not a Wizard Command */
1895 msg_print("That is not a valid debug command.");