From b97a59395f78b3fea1126952def0a6a9e6f63e1c Mon Sep 17 00:00:00 2001 From: Hourier Date: Wed, 3 Jun 2020 21:30:47 +0900 Subject: [PATCH] [Refactor] #40414 Moved binding_field() from spells1.c/h to spells-mirror.c/h --- src/cmd-action/cmd-spell.c | 1 + src/floor/floor-generate.c | 2 - src/floor/floor-streams.c | 1 - src/floor/floor.h | 1 + src/monster/monster-direction.c | 1 + src/mspell/mspells1.c | 2 +- src/mspell/mspells2.c | 2 +- src/player/player-class.h | 2 + src/player/player-status.c | 1 + src/spell/process-effect.c | 134 +++++++++++------------------- src/spell/spells-mirror.c | 131 +++++++++++++++++++++++++++++ src/spell/spells-mirror.h | 1 + src/spell/spells1.c | 178 ---------------------------------------- src/spell/spells1.h | 4 +- src/spell/spells2.c | 1 + 15 files changed, 191 insertions(+), 271 deletions(-) diff --git a/src/cmd-action/cmd-spell.c b/src/cmd-action/cmd-spell.c index 7ad87e8f4..83d70fc8a 100644 --- a/src/cmd-action/cmd-spell.c +++ b/src/cmd-action/cmd-spell.c @@ -16,6 +16,7 @@ #include "cmd-io/cmd-dump.h" #include "player/selfinfo.h" #include "spell/technic-info-table.h" +#include "spell/spells1.h" #include "spell/spells2.h" #include "spell/spells3.h" #include "spell/spells-summon.h" diff --git a/src/floor/floor-generate.c b/src/floor/floor-generate.c index fcea4ab7b..91822cab9 100644 --- a/src/floor/floor-generate.c +++ b/src/floor/floor-generate.c @@ -123,8 +123,6 @@ #include "dungeon/dungeon-file.h" #include "main/init.h" #include "grid/feature.h" -#include "spell/spells1.h" - #include "world/world.h" #include "view/display-main-window.h" diff --git a/src/floor/floor-streams.c b/src/floor/floor-streams.c index 6db9a70ca..c544ea76f 100644 --- a/src/floor/floor-streams.c +++ b/src/floor/floor-streams.c @@ -26,7 +26,6 @@ #include "object/object-hook.h" #include "room/rooms.h" #include "spell/spells-floor.h" -#include "spell/spells1.h" #include "util/util.h" /*! diff --git a/src/floor/floor.h b/src/floor/floor.h index 6b190b7e5..da1e84f2d 100644 --- a/src/floor/floor.h +++ b/src/floor/floor.h @@ -3,6 +3,7 @@ #include "system/angband.h" #include "grid/feature.h" #include "grid/grid.h" +#include "object/object-util.h" #include "object/object1.h" #include "floor/floor-save.h" diff --git a/src/monster/monster-direction.c b/src/monster/monster-direction.c index ee2b4af90..70c30d768 100644 --- a/src/monster/monster-direction.c +++ b/src/monster/monster-direction.c @@ -10,6 +10,7 @@ #include "monster/monster-util.h" #include "monster/monster-status.h" #include "pet/pet-util.h" +#include "spell/spells1.h" /*! * @brief ペットが敵に接近するための方向を決定する diff --git a/src/mspell/mspells1.c b/src/mspell/mspells1.c index fb72ba910..6df890972 100644 --- a/src/mspell/mspells1.c +++ b/src/mspell/mspells1.c @@ -40,7 +40,6 @@ #include "system/angband.h" #include "util/util.h" - #include "effect/effect-characteristics.h" #include "dungeon/dungeon.h" #include "grid/grid.h" @@ -58,6 +57,7 @@ #include "player/player-races-table.h" #include "player/player-class.h" #include "spell/process-effect.h" +#include "spell/spells1.h" #include "spell/spells3.h" #include "mspell/mspell-learn-checker.h" #include "mspell/assign-monster-spell.h" diff --git a/src/mspell/mspells2.c b/src/mspell/mspells2.c index a79ea481d..f9a9e3d0a 100644 --- a/src/mspell/mspells2.c +++ b/src/mspell/mspells2.c @@ -14,7 +14,6 @@ #include "system/angband.h" #include "util/util.h" #include "main/sound-definitions-table.h" - #include "pet/pet-util.h" #include "effect/effect-characteristics.h" #include "grid/grid.h" @@ -26,6 +25,7 @@ #include "monster/monster-status.h" #include "mspell/monster-spell.h" #include "spell/spells-type.h" +#include "spell/spells1.h" #include "dungeon/dungeon.h" #include "world/world.h" #include "view/display-main-window.h" diff --git a/src/player/player-class.h b/src/player/player-class.h index 8aad4891d..ab110cf56 100644 --- a/src/player/player-class.h +++ b/src/player/player-class.h @@ -1,4 +1,6 @@ #pragma once + +#include "object/tval-types.h" #include "spell/spells1.h" #include "spell/technic-info-table.h" #include "player/player-status.h" diff --git a/src/player/player-status.c b/src/player/player-status.c index b75a3824f..c31bffebf 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -56,6 +56,7 @@ #include "spell/spells-execution.h" #include "spell/spells-status.h" #include "spell/spells-util.h" +#include "spell/spells1.h" #include "spell/technic-info-table.h" #include "util/util.h" #include "view/display-main-window.h" diff --git a/src/spell/process-effect.c b/src/spell/process-effect.c index 2820a67c6..047903caa 100644 --- a/src/spell/process-effect.c +++ b/src/spell/process-effect.c @@ -1,18 +1,19 @@ #include "system/angband.h" -#include "effect/spells-effect-util.h" #include "spell/process-effect.h" -#include "floor/floor.h" -#include "pet/pet-fall-off.h" #include "core/stuff-handler.h" +#include "effect/effect-characteristics.h" #include "effect/effect-feature.h" #include "effect/effect-item.h" #include "effect/effect-monster.h" #include "effect/effect-player.h" -#include "term/gameterm.h" +#include "effect/spells-effect-util.h" +#include "floor/floor.h" #include "main/sound-definitions-table.h" +#include "pet/pet-fall-off.h" #include "spell/spells-type.h" +#include "spell/spells1.h" +#include "term/gameterm.h" #include "view/display-main-window.h" // 暫定、後で消すかも. -#include "effect/effect-characteristics.h" /*! * @brief 配置した鏡リストの次を取得する / @@ -22,7 +23,7 @@ * @param cury 現在の鏡のy座標 * @param curx 現在の鏡のx座標 */ -static void next_mirror(player_type* creature_ptr, POSITION* next_y, POSITION* next_x, POSITION cury, POSITION curx) +static void next_mirror(player_type *creature_ptr, POSITION *next_y, POSITION *next_x, POSITION cury, POSITION curx) { POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */ int mirror_num = 0; /* 鏡の数 */ @@ -66,7 +67,7 @@ static void next_mirror(player_type* creature_ptr, POSITION* next_y, POSITION* n * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the * projection were observed, else FALSE */ -bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flag, int monspell) +bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flag, int monspell) { int dist; POSITION y1, x1; @@ -85,7 +86,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, int path_n = 0; u16b path_g[512]; int grids = 0; - POSITION gx[1024]; + POSITION gx[1024]; POSITION gy[1024]; POSITION gm[32]; POSITION gm_rad = rad; @@ -109,9 +110,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, } else if (who > 0) { x1 = caster_ptr->current_floor_ptr->m_list[who].fx; y1 = caster_ptr->current_floor_ptr->m_list[who].fy; - monster_desc(caster_ptr, who_name, - &caster_ptr->current_floor_ptr->m_list[who], - MD_WRONGDOER_NAME); + monster_desc(caster_ptr, who_name, &caster_ptr->current_floor_ptr->m_list[who], MD_WRONGDOER_NAME); } else { x1 = x; y1 = y; @@ -222,7 +221,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, if (affect_monster(caster_ptr, 0, 0, y, x, dam, GF_SEEKER, flag, TRUE)) notice = TRUE; if (!who && (project_m_n == 1) && !jump && (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0)) { - monster_type* m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx]; + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx]; if (m_ptr->ml) { if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx); @@ -243,10 +242,8 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, if (affect_monster(caster_ptr, 0, 0, py, px, dam, GF_SEEKER, flag, TRUE)) notice = TRUE; if (!who && (project_m_n == 1) && !jump) { - if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x] - .m_idx - > 0) { - monster_type* m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx]; + if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0) { + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx]; if (m_ptr->ml) { if (!caster_ptr->image) @@ -305,8 +302,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, if (affect_item(caster_ptr, 0, 0, y, x, dam, GF_SUPER_RAY)) notice = TRUE; - if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, - FF_PROJECT)) { + if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT)) { if (second_step) continue; break; @@ -324,43 +320,24 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, path_n = i; second_step = i + 1; - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y - 1, x - 1, flag); - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y - 1, x, flag); - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y - 1, x + 1, flag); - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y, x - 1, flag); - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y, x + 1, flag); - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y + 1, x - 1, flag); - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y + 1, x, flag); - path_n += project_path(caster_ptr, &(path_g[path_n + 1]), - (project_length ? project_length : MAX_RANGE), y, - x, y + 1, x + 1, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x - 1, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x + 1, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x - 1, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x + 1, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x - 1, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x, flag); + path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x + 1, flag); } } for (int i = 0; i < path_n; i++) { POSITION py = GRID_Y(path_g[i]); POSITION px = GRID_X(path_g[i]); - (void)affect_monster(caster_ptr, 0, 0, py, px, dam, GF_SUPER_RAY, flag, - TRUE); + (void)affect_monster(caster_ptr, 0, 0, py, px, dam, GF_SUPER_RAY, flag, TRUE); if (!who && (project_m_n == 1) && !jump) { - if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x] - .m_idx - > 0) { - monster_type* m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx]; + if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0) { + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx]; if (m_ptr->ml) { if (!caster_ptr->image) @@ -389,8 +366,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, if (!cave_los_bold(caster_ptr->current_floor_ptr, ny, nx) && (rad > 0)) break; } else { - if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, ny, nx, FF_PROJECT) - && (rad > 0)) + if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, ny, nx, FF_PROJECT) && (rad > 0)) break; } @@ -545,9 +521,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, if (flag & PROJECT_KILL) { see_s_msg = (who > 0) ? is_seen(&caster_ptr->current_floor_ptr->m_list[who]) - : (!who ? TRUE - : (player_can_see_bold(caster_ptr, y1, x1) && - projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y1, x1))); + : (!who ? TRUE : (player_can_see_bold(caster_ptr, y1, x1) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y1, x1))); } if (flag & (PROJECT_GRID)) { @@ -601,14 +575,11 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, y = gy[i]; x = gx[i]; if (grids <= 1) { - monster_type* m_ptr = &caster_ptr->current_floor_ptr->m_list - [caster_ptr->current_floor_ptr->grid_array[y][x].m_idx]; - monster_race* ref_ptr = &r_info[m_ptr->r_idx]; - if ((flag & PROJECT_REFLECTABLE) && - caster_ptr->current_floor_ptr->grid_array[y][x].m_idx && - (ref_ptr->flags2 & RF2_REFLECTING) && - ((caster_ptr->current_floor_ptr->grid_array[y][x].m_idx != caster_ptr->riding) || !(flag & PROJECT_PLAYER)) && - (!who || dist_hack > 1) && !one_in_(10)) { + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[y][x].m_idx]; + monster_race *ref_ptr = &r_info[m_ptr->r_idx]; + if ((flag & PROJECT_REFLECTABLE) && caster_ptr->current_floor_ptr->grid_array[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) + && ((caster_ptr->current_floor_ptr->grid_array[y][x].m_idx != caster_ptr->riding) || !(flag & PROJECT_PLAYER)) && (!who || dist_hack > 1) + && !one_in_(10)) { POSITION t_y, t_x; int max_attempts = 10; do { @@ -625,11 +596,9 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, sound(SOUND_REFLECT); if (is_seen(m_ptr)) { if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU)) - msg_print( - _("「北斗神拳奥義・二指真空把!」", "The attack bounces!")); + msg_print(_("「北斗神拳奥義・二指真空把!」", "The attack bounces!")); else if (m_ptr->r_idx == MON_DIO) - msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", - "The attack bounces!")); + msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", "The attack bounces!")); else msg_print(_("攻撃は跳ね返った!", "The attack bounces!")); } @@ -642,9 +611,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, else flag |= PROJECT_PLAYER; - project(caster_ptr, - caster_ptr->current_floor_ptr->grid_array[y][x].m_idx, 0, t_y, - t_x, dam, typ, flag, monspell); + project(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].m_idx, 0, t_y, t_x, dam, typ, flag, monspell); continue; } } @@ -711,8 +678,7 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, } } - if (affect_monster(caster_ptr, who, effective_dist, y, x, dam, typ, flag, - see_s_msg)) + if (affect_monster(caster_ptr, who, effective_dist, y, x, dam, typ, flag, see_s_msg)) notice = TRUE; } @@ -721,13 +687,12 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, x = project_m_x; y = project_m_y; if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx > 0) { - monster_type* m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[y][x].m_idx]; + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[y][x].m_idx]; if (m_ptr->ml) { if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx); - health_track(caster_ptr, - caster_ptr->current_floor_ptr->grid_array[y][x].m_idx); + health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].m_idx); } } } @@ -770,16 +735,16 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, */ else if (flag & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED)) { /* - * A beam or bolt is well aimed - * at the mount! - * So don't affects the player. - */ + * A beam or bolt is well aimed + * at the mount! + * So don't affects the player. + */ continue; } else { /* - * The spell is not well aimed, - * So partly affect the player too. - */ + * The spell is not well aimed, + * So partly affect the player too. + */ effective_dist++; } } @@ -791,19 +756,16 @@ bool project(player_type* caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, if (caster_ptr->riding) { GAME_TEXT m_name[MAX_NLEN]; - monster_desc(caster_ptr, m_name, - &caster_ptr->current_floor_ptr->m_list[caster_ptr->riding], 0); + monster_desc(caster_ptr, m_name, &caster_ptr->current_floor_ptr->m_list[caster_ptr->riding], 0); if (rakubadam_m > 0) { if (process_fall_off_horse(caster_ptr, rakubadam_m, FALSE)) { - msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), - m_name); + msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name); } } if (caster_ptr->riding && rakubadam_p > 0) { if (process_fall_off_horse(caster_ptr, rakubadam_p, FALSE)) { - msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), - m_name); + msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_name); } } } diff --git a/src/spell/spells-mirror.c b/src/spell/spells-mirror.c index 6ceca42e2..743dc3c2b 100644 --- a/src/spell/spells-mirror.c +++ b/src/spell/spells-mirror.c @@ -1,8 +1,139 @@ #include "spell/spells-mirror.h" +#include "effect/effect-feature.h" +#include "effect/effect-item.h" +#include "effect/effect-monster.h" #include "effect/effect-characteristics.h" +#include "effect/spells-effect-util.h" #include "effect/effect-monster.h" #include "floor/floor.h" #include "spell/spells-type.h" +#include "term/gameterm.h" +#include "view/display-main-window.h" + +/*! + * @brief 鏡魔法「封魔結界」の効果処理 + * @param dam ダメージ量 + * @return 効果があったらTRUEを返す + */ +bool binding_field(player_type *caster_ptr, HIT_POINT dam) +{ + POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */ + int mirror_num = 0; /* 鏡の数 */ + int msec = delay_factor * delay_factor * delay_factor; + + /* 三角形の頂点 */ + POSITION point_x[3]; + POSITION point_y[3]; + + /* Default target of monsterspell is player */ + monster_target_y = caster_ptr->y; + monster_target_x = caster_ptr->x; + + for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) { + for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) { + if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && distance(caster_ptr->y, caster_ptr->x, y, x) <= MAX_RANGE + && distance(caster_ptr->y, caster_ptr->x, y, x) != 0 && player_has_los_bold(caster_ptr, y, x) + && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) { + mirror_y[mirror_num] = y; + mirror_x[mirror_num] = x; + mirror_num++; + } + } + } + + if (mirror_num < 2) + return FALSE; + + point_x[0] = randint0(mirror_num); + do { + point_x[1] = randint0(mirror_num); + } while (point_x[0] == point_x[1]); + + point_y[0] = mirror_y[point_x[0]]; + point_x[0] = mirror_x[point_x[0]]; + point_y[1] = mirror_y[point_x[1]]; + point_x[1] = mirror_x[point_x[1]]; + point_y[2] = caster_ptr->y; + point_x[2] = caster_ptr->x; + + POSITION x = point_x[0] + point_x[1] + point_x[2]; + POSITION y = point_y[0] + point_y[1] + point_y[2]; + + POSITION centersign = (point_x[0] * 3 - x) * (point_y[1] * 3 - y) - (point_y[0] * 3 - y) * (point_x[1] * 3 - x); + if (centersign == 0) + return FALSE; + + POSITION x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1]; + x1 = x1 < point_x[2] ? x1 : point_x[2]; + POSITION y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1]; + y1 = y1 < point_y[2] ? y1 : point_y[2]; + + POSITION x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1]; + x2 = x2 > point_x[2] ? x2 : point_x[2]; + POSITION y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1]; + y2 = y2 > point_y[2] ? y2 : point_y[2]; + + for (y = y1; y <= y2; y++) { + for (x = x1; x <= x2; x++) { + if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0 + && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0 + && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) { + if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) { + if (!(caster_ptr->blind) && panel_contains(y, x)) { + u16b p = bolt_pict(y, x, y, x, GF_MANA); + print_rel(caster_ptr, PICT_C(p), PICT_A(p), y, x); + move_cursor_relative(y, x); + Term_fresh(); + Term_xtra(TERM_XTRA_DELAY, msec); + } + } + } + } + } + + for (y = y1; y <= y2; y++) { + for (x = x1; x <= x2; x++) { + if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0 + && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0 + && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) { + if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) { + (void)affect_feature(caster_ptr, 0, 0, y, x, dam, GF_MANA); + } + } + } + } + + for (y = y1; y <= y2; y++) { + for (x = x1; x <= x2; x++) { + if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0 + && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0 + && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) { + if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) { + (void)affect_item(caster_ptr, 0, 0, y, x, dam, GF_MANA); + } + } + } + } + + for (y = y1; y <= y2; y++) { + for (x = x1; x <= x2; x++) { + if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0 + && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0 + && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) { + if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) { + (void)affect_monster(caster_ptr, 0, 0, y, x, dam, GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE); + } + } + } + } + + if (one_in_(7)) { + msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror")); + remove_mirror(caster_ptr, point_y[0], point_x[0]); + } + + return TRUE; +} /*! * @brief 鏡魔法「鏡の封印」の効果処理 diff --git a/src/spell/spells-mirror.h b/src/spell/spells-mirror.h index 3552d6adb..0c00caea5 100644 --- a/src/spell/spells-mirror.h +++ b/src/spell/spells-mirror.h @@ -2,4 +2,5 @@ #include "system/angband.h" +bool binding_field(player_type *caster_ptr, HIT_POINT dam); void seal_of_mirror(player_type *caster_ptr, HIT_POINT dam); diff --git a/src/spell/spells1.c b/src/spell/spells1.c index 2c7a80a3b..a8b18a78e 100644 --- a/src/spell/spells1.c +++ b/src/spell/spells1.c @@ -1,5 +1,4 @@ /*! - * @file spells1.c * @brief 魔法による遠隔処理の実装 / Spell projection * @date 2014/07/10 * @author @@ -11,23 +10,8 @@ * */ -#include "system/angband.h" -#include "floor/floor.h" -#include "system/system-variables.h" -#include "util/util.h" -#include "main/sound-definitions-table.h" -#include "cmd-action/cmd-pet.h" -#include "cmd-io/cmd-dump.h" -#include "player/player-class.h" -#include "monster/monster.h" #include "spell/spells1.h" #include "term/gameterm.h" -#include "view/display-main-window.h" -#include "effect/spells-effect-util.h" -#include "effect/effect-feature.h" -#include "effect/effect-item.h" -#include "effect/effect-monster.h" -#include "effect/effect-characteristics.h" /* * Find the distance from (x, y) to a line. @@ -296,168 +280,6 @@ void breath_shape(player_type *caster_ptr, u16b *path_g, int dist, int *pgrids, /*! - * @brief 鏡魔法「封魔結界」の効果処理 - * @param dam ダメージ量 - * @return 効果があったらTRUEを返す - */ -bool binding_field(player_type *caster_ptr, HIT_POINT dam) -{ - POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */ - int mirror_num = 0; /* 鏡の数 */ - int msec = delay_factor * delay_factor*delay_factor; - - /* 三角形の頂点 */ - POSITION point_x[3]; - POSITION point_y[3]; - - /* Default target of monsterspell is player */ - monster_target_y = caster_ptr->y; - monster_target_x = caster_ptr->x; - - for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) - { - for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) - { - if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && - distance(caster_ptr->y, caster_ptr->x, y, x) <= MAX_RANGE && - distance(caster_ptr->y, caster_ptr->x, y, x) != 0 && - player_has_los_bold(caster_ptr, y, x) && - projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) - { - mirror_y[mirror_num] = y; - mirror_x[mirror_num] = x; - mirror_num++; - } - } - } - - if (mirror_num < 2)return FALSE; - - point_x[0] = randint0(mirror_num); - do { - point_x[1] = randint0(mirror_num); - } while (point_x[0] == point_x[1]); - - point_y[0] = mirror_y[point_x[0]]; - point_x[0] = mirror_x[point_x[0]]; - point_y[1] = mirror_y[point_x[1]]; - point_x[1] = mirror_x[point_x[1]]; - point_y[2] = caster_ptr->y; - point_x[2] = caster_ptr->x; - - POSITION x = point_x[0] + point_x[1] + point_x[2]; - POSITION y = point_y[0] + point_y[1] + point_y[2]; - - POSITION centersign = (point_x[0] * 3 - x)*(point_y[1] * 3 - y) - - (point_y[0] * 3 - y)*(point_x[1] * 3 - x); - if (centersign == 0)return FALSE; - - POSITION x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1]; - x1 = x1 < point_x[2] ? x1 : point_x[2]; - POSITION y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1]; - y1 = y1 < point_y[2] ? y1 : point_y[2]; - - POSITION x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1]; - x2 = x2 > point_x[2] ? x2 : point_x[2]; - POSITION y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1]; - y2 = y2 > point_y[2] ? y2 : point_y[2]; - - for (y = y1; y <= y2; y++) - { - for (x = x1; x <= x2; x++) - { - if (centersign*((point_x[0] - x)*(point_y[1] - y) - - (point_y[0] - y)*(point_x[1] - x)) >= 0 && - centersign*((point_x[1] - x)*(point_y[2] - y) - - (point_y[1] - y)*(point_x[2] - x)) >= 0 && - centersign*((point_x[2] - x)*(point_y[0] - y) - - (point_y[2] - y)*(point_x[0] - x)) >= 0) - { - if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) - { - if (!(caster_ptr->blind) - && panel_contains(y, x)) - { - u16b p = bolt_pict(y, x, y, x, GF_MANA); - print_rel(caster_ptr, PICT_C(p), PICT_A(p), y, x); - move_cursor_relative(y, x); - Term_fresh(); - Term_xtra(TERM_XTRA_DELAY, msec); - } - } - } - } - } - - for (y = y1; y <= y2; y++) - { - for (x = x1; x <= x2; x++) - { - if (centersign*((point_x[0] - x)*(point_y[1] - y) - - (point_y[0] - y)*(point_x[1] - x)) >= 0 && - centersign*((point_x[1] - x)*(point_y[2] - y) - - (point_y[1] - y)*(point_x[2] - x)) >= 0 && - centersign*((point_x[2] - x)*(point_y[0] - y) - - (point_y[2] - y)*(point_x[0] - x)) >= 0) - { - if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) - { - (void)affect_feature(caster_ptr, 0, 0, y, x, dam, GF_MANA); - } - } - } - } - - for (y = y1; y <= y2; y++) - { - for (x = x1; x <= x2; x++) - { - if (centersign*((point_x[0] - x)*(point_y[1] - y) - - (point_y[0] - y)*(point_x[1] - x)) >= 0 && - centersign*((point_x[1] - x)*(point_y[2] - y) - - (point_y[1] - y)*(point_x[2] - x)) >= 0 && - centersign*((point_x[2] - x)*(point_y[0] - y) - - (point_y[2] - y)*(point_x[0] - x)) >= 0) - { - if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) - { - (void)affect_item(caster_ptr, 0, 0, y, x, dam, GF_MANA); - } - } - } - } - - for (y = y1; y <= y2; y++) - { - for (x = x1; x <= x2; x++) - { - if (centersign*((point_x[0] - x)*(point_y[1] - y) - - (point_y[0] - y)*(point_x[1] - x)) >= 0 && - centersign*((point_x[1] - x)*(point_y[2] - y) - - (point_y[1] - y)*(point_x[2] - x)) >= 0 && - centersign*((point_x[2] - x)*(point_y[0] - y) - - (point_y[2] - y)*(point_x[0] - x)) >= 0) - { - if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) - { - (void)affect_monster(caster_ptr, 0, 0, y, x, dam, GF_MANA, - (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE); - } - } - } - } - - if (one_in_(7)) - { - msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror")); - remove_mirror(caster_ptr, point_y[0], point_x[0]); - } - - return TRUE; -} - - -/*! * @brief 領域魔法に応じて技能の名称を返す。 * @param tval 魔法書のtval * @return 領域魔法の技能名称を保管した文字列ポインタ diff --git a/src/spell/spells1.h b/src/spell/spells1.h index 71110ee7f..045ff4bf0 100644 --- a/src/spell/spells1.h +++ b/src/spell/spells1.h @@ -1,11 +1,11 @@ #pragma once -#include "object/object-util.h" +#include "system/angband.h" +#include "floor/floor.h" #include "object/tval-types.h" #include "realm/realm-names-table.h" bool in_disintegration_range(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2); void breath_shape(player_type *caster_ptr, u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *gy, POSITION *gm, POSITION *pgm_rad, POSITION rad, POSITION y1, POSITION x1, POSITION y2, POSITION x2, EFFECT_ID typ); POSITION dist_to_line(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2); -bool binding_field(player_type *caster_ptr, HIT_POINT dam); concptr spell_category_name(tval_type tval); diff --git a/src/spell/spells2.c b/src/spell/spells2.c index e8749892e..0604c0276 100644 --- a/src/spell/spells2.c +++ b/src/spell/spells2.c @@ -61,6 +61,7 @@ #include "spell/spells-status.h" #include "spell/spells-summon.h" #include "spell/spells-type.h" +#include "spell/spells1.h" #include "spell/spells3.h" #include "sv-definition/sv-food-types.h" #include "system/system-variables.h" -- 2.11.0