OSDN Git Service

[Refactor] #37353 ソースファイル改名。
[hengband/hengband.git] / src / spells3.c
index ebcbf84..586a853 100644 (file)
@@ -16,9 +16,6 @@
 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
 #define MAX_TRIES 100
 
-/*! 能力値現象の基本確率(1 / HURT_CHANCE) / 1/x chance of reducing stats (for elemental attacks) */
-#define HURT_CHANCE 16
-
 /*!
  * @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
  * @param m_idx モンスターID
@@ -27,7 +24,7 @@
  * @param mode オプション
  * @return テレポート先として妥当ならばtrue
  */
-static bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, int y, int x, u32b mode)
+static bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, int y, int x, BIT_FLAGS mode)
 {
        monster_type *m_ptr = &m_list[m_idx];
        cave_type    *c_ptr = &cave[y][x];
@@ -63,7 +60,7 @@ static bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, int y, int x, u32b
  * Attempt to move the monster at least "dis/2" grids away.
  * But allow variation to prevent infinite loops.
  */
-bool teleport_away(MONSTER_IDX m_idx, int dis, u32b mode)
+bool teleport_away(MONSTER_IDX m_idx, int dis, BIT_FLAGS mode)
 {
        int oy, ox, d, i, min;
        int tries = 0;
@@ -178,7 +175,7 @@ bool teleport_away(MONSTER_IDX m_idx, int dis, u32b mode)
  * @param mode オプション
  * @return なし
  */
-void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, u32b mode)
+void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
 {
        int ny, nx, oy, ox, d, i, min;
        int attempts = 500;
@@ -278,7 +275,7 @@ void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power,
  * @param mode オプション
  * @return テレポート先として妥当ならばtrue
  */
-bool cave_player_teleportable_bold(int y, int x, u32b mode)
+bool cave_player_teleportable_bold(int y, int x, BIT_FLAGS mode)
 {
        cave_type    *c_ptr = &cave[y][x];
        feature_type *f_ptr = &f_info[c_ptr->feat];
@@ -318,9 +315,6 @@ bool cave_player_teleportable_bold(int y, int x, u32b mode)
 }
 
 
-/*! テレポート最大距離 */
-#define MAX_TELEPORT_DISTANCE 200
-
 /*!
  * @brief プレイヤーのテレポート先選定と移動処理 /
  * Teleport the player to a location up to "dis" grids away.
@@ -344,7 +338,7 @@ bool cave_player_teleportable_bold(int y, int x, u32b mode)
  * </pre>
  */
 
-bool teleport_player_aux(int dis, u32b mode)
+bool teleport_player_aux(int dis, BIT_FLAGS mode)
 {
        int candidates_at[MAX_TELEPORT_DISTANCE + 1];
        int total_candidates, cur_candidates;
@@ -461,7 +455,7 @@ bool teleport_player_aux(int dis, u32b mode)
  * @param mode オプション
  * @return なし
  */
-void teleport_player(int dis, u32b mode)
+void teleport_player(int dis, BIT_FLAGS mode)
 {
        int yy, xx;
 
@@ -556,7 +550,7 @@ void teleport_player_away(MONSTER_IDX m_idx, int dis)
  * This function allows teleporting into vaults (!)
  * </pre>
  */
-void teleport_player_to(POSITION ny, POSITION nx, u32b mode)
+void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
 {
        POSITION y, x;
        int dis = 0, ctr = 0;
@@ -842,8 +836,9 @@ void teleport_level(MONSTER_IDX m_idx)
 DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
 {
        DUNGEON_IDX select_dungeon;
-       int i, num = 0;
-       s16b *dun;
+       DUNGEON_IDX i;
+       int num = 0;
+       DUNGEON_IDX *dun;
 
        /* Hack -- No need to choose dungeon in some case */
        if (lite_town || vanilla_town || ironman_downward)
@@ -1041,7 +1036,7 @@ msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select
  * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
  * Return "TRUE" if the player notices anything
  */
-bool apply_disenchant(int mode)
+bool apply_disenchant(BIT_FLAGS mode)
 {
        int             t = 0;
        object_type     *o_ptr;
@@ -1242,7 +1237,7 @@ void apply_nexus(monster_type *m_ptr)
  */
 void phlogiston(void)
 {
-       int max_flog = 0;
+       GAME_TURN max_flog = 0;
        object_type * o_ptr = &inventory[INVEN_LITE];
 
        /* It's a lamp */
@@ -1271,7 +1266,7 @@ void phlogiston(void)
        }
 
        /* Refuel */
-       o_ptr->xtra4 += (max_flog / 2);
+       o_ptr->xtra4 += (XTRA16)(max_flog / 2);
 
        /* Message */
        msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
@@ -1279,7 +1274,7 @@ void phlogiston(void)
        /* Comment */
        if (o_ptr->xtra4 >= max_flog)
        {
-               o_ptr->xtra4 = max_flog;
+               o_ptr->xtra4 = (XTRA16)max_flog;
                msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
        }
 
@@ -1347,7 +1342,7 @@ void brand_weapon(int brand_type)
                                act = _("は鋭さを増した!", "becomes very sharp!");
 
                                o_ptr->name2 = EGO_SHARPNESS;
-                               o_ptr->pval = m_bonus(5, dun_level) + 1;
+                               o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, dun_level) + 1;
 
                                if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
                                        o_ptr->pval = 2;
@@ -1356,7 +1351,7 @@ void brand_weapon(int brand_type)
                        {
                                act = _("は破壊力を増した!", "seems very powerful.");
                                o_ptr->name2 = EGO_EARTHQUAKES;
-                               o_ptr->pval = m_bonus(3, dun_level);
+                               o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, dun_level);
                        }
                        break;
                case 16:
@@ -1676,13 +1671,13 @@ void call_the_(void)
  * @param require_los 射線の通りを要求するならばTRUE
  * @return なし
  */
-void fetch(int dir, int wgt, bool require_los)
+void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
 {
-       int             ty, tx;
-       DEPTH i;
-       cave_type       *c_ptr;
-       object_type     *o_ptr;
-       char            o_name[MAX_NLEN];
+       POSITION ty, tx;
+       OBJECT_IDX i;
+       cave_type *c_ptr;
+       object_type *o_ptr;
+       char o_name[MAX_NLEN];
 
        /* Check to see if an object is already there */
        if (cave[p_ptr->y][p_ptr->x].o_idx)
@@ -1764,6 +1759,7 @@ void fetch(int dir, int wgt, bool require_los)
        i = c_ptr->o_idx;
        c_ptr->o_idx = o_ptr->next_o_idx;
        cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
+
        o_ptr->next_o_idx = 0;
        o_ptr->iy = (byte)p_ptr->y;
        o_ptr->ix = (byte)p_ptr->x;
@@ -2297,7 +2293,7 @@ bool enchant(object_type *o_ptr, int n, int eflag)
  * Note that "num_ac" requires armour, else weapon
  * Returns TRUE if attempted, FALSE if cancelled
  */
-bool enchant_spell(int num_hit, int num_dam, int num_ac)
+bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
 {
        OBJECT_IDX item;
        bool        okay = FALSE;
@@ -3024,7 +3020,7 @@ bool recharge(int power)
                         */
                        if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
                        {
-                               recharge_amount /= o_ptr->number;
+                               recharge_amount /= (TIME_EFFECT)o_ptr->number;
                                if (recharge_amount < 1) recharge_amount = 1;
                        }
 
@@ -3908,7 +3904,7 @@ int mod_need_mana(int need_mana, int spell, int realm)
  * @return 失敗率(%)
  * @todo 統合を検討
  */
-int mod_spell_chance_1(int chance)
+PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
 {
        chance += p_ptr->to_m_chance;
 
@@ -3933,7 +3929,7 @@ int mod_spell_chance_1(int chance)
  * Note: variable "chance" cannot be negative.
  * @todo 統合を検討
  */
-int mod_spell_chance_2(int chance)
+PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
 {
        if (p_ptr->dec_mana) chance--;
 
@@ -3950,12 +3946,12 @@ int mod_spell_chance_2(int chance)
  * @param use_realm 魔法領域ID
  * @return 失敗率(%)
  */
-s16b spell_chance(int spell, int use_realm)
+PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
 {
-       int             chance, minfail;
+       PERCENTAGE chance, minfail;
        const magic_type *s_ptr;
-       int             need_mana;
-       int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
+       MANA_POINT need_mana;
+       PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
 
 
        /* Paranoia -- must be literate */
@@ -4685,7 +4681,7 @@ static int minus_ac(void)
  * @param aura オーラよるダメージが原因ならばTRUE
  * @return 修正HPダメージ量
  */
-int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
+int acid_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
 {
        int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
@@ -4735,7 +4731,7 @@ int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
  * @param aura オーラよるダメージが原因ならばTRUE
  * @return 修正HPダメージ量
  */
-int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
+int elec_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
 {
        int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
@@ -4784,7 +4780,7 @@ int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
  * @param aura オーラよるダメージが原因ならばTRUE
  * @return 修正HPダメージ量
  */
-int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
+int fire_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
 {
        int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
@@ -4833,7 +4829,7 @@ int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
  * @param aura オーラよるダメージが原因ならばTRUE
  * @return 修正HPダメージ量
  */
-int cold_dam(int dam, cptr kb_str, int monspell, bool aura)
+int cold_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
 {
        int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
@@ -5235,7 +5231,7 @@ bool polymorph_monster(POSITION y, POSITION x)
        /* Handle polymorph */
        if (new_r_idx != old_r_idx)
        {
-               u32b mode = 0L;
+               BIT_FLAGS mode = 0L;
                bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
                s16b this_o_idx, next_o_idx = 0;
 
@@ -5667,7 +5663,7 @@ bool eat_magic(int power)
  * @param mode 召喚オプション
  * @return ターンを消費した場合TRUEを返す
  */
-bool summon_kin_player(int level, int y, int x, u32b mode)
+bool summon_kin_player(int level, int y, int x, BIT_FLAGS mode)
 {
        bool pet = (bool)(mode & PM_FORCE_PET);
        if (!pet) mode |= PM_NO_PET;