X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fmonster2.c;h=db89286e723b645510d1534f3b55eb1ce601659b;hb=7de4d6dfb51f88bb16a02b538ab727fc1a6b9858;hp=5cdcc405084a8eea5089c67d4449797aeaeea568;hpb=39df08379bbffb2da8bf514e2712728d1704be5f;p=hengband%2Fhengband.git diff --git a/src/monster2.c b/src/monster2.c index 5cdcc4050..db89286e7 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -11,11 +11,19 @@ */ #include "angband.h" +#include "cmd-pet.h" +#include "monsterrace-hook.h" +#include "monster-status.h" -#define HORDE_NOGOOD 0x01 -#define HORDE_NOEVIL 0x02 +#define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */ +#define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */ -cptr horror_desc[MAX_SAN_HORROR] = + +/*! + * @var horror_desc + * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時) + */ +concptr horror_desc[MAX_SAN_HORROR] = { #ifdef JP "忌まわしい", @@ -69,7 +77,11 @@ cptr horror_desc[MAX_SAN_HORROR] = }; -cptr funny_desc[MAX_SAN_FUNNY] = +/*! + * @var funny_desc + * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時) + */ +concptr funny_desc[MAX_SAN_FUNNY] = { #ifdef JP "間抜けな", @@ -129,7 +141,11 @@ cptr funny_desc[MAX_SAN_FUNNY] = }; -cptr funny_comments[MAX_SAN_COMMENT] = +/*! + * @var funny_comments + * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現 + */ +concptr funny_comments[MAX_SAN_COMMENT] = { #ifdef JP /* nuke me */ @@ -156,7 +172,7 @@ cptr funny_comments[MAX_SAN_COMMENT] = * @param x 目標x座標 * @return なし */ -void set_target(monster_type *m_ptr, int y, int x) +void set_target(monster_type *m_ptr, POSITION y, POSITION x) { m_ptr->target_y = y; m_ptr->target_x = x; @@ -181,19 +197,24 @@ void reset_target(monster_type *m_ptr) */ monster_race *real_r_ptr(monster_type *m_ptr) { + return &r_info[real_r_idx(m_ptr)]; +} + +MONRACE_IDX real_r_idx(monster_type *m_ptr) +{ monster_race *r_ptr = &r_info[m_ptr->r_idx]; /* Extract real race */ if (m_ptr->mflag2 & MFLAG2_CHAMELEON) { if (r_ptr->flags1 & RF1_UNIQUE) - return &r_info[MON_CHAMELEON_K]; + return MON_CHAMELEON_K; else - return &r_info[MON_CHAMELEON]; + return MON_CHAMELEON; } else { - return r_ptr; + return m_ptr->r_idx; } } @@ -206,22 +227,16 @@ monster_race *real_r_ptr(monster_type *m_ptr) * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 / * When a monster is deleted, all of its objects are deleted. */ -void delete_monster_idx(int i) +void delete_monster_idx(MONSTER_IDX i) { - int x, y; - + POSITION x, y; monster_type *m_ptr = &m_list[i]; - monster_race *r_ptr = &r_info[m_ptr->r_idx]; + OBJECT_IDX this_o_idx, next_o_idx = 0; - s16b this_o_idx, next_o_idx = 0; - - - /* Get location */ y = m_ptr->fy; x = m_ptr->fx; - /* Hack -- Reduce the racial counter */ real_r_ptr(m_ptr)->cur_num--; @@ -236,7 +251,6 @@ void delete_monster_idx(int i) if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0); if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE); - /* Hack -- remove target monster */ if (i == target_who) target_who = 0; @@ -255,8 +269,6 @@ void delete_monster_idx(int i) for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - - /* Acquire object */ o_ptr = &o_list[this_o_idx]; /* Acquire next object */ @@ -267,7 +279,6 @@ void delete_monster_idx(int i) * to prevent calling lite_spot() */ - /* Delete the object */ delete_object_idx(this_o_idx); } @@ -296,7 +307,7 @@ void delete_monster_idx(int i) * @param y 削除位置y座標 * @return なし */ -void delete_monster(int y, int x) +void delete_monster(POSITION y, POSITION x) { cave_type *c_ptr; @@ -317,25 +328,20 @@ void delete_monster(int y, int x) * @param i2 配列移動先添字 * @return なし */ -static void compact_monsters_aux(int i1, int i2) +static void compact_monsters_aux(IDX i1, IDX i2) { - int y, x, i; - + POSITION y, x; + int i; cave_type *c_ptr; - monster_type *m_ptr; - - s16b this_o_idx, next_o_idx = 0; - + OBJECT_IDX this_o_idx, next_o_idx = 0; /* Do nothing */ if (i1 == i2) return; - /* Old monster */ m_ptr = &m_list[i1]; - /* Location */ y = m_ptr->fy; x = m_ptr->fx; @@ -349,8 +355,6 @@ static void compact_monsters_aux(int i1, int i2) for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - - /* Acquire object */ o_ptr = &o_list[this_o_idx]; /* Acquire next object */ @@ -415,8 +419,9 @@ static void compact_monsters_aux(int i1, int i2) */ void compact_monsters(int size) { - int i, num, cnt; - int cur_lev, cur_dis, chance; + MONSTER_IDX i; + int num, cnt; + int cur_lev, cur_dis, chance; /* Message (only if compacting) */ if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters...")); @@ -463,13 +468,11 @@ void compact_monsters(int size) if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) { - char m_name[80]; - + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE); do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name); } - /* Delete the monster */ delete_monster_idx(i); /* Count the monster */ @@ -579,10 +582,9 @@ void wipe_m_list(void) * @details * This routine should almost never fail, but it *can* happen. */ -s16b m_pop(void) +MONSTER_IDX m_pop(void) { - int i; - + MONSTER_IDX i; /* Normal allocation */ if (m_max < max_m_idx) @@ -600,7 +602,6 @@ s16b m_pop(void) return (i); } - /* Recycle dead monsters */ for (i = 1; i < m_max; i++) { @@ -619,7 +620,6 @@ s16b m_pop(void) return (i); } - /* Warn the player (except during dungeon creation) */ if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!")); @@ -630,27 +630,34 @@ s16b m_pop(void) -/* - * Hack -- the "type" of the current "summon specific" +/*! + * @var summon_specific_type + * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific" + * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う */ static int summon_specific_type = 0; -/* - * Hack -- the index of the summoning monster +/*! + * @var summon_specific_who + * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster + * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う */ static int summon_specific_who = -1; - +/*! + * @var summon_unique_okay + * @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable + * @todo summon_unique_okay グローバル変数の除去と関数引数への代替を行う + */ static bool summon_unique_okay = FALSE; - /*! * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す * @return 召喚条件が一致するならtrue * @details */ -static bool summon_specific_aux(int r_idx) +static bool summon_specific_aux(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[r_idx]; int okay = FALSE; @@ -741,35 +748,29 @@ static bool summon_specific_aux(int r_idx) break; } - case SUMMON_BIZARRE1: + case SUMMON_MOLD: { okay = (r_ptr->d_char == 'm'); break; } - case SUMMON_BIZARRE2: + case SUMMON_BAT: { okay = (r_ptr->d_char == 'b'); break; } - case SUMMON_BIZARRE3: + case SUMMON_QUYLTHULG: { okay = (r_ptr->d_char == 'Q'); break; } - case SUMMON_BIZARRE4: - { - okay = (r_ptr->d_char == 'v'); - break; - } - - case SUMMON_BIZARRE5: + case SUMMON_COIN_MIMIC: { okay = (r_ptr->d_char == '$'); break; } - case SUMMON_BIZARRE6: + case SUMMON_MIMIC: { okay = ((r_ptr->d_char == '!') || (r_ptr->d_char == '?') || @@ -792,7 +793,6 @@ static bool summon_specific_aux(int r_idx) break; } - case SUMMON_KIN: { okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE)); @@ -820,19 +820,19 @@ static bool summon_specific_aux(int r_idx) !(r_ptr->flags3 & (RF3_UNDEAD)) && !(r_ptr->flags3 & (RF3_DEMON)) && !(r_ptr->flags2 & (RF2_MULTIPLY)) && - !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6)); + !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2)); break; } case SUMMON_HI_DRAGON_LIVING: { - okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr)); + okay = ((r_ptr->d_char == 'D') && monster_living(r_idx)); break; } case SUMMON_LIVING: { - okay = monster_living(r_ptr); + okay = monster_living(r_idx); break; } @@ -886,7 +886,7 @@ static bool summon_specific_aux(int r_idx) for (i = 0; i < 4; i++) if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE; - okay = (okay && monster_living(r_ptr)); + okay = (okay && monster_living(r_idx)); break; } @@ -946,13 +946,15 @@ static bool summon_specific_aux(int r_idx) break; } } - - /* Result */ /* Since okay is int, "return (okay);" is not correct. */ return (bool)(okay ? TRUE : FALSE); } - +/*! + * @var chameleon_change_m_idx + * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数 + * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること + */ static int chameleon_change_m_idx = 0; @@ -961,7 +963,7 @@ static int chameleon_change_m_idx = 0; * @param r_idx チェックするモンスター種族ID * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise */ -static bool restrict_monster_to_dungeon(int r_idx) +static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx) { dungeon_info_type *d_ptr = &d_info[dungeon_type]; monster_race *r_ptr = &r_info[r_idx]; @@ -976,16 +978,16 @@ static bool restrict_monster_to_dungeon(int r_idx) if (r_idx != MON_CHAMELEON && r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && - !(r_ptr->flags5 & RF5_NOMAGIC_MASK) && - !(r_ptr->flags6 & RF6_NOMAGIC_MASK)) + !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) && + !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK)) return FALSE; } if (d_ptr->flags1 & DF1_NO_MELEE) { if (r_idx == MON_CHAMELEON) return TRUE; if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) && - !(r_ptr->flags5 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH)) && - !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK))) + !(r_ptr->a_ability_flags1 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH)) && + !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK))) return FALSE; } if (d_ptr->flags1 & DF1_BEGINNER) @@ -1020,14 +1022,14 @@ static bool restrict_monster_to_dungeon(int r_idx) if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4) return FALSE; } - if (d_ptr->mflags5) + if (d_ptr->m_a_ability_flags1) { - if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5) + if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1) return FALSE; } - if (d_ptr->mflags6) + if (d_ptr->m_a_ability_flags2) { - if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6) + if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2) return FALSE; } if (d_ptr->mflags7) @@ -1076,14 +1078,14 @@ static bool restrict_monster_to_dungeon(int r_idx) if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4) return TRUE; } - if (d_ptr->mflags5) + if (d_ptr->m_a_ability_flags1) { - if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5) + if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1) return TRUE; } - if (d_ptr->mflags6) + if (d_ptr->m_a_ability_flags2) { - if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6) + if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2) return TRUE; } if (d_ptr->mflags7) @@ -1116,8 +1118,8 @@ static bool restrict_monster_to_dungeon(int r_idx) if (r_ptr->flags2 & d_ptr->mflags2) return TRUE; if (r_ptr->flags3 & d_ptr->mflags3) return TRUE; if (r_ptr->flags4 & d_ptr->mflags4) return TRUE; - if (r_ptr->flags5 & d_ptr->mflags5) return TRUE; - if (r_ptr->flags6 & d_ptr->mflags6) return TRUE; + if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE; + if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE; if (r_ptr->flags7 & d_ptr->mflags7) return TRUE; if (r_ptr->flags8 & d_ptr->mflags8) return TRUE; if (r_ptr->flags9 & d_ptr->mflags9) return TRUE; @@ -1132,8 +1134,8 @@ static bool restrict_monster_to_dungeon(int r_idx) if (r_ptr->flags2 & d_ptr->mflags2) return FALSE; if (r_ptr->flags3 & d_ptr->mflags3) return FALSE; if (r_ptr->flags4 & d_ptr->mflags4) return FALSE; - if (r_ptr->flags5 & d_ptr->mflags5) return FALSE; - if (r_ptr->flags6 & d_ptr->mflags6) return FALSE; + if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE; + if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE; if (r_ptr->flags7 & d_ptr->mflags7) return FALSE; if (r_ptr->flags8 & d_ptr->mflags8) return FALSE; if (r_ptr->flags9 & d_ptr->mflags9) return FALSE; @@ -1149,12 +1151,12 @@ static bool restrict_monster_to_dungeon(int r_idx) /*! * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table" - * @param monnster_hook 制限関数1 - * @param monnster_hook2 制限関数2 + * @param monster_hook 制限関数1 + * @param monster_hook2 制限関数2 * @return エラーコード */ -errr get_mon_num_prep(monster_hook_type monster_hook, - monster_hook_type monster_hook2) +errr get_mon_num_prep(monsterrace_hook_type monster_hook, + monsterrace_hook_type monster_hook2) { int i; @@ -1167,7 +1169,7 @@ errr get_mon_num_prep(monster_hook_type monster_hook, /* Scan the allocation table */ for (i = 0; i < alloc_race_size; i++) { - monster_race *r_ptr; + monster_race *r_ptr; /* Get the entry */ alloc_entry *entry = &alloc_race_table[i]; @@ -1211,47 +1213,6 @@ errr get_mon_num_prep(monster_hook_type monster_hook, return (0); } -/*! - * @brief 平方根を切り捨て整数で返す - * @param n 数値 - * @return 平方根 - */ -static int mysqrt(int n) -{ - int tmp = n>>1; - int tasu = 10; - int kaeriti = 1; - - if (!tmp) - { - if (n) return 1; - else return 0; - } - - while(tmp) - { - if ((n/tmp) < tmp) - { - tmp >>= 1; - } - else break; - } - kaeriti = tmp; - while(tasu) - { - if ((n/tmp) < tmp) - { - tasu--; - tmp = kaeriti; - } - else - { - kaeriti = tmp; - tmp += tasu; - } - } - return kaeriti; -} /*! * @brief 生成モンスター種族を1種生成テーブルから選択する @@ -1279,21 +1240,19 @@ static int mysqrt(int n) * Note that if no monsters are "appropriate", then this function will * fail, and return zero, but this should *almost* never happen. */ -s16b get_mon_num(int level) +MONRACE_IDX get_mon_num(DEPTH level) { - int i, j, p; - int r_idx; - long value, total; - monster_race *r_ptr; - alloc_entry *table = alloc_race_table; + int i, j, p; + MONRACE_IDX r_idx; + long value, total; + monster_race *r_ptr; + alloc_entry *table = alloc_race_table; int pls_kakuritu, pls_level; - int hoge = mysqrt(level*10000L); + int delay = mysqrt(level * 10000L) + 400L; - if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1; - - pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 2500L) - hoge / 10))); - pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 20000L) - hoge / 40 + MIN(5, level / 10)) ; + pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10))); + pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ; if (d_info[dungeon_type].flags1 & DF1_MAZE) { @@ -1323,6 +1282,9 @@ s16b get_mon_num(int level) } } + if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1; + if (level < 0) level = 0; + /* Reset total */ total = 0L; @@ -1435,8 +1397,6 @@ s16b get_mon_num(int level) /* Keep the "best" one */ if (table[i].level < table[j].level) i = j; } - - /* Result */ return (table[i].index); } @@ -1494,14 +1454,14 @@ s16b get_mon_num(int level) * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE * --> Reflexive, genderized if visable ("himself") or "itself" */ -void monster_desc(char *desc, monster_type *m_ptr, int mode) +void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode) { - cptr res; + concptr res; monster_race *r_ptr; - cptr name; + concptr name; char buf[128]; - char silly_name[1024]; + GAME_TEXT silly_name[1024]; bool seen, pron; bool named = FALSE; @@ -1787,7 +1747,7 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) * @details * Return the number of new flags learnt. -Mogami- */ -int lore_do_probe(int r_idx) +int lore_do_probe(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[r_idx]; int i, n = 0; @@ -1847,9 +1807,9 @@ int lore_do_probe(int r_idx) if (!(r_ptr->r_flags4 & (1L << i)) && (r_ptr->flags4 & (1L << i))) n++; if (!(r_ptr->r_flags5 & (1L << i)) && - (r_ptr->flags5 & (1L << i))) n++; + (r_ptr->a_ability_flags1 & (1L << i))) n++; if (!(r_ptr->r_flags6 & (1L << i)) && - (r_ptr->flags6 & (1L << i))) n++; + (r_ptr->a_ability_flags2 & (1L << i))) n++; if (!(r_ptr->r_flagsr & (1L << i)) && (r_ptr->flagsr & (1L << i))) n++; @@ -1865,8 +1825,8 @@ int lore_do_probe(int r_idx) r_ptr->r_flags2 = r_ptr->flags2; r_ptr->r_flags3 = r_ptr->flags3; r_ptr->r_flags4 = r_ptr->flags4; - r_ptr->r_flags5 = r_ptr->flags5; - r_ptr->r_flags6 = r_ptr->flags6; + r_ptr->r_flags5 = r_ptr->a_ability_flags1; + r_ptr->r_flags6 = r_ptr->a_ability_flags2; r_ptr->r_flagsr = r_ptr->flagsr; /* r_flags7 is actually unused */ @@ -1879,7 +1839,6 @@ int lore_do_probe(int r_idx) /* Update monster recall window */ if (p_ptr->monster_race_idx == r_idx) { - /* Window stuff */ p_ptr->window |= (PW_MONSTER); } @@ -1905,7 +1864,7 @@ int lore_do_probe(int r_idx) * gold and items are dropped, and remembers that information to be * described later by the monster recall code. */ -void lore_treasure(int m_idx, int num_item, int num_gold) +void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold) { monster_type *m_ptr = &m_list[m_idx]; @@ -1925,7 +1884,6 @@ void lore_treasure(int m_idx, int num_item, int num_gold) /* Update monster recall window */ if (p_ptr->monster_race_idx == m_ptr->r_idx) { - /* Window stuff */ p_ptr->window |= (PW_MONSTER); } } @@ -1939,15 +1897,14 @@ void lore_treasure(int m_idx, int num_item, int num_gold) */ void sanity_blast(monster_type *m_ptr, bool necro) { - bool happened = FALSE; int power = 100; if (p_ptr->inside_battle || !character_dungeon) return; - if (!necro) + if (!necro && m_ptr) { - char m_name[80]; - monster_race *r_ptr = &r_info[m_ptr->ap_r_idx]; + GAME_TEXT m_name[MAX_NLEN]; + monster_race *r_ptr = &r_info[m_ptr->ap_r_idx]; power = r_ptr->level / 2; @@ -1960,16 +1917,14 @@ void sanity_blast(monster_type *m_ptr, bool necro) } else power *= 2; - if (!hack_mind) + if (!is_loading_now) return; /* No effect yet, just loaded... */ if (!m_ptr->ml) return; /* Cannot see it for some reason */ if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR)) - return; /* oops */ - - + return; if (is_pet(m_ptr)) return; /* Pet eldritch horrors are safe most of the time */ @@ -1992,7 +1947,6 @@ void sanity_blast(monster_type *m_ptr, bool necro) funny_desc[randint0(MAX_SAN_FUNNY)], m_name); #endif - if (one_in_(3)) { msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]); @@ -2025,59 +1979,97 @@ void sanity_blast(monster_type *m_ptr, bool necro) if (saving_throw(25 + p_ptr->lev)) return; } } - else + else if(!necro) { - msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!")); - } + monster_race *r_ptr; + GAME_TEXT m_name[MAX_NLEN]; + concptr desc; - if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */ - { - if (!p_ptr->resist_conf) + get_mon_num_prep(get_nightmare, NULL); + + r_ptr = &r_info[get_mon_num(MAX_DEPTH)]; + power = r_ptr->level + 10; + desc = r_name + r_ptr->name; + + get_mon_num_prep(NULL, NULL); + +#ifndef JP + if (!(r_ptr->flags1 & RF1_UNIQUE)) + sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc); + else +#endif + sprintf(m_name, "%s", desc); + + if (!(r_ptr->flags1 & RF1_UNIQUE)) { - (void)set_confused(p_ptr->confused + randint0(4) + 4); + if (r_ptr->flags1 & RF1_FRIENDS) power /= 2; } - if (!p_ptr->resist_chaos && one_in_(3)) + else power *= 2; + + if (saving_throw(p_ptr->skill_sav * 100 / power)) { - (void)set_image(p_ptr->image + randint0(250) + 150); + msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name); + /* Safe */ + return; } - return; - } - - if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */ - { - do_dec_stat(A_INT); - do_dec_stat(A_WIS); - return; - } - if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */ - { - if (!p_ptr->resist_conf) + if (p_ptr->image) { - (void)set_confused(p_ptr->confused + randint0(4) + 4); + /* Something silly happens... */ + msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), + funny_desc[randint0(MAX_SAN_FUNNY)], m_name); + + if (one_in_(3)) + { + msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]); + p_ptr->image = p_ptr->image + randint1(r_ptr->level); + } + + /* Never mind; we can't see it clearly enough */ + return; } - if (!p_ptr->free_act) + + /* Something frightening happens... */ + msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), + horror_desc[randint0(MAX_SAN_HORROR)], desc); + + r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR; + + if (!p_ptr->mimic_form) { - (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4); + switch (p_ptr->prace) + { + /* Demons may make a saving throw */ + case RACE_IMP: + case RACE_DEMON: + if (saving_throw(20 + p_ptr->lev)) return; + break; + /* Undead may make a saving throw */ + case RACE_SKELETON: + case RACE_ZOMBIE: + case RACE_SPECTRE: + case RACE_VAMPIRE: + if (saving_throw(10 + p_ptr->lev)) return; + break; + } } - while (randint0(100) > p_ptr->skill_sav) - (void)do_dec_stat(A_INT); - while (randint0(100) > p_ptr->skill_sav) - (void)do_dec_stat(A_WIS); - if (!p_ptr->resist_chaos) + else { - (void)set_image(p_ptr->image + randint0(250) + 150); + /* Demons may make a saving throw */ + if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON) + { + if (saving_throw(20 + p_ptr->lev)) return; + } + /* Undead may make a saving throw */ + else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD) + { + if (saving_throw(10 + p_ptr->lev)) return; + } } - return; } - - if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */ + else { - - if (lose_all_info()) - msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!")); - - return; + msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!")); } if (saving_throw(p_ptr->skill_sav - power)) @@ -2085,91 +2077,100 @@ void sanity_blast(monster_type *m_ptr, bool necro) return; } - /* Else gain permanent insanity */ - if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/ - ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) && - ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos))) - { - /* The poor bastard already has all possible insanities! */ - return; - } + do { + (void)do_dec_stat(A_INT); + } while (randint0(100) > p_ptr->skill_sav && one_in_(2)); - while (!happened) + do { + (void)do_dec_stat(A_WIS); + } while (randint0(100) > p_ptr->skill_sav && one_in_(2)); + + switch (randint1(21)) { - switch (randint1(21)) + case 1: + if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5)) { - case 1: - if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5)) - { - if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4)) - { - msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!")); - } - else - { - msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!")); - } + if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4)) + { + msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!")); + } + else + { + msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!")); + } - if (p_ptr->muta3 & MUT3_HYPER_INT) - { - msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer.")); - p_ptr->muta3 &= ~(MUT3_HYPER_INT); - } - p_ptr->muta3 |= MUT3_MORONIC; - happened = TRUE; - } - break; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear) - { - msg_print(_("あなたはパラノイアになった!", "You become paranoid!")); + if (p_ptr->muta3 & MUT3_HYPER_INT) + { + msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer.")); + p_ptr->muta3 &= ~(MUT3_HYPER_INT); + } + p_ptr->muta3 |= MUT3_MORONIC; + } + break; + case 2: + case 3: + case 4: + if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear) + { + msg_print(_("あなたはパラノイアになった!", "You become paranoid!")); - /* Duh, the following should never happen, but anyway... */ - if (p_ptr->muta3 & MUT3_FEARLESS) - { - msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless.")); - p_ptr->muta3 &= ~(MUT3_FEARLESS); - } + /* Duh, the following should never happen, but anyway... */ + if (p_ptr->muta3 & MUT3_FEARLESS) + { + msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless.")); + p_ptr->muta3 &= ~(MUT3_FEARLESS); + } - p_ptr->muta2 |= MUT2_COWARDICE; - happened = TRUE; - } - break; - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos) - { - msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!")); - p_ptr->muta2 |= MUT2_HALLU; - happened = TRUE; - } - break; - default: - if (!(p_ptr->muta2 & MUT2_BERS_RAGE)) - { - msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!")); - p_ptr->muta2 |= MUT2_BERS_RAGE; - happened = TRUE; - } - break; + p_ptr->muta2 |= MUT2_COWARDICE; + } + break; + case 5: + case 6: + case 7: + if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos) + { + msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!")); + p_ptr->muta2 |= MUT2_HALLU; + } + break; + case 8: + case 9: + case 10: + if (!(p_ptr->muta2 & MUT2_BERS_RAGE)) + { + msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!")); + p_ptr->muta2 |= MUT2_BERS_RAGE; + } + break; + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + /* Brain smash */ + if (!p_ptr->resist_conf) + { + (void)set_confused(p_ptr->confused + randint0(4) + 4); + } + if (!p_ptr->free_act) + { + (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4); } + if (!p_ptr->resist_chaos) + { + (void)set_image(p_ptr->image + randint0(250) + 150); + } + break; + case 17: + case 18: + case 19: + case 20: + case 21: + /* Amnesia */ + if (lose_all_info()) + msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!")); + break; } p_ptr->update |= PU_BONUS; @@ -2181,7 +2182,7 @@ void sanity_blast(monster_type *m_ptr, bool necro) * @param m_idx 更新するモンスター情報のID * @param full プレイヤーとの距離更新を行うならばtrue * @return なし - * @detail + * @details * This involves extracting the distance to the player (if requested), * and then checking for visibility (natural, infravision, see-invis, * telepathy), updating the monster visibility flag, redrawing (or @@ -2238,7 +2239,7 @@ void sanity_blast(monster_type *m_ptr, bool necro) * "disturb_near" (monster which is "easily" viewable moves in some * way). Note that "moves" includes "appears" and "disappears". */ -void update_mon(int m_idx, bool full) +void update_monster(MONSTER_IDX m_idx, bool full) { monster_type *m_ptr = &m_list[m_idx]; @@ -2274,8 +2275,8 @@ void update_mon(int m_idx, bool full) if (full) { /* Distance components */ - int dy = (py > fy) ? (py - fy) : (fy - py); - int dx = (px > fx) ? (px - fx) : (fx - px); + int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y); + int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x); /* Approximate distance */ d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1)); @@ -2471,7 +2472,6 @@ void update_mon(int m_idx, bool full) /* Handle "cold blooded" monsters */ if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD) { - /* Take note */ do_cold_blood = TRUE; } @@ -2489,7 +2489,6 @@ void update_mon(int m_idx, bool full) /* Handle "invisible" monsters */ if (r_ptr->flags2 & (RF2_INVISIBLE)) { - /* Take note */ do_invisible = TRUE; /* See invisible */ @@ -2554,10 +2553,10 @@ void update_mon(int m_idx, bool full) } /* Disturb on appearance */ - if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx))) + if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx))) { if (disturb_pets || is_hostile(m_ptr)) - disturb(1, 1); + disturb(TRUE, TRUE); } } } @@ -2582,7 +2581,7 @@ void update_mon(int m_idx, bool full) if (do_disturb) { if (disturb_pets || is_hostile(m_ptr)) - disturb(1, 1); + disturb(TRUE, TRUE); } } } @@ -2601,7 +2600,7 @@ void update_mon(int m_idx, bool full) if (do_disturb) { if (disturb_pets || is_hostile(m_ptr)) - disturb(1, 1); + disturb(TRUE, TRUE); } } } @@ -2619,7 +2618,7 @@ void update_mon(int m_idx, bool full) if (do_disturb) { if (disturb_pets || is_hostile(m_ptr)) - disturb(1, 1); + disturb(TRUE, TRUE); } } } @@ -2633,7 +2632,7 @@ void update_mon(int m_idx, bool full) */ void update_monsters(bool full) { - int i; + IDX i; /* Update each (live) monster */ for (i = 1; i < m_max; i++) @@ -2642,9 +2641,7 @@ void update_monsters(bool full) /* Skip dead monsters */ if (!m_ptr->r_idx) continue; - - /* Update the monster */ - update_mon(i, full); + update_monster(i, full); } } @@ -2654,7 +2651,7 @@ void update_monsters(bool full) * @param r_idx モンスター種族ID * @return 対象にできるならtrueを返す */ -static bool monster_hook_chameleon_lord(int r_idx) +static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[r_idx]; monster_type *m_ptr = &m_list[chameleon_change_m_idx]; @@ -2690,7 +2687,7 @@ static bool monster_hook_chameleon_lord(int r_idx) * @param r_idx モンスター種族ID * @return 対象にできるならtrueを返す */ -static bool monster_hook_chameleon(int r_idx) +static bool monster_hook_chameleon(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[r_idx]; monster_type *m_ptr = &m_list[chameleon_change_m_idx]; @@ -2729,12 +2726,12 @@ static bool monster_hook_chameleon(int r_idx) * @param r_idx 旧モンスター種族のID * @return なし */ -void choose_new_monster(int m_idx, bool born, int r_idx) +void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx) { int oldmaxhp; monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr; - char old_m_name[80]; + char old_m_name[MAX_NLEN]; bool old_unique = FALSE; int old_r_idx = m_ptr->r_idx; @@ -2747,7 +2744,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx) if (!r_idx) { - int level; + DEPTH level; chameleon_change_m_idx = m_idx; if (old_unique) @@ -2777,7 +2774,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx) m_ptr->r_idx = r_idx; m_ptr->ap_r_idx = r_idx; - update_mon(m_idx, FALSE); + update_monster(m_idx, FALSE); lite_spot(m_ptr->fy, m_ptr->fx); if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) || @@ -2800,7 +2797,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx) if (m_idx == p_ptr->riding) { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name); if (!(r_ptr->flags7 & RF7_RIDING)) @@ -2825,7 +2822,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx) if (ironman_nightmare) { u32b hp = m_ptr->max_maxhp * 2L; - m_ptr->max_maxhp = (s16b)MIN(30000, hp); + m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp); } m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp; @@ -2842,7 +2839,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx) * @param r_idx モンスター種族ID * @return 対象にできるならtrueを返す */ -static bool monster_hook_tanuki(int r_idx) +static bool monster_hook_tanuki(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[r_idx]; @@ -2863,12 +2860,12 @@ static bool monster_hook_tanuki(int r_idx) * @param r_idx モンスター種族ID * @return モンスター種族の表層ID */ -static int initial_r_appearance(int r_idx) +static IDX initial_r_appearance(MONRACE_IDX r_idx) { int attempts = 1000; - int ap_r_idx; - int min = MIN(base_level-5, 50); + IDX ap_r_idx; + DEPTH min = MIN(base_level-5, 50); if (!(r_info[r_idx].flags7 & RF7_TANUKI)) return r_idx; @@ -2886,7 +2883,7 @@ static int initial_r_appearance(int r_idx) /*! - * @brief モンスターの個体加速を設定する / Get initial monster spee\d + * @brief モンスターの個体加速を設定する / Get initial monster speed * @param r_ptr モンスター種族の参照ポインタ * @return 加速値 */ @@ -2925,25 +2922,22 @@ byte get_mspeed(monster_race *r_ptr) * * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters. * - * XXX XXX XXX Use special "here" and "dead" flags for unique monsters, + * Use special "here" and "dead" flags for unique monsters, * remove old "cur_num" and "max_num" fields. * - * XXX XXX XXX Actually, do something similar for artifacts, to simplify + * Actually, do something similar for artifacts, to simplify * the "preserve" mode, and to make the "what artifacts" flag more useful. * * This is the only function which may place a monster in the dungeon, * except for the savefile loading code. */ -static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode) +static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode) { /* Access the location */ cave_type *c_ptr = &cave[y][x]; - monster_type *m_ptr; - monster_race *r_ptr = &r_info[r_idx]; - - cptr name = (r_name + r_ptr->name); + concptr name = (r_name + r_ptr->name); int cmi; @@ -3039,36 +3033,12 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode) c_ptr->info &= ~(CAVE_OBJECT); c_ptr->mimic = 0; - /* Notice */ note_spot(y, x); } else return FALSE; } - /* Powerful monster */ - if (r_ptr->level > dun_level) - { - /* Unique monsters */ - if (r_ptr->flags1 & (RF1_UNIQUE)) - { - /* Message for cheaters */ - if (cheat_hear) msg_format(_("深層のユニーク・モンスター (%s)。", "Deep Unique (%s)."), name); - } - - /* Normal monsters */ - else - { - /* Message for cheaters */ - if (cheat_hear) msg_format(_("深層のモンスター (%s)。", "Deep Monster (%s)."), name); - } - } - - /* Note the monster */ - else if (r_ptr->flags1 & (RF1_UNIQUE)) - { - /* Unique monsters induce message */ - if (cheat_hear) msg_format(_("ユニーク・モンスター (%s)。", "Unique (%s)."), name); - } + msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level); if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE; @@ -3197,7 +3167,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode) { u32b hp = m_ptr->max_maxhp * 2L; - m_ptr->max_maxhp = (s16b)MIN(30000, hp); + m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp); } m_ptr->maxhp = m_ptr->max_maxhp; @@ -3250,9 +3220,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode) p_ptr->update |= (PU_MON_LITE); else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr)) p_ptr->update |= (PU_MON_LITE); - - /* Update the monster */ - update_mon(c_ptr->m_idx, TRUE); + update_monster(c_ptr->m_idx, TRUE); /* Count the monsters on the level */ @@ -3280,9 +3248,9 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode) { if (r_ptr->flags1 & RF1_UNIQUE) { - cptr color; + concptr color; object_type *o_ptr; - char o_name[MAX_NLEN]; + GAME_TEXT o_name[MAX_NLEN]; if (r_ptr->level > p_ptr->lev + 30) color = _("黒く", "black"); @@ -3344,7 +3312,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode) -#define MON_SCAT_MAXD 10 +#define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */ /*! * @brief モンスター1体を目標地点に可能ながり近い位置に生成する / improved version of scatter() for place monster @@ -3357,7 +3325,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode) * @return 成功したらtrue * */ -static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist) +static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist) { int place_x[MON_SCAT_MAXD]; int place_y[MON_SCAT_MAXD]; @@ -3426,12 +3394,6 @@ static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist) return TRUE; } - -/* - * Maximum size of a group of monsters - */ -#define GROUP_MAX 32 - /*! * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location * @param who 召喚主のモンスター情報ID @@ -3441,7 +3403,7 @@ static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist) * @param mode 生成オプション * @return 成功したらtrue */ -static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode) +static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode) { monster_race *r_ptr = &r_info[r_idx]; @@ -3450,8 +3412,8 @@ static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode) int hack_n = 0; - byte hack_y[GROUP_MAX]; - byte hack_x[GROUP_MAX]; + POSITION hack_y[GROUP_MAX]; + POSITION hack_x[GROUP_MAX]; /* Pick a group size */ @@ -3493,13 +3455,13 @@ static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode) for (n = 0; (n < hack_n) && (hack_n < total); n++) { /* Grab the location */ - int hx = hack_x[n]; - int hy = hack_y[n]; + POSITION hx = hack_x[n]; + POSITION hy = hack_y[n]; /* Check each direction, up to total */ for (i = 0; (i < 8) && (hack_n < total); i++) { - int mx, my; + POSITION mx, my; scatter(&my, &mx, hy, hx, 4, 0); @@ -3522,19 +3484,26 @@ static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode) return (TRUE); } +/*! + * @var place_monster_idx + * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type + * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する + */ +static MONSTER_IDX place_monster_idx = 0; -/* - * Hack -- help pick an escort type +/*! + * @var place_monster_m_idx + * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type + * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する */ -static int place_monster_idx = 0; -static int place_monster_m_idx = 0; +static MONSTER_IDX place_monster_m_idx = 0; /*! * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type * @param r_idx チェックするモンスター種族のID * @return 護衛にできるならばtrue */ -static bool place_monster_okay(int r_idx) +static bool place_monster_can_escort(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[place_monster_idx]; monster_type *m_ptr = &m_list[place_monster_m_idx]; @@ -3567,7 +3536,6 @@ static bool place_monster_okay(int r_idx) if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON)) return FALSE; - /* Okay */ return (TRUE); } @@ -3596,7 +3564,7 @@ static bool place_monster_okay(int r_idx) * Note the use of the new "monster allocation table" code to restrict * the "get_mon_num()" function to "legal" escort types. */ -bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode) +bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode) { int i, j, n; monster_race *r_ptr = &r_info[r_idx]; @@ -3613,13 +3581,13 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode) place_monster_m_idx = hack_m_idx_ii; /* Reinforcement */ - for(i = 0; i < 6; i++) + for(i = 0; i < A_MAX; i++) { if(!r_ptr->reinforce_id[i]) break; n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]); for(j = 0; j < n; j++) { - int nx, ny, d = 7; + POSITION nx, ny, d = 7; scatter(&ny, &nx, y, x, d, 0); (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode); } @@ -3641,7 +3609,8 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode) /* Try to place several "escorts" */ for (i = 0; i < 32; i++) { - int nx, ny, z, d = 3; + POSITION nx, ny, d = 3; + MONRACE_IDX z; /* Pick a location */ scatter(&ny, &nx, y, x, d, 0); @@ -3650,7 +3619,7 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode) if (!cave_empty_bold2(ny, nx)) continue; /* Prepare allocation table */ - get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx)); + get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx)); /* Pick a random race */ z = get_mon_num(r_ptr->level); @@ -3682,9 +3651,9 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode) * @param mode 生成オプション * @return 生成に成功したらtrue */ -bool place_monster(int y, int x, u32b mode) +bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode) { - int r_idx; + MONRACE_IDX r_idx; /* Prepare allocation table */ get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x)); @@ -3698,27 +3667,23 @@ bool place_monster(int y, int x, u32b mode) /* Attempt to place the monster */ if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE); - /* Oops */ return (FALSE); } - -#ifdef MONSTER_HORDES - /*! * @brief 指定地点に1種類のモンスター種族による群れを生成する * @param y 生成地点y座標 * @param x 生成地点x座標 * @return 生成に成功したらtrue */ -bool alloc_horde(int y, int x) +bool alloc_horde(POSITION y, POSITION x) { monster_race *r_ptr = NULL; - int r_idx = 0; - int m_idx; + MONRACE_IDX r_idx = 0; + MONSTER_IDX m_idx; int attempts = 1000; - int cy = y; - int cx = x; + POSITION cy = y; + POSITION cx = x; /* Prepare allocation table */ get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x)); @@ -3753,24 +3718,21 @@ bool alloc_horde(int y, int x) m_idx = cave[y][x].m_idx; if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx]; - summon_kin_type = r_ptr->d_char; for (attempts = randint1(10) + 5; attempts; attempts--) { scatter(&cy, &cx, y, x, 5, 0); - (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP); + (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char); y = cy; x = cx; } + if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char); return TRUE; } -#endif /* MONSTER_HORDES */ - - /*! * @brief ダンジョンの主生成を試みる / Put the Guardian * @param def_val 現在の主の生成状態 @@ -3778,7 +3740,7 @@ bool alloc_horde(int y, int x) */ bool alloc_guardian(bool def_val) { - int guardian = d_info[dungeon_type].final_guardian; + MONRACE_IDX guardian = d_info[dungeon_type].final_guardian; if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num)) { @@ -3821,10 +3783,10 @@ bool alloc_guardian(bool def_val) * Use "slp" to choose the initial "sleep" status * Use "monster_level" for the monster level */ -bool alloc_monster(int dis, u32b mode) +bool alloc_monster(POSITION dis, BIT_FLAGS mode) { - int y = 0, x = 0; - int attempts_left = 10000; + int y = 0, x = 0; + int attempts_left = 10000; /* Put the Guardian */ if (alloc_guardian(FALSE)) return TRUE; @@ -3847,7 +3809,7 @@ bool alloc_monster(int dis, u32b mode) } /* Accept far away grids */ - if (distance(y, x, py, px) > dis) break; + if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break; } if (!attempts_left) @@ -3861,27 +3823,19 @@ bool alloc_monster(int dis, u32b mode) } -#ifdef MONSTER_HORDES if (randint1(5000) <= dun_level) { if (alloc_horde(y, x)) { - if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type); return (TRUE); } } else { -#endif /* MONSTER_HORDES */ - /* Attempt to place the monster, allow groups */ if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE); - -#ifdef MONSTER_HORDES } -#endif /* MONSTER_HORDES */ - /* Nope */ return (FALSE); } @@ -3891,7 +3845,7 @@ bool alloc_monster(int dis, u32b mode) * @param r_idx チェックするモンスター種族ID * @return 召喚対象にできるならばTRUE */ -static bool summon_specific_okay(int r_idx) +static bool summon_specific_okay(MONRACE_IDX r_idx) { monster_race *r_ptr = &r_info[r_idx]; @@ -3918,11 +3872,11 @@ static bool summon_specific_okay(int r_idx) } } + if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE; + /* Hack -- no specific type specified */ if (!summon_specific_type) return (TRUE); - if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE; - if ((summon_specific_who < 0) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) && monster_has_hostile_align(NULL, 10, -10, r_ptr)) @@ -3965,9 +3919,10 @@ static bool summon_specific_okay(int r_idx) * * Note that this function may not succeed, though this is very rare. */ -bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode) +bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol) { - int x, y, r_idx; + POSITION x, y; + MONRACE_IDX r_idx; if (p_ptr->inside_arena) return (FALSE); @@ -3979,6 +3934,8 @@ bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode) /* Save the "summon" type */ summon_specific_type = type; + summon_kin_type = symbol; + summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE; /* Prepare allocation table */ @@ -4005,6 +3962,7 @@ bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode) summon_specific_type = 0; /* Success */ + sound(SOUND_SUMMON); return (TRUE); } @@ -4018,9 +3976,9 @@ bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode) * @param mode 生成オプション * @return 召喚できたらtrueを返す */ -bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode) +bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode) { - int x, y; + POSITION x, y; /* Paranoia */ /* if (!r_idx) return; */ @@ -4046,11 +4004,11 @@ bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode) * @details * Note that "reproduction" REQUIRES empty space. */ -bool multiply_monster(int m_idx, bool clone, u32b mode) +bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode) { monster_type *m_ptr = &m_list[m_idx]; - int y, x; + POSITION y, x; if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1)) return FALSE; @@ -4081,17 +4039,17 @@ bool multiply_monster(int m_idx, bool clone, u32b mode) * @details * Technically should attempt to treat "Beholder"'s as jelly's */ -void message_pain(int m_idx, int dam) +void message_pain(MONSTER_IDX m_idx, HIT_POINT dam) { - long oldhp, newhp, tmp; - int percentage; + HIT_POINT oldhp, newhp; + HIT_POINT tmp; + PERCENTAGE percentage; monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; - /* Get the monster name */ monster_desc(m_name, m_ptr, 0); if(dam == 0) // Notice non-damage @@ -4101,10 +4059,10 @@ void message_pain(int m_idx, int dam) } /* Note -- subtle fix -CFT */ - newhp = (long)(m_ptr->hp); - oldhp = newhp + (long)(dam); + newhp = m_ptr->hp; + oldhp = newhp + dam; tmp = (newhp * 100L) / oldhp; - percentage = (int)(tmp); + percentage = tmp; if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs { @@ -4403,17 +4361,17 @@ void message_pain(int m_idx, int dam) - -/* - * Learn about an "observed" resistance. +/*! + * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance. + * @param m_idx 更新を行う「モンスター情報ID + * @param what 学習対象ID + * @return なし */ -void update_smart_learn(int m_idx, int what) +void update_smart_learn(MONSTER_IDX m_idx, int what) { monster_type *m_ptr = &m_list[m_idx]; - monster_race *r_ptr = &r_info[m_ptr->r_idx]; - /* Not allowed to learn */ if (!smart_learn) return; @@ -4423,9 +4381,6 @@ void update_smart_learn(int m_idx, int what) /* Not intelligent, only learn sometimes */ if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return; - - /* XXX XXX XXX */ - /* Analyze the knowledge */ switch (what) { @@ -4518,29 +4473,34 @@ void update_smart_learn(int m_idx, int what) } -/* - * Place the player in the dungeon XXX XXX +/*! + * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX + * @param x 配置先X座標 + * @param y 配置先Y座標 + * @return 配置に成功したらTRUE */ -bool player_place(int y, int x) +bool player_place(POSITION y, POSITION x) { /* Paranoia XXX XXX */ if (cave[y][x].m_idx != 0) return FALSE; /* Save player location */ - py = y; - px = x; + p_ptr->y = y; + p_ptr->x = x; /* Success */ return TRUE; } -/* - * Drop all items carried by a monster +/*! + * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster + * @param m_ptr モンスター参照ポインタ + * @return なし */ void monster_drop_carried_objects(monster_type *m_ptr) { - s16b this_o_idx, next_o_idx = 0; + OBJECT_IDX this_o_idx, next_o_idx = 0; object_type forge; object_type *o_ptr; object_type *q_ptr; @@ -4549,13 +4509,10 @@ void monster_drop_carried_objects(monster_type *m_ptr) /* Drop objects being carried */ for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { - /* Acquire object */ o_ptr = &o_list[this_o_idx]; /* Acquire next object */ next_o_idx = o_ptr->next_o_idx; - - /* Get local object */ q_ptr = &forge; /* Copy the object */ @@ -4564,7 +4521,6 @@ void monster_drop_carried_objects(monster_type *m_ptr) /* Forget monster */ q_ptr->held_m_idx = 0; - /* Delete the object */ delete_object_idx(this_o_idx); /* Drop it */