2 * @brief モンスター魔法の実装(対モンスター処理) / Monster spells (attack monster)
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
9 * 2014 Deskull rearranged comment for Doxygen.
12 #include "mspell/mspell-judgement.h"
13 #include "dungeon/dungeon.h"
14 #include "effect/effect-characteristics.h"
15 #include "floor/cave.h"
16 #include "floor/floor.h"
17 #include "grid/grid.h"
18 #include "main/sound-definitions-table.h"
19 #include "monster-race/monster-race.h"
20 #include "monster-race/race-flags-resistance.h"
21 #include "monster-race/race-flags4.h"
22 #include "monster/monster-info.h"
23 #include "monster/monster-status.h"
24 #include "player/attack-defense-types.h"
25 #include "player/player-race.h"
26 #include "player/special-defense-types.h"
27 #include "realm/realm-song-numbers.h"
28 #include "spell/range-calc.h"
29 #include "spell/spell-types.h"
30 #include "system/floor-type-definition.h"
33 * @brief モンスターが敵対モンスターにビームを当てること可能かを判定する /
34 * Determine if a beam spell will hit the target.
35 * @param target_ptr プレーヤーへの参照ポインタ
40 * @param m_ptr 使用するモンスターの構造体参照ポインタ
41 * @return ビームが到達可能ならばTRUEを返す
43 bool direct_beam(player_type *target_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, monster_type *m_ptr)
45 floor_type *floor_ptr = target_ptr->current_floor_ptr;
47 int grid_n = projection_path(target_ptr, grid_g, get_max_range(target_ptr), y1, x1, y2, x2, PROJECT_THRU);
53 bool is_friend = is_pet(m_ptr);
54 for (int i = 0; i < grid_n; i++) {
55 y = GRID_Y(grid_g[i]);
56 x = GRID_X(grid_g[i]);
58 if (y == y2 && x == x2)
60 else if (is_friend && floor_ptr->grid_array[y][x].m_idx > 0 && !are_enemies(target_ptr, m_ptr, &floor_ptr->m_list[floor_ptr->grid_array[y][x].m_idx])) {
64 if (is_friend && player_bold(target_ptr, y, x))
74 * @brief モンスターが敵対モンスターに直接ブレスを当てることが可能かを判定する /
75 * Determine if a breath will hit the target.
82 * @param is_friend TRUEならば、プレイヤーを巻き込む時にブレスの判定をFALSEにする。
83 * @return ブレスを直接当てられるならばTRUEを返す
85 bool breath_direct(player_type *master_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, POSITION rad, EFFECT_ID typ, bool is_friend)
102 int grid_n = projection_path(master_ptr, grid_g, get_max_range(master_ptr), y1, x1, y2, x2, flg);
106 for (i = 0; i < grid_n; ++i) {
107 int ny = GRID_Y(grid_g[i]);
108 int nx = GRID_X(grid_g[i]);
110 if (flg & PROJECT_DISI) {
111 if (cave_stop_disintegration(master_ptr->current_floor_ptr, ny, nx))
113 } else if (flg & PROJECT_LOS) {
114 if (!cave_los_bold(master_ptr->current_floor_ptr, ny, nx))
117 if (!cave_have_flag_bold(master_ptr->current_floor_ptr, ny, nx, FF_PROJECT))
129 if (flg & PROJECT_DISI) {
130 if (in_disintegration_range(master_ptr->current_floor_ptr, y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad))
132 if (in_disintegration_range(master_ptr->current_floor_ptr, y1, x1, master_ptr->y, master_ptr->x)
133 && (distance(y1, x1, master_ptr->y, master_ptr->x) <= rad))
135 } else if (flg & PROJECT_LOS) {
136 if (los(master_ptr, y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad))
138 if (los(master_ptr, y1, x1, master_ptr->y, master_ptr->x) && (distance(y1, x1, master_ptr->y, master_ptr->x) <= rad))
141 if (projectable(master_ptr, y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad))
143 if (projectable(master_ptr, y1, x1, master_ptr->y, master_ptr->x) && (distance(y1, x1, master_ptr->y, master_ptr->x) <= rad))
148 POSITION gx[1024], gy[1024];
150 POSITION gm_rad = rad;
151 breath_shape(master_ptr, grid_g, grid_n, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, y, x, typ);
152 for (i = 0; i < grids; i++) {
155 if ((y == y2) && (x == x2))
157 if (player_bold(master_ptr, y, x))
164 if (is_friend && hityou)
171 * @brief モンスターが特殊能力の目標地点を決める処理 /
172 * Get the actual center point of ball spells (rad > 1) (originally from TOband)
173 * @param target_ptr プレーヤーへの参照ポインタ
176 * @param ty 目標Y座標を返す参照ポインタ
177 * @param tx 目標X座標を返す参照ポインタ
178 * @param flg 判定のフラグ配列
181 void get_project_point(player_type *target_ptr, POSITION sy, POSITION sx, POSITION *ty, POSITION *tx, BIT_FLAGS flg)
184 int path_n = projection_path(target_ptr, path_g, get_max_range(target_ptr), sy, sx, *ty, *tx, flg);
187 for (int i = 0; i < path_n; i++) {
188 sy = GRID_Y(path_g[i]);
189 sx = GRID_X(path_g[i]);
190 if (!cave_have_flag_bold(target_ptr->current_floor_ptr, sy, sx, FF_PROJECT))
199 * @brief モンスターが敵モンスターに魔力消去を使うかどうかを返す /
200 * Check should monster cast dispel spell at other monster.
201 * @param target_ptr プレーヤーへの参照ポインタ
202 * @param m_idx 術者のモンスターID
203 * @param t_idx 目標のモンスターID
204 * @return 魔力消去を使うべきならばTRUEを変えす。
206 bool dispel_check_monster(player_type *target_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx)
208 monster_type *t_ptr = &target_ptr->current_floor_ptr->m_list[t_idx];
209 if (monster_invulner_remaining(t_ptr))
212 if ((t_ptr->mspeed < 135) && monster_fast_remaining(t_ptr))
215 if ((t_idx == target_ptr->riding) && dispel_check(target_ptr, m_idx))
222 * @brief モンスターがプレイヤーに魔力消去を与えるべきかを判定するルーチン
223 * Check should monster cast dispel spell.
224 * @param m_idx モンスターの構造体配列ID
225 * @return 魔力消去をかけるべきならTRUEを返す。
227 bool dispel_check(player_type *creature_ptr, MONSTER_IDX m_idx)
229 if (is_invuln(creature_ptr))
232 if (creature_ptr->wraith_form)
235 if (creature_ptr->shield)
238 if (creature_ptr->magicdef)
241 if (creature_ptr->multishadow)
244 if (creature_ptr->dustrobe)
247 if (creature_ptr->shero && (creature_ptr->pclass != CLASS_BERSERKER))
250 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD)
253 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
254 monster_race *r_ptr = &r_info[m_ptr->r_idx];
255 if (r_ptr->flags4 & RF4_BR_ACID) {
256 if (!creature_ptr->immune_acid && (creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST)))
259 if (creature_ptr->special_defense & DEFENSE_ACID)
263 if (r_ptr->flags4 & RF4_BR_FIRE) {
264 if (!((creature_ptr->prace == RACE_BALROG) && creature_ptr->lev > 44)) {
265 if (!creature_ptr->immune_fire && (creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST)))
268 if (creature_ptr->special_defense & DEFENSE_FIRE)
273 if (r_ptr->flags4 & RF4_BR_ELEC) {
274 if (!creature_ptr->immune_elec && (creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST)))
277 if (creature_ptr->special_defense & DEFENSE_ELEC)
281 if (r_ptr->flags4 & RF4_BR_COLD) {
282 if (!creature_ptr->immune_cold && (creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST)))
285 if (creature_ptr->special_defense & DEFENSE_COLD)
289 if (((r_ptr->flags4 & (RF4_BR_POIS | RF4_BR_NUKE)) != 0) && !((creature_ptr->pclass == CLASS_NINJA) && (creature_ptr->lev > 44))) {
290 if (creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST))
293 if (creature_ptr->special_defense & DEFENSE_POIS)
297 if (creature_ptr->ult_res)
300 if (creature_ptr->tsuyoshi)
303 if ((creature_ptr->special_attack & ATTACK_ACID) && !(r_ptr->flagsr & RFR_EFF_IM_ACID_MASK))
306 if ((creature_ptr->special_attack & ATTACK_FIRE) && !(r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
309 if ((creature_ptr->special_attack & ATTACK_ELEC) && !(r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK))
312 if ((creature_ptr->special_attack & ATTACK_COLD) && !(r_ptr->flagsr & RFR_EFF_IM_COLD_MASK))
315 if ((creature_ptr->special_attack & ATTACK_POIS) && !(r_ptr->flagsr & RFR_EFF_IM_POIS_MASK))
318 if ((creature_ptr->pspeed < 145) && is_fast(creature_ptr))
321 if (creature_ptr->lightspeed && (m_ptr->mspeed < 136))
324 if (creature_ptr->riding && (creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].mspeed < 135)
325 && monster_fast_remaining(&creature_ptr->current_floor_ptr->m_list[creature_ptr->riding]))