1 #include "info-reader/race-reader.h"
2 #include "info-reader/race-info-tokens-table.h"
3 #include "main/angband-headers.h"
4 #include "monster-race/monster-race.h"
5 #include "term/gameterm.h"
6 #include "util/string-processor.h"
7 #include "view/display-messages.h"
10 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用1) /
11 * Grab one (basic) flag in a monster_race from a textual string
12 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
13 * @param what 参照元の文字列ポインタ
16 static errr grab_one_basic_flag(monster_race *r_ptr, concptr what)
18 if (grab_one_flag(&r_ptr->flags1, r_info_flags1, what) == 0)
21 if (grab_one_flag(&r_ptr->flags2, r_info_flags2, what) == 0)
24 if (grab_one_flag(&r_ptr->flags3, r_info_flags3, what) == 0)
27 if (grab_one_flag(&r_ptr->flags7, r_info_flags7, what) == 0)
30 if (grab_one_flag(&r_ptr->flags8, r_info_flags8, what) == 0)
33 if (grab_one_flag(&r_ptr->flags9, r_info_flags9, what) == 0)
36 if (grab_one_flag(&r_ptr->flagsr, r_info_flagsr, what) == 0)
39 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
44 * @brief テキストトークンを走査してフラグを一つ得る(モンスター用2) /
45 * Grab one (spell) flag in a monster_race from a textual string
46 * @param r_ptr 保管先のモンスター種族構造体参照ポインタ
47 * @param what 参照元の文字列ポインタ
50 static errr grab_one_spell_flag(monster_race *r_ptr, concptr what)
52 if (grab_one_flag(&r_ptr->flags4, r_info_flags4, what) == 0)
55 if (grab_one_flag(&r_ptr->a_ability_flags1, r_a_ability_flags1, what) == 0)
58 if (grab_one_flag(&r_ptr->a_ability_flags2, r_a_ability_flags2, what) == 0)
61 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
66 * @brief モンスター種族情報(r_info)のパース関数 /
67 * Initialize the "r_info" array, by parsing an ascii "template" file
72 errr parse_r_info(char *buf, angband_header *head)
74 static monster_race *r_ptr = NULL;
77 s = angband_strchr(buf + 2, ':');
87 int i = atoi(buf + 2);
90 if (i >= head->info_num)
96 if (!add_name(&r_ptr->name, head, s))
105 else if (buf[0] == 'E') {
107 if (!add_name(&r_ptr->E_name, head, s))
111 else if (buf[0] == 'E') {
113 if (!add_name(&r_ptr->name, head, s))
117 else if (buf[0] == 'D') {
127 if (!add_text(&r_ptr->text, head, s, TRUE))
129 } else if (buf[0] == 'G') {
140 byte tmp = color_char_to_attr(buf[4]);
146 } else if (buf[0] == 'I') {
147 int spd, hp1, hp2, aaf, ac, slp;
149 if (6 != sscanf(buf + 2, "%d:%dd%d:%d:%d:%d", &spd, &hp1, &hp2, &aaf, &ac, &slp))
152 r_ptr->speed = (SPEED)spd;
153 r_ptr->hdice = (DICE_NUMBER)MAX(hp1, 1);
154 r_ptr->hside = (DICE_SID)MAX(hp2, 1);
155 r_ptr->aaf = (POSITION)aaf;
156 r_ptr->ac = (ARMOUR_CLASS)ac;
157 r_ptr->sleep = (SLEEP_DEGREE)slp;
158 } else if (buf[0] == 'W') {
163 if (6 != sscanf(buf + 2, "%d:%d:%d:%ld:%ld:%d", &lev, &rar, &pad, &exp, &nextexp, &nextmon))
166 r_ptr->level = (DEPTH)lev;
167 r_ptr->rarity = (RARITY)rar;
168 r_ptr->extra = (BIT_FLAGS16)pad;
169 r_ptr->mexp = (EXP)exp;
170 r_ptr->next_exp = (EXP)nextexp;
171 r_ptr->next_r_idx = (MONRACE_IDX)nextmon;
172 } else if (buf[0] == 'R') {
175 for (; i < A_MAX; i++)
176 if (r_ptr->reinforce_id[i] == 0)
182 if (3 != sscanf(buf + 2, "%d:%dd%d", &id, &dd, &ds))
184 r_ptr->reinforce_id[i] = (MONRACE_IDX)id;
185 r_ptr->reinforce_dd[i] = (DICE_NUMBER)dd;
186 r_ptr->reinforce_ds[i] = (DICE_SID)ds;
187 } else if (buf[0] == 'B') {
190 for (i = 0; i < 4; i++)
191 if (!r_ptr->blow[i].method)
198 for (s = t = buf + 2; *t && (*t != ':'); t++)
204 for (n1 = 0; r_info_blow_method[n1]; n1++) {
205 if (streq(s, r_info_blow_method[n1]))
209 if (!r_info_blow_method[n1])
213 for (s = t; *t && (*t != ':'); t++)
219 for (n2 = 0; r_info_blow_effect[n2]; n2++) {
220 if (streq(s, r_info_blow_effect[n2]))
224 if (!r_info_blow_effect[n2])
228 for (s = t; *t && (*t != 'd'); t++)
234 r_ptr->blow[i].method = (rbm_type)n1;
235 r_ptr->blow[i].effect = (rbe_type)n2;
236 r_ptr->blow[i].d_dice = atoi(s);
237 r_ptr->blow[i].d_side = atoi(t);
238 } else if (buf[0] == 'F') {
239 for (s = buf + 2; *s;) {
241 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
246 while (*t == ' ' || *t == '|')
250 if (0 != grab_one_basic_flag(r_ptr, s))
255 } else if (buf[0] == 'S') {
256 for (s = buf + 2; *s;) {
259 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
264 while ((*t == ' ') || (*t == '|'))
269 if (1 == sscanf(s, "1_IN_%d", &i)) {
270 r_ptr->freq_spell = 100 / i;
275 if (0 != grab_one_spell_flag(r_ptr, s))
280 } else if (buf[0] == 'A') {
283 for (i = 0; i < 4; i++)
284 if (!r_ptr->artifact_id[i])
290 if (3 != sscanf(buf + 2, "%d:%d:%d", &id, &rarity, &per))
292 r_ptr->artifact_id[i] = (ARTIFACT_IDX)id;
293 r_ptr->artifact_rarity[i] = (RARITY)rarity;
294 r_ptr->artifact_percent[i] = (PERCENTAGE)per;
295 } else if (buf[0] == 'V') {
297 if (3 != sscanf(buf + 2, "%d", &val))
299 r_ptr->arena_ratio = (PERCENTAGE)val;