From 8dff2aa6ff93dbaf5dc0071ef45522443e0159d9 Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 21 Apr 2019 18:21:29 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20calc=5Fcrit=5Fratio=5Fshot?= =?utf8?q?(),=20calc=5Fexpect=5Fcrit=5Fshot(),=20calc=5Fexpect=5Fcrit()=20?= =?utf8?q?=E3=82=92=20shoot.c/h=20=E3=81=AB=E7=A7=BB=E5=8B=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/bldg.c | 119 +--------------------------------------------------------- src/externs.h | 3 -- src/shoot.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/shoot.h | 3 ++ 4 files changed, 122 insertions(+), 121 deletions(-) diff --git a/src/bldg.c b/src/bldg.c index cdbe68540..bd8438080 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -43,6 +43,7 @@ #include "files.h" #include "player-effects.h" #include "scores.h" +#include "shoot.h" /*! * @brief 闘技場のモンスターID及び報酬アイテムテーブル @@ -2242,124 +2243,6 @@ static void town_history(void) } /*! - * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000 - * @param plus_ammo 矢弾のダメージ修正 - * @param plus_bow 弓のダメージ修正 - * @return ダメージ期待値 - * @note 基本ダメージ量と重量はこの部位では計算に加わらない。 - */ -HIT_POINT calc_crit_ratio_shot(HIT_POINT plus_ammo, HIT_POINT plus_bow) -{ - HIT_POINT i; - object_type *j_ptr = &inventory[INVEN_BOW]; - - /* Extract "shot" power */ - i = p_ptr->to_h_b + plus_ammo; - - if (p_ptr->tval_ammo == TV_BOLT) - i = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ); - else - i = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ); - - /* Snipers can shot more critically with crossbows */ - if (p_ptr->concent) i += ((i * p_ptr->concent) / 5); - if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->tval_ammo == TV_BOLT)) i *= 2; - - /* Good bow makes more critical */ - i += plus_bow * 8 * (p_ptr->concent ? p_ptr->concent + 5 : 5); - - if (i < 0) i = 0; - - return i; -} - -/*! - * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000 - * @param weight 武器の重量 - * @param plus_ammo 矢弾のダメージ修正 - * @param plus_bow 弓のダメージ修正 - * @param dam 基本ダメージ量 - * @return ダメージ期待値 - */ -HIT_POINT calc_expect_crit_shot(WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam) -{ - u32b num; - int i, k, crit; - i = calc_crit_ratio_shot(plus_ammo, plus_bow); - - k = 0; - num = 0; - - crit = MIN(500, 900/weight); - num += dam * 3 /2 * crit; - k = crit; - - crit = MIN(500, 1350/weight); - crit -= k; - num += dam * 2 * crit; - k += crit; - - if(k < 500) - { - crit = 500 - k; - num += dam * 3 * crit; - } - - num /= 500; - - num *= i; - num += (10000 - i) * dam; - num /= 10000; - - return num; -} - -/*! - * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000 - * @param weight 武器の重量 - * @param plus 武器のダメージ修正 - * @param dam 基本ダメージ - * @param meichuu 命中値 - * @param dokubari 毒針処理か否か - * @return ダメージ期待値 - */ -HIT_POINT calc_expect_crit(WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari) -{ - u32b k, num; - int i; - - if(dokubari) return dam; - - i = (weight + (meichuu * 3 + plus * 5) + p_ptr->skill_thn); - if (i < 0) i = 0; - - k = weight; - num = 0; - - if (k < 400) num += (2 * dam + 5) * (400 - k); - if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k)); - if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k)); - if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k)); - if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650)); - - num /= 650; - if(p_ptr->pclass == CLASS_NINJA) - { - num *= i; - num += (4444 - i) * dam; - num /= 4444; - } - else - { - num *= i; - num += (5000 - i) * dam; - num /= 5000; - } - - return num; -} - -/*! * @brief 攻撃時スレイによるダメージ期待値修正計算 / critical happens at i / 10000 * @param dam 基本ダメージ * @param mult スレイ倍率(掛け算部分) diff --git a/src/externs.h b/src/externs.h index 697ff1a16..e143e3d98 100644 --- a/src/externs.h +++ b/src/externs.h @@ -775,9 +775,6 @@ extern bool fire_crimson(void); extern void update_gambling_monsters(void); extern void do_cmd_bldg(void); extern bool tele_town(void); -extern HIT_POINT calc_crit_ratio_shot(HIT_POINT plus_ammo, HIT_POINT plus_bow); -extern HIT_POINT calc_expect_crit_shot(WEIGHT weight, int plus_ammo,int plus_bow, HIT_POINT dam); -extern HIT_POINT calc_expect_crit(WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari); /* xtra1.c */ diff --git a/src/shoot.c b/src/shoot.c index edb107c74..b74c4c298 100644 --- a/src/shoot.c +++ b/src/shoot.c @@ -1126,3 +1126,121 @@ int bow_tmul(OBJECT_SUBTYPE_VALUE sval) } +/*! + * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000 + * @param plus_ammo 矢弾のダメージ修正 + * @param plus_bow 弓のダメージ修正 + * @return ダメージ期待値 + * @note 基本ダメージ量と重量はこの部位では計算に加わらない。 + */ +HIT_POINT calc_crit_ratio_shot(HIT_POINT plus_ammo, HIT_POINT plus_bow) +{ + HIT_POINT i; + object_type *j_ptr = &inventory[INVEN_BOW]; + + /* Extract "shot" power */ + i = p_ptr->to_h_b + plus_ammo; + + if (p_ptr->tval_ammo == TV_BOLT) + i = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ); + else + i = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ); + + /* Snipers can shot more critically with crossbows */ + if (p_ptr->concent) i += ((i * p_ptr->concent) / 5); + if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->tval_ammo == TV_BOLT)) i *= 2; + + /* Good bow makes more critical */ + i += plus_bow * 8 * (p_ptr->concent ? p_ptr->concent + 5 : 5); + + if (i < 0) i = 0; + + return i; +} + +/*! + * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000 + * @param weight 武器の重量 + * @param plus_ammo 矢弾のダメージ修正 + * @param plus_bow 弓のダメージ修正 + * @param dam 基本ダメージ量 + * @return ダメージ期待値 + */ +HIT_POINT calc_expect_crit_shot(WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam) +{ + u32b num; + int i, k, crit; + i = calc_crit_ratio_shot(plus_ammo, plus_bow); + + k = 0; + num = 0; + + crit = MIN(500, 900 / weight); + num += dam * 3 / 2 * crit; + k = crit; + + crit = MIN(500, 1350 / weight); + crit -= k; + num += dam * 2 * crit; + k += crit; + + if (k < 500) + { + crit = 500 - k; + num += dam * 3 * crit; + } + + num /= 500; + + num *= i; + num += (10000 - i) * dam; + num /= 10000; + + return num; +} + +/*! + * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000 + * @param weight 武器の重量 + * @param plus 武器のダメージ修正 + * @param dam 基本ダメージ + * @param meichuu 命中値 + * @param dokubari 毒針処理か否か + * @return ダメージ期待値 + */ +HIT_POINT calc_expect_crit(WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari) +{ + u32b k, num; + int i; + + if (dokubari) return dam; + + i = (weight + (meichuu * 3 + plus * 5) + p_ptr->skill_thn); + if (i < 0) i = 0; + + k = weight; + num = 0; + + if (k < 400) num += (2 * dam + 5) * (400 - k); + if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k)); + if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k)); + if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k)); + if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650)); + + num /= 650; + if (p_ptr->pclass == CLASS_NINJA) + { + num *= i; + num += (4444 - i) * dam; + num /= 4444; + } + else + { + num *= i; + num += (5000 - i) * dam; + num /= 5000; + } + + return num; +} + diff --git a/src/shoot.h b/src/shoot.h index 0c99a7f95..13a4c7051 100644 --- a/src/shoot.h +++ b/src/shoot.h @@ -7,3 +7,6 @@ extern bool test_hit_fire(int chance, monster_type *m_ptr, int vis, char* o_name extern HIT_POINT critical_shot(WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam); extern ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval); extern int bow_tmul(OBJECT_SUBTYPE_VALUE sval); +extern HIT_POINT calc_crit_ratio_shot(HIT_POINT plus_ammo, HIT_POINT plus_bow); +extern HIT_POINT calc_expect_crit_shot(WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam); +extern HIT_POINT calc_expect_crit(WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari); -- 2.11.0