2 * @brief モンスターから直接攻撃を受けた時に、プレーヤーのオーラダメージで反撃する処理
7 #include "combat/aura-counterattack.h"
8 #include "effect/effect-characteristics.h"
9 #include "floor/floor.h"
10 #include "grid/grid.h"
11 #include "monster-race/monster-race.h"
12 #include "monster-race/race-flags-resistance.h"
13 #include "monster-race/race-flags3.h"
14 #include "monster/monster-status.h"
15 #include "monster/monster-info.h"
16 #include "object-hook/hook-armor.h"
17 #include "object/object-hook.h"
18 #include "realm/realm-hex-numbers.h"
19 #include "spell/process-effect.h"
20 #include "spell-realm/spells-hex.h"
21 #include "spell-kind/spells-teleport.h"
22 #include "spell/spell-types.h"
23 #include "view/display-messages.h"
25 static void aura_fire_by_monster_attack(player_type *target_ptr, monap_type *monap_ptr)
27 if (!target_ptr->sh_fire || !monap_ptr->alive || target_ptr->is_dead)
30 monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
31 if ((r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK) != 0) {
32 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
33 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
38 HIT_POINT dam = damroll(2, 6);
39 dam = mon_damage_mod(target_ptr, monap_ptr->m_ptr, dam, FALSE);
40 msg_format(_("%^sは突然熱くなった!", "%^s is suddenly very hot!"), monap_ptr->m_name);
41 if (mon_take_hit(target_ptr, monap_ptr->m_idx, dam, &monap_ptr->fear, _("は灰の山になった。", " turns into a pile of ash."))) {
42 monap_ptr->blinked = FALSE;
43 monap_ptr->alive = FALSE;
47 static void aura_elec_by_monster_attack(player_type *target_ptr, monap_type *monap_ptr)
49 if (!target_ptr->sh_elec || !monap_ptr->alive || target_ptr->is_dead)
52 monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
53 if ((r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK) != 0) {
54 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
55 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
60 HIT_POINT dam = damroll(2, 6);
61 dam = mon_damage_mod(target_ptr, monap_ptr->m_ptr, dam, FALSE);
62 msg_format(_("%^sは電撃をくらった!", "%^s gets zapped!"), monap_ptr->m_name);
63 if (mon_take_hit(target_ptr, monap_ptr->m_idx, dam, &monap_ptr->fear, _("は燃え殻の山になった。", " turns into a pile of cinder."))) {
64 monap_ptr->blinked = FALSE;
65 monap_ptr->alive = FALSE;
69 static void aura_cold_by_monster_attack(player_type *target_ptr, monap_type *monap_ptr)
71 if (!target_ptr->sh_cold || !monap_ptr->alive || target_ptr->is_dead)
74 monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
75 if ((r_ptr->flagsr & RFR_EFF_IM_COLD_MASK) != 0) {
76 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
77 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
82 HIT_POINT dam = damroll(2, 6);
83 dam = mon_damage_mod(target_ptr, monap_ptr->m_ptr, dam, FALSE);
84 msg_format(_("%^sは冷気をくらった!", "%^s is very cold!"), monap_ptr->m_name);
85 if (mon_take_hit(target_ptr, monap_ptr->m_idx, dam, &monap_ptr->fear, _("は凍りついた。", " was frozen."))) {
86 monap_ptr->blinked = FALSE;
87 monap_ptr->alive = FALSE;
91 static void aura_shards_by_monster_attack(player_type *target_ptr, monap_type *monap_ptr)
93 if (!target_ptr->dustrobe || !monap_ptr->alive || target_ptr->is_dead)
96 monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
97 if ((r_ptr->flagsr & RFR_EFF_RES_SHAR_MASK) != 0) {
98 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
99 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_RES_SHAR_MASK);
101 HIT_POINT dam = damroll(2, 6);
102 dam = mon_damage_mod(target_ptr, monap_ptr->m_ptr, dam, FALSE);
103 msg_format(_("%^sは鏡の破片をくらった!", "%^s gets zapped!"), monap_ptr->m_name);
104 if (mon_take_hit(target_ptr, monap_ptr->m_idx, dam, &monap_ptr->fear, _("はズタズタになった。", " had torn to pieces."))) {
105 monap_ptr->blinked = FALSE;
106 monap_ptr->alive = FALSE;
110 if (is_mirror_grid(&target_ptr->current_floor_ptr->grid_array[target_ptr->y][target_ptr->x]))
111 teleport_player(target_ptr, 10, TELEPORT_SPONTANEOUS);
114 static void aura_holy_by_monster_attack(player_type *target_ptr, monap_type *monap_ptr)
116 if (!target_ptr->tim_sh_holy || !monap_ptr->alive || target_ptr->is_dead)
119 monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
120 if ((r_ptr->flags3 & RF3_EVIL) == 0)
123 if ((r_ptr->flagsr & RFR_RES_ALL) != 0) {
124 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
125 r_ptr->r_flagsr |= RFR_RES_ALL;
130 HIT_POINT dam = damroll(2, 6);
131 dam = mon_damage_mod(target_ptr, monap_ptr->m_ptr, dam, FALSE);
132 msg_format(_("%^sは聖なるオーラで傷ついた!", "%^s is injured by holy power!"), monap_ptr->m_name);
133 if (mon_take_hit(target_ptr, monap_ptr->m_idx, dam, &monap_ptr->fear, _("は倒れた。", " is destroyed."))) {
134 monap_ptr->blinked = FALSE;
135 monap_ptr->alive = FALSE;
138 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
139 r_ptr->r_flags3 |= RF3_EVIL;
142 static void aura_force_by_monster_attack(player_type *target_ptr, monap_type *monap_ptr)
144 if (!target_ptr->tim_sh_touki || !monap_ptr->alive || target_ptr->is_dead)
147 monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
148 if ((r_ptr->flagsr & RFR_RES_ALL) != 0) {
149 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
150 r_ptr->r_flagsr |= RFR_RES_ALL;
155 HIT_POINT dam = damroll(2, 6);
156 dam = mon_damage_mod(target_ptr, monap_ptr->m_ptr, dam, FALSE);
157 msg_format(_("%^sが鋭い闘気のオーラで傷ついた!", "%^s is injured by the Force"), monap_ptr->m_name);
158 if (mon_take_hit(target_ptr, monap_ptr->m_idx, dam, &monap_ptr->fear, _("は倒れた。", " is destroyed."))) {
159 monap_ptr->blinked = FALSE;
160 monap_ptr->alive = FALSE;
164 static void aura_shadow_by_monster_attack(player_type *target_ptr, monap_type *monap_ptr)
166 if (!hex_spelling(target_ptr, HEX_SHADOW_CLOAK) || !monap_ptr->alive || target_ptr->is_dead)
170 object_type *o_armed_ptr = &target_ptr->inventory_list[INVEN_RARM];
171 monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
172 if (((r_ptr->flagsr & RFR_RES_ALL) != 0) || ((r_ptr->flagsr & RFR_RES_DARK) != 0)) {
173 if (is_original_ap_and_seen(target_ptr, monap_ptr->m_ptr))
174 r_ptr->r_flagsr |= (RFR_RES_ALL | RFR_RES_DARK);
179 if (o_armed_ptr->k_idx) {
180 int basedam = ((o_armed_ptr->dd + target_ptr->to_dd[0]) * (o_armed_ptr->ds + target_ptr->to_ds[0] + 1));
181 dam = basedam / 2 + o_armed_ptr->to_d + target_ptr->to_d[0];
184 o_armed_ptr = &target_ptr->inventory_list[INVEN_BODY];
185 if ((o_armed_ptr->k_idx) && object_is_cursed(o_armed_ptr))
188 dam = mon_damage_mod(target_ptr, monap_ptr->m_ptr, dam, FALSE);
189 msg_format(_("影のオーラが%^sに反撃した!", "Enveloping shadows attack %^s."), monap_ptr->m_name);
190 if (mon_take_hit(target_ptr, monap_ptr->m_idx, dam, &monap_ptr->fear, _("は倒れた。", " is destroyed."))) {
191 monap_ptr->blinked = FALSE;
192 monap_ptr->alive = FALSE;
196 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
197 EFFECT_ID typ[4][2] = { { INVEN_HEAD, GF_OLD_CONF }, { INVEN_LARM, GF_OLD_SLEEP }, { INVEN_HANDS, GF_TURN_ALL }, { INVEN_FEET, GF_OLD_SLOW } };
199 /* Some cursed armours gives an extra effect */
200 for (int j = 0; j < 4; j++) {
201 o_armed_ptr = &target_ptr->inventory_list[typ[j][0]];
202 if ((o_armed_ptr->k_idx) && object_is_cursed(o_armed_ptr) && object_is_armour(target_ptr, o_armed_ptr))
203 project(target_ptr, 0, 0, monap_ptr->m_ptr->fy, monap_ptr->m_ptr->fx, (target_ptr->lev * 2), typ[j][1], flg, -1);
207 void process_aura_counterattack(player_type *target_ptr, monap_type *monap_ptr)
209 if (!monap_ptr->touched)
212 aura_fire_by_monster_attack(target_ptr, monap_ptr);
213 aura_elec_by_monster_attack(target_ptr, monap_ptr);
214 aura_cold_by_monster_attack(target_ptr, monap_ptr);
215 aura_shards_by_monster_attack(target_ptr, monap_ptr);
216 aura_holy_by_monster_attack(target_ptr, monap_ptr);
217 aura_force_by_monster_attack(target_ptr, monap_ptr);
218 aura_shadow_by_monster_attack(target_ptr, monap_ptr);