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 = randint(p_ptr->hitdie);
41 for (i = 1; i < PY_MAX_LEVEL; i++)
43 player_hp[i] = randint(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, '-');
189 * Output a rarity graph for a type of object.
191 static void prt_alloc(byte tval, byte sval, int row, int col)
196 u32b maxd = 1, maxr = 1, maxt = 1;
197 u32b rarity[MAX_DEPTH];
198 u32b total[MAX_DEPTH];
201 cptr r = "+--common--+";
206 alloc_entry *table = alloc_kind_table;
208 /* Wipe the tables */
209 (void)C_WIPE(rarity, MAX_DEPTH, u32b);
210 (void)C_WIPE(total, MAX_DEPTH, u32b);
211 (void)C_WIPE(display, 20, u32b);
213 /* Scan all entries */
214 for (i = 0; i < MAX_DEPTH; i++)
217 lev = ((i * (GREAT_OBJ - 1)) + (1 + i * 5433L / 1000)) / GREAT_OBJ;
219 for (j = 0; j < alloc_kind_size; j++)
221 /* Objects are sorted by depth */
222 if (table[j].level > lev) break;
224 /* Acquire this kind */
225 k_ptr = &k_info[table[j].index];
227 /* Accumulate probabilities */
228 total[i] += table[j].prob1;
230 /* Accumulate probabilities */
231 if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
234 rarity[i] += table[j].prob1;
240 for (i = 0; i < MAX_DEPTH; i++)
242 if (rarity[i] > maxr) maxr = rarity[i];
243 if (total[i] > maxt) maxt = total[i];
246 /* Simulate a log graph */
247 if (maxt / maxr > 32)
252 if (maxt / maxr > 1024)
257 if (maxt / maxr > 32768L)
263 /* Calculate probabilities for each range */
264 for (i = 0; i < 20; i++)
266 /* Shift the values into view */
267 for (j = i * MAX_DEPTH / 20; j < (i + 1) * MAX_DEPTH / 20; j++)
269 display[i] += rarity[j] * maxt * 10 / total[j];
272 /* Correct proportions */
276 if (display[i] > maxd) maxd = display[i];
280 for (i = 0; i < 20; i++)
282 display[i] = display[i] * 10 / maxd;
285 /* Graph the rarities */
286 for (i = 0; i < 20; i++)
288 Term_putch(col, row + i + 1, TERM_WHITE, '|');
291 if ((i * MAX_DEPTH / 20 <= home) && (home < (i + 1) * MAX_DEPTH / 20))
293 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
297 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
301 /* Make it look nice */
304 Term_putch(col, row + 2, TERM_WHITE, '6');
306 Term_putch(col, row + 8, TERM_WHITE, 'A');
307 Term_putch(col, row + 9, TERM_WHITE, 'L');
308 Term_putch(col, row + 10, TERM_WHITE, 'L');
309 Term_putch(col, row + 11, TERM_WHITE, 'O');
310 Term_putch(col, row + 12, TERM_WHITE, 'C');
312 prt("+", row + 21, col);
317 * Hack -- Teleport to the target
319 static void do_cmd_wiz_bamf(void)
321 /* Must have a target */
322 if (!target_who) return;
324 /* Teleport to the target */
325 teleport_player_to(target_row, target_col, FALSE);
330 * Aux function for "do_cmd_wiz_change()". -RAK-
332 static void do_cmd_wiz_change_aux(void)
342 /* Query the stats */
343 for (i = 0; i < 6; i++)
346 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
349 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
352 if (!get_string(ppp, tmp_val, 3)) return;
355 tmp_int = atoi(tmp_val);
358 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
359 else if (tmp_int < 3) tmp_int = 3;
362 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
367 sprintf(tmp_val, "8000");
371 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
373 if (!get_string("Proficiency: ", tmp_val, 9)) return;
377 tmp_s16b = atoi(tmp_val);
380 if (tmp_s16b < 0) tmp_s16b = 0L;
381 if (tmp_s16b > 8000) tmp_s16b = 8000L;
383 for (j = 0; j <= TV_SWORD - TV_BOW;j++)
385 for (i = 0;i < 64;i++)
387 weapon_exp[j][i] = tmp_s16b;
388 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];
392 for (j = 0; j < 10; j++)
394 skill_exp[j] = tmp_s16b;
395 if (skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
398 for (j = 0; j < 32; j++)
399 spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
401 spell_exp[j] = (tmp_s16b > 1400 ? 1400 : tmp_s16b);
404 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
407 if (!get_string("Gold: ", tmp_val, 9)) return;
410 tmp_long = atol(tmp_val);
413 if (tmp_long < 0) tmp_long = 0L;
416 p_ptr->au = tmp_long;
420 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
423 if (!get_string("Experience: ", tmp_val, 9)) return;
426 tmp_long = atol(tmp_val);
429 if (tmp_long < 0) tmp_long = 0L;
431 if (p_ptr->prace != RACE_ANDROID)
434 p_ptr->max_exp = tmp_long;
435 p_ptr->exp = tmp_long;
444 * Change various "permanent" player variables.
446 static void do_cmd_wiz_change(void)
449 do_cmd_wiz_change_aux();
451 /* Redraw everything */
457 * Wizard routines for creating objects -RAK-
458 * And for manipulating them! -Bernd-
460 * This has been rewritten to make the whole procedure
461 * of debugging objects much easier and more comfortable.
463 * The following functions are meant to play with objects:
464 * Create, modify, roll for them (for statistic purposes) and more.
465 * The original functions were by RAK.
466 * The function to show an item's debug information was written
467 * by David Reeve Sward <sward+@CMU.EDU>.
468 * Bernd (wiebelt@mathematik.hu-berlin.de)
470 * Here are the low-level functions
471 * - wiz_display_item()
472 * display an item's debug-info
473 * - wiz_create_itemtype()
474 * specify tval and sval (type and subtype of object)
476 * specify pval, +AC, +tohit, +todam
477 * Note that the wizard can leave this function anytime,
478 * thus accepting the default-values for the remaining values.
479 * pval comes first now, since it is most important.
480 * - wiz_reroll_item()
481 * apply some magic to the item or turn it into an artifact.
483 * Get some statistics about the rarity of an item:
484 * We create a lot of fake items and see if they are of the
485 * same type (tval and sval), then we compare pval and +AC.
486 * If the fake-item is better or equal it is counted.
487 * Note that cursed items that are better or equal (absolute values)
489 * HINT: This is *very* useful for balancing the game!
490 * - wiz_quantity_item()
491 * change the quantity of an item, but be sane about it.
493 * And now the high-level functions
494 * - do_cmd_wiz_play()
495 * play with an existing object
496 * - wiz_create_item()
497 * create a new object
499 * Note -- You do not have to specify "pval" and other item-properties
500 * directly. Just apply magic until you are satisfied with the item.
502 * Note -- For some items (such as wands, staffs, some rings, etc), you
503 * must apply magic, or you will get "broken" or "uncharged" objects.
505 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
506 * the artifact. Be careful.
508 * Hack -- this function will allow you to create multiple artifacts.
509 * This "feature" may induce crashes or other nasty effects.
513 * Just display an item's properties (debug-info)
514 * Originally by David Reeve Sward <sward+@CMU.EDU>
515 * Verbose item flags by -Bernd-
517 static void wiz_display_item(object_type *o_ptr)
523 /* Extract the flags */
524 object_flags(o_ptr, &f1, &f2, &f3);
526 /* Clear the screen */
527 for (i = 1; i <= 23; i++) prt("", i, j - 2);
529 prt_alloc(o_ptr->tval, o_ptr->sval, 2, 0);
532 object_desc_store(buf, o_ptr, TRUE, 3);
536 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
537 o_ptr->k_idx, get_object_level(o_ptr),
538 o_ptr->tval, o_ptr->sval), 4, j);
540 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
541 o_ptr->number, o_ptr->weight,
542 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
544 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
545 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
547 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
548 o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
550 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
551 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
553 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d",
554 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5), 9, j);
556 prt("+------------FLAGS1------------+", 10, j);
557 prt("AFFECT........SLAY........BRAND.", 11, j);
558 prt(" mr cvae xsqpaefc", 12, j);
559 prt("siwdccsissidsahanvudotgddhuoclio", 13, j);
560 prt("tnieohtrtrnipttmiinmrrnrrraiierl", 14, j);
561 prt("rtsxnarylcfgdkcpmldncltggpksdced", 15, j);
562 prt_binary(f1, 16, j);
564 prt("+------------FLAGS2------------+", 17, j);
565 prt("SUST....IMMUN.RESIST............", 18, j);
566 prt(" aefctrpsaefcpfldbc sn ", 19, j);
567 prt("siwdcc clioheatcliooeialoshtncd", 20, j);
568 prt("tnieoh ierlrfraierliatrnnnrhehi", 21, j);
569 prt("rtsxna..dcedwlatdcedsrekdfddrxss", 22, j);
570 prt_binary(f2, 23, j);
572 prt("+------------FLAGS3------------+", 10, j+32);
573 prt("fe cnn t i stdrmsiiii d abchp", 11, j+32);
574 prt("aa aoomyehsnlleeieihgggg rtgluvr", 12, j+32);
575 prt("uu utmacaihseielgggonnnnaaerercc", 13, j+32);
576 prt("rr reanusdotvtieeehtrrrrcilassuu", 14, j+32);
577 prt("aa algaryewaienpsntsaefctnevserr", 15, j+32);
578 prt_binary(f3, 16, j+32);
583 * A structure to hold a tval and its description
585 typedef struct tval_desc
592 * A list of tvals and their textual names
594 static tval_desc tvals[] =
596 { TV_SWORD, "Sword" },
597 { TV_POLEARM, "Polearm" },
598 { TV_HAFTED, "Hafted Weapon" },
600 { TV_ARROW, "Arrows" },
601 { TV_BOLT, "Bolts" },
602 { TV_SHOT, "Shots" },
603 { TV_SHIELD, "Shield" },
604 { TV_CROWN, "Crown" },
606 { TV_GLOVES, "Gloves" },
607 { TV_BOOTS, "Boots" },
608 { TV_CLOAK, "Cloak" },
609 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
610 { TV_HARD_ARMOR, "Hard Armor" },
611 { TV_SOFT_ARMOR, "Soft Armor" },
613 { TV_AMULET, "Amulet" },
615 { TV_POTION, "Potion" },
616 { TV_SCROLL, "Scroll" },
618 { TV_STAFF, "Staff" },
620 { TV_LIFE_BOOK, "Life Spellbook" },
621 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
622 { TV_NATURE_BOOK, "Nature Spellbook" },
623 { TV_CHAOS_BOOK, "Chaos Spellbook" },
624 { TV_DEATH_BOOK, "Death Spellbook" },
625 { TV_TRUMP_BOOK, "Trump Spellbook" },
626 { TV_ARCANE_BOOK, "Arcane Spellbook" },
627 { TV_ENCHANT_BOOK, "Craft Spellbook"},
628 { TV_DAEMON_BOOK, "Daemon Spellbook"},
629 { TV_MUSIC_BOOK, "Music Spellbook" },
630 { TV_HISSATSU_BOOK, "Book of Kendo" },
631 { TV_PARCHEMENT, "Parchement" },
632 { TV_WHISTLE, "Whistle" },
633 { TV_SPIKE, "Spikes" },
634 { TV_DIGGING, "Digger" },
635 { TV_CHEST, "Chest" },
636 { TV_CAPTURE, "Capture Ball" },
637 { TV_CARD, "Express Card" },
638 { TV_FIGURINE, "Magical Figurine" },
639 { TV_STATUE, "Statue" },
640 { TV_CORPSE, "Corpse" },
642 { TV_FLASK, "Flask" },
644 { TV_SKELETON, "Skeleton" },
650 * Strip an "object name" into a buffer
652 void strip_name(char *buf, int k_idx)
656 object_kind *k_ptr = &k_info[k_idx];
658 cptr str = (k_name + k_ptr->name);
661 /* Skip past leading characters */
662 while ((*str == ' ') || (*str == '&')) str++;
664 /* Copy useful chars */
665 for (t = buf; *str; str++)
668 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
670 if (*str != '~') *t++ = *str;
673 /* Terminate the new name */
679 * Specify tval and sval (type and subtype of object) originally
680 * by RAK, heavily modified by -Bernd-
682 * This function returns the k_idx of an object type, or zero if failed
684 * List up to 50 choices in three columns
686 static int wiz_create_itemtype(void)
703 /* Print all tval's and their descriptions */
704 for (num = 0; (num < 80) && tvals[num].tval; num++)
706 row = 2 + (num % 20);
707 col = 20 * (num / 20);
709 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
712 /* Me need to know the maximal possible tval_index */
716 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
719 for (num = 0; num < max_num; num++)
721 if (listsym[num] == ch) break;
724 /* Bail out if choice is illegal */
725 if ((num < 0) || (num >= max_num)) return (0);
727 /* Base object type chosen, fill in tval */
728 tval = tvals[num].tval;
729 tval_desc = tvals[num].desc;
732 /*** And now we go for k_idx ***/
737 /* We have to search the whole itemlist. */
738 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
740 object_kind *k_ptr = &k_info[i];
742 /* Analyze matching items */
743 if (k_ptr->tval == tval)
746 row = 2 + (num % 20);
747 col = 20 * (num / 20);
751 /* Acquire the "name" of object "i" */
755 prt(format("[%c] %s", ch, buf), row, col);
757 /* Remember the object index */
762 /* Me need to know the maximal possible remembered object_index */
766 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
769 for (num = 0; num < max_num; num++)
771 if (listsym[num] == ch) break;
774 /* Bail out if choice is "illegal" */
775 if ((num < 0) || (num >= max_num)) return (0);
777 /* And return successful */
778 return (choice[num]);
785 static void wiz_tweak_item(object_type *o_ptr)
791 /* Hack -- leave artifacts alone */
792 if (artifact_p(o_ptr) || o_ptr->art_name) return;
794 p = "Enter new 'pval' setting: ";
795 sprintf(tmp_val, "%d", o_ptr->pval);
796 if (!get_string(p, tmp_val, 5)) return;
797 o_ptr->pval = atoi(tmp_val);
798 wiz_display_item(o_ptr);
800 p = "Enter new 'to_a' setting: ";
801 sprintf(tmp_val, "%d", o_ptr->to_a);
802 if (!get_string(p, tmp_val, 5)) return;
803 o_ptr->to_a = atoi(tmp_val);
804 wiz_display_item(o_ptr);
806 p = "Enter new 'to_h' setting: ";
807 sprintf(tmp_val, "%d", o_ptr->to_h);
808 if (!get_string(p, tmp_val, 5)) return;
809 o_ptr->to_h = atoi(tmp_val);
810 wiz_display_item(o_ptr);
812 p = "Enter new 'to_d' setting: ";
813 sprintf(tmp_val, "%d", o_ptr->to_d);
814 if (!get_string(p, tmp_val, 5)) return;
815 o_ptr->to_d = atoi(tmp_val);
816 wiz_display_item(o_ptr);
821 * Apply magic to an item or turn it into an artifact. -Bernd-
823 static void wiz_reroll_item(object_type *o_ptr)
830 bool changed = FALSE;
833 /* Hack -- leave artifacts alone */
834 if (artifact_p(o_ptr) || o_ptr->art_name) return;
837 /* Get local object */
840 /* Copy the object */
841 object_copy(q_ptr, o_ptr);
844 /* Main loop. Ask for magification and artifactification */
847 /* Display full item debug information */
848 wiz_display_item(q_ptr);
850 /* Ask wizard what to do. */
851 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
853 /* Preserve wizard-generated artifacts */
854 if (artifact_p(q_ptr))
856 a_info[q_ptr->name1].cur_num = 0;
864 /* Create/change it! */
865 if (ch == 'A' || ch == 'a')
871 /* Preserve wizard-generated artifacts */
872 if (artifact_p(q_ptr))
874 a_info[q_ptr->name1].cur_num = 0;
880 /* Apply bad magic, but first clear object */
883 object_prep(q_ptr, o_ptr->k_idx);
884 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
887 /* Apply bad magic, but first clear object */
890 object_prep(q_ptr, o_ptr->k_idx);
891 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
894 /* Apply normal magic, but first clear object */
897 object_prep(q_ptr, o_ptr->k_idx);
898 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
901 /* Apply good magic, but first clear object */
904 object_prep(q_ptr, o_ptr->k_idx);
905 apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
908 /* Apply great magic, but first clear object */
911 object_prep(q_ptr, o_ptr->k_idx);
912 apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
917 object_prep(q_ptr, o_ptr->k_idx);
918 apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
920 /* Failed to create normal artifact; make a random one */
921 if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
925 q_ptr->iy = o_ptr->iy;
926 q_ptr->ix = o_ptr->ix;
927 q_ptr->next_o_idx = o_ptr->next_o_idx;
928 q_ptr->marked = o_ptr->marked;
936 object_copy(o_ptr, q_ptr);
938 /* Recalculate bonuses */
939 p_ptr->update |= (PU_BONUS);
941 /* Combine / Reorder the pack (later) */
942 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
945 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
952 * Try to create an item again. Output some statistics. -Bernd-
954 * The statistics are correct now. We acquire a clean grid, and then
955 * repeatedly place an object in this grid, copying it into an item
956 * holder, and then deleting the object. We fiddle with the artifact
957 * counter flags to prevent weirdness. We use the items to collect
958 * statistics on item creation relative to the initial item.
960 static void wiz_statistics(object_type *o_ptr)
962 u32b i, matches, better, worse, other, correct;
964 u32b test_roll = 1000000;
974 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
976 cptr p = "Enter number of items to roll: ";
980 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
981 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
987 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
990 wiz_display_item(o_ptr);
993 if (!get_com(pmt, &ch, FALSE)) break;
995 if (ch == 'n' || ch == 'N')
1001 else if (ch == 'g' || ch == 'G')
1007 else if (ch == 'e' || ch == 'E')
1011 quality = "excellent";
1020 sprintf(tmp_val, "%ld", test_roll);
1021 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1022 test_roll = MAX(1, test_roll);
1024 /* Let us know what we are doing */
1025 msg_format("Creating a lot of %s items. Base level = %d.",
1026 quality, dun_level);
1029 /* Set counters to zero */
1030 correct = matches = better = worse = other = 0;
1032 /* Let's rock and roll */
1033 for (i = 0; i <= test_roll; i++)
1035 /* Output every few rolls */
1036 if ((i < 100) || (i % 100 == 0))
1041 /* Allow interupt */
1051 /* Dump the stats */
1052 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1057 /* Get local object */
1060 /* Wipe the object */
1063 /* Create an object */
1064 make_object(q_ptr, good, great);
1067 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1068 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1071 /* Test for the same tval and sval. */
1072 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1073 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1075 /* One more correct item */
1078 /* Check for match */
1079 if ((q_ptr->pval == o_ptr->pval) &&
1080 (q_ptr->to_a == o_ptr->to_a) &&
1081 (q_ptr->to_h == o_ptr->to_h) &&
1082 (q_ptr->to_d == o_ptr->to_d) &&
1083 (q_ptr->name1 == o_ptr->name1))
1088 /* Check for better */
1089 else if ((q_ptr->pval >= o_ptr->pval) &&
1090 (q_ptr->to_a >= o_ptr->to_a) &&
1091 (q_ptr->to_h >= o_ptr->to_h) &&
1092 (q_ptr->to_d >= o_ptr->to_d))
1097 /* Check for worse */
1098 else if ((q_ptr->pval <= o_ptr->pval) &&
1099 (q_ptr->to_a <= o_ptr->to_a) &&
1100 (q_ptr->to_h <= o_ptr->to_h) &&
1101 (q_ptr->to_d <= o_ptr->to_d))
1106 /* Assume different */
1114 msg_format(q, i, correct, matches, better, worse, other);
1119 /* Hack -- Normally only make a single artifact */
1120 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1125 * Change the quantity of a the item
1127 static void wiz_quantity_item(object_type *o_ptr)
1129 int tmp_int, tmp_qnt;
1134 /* Never duplicate artifacts */
1135 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1137 /* Store old quantity. -LM- */
1138 tmp_qnt = o_ptr->number;
1141 sprintf(tmp_val, "%d", o_ptr->number);
1144 if (get_string("Quantity: ", tmp_val, 2))
1147 tmp_int = atoi(tmp_val);
1150 if (tmp_int < 1) tmp_int = 1;
1151 if (tmp_int > 99) tmp_int = 99;
1153 /* Accept modifications */
1154 o_ptr->number = tmp_int;
1156 /* Hack -- rod pvals must change if the number in the stack does. -LM- */
1157 if (o_ptr->tval == TV_ROD)
1158 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1165 * Play with an item. Options include:
1166 * - Output statistics (via wiz_roll_item)
1167 * - Reroll item (via wiz_reroll_item)
1168 * - Change properties (via wiz_tweak_item)
1169 * - Change the number of items (via wiz_quantity_item)
1171 static void do_cmd_wiz_play(void)
1186 item_tester_no_ryoute = TRUE;
1188 q = "Play with which object? ";
1189 s = "You have nothing to play with.";
1190 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1192 /* Get the item (in the pack) */
1195 o_ptr = &inventory[item];
1198 /* Get the item (on the floor) */
1201 o_ptr = &o_list[0 - item];
1205 /* The item was not changed */
1209 /* Save the screen */
1213 /* Get local object */
1217 object_copy(q_ptr, o_ptr);
1223 /* Display the item */
1224 wiz_display_item(q_ptr);
1227 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1233 if (ch == 'A' || ch == 'a')
1239 if (ch == 's' || ch == 'S')
1241 wiz_statistics(q_ptr);
1244 if (ch == 'r' || ch == 'r')
1246 wiz_reroll_item(q_ptr);
1249 if (ch == 't' || ch == 'T')
1251 wiz_tweak_item(q_ptr);
1254 if (ch == 'q' || ch == 'Q')
1256 wiz_quantity_item(q_ptr);
1261 /* Restore the screen */
1269 msg_print("Changes accepted.");
1272 object_copy(o_ptr, q_ptr);
1274 /* Recalculate bonuses */
1275 p_ptr->update |= (PU_BONUS);
1277 /* Combine / Reorder the pack (later) */
1278 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1281 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1287 msg_print("Changes ignored.");
1293 * Wizard routine for creating objects -RAK-
1294 * Heavily modified to allow magification and artifactification -Bernd-
1296 * Note that wizards cannot create objects on top of other objects.
1298 * Hack -- this routine always makes a "dungeon object", and applies
1299 * magic to it, and attempts to decline cursed items.
1301 static void wiz_create_item(void)
1309 /* Save the screen */
1312 /* Get object base type */
1313 k_idx = wiz_create_itemtype();
1315 /* Restore the screen */
1319 /* Return if failed */
1322 /* Get local object */
1325 /* Create the item */
1326 object_prep(q_ptr, k_idx);
1328 if (k_info[k_idx].flags3 & TR3_INSTA_ART)
1333 for (i = 1; i < max_a_idx; i++)
1335 /* Ignore incorrect tval */
1336 if (a_info[i].tval != q_ptr->tval) continue;
1338 /* Ignore incorrect sval */
1339 if (a_info[i].sval != q_ptr->sval) continue;
1341 /* Choose this artifact */
1347 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1352 apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
1356 q_ptr->python = object_create_callback(q_ptr);
1357 #endif /* USE_SCRIPT */
1359 /* Drop the object from heaven */
1360 (void)drop_near(q_ptr, -1, py, px);
1363 msg_print("Allocated.");
1368 * Cure everything instantly
1370 static void do_cmd_wiz_cure_all(void)
1373 (void)remove_all_curse();
1376 (void)res_stat(A_STR);
1377 (void)res_stat(A_INT);
1378 (void)res_stat(A_WIS);
1379 (void)res_stat(A_CON);
1380 (void)res_stat(A_DEX);
1381 (void)res_stat(A_CHR);
1383 /* Restore the level */
1384 (void)restore_level();
1386 /* Heal the player */
1387 p_ptr->chp = p_ptr->mhp;
1388 p_ptr->chp_frac = 0;
1391 if (p_ptr->csp < p_ptr->msp)
1393 p_ptr->csp = p_ptr->msp;
1394 p_ptr->csp_frac = 0;
1399 (void)set_confused(0);
1400 (void)set_poisoned(0);
1401 (void)set_afraid(0);
1402 (void)set_paralyzed(0);
1406 (void)set_slow(0, TRUE);
1408 /* No longer hungry */
1409 (void)set_food(PY_FOOD_MAX - 1);
1411 /* Redraw everything */
1419 static void do_cmd_wiz_jump(void)
1422 if (command_arg <= 0)
1429 sprintf(ppp, "Jump which dungeon : ");
1432 sprintf(tmp_val, "%d", dungeon_type);
1434 /* Ask for a level */
1435 if (!get_string(ppp, tmp_val, 2)) return;
1437 dungeon_type = atoi(tmp_val);
1438 if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
1441 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
1444 sprintf(tmp_val, "%d", dun_level);
1446 /* Ask for a level */
1447 if (!get_string(ppp, tmp_val, 10)) return;
1449 /* Extract request */
1450 command_arg = atoi(tmp_val);
1454 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1457 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1459 /* Accept request */
1460 msg_format("You jump to dungeon level %d.", command_arg);
1462 if (autosave_l) do_cmd_save_game(TRUE);
1465 dun_level = command_arg;
1467 if (!dun_level) dungeon_type = 0;
1468 p_ptr->inside_arena = FALSE;
1469 leaving_quest = p_ptr->inside_quest;
1471 /* Leaving an 'only once' quest marks it as failed */
1472 if (leaving_quest &&
1473 (quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
1474 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
1476 quest[leaving_quest].status = QUEST_STATUS_FAILED;
1477 quest[leaving_quest].complev = (byte)p_ptr->lev;
1478 if (record_fix_quest)
1479 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1482 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1484 p_ptr->inside_quest = 0;
1485 p_ptr->leftbldg = FALSE;
1489 p_ptr->leaving = TRUE;
1494 * Become aware of a lot of objects
1496 static void do_cmd_wiz_learn(void)
1503 /* Scan every object */
1504 for (i = 1; i < max_k_idx; i++)
1506 object_kind *k_ptr = &k_info[i];
1508 /* Induce awareness */
1509 if (k_ptr->level <= command_arg)
1511 /* Get local object */
1514 /* Prepare object */
1515 object_prep(q_ptr, i);
1518 object_aware(q_ptr);
1525 * Summon some creatures
1527 static void do_cmd_wiz_summon(int num)
1531 for (i = 0; i < num; i++)
1533 (void)summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, FALSE);
1539 * Summon a creature of the specified type
1541 * XXX XXX XXX This function is rather dangerous
1543 static void do_cmd_wiz_named(int r_idx, bool slp)
1548 /* if (!r_idx) return; */
1550 /* Prevent illegal monsters */
1551 if (r_idx >= max_r_idx) return;
1554 for (i = 0; i < 10; i++)
1558 /* Pick a location */
1559 scatter(&y, &x, py, px, d, 0);
1561 /* Require empty grids */
1562 if (!cave_empty_bold(y, x)) continue;
1564 /* Place it (allow groups) */
1565 if (place_monster_aux(y, x, r_idx, slp, TRUE, FALSE, FALSE, FALSE, FALSE)) break;
1571 * Summon a creature of the specified type
1573 * XXX XXX XXX This function is rather dangerous
1575 static void do_cmd_wiz_named_friendly(int r_idx, bool slp)
1577 (void) summon_named_creature(py, px, r_idx, slp, TRUE, TRUE, TRUE);
1583 * Hack -- Delete all nearby monsters
1585 static void do_cmd_wiz_zap(void)
1590 /* Genocide everyone nearby */
1591 for (i = 1; i < m_max; i++)
1593 monster_type *m_ptr = &m_list[i];
1595 /* Paranoia -- Skip dead monsters */
1596 if (!m_ptr->r_idx) continue;
1598 /* Delete nearby monsters */
1599 if (m_ptr->cdis <= MAX_SIGHT)
1601 if (i == p_ptr->riding)
1604 p_ptr->redraw |= (PR_EXTRA);
1606 delete_monster_idx(i);
1613 * Hack -- Delete all monsters
1615 static void do_cmd_wiz_zap_all(void)
1619 /* Genocide everyone */
1620 for (i = 1; i < m_max; i++)
1622 monster_type *m_ptr = &m_list[i];
1624 /* Paranoia -- Skip dead monsters */
1625 if (!m_ptr->r_idx) continue;
1627 if (i == p_ptr->riding)
1630 p_ptr->redraw |= (PR_EXTRA);
1633 /* Delete this monster */
1634 delete_monster_idx(i);
1642 * Hack -- Execute a script function
1644 static void do_cmd_wiz_script(void)
1649 /* Get name of script to execute */
1652 if (!get_string("Function name: ", name, 80)) return;
1654 /* No name, no execute */
1655 if (name[0] == '\0')
1657 msg_print("Cancelled.");
1661 /* Execute script */
1662 err = script_execute(name);
1667 msg_print("Failed.");
1672 #endif /* USE_SCRIPT */
1676 #ifdef ALLOW_SPOILERS
1681 extern void do_cmd_spoilers(void);
1683 #endif /* ALLOW_SPOILERS */
1688 * Hack -- declare external function
1690 extern void do_cmd_debug(void);
1695 * Ask for and parse a "debug command"
1696 * The "command_arg" may have been set.
1698 void do_cmd_debug(void)
1704 /* Get a "debug command" */
1705 get_com("Debug Command: ", &cmd, FALSE);
1707 /* Analyze the command */
1718 #ifdef ALLOW_SPOILERS
1720 /* Hack -- Generate Spoilers */
1725 #endif /* ALLOW_SPOILERS */
1734 /* Cure all maladies */
1736 do_cmd_wiz_cure_all();
1739 /* Know alignment */
1741 msg_format("Your alignment is %d.", p_ptr->align);
1744 /* Teleport to target */
1753 /* Create any object */
1758 /* Create a named artifact */
1760 wiz_create_named_art(command_arg);
1763 /* Detect everything */
1765 detect_all(DETECT_RAD_ALL*3);
1768 /* Dimension_door */
1770 wiz_dimension_door();
1773 /* Edit character */
1775 do_cmd_wiz_change();
1778 /* View item info */
1780 identify_fully(FALSE);
1785 if (command_arg <= 0) command_arg = 1;
1786 acquirement(py, px, command_arg, FALSE, TRUE);
1789 /* Hitpoint rerating */
1791 do_cmd_rerate(TRUE); break;
1793 #ifdef MONSTER_HORDES
1795 do_cmd_summon_horde(); break;
1796 #endif /* MONSTER_HORDES */
1800 (void)ident_spell(FALSE);
1803 /* Go up or down in the dungeon */
1808 /* Self-Knowledge */
1813 /* Learn about objects */
1820 map_area(DETECT_RAD_ALL);
1825 (void)gain_random_mutation(command_arg);
1828 /* Specific reward */
1830 (void)gain_level_reward(command_arg);
1833 /* Summon _friendly_ named monster */
1835 do_cmd_wiz_named_friendly(command_arg, TRUE);
1838 /* Summon Named Monster */
1840 do_cmd_wiz_named(command_arg, TRUE);
1843 /* Object playing routines */
1850 teleport_player(10);
1854 /* Complete a Quest -KMW- */
1857 for (i = 0; i < max_quests; i++)
1859 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1861 p_ptr->quest[i].status++;
1862 msg_print("Completed Quest");
1867 if (i == max_quests)
1869 msg_print("No current quest");
1876 /* Make every dungeon square "known" to test streamers -KMW- */
1879 for(y = 0; y < cur_hgt; y++)
1881 for(x = 0; x < cur_wid; x++)
1883 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1886 wiz_lite(TRUE, FALSE);
1890 /* Summon Random Monster(s) */
1892 if (command_arg <= 0) command_arg = 1;
1893 do_cmd_wiz_summon(command_arg);
1898 teleport_player(100);
1901 /* Very Good Objects */
1903 if (command_arg <= 0) command_arg = 1;
1904 acquirement(py, px, command_arg, TRUE, TRUE);
1907 /* Wizard Light the Level */
1909 wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
1912 /* Increase Experience */
1916 gain_exp(command_arg);
1920 gain_exp(p_ptr->exp + 1);
1924 /* Zap Monsters (Genocide) */
1930 do_cmd_wiz_zap_all();
1933 /* Hack -- whatever I desire */
1935 do_cmd_wiz_hack_ben();
1939 /* Hack -- activate a script */
1941 do_cmd_wiz_script();
1943 #endif /* USE_SCRIPT */
1945 /* Not a Wizard Command */
1947 msg_print("That is not a valid debug command.");