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)
68 if (is_immune_acid(creature_ptr)) {
72 BIT_FLAGS flgs = is_vuln_acid(creature_ptr);
73 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
74 if (flgs & (0x01 << i)) {
75 if (i == FLAG_CAUSE_MUTATION) {
83 if (creature_ptr->resist_acid)
85 if (is_oppose_acid(creature_ptr))
92 * @brief 電撃属性攻撃に対するダメージ倍率計算
94 PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
99 if (is_immune_elec(creature_ptr)) {
103 BIT_FLAGS flgs = is_vuln_elec(creature_ptr);
104 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
105 if (flgs & (0x01 << i)) {
106 if (i == FLAG_CAUSE_MUTATION) {
114 if (creature_ptr->resist_elec)
116 if (is_oppose_elec(creature_ptr))
123 * @brief 火炎属性攻撃に対するダメージ倍率計算
125 PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
127 PERCENTAGE per = 100;
129 BIT_FLAGS flgs = is_vuln_fire(creature_ptr);
130 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
131 if (flgs & (0x01 << i)) {
132 if (i == FLAG_CAUSE_MUTATION) {
140 /* Resist the damage */
141 if (creature_ptr->resist_fire)
143 if (is_oppose_fire(creature_ptr))
150 * @brief 冷気属性攻撃に対するダメージ倍率計算
152 PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
154 PERCENTAGE per = 100;
156 BIT_FLAGS flgs = is_vuln_cold(creature_ptr);
157 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
158 if (flgs & (0x01 << i)) {
159 if (i == FLAG_CAUSE_MUTATION) {
167 if (creature_ptr->resist_cold)
169 if (is_oppose_cold(creature_ptr))
176 * @brief 毒属性攻撃に対するダメージ倍率計算
178 PERCENTAGE calc_pois_damage_rate(player_type *creature_ptr)
180 PERCENTAGE per = 100;
181 if (creature_ptr->resist_pois)
183 if (is_oppose_pois(creature_ptr))
190 * @brief 放射性廃棄物攻撃に対するダメージ倍率計算
192 PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
195 PERCENTAGE per = 100;
196 if (creature_ptr->resist_pois)
197 per = (2 * per + 2) / 5;
198 if (is_oppose_pois(creature_ptr))
199 per = (2 * per + 2) / 5;
205 * @brief 死の光線に対するダメージ倍率計算
207 PERCENTAGE calc_deathray_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
210 if (creature_ptr->mimic_form) {
211 if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) {
216 switch (creature_ptr->prace) {
231 * @brief 閃光属性攻撃に対するダメージ倍率計算
233 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
235 PERCENTAGE per = 100;
236 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
238 } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
242 if (creature_ptr->resist_lite) {
244 per /= randrate(4, 7, mode);
247 if (creature_ptr->wraith_form)
254 * @brief 暗黒属性攻撃に対するダメージ倍率計算
256 PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
258 PERCENTAGE per = 100;
260 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE) || creature_ptr->wraith_form) {
264 if (creature_ptr->resist_dark) {
266 per /= randrate(4, 7, mode);
273 * @brief 破片属性攻撃に対するダメージ倍率計算
275 PERCENTAGE calc_shards_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
277 PERCENTAGE per = 100;
279 if (creature_ptr->resist_shard) {
281 per /= randrate(4, 7, mode);
288 * @brief 轟音属性攻撃に対するダメージ倍率計算
290 PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
292 PERCENTAGE per = 100;
294 if (creature_ptr->resist_sound) {
296 per /= randrate(4, 7, mode);
303 * @brief 混乱属性攻撃に対するダメージ倍率計算
305 PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
307 PERCENTAGE per = 100;
309 if (creature_ptr->resist_conf) {
311 per /= randrate(4, 7, mode);
318 * @brief 混沌属性攻撃に対するダメージ倍率計算
320 PERCENTAGE calc_chaos_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
322 PERCENTAGE per = 100;
324 if (creature_ptr->resist_chaos) {
326 per /= randrate(4, 7, mode);
333 * @brief 劣化属性攻撃に対するダメージ倍率計算
335 PERCENTAGE calc_disenchant_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
337 PERCENTAGE per = 100;
339 if (creature_ptr->resist_disen) {
341 per /= randrate(4, 7, mode);
348 * @brief 因果混乱属性攻撃に対するダメージ倍率計算
350 PERCENTAGE calc_nexus_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
352 PERCENTAGE per = 100;
354 if (creature_ptr->resist_disen) {
356 per /= randrate(4, 7, mode);
363 * @brief ロケット属性攻撃に対するダメージ倍率計算
365 PERCENTAGE calc_rocket_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
368 PERCENTAGE per = 100;
370 if (creature_ptr->resist_shard) {
378 * @brief 地獄属性攻撃に対するダメージ倍率計算
380 PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
382 PERCENTAGE per = 100;
384 if (creature_ptr->resist_neth) {
385 if (!is_specific_player_race(creature_ptr, RACE_SPECTRE))
388 per /= randrate(4, 7, mode);
396 * @brief 時間逆転攻撃に対するダメージ倍率計算
398 PERCENTAGE calc_time_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
401 PERCENTAGE per = 100;
403 if (creature_ptr->resist_time) {
405 per /= randrate(4, 7, mode);
412 * @brief 聖なる火炎攻撃に対するダメージ倍率計算
414 PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
417 PERCENTAGE per = 100;
418 if (creature_ptr->align > 10)
420 else if (creature_ptr->align < -10)
426 * @brief 地獄の火炎攻撃に対するダメージ倍率計算
428 PERCENTAGE calc_hell_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
431 PERCENTAGE per = 100;
432 if (creature_ptr->align > 10)
438 * @brief 重力攻撃に対するダメージ倍率計算
440 PERCENTAGE calc_gravity_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
443 PERCENTAGE per = 100;
444 if (creature_ptr->levitation) {