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/effect-processor.h"
12 #include "effect/spells-effect-util.h"
13 #include "floor/cave.h"
14 #include "game-option/disturbance-options.h"
15 #include "game-option/map-screen-options.h"
16 #include "game-option/special-options.h"
17 #include "grid/feature.h"
18 #include "io/cursor.h"
19 #include "io/screen-util.h"
20 #include "mind/mind-magic-resistance.h"
21 #include "mind/mind-numbers.h"
22 #include "spell-kind/spells-detection.h"
23 #include "spell-kind/spells-floor.h"
24 #include "spell-kind/spells-launcher.h"
25 #include "spell-kind/spells-lite.h"
26 #include "spell-kind/spells-sight.h"
27 #include "spell-kind/spells-teleport.h"
28 #include "spell-kind/spells-world.h"
29 #include "spell/spell-types.h"
30 #include "status/body-improvement.h"
31 #include "status/buff-setter.h"
32 #include "status/sight-setter.h"
33 #include "system/floor-type-definition.h"
34 #include "target/grid-selector.h"
35 #include "target/projection-path-calculator.h"
36 #include "target/target-getter.h"
37 #include "term/gameterm.h"
38 #include "util/bit-flags-calculator.h"
39 #include "view/display-messages.h"
40 #include "world/world.h"
43 * @brief Multishadow effects is determined by turn
45 bool check_multishadow(player_type *creature_ptr) { return (creature_ptr->multishadow != 0) && ((current_world_ptr->game_turn & 1) != 0); }
49 * @param creature_ptr プレーヤーへの参照ポインタ
50 * @return ペットを操っている場合を除きTRUE
52 bool mirror_concentration(player_type *creature_ptr)
55 msg_print(_("今はペットを操ることに集中していないと。", "Your pets demand all of your attention."));
59 if (!is_mirror_grid(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])) {
60 msg_print(_("鏡の上でないと集中できない!", "There's no mirror here!"));
64 msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
66 creature_ptr->csp += (5 + creature_ptr->lev * creature_ptr->lev / 100);
67 if (creature_ptr->csp >= creature_ptr->msp) {
68 creature_ptr->csp = creature_ptr->msp;
69 creature_ptr->csp_frac = 0;
72 creature_ptr->redraw |= PR_MANA;
77 * @brief 全鏡の消去 / Remove all mirrors in this floor
78 * @param caster_ptr プレーヤーへの参照ポインタ
79 * @param explode 爆発処理を伴うならばTRUE
82 void remove_all_mirrors(player_type *caster_ptr, bool explode)
84 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
85 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
86 if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
89 remove_mirror(caster_ptr, y, x);
93 project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS,
94 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
100 * @brief 鏡魔法「封魔結界」の効果処理
102 * @return 効果があったらTRUEを返す
104 bool binding_field(player_type *caster_ptr, HIT_POINT dam)
106 POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
107 int mirror_num = 0; /* 鏡の数 */
108 int msec = delay_factor * delay_factor * delay_factor;
114 /* Default target of monsterspell is player */
115 monster_target_y = caster_ptr->y;
116 monster_target_x = caster_ptr->x;
118 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
119 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
120 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)
121 && distance(caster_ptr->y, caster_ptr->x, y, x) != 0 && player_has_los_bold(caster_ptr, y, x)
122 && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
123 mirror_y[mirror_num] = y;
124 mirror_x[mirror_num] = x;
133 point_x[0] = randint0(mirror_num);
135 point_x[1] = randint0(mirror_num);
136 } while (point_x[0] == point_x[1]);
138 point_y[0] = mirror_y[point_x[0]];
139 point_x[0] = mirror_x[point_x[0]];
140 point_y[1] = mirror_y[point_x[1]];
141 point_x[1] = mirror_x[point_x[1]];
142 point_y[2] = caster_ptr->y;
143 point_x[2] = caster_ptr->x;
145 POSITION x = point_x[0] + point_x[1] + point_x[2];
146 POSITION y = point_y[0] + point_y[1] + point_y[2];
148 POSITION centersign = (point_x[0] * 3 - x) * (point_y[1] * 3 - y) - (point_y[0] * 3 - y) * (point_x[1] * 3 - x);
152 POSITION x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
153 x1 = x1 < point_x[2] ? x1 : point_x[2];
154 POSITION y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
155 y1 = y1 < point_y[2] ? y1 : point_y[2];
157 POSITION x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
158 x2 = x2 > point_x[2] ? x2 : point_x[2];
159 POSITION y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
160 y2 = y2 > point_y[2] ? y2 : point_y[2];
162 for (y = y1; y <= y2; y++) {
163 for (x = x1; x <= x2; x++) {
164 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
165 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
166 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
167 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
168 if (!(caster_ptr->blind) && panel_contains(y, x)) {
169 u16b p = bolt_pict(y, x, y, x, GF_MANA);
170 print_rel(caster_ptr, PICT_C(p), PICT_A(p), y, x);
171 move_cursor_relative(y, x);
174 term_xtra(TERM_XTRA_DELAY, msec);
182 for (y = y1; y <= y2; y++) {
183 for (x = x1; x <= x2; x++) {
184 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
185 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
186 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
187 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
188 (void)affect_feature(caster_ptr, 0, 0, y, x, dam, GF_MANA);
194 for (y = y1; y <= y2; y++) {
195 for (x = x1; x <= x2; x++) {
196 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
197 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
198 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
199 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
200 (void)affect_item(caster_ptr, 0, 0, y, x, dam, GF_MANA);
206 for (y = y1; y <= y2; y++) {
207 for (x = x1; x <= x2; x++) {
208 if (centersign * ((point_x[0] - x) * (point_y[1] - y) - (point_y[0] - y) * (point_x[1] - x)) >= 0
209 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
210 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
211 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
212 (void)affect_monster(caster_ptr, 0, 0, y, x, dam, GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
219 msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
220 remove_mirror(caster_ptr, point_y[0], point_x[0]);
227 * @brief 鏡魔法「鏡の封印」の効果処理
229 * @return 効果があったらTRUEを返す
231 void seal_of_mirror(player_type *caster_ptr, HIT_POINT dam)
233 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++) {
234 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++) {
235 if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
238 if (!affect_monster(caster_ptr, 0, 0, y, x, dam, GF_GENOCIDE, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
241 if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
242 remove_mirror(caster_ptr, y, x);
249 * 幻惑の光 @ 鏡使いだけでなく混沌の戦士も使える
250 * @param creature_ptr プレーヤーへの参照ポインタ
253 bool confusing_light(player_type *creature_ptr)
255 msg_print(_("辺りを睨んだ...", "You glare at nearby monsters..."));
256 slow_monsters(creature_ptr, creature_ptr->lev);
257 stun_monsters(creature_ptr, creature_ptr->lev * 4);
258 confuse_monsters(creature_ptr, creature_ptr->lev * 4);
259 turn_monsters(creature_ptr, creature_ptr->lev * 4);
260 stasis_monsters(creature_ptr, creature_ptr->lev * 4);
266 * @return 実際に設置が行われた場合TRUEを返す
268 bool place_mirror(player_type *caster_ptr)
270 if (!cave_clean_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x)) {
271 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
275 /* Create a mirror */
276 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_OBJECT;
277 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].mimic = feat_mirror;
279 /* Turn on the light */
280 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_GLOW;
282 note_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
283 lite_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
284 update_local_illumination(caster_ptr, caster_ptr->y, caster_ptr->x);
290 * @brief 鏡抜け処理のメインルーチン /
291 * Mirror Master's Dimension Door
292 * @param caster_ptr プレーヤーへの参照ポインタ
293 * @return ターンを消費した場合TRUEを返す
295 bool mirror_tunnel(player_type *caster_ptr)
297 POSITION x = 0, y = 0;
298 if (!tgt_pt(caster_ptr, &x, &y))
300 if (exe_dimension_door(caster_ptr, x, y))
303 msg_print(_("鏡の世界をうまく通れなかった!", "You could not enter the mirror!"));
308 * Set "multishadow", notice observable changes
310 bool set_multishadow(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
313 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
315 if (creature_ptr->is_dead)
319 if (creature_ptr->multishadow && !do_dec) {
320 if (creature_ptr->multishadow > v)
322 } else if (!creature_ptr->multishadow) {
323 msg_print(_("あなたの周りに幻影が生まれた。", "Your Shadow enveloped you."));
327 if (creature_ptr->multishadow) {
328 msg_print(_("幻影が消えた。", "Your Shadow disappears."));
333 creature_ptr->multishadow = v;
334 creature_ptr->redraw |= (PR_STATUS);
340 disturb(creature_ptr, FALSE, FALSE);
341 creature_ptr->update |= (PU_BONUS);
342 handle_stuff(creature_ptr);
347 * @brief 一時的破片のオーラの継続時間をセットする / Set "dustrobe", notice observable changes
349 * @param do_dec 現在の継続時間より長い値のみ上書きする
350 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
352 bool set_dustrobe(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
355 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
357 if (creature_ptr->is_dead)
361 if (creature_ptr->dustrobe && !do_dec) {
362 if (creature_ptr->dustrobe > v)
364 } else if (!creature_ptr->dustrobe) {
365 msg_print(_("体が鏡のオーラで覆われた。", "You are enveloped by mirror shards."));
369 if (creature_ptr->dustrobe) {
370 msg_print(_("鏡のオーラが消えた。", "The mirror shards disappear."));
375 creature_ptr->dustrobe = v;
376 creature_ptr->redraw |= (PR_STATUS);
382 disturb(creature_ptr, FALSE, FALSE);
383 creature_ptr->update |= (PU_BONUS);
384 handle_stuff(creature_ptr);
389 * @brief 現在フロアに存在している鏡の数を数える / calculate mirrors
392 static int number_of_mirrors(floor_type *floor_ptr)
395 for (POSITION x = 0; x < floor_ptr->width; x++) {
396 for (POSITION y = 0; y < floor_ptr->height; y++) {
397 if (is_mirror_grid(&floor_ptr->grid_array[y][x]))
407 * do_cmd_cast calls this function if the player's class is 'Mirror magic'.
408 * @param spell 発動する特殊技能のID
409 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
411 bool cast_mirror_spell(player_type *caster_ptr, mind_mirror_master_type spell)
414 PLAYER_LEVEL plev = caster_ptr->lev;
420 tmp = is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]) ? 4 : 0;
422 detect_monsters_normal(caster_ptr, DETECT_RAD_DEFAULT);
424 detect_monsters_invis(caster_ptr, DETECT_RAD_DEFAULT);
426 set_tim_esp(caster_ptr, (TIME_EFFECT)plev, FALSE);
428 map_area(caster_ptr, DETECT_RAD_MAP);
429 if (tmp == 0 && plev < 5) {
430 msg_print(_("鏡がなくて集中できなかった!", "You need a mirror to concentrate!"));
434 if (number_of_mirrors(caster_ptr->current_floor_ptr) < 4 + plev / 10)
435 place_mirror(caster_ptr);
437 msg_format(_("これ以上鏡は制御できない!", "There are too many mirrors to control!"));
441 if (!get_aim_dir(caster_ptr, &dir))
444 if (plev > 9 && is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]))
445 fire_beam(caster_ptr, GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
447 fire_bolt(caster_ptr, GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
451 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
454 (void)lite_area(caster_ptr, damroll(2, (plev / 2)), (plev / 10) + 1);
456 case WANDERING_MIRROR:
457 teleport_player(caster_ptr, plev * 5, TELEPORT_SPONTANEOUS);
460 set_dustrobe(caster_ptr, 20 + randint1(20), FALSE);
462 case BANISHING_MIRROR:
463 if (!get_aim_dir(caster_ptr, &dir))
466 (void)fire_beam(caster_ptr, GF_AWAY_ALL, dir, plev);
468 case MIRROR_CRASHING:
469 if (!get_aim_dir(caster_ptr, &dir))
472 fire_ball(caster_ptr, GF_SHARDS, dir, damroll(8 + ((plev - 5) / 4), 8), (plev > 20 ? (plev - 20) / 8 + 1 : 0));
474 case SLEEPING_MIRROR:
475 for (x = 0; x < caster_ptr->current_floor_ptr->width; x++)
476 for (y = 0; y < caster_ptr->current_floor_ptr->height; y++)
477 if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
478 project(caster_ptr, 0, 2, y, x, (HIT_POINT)plev, GF_OLD_SLEEP,
479 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
483 if (!get_aim_dir(caster_ptr, &dir))
486 fire_beam(caster_ptr, GF_SEEKER, dir, damroll(11 + (plev - 5) / 4, 8));
489 seal_of_mirror(caster_ptr, plev * 4 + 100);
492 t = 20 + randint1(20);
493 set_shield(caster_ptr, t, FALSE);
495 set_tim_reflect(caster_ptr, t, FALSE);
498 set_resist_magic(caster_ptr, t, FALSE);
502 if (!get_aim_dir(caster_ptr, &dir))
505 fire_beam(caster_ptr, GF_SUPER_RAY, dir, 150 + randint1(2 * plev));
508 tmp = is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x]) ? 4 : 3;
509 slow_monsters(caster_ptr, plev);
510 stun_monsters(caster_ptr, plev * tmp * 2);
511 confuse_monsters(caster_ptr, plev * tmp);
512 turn_monsters(caster_ptr, plev * tmp);
513 stasis_monsters(caster_ptr, plev * tmp);
516 if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x])) {
517 msg_print(_("鏡の国の場所がわからない!", "You cannot find out where the mirror is!"));
521 reserve_alter_reality(caster_ptr, randint0(21) + 15);
524 msg_print(_("鏡の世界を通り抜け… ", "You try to enter the mirror..."));
525 return mirror_tunnel(caster_ptr);
527 return recall_player(caster_ptr, randint0(21) + 15);
529 set_multishadow(caster_ptr, 6 + randint1(6), FALSE);
532 if (!binding_field(caster_ptr, plev * 11 + 5))
533 msg_print(_("適当な鏡を選べなかった!", "You were not able to choose suitable mirrors!"));
537 (void)set_invuln(caster_ptr, randint1(4) + 4, FALSE);
540 msg_print(_("なに?", "Zap?"));
544 caster_ptr->magic_num1[0] = 0;