1 #include "player/player-status-resist.h"
2 #include "player/mimic-info-table.h"
3 #include "art-definition/art-sword-types.h"
5 #include "inventory/inventory-slot-types.h"
6 #include "monster-race/monster-race.h"
7 #include "monster-race/race-flags2.h"
8 #include "monster-race/race-flags7.h"
9 #include "mutation/mutation-flag-types.h"
10 #include "object-enchant/object-ego.h"
11 #include "object-enchant/tr-types.h"
12 #include "object-enchant/trc-types.h"
13 #include "object-hook/hook-checker.h"
14 #include "object-hook/hook-weapon.h"
15 #include "object/object-flags.h"
16 #include "player/player-class.h"
17 #include "player/player-race-types.h"
18 #include "player/player-race.h"
19 #include "player/player-skill.h"
20 #include "player/player-status-flags.h"
21 #include "player/player-status.h"
22 #include "player/special-defense-types.h"
23 #include "realm/realm-hex-numbers.h"
24 #include "realm/realm-song-numbers.h"
25 #include "realm/realm-types.h"
26 #include "spell-realm/spells-hex.h"
27 #include "status/element-resistance.h"
28 #include "sv-definition/sv-weapon-types.h"
29 #include "system/floor-type-definition.h"
30 #include "system/monster-type-definition.h"
31 #include "system/object-type-definition.h"
32 #include "util/bit-flags-calculator.h"
33 #include "util/quarks.h"
34 #include "util/string-processor.h"
37 * @brief 耐性倍率計算の用途に応じた分岐処理
39 PERCENTAGE randrate(int dice, int fix, rate_calc_type_mode mode)
43 return randint1(dice) * 100 + fix * 100;
46 return (dice + 1) * 50 + fix * 100;
49 return (fix + 1) * 100;
52 return (dice + fix) * 100;
55 return (fix + 1) * 100;
61 * @brief 酸属性攻撃に対するダメージ倍率計算
63 PERCENTAGE calc_acid_damage_rate(player_type *creature_ptr)
67 if (has_immune_acid(creature_ptr)) {
71 BIT_FLAGS flgs = has_vuln_acid(creature_ptr);
72 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
73 if (flgs & (0x01 << i)) {
74 if (i == FLAG_CAUSE_MUTATION) {
82 if (creature_ptr->resist_acid)
84 if (is_oppose_acid(creature_ptr))
91 * @brief 電撃属性攻撃に対するダメージ倍率計算
93 PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
97 if (has_immune_elec(creature_ptr)) {
101 BIT_FLAGS flgs = has_vuln_elec(creature_ptr);
102 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
103 if (flgs & (0x01 << i)) {
104 if (i == FLAG_CAUSE_MUTATION) {
112 if (creature_ptr->resist_elec)
114 if (is_oppose_elec(creature_ptr))
121 * @brief 火炎属性攻撃に対するダメージ倍率計算
123 PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
125 PERCENTAGE per = 100;
126 BIT_FLAGS flgs = has_vuln_fire(creature_ptr);
127 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
128 if (flgs & (0x01 << i)) {
129 if (i == FLAG_CAUSE_MUTATION) {
137 /* Resist the damage */
138 if (creature_ptr->resist_fire)
140 if (is_oppose_fire(creature_ptr))
147 * @brief 冷気属性攻撃に対するダメージ倍率計算
149 PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
151 PERCENTAGE per = 100;
152 BIT_FLAGS flgs = has_vuln_cold(creature_ptr);
153 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
154 if (flgs & (0x01 << i)) {
155 if (i == FLAG_CAUSE_MUTATION) {
163 if (creature_ptr->resist_cold)
165 if (is_oppose_cold(creature_ptr))
172 * @brief 毒属性攻撃に対するダメージ倍率計算
174 PERCENTAGE calc_pois_damage_rate(player_type *creature_ptr)
176 PERCENTAGE per = 100;
177 if (creature_ptr->resist_pois)
179 if (is_oppose_pois(creature_ptr))
186 * @brief 放射性廃棄物攻撃に対するダメージ倍率計算
188 PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
191 PERCENTAGE per = 100;
192 if (creature_ptr->resist_pois)
193 per = (2 * per + 2) / 5;
194 if (is_oppose_pois(creature_ptr))
195 per = (2 * per + 2) / 5;
201 * @brief 死の光線に対するダメージ倍率計算
203 PERCENTAGE calc_deathray_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
206 if (creature_ptr->mimic_form) {
207 if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) {
212 switch (creature_ptr->prace) {
227 * @brief 閃光属性攻撃に対するダメージ倍率計算
229 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
231 PERCENTAGE per = 100;
232 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
234 } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
238 if (creature_ptr->resist_lite) {
240 per /= randrate(4, 7, mode);
243 if (creature_ptr->wraith_form)
250 * @brief 暗黒属性攻撃に対するダメージ倍率計算
252 PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
254 PERCENTAGE per = 100;
256 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE) || creature_ptr->wraith_form) {
260 if (creature_ptr->resist_dark) {
262 per /= randrate(4, 7, mode);
269 * @brief 破片属性攻撃に対するダメージ倍率計算
271 PERCENTAGE calc_shards_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
273 PERCENTAGE per = 100;
275 if (creature_ptr->resist_shard) {
277 per /= randrate(4, 7, mode);
284 * @brief 轟音属性攻撃に対するダメージ倍率計算
286 PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
288 PERCENTAGE per = 100;
290 if (creature_ptr->resist_sound) {
292 per /= randrate(4, 7, mode);
299 * @brief 混乱属性攻撃に対するダメージ倍率計算
301 PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
303 PERCENTAGE per = 100;
305 if (creature_ptr->resist_conf) {
307 per /= randrate(4, 7, mode);
314 * @brief 混沌属性攻撃に対するダメージ倍率計算
316 PERCENTAGE calc_chaos_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
318 PERCENTAGE per = 100;
320 if (creature_ptr->resist_chaos) {
322 per /= randrate(4, 7, mode);
329 * @brief 劣化属性攻撃に対するダメージ倍率計算
331 PERCENTAGE calc_disenchant_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
333 PERCENTAGE per = 100;
335 if (creature_ptr->resist_disen) {
337 per /= randrate(4, 7, mode);
344 * @brief 因果混乱属性攻撃に対するダメージ倍率計算
346 PERCENTAGE calc_nexus_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
348 PERCENTAGE per = 100;
350 if (creature_ptr->resist_disen) {
352 per /= randrate(4, 7, mode);
359 * @brief ロケット属性攻撃に対するダメージ倍率計算
361 PERCENTAGE calc_rocket_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
364 PERCENTAGE per = 100;
366 if (creature_ptr->resist_shard) {
374 * @brief 地獄属性攻撃に対するダメージ倍率計算
376 PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
378 PERCENTAGE per = 100;
380 if (creature_ptr->resist_neth) {
381 if (!is_specific_player_race(creature_ptr, RACE_SPECTRE))
384 per /= randrate(4, 7, mode);
392 * @brief 時間逆転攻撃に対するダメージ倍率計算
394 PERCENTAGE calc_time_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
397 PERCENTAGE per = 100;
399 if (creature_ptr->resist_time) {
401 per /= randrate(4, 7, mode);
408 * @brief 聖なる火炎攻撃に対するダメージ倍率計算
410 PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
413 PERCENTAGE per = 100;
414 if (creature_ptr->align > 10)
416 else if (creature_ptr->align < -10)
422 * @brief 地獄の火炎攻撃に対するダメージ倍率計算
424 PERCENTAGE calc_hell_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
427 PERCENTAGE per = 100;
428 if (creature_ptr->align > 10)
434 * @brief 重力攻撃に対するダメージ倍率計算
436 PERCENTAGE calc_gravity_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
439 PERCENTAGE per = 100;
440 if (creature_ptr->levitation) {