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, FALSE, FALSE);
118 * Create the artifact of the specified number -- DAN
121 static void wiz_create_named_art(int a_idx)
123 /* Create the artifact */
124 create_named_art(a_idx, py, px);
127 msg_print("Allocated.");
132 * Hack -- quick debugging hook
134 static void do_cmd_wiz_hack_ben(void)
143 #ifdef MONSTER_HORDES
145 /* Summon a horde of monsters */
146 static void do_cmd_summon_horde(void)
148 int wy = py, wx = px;
153 scatter(&wy, &wx, py, px, 3, 0);
154 if (cave_empty_bold(wy, wx)) break;
157 (void)alloc_horde(wy, wx);
160 #endif /* MONSTER_HORDES */
164 * Output a long int in binary format.
166 static void prt_binary(u32b flags, int row, int col)
172 for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
177 Term_putch(col++, row, TERM_BLUE, '*');
180 /* Dump unset bits */
183 Term_putch(col++, row, TERM_WHITE, '-');
189 #define K_MAX_DEPTH 110
192 * Output a rarity graph for a type of object.
194 static void prt_alloc(byte tval, byte sval, int row, int col)
198 u32b maxr = 1, maxt = 1, ratio;
199 u32b rarity[K_MAX_DEPTH];
200 u32b total[K_MAX_DEPTH];
201 s32b maxd = 1, display[22];
203 cptr r = "+--common--+";
208 alloc_entry *table = alloc_kind_table;
210 /* Wipe the tables */
211 (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
212 (void)C_WIPE(total, K_MAX_DEPTH, u32b);
213 (void)C_WIPE(display, 22, s32b);
215 /* Scan all entries */
216 for (i = 0; i < K_MAX_DEPTH; i++)
219 for (j = 0; j < alloc_kind_size; j++)
223 if (table[j].level <= i)
225 prob = table[j].prob1 * GREAT_OBJ * K_MAX_DEPTH;
227 else if (table[j].level - 1 > 0)
229 prob = table[j].prob1 * i * K_MAX_DEPTH / (table[j].level - 1);
232 /* Acquire this kind */
233 k_ptr = &k_info[table[j].index];
235 /* Accumulate probabilities */
236 total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
237 total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
239 /* Accumulate probabilities */
240 if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
246 total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
250 for (i = 0; i < K_MAX_DEPTH; i++)
252 if (rarity[i] > maxr) maxr = rarity[i];
253 if (total[i] > maxt) maxt = total[i];
256 if (maxr / (GREAT_OBJ * K_MAX_DEPTH) != 0)
257 ratio = maxt / (maxr / (GREAT_OBJ * K_MAX_DEPTH));
261 /* Simulate a log graph */
278 /* Calculate probabilities for each range */
279 for (i = 0; i < 22; i++)
281 /* Shift the values into view */
284 for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
285 possibility += rarity[j] * (100 * maxt / total[j]);
287 possibility = possibility / maxr;
289 /* display[i] = log_{sqrt(2)}(possibility) */
294 possibility = possibility * 1000 / 1414;
298 if (display[i] > maxd) maxd = display[i];
302 if (maxd > 10) for (i = 0; i < 22; i++)
304 display[i] = display[i] - maxd + 10;
307 /* Graph the rarities */
308 for (i = 0; i < 22; i++)
310 Term_putch(col, row + i + 1, TERM_WHITE, '|');
312 prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
318 if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
320 c_prt(TERM_RED, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
324 c_prt(c, format("%.*s", display[i], "**********"), row + i + 1, col + 1);
328 /* Make it look nice */
334 * Hack -- Teleport to the target
336 static void do_cmd_wiz_bamf(void)
338 /* Must have a target */
339 if (!target_who) return;
341 /* Teleport to the target */
342 teleport_player_to(target_row, target_col, FALSE, FALSE);
347 * Aux function for "do_cmd_wiz_change()". -RAK-
349 static void do_cmd_wiz_change_aux(void)
359 /* Query the stats */
360 for (i = 0; i < 6; i++)
363 sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
366 sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
369 if (!get_string(ppp, tmp_val, 3)) return;
372 tmp_int = atoi(tmp_val);
375 if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
376 else if (tmp_int < 3) tmp_int = 3;
379 p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
384 sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
388 if (!get_string("½ÏÎýÅÙ: ", tmp_val, 9)) return;
390 if (!get_string("Proficiency: ", tmp_val, 9)) return;
394 tmp_s16b = atoi(tmp_val);
397 if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED;
398 if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER;
400 for (j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++)
402 for (i = 0;i < 64;i++)
404 p_ptr->weapon_exp[j][i] = tmp_s16b;
405 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];
409 for (j = 0; j < 10; j++)
411 p_ptr->skill_exp[j] = tmp_s16b;
412 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];
415 for (j = 0; j < 32; j++)
416 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
418 p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
421 sprintf(tmp_val, "%ld", (long)(p_ptr->au));
424 if (!get_string("Gold: ", tmp_val, 9)) return;
427 tmp_long = atol(tmp_val);
430 if (tmp_long < 0) tmp_long = 0L;
433 p_ptr->au = tmp_long;
437 sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
440 if (!get_string("Experience: ", tmp_val, 9)) return;
443 tmp_long = atol(tmp_val);
446 if (tmp_long < 0) tmp_long = 0L;
448 if (p_ptr->prace != RACE_ANDROID)
451 p_ptr->max_exp = tmp_long;
452 p_ptr->exp = tmp_long;
461 * Change various "permanent" player variables.
463 static void do_cmd_wiz_change(void)
466 do_cmd_wiz_change_aux();
468 /* Redraw everything */
474 * Wizard routines for creating objects -RAK-
475 * And for manipulating them! -Bernd-
477 * This has been rewritten to make the whole procedure
478 * of debugging objects much easier and more comfortable.
480 * The following functions are meant to play with objects:
481 * Create, modify, roll for them (for statistic purposes) and more.
482 * The original functions were by RAK.
483 * The function to show an item's debug information was written
484 * by David Reeve Sward <sward+@CMU.EDU>.
485 * Bernd (wiebelt@mathematik.hu-berlin.de)
487 * Here are the low-level functions
488 * - wiz_display_item()
489 * display an item's debug-info
490 * - wiz_create_itemtype()
491 * specify tval and sval (type and subtype of object)
493 * specify pval, +AC, +tohit, +todam
494 * Note that the wizard can leave this function anytime,
495 * thus accepting the default-values for the remaining values.
496 * pval comes first now, since it is most important.
497 * - wiz_reroll_item()
498 * apply some magic to the item or turn it into an artifact.
500 * Get some statistics about the rarity of an item:
501 * We create a lot of fake items and see if they are of the
502 * same type (tval and sval), then we compare pval and +AC.
503 * If the fake-item is better or equal it is counted.
504 * Note that cursed items that are better or equal (absolute values)
506 * HINT: This is *very* useful for balancing the game!
507 * - wiz_quantity_item()
508 * change the quantity of an item, but be sane about it.
510 * And now the high-level functions
511 * - do_cmd_wiz_play()
512 * play with an existing object
513 * - wiz_create_item()
514 * create a new object
516 * Note -- You do not have to specify "pval" and other item-properties
517 * directly. Just apply magic until you are satisfied with the item.
519 * Note -- For some items (such as wands, staffs, some rings, etc), you
520 * must apply magic, or you will get "broken" or "uncharged" objects.
522 * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
523 * the artifact. Be careful.
525 * Hack -- this function will allow you to create multiple artifacts.
526 * This "feature" may induce crashes or other nasty effects.
530 * Just display an item's properties (debug-info)
531 * Originally by David Reeve Sward <sward+@CMU.EDU>
532 * Verbose item flags by -Bernd-
534 static void wiz_display_item(object_type *o_ptr)
537 u32b flgs[TR_FLAG_SIZE];
540 /* Extract the flags */
541 object_flags(o_ptr, flgs);
543 /* Clear the screen */
544 for (i = 1; i <= 23; i++) prt("", i, j - 2);
546 prt_alloc(o_ptr->tval, o_ptr->sval, 1, 0);
549 object_desc(buf, o_ptr, OD_STORE);
553 prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d",
554 o_ptr->k_idx, k_info[o_ptr->k_idx].level,
555 o_ptr->tval, o_ptr->sval), 4, j);
557 prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %dd%d",
558 o_ptr->number, o_ptr->weight,
559 o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
561 prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d",
562 o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
564 prt(format("name1 = %-4d name2 = %-4d cost = %ld",
565 o_ptr->name1, o_ptr->name2, (long)object_value_real(o_ptr)), 7, j);
567 prt(format("ident = %04x xtra1 = %-4d xtra2 = %-4d timeout = %-d",
568 o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
570 prt(format("xtra3 = %-4d xtra4 = %-4d xtra5 = %-4d cursed = %-d",
571 o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
573 prt("+------------FLAGS1------------+", 10, j);
574 prt("AFFECT........SLAY........BRAND.", 11, j);
575 prt(" mf cvae xsqpaefc", 12, j);
576 prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
577 prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
578 prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
579 prt_binary(flgs[0], 16, j);
581 prt("+------------FLAGS2------------+", 17, j);
582 prt("SUST....IMMUN.RESIST............", 18, j);
583 prt(" reaefctrpsaefcpfldbc sn ", 19, j);
584 prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
585 prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
586 prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
587 prt_binary(flgs[1], 23, j);
589 prt("+------------FLAGS3------------+", 10, j+32);
590 prt("fe cnn t stdrmsiiii d ab ", 11, j+32);
591 prt("aa aoomywhs lleeieihgggg rtgl ", 12, j+32);
592 prt("uu utmacaih eielgggonnnnaaere ", 13, j+32);
593 prt("rr reanurdo vtieeehtrrrrcilas ", 14, j+32);
594 prt("aa algarnew ienpsntsaefctnevs ", 15, j+32);
595 prt_binary(flgs[2], 16, j+32);
597 prt("+------------FLAGS4------------+", 17, j+32);
598 prt("KILL....ESP......... ", 18, j+32);
599 prt("aeud tghaud tgdhegnu ", 19, j+32);
600 prt("nvneoriunneoriruvoon ", 20, j+32);
601 prt("iidmroamidmroagmionq ", 21, j+32);
602 prt("mlenclnmmenclnnnldlu ", 22, j+32);
603 prt_binary(flgs[3], 23, j+32);
608 * A structure to hold a tval and its description
610 typedef struct tval_desc
617 * A list of tvals and their textual names
619 static tval_desc tvals[] =
621 { TV_SWORD, "Sword" },
622 { TV_POLEARM, "Polearm" },
623 { TV_HAFTED, "Hafted Weapon" },
625 { TV_ARROW, "Arrows" },
626 { TV_BOLT, "Bolts" },
627 { TV_SHOT, "Shots" },
628 { TV_SHIELD, "Shield" },
629 { TV_CROWN, "Crown" },
631 { TV_GLOVES, "Gloves" },
632 { TV_BOOTS, "Boots" },
633 { TV_CLOAK, "Cloak" },
634 { TV_DRAG_ARMOR, "Dragon Scale Mail" },
635 { TV_HARD_ARMOR, "Hard Armor" },
636 { TV_SOFT_ARMOR, "Soft Armor" },
638 { TV_AMULET, "Amulet" },
640 { TV_POTION, "Potion" },
641 { TV_SCROLL, "Scroll" },
643 { TV_STAFF, "Staff" },
645 { TV_LIFE_BOOK, "Life Spellbook" },
646 { TV_SORCERY_BOOK, "Sorcery Spellbook" },
647 { TV_NATURE_BOOK, "Nature Spellbook" },
648 { TV_CHAOS_BOOK, "Chaos Spellbook" },
649 { TV_DEATH_BOOK, "Death Spellbook" },
650 { TV_TRUMP_BOOK, "Trump Spellbook" },
651 { TV_ARCANE_BOOK, "Arcane Spellbook" },
652 { TV_ENCHANT_BOOK, "Craft Spellbook"},
653 { TV_DAEMON_BOOK, "Daemon Spellbook"},
654 { TV_CRUSADE_BOOK, "Crusade Spellbook"},
655 { TV_MUSIC_BOOK, "Music Spellbook" },
656 { TV_HISSATSU_BOOK, "Book of Kendo" },
657 { TV_PARCHMENT, "Parchment" },
658 { TV_WHISTLE, "Whistle" },
659 { TV_SPIKE, "Spikes" },
660 { TV_DIGGING, "Digger" },
661 { TV_CHEST, "Chest" },
662 { TV_CAPTURE, "Capture Ball" },
663 { TV_CARD, "Express Card" },
664 { TV_FIGURINE, "Magical Figurine" },
665 { TV_STATUE, "Statue" },
666 { TV_CORPSE, "Corpse" },
668 { TV_FLASK, "Flask" },
670 { TV_SKELETON, "Skeleton" },
676 * Strip an "object name" into a buffer
678 void strip_name(char *buf, int k_idx)
682 object_kind *k_ptr = &k_info[k_idx];
684 cptr str = (k_name + k_ptr->name);
687 /* Skip past leading characters */
688 while ((*str == ' ') || (*str == '&')) str++;
690 /* Copy useful chars */
691 for (t = buf; *str; str++)
694 if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
696 if (*str != '~') *t++ = *str;
699 /* Terminate the new name */
705 * Specify tval and sval (type and subtype of object) originally
706 * by RAK, heavily modified by -Bernd-
708 * This function returns the k_idx of an object type, or zero if failed
710 * List up to 50 choices in three columns
712 static int wiz_create_itemtype(void)
729 /* Print all tval's and their descriptions */
730 for (num = 0; (num < 80) && tvals[num].tval; num++)
732 row = 2 + (num % 20);
733 col = 20 * (num / 20);
735 prt(format("[%c] %s", ch, tvals[num].desc), row, col);
738 /* Me need to know the maximal possible tval_index */
742 if (!get_com("Get what type of object? ", &ch, FALSE)) return (0);
745 for (num = 0; num < max_num; num++)
747 if (listsym[num] == ch) break;
750 /* Bail out if choice is illegal */
751 if ((num < 0) || (num >= max_num)) return (0);
753 /* Base object type chosen, fill in tval */
754 tval = tvals[num].tval;
755 tval_desc = tvals[num].desc;
758 /*** And now we go for k_idx ***/
763 /* We have to search the whole itemlist. */
764 for (num = 0, i = 1; (num < 80) && (i < max_k_idx); i++)
766 object_kind *k_ptr = &k_info[i];
768 /* Analyze matching items */
769 if (k_ptr->tval == tval)
772 row = 2 + (num % 20);
773 col = 20 * (num / 20);
777 /* Acquire the "name" of object "i" */
781 prt(format("[%c] %s", ch, buf), row, col);
783 /* Remember the object index */
788 /* Me need to know the maximal possible remembered object_index */
792 if (!get_com(format("What Kind of %s? ", tval_desc), &ch, FALSE)) return (0);
795 for (num = 0; num < max_num; num++)
797 if (listsym[num] == ch) break;
800 /* Bail out if choice is "illegal" */
801 if ((num < 0) || (num >= max_num)) return (0);
803 /* And return successful */
804 return (choice[num]);
811 static void wiz_tweak_item(object_type *o_ptr)
817 /* Hack -- leave artifacts alone */
818 if (artifact_p(o_ptr) || o_ptr->art_name) return;
820 p = "Enter new 'pval' setting: ";
821 sprintf(tmp_val, "%d", o_ptr->pval);
822 if (!get_string(p, tmp_val, 5)) return;
823 o_ptr->pval = atoi(tmp_val);
824 wiz_display_item(o_ptr);
826 p = "Enter new 'to_a' setting: ";
827 sprintf(tmp_val, "%d", o_ptr->to_a);
828 if (!get_string(p, tmp_val, 5)) return;
829 o_ptr->to_a = atoi(tmp_val);
830 wiz_display_item(o_ptr);
832 p = "Enter new 'to_h' setting: ";
833 sprintf(tmp_val, "%d", o_ptr->to_h);
834 if (!get_string(p, tmp_val, 5)) return;
835 o_ptr->to_h = atoi(tmp_val);
836 wiz_display_item(o_ptr);
838 p = "Enter new 'to_d' setting: ";
839 sprintf(tmp_val, "%d", o_ptr->to_d);
840 if (!get_string(p, tmp_val, 5)) return;
841 o_ptr->to_d = atoi(tmp_val);
842 wiz_display_item(o_ptr);
847 * Apply magic to an item or turn it into an artifact. -Bernd-
849 static void wiz_reroll_item(object_type *o_ptr)
856 bool changed = FALSE;
859 /* Hack -- leave artifacts alone */
860 if (artifact_p(o_ptr) || o_ptr->art_name) return;
863 /* Get local object */
866 /* Copy the object */
867 object_copy(q_ptr, o_ptr);
870 /* Main loop. Ask for magification and artifactification */
873 /* Display full item debug information */
874 wiz_display_item(q_ptr);
876 /* Ask wizard what to do. */
877 if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
879 /* Preserve wizard-generated artifacts */
880 if (artifact_p(q_ptr))
882 a_info[q_ptr->name1].cur_num = 0;
890 /* Create/change it! */
891 if (ch == 'A' || ch == 'a')
897 /* Preserve wizard-generated artifacts */
898 if (artifact_p(q_ptr))
900 a_info[q_ptr->name1].cur_num = 0;
906 /* Apply bad magic, but first clear object */
909 object_prep(q_ptr, o_ptr->k_idx);
910 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
913 /* Apply bad magic, but first clear object */
916 object_prep(q_ptr, o_ptr->k_idx);
917 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
920 /* Apply normal magic, but first clear object */
923 object_prep(q_ptr, o_ptr->k_idx);
924 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
927 /* Apply good magic, but first clear object */
930 object_prep(q_ptr, o_ptr->k_idx);
931 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD);
934 /* Apply great magic, but first clear object */
937 object_prep(q_ptr, o_ptr->k_idx);
938 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
941 /* Apply special magic, but first clear object */
944 object_prep(q_ptr, o_ptr->k_idx);
945 apply_magic(q_ptr, dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
947 /* Failed to create artifact; make a random one */
948 if (!artifact_p(q_ptr) && !q_ptr->art_name) create_artifact(q_ptr, FALSE);
952 q_ptr->iy = o_ptr->iy;
953 q_ptr->ix = o_ptr->ix;
954 q_ptr->next_o_idx = o_ptr->next_o_idx;
955 q_ptr->marked = o_ptr->marked;
963 object_copy(o_ptr, q_ptr);
965 /* Recalculate bonuses */
966 p_ptr->update |= (PU_BONUS);
968 /* Combine / Reorder the pack (later) */
969 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
972 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
979 * Try to create an item again. Output some statistics. -Bernd-
981 * The statistics are correct now. We acquire a clean grid, and then
982 * repeatedly place an object in this grid, copying it into an item
983 * holder, and then deleting the object. We fiddle with the artifact
984 * counter flags to prevent weirdness. We use the items to collect
985 * statistics on item creation relative to the initial item.
987 static void wiz_statistics(object_type *o_ptr)
989 u32b i, matches, better, worse, other, correct;
991 u32b test_roll = 1000000;
1001 cptr q = "Rolls: %ld Correct: %ld Matches: %ld Better: %ld Worse: %ld Other: %ld";
1003 cptr p = "Enter number of items to roll: ";
1007 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1008 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 0;
1014 cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
1017 wiz_display_item(o_ptr);
1020 if (!get_com(pmt, &ch, FALSE)) break;
1022 if (ch == 'n' || ch == 'N')
1027 else if (ch == 'g' || ch == 'G')
1032 else if (ch == 'e' || ch == 'E')
1034 mode = AM_GOOD | AM_GREAT;
1035 quality = "excellent";
1042 sprintf(tmp_val, "%ld", test_roll);
1043 if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
1044 test_roll = MAX(1, test_roll);
1046 /* Let us know what we are doing */
1047 msg_format("Creating a lot of %s items. Base level = %d.",
1048 quality, dun_level);
1051 /* Set counters to zero */
1052 correct = matches = better = worse = other = 0;
1054 /* Let's rock and roll */
1055 for (i = 0; i <= test_roll; i++)
1057 /* Output every few rolls */
1058 if ((i < 100) || (i % 100 == 0))
1063 /* Allow interupt */
1073 /* Dump the stats */
1074 prt(format(q, i, correct, matches, better, worse, other), 0, 0);
1079 /* Get local object */
1082 /* Wipe the object */
1085 /* Create an object */
1086 make_object(q_ptr, mode);
1089 /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
1090 if (artifact_p(q_ptr)) a_info[q_ptr->name1].cur_num = 0;
1093 /* Test for the same tval and sval. */
1094 if ((o_ptr->tval) != (q_ptr->tval)) continue;
1095 if ((o_ptr->sval) != (q_ptr->sval)) continue;
1097 /* One more correct item */
1100 /* Check for match */
1101 if ((q_ptr->pval == o_ptr->pval) &&
1102 (q_ptr->to_a == o_ptr->to_a) &&
1103 (q_ptr->to_h == o_ptr->to_h) &&
1104 (q_ptr->to_d == o_ptr->to_d) &&
1105 (q_ptr->name1 == o_ptr->name1))
1110 /* Check for better */
1111 else if ((q_ptr->pval >= o_ptr->pval) &&
1112 (q_ptr->to_a >= o_ptr->to_a) &&
1113 (q_ptr->to_h >= o_ptr->to_h) &&
1114 (q_ptr->to_d >= o_ptr->to_d))
1119 /* Check for worse */
1120 else if ((q_ptr->pval <= o_ptr->pval) &&
1121 (q_ptr->to_a <= o_ptr->to_a) &&
1122 (q_ptr->to_h <= o_ptr->to_h) &&
1123 (q_ptr->to_d <= o_ptr->to_d))
1128 /* Assume different */
1136 msg_format(q, i, correct, matches, better, worse, other);
1141 /* Hack -- Normally only make a single artifact */
1142 if (artifact_p(o_ptr)) a_info[o_ptr->name1].cur_num = 1;
1147 * Change the quantity of a the item
1149 static void wiz_quantity_item(object_type *o_ptr)
1151 int tmp_int, tmp_qnt;
1156 /* Never duplicate artifacts */
1157 if (artifact_p(o_ptr) || o_ptr->art_name) return;
1159 /* Store old quantity. -LM- */
1160 tmp_qnt = o_ptr->number;
1163 sprintf(tmp_val, "%d", o_ptr->number);
1166 if (get_string("Quantity: ", tmp_val, 2))
1169 tmp_int = atoi(tmp_val);
1172 if (tmp_int < 1) tmp_int = 1;
1173 if (tmp_int > 99) tmp_int = 99;
1175 /* Accept modifications */
1176 o_ptr->number = tmp_int;
1179 if (o_ptr->tval == TV_ROD)
1181 o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
1185 /* debug command for blue mage */
1186 static void do_cmd_wiz_blue_mage(void)
1191 s32b f4 = 0, f5 = 0, f6 = 0;
1196 set_rf_masks(&f4, &f5, &f6, j);
1198 for (i = 0; i < 32; i++)
1200 if ((0x00000001 << i) & f4) p_ptr->magic_num2[i] = 1;
1204 if ((0x00000001 << (i - 32)) & f5) p_ptr->magic_num2[i] = 1;
1208 if ((0x00000001 << (i - 64)) & f6) p_ptr->magic_num2[i] = 1;
1215 * Play with an item. Options include:
1216 * - Output statistics (via wiz_roll_item)
1217 * - Reroll item (via wiz_reroll_item)
1218 * - Change properties (via wiz_tweak_item)
1219 * - Change the number of items (via wiz_quantity_item)
1221 static void do_cmd_wiz_play(void)
1236 item_tester_no_ryoute = TRUE;
1238 q = "Play with which object? ";
1239 s = "You have nothing to play with.";
1240 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1242 /* Get the item (in the pack) */
1245 o_ptr = &inventory[item];
1248 /* Get the item (on the floor) */
1251 o_ptr = &o_list[0 - item];
1254 /* The item was not changed */
1258 /* Save the screen */
1262 /* Get local object */
1266 object_copy(q_ptr, o_ptr);
1272 /* Display the item */
1273 wiz_display_item(q_ptr);
1276 if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
1282 if (ch == 'A' || ch == 'a')
1288 if (ch == 's' || ch == 'S')
1290 wiz_statistics(q_ptr);
1293 if (ch == 'r' || ch == 'r')
1295 wiz_reroll_item(q_ptr);
1298 if (ch == 't' || ch == 'T')
1300 wiz_tweak_item(q_ptr);
1303 if (ch == 'q' || ch == 'Q')
1305 wiz_quantity_item(q_ptr);
1310 /* Restore the screen */
1318 msg_print("Changes accepted.");
1320 /* Recalcurate object's weight */
1323 p_ptr->total_weight += (q_ptr->weight * q_ptr->number)
1324 - (o_ptr->weight * o_ptr->number);
1328 object_copy(o_ptr, q_ptr);
1331 /* Recalculate bonuses */
1332 p_ptr->update |= (PU_BONUS);
1334 /* Combine / Reorder the pack (later) */
1335 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1338 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1344 msg_print("Changes ignored.");
1350 * Wizard routine for creating objects -RAK-
1351 * Heavily modified to allow magification and artifactification -Bernd-
1353 * Note that wizards cannot create objects on top of other objects.
1355 * Hack -- this routine always makes a "dungeon object", and applies
1356 * magic to it, and attempts to decline cursed items.
1358 static void wiz_create_item(void)
1366 /* Save the screen */
1369 /* Get object base type */
1370 k_idx = wiz_create_itemtype();
1372 /* Restore the screen */
1376 /* Return if failed */
1379 if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
1384 for (i = 1; i < max_a_idx; i++)
1386 /* Ignore incorrect tval */
1387 if (a_info[i].tval != k_info[k_idx].tval) continue;
1389 /* Ignore incorrect sval */
1390 if (a_info[i].sval != k_info[k_idx].sval) continue;
1392 /* Create this artifact */
1393 create_named_art(i, py, px);
1396 msg_print("Allocated(INSTA_ART).");
1402 /* Get local object */
1405 /* Create the item */
1406 object_prep(q_ptr, k_idx);
1409 apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
1411 /* Drop the object from heaven */
1412 (void)drop_near(q_ptr, -1, py, px);
1415 msg_print("Allocated.");
1420 * Cure everything instantly
1422 static void do_cmd_wiz_cure_all(void)
1425 (void)res_stat(A_STR);
1426 (void)res_stat(A_INT);
1427 (void)res_stat(A_WIS);
1428 (void)res_stat(A_CON);
1429 (void)res_stat(A_DEX);
1430 (void)res_stat(A_CHR);
1432 /* Restore the level */
1433 (void)restore_level();
1435 /* Heal the player */
1436 p_ptr->chp = p_ptr->mhp;
1437 p_ptr->chp_frac = 0;
1440 if (p_ptr->csp < p_ptr->msp)
1442 p_ptr->csp = p_ptr->msp;
1443 p_ptr->csp_frac = 0;
1448 (void)set_confused(0);
1449 (void)set_poisoned(0);
1450 (void)set_afraid(0);
1451 (void)set_paralyzed(0);
1455 (void)set_slow(0, TRUE);
1457 /* No longer hungry */
1458 (void)set_food(PY_FOOD_MAX - 1);
1460 /* Redraw everything */
1468 static void do_cmd_wiz_jump(void)
1471 if (command_arg <= 0)
1476 int tmp_dungeon_type;
1479 sprintf(ppp, "Jump which dungeon : ");
1482 sprintf(tmp_val, "%d", dungeon_type);
1484 /* Ask for a level */
1485 if (!get_string(ppp, tmp_val, 2)) return;
1487 tmp_dungeon_type = atoi(tmp_val);
1488 if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
1491 sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[tmp_dungeon_type].mindepth, d_info[tmp_dungeon_type].maxdepth);
1494 sprintf(tmp_val, "%d", dun_level);
1496 /* Ask for a level */
1497 if (!get_string(ppp, tmp_val, 10)) return;
1499 /* Extract request */
1500 command_arg = atoi(tmp_val);
1502 dungeon_type = tmp_dungeon_type;
1506 if (command_arg < d_info[dungeon_type].mindepth) command_arg = 0;
1509 if (command_arg > d_info[dungeon_type].maxdepth) command_arg = d_info[dungeon_type].maxdepth;
1511 /* Accept request */
1512 msg_format("You jump to dungeon level %d.", command_arg);
1514 if (autosave_l) do_cmd_save_game(TRUE);
1517 dun_level = command_arg;
1519 prepare_change_floor_mode(CFM_RAND_PLACE);
1521 if (!dun_level) dungeon_type = 0;
1522 p_ptr->inside_arena = FALSE;
1523 p_ptr->wild_mode = FALSE;
1525 leave_quest_check();
1527 if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
1529 p_ptr->inside_quest = 0;
1532 /* Prevent energy_need from being too lower than 0 */
1533 p_ptr->energy_need = 0;
1536 * Clear all saved floors
1537 * and create a first saved floor
1539 prepare_change_floor_mode(CFM_FIRST_FLOOR);
1542 p_ptr->leaving = TRUE;
1547 * Become aware of a lot of objects
1549 static void do_cmd_wiz_learn(void)
1556 /* Scan every object */
1557 for (i = 1; i < max_k_idx; i++)
1559 object_kind *k_ptr = &k_info[i];
1561 /* Induce awareness */
1562 if (k_ptr->level <= command_arg)
1564 /* Get local object */
1567 /* Prepare object */
1568 object_prep(q_ptr, i);
1571 object_aware(q_ptr);
1578 * Summon some creatures
1580 static void do_cmd_wiz_summon(int num)
1584 for (i = 0; i < num; i++)
1586 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1592 * Summon a creature of the specified type
1594 * XXX XXX XXX This function is rather dangerous
1596 static void do_cmd_wiz_named(int r_idx)
1598 (void)summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
1603 * Summon a creature of the specified type
1605 * XXX XXX XXX This function is rather dangerous
1607 static void do_cmd_wiz_named_friendly(int r_idx)
1609 (void)summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
1615 * Hack -- Delete all nearby monsters
1617 static void do_cmd_wiz_zap(void)
1622 /* Genocide everyone nearby */
1623 for (i = 1; i < m_max; i++)
1625 monster_type *m_ptr = &m_list[i];
1627 /* Paranoia -- Skip dead monsters */
1628 if (!m_ptr->r_idx) continue;
1630 /* Skip the mount */
1631 if (i == p_ptr->riding) continue;
1633 /* Delete nearby monsters */
1634 if (m_ptr->cdis <= MAX_SIGHT)
1636 delete_monster_idx(i);
1643 * Hack -- Delete all monsters
1645 static void do_cmd_wiz_zap_all(void)
1649 /* Genocide everyone */
1650 for (i = 1; i < m_max; i++)
1652 monster_type *m_ptr = &m_list[i];
1654 /* Paranoia -- Skip dead monsters */
1655 if (!m_ptr->r_idx) continue;
1657 /* Skip the mount */
1658 if (i == p_ptr->riding) continue;
1660 /* Delete this monster */
1661 delete_monster_idx(i);
1667 #define NUM_O_BIT 32
1670 * Hack -- Dump option bits usage
1672 static void do_cmd_dump_options(void)
1679 /* Build the filename */
1680 path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
1682 /* File type is "TEXT" */
1683 FILE_TYPE(FILE_TYPE_TEXT);
1686 fff = my_fopen(buf, "a");
1692 msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
1694 msg_format("Failed to open file %s.", buf);
1700 /* Allocate the "exist" array (2-dimension) */
1701 C_MAKE(exist, NUM_O_SET, int *);
1702 C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
1703 for (i = 1; i < NUM_O_SET; i++) exist[i] = *exist + i * NUM_O_BIT;
1705 /* Check for exist option bits */
1706 for (i = 0; option_info[i].o_desc; i++)
1708 option_type *ot_ptr = &option_info[i];
1709 if (ot_ptr->o_var) exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
1712 fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n",
1713 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1715 fputs("Set - Bit (Page) Option Name\n", fff);
1716 fputs("------------------------------------------------\n", fff);
1717 /* Dump option bits usage */
1718 for (i = 0; i < NUM_O_SET; i++)
1720 for (j = 0; j < NUM_O_BIT; j++)
1724 option_type *ot_ptr = &option_info[exist[i][j] - 1];
1725 fprintf(fff, " %d - %02d (%4d) %s\n",
1726 i, j, ot_ptr->o_page, ot_ptr->o_text);
1730 fprintf(fff, " %d - %02d\n", i, j);
1736 /* Free the "exist" array (2-dimension) */
1737 C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
1738 C_KILL(exist, NUM_O_SET, int *);
1744 msg_format("¥ª¥×¥·¥ç¥óbit»ÈÍѾõ¶·¤ò¥Õ¥¡¥¤¥ë %s ¤Ë½ñ¤½Ð¤·¤Þ¤·¤¿¡£", buf);
1746 msg_format("Option bits usage dump saved to file %s.", buf);
1751 #ifdef ALLOW_SPOILERS
1756 extern void do_cmd_spoilers(void);
1758 #endif /* ALLOW_SPOILERS */
1763 * Hack -- declare external function
1765 extern void do_cmd_debug(void);
1770 * Ask for and parse a "debug command"
1771 * The "command_arg" may have been set.
1773 void do_cmd_debug(void)
1779 /* Get a "debug command" */
1780 get_com("Debug Command: ", &cmd, FALSE);
1782 /* Analyze the command */
1792 #ifdef ALLOW_SPOILERS
1794 /* Hack -- Generate Spoilers */
1799 #endif /* ALLOW_SPOILERS */
1806 /* Cure all maladies */
1808 do_cmd_wiz_cure_all();
1811 /* Know alignment */
1813 msg_format("Your alignment is %d.", p_ptr->align);
1816 /* Teleport to target */
1825 /* Create any object */
1830 /* Create a named artifact */
1832 wiz_create_named_art(command_arg);
1835 /* Detect everything */
1837 detect_all(DETECT_RAD_ALL * 3);
1840 /* Dimension_door */
1842 wiz_dimension_door();
1845 /* Edit character */
1847 do_cmd_wiz_change();
1850 /* Blue Mage Only */
1852 if (p_ptr->pclass == CLASS_BLUE_MAGE)
1854 do_cmd_wiz_blue_mage();
1858 /* View item info */
1860 identify_fully(FALSE);
1865 if (command_arg <= 0) command_arg = 1;
1866 acquirement(py, px, command_arg, FALSE, TRUE);
1869 /* Hitpoint rerating */
1871 do_cmd_rerate(TRUE);
1874 #ifdef MONSTER_HORDES
1876 do_cmd_summon_horde();
1878 #endif /* MONSTER_HORDES */
1882 (void)ident_spell(FALSE);
1885 /* Go up or down in the dungeon */
1890 /* Self-Knowledge */
1895 /* Learn about objects */
1902 map_area(DETECT_RAD_ALL * 3);
1907 (void)gain_random_mutation(command_arg);
1910 /* Specific reward */
1912 (void)gain_level_reward(command_arg);
1915 /* Summon _friendly_ named monster */
1917 do_cmd_wiz_named_friendly(command_arg);
1920 /* Summon Named Monster */
1922 do_cmd_wiz_named(command_arg);
1925 /* Dump option bits usage */
1927 do_cmd_dump_options();
1930 /* Object playing routines */
1937 teleport_player(10, FALSE);
1941 /* Complete a Quest -KMW- */
1943 for (i = 0; i < max_quests; i++)
1945 if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
1947 p_ptr->quest[i].status++;
1948 msg_print("Completed Quest");
1953 if (i == max_quests)
1955 msg_print("No current quest");
1961 /* Make every dungeon square "known" to test streamers -KMW- */
1963 for (y = 0; y < cur_hgt; y++)
1965 for (x = 0; x < cur_wid; x++)
1967 cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
1973 /* Summon Random Monster(s) */
1975 if (command_arg <= 0) command_arg = 1;
1976 do_cmd_wiz_summon(command_arg);
1981 teleport_player(100, FALSE);
1984 /* Very Good Objects */
1986 if (command_arg <= 0) command_arg = 1;
1987 acquirement(py, px, command_arg, TRUE, TRUE);
1990 /* Wizard Light the Level */
1992 wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
1995 /* Increase Experience */
1997 gain_exp(command_arg ? command_arg : (p_ptr->exp + 1));
2000 /* Zap Monsters (Genocide) */
2005 /* Zap Monsters (Omnicide) */
2007 do_cmd_wiz_zap_all();
2010 /* Hack -- whatever I desire */
2012 do_cmd_wiz_hack_ben();
2015 /* Not a Wizard Command */
2017 msg_print("That is not a valid debug command.");