OSDN Git Service

Merge remote-tracking branch 'remotes/hengbandosx/english-mind-edits' into feature...
[hengband/hengband.git] / src / player / temporary-resistances.c
1 #include "temporary-resistances.h"
2 #include "object-enchant/tr-types.h"
3 #include "player/attack-defense-types.h"
4 #include "player/player-race-types.h"
5 #include "player/player-race.h"
6 #include "player/special-defense-types.h"
7 #include "realm/realm-hex-numbers.h"
8 #include "realm/realm-song-numbers.h"
9 #include "realm/realm-types.h"
10 #include "spell-realm/spells-hex.h"
11 #include "status/element-resistance.h"
12 #include "system/object-type-definition.h"
13 #include "util/bit-flags-calculator.h"
14
15 /*!
16  * @brief プレイヤーの一時的魔法効果による耐性を返す
17  * Prints ratings on certain abilities
18  * @param creature_ptr プレーヤーへの参照ポインタ
19  * @param flags フラグを保管する配列
20  * @return なし
21  * @todo
22  * xtra1.c周りと多重実装になっているのを何とかする
23  */
24 void tim_player_flags(player_type *creature_ptr, BIT_FLAGS *flags)
25 {
26     for (int i = 0; i < TR_FLAG_SIZE; i++)
27         flags[i] = 0L;
28
29     if (is_hero(creature_ptr) || is_shero(creature_ptr))
30         add_flag(flags, TR_RES_FEAR);
31     if (creature_ptr->tim_infra)
32         add_flag(flags, TR_INFRA);
33     if (creature_ptr->tim_invis)
34         add_flag(flags, TR_SEE_INVIS);
35     if (creature_ptr->tim_regen)
36         add_flag(flags, TR_REGEN);
37     if (is_time_limit_esp(creature_ptr))
38         add_flag(flags, TR_TELEPATHY);
39     if (is_fast(creature_ptr) || creature_ptr->slow)
40         add_flag(flags, TR_SPEED);
41
42     if (is_oppose_acid(creature_ptr) && !(creature_ptr->special_defense & DEFENSE_ACID)
43         && !(is_specific_player_race(creature_ptr, RACE_YEEK) && (creature_ptr->lev > 19)))
44         add_flag(flags, TR_RES_ACID);
45     if (is_oppose_elec(creature_ptr) && !(creature_ptr->special_defense & DEFENSE_ELEC))
46         add_flag(flags, TR_RES_ELEC);
47     if (is_oppose_fire(creature_ptr) && !(creature_ptr->special_defense & DEFENSE_FIRE))
48         add_flag(flags, TR_RES_FIRE);
49     if (is_oppose_cold(creature_ptr) && !(creature_ptr->special_defense & DEFENSE_COLD))
50         add_flag(flags, TR_RES_COLD);
51     if (is_oppose_pois(creature_ptr))
52         add_flag(flags, TR_RES_POIS);
53
54     if (creature_ptr->special_attack & ATTACK_ACID)
55         add_flag(flags, TR_BRAND_ACID);
56     if (creature_ptr->special_attack & ATTACK_ELEC)
57         add_flag(flags, TR_BRAND_ELEC);
58     if (creature_ptr->special_attack & ATTACK_FIRE)
59         add_flag(flags, TR_BRAND_FIRE);
60     if (creature_ptr->special_attack & ATTACK_COLD)
61         add_flag(flags, TR_BRAND_COLD);
62     if (creature_ptr->special_attack & ATTACK_POIS)
63         add_flag(flags, TR_BRAND_POIS);
64     if (creature_ptr->special_defense & DEFENSE_ACID)
65         add_flag(flags, TR_IM_ACID);
66     if (creature_ptr->special_defense & DEFENSE_ELEC)
67         add_flag(flags, TR_IM_ELEC);
68     if (creature_ptr->special_defense & DEFENSE_FIRE)
69         add_flag(flags, TR_IM_FIRE);
70     if (creature_ptr->special_defense & DEFENSE_COLD)
71         add_flag(flags, TR_IM_COLD);
72     if (creature_ptr->wraith_form)
73         add_flag(flags, TR_REFLECT);
74     if (creature_ptr->tim_reflect)
75         add_flag(flags, TR_REFLECT);
76
77     if (creature_ptr->magicdef) {
78         add_flag(flags, TR_RES_BLIND);
79         add_flag(flags, TR_RES_CONF);
80         add_flag(flags, TR_REFLECT);
81         add_flag(flags, TR_FREE_ACT);
82         add_flag(flags, TR_LEVITATION);
83     }
84
85     if (creature_ptr->tim_res_nether)
86         add_flag(flags, TR_RES_NETHER);
87
88     if (creature_ptr->tim_sh_fire)
89         add_flag(flags, TR_SH_FIRE);
90
91     if (creature_ptr->ult_res) {
92         add_flag(flags, TR_RES_FEAR);
93         add_flag(flags, TR_RES_LITE);
94         add_flag(flags, TR_RES_DARK);
95         add_flag(flags, TR_RES_BLIND);
96         add_flag(flags, TR_RES_CONF);
97         add_flag(flags, TR_RES_SOUND);
98         add_flag(flags, TR_RES_SHARDS);
99         add_flag(flags, TR_RES_NETHER);
100         add_flag(flags, TR_RES_NEXUS);
101         add_flag(flags, TR_RES_CHAOS);
102         add_flag(flags, TR_RES_DISEN);
103         add_flag(flags, TR_REFLECT);
104         add_flag(flags, TR_HOLD_EXP);
105         add_flag(flags, TR_FREE_ACT);
106         add_flag(flags, TR_SH_FIRE);
107         add_flag(flags, TR_SH_ELEC);
108         add_flag(flags, TR_SH_COLD);
109         add_flag(flags, TR_LEVITATION);
110         add_flag(flags, TR_LITE_1);
111         add_flag(flags, TR_SEE_INVIS);
112         add_flag(flags, TR_TELEPATHY);
113         add_flag(flags, TR_SLOW_DIGEST);
114         add_flag(flags, TR_REGEN);
115         add_flag(flags, TR_SUST_STR);
116         add_flag(flags, TR_SUST_INT);
117         add_flag(flags, TR_SUST_WIS);
118         add_flag(flags, TR_SUST_DEX);
119         add_flag(flags, TR_SUST_CON);
120         add_flag(flags, TR_SUST_CHR);
121     }
122
123     if (creature_ptr->realm1 != REALM_HEX)
124         return;
125
126     if (hex_spelling(creature_ptr, HEX_DEMON_AURA)) {
127         add_flag(flags, TR_SH_FIRE);
128         add_flag(flags, TR_REGEN);
129     }
130
131     if (hex_spelling(creature_ptr, HEX_ICE_ARMOR))
132         add_flag(flags, TR_SH_COLD);
133     if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK))
134         add_flag(flags, TR_SH_ELEC);
135 }