OSDN Git Service

デバッグモードの^A o でアイテムをいじっている時、costの表示が本物の値段
[hengbandforosx/hengbandosx.git] / src / wizard2.c
index eea6d25..b2f6636 100644 (file)
@@ -1,55 +1,66 @@
 /* File: wizard2.c */
 
-/* Purpose: Wizard commands */
-
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, and others
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
+/* Purpose: Wizard commands */
+
 #include "angband.h"
 
 
 /*
- * Hack -- Rerate Hitpoints
+ * Roll the hitdie -- aux of do_cmd_rerate()
  */
-void do_cmd_rerate(bool display)
+void do_cmd_rerate_aux(void)
 {
-       int min_value, max_value, i, percent, j;
+       /* Minimum hitpoints at highest level */
+       int min_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 3 / 8;
 
-       min_value = ((PY_MAX_LEVEL+2) * (p_ptr->hitdie + 1)) * 3 / 8;
-       min_value += p_ptr->hitdie;
+       /* Maximum hitpoints at highest level */
+       int max_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 5 / 8;
 
-       max_value = ((PY_MAX_LEVEL+2) * (p_ptr->hitdie + 1)) * 5 / 8;
-       max_value += p_ptr->hitdie;
+       int i;
 
        /* Rerate */
        while (1)
        {
-               player_hp[0] = p_ptr->hitdie;
+               /* Pre-calculate level 1 hitdice */
+               p_ptr->player_hp[0] = p_ptr->hitdie;
 
                for (i = 1; i < 4; i++)
                {
-                       j = randint1(p_ptr->hitdie);
-                       player_hp[0] += j;
+                       p_ptr->player_hp[0] += randint1(p_ptr->hitdie);
                }
 
-               /* Collect values */
+               /* Roll the hitpoint values */
                for (i = 1; i < PY_MAX_LEVEL; i++)
                {
-                       player_hp[i] = randint1(p_ptr->hitdie);
-                       player_hp[i] += player_hp[i - 1];
+                       p_ptr->player_hp[i] = p_ptr->player_hp[i - 1] + randint1(p_ptr->hitdie);
                }
 
-               /* Legal values */
-               if ((player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
-                   (player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
+               /* Require "valid" hitpoints at highest level */
+               if ((p_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
+                   (p_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
        }
+}
+
 
-       percent = (int)(((long)player_hp[PY_MAX_LEVEL - 1] * 200L) /
+/*
+ * Hack -- Rerate Hitpoints
+ */
+void do_cmd_rerate(bool display)
+{
+       int percent;
+
+       /* Rerate */
+       do_cmd_rerate_aux();
+
+       percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
                (2 * p_ptr->hitdie +
                ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
 
@@ -194,10 +205,10 @@ static void prt_alloc(byte tval, byte sval, int row, int col)
 {
        int i, j;
        int home = 0;
-       u32b maxd = 1, maxr0 = 1, maxr = 1, maxt = 1;
+       u32b maxr = 1, maxt = 1, ratio;
        u32b rarity[K_MAX_DEPTH];
        u32b total[K_MAX_DEPTH];
-       u32b display[22];
+       s32b maxd = 1, display[22];
        byte c = TERM_WHITE;
        cptr r = "+--common--+";
        object_kind *k_ptr;
@@ -209,11 +220,12 @@ static void prt_alloc(byte tval, byte sval, int row, int col)
        /* Wipe the tables */
        (void)C_WIPE(rarity, K_MAX_DEPTH, u32b);
        (void)C_WIPE(total, K_MAX_DEPTH, u32b);
-       (void)C_WIPE(display, 22, u32b);
+       (void)C_WIPE(display, 22, s32b);
 
        /* Scan all entries */
        for (i = 0; i < K_MAX_DEPTH; i++)
        {
+               int total_frac = 0;
                for (j = 0; j < alloc_kind_size; j++)
                {
                        int prob = 0;
@@ -231,7 +243,8 @@ static void prt_alloc(byte tval, byte sval, int row, int col)
                        k_ptr = &k_info[table[j].index];
 
                        /* Accumulate probabilities */
-                       total[i] += prob / GREAT_OBJ / K_MAX_DEPTH;
+                       total[i] += prob / (GREAT_OBJ * K_MAX_DEPTH);
+                       total_frac += prob % (GREAT_OBJ * K_MAX_DEPTH);
 
                        /* Accumulate probabilities */
                        if ((k_ptr->tval == tval) && (k_ptr->sval == sval))
@@ -240,43 +253,55 @@ static void prt_alloc(byte tval, byte sval, int row, int col)
                                rarity[i] += prob;
                        }
                }
+               total[i] += total_frac / (GREAT_OBJ * K_MAX_DEPTH);
        }
 
        /* Find maxima */
        for (i = 0; i < K_MAX_DEPTH; i++)
        {
-               if (rarity[i] > maxr0) maxr0 = rarity[i];
+               if (rarity[i] > maxr) maxr = rarity[i];
                if (total[i] > maxt) maxt = total[i];
        }
-       maxr = maxr0 / GREAT_OBJ / K_MAX_DEPTH;
-       if (maxr == 0) maxr = 1;
+
+       if (maxr / (GREAT_OBJ * K_MAX_DEPTH) != 0)
+               ratio = maxt / (maxr / (GREAT_OBJ * K_MAX_DEPTH));
+       else
+               ratio = 99999L;
 
        /* Simulate a log graph */
-       if (maxt / maxr > 32)
+       if (ratio > 1000)
        {
                c = TERM_L_WHITE;
                r = "+-uncommon-+";
        }
-       if (maxt / maxr > 1024)
+       if (ratio > 3000)
        {
                c = TERM_SLATE;
                r = "+---rare---+";
        }
-       if (maxt / maxr > 32768L)
+       if (ratio > 32768L)
        {
                c = TERM_L_DARK;
-               r = "+--unique--+";
+               r = "+-VeryRare-+";
        }
 
        /* Calculate probabilities for each range */
        for (i = 0; i < 22; i++)
        {
                /* Shift the values into view */
+
+               int possibility = 0;
                for (j = i * K_MAX_DEPTH / 22; j < (i + 1) * K_MAX_DEPTH / 22; j++)
+                       possibility += rarity[j] * (100 * maxt / total[j]);
+
+               possibility = possibility / maxr;
+
+               /* display[i] = log_{sqrt(2)}(possibility) */
+               display[i] = 0;
+               while (possibility)
                {
-                       if (maxr0 < 10)
-                               rarity[j] *= 10;
-                       display[i] += rarity[j] * maxt / total[j];
+                       display[i]++;
+                       possibility = possibility * 1000 / 1414;
                }
 
                /* Track maximum */
@@ -284,9 +309,9 @@ static void prt_alloc(byte tval, byte sval, int row, int col)
        }
 
        /* Normalize */
-       for (i = 0; i < 22; i++)
+       if (maxd > 10) for (i = 0; i < 22; i++)
        {
-               display[i] = display[i] * 10 / maxd;
+               display[i] = display[i] - maxd + 10;
        }
 
        /* Graph the rarities */
@@ -296,6 +321,9 @@ static void prt_alloc(byte tval, byte sval, int row, int col)
 
                prt(format("%d", (i * K_MAX_DEPTH / 220) % 10), row + i + 1, col);
 
+               if (display[i] <= 0) 
+                       continue;
+
                /* Note the level */
                if ((i * K_MAX_DEPTH / 22 <= home) && (home < (i + 1) * K_MAX_DEPTH / 22))
                {
@@ -363,7 +391,7 @@ static void do_cmd_wiz_change_aux(void)
 
 
        /* Default */
-       sprintf(tmp_val, "8000");
+       sprintf(tmp_val, "%d", WEAPON_EXP_MASTER);
 
        /* Query */
 #ifdef JP
@@ -376,28 +404,28 @@ static void do_cmd_wiz_change_aux(void)
        tmp_s16b = atoi(tmp_val);
 
        /* Verify */
-       if (tmp_s16b < 0) tmp_s16b = 0L;
-       if (tmp_s16b > 8000) tmp_s16b = 8000L;
+       if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED;
+       if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER;
 
-       for (j = 0; j <= TV_SWORD - TV_BOW;j++)
+       for (j = 0; j <= TV_SWORD - TV_BOW; j++)
        {
                for (i = 0;i < 64;i++)
                {
-                       weapon_exp[j][i] = tmp_s16b;
-                       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];
+                       p_ptr->weapon_exp[j][i] = tmp_s16b;
+                       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];
                }
        }
 
        for (j = 0; j < 10; j++)
        {
-               skill_exp[j] = tmp_s16b;
-               if (skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
+               p_ptr->skill_exp[j] = tmp_s16b;
+               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];
        }
 
        for (j = 0; j < 32; j++)
-               spell_exp[j] = (tmp_s16b > 1600 ? 1600 : tmp_s16b);
+               p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
        for (; j < 64; j++)
-               spell_exp[j] = (tmp_s16b > 1400 ? 1400 : tmp_s16b);
+               p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
 
        /* Default */
        sprintf(tmp_val, "%ld", (long)(p_ptr->au));
@@ -516,11 +544,11 @@ static void do_cmd_wiz_change(void)
 static void wiz_display_item(object_type *o_ptr)
 {
        int i, j = 13;
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        char buf[256];
 
        /* Extract the flags */
-       object_flags(o_ptr, &f1, &f2, &f3);
+       object_flags(o_ptr, flgs);
 
        /* Clear the screen */
        for (i = 1; i <= 23; i++) prt("", i, j - 2);
@@ -533,48 +561,56 @@ static void wiz_display_item(object_type *o_ptr)
        prt(buf, 2, j);
 
        prt(format("kind = %-5d  level = %-4d  tval = %-5d  sval = %-5d",
-                  o_ptr->k_idx, get_object_level(o_ptr),
-                  o_ptr->tval, o_ptr->sval), 4, j);
+                  o_ptr->k_idx, get_object_level(o_ptr),
+                  o_ptr->tval, o_ptr->sval), 4, j);
 
        prt(format("number = %-3d  wgt = %-6d  ac = %-5d    damage = %dd%d",
-                  o_ptr->number, o_ptr->weight,
-                  o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
+                  o_ptr->number, o_ptr->weight,
+                  o_ptr->ac, o_ptr->dd, o_ptr->ds), 5, j);
 
        prt(format("pval = %-5d  toac = %-5d  tohit = %-4d  todam = %-4d",
-                  o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
+                  o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), 6, j);
 
        prt(format("name1 = %-4d  name2 = %-4d  cost = %ld",
-                  o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr)), 7, j);
+                  o_ptr->name1, o_ptr->name2, (long)object_value_real(o_ptr)), 7, j);
 
        prt(format("ident = %04x  xtra1 = %-4d  xtra2 = %-4d  timeout = %-d",
-                  o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
+                  o_ptr->ident, o_ptr->xtra1, o_ptr->xtra2, o_ptr->timeout), 8, j);
 
-       prt(format("xtra3 = %-4d  xtra4 = %-4d  xtra5 = %-4d",
-                  o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5), 9, j);
+       prt(format("xtra3 = %-4d  xtra4 = %-4d  xtra5 = %-4d  cursed  = %-d",
+                  o_ptr->xtra3, o_ptr->xtra4, o_ptr->xtra5, o_ptr->curse_flags), 9, j);
 
        prt("+------------FLAGS1------------+", 10, j);
        prt("AFFECT........SLAY........BRAND.", 11, j);
-       prt("      mr      cvae      xsqpaefc", 12, j);
-       prt("siwdccsissidsahanvudotgddhuoclio", 13, j);
-       prt("tnieohtrtrnipttmiinmrrnrrraiierl", 14, j);
-       prt("rtsxnarylcfgdkcpmldncltggpksdced", 15, j);
-       prt_binary(f1, 16, j);
+       prt("      mf      cvae      xsqpaefc", 12, j);
+       prt("siwdccsossidsahanvudotgddhuoclio", 13, j);
+       prt("tnieohtctrnipttmiinmrrnrrraiierl", 14, j);
+       prt("rtsxnarelcfgdkcpmldncltggpksdced", 15, j);
+       prt_binary(flgs[0], 16, j);
 
        prt("+------------FLAGS2------------+", 17, j);
        prt("SUST....IMMUN.RESIST............", 18, j);
-       prt("        aefctrpsaefcpfldbc sn   ", 19, j);
-       prt("siwdcc  clioheatcliooeialoshtncd", 20, j);
-       prt("tnieoh  ierlrfraierliatrnnnrhehi", 21, j);
-       prt("rtsxna..dcedwlatdcedsrekdfddrxss", 22, j);
-       prt_binary(f2, 23, j);
+       prt("      reaefctrpsaefcpfldbc sn   ", 19, j);
+       prt("siwdcciaclioheatcliooeialoshtncd", 20, j);
+       prt("tnieohdsierlrfraierliatrnnnrhehi", 21, j);
+       prt("rtsxnaeydcedwlatdcedsrekdfddrxss", 22, j);
+       prt_binary(flgs[1], 23, j);
 
        prt("+------------FLAGS3------------+", 10, j+32);
-       prt("fe cnn t   i  stdrmsiiii d abchp", 11, j+32);
-       prt("aa aoomyehsnlleeieihgggg rtgluvr", 12, j+32);
-       prt("uu utmacaihseielgggonnnnaaerercc", 13, j+32);
-       prt("rr reanusdotvtieeehtrrrrcilassuu", 14, j+32);
-       prt("aa algaryewaienpsntsaefctnevserr", 15, j+32);
-       prt_binary(f3, 16, j+32);
+       prt("fe cnn t      stdrmsiiii d ab   ", 11, j+32);
+       prt("aa aoomywhs lleeieihgggg rtgl   ", 12, j+32);
+       prt("uu utmacaih eielgggonnnnaaere   ", 13, j+32);
+       prt("rr reanurdo vtieeehtrrrrcilas   ", 14, j+32);
+       prt("aa algarnew ienpsntsaefctnevs   ", 15, j+32);
+       prt_binary(flgs[2], 16, j+32);
+
+       prt("+------------FLAGS4------------+", 17, j+32);
+       prt("KILL....ESP.........            ", 18, j+32);
+       prt("aeud tghaud tgdhegnu            ", 19, j+32);
+       prt("nvneoriunneoriruvoon            ", 20, j+32);
+       prt("iidmroamidmroagmionq            ", 21, j+32);
+       prt("mlenclnmmenclnnnldlu            ", 22, j+32);
+       prt_binary(flgs[3], 23, j+32);
 }
 
 
@@ -625,6 +661,7 @@ static tval_desc tvals[] =
        { TV_ARCANE_BOOK,       "Arcane Spellbook"     },
        { TV_ENCHANT_BOOK,      "Craft Spellbook"},
        { TV_DAEMON_BOOK,       "Daemon Spellbook"},
+       { TV_CRUSADE_BOOK,         "Crusade Spellbook"},
        { TV_MUSIC_BOOK,        "Music Spellbook"      },
        { TV_HISSATSU_BOOK,     "Book of Kendo" },
        { TV_PARCHEMENT,        "Parchement" },
@@ -880,44 +917,45 @@ static void wiz_reroll_item(object_type *o_ptr)
                        case 'w': case 'W':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
+                               apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
                                break;
                        }
                        /* Apply bad magic, but first clear object */
                        case 'c': case 'C':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
+                               apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
                                break;
                        }
                        /* Apply normal magic, but first clear object */
                        case 'n': case 'N':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
+                               apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
                                break;
                        }
                        /* Apply good magic, but first clear object */
                        case 'g': case 'G':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
+                               apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD);
                                break;
                        }
                        /* Apply great magic, but first clear object */
                        case 'e': case 'E':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
+                               apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
                                break;
                        }
+                       /* Apply special magic, but first clear object */
                        case 's': case 'S':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
+                               apply_magic(q_ptr, dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
 
-                               /* Failed to create normal artifact; make a random one */
-                               if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
+                               /* Failed to create artifact; make a random one */
+                               if (!artifact_p(q_ptr) && !q_ptr->art_name) create_artifact(q_ptr, FALSE);
                                break;
                        }
                }
@@ -963,9 +1001,9 @@ static void wiz_statistics(object_type *o_ptr)
        u32b test_roll = 1000000;
 
        char ch;
-       char *quality;
+       cptr quality;
 
-       bool good, great;
+       u32b mode;
 
        object_type forge;
        object_type     *q_ptr;
@@ -993,26 +1031,21 @@ static void wiz_statistics(object_type *o_ptr)
 
                if (ch == 'n' || ch == 'N')
                {
-                       good = FALSE;
-                       great = FALSE;
+                       mode = 0L;
                        quality = "normal";
                }
                else if (ch == 'g' || ch == 'G')
                {
-                       good = TRUE;
-                       great = FALSE;
+                       mode = AM_GOOD;
                        quality = "good";
                }
                else if (ch == 'e' || ch == 'E')
                {
-                       good = TRUE;
-                       great = TRUE;
+                       mode = AM_GOOD | AM_GREAT;
                        quality = "excellent";
                }
                else
                {
-                       good = FALSE;
-                       great = FALSE;
                        break;
                }
 
@@ -1060,7 +1093,7 @@ static void wiz_statistics(object_type *o_ptr)
                        object_wipe(q_ptr);
 
                        /* Create an object */
-                       make_object(q_ptr, good, great);
+                       make_object(q_ptr, mode);
 
 
                        /* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
@@ -1151,13 +1184,41 @@ static void wiz_quantity_item(object_type *o_ptr)
 
                /* Accept modifications */
                o_ptr->number = tmp_int;
+       }
 
-               /* Hack -- rod pvals must change if the number in the stack does. -LM- */
-               if (o_ptr->tval == TV_ROD)
-                       o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
+       if (o_ptr->tval == TV_ROD)
+       {
+               o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
        }
 }
 
+/* debug command for blue mage */
+static void do_cmd_wiz_blue_mage(void)
+{
+
+       int                             i = 0;
+       int                             j = 0;
+       s32b            f4 = 0, f5 = 0, f6 = 0; 
+
+       for (j=1; j<6; j++)
+       {
+
+               set_rf_masks(&f4, &f5, &f6, j);
+
+               for (i = 0; i < 32; i++)
+               {
+                       if ((0x00000001 << i) & f4) p_ptr->magic_num2[i] = 1;
+               }
+               for (; i < 64; i++)
+               {
+                       if ((0x00000001 << (i - 32)) & f5) p_ptr->magic_num2[i] = 1;
+               }
+               for (; i < 96; i++)
+               {
+                       if ((0x00000001 << (i - 64)) & f6) p_ptr->magic_num2[i] = 1;
+               }
+       }
+}
 
 
 /*
@@ -1199,8 +1260,7 @@ static void do_cmd_wiz_play(void)
        {
                o_ptr = &o_list[0 - item];
        }
-
-
+       
        /* The item was not changed */
        changed = FALSE;
 
@@ -1267,9 +1327,17 @@ static void do_cmd_wiz_play(void)
                /* Message */
                msg_print("Changes accepted.");
 
+               /* Recalcurate object's weight */
+               if (item >= 0)
+               {
+                       p_ptr->total_weight += (q_ptr->weight * q_ptr->number)
+                               - (o_ptr->weight * o_ptr->number);
+               }
+
                /* Change */
                object_copy(o_ptr, q_ptr);
 
+
                /* Recalculate bonuses */
                p_ptr->update |= (PU_BONUS);
 
@@ -1318,13 +1386,7 @@ static void wiz_create_item(void)
        /* Return if failed */
        if (!k_idx) return;
 
-       /* Get local object */
-       q_ptr = &forge;
-
-       /* Create the item */
-       object_prep(q_ptr, k_idx);
-
-       if (k_info[k_idx].flags3 & TR3_INSTA_ART)
+       if (k_info[k_idx].gen_flags & TRG_INSTA_ART)
        {
                int i;
 
@@ -1332,25 +1394,30 @@ static void wiz_create_item(void)
                for (i = 1; i < max_a_idx; i++)
                {
                        /* Ignore incorrect tval */
-                       if (a_info[i].tval != q_ptr->tval) continue;
+                       if (a_info[i].tval != k_info[k_idx].tval) continue;
 
                        /* Ignore incorrect sval */
-                       if (a_info[i].sval != q_ptr->sval) continue;
+                       if (a_info[i].sval != k_info[k_idx].sval) continue;
 
-                       /* Choose this artifact */
-                       q_ptr->name1 = i;
-                       break;
-               }
+                       /* Create this artifact */
+                       create_named_art(i, py, px);
 
-               /* Apply magic */
-               apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
-       }
-       else
-       {
-               /* Apply magic */
-               apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
+                       /* All done */
+                       msg_print("Allocated(INSTA_ART).");
+
+                       return;
+               }
        }
 
+       /* Get local object */
+       q_ptr = &forge;
+
+       /* Create the item */
+       object_prep(q_ptr, k_idx);
+
+       /* Apply magic */
+       apply_magic(q_ptr, dun_level, AM_NO_FIXED_ART);
+
        /* Drop the object from heaven */
        (void)drop_near(q_ptr, -1, py, px);
 
@@ -1364,9 +1431,6 @@ static void wiz_create_item(void)
  */
 static void do_cmd_wiz_cure_all(void)
 {
-       /* Remove curses */
-       (void)remove_all_curse();
-
        /* Restore stats */
        (void)res_stat(A_STR);
        (void)res_stat(A_INT);
@@ -1419,6 +1483,7 @@ static void do_cmd_wiz_jump(void)
                char    ppp[80];
 
                char    tmp_val[160];
+               int             tmp_dungeon_type;
 
                /* Prompt */
                sprintf(ppp, "Jump which dungeon : ");
@@ -1429,11 +1494,11 @@ static void do_cmd_wiz_jump(void)
                /* Ask for a level */
                if (!get_string(ppp, tmp_val, 2)) return;
 
-               dungeon_type = atoi(tmp_val);
-               if (!d_info[dungeon_type].maxdepth || (dungeon_type > max_d_idx)) dungeon_type = DUNGEON_ANGBAND;
+               tmp_dungeon_type = atoi(tmp_val);
+               if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
 
                /* Prompt */
-               sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[dungeon_type].mindepth, d_info[dungeon_type].maxdepth);
+               sprintf(ppp, "Jump to level (0, %d-%d): ", d_info[tmp_dungeon_type].mindepth, d_info[tmp_dungeon_type].maxdepth);
 
                /* Default */
                sprintf(tmp_val, "%d", dun_level);
@@ -1443,6 +1508,8 @@ static void do_cmd_wiz_jump(void)
 
                /* Extract request */
                command_arg = atoi(tmp_val);
+
+               dungeon_type = tmp_dungeon_type;
        }
 
        /* Paranoia */
@@ -1459,20 +1526,13 @@ static void do_cmd_wiz_jump(void)
        /* Change level */
        dun_level = command_arg;
 
+       prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
+
        if (!dun_level) dungeon_type = 0;
        p_ptr->inside_arena = FALSE;
-       leaving_quest = p_ptr->inside_quest;
+       p_ptr->wild_mode = FALSE;
 
-       /* Leaving an 'only once' quest marks it as failed */
-       if (leaving_quest &&
-               (quest[leaving_quest].flags & QUEST_FLAG_ONCE) &&
-               (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-       {
-               quest[leaving_quest].status = QUEST_STATUS_FAILED;
-               quest[leaving_quest].complev = (byte)p_ptr->lev;
-               if (record_fix_quest)
-                       do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
-       }
+       leave_quest_check();
 
        if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
 
@@ -1480,6 +1540,9 @@ static void do_cmd_wiz_jump(void)
        p_ptr->leftbldg = FALSE;
        energy_use = 0;
 
+       /* Prevent energy_need from being too lower than 0 */
+       p_ptr->energy_need = 0;
+
        /* Leaving */
        p_ptr->leaving = TRUE;
 }
@@ -1525,7 +1588,7 @@ static void do_cmd_wiz_summon(int num)
 
        for (i = 0; i < num; i++)
        {
-               (void)summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, FALSE);
+               (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
        }
 }
 
@@ -1535,7 +1598,7 @@ static void do_cmd_wiz_summon(int num)
  *
  * XXX XXX XXX This function is rather dangerous
  */
-static void do_cmd_wiz_named(int r_idx, bool slp)
+static void do_cmd_wiz_named(int r_idx)
 {
        int i, x, y;
 
@@ -1557,7 +1620,7 @@ static void do_cmd_wiz_named(int r_idx, bool slp)
                if (!cave_empty_bold(y, x)) continue;
 
                /* Place it (allow groups) */
-               if (place_monster_aux(y, x, r_idx, slp, TRUE, FALSE, FALSE, FALSE, FALSE)) break;
+               if (place_monster_aux(0, y, x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP))) break;
        }
 }
 
@@ -1567,9 +1630,9 @@ static void do_cmd_wiz_named(int r_idx, bool slp)
  *
  * XXX XXX XXX This function is rather dangerous
  */
-static void do_cmd_wiz_named_friendly(int r_idx, bool slp)
+static void do_cmd_wiz_named_friendly(int r_idx)
 {
-       (void) summon_named_creature(py, px, r_idx, slp, TRUE, TRUE, TRUE);
+       (void) summon_named_creature(0, py, px, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
 }
 
 
@@ -1631,6 +1694,91 @@ static void do_cmd_wiz_zap_all(void)
 }
 
 
+#define NUM_O_SET 8
+#define NUM_O_BIT 32
+
+/*
+ * Hack -- Dump option bits usage
+ */
+static void do_cmd_dump_options(void)
+{
+       int  i, j;
+       FILE *fff;
+       char buf[1024];
+       int  **exist;
+
+       /* Build the filename */
+       path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
+
+       /* File type is "TEXT" */
+       FILE_TYPE(FILE_TYPE_TEXT);
+
+       /* Open the file */
+       fff = my_fopen(buf, "a");
+
+       /* Oops */
+       if (!fff)
+       {
+#ifdef JP
+               msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
+#else
+               msg_format("Failed to open file %s.", buf);
+#endif
+               msg_print(NULL);
+               return;
+       }
+
+       /* Allocate the "exist" array (2-dimension) */
+       C_MAKE(exist, NUM_O_SET, int *);
+       C_MAKE(*exist, NUM_O_BIT * NUM_O_SET, int);
+       for (i = 1; i < NUM_O_SET; i++) exist[i] = *exist + i * NUM_O_BIT;
+
+       /* Check for exist option bits */
+       for (i = 0; option_info[i].o_desc; i++)
+       {
+               option_type *ot_ptr = &option_info[i];
+               if (ot_ptr->o_var) exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1;
+       }
+
+       fprintf(fff, "[Option bits usage on Hengband %d.%d.%d]\n\n",
+               FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+
+       fputs("Set - Bit (Page) Option Name\n", fff);
+       fputs("------------------------------------------------\n", fff);
+       /* Dump option bits usage */
+       for (i = 0; i < NUM_O_SET; i++)
+       {
+               for (j = 0; j < NUM_O_BIT; j++)
+               {
+                       if (exist[i][j])
+                       {
+                               option_type *ot_ptr = &option_info[exist[i][j] - 1];
+                               fprintf(fff, "  %d -  %02d (%4d) %s\n",
+                                       i, j, ot_ptr->o_page, ot_ptr->o_text);
+                       }
+                       else
+                       {
+                               fprintf(fff, "  %d -  %02d\n", i, j);
+                       }
+               }
+               fputc('\n', fff);
+       }
+
+       /* Free the "exist" array (2-dimension) */
+       C_KILL(*exist, NUM_O_BIT * NUM_O_SET, int);
+       C_KILL(exist, NUM_O_SET, int *);
+
+       /* Close it */
+       my_fclose(fff);
+
+#ifdef JP
+       msg_format("¥ª¥×¥·¥ç¥óbit»ÈÍѾõ¶·¤ò¥Õ¥¡¥¤¥ë %s ¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£", buf);
+#else
+       msg_format("Option bits usage dump saved to file %s.", buf);
+#endif
+}
+
+
 #ifdef ALLOW_SPOILERS
 
 /*
@@ -1665,236 +1813,238 @@ void do_cmd_debug(void)
        /* Analyze the command */
        switch (cmd)
        {
-               /* Nothing */
-               case ESCAPE:
-               case ' ':
-               case '\n':
-               case '\r':
+       /* Nothing */
+       case ESCAPE:
+       case ' ':
+       case '\n':
+       case '\r':
                break;
 
-
 #ifdef ALLOW_SPOILERS
 
-               /* Hack -- Generate Spoilers */
-               case '"':
+       /* Hack -- Generate Spoilers */
+       case '"':
                do_cmd_spoilers();
                break;
 
 #endif /* ALLOW_SPOILERS */
 
-
-               /* Hack -- Help */
-               case '?':
+       /* Hack -- Help */
+       case '?':
                do_cmd_help();
                break;
 
-
-               /* Cure all maladies */
-               case 'a':
+       /* Cure all maladies */
+       case 'a':
                do_cmd_wiz_cure_all();
                break;
 
-               /* Know alignment */
-               case 'A':
+       /* Know alignment */
+       case 'A':
                msg_format("Your alignment is %d.", p_ptr->align);
                break;
 
-               /* Teleport to target */
-               case 'b':
+       /* Teleport to target */
+       case 'b':
                do_cmd_wiz_bamf();
                break;
 
-               case 'B':
+       case 'B':
                battle_monsters();
                break;
 
-               /* Create any object */
-               case 'c':
+       /* Create any object */
+       case 'c':
                wiz_create_item();
                break;
 
-               /* Create a named artifact */
-               case 'C':
+       /* Create a named artifact */
+       case 'C':
                wiz_create_named_art(command_arg);
                break;
 
-               /* Detect everything */
-               case 'd':
+       /* Detect everything */
+       case 'd':
                detect_all(DETECT_RAD_ALL*3);
                break;
 
-               /* Dimension_door */
-               case 'D':
+       /* Dimension_door */
+       case 'D':
                wiz_dimension_door();
                break;
 
-               /* Edit character */
-               case 'e':
+       /* Edit character */
+       case 'e':
                do_cmd_wiz_change();
                break;
 
-               /* View item info */
-               case 'f':
+       /* Blue Mage Only */
+       case 'E':
+               if (p_ptr->pclass == CLASS_BLUE_MAGE)
+               {
+                       do_cmd_wiz_blue_mage();
+               }
+               break;
+
+       /* View item info */
+       case 'f':
                identify_fully(FALSE);
                break;
 
-               /* Good Objects */
-               case 'g':
+       /* Good Objects */
+       case 'g':
                if (command_arg <= 0) command_arg = 1;
                acquirement(py, px, command_arg, FALSE, TRUE);
                break;
 
-               /* Hitpoint rerating */
-               case 'h':
-               do_cmd_rerate(TRUE); break;
+       /* Hitpoint rerating */
+       case 'h':
+               do_cmd_rerate(TRUE);
+               break;
 
 #ifdef MONSTER_HORDES
-               case 'H':
-               do_cmd_summon_horde(); break;
+       case 'H':
+               do_cmd_summon_horde();
+               break;
 #endif /* MONSTER_HORDES */
 
-               /* Identify */
-               case 'i':
+       /* Identify */
+       case 'i':
                (void)ident_spell(FALSE);
                break;
 
-               /* Go up or down in the dungeon */
-               case 'j':
+       /* Go up or down in the dungeon */
+       case 'j':
                do_cmd_wiz_jump();
                break;
 
-               /* Self-Knowledge */
-               case 'k':
-                       self_knowledge();
-                       break;
+       /* Self-Knowledge */
+       case 'k':
+               self_knowledge();
+               break;
 
-               /* Learn about objects */
-               case 'l':
-                       do_cmd_wiz_learn();
-                       break;
+       /* Learn about objects */
+       case 'l':
+               do_cmd_wiz_learn();
+               break;
 
-               /* Magic Mapping */
-               case 'm':
-                       map_area(DETECT_RAD_ALL);
-                       break;
+       /* Magic Mapping */
+       case 'm':
+               map_area(DETECT_RAD_ALL);
+               break;
 
-               /* Mutation */
-               case 'M':
-                       (void)gain_random_mutation(command_arg);
-                       break;
+       /* Mutation */
+       case 'M':
+               (void)gain_random_mutation(command_arg);
+               break;
 
-               /* Specific reward */
-               case 'r':
-                       (void)gain_level_reward(command_arg);
-                       break;
+       /* Specific reward */
+       case 'r':
+               (void)gain_level_reward(command_arg);
+               break;
 
-               /* Summon _friendly_ named monster */
-               case 'N':
-                       do_cmd_wiz_named_friendly(command_arg, TRUE);
-                       break;
+       /* Summon _friendly_ named monster */
+       case 'N':
+               do_cmd_wiz_named_friendly(command_arg);
+               break;
 
-               /* Summon Named Monster */
-               case 'n':
-                       do_cmd_wiz_named(command_arg, TRUE);
-                       break;
+       /* Summon Named Monster */
+       case 'n':
+               do_cmd_wiz_named(command_arg);
+               break;
 
-               /* Object playing routines */
-               case 'o':
-                       do_cmd_wiz_play();
-                       break;
+       /* Dump option bits usage */
+       case 'O':
+               do_cmd_dump_options();
+               break;
 
-               /* Phase Door */
-               case 'p':
-                       teleport_player(10);
-                       break;
+       /* Object playing routines */
+       case 'o':
+               do_cmd_wiz_play();
+               break;
+
+       /* Phase Door */
+       case 'p':
+               teleport_player(10);
+               break;
 
 #if 0
-               /* Complete a Quest -KMW- */
-               case 'q':
+       /* Complete a Quest -KMW- */
+       case 'q':
+               for (i = 0; i < max_quests; i++)
                {
-                       for (i = 0; i < max_quests; i++)
-                       {
-                               if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
-                               {
-                                       p_ptr->quest[i].status++;
-                                       msg_print("Completed Quest");
-                                       msg_print(NULL);
-                                       break;
-                               }
-                       }
-                       if (i == max_quests)
+                       if (p_ptr->quest[i].status == QUEST_STATUS_TAKEN)
                        {
-                               msg_print("No current quest");
+                               p_ptr->quest[i].status++;
+                               msg_print("Completed Quest");
                                msg_print(NULL);
+                               break;
                        }
-                       break;
                }
+               if (i == max_quests)
+               {
+                       msg_print("No current quest");
+                       msg_print(NULL);
+               }
+               break;
 #endif
 
-               /* Make every dungeon square "known" to test streamers -KMW- */
-               case 'u':
+       /* Make every dungeon square "known" to test streamers -KMW- */
+       case 'u':
+               for (y = 0; y < cur_hgt; y++)
                {
-                       for(y = 0; y < cur_hgt; y++)
+                       for (x = 0; x < cur_wid; x++)
                        {
-                               for(x = 0; x < cur_wid; x++)
-                               {
-                                       cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
-                               }
+                               cave[y][x].info |= (CAVE_GLOW | CAVE_MARK);
                        }
-                       wiz_lite(TRUE, FALSE);
-                       break;
                }
+               wiz_lite(FALSE);
+               break;
 
-               /* Summon Random Monster(s) */
-               case 's':
-                       if (command_arg <= 0) command_arg = 1;
-                       do_cmd_wiz_summon(command_arg);
-                       break;
+       /* Summon Random Monster(s) */
+       case 's':
+               if (command_arg <= 0) command_arg = 1;
+               do_cmd_wiz_summon(command_arg);
+               break;
 
-               /* Teleport */
-               case 't':
-                       teleport_player(100);
-                       break;
+       /* Teleport */
+       case 't':
+               teleport_player(100);
+               break;
 
-               /* Very Good Objects */
-               case 'v':
-                       if (command_arg <= 0) command_arg = 1;
-                       acquirement(py, px, command_arg, TRUE, TRUE);
-                       break;
+       /* Very Good Objects */
+       case 'v':
+               if (command_arg <= 0) command_arg = 1;
+               acquirement(py, px, command_arg, TRUE, TRUE);
+               break;
 
-               /* Wizard Light the Level */
-               case 'w':
-               wiz_lite(TRUE, (bool)(p_ptr->pclass == CLASS_NINJA));
+       /* Wizard Light the Level */
+       case 'w':
+               wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
                break;
 
-               /* Increase Experience */
-               case 'x':
-               if (command_arg)
-               {
-                       gain_exp(command_arg);
-               }
-               else
-               {
-                       gain_exp(p_ptr->exp + 1);
-               }
+       /* Increase Experience */
+       case 'x':
+               gain_exp(command_arg ? command_arg : (p_ptr->exp + 1));
                break;
 
-               /* Zap Monsters (Genocide) */
-               case 'z':
+       /* Zap Monsters (Genocide) */
+       case 'z':
                do_cmd_wiz_zap();
                break;
 
-               case 'Z':
+       /* Zap Monsters (Omnicide) */
+       case 'Z':
                do_cmd_wiz_zap_all();
                break;
 
-               /* Hack -- whatever I desire */
-               case '_':
+       /* Hack -- whatever I desire */
+       case '_':
                do_cmd_wiz_hack_ben();
                break;
 
-               /* Not a Wizard Command */
-               default:
+       /* Not a Wizard Command */
+       default:
                msg_print("That is not a valid debug command.");
                break;
        }