1 #include "mind/mind-mirror-master.h"
2 #include "cmd-action/cmd-pet.h"
3 #include "core/disturbance.h"
4 #include "core/player-redraw-types.h"
5 #include "core/player-update-types.h"
6 #include "core/stuff-handler.h"
7 #include "effect/effect-characteristics.h"
8 #include "effect/effect-feature.h"
9 #include "effect/effect-item.h"
10 #include "effect/effect-monster.h"
11 #include "effect/spells-effect-util.h"
12 #include "floor/cave.h"
13 #include "floor/floor.h"
14 #include "game-option/disturbance-options.h"
15 #include "game-option/special-options.h"
16 #include "grid/feature.h"
17 #include "io/cursor.h"
18 #include "io/screen-util.h"
19 #include "spell-kind/spells-sight.h"
20 #include "spell-kind/spells-teleport.h"
21 #include "spell/process-effect.h"
22 #include "spell/spell-types.h"
23 #include "system/floor-type-definition.h"
24 #include "target/grid-selector.h"
25 #include "term/gameterm.h"
26 #include "util/bit-flags-calculator.h"
27 #include "view/display-messages.h"
28 #include "world/world.h"
31 * @brief Multishadow effects is determined by turn
33 bool check_multishadow(player_type *creature_ptr) { return (creature_ptr->multishadow != 0) && ((current_world_ptr->game_turn & 1) != 0); }
37 * @param creature_ptr プレーヤーへの参照ポインタ
38 * @return ペットを操っている場合を除きTRUE
40 bool mirror_concentration(player_type *creature_ptr)
43 msg_print(_("今はペットを操ることに集中していないと。", "Your pets demand all of your attention."));
47 if (!is_mirror_grid(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])) {
48 msg_print(_("鏡の上でないと集中できない!", "There's no mirror here!"));
52 msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
54 creature_ptr->csp += (5 + creature_ptr->lev * creature_ptr->lev / 100);
55 if (creature_ptr->csp >= creature_ptr->msp) {
56 creature_ptr->csp = creature_ptr->msp;
57 creature_ptr->csp_frac = 0;
60 creature_ptr->redraw |= PR_MANA;
65 * @brief 全鏡の消去 / Remove all mirrors in this floor
66 * @param caster_ptr プレーヤーへの参照ポインタ
67 * @param explode 爆発処理を伴うならばTRUE
70 void remove_all_mirrors(player_type *caster_ptr, bool explode)
72 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
73 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
74 if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
77 remove_mirror(caster_ptr, y, x);
81 project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS,
82 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
88 * @brief 鏡魔法「封魔結界」の効果処理
90 * @return 効果があったらTRUEを返す
92 bool binding_field(player_type *caster_ptr, HIT_POINT dam)
94 POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
95 int mirror_num = 0; /* 鏡の数 */
96 int msec = delay_factor * delay_factor * delay_factor;
102 /* Default target of monsterspell is player */
103 monster_target_y = caster_ptr->y;
104 monster_target_x = caster_ptr->x;
106 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
107 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
108 if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && distance(caster_ptr->y, caster_ptr->x, y, x) <= get_max_range(caster_ptr)
109 && distance(caster_ptr->y, caster_ptr->x, y, x) != 0 && player_has_los_bold(caster_ptr, y, x)
110 && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
111 mirror_y[mirror_num] = y;
112 mirror_x[mirror_num] = x;
121 point_x[0] = randint0(mirror_num);
123 point_x[1] = randint0(mirror_num);
124 } while (point_x[0] == point_x[1]);
126 point_y[0] = mirror_y[point_x[0]];
127 point_x[0] = mirror_x[point_x[0]];
128 point_y[1] = mirror_y[point_x[1]];
129 point_x[1] = mirror_x[point_x[1]];
130 point_y[2] = caster_ptr->y;
131 point_x[2] = caster_ptr->x;
133 POSITION x = point_x[0] + point_x[1] + point_x[2];
134 POSITION y = point_y[0] + point_y[1] + point_y[2];
136 POSITION centersign = (point_x[0] * 3 - x) * (point_y[1] * 3 - y) - (point_y[0] * 3 - y) * (point_x[1] * 3 - x);
140 POSITION x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
141 x1 = x1 < point_x[2] ? x1 : point_x[2];
142 POSITION y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
143 y1 = y1 < point_y[2] ? y1 : point_y[2];
145 POSITION x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
146 x2 = x2 > point_x[2] ? x2 : point_x[2];
147 POSITION y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
148 y2 = y2 > point_y[2] ? y2 : point_y[2];
150 for (y = y1; y <= y2; y++) {
151 for (x = x1; x <= x2; x++) {
152 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
153 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
154 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
155 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
156 if (!(caster_ptr->blind) && panel_contains(y, x)) {
157 u16b p = bolt_pict(y, x, y, x, GF_MANA);
158 print_rel(caster_ptr, PICT_C(p), PICT_A(p), y, x);
159 move_cursor_relative(y, x);
161 term_xtra(TERM_XTRA_DELAY, msec);
168 for (y = y1; y <= y2; y++) {
169 for (x = x1; x <= x2; x++) {
170 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
171 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
172 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
173 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
174 (void)affect_feature(caster_ptr, 0, 0, y, x, dam, GF_MANA);
180 for (y = y1; y <= y2; y++) {
181 for (x = x1; x <= x2; x++) {
182 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
183 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
184 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
185 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
186 (void)affect_item(caster_ptr, 0, 0, y, x, dam, GF_MANA);
192 for (y = y1; y <= y2; y++) {
193 for (x = x1; x <= x2; x++) {
194 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
195 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
196 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
197 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
198 (void)affect_monster(caster_ptr, 0, 0, y, x, dam, GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
205 msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
206 remove_mirror(caster_ptr, point_y[0], point_x[0]);
213 * @brief 鏡魔法「鏡の封印」の効果処理
215 * @return 効果があったらTRUEを返す
217 void seal_of_mirror(player_type *caster_ptr, HIT_POINT dam)
219 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
220 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
221 if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
224 if (!affect_monster(caster_ptr, 0, 0, y, x, dam, GF_GENOCIDE, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
227 if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
228 remove_mirror(caster_ptr, y, x);
235 * 幻惑の光 @ 鏡使いだけでなく混沌の戦士も使える
236 * @param creature_ptr プレーヤーへの参照ポインタ
239 bool confusing_light(player_type *creature_ptr)
241 msg_print(_("辺りを睨んだ...", "You glare nearby monsters..."));
242 slow_monsters(creature_ptr, creature_ptr->lev);
243 stun_monsters(creature_ptr, creature_ptr->lev * 4);
244 confuse_monsters(creature_ptr, creature_ptr->lev * 4);
245 turn_monsters(creature_ptr, creature_ptr->lev * 4);
246 stasis_monsters(creature_ptr, creature_ptr->lev * 4);
252 * @return 実際に設置が行われた場合TRUEを返す
254 bool place_mirror(player_type *caster_ptr)
256 if (!cave_clean_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x)) {
257 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
261 /* Create a mirror */
262 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_OBJECT;
263 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].mimic = feat_mirror;
265 /* Turn on the light */
266 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_GLOW;
268 note_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
269 lite_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
270 update_local_illumination(caster_ptr, caster_ptr->y, caster_ptr->x);
276 * @brief 鏡抜け処理のメインルーチン /
277 * Mirror Master's Dimension Door
278 * @param caster_ptr プレーヤーへの参照ポインタ
279 * @return ターンを消費した場合TRUEを返す
281 bool mirror_tunnel(player_type *caster_ptr)
283 POSITION x = 0, y = 0;
284 if (!tgt_pt(caster_ptr, &x, &y))
286 if (exe_dimension_door(caster_ptr, x, y))
289 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
294 * Set "multishadow", notice observable changes
296 bool set_multishadow(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
299 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
301 if (creature_ptr->is_dead)
305 if (creature_ptr->multishadow && !do_dec) {
306 if (creature_ptr->multishadow > v)
308 } else if (!creature_ptr->multishadow) {
309 msg_print(_("あなたの周りに幻影が生まれた。", "Your Shadow enveloped you."));
313 if (creature_ptr->multishadow) {
314 msg_print(_("幻影が消えた。", "Your Shadow disappears."));
319 creature_ptr->multishadow = v;
320 creature_ptr->redraw |= (PR_STATUS);
326 disturb(creature_ptr, FALSE, FALSE);
327 creature_ptr->update |= (PU_BONUS);
328 handle_stuff(creature_ptr);
333 * @brief 一時的破片のオーラの継続時間をセットする / Set "dustrobe", notice observable changes
335 * @param do_dec 現在の継続時間より長い値のみ上書きする
336 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
338 bool set_dustrobe(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
341 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
343 if (creature_ptr->is_dead)
347 if (creature_ptr->dustrobe && !do_dec) {
348 if (creature_ptr->dustrobe > v)
350 } else if (!creature_ptr->dustrobe) {
351 msg_print(_("体が鏡のオーラで覆われた。", "You were enveloped by mirror shards."));
355 if (creature_ptr->dustrobe) {
356 msg_print(_("鏡のオーラが消えた。", "The mirror shards disappear."));
361 creature_ptr->dustrobe = v;
362 creature_ptr->redraw |= (PR_STATUS);
368 disturb(creature_ptr, FALSE, FALSE);
369 creature_ptr->update |= (PU_BONUS);
370 handle_stuff(creature_ptr);