OSDN Git Service

Integrate initial flag, level and value settings of activations for random artifacts...
[hengband/hengband.git] / src / init1.c
index d8d3a09..ba9accb 100644 (file)
@@ -123,6 +123,8 @@ static cptr r_info_blow_effect[] =
        "EXP_VAMP",
        "DR_MANA",
        "SUPERHURT",
+       "INERTIA",
+       "STUN",
        NULL
 };
 
@@ -247,6 +249,7 @@ static cptr f_info_flags[] =
        "UNPERM",
        "TELEPORTABLE",
        "CONVERT",
+       "GLASS",
 };
 
 
@@ -792,7 +795,7 @@ static cptr k_info_gen_flags[] =
        "RANDOM_CURSE0",
        "RANDOM_CURSE1",
        "RANDOM_CURSE2",
-       "XXX",
+       "XTRA_DICE",
        "XXX",
        "XXX",
        "XXX",
@@ -810,7 +813,6 @@ static cptr k_info_gen_flags[] =
        "XXX",
 };
 
-
 /*
  * Dungeon flags
  */
@@ -824,8 +826,8 @@ static cptr d_info_flags1[] =
        "NO_DOORS",
        "WATER_RIVER",
        "LAVA_RIVER",
-       "XXX",
-       "XXX",
+       "CURTAIN",
+       "GLASS_DOOR",
        "CAVE",
        "CAVERN",
        "XXX",
@@ -840,7 +842,7 @@ static cptr d_info_flags1[] =
        "NO_VAULT",
        "ARENA",
        "DESTROY",
-       "XXX",
+       "GLASS_ROOM",
        "NO_CAVE",
        "NO_MAGIC",
        "NO_MELEE",
@@ -857,7 +859,7 @@ static cptr d_info_flags1[] =
  * Returns FALSE when there isn't enough space available to store
  * the text.
  */
-static bool add_text(u32b *offset, header *head, cptr buf)
+static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
 {
        /* Hack -- Verify space */
        if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
@@ -867,11 +869,11 @@ static bool add_text(u32b *offset, header *head, cptr buf)
        if (*offset == 0)
        {
                /* Advance and save the text index */
-               *offset = ++head->text_size;    
+               *offset = ++head->text_size;
        }
 
        /* Additional text */
-       else
+       else if (normal_text)
        {
                /*
                 * If neither the end of the last line nor
@@ -1033,7 +1035,7 @@ errr init_info_txt(FILE *fp, char *buf, header *head,
        /* Prepare the "fake" stuff */
        head->name_size = 0;
        head->text_size = 0;
-       head->tag_size = 1;
+       head->tag_size = 0;
 
        /* Parse */
        while (0 == my_fgets(fp, buf, 1024))
@@ -1136,7 +1138,7 @@ errr parse_v_info(char *buf, header *head)
                s = buf+2;
 
                /* Store the text */
-               if (!add_text(&v_ptr->text, head, s)) return (7);
+               if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
        }
 
        /* Process 'X' for "Extra info" (one line only) */
@@ -1642,6 +1644,19 @@ errr parse_f_info(char *buf, header *head)
                                while (*t == ' ' || *t == '|') t++;
                        }
 
+                       /* XXX XXX XXX Hack -- Read feature subtype */
+                       if (1 == sscanf(s, "SUBTYPE_%d", &i))
+                       {
+                               /* Extract a "subtype" */
+                               f_ptr->subtype =  i;
+
+                               /* Start at next entry */
+                               s = t;
+
+                               /* Continue */
+                               continue;
+                       }
+
                        /* XXX XXX XXX Hack -- Read feature power */
                        if (1 == sscanf(s, "POWER_%d", &i))
                        {
@@ -1949,7 +1964,7 @@ errr parse_k_info(char *buf, header *head)
 #endif
 
                /* Store the text */
-               if (!add_text(&k_ptr->text, head, s)) return (7);
+               if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
        }
 
        /* Process 'G' for "Graphics" (one line only) */
@@ -2122,7 +2137,39 @@ static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
        return (1);
 }
 
+/*
+ * Grab one activation index flag
+ */
+static byte grab_one_activation_flag(cptr what)
+{
+       int i;
+
+       for (i = 0; ; i++)
+       {
+               if (activation_info[i].flag == NULL) break;
+
+               if (streq(what, activation_info[i].flag))
+               {
+                       return activation_info[i].index;
+               }
+       }
 
+       i = atoi(what);
+        if (i > 0)
+        {
+                return ((byte) i);
+        }
+
+       /* Oops */
+#ifdef JP
+       msg_format("̤ÃΤÎȯư¡¦¥Õ¥é¥° '%s'¡£", what);
+#else
+       msg_format("Unknown activation flag '%s'.", what);
+#endif
+
+       /* Error */
+       return (0);
+}
 
 
 /*
@@ -2217,7 +2264,7 @@ errr parse_a_info(char *buf, header *head)
 #endif
 
                /* Store the text */
-               if (!add_text(&a_ptr->text, head, s)) return (7);
+               if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
        }
 
 
@@ -2270,6 +2317,21 @@ errr parse_a_info(char *buf, header *head)
                a_ptr->to_a =  ta;
        }
 
+       /* Hack -- Process 'U' for activation index */
+       else if (buf[0] == 'U')
+       {
+               byte n;
+               n = grab_one_activation_flag(buf + 2);
+               if (n > 0)
+               {
+                       a_ptr->act_idx = n;
+               }
+               else
+               {
+                       return (5);
+               }
+       }
+
        /* Hack -- Process 'F' for flags */
        else if (buf[0] == 'F')
        {
@@ -2424,7 +2486,7 @@ errr parse_e_info(char *buf, header *head)
                s = buf+2;
 
                /* Store the text */
-               if (!add_text(&e_ptr->text, head, s)) return (7);
+               if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
        }
 
 #endif
@@ -2664,7 +2726,7 @@ errr parse_r_info(char *buf, header *head)
 #endif
 
                /* Store the text */
-               if (!add_text(&r_ptr->text, head, s)) return (7);
+               if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
        }
 
        /* Process 'G' for "Graphics" (one line only) */
@@ -2704,8 +2766,8 @@ errr parse_r_info(char *buf, header *head)
 
                /* Save the values */
                r_ptr->speed = spd;
-               r_ptr->hdice = hp1;
-               r_ptr->hside = hp2;
+               r_ptr->hdice = MAX(hp1, 1);
+               r_ptr->hside = MAX(hp2, 1);
                r_ptr->aaf = aaf;
                r_ptr->ac = ac;
                r_ptr->sleep = slp;
@@ -3018,7 +3080,7 @@ errr parse_d_info(char *buf, header *head)
 #endif
 
                /* Store the text */
-               if (!add_text(&d_ptr->text, head, s)) return (7);
+               if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
        }
 
        /* Process 'W' for "More Info" (one line only) */
@@ -3325,12 +3387,12 @@ static errr parse_line_feature(char *buf)
                int index = zz[0][0];
 
                /* Reset the info for the letter */
-               letter[index].feature = FEAT_NONE;
+               letter[index].feature = feat_none;
                letter[index].monster = 0;
                letter[index].object = 0;
                letter[index].ego = 0;
                letter[index].artifact = 0;
-               letter[index].trap = FEAT_NONE;
+               letter[index].trap = feat_none;
                letter[index].cave_info = 0;
                letter[index].special = 0;
                letter[index].random = RANDOM_NONE;
@@ -3360,6 +3422,13 @@ static errr parse_line_feature(char *buf)
                                        letter[index].random |= RANDOM_ARTIFACT;
                                        if (zz[6][1]) letter[index].artifact = atoi(zz[6] + 1);
                                }
+                               else if (zz[6][0] == '!')
+                               {
+                                       if (p_ptr->inside_quest)
+                                       {
+                                               letter[index].artifact = quest[p_ptr->inside_quest].k_idx;
+                                       }
+                               }
                                else
                                {
                                        letter[index].artifact = atoi(zz[6]);
@@ -3384,6 +3453,21 @@ static errr parse_line_feature(char *buf)
                                        letter[index].random |= RANDOM_OBJECT;
                                        if (zz[4][1]) letter[index].object = atoi(zz[4] + 1);
                                }
+                               else if (zz[4][0] == '!')
+                               {
+                                       if (p_ptr->inside_quest)
+                                       {
+                                               int a_idx = quest[p_ptr->inside_quest].k_idx;
+                                               if (a_idx)
+                                               {
+                                                       artifact_type *a_ptr = &a_info[a_idx];
+                                                       if (!(a_ptr->gen_flags & TRG_INSTA_ART))
+                                                       {
+                                                               letter[index].object = lookup_kind(a_ptr->tval, a_ptr->sval);
+                                                       }
+                                               }
+                                       }
+                               }
                                else
                                {
                                        letter[index].object = atoi(zz[4]);
@@ -3822,9 +3906,8 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                else
                                {
                                        /* Create the artifact */
-                                       create_named_art(artifact_index, *y, *x);
-
-                                       a_info[artifact_index].cur_num = 1;
+                                       if (create_named_art(artifact_index, *y, *x))
+                                               a_info[artifact_index].cur_num = 1;
                                }
                        }
 
@@ -3890,10 +3973,42 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        return (0);
                }
 
+               else if (zz[1][0] == 'R')
+               {
+                       if (init_flags & INIT_ASSIGN)
+                       {
+                               int idx, count = 0;
+                               int reward_idx = 0;
+
+                               for (idx = 2; idx < num; idx++)
+                               {
+                                       int a_idx = atoi(zz[idx]);
+                                       if (a_idx < 1) continue;
+                                       if (a_info[a_idx].cur_num > 0) continue;
+                                       count++;
+                                       if (one_in_(count)) reward_idx = a_idx;
+                               }
+
+                               if (reward_idx)
+                               {
+                                       /* Set quest's rewarding artifact */
+                                       q_ptr->k_idx = reward_idx;
+                                       a_info[reward_idx].gen_flags |= TRG_QUESTITEM;
+                               }
+                               else
+                               {
+                                       /* Change a quest type to KILL_ALL when all artifact of reward list are got */
+                                       q_ptr->type = QUEST_TYPE_KILL_ALL;
+                               }
+                       }
+
+                       return (0);
+               }
+
                /* Process "Q:<q_index>:N:<name>" -- quest name */
                else if (zz[1][0] == 'N')
                {
-                       if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT))
+                       if (init_flags & (INIT_ASSIGN | INIT_SHOW_TEXT | INIT_NAME_ONLY))
                        {
                                strcpy(q_ptr->name, zz[2]);
                        }
@@ -4217,7 +4332,15 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
        else
        {
                /* Accept all printables except spaces and brackets */
+#ifdef JP
+               while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
+               {
+                       if (iskanji(*s)) s++;
+                       s++;
+               }
+#else
                while (isprint(*s) && !my_strchr(" []", *s)) ++s;
+#endif
 
                /* Extract final and Terminate */
                if ((f = *s) != '\0') *s++ = '\0';
@@ -4288,7 +4411,22 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        /* Player name */
                        else if (streq(b+1, "PLAYER"))
                        {
-                               v = player_base;
+                               static char tmp_player_name[32];
+                               char *pn, *tpn;
+                               for (pn = player_name, tpn = tmp_player_name; *pn; pn++, tpn++)
+                               {
+#ifdef JP
+                                       if (iskanji(*pn))
+                                       {
+                                               *(tpn++) = *(pn++);
+                                               *tpn = *pn;
+                                               continue;
+                                       }
+#endif
+                                       *tpn = my_strchr(" []", *pn) ? '_' : *pn;
+                               }
+                               *tpn = '\0';
+                               v = tmp_player_name;
                        }
 
                        /* Town */
@@ -4319,6 +4457,14 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                                v = tmp;
                        }
 
+                       /* Quest type */
+                       else if (prefix(b+1, "QUEST_TYPE"))
+                       {
+                               /* "QUEST_TYPE" uses a special parameter to determine the type of the quest */
+                               sprintf(tmp, "%d", quest[atoi(b+11)].type);
+                               v = tmp;
+                       }
+
                        /* Quest status */
                        else if (prefix(b+1, "QUEST"))
                        {