4 * Copyright (c) 1997 Ben Harrison, and others
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Wizard commands */
17 * Roll the hitdie -- aux of do_cmd_rerate()
19 void do_cmd_rerate_aux(void)
21 /* Minimum hitpoints at highest level */
22 int min_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 3 / 8;
24 /* Maximum hitpoints at highest level */
25 int max_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 5 / 8;
32 /* Pre-calculate level 1 hitdice */
33 p_ptr->player_hp[0] = p_ptr->hitdie;
35 for (i = 1; i < 4; i++)
37 p_ptr->player_hp[0] += randint1(p_ptr->hitdie);
40 /* Roll the hitpoint values */
41 for (i = 1; i < PY_MAX_LEVEL; i++)
43 p_ptr->player_hp[i] = p_ptr->player_hp[i - 1] + randint1(p_ptr->hitdie);
46 /* Require "valid" hitpoints at highest level */
47 if ((p_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
48 (p_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
54 * Hack -- Rerate Hitpoints
56 void do_cmd_rerate(bool display)
63 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
65 ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
68 /* Update and redraw hitpoints */
69 p_ptr->update |= (PU_HP);
70 p_ptr->redraw |= (PR_HP);
73 p_ptr->window |= (PW_PLAYER);
82 msg_format("¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯¤Ï %d/100 ¤Ç¤¹¡£", percent);
84 msg_format("Your life rate is %d/100 now.", percent);
86 p_ptr->knowledge |= KNOW_HPRATE;
91 msg_print("ÂÎÎÏ¥é¥ó¥¯¤¬ÊѤï¤Ã¤¿¡£");
93 msg_print("Life rate is changed.");
95 p_ptr->knowledge &= ~(KNOW_HPRATE);
105 static bool wiz_dimension_door(void)
109 if (!tgt_pt(&x, &y)) return FALSE;
111 teleport_player_to(y, x, TELEPORT_NONMAGICAL);
118 * Create the artifact of the specified number -- DAN
121 static void wiz_create_named_art(void)
127 if (!get_string("Artifact ID:", tmp_val, 3)) return;
130 a_idx = atoi(tmp_val);
131 if(a_idx < 0) a_idx = 0;
132 if(a_idx >= max_a_idx) a_idx = 0;
134 /* Create the artifact */
135 (void)create_named_art(a_idx, py, px);
138 msg_print("Allocated.");
143 * Hack -- quick debugging hook
145 static void do_cmd_wiz_hack_ben(void)
154 #ifdef MONSTER_HORDES
156 /* Summon a horde of monsters */
157 static void do_cmd_summon_horde(void)
159 int wy = py, wx = px;
164 scatter(&wy, &wx, py, px, 3, 0);
165 if (cave_empty_bold(wy, wx)) break;
168 (void)alloc_horde(wy, wx);
171 #endif /* MONSTER_HORDES */
175 * Output a long int in binary format.
177 static void prt_binary(u32b flags, int row, int col)
183 for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
188 Term_putch(col++, row, TERM_BLUE, '*');
191 /* Dump unset bits */
194 Term_putch(col++, row, TERM_WHITE, '-');
200 #define K_MAX_DEPTH 110
203 * Output a rarity graph for a type of object.
205 static void prt_alloc(byte tval, byte sval, int row, int col)
209 u32b maxr = 1, maxt = 1, ratio;
210 u32b rarity[K_MAX_DEPTH];
211 u32b total[K_MAX_DEPTH];
212 s32b maxd = 1, display[22];
214 cptr r = "+--common--+";
219 alloc_entry *table = alloc_kind_table;
221 /* Wipe the tables */
222 (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
223 (void)C_WIPE(total, K_MAX_DEPTH, u32b);
224 (void)C_WIPE(display, 22, s32b);
226 /* Scan all entries */
227 for (i = 0; i < K_MAX_DEPTH; i++)
230 for (j = 0; j < alloc_kind_size; j++)
234 if (table[j].level <= i)
236 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
238 else if (table[j].level - 1 > 0)
240 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
243 /* Acquire this kind */
244 k_ptr = &k_info[table[j].index];
246 /* Accumulate probabilities */
247 total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
248 total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
250 /* Accumulate probabilities */
251 if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
257 total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
261 for (i = 0; i < K_MAX_DEPTH; i++)
263 if (rarity[i] > maxr) maxr = rarity[i];
264 if (total[i] > maxt) maxt = total[i];
267 if (maxr / (GREAT_OBJ * K_MAX_DEPTH) != 0)
268 ratio = maxt / (maxr / (GREAT_OBJ * K_MAX_DEPTH));
272 /* Simulate a log graph */
289 /* Calculate probabilities for each range */
290 for (i = 0; i < 22; i++)
292 /* Shift the values into view */
295 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
296 possibility += rarity[j] * (100 * maxt / total[j]);
298 possibility = possibility / maxr;
300 /* display[i] = log_{sqrt(2)}(possibility) */
305 possibility = possibility * 1000 / 1414;
309 if (display[i] > maxd) maxd = display[i];
313 if (maxd > 10) for (i = 0; i < 22; i++)
315 display[i] = display[i] - maxd + 10;
318 /* Graph the rarities */
319 for (i = 0; i < 22; i++)
321 Term_putch(col, row + i + 1, TERM_WHITE, '|');
323 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
329 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
331 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
335 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
339 /* Make it look nice */
345 * Hack -- Teleport to the target
347 static void do_cmd_wiz_bamf(void)
349 /* Must have a target */
350 if (!target_who) return;
352 /* Teleport to the target */
353 teleport_player_to(target_row, target_col, TELEPORT_NONMAGICAL);
358 * Aux function for "do_cmd_wiz_change()". -RAK-
360 static void do_cmd_wiz_change_aux(void)
370 /* Query the stats */
371 for (i = 0; i < 6; i++)
374 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
377 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
380 if (!get_string(ppp, tmp_val, 3)) return;
383 tmp_int = atoi(tmp_val);
386 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
387 else if (tmp_int < 3) tmp_int = 3;
390 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
395 sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
399 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
401 if (!get_string("Proficiency: ", tmp_val, 9)) return;
405 tmp_s16b = atoi(tmp_val);
408 if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED;
409 if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER;
411 for (j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++)
413 for (i = 0;i < 64;i++)
415 p_ptr->weapon_exp[j][i] = tmp_s16b;
416 if (p_ptr->weapon_exp[j][i] > s_info[p_ptr->pclass].w_max[j][i]) p_ptr->weapon_exp[j][i] = s_info[p_ptr->pclass].w_max[j][i];
420 for (j = 0; j < 10; j++)
422 p_ptr->skill_exp[j] = tmp_s16b;
423 if (p_ptr->skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) p_ptr->skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
426 for (j = 0; j < 32; j++)
427 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
429 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
432 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
435 if (!get_string("Gold: ", tmp_val, 9)) return;
438 tmp_long = atol(tmp_val);
441 if (tmp_long < 0) tmp_long = 0L;
444 p_ptr->au = tmp_long;
448 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
451 if (!get_string("Experience: ", tmp_val, 9)) return;
454 tmp_long = atol(tmp_val);
457 if (tmp_long < 0) tmp_long = 0L;
459 if (p_ptr->prace != RACE_ANDROID)
462 p_ptr->max_exp = tmp_long;
463 p_ptr->exp = tmp_long;
472 * Change various "permanent" player variables.
474 static void do_cmd_wiz_change(void)
477 do_cmd_wiz_change_aux();
479 /* Redraw everything */
485 * Wizard routines for creating objects -RAK-
486 * And for manipulating them! -Bernd-
488 * This has been rewritten to make the whole procedure
489 * of debugging objects much easier and more comfortable.
491 * The following functions are meant to play with objects:
492 * Create, modify, roll for them (for statistic purposes) and more.
493 * The original functions were by RAK.
494 * The function to show an item's debug information was written
495 * by David Reeve Sward <sward+@CMU.EDU>.
496 * Bernd (wiebelt@mathematik.hu-berlin.de)
498 * Here are the low-level functions
499 * - wiz_display_item()
500 * display an item's debug-info
501 * - wiz_create_itemtype()
502 * specify tval and sval (type and subtype of object)
504 * specify pval, +AC, +tohit, +todam
505 * Note that the wizard can leave this function anytime,
506 * thus accepting the default-values for the remaining values.
507 * pval comes first now, since it is most important.
508 * - wiz_reroll_item()
509 * apply some magic to the item or turn it into an artifact.
511 * Get some statistics about the rarity of an item:
512 * We create a lot of fake items and see if they are of the
513 * same type (tval and sval), then we compare pval and +AC.
514 * If the fake-item is better or equal it is counted.
515 * Note that cursed items that are better or equal (absolute values)
517 * HINT: This is *very* useful for balancing the game!
518 * - wiz_quantity_item()
519 * change the quantity of an item, but be sane about it.
521 * And now the high-level functions
522 * - do_cmd_wiz_play()
523 * play with an existing object
524 * - wiz_create_item()
525 * create a new object
527 * Note -- You do not have to specify "pval" and other item-properties
528 * directly. Just apply magic until you are satisfied with the item.
530 * Note -- For some items (such as wands, staffs, some rings, etc), you
531 * must apply magic, or you will get "broken" or "uncharged" objects.
533 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
534 * the artifact. Be careful.
536 * Hack -- this function will allow you to create multiple artifacts.
537 * This "feature" may induce crashes or other nasty effects.
541 * Just display an item's properties (debug-info)
542 * Originally by David Reeve Sward <sward+@CMU.EDU>
543 * Verbose item flags by -Bernd-
545 static void wiz_display_item(object_type *o_ptr)
548 u32b flgs[TR_FLAG_SIZE];
551 /* Extract the flags */
552 object_flags(o_ptr, flgs);
554 /* Clear the screen */
555 for (i = 1; i <= 23; i++) prt("", i, j - 2);
557 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
560 object_desc(buf, o_ptr, OD_STORE);
564 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
565 o_ptr->k_idx, k_info[o_ptr->k_idx].level,
566 o_ptr->tval, o_ptr->sval), 4, j);
568 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
569 o_ptr->number, o_ptr->weight,
570 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
572 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
573 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
575 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
576 o_ptr->name1, o_ptr->name2, (long)object_value_real(o_ptr)), 7, j);
578 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
579 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
581 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d cursed = %-d",
582 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
584 prt("+------------FLAGS1------------+", 10, j);
585 prt("AFFECT........SLAY........BRAND.", 11, j);
586 prt(" mf cvae xsqpaefc", 12, j);
587 prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
588 prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
589 prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
590 prt_binary(flgs[0], 16, j);
592 prt("+------------FLAGS2------------+", 17, j);
593 prt("SUST....IMMUN.RESIST............", 18, j);
594 prt(" reaefctrpsaefcpfldbc sn ", 19, j);
595 prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
596 prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
597 prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
598 prt_binary(flgs[1], 23, j);
600 prt("+------------FLAGS3------------+", 10, j+32);
601 prt("fe cnn t stdrmsiiii d ab ", 11, j+32);
602 prt("aa aoomywhs lleeieihgggg rtgl ", 12, j+32);
603 prt("uu utmacaih eielgggonnnnaaere ", 13, j+32);
604 prt("rr reanurdo vtieeehtrrrrcilas ", 14, j+32);
605 prt("aa algarnew ienpsntsaefctnevs ", 15, j+32);
606 prt_binary(flgs[2], 16, j+32);
608 prt("+------------FLAGS4------------+", 17, j+32);
609 prt("KILL....ESP......... ", 18, j+32);
610 prt("aeud tghaud tgdhegnu ", 19, j+32);
611 prt("nvneoriunneoriruvoon ", 20, j+32);
612 prt("iidmroamidmroagmionq ", 21, j+32);
613 prt("mlenclnmmenclnnnldlu ", 22, j+32);
614 prt_binary(flgs[3], 23, j+32);
619 * A structure to hold a tval and its description
621 typedef struct tval_desc
628 * A list of tvals and their textual names
630 static tval_desc tvals[] =
632 { TV_SWORD, "Sword" },
633 { TV_POLEARM, "Polearm" },
634 { TV_HAFTED, "Hafted Weapon" },
636 { TV_ARROW, "Arrows" },
637 { TV_BOLT, "Bolts" },
638 { TV_SHOT, "Shots" },
639 { TV_SHIELD, "Shield" },
640 { TV_CROWN, "Crown" },
642 { TV_GLOVES, "Gloves" },
643 { TV_BOOTS, "Boots" },
644 { TV_CLOAK, "Cloak" },
645 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
646 { TV_HARD_ARMOR, "Hard Armor" },
647 { TV_SOFT_ARMOR, "Soft Armor" },
649 { TV_AMULET, "Amulet" },
651 { TV_POTION, "Potion" },
652 { TV_SCROLL, "Scroll" },
654 { TV_STAFF, "Staff" },
656 { TV_LIFE_BOOK, "Life Spellbook" },
657 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
658 { TV_NATURE_BOOK, "Nature Spellbook" },
659 { TV_CHAOS_BOOK, "Chaos Spellbook" },
660 { TV_DEATH_BOOK, "Death Spellbook" },
661 { TV_TRUMP_BOOK, "Trump Spellbook" },
662 { TV_ARCANE_BOOK, "Arcane Spellbook" },
663 { TV_CRAFT_BOOK, "Craft Spellbook"},
664 { TV_DAEMON_BOOK, "Daemon Spellbook"},
665 { TV_CRUSADE_BOOK, "Crusade Spellbook"},
666 { TV_MUSIC_BOOK, "Music Spellbook" },
667 { TV_HISSATSU_BOOK, "Book of Kendo" },
668 { TV_HEX_BOOK, "Hex Spellbook" },
669 { TV_PARCHMENT, "Parchment" },
670 { TV_WHISTLE, "Whistle" },
671 { TV_SPIKE, "Spikes" },
672 { TV_DIGGING, "Digger" },
673 { TV_CHEST, "Chest" },
674 { TV_CAPTURE, "Capture Ball" },
675 { TV_CARD, "Express Card" },
676 { TV_FIGURINE, "Magical Figurine" },
677 { TV_STATUE, "Statue" },
678 { TV_CORPSE, "Corpse" },
680 { TV_FLASK, "Flask" },
682 { TV_SKELETON, "Skeleton" },
688 * Strip an "object name" into a buffer
690 void strip_name(char *buf, int k_idx)
694 object_kind *k_ptr = &k_info[k_idx];
696 cptr str = (k_name + k_ptr->name);
699 /* Skip past leading characters */
700 while ((*str == ' ') || (*str == '&')) str++;
702 /* Copy useful chars */
703 for (t = buf; *str; str++)
706 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
708 if (*str != '~') *t++ = *str;
711 /* Terminate the new name */
717 * Specify tval and sval (type and subtype of object) originally
718 * by RAK, heavily modified by -Bernd-
720 * This function returns the k_idx of an object type, or zero if failed
722 * List up to 50 choices in three columns
724 static int wiz_create_itemtype(void)
741 /* Print all tval's and their descriptions */
742 for (num = 0; (num < 80) && tvals[num].tval; num++)
744 row = 2 + (num % 20);
745 col = 20 * (num / 20);
747 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
750 /* Me need to know the maximal possible tval_index */
754 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
757 for (num = 0; num < max_num; num++)
759 if (listsym[num] == ch) break;
762 /* Bail out if choice is illegal */
763 if ((num < 0) || (num >= max_num)) return (0);
765 /* Base object type chosen, fill in tval */
766 tval = tvals[num].tval;
767 tval_desc = tvals[num].desc;
770 /*** And now we go for k_idx ***/
775 /* We have to search the whole itemlist. */
776 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
778 object_kind *k_ptr = &k_info[i];
780 /* Analyze matching items */
781 if (k_ptr->tval == tval)
784 row = 2 + (num % 20);
785 col = 20 * (num / 20);
789 /* Acquire the "name" of object "i" */
793 prt(format("[%c] %s", ch, buf), row, col);
795 /* Remember the object index */
800 /* Me need to know the maximal possible remembered object_index */
804 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
807 for (num = 0; num < max_num; num++)
809 if (listsym[num] == ch) break;
812 /* Bail out if choice is "illegal" */
813 if ((num < 0) || (num >= max_num)) return (0);
815 /* And return successful */
816 return (choice[num]);
823 static void wiz_tweak_item(object_type *o_ptr)
829 /* Hack -- leave artifacts alone */
830 if (object_is_artifact(o_ptr)) return;
832 p = "Enter new 'pval' setting: ";
833 sprintf(tmp_val, "%d", o_ptr->pval);
834 if (!get_string(p, tmp_val, 5)) return;
835 o_ptr->pval = atoi(tmp_val);
836 wiz_display_item(o_ptr);
838 p = "Enter new 'to_a' setting: ";
839 sprintf(tmp_val, "%d", o_ptr->to_a);
840 if (!get_string(p, tmp_val, 5)) return;
841 o_ptr->to_a = atoi(tmp_val);
842 wiz_display_item(o_ptr);
844 p = "Enter new 'to_h' setting: ";
845 sprintf(tmp_val, "%d", o_ptr->to_h);
846 if (!get_string(p, tmp_val, 5)) return;
847 o_ptr->to_h = atoi(tmp_val);
848 wiz_display_item(o_ptr);
850 p = "Enter new 'to_d' setting: ";
851 sprintf(tmp_val, "%d", o_ptr->to_d);
852 if (!get_string(p, tmp_val, 5)) return;
853 o_ptr->to_d = atoi(tmp_val);
854 wiz_display_item(o_ptr);
859 * Apply magic to an item or turn it into an artifact. -Bernd-
861 static void wiz_reroll_item(object_type *o_ptr)
868 bool changed = FALSE;
871 /* Hack -- leave artifacts alone */
872 if (object_is_artifact(o_ptr)) return;
875 /* Get local object */
878 /* Copy the object */
879 object_copy(q_ptr, o_ptr);
882 /* Main loop. Ask for magification and artifactification */
885 /* Display full item debug information */
886 wiz_display_item(q_ptr);
888 /* Ask wizard what to do. */
889 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
891 /* Preserve wizard-generated artifacts */
892 if (object_is_fixed_artifact(q_ptr))
894 a_info[q_ptr->name1].cur_num = 0;
902 /* Create/change it! */
903 if (ch == 'A' || ch == 'a')
909 /* Preserve wizard-generated artifacts */
910 if (object_is_fixed_artifact(q_ptr))
912 a_info[q_ptr->name1].cur_num = 0;
918 /* Apply bad magic, but first clear object */
921 object_prep(q_ptr, o_ptr->k_idx);
922 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
925 /* Apply bad magic, but first clear object */
928 object_prep(q_ptr, o_ptr->k_idx);
929 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
932 /* Apply normal magic, but first clear object */
935 object_prep(q_ptr, o_ptr->k_idx);
936 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
939 /* Apply good magic, but first clear object */
942 object_prep(q_ptr, o_ptr->k_idx);
943 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD);
946 /* Apply great magic, but first clear object */
949 object_prep(q_ptr, o_ptr->k_idx);
950 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
953 /* Apply special magic, but first clear object */
956 object_prep(q_ptr, o_ptr->k_idx);
957 apply_magic(q_ptr, dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
959 /* Failed to create artifact; make a random one */
960 if (!object_is_artifact(q_ptr)) create_artifact(q_ptr, FALSE);
964 q_ptr->iy = o_ptr->iy;
965 q_ptr->ix = o_ptr->ix;
966 q_ptr->next_o_idx = o_ptr->next_o_idx;
967 q_ptr->marked = o_ptr->marked;
975 object_copy(o_ptr, q_ptr);
977 /* Recalculate bonuses */
978 p_ptr->update |= (PU_BONUS);
980 /* Combine / Reorder the pack (later) */
981 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
984 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
991 * Try to create an item again. Output some statistics. -Bernd-
993 * The statistics are correct now. We acquire a clean grid, and then
994 * repeatedly place an object in this grid, copying it into an item
995 * holder, and then deleting the object. We fiddle with the artifact
996 * counter flags to prevent weirdness. We use the items to collect
997 * statistics on item creation relative to the initial item.
999 static void wiz_statistics(object_type *o_ptr)
1001 u32b i, matches, better, worse, other, correct;
1003 u32b test_roll = 1000000;
1013 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
1015 cptr p = "Enter number of items to roll: ";
1019 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1020 if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
1026 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
1029 wiz_display_item(o_ptr);
1032 if (!get_com(pmt, &ch, FALSE)) break;
1034 if (ch == 'n' || ch == 'N')
1039 else if (ch == 'g' || ch == 'G')
1044 else if (ch == 'e' || ch == 'E')
1046 mode = AM_GOOD | AM_GREAT;
1047 quality = "excellent";
1054 sprintf(tmp_val, "%ld", (long int)test_roll);
1055 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1056 test_roll = MAX(1, test_roll);
1058 /* Let us know what we are doing */
1059 msg_format("Creating a lot of %s items. Base level = %d.",
1060 quality, dun_level);
1063 /* Set counters to zero */
1064 correct = matches = better = worse = other = 0;
1066 /* Let's rock and roll */
1067 for (i = 0; i <= test_roll; i++)
1069 /* Output every few rolls */
1070 if ((i < 100) || (i % 100 == 0))
1075 /* Allow interupt */
1085 /* Dump the stats */
1086 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1091 /* Get local object */
1094 /* Wipe the object */
1097 /* Create an object */
1098 make_object(q_ptr, mode);
1101 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1102 if (object_is_fixed_artifact(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1105 /* Test for the same tval and sval. */
1106 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1107 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1109 /* One more correct item */
1112 /* Check for match */
1113 if ((q_ptr->pval == o_ptr->pval) &&
1114 (q_ptr->to_a == o_ptr->to_a) &&
1115 (q_ptr->to_h == o_ptr->to_h) &&
1116 (q_ptr->to_d == o_ptr->to_d) &&
1117 (q_ptr->name1 == o_ptr->name1))
1122 /* Check for better */
1123 else if ((q_ptr->pval >= o_ptr->pval) &&
1124 (q_ptr->to_a >= o_ptr->to_a) &&
1125 (q_ptr->to_h >= o_ptr->to_h) &&
1126 (q_ptr->to_d >= o_ptr->to_d))
1131 /* Check for worse */
1132 else if ((q_ptr->pval <= o_ptr->pval) &&
1133 (q_ptr->to_a <= o_ptr->to_a) &&
1134 (q_ptr->to_h <= o_ptr->to_h) &&
1135 (q_ptr->to_d <= o_ptr->to_d))
1140 /* Assume different */
1148 msg_format(q, i, correct, matches, better, worse, other);
1153 /* Hack -- Normally only make a single artifact */
1154 if (object_is_fixed_artifact(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1159 * Change the quantity of a the item
1161 static void wiz_quantity_item(object_type *o_ptr)
1163 int tmp_int, tmp_qnt;
1168 /* Never duplicate artifacts */
1169 if (object_is_artifact(o_ptr)) return;
1171 /* Store old quantity. -LM- */
1172 tmp_qnt = o_ptr->number;
1175 sprintf(tmp_val, "%d", o_ptr->number);
1178 if (get_string("Quantity: ", tmp_val, 2))
1181 tmp_int = atoi(tmp_val);
1184 if (tmp_int < 1) tmp_int = 1;
1185 if (tmp_int > 99) tmp_int = 99;
1187 /* Accept modifications */
1188 o_ptr->number = tmp_int;
1191 if (o_ptr->tval == TV_ROD)
1193 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1197 /* debug command for blue mage */
1198 static void do_cmd_wiz_blue_mage(void)
1203 s32b f4 = 0, f5 = 0, f6 = 0;
1208 set_rf_masks(&f4, &f5, &f6, j);
1210 for (i = 0; i < 32; i++)
1212 if ((0x00000001 << i) & f4) p_ptr->magic_num2[i] = 1;
1216 if ((0x00000001 << (i - 32)) & f5) p_ptr->magic_num2[i] = 1;
1220 if ((0x00000001 << (i - 64)) & f6) p_ptr->magic_num2[i] = 1;
1227 * Play with an item. Options include:
1228 * - Output statistics (via wiz_roll_item)
1229 * - Reroll item (via wiz_reroll_item)
1230 * - Change properties (via wiz_tweak_item)
1231 * - Change the number of items (via wiz_quantity_item)
1233 static void do_cmd_wiz_play(void)
1248 item_tester_no_ryoute = TRUE;
1250 q = "Play with which object? ";
1251 s = "You have nothing to play with.";
1252 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1254 /* Get the item (in the pack) */
1257 o_ptr = &inventory[item];
1260 /* Get the item (on the floor) */
1263 o_ptr = &o_list[0 - item];
1266 /* The item was not changed */
1270 /* Save the screen */
1274 /* Get local object */
1278 object_copy(q_ptr, o_ptr);
1284 /* Display the item */
1285 wiz_display_item(q_ptr);
1288 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1294 if (ch == 'A' || ch == 'a')
1300 if (ch == 's' || ch == 'S')
1302 wiz_statistics(q_ptr);
1305 if (ch == 'r' || ch == 'r')
1307 wiz_reroll_item(q_ptr);
1310 if (ch == 't' || ch == 'T')
1312 wiz_tweak_item(q_ptr);
1315 if (ch == 'q' || ch == 'Q')
1317 wiz_quantity_item(q_ptr);
1322 /* Restore the screen */
1330 msg_print("Changes accepted.");
1332 /* Recalcurate object's weight */
1335 p_ptr->total_weight += (q_ptr->weight * q_ptr->number)
1336 - (o_ptr->weight * o_ptr->number);
1340 object_copy(o_ptr, q_ptr);
1343 /* Recalculate bonuses */
1344 p_ptr->update |= (PU_BONUS);
1346 /* Combine / Reorder the pack (later) */
1347 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1350 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1356 msg_print("Changes ignored.");
1362 * Wizard routine for creating objects -RAK-
1363 * Heavily modified to allow magification and artifactification -Bernd-
1365 * Note that wizards cannot create objects on top of other objects.
1367 * Hack -- this routine always makes a "dungeon object", and applies
1368 * magic to it, and attempts to decline cursed items.
1370 static void wiz_create_item(void)
1378 /* Save the screen */
1381 /* Get object base type */
1382 k_idx = wiz_create_itemtype();
1384 /* Restore the screen */
1388 /* Return if failed */
1391 if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
1396 for (i = 1; i < max_a_idx; i++)
1398 /* Ignore incorrect tval */
1399 if (a_info[i].tval != k_info[k_idx].tval) continue;
1401 /* Ignore incorrect sval */
1402 if (a_info[i].sval != k_info[k_idx].sval) continue;
1404 /* Create this artifact */
1405 (void)create_named_art(i, py, px);
1408 msg_print("Allocated(INSTA_ART).");
1414 /* Get local object */
1417 /* Create the item */
1418 object_prep(q_ptr, k_idx);
1421 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
1423 /* Drop the object from heaven */
1424 (void)drop_near(q_ptr, -1, py, px);
1427 msg_print("Allocated.");
1432 * Cure everything instantly
1434 static void do_cmd_wiz_cure_all(void)
1437 (void)res_stat(A_STR);
1438 (void)res_stat(A_INT);
1439 (void)res_stat(A_WIS);
1440 (void)res_stat(A_CON);
1441 (void)res_stat(A_DEX);
1442 (void)res_stat(A_CHR);
1444 /* Restore the level */
1445 (void)restore_level();
1447 /* Heal the player */
1448 if (p_ptr->chp < p_ptr->mhp)
1450 p_ptr->chp = p_ptr->mhp;
1451 p_ptr->chp_frac = 0;
1454 p_ptr->redraw |= (PR_HP);
1457 p_ptr->window |= (PW_PLAYER);
1461 if (p_ptr->csp < p_ptr->msp)
1463 p_ptr->csp = p_ptr->msp;
1464 p_ptr->csp_frac = 0;
1466 p_ptr->redraw |= (PR_MANA);
1467 p_ptr->window |= (PW_PLAYER);
1468 p_ptr->window |= (PW_SPELL);
1473 (void)set_confused(0);
1474 (void)set_poisoned(0);
1475 (void)set_afraid(0);
1476 (void)set_paralyzed(0);
1480 (void)set_slow(0, TRUE);
1482 /* No longer hungry */
1483 (void)set_food(PY_FOOD_MAX - 1);
1490 static void do_cmd_wiz_jump(void)
1493 if (command_arg <= 0)
1498 int tmp_dungeon_type;
1501 sprintf(ppp, "Jump which dungeon : ");
1504 sprintf(tmp_val, "%d", dungeon_type);
1506 /* Ask for a level */
1507 if (!get_string(ppp, tmp_val, 2)) return;
1509 tmp_dungeon_type = atoi(tmp_val);
1510 if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
1513 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[tmp_dungeon_type].mindepth, d_info[tmp_dungeon_type].maxdepth);
1516 sprintf(tmp_val, "%d", dun_level);
1518 /* Ask for a level */
1519 if (!get_string(ppp, tmp_val, 10)) return;
1521 /* Extract request */
1522 command_arg = atoi(tmp_val);
1524 dungeon_type = tmp_dungeon_type;
1528 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1531 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1533 /* Accept request */
1534 msg_format("You jump to dungeon level %d.", command_arg);
1536 if (autosave_l) do_cmd_save_game(TRUE);
1539 dun_level = command_arg;
1541 prepare_change_floor_mode(CFM_RAND_PLACE);
1543 if (!dun_level) dungeon_type = 0;
1544 p_ptr->inside_arena = FALSE;
1545 p_ptr->wild_mode = FALSE;
1547 leave_quest_check();
1549 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1551 p_ptr->inside_quest = 0;
1554 /* Prevent energy_need from being too lower than 0 */
1555 p_ptr->energy_need = 0;
1558 * Clear all saved floors
1559 * and create a first saved floor
1561 prepare_change_floor_mode(CFM_FIRST_FLOOR);
1564 p_ptr->leaving = TRUE;
1569 * Become aware of a lot of objects
1571 static void do_cmd_wiz_learn(void)
1578 /* Scan every object */
1579 for (i = 1; i < max_k_idx; i++)
1581 object_kind *k_ptr = &k_info[i];
1583 /* Induce awareness */
1584 if (k_ptr->level <= command_arg)
1586 /* Get local object */
1589 /* Prepare object */
1590 object_prep(q_ptr, i);
1593 object_aware(q_ptr);
1600 * Summon some creatures
1602 static void do_cmd_wiz_summon(int num)
1606 for (i = 0; i < num; i++)
1608 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1614 * Summon a creature of the specified type
1616 * XXX XXX XXX This function is rather dangerous
1618 static void do_cmd_wiz_named(int r_idx)
1620 (void)summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
1625 * Summon a creature of the specified type
1627 * XXX XXX XXX This function is rather dangerous
1629 static void do_cmd_wiz_named_friendly(int r_idx)
1631 (void)summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
1637 * Hack -- Delete all nearby monsters
1639 static void do_cmd_wiz_zap(void)
1644 /* Genocide everyone nearby */
1645 for (i = 1; i < m_max; i++)
1647 monster_type *m_ptr = &m_list[i];
1649 /* Paranoia -- Skip dead monsters */
1650 if (!m_ptr->r_idx) continue;
1652 /* Skip the mount */
1653 if (i == p_ptr->riding) continue;
1655 /* Delete nearby monsters */
1656 if (m_ptr->cdis <= MAX_SIGHT)
1658 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1662 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1663 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
1666 delete_monster_idx(i);
1673 * Hack -- Delete all monsters
1675 static void do_cmd_wiz_zap_all(void)
1679 /* Genocide everyone */
1680 for (i = 1; i < m_max; i++)
1682 monster_type *m_ptr = &m_list[i];
1684 /* Paranoia -- Skip dead monsters */
1685 if (!m_ptr->r_idx) continue;
1687 /* Skip the mount */
1688 if (i == p_ptr->riding) continue;
1690 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1694 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1695 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
1698 /* Delete this monster */
1699 delete_monster_idx(i);
1705 * Create desired feature
1707 static void do_cmd_wiz_create_feature(void)
1709 static int prev_feat = 0;
1710 static int prev_mimic = 0;
1712 feature_type *f_ptr;
1714 int tmp_feat, tmp_mimic;
1717 if (!tgt_pt(&x, &y)) return;
1719 c_ptr = &cave[y][x];
1722 sprintf(tmp_val, "%d", prev_feat);
1726 if (!get_string("ÃÏ·Á: ", tmp_val, 3)) return;
1728 if (!get_string("Feature: ", tmp_val, 3)) return;
1732 tmp_feat = atoi(tmp_val);
1733 if (tmp_feat < 0) tmp_feat = 0;
1734 else if (tmp_feat >= max_f_idx) tmp_feat = max_f_idx - 1;
1737 sprintf(tmp_val, "%d", prev_mimic);
1741 if (!get_string("ÃÏ·Á (mimic): ", tmp_val, 3)) return;
1743 if (!get_string("Feature (mimic): ", tmp_val, 3)) return;
1747 tmp_mimic = atoi(tmp_val);
1748 if (tmp_mimic < 0) tmp_mimic = 0;
1749 else if (tmp_mimic >= max_f_idx) tmp_mimic = max_f_idx - 1;
1751 cave_set_feat(y, x, tmp_feat);
1752 c_ptr->mimic = tmp_mimic;
1754 f_ptr = &f_info[get_feat_mimic(c_ptr)];
1756 if (have_flag(f_ptr->flags, FF_GLYPH) ||
1757 have_flag(f_ptr->flags, FF_MINOR_GLYPH))
1758 c_ptr->info |= (CAVE_OBJECT);
1759 else if (have_flag(f_ptr->flags, FF_MIRROR))
1760 c_ptr->info |= (CAVE_GLOW | CAVE_OBJECT);
1768 /* Update some things */
1769 p_ptr->update |= (PU_FLOW);
1771 prev_feat = tmp_feat;
1772 prev_mimic = tmp_mimic;
1777 #define NUM_O_BIT 32
1780 * Hack -- Dump option bits usage
1782 static void do_cmd_dump_options(void)
1789 /* Build the filename */
1790 path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
1792 /* File type is "TEXT" */
1793 FILE_TYPE(FILE_TYPE_TEXT);
1796 fff = my_fopen(buf, "a");
1802 msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
1804 msg_format("Failed to open file %s.", buf);
1810 /* Allocate the "exist" array (2-dimension) */
1811 C_MAKE(exist, NUM_O_SET, int *);
1812 C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
1813 for (i = 1; i < NUM_O_SET; i++) exist[i] = *exist + i * NUM_O_BIT;
1815 /* Check for exist option bits */
1816 for (i = 0; option_info[i].o_desc; i++)
1818 option_type *ot_ptr = &option_info[i];
1819 if (ot_ptr->o_var) exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
1822 fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n",
1823 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1825 fputs("Set - Bit (Page) Option Name\n", fff);
1826 fputs("------------------------------------------------\n", fff);
1827 /* Dump option bits usage */
1828 for (i = 0; i < NUM_O_SET; i++)
1830 for (j = 0; j < NUM_O_BIT; j++)
1834 option_type *ot_ptr = &option_info[exist[i][j] - 1];
1835 fprintf(fff, " %d - %02d (%4d) %s\n",
1836 i, j, ot_ptr->o_page, ot_ptr->o_text);
1840 fprintf(fff, " %d - %02d\n", i, j);
1846 /* Free the "exist" array (2-dimension) */
1847 C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
1848 C_KILL(exist, NUM_O_SET, int *);
1854 msg_format("¥ª¥×¥·¥ç¥óbit»ÈÍѾõ¶·¤ò¥Õ¥¡¥¤¥ë %s ¤Ë½ñ¤½Ð¤·¤Þ¤·¤¿¡£", buf);
1856 msg_format("Option bits usage dump saved to file %s.", buf);
1861 #ifdef ALLOW_SPOILERS
1866 extern void do_cmd_spoilers(void);
1868 #endif /* ALLOW_SPOILERS */
1873 * Hack -- declare external function
1875 extern void do_cmd_debug(void);
1880 * Ask for and parse a "debug command"
1881 * The "command_arg" may have been set.
1883 void do_cmd_debug(void)
1889 /* Get a "debug command" */
1890 get_com("Debug Command: ", &cmd, FALSE);
1892 /* Analyze the command */
1902 #ifdef ALLOW_SPOILERS
1904 /* Hack -- Generate Spoilers */
1909 #endif /* ALLOW_SPOILERS */
1916 /* Cure all maladies */
1918 do_cmd_wiz_cure_all();
1921 /* Know alignment */
1923 msg_format("Your alignment is %d.", p_ptr->align);
1926 /* Teleport to target */
1935 /* Create any object */
1940 /* Create a named artifact */
1942 wiz_create_named_art();
1945 /* Detect everything */
1947 detect_all(DETECT_RAD_ALL * 3);
1950 /* Dimension_door */
1952 wiz_dimension_door();
1955 /* Edit character */
1957 do_cmd_wiz_change();
1960 /* Blue Mage Only */
1962 if (p_ptr->pclass == CLASS_BLUE_MAGE)
1964 do_cmd_wiz_blue_mage();
1968 /* View item info */
1970 identify_fully(FALSE);
1973 /* Create desired feature */
1975 do_cmd_wiz_create_feature();
1980 if (command_arg <= 0) command_arg = 1;
1981 acquirement(py, px, command_arg, FALSE, TRUE);
1984 /* Hitpoint rerating */
1986 do_cmd_rerate(TRUE);
1989 #ifdef MONSTER_HORDES
1991 do_cmd_summon_horde();
1993 #endif /* MONSTER_HORDES */
1997 (void)ident_spell(FALSE);
2000 /* Go up or down in the dungeon */
2005 /* Self-Knowledge */
2010 /* Learn about objects */
2017 map_area(DETECT_RAD_ALL * 3);
2022 (void)gain_random_mutation(command_arg);
2025 /* Specific reward */
2027 (void)gain_level_reward(command_arg);
2030 /* Summon _friendly_ named monster */
2032 do_cmd_wiz_named_friendly(command_arg);
2035 /* Summon Named Monster */
2037 do_cmd_wiz_named(command_arg);
2040 /* Dump option bits usage */
2042 do_cmd_dump_options();
2045 /* Object playing routines */
2052 teleport_player(10, 0L);
2056 /* Complete a Quest -KMW- */
2058 for (i = 0; i < max_quests; i++)
2060 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
2062 p_ptr->quest[i].status++;
2063 msg_print("Completed Quest");
2068 if (i == max_quests)
2070 msg_print("No current quest");
2076 /* Make every dungeon square "known" to test streamers -KMW- */
2078 for (y = 0; y < cur_hgt; y++)
2080 for (x = 0; x < cur_wid; x++)
2082 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
2088 /* Summon Random Monster(s) */
2090 if (command_arg <= 0) command_arg = 1;
2091 do_cmd_wiz_summon(command_arg);
2096 teleport_player(100, 0L);
2099 /* Very Good Objects */
2101 if (command_arg <= 0) command_arg = 1;
2102 acquirement(py, px, command_arg, TRUE, TRUE);
2105 /* Wizard Light the Level */
2107 wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
2110 /* Increase Experience */
2112 gain_exp(command_arg ? command_arg : (p_ptr->exp + 1));
2115 /* Zap Monsters (Genocide) */
2120 /* Zap Monsters (Omnicide) */
2122 do_cmd_wiz_zap_all();
2125 /* Hack -- whatever I desire */
2127 do_cmd_wiz_hack_ben();
2130 /* Not a Wizard Command */
2132 msg_print("That is not a valid debug command.");