3 * @brief 魔法による遠隔処理の実装 / Spell projection
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
23 #include "object-curse.h"
24 #include "player-damage.h"
25 #include "player-effects.h"
26 #include "player-race.h"
27 #include "player-class.h"
30 #include "monster-status.h"
31 #include "monster-spell.h"
33 #include "spells-status.h"
34 #include "spells-diceroll.h"
35 #include "spells-summon.h"
36 #include "monsterrace-hook.h"
44 #include "player-status.h"
45 #include "player-move.h"
46 #include "realm-hex.h"
47 #include "realm-song.h"
48 #include "object-hook.h"
49 #include "object-broken.h"
50 #include "object-flavor.h"
55 #include "view-mainwindow.h"
59 static int rakubadam_m; /*!< 振り落とされた際のダメージ量 */
60 static int rakubadam_p; /*!< 落馬した際のダメージ量 */
63 int project_length = 0; /*!< 投射の射程距離 */
69 STR_OFFSET cap_nickname;
72 * @brief 歌、剣術、呪術領域情報テーブル
74 const magic_type technic_info[NUM_TECHNIC][32] =
197 * @brief 配置した鏡リストの次を取得する /
198 * Get another mirror. for SEEKER
199 * @param next_y 次の鏡のy座標を返す参照ポインタ
200 * @param next_x 次の鏡のx座標を返す参照ポインタ
201 * @param cury 現在の鏡のy座標
202 * @param curx 現在の鏡のx座標
204 static void next_mirror(player_type *creature_ptr, POSITION* next_y, POSITION* next_x, POSITION cury, POSITION curx)
206 POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
207 int mirror_num = 0; /* 鏡の数 */
211 for (x = 0; x < creature_ptr->current_floor_ptr->width; x++)
213 for (y = 0; y < creature_ptr->current_floor_ptr->height; y++)
215 if (is_mirror_grid(&creature_ptr->current_floor_ptr->grid_array[y][x])) {
216 mirror_y[mirror_num] = y;
217 mirror_x[mirror_num] = x;
224 num = randint0(mirror_num);
225 *next_y = mirror_y[num];
226 *next_x = mirror_x[num];
229 *next_y = cury + randint0(5) - 2;
230 *next_x = curx + randint0(5) - 2;
236 * Mega-Hack -- track "affected" monsters (see "project()" comments)
238 static int project_m_n; /*!< 魔法効果範囲内にいるモンスターの数 */
239 static POSITION project_m_x; /*!< 処理中のモンスターX座標 */
240 static POSITION project_m_y; /*!< 処理中のモンスターY座標 */
241 /* Mega-Hack -- monsters target */
242 static POSITION monster_target_x; /*!< モンスターの攻撃目標X座標 */
243 static POSITION monster_target_y; /*!< モンスターの攻撃目標Y座標 */
247 * @brief 汎用的なビーム/ボルト/ボール系による地形効果処理 / We are called from "project()" to "damage" terrain features
248 * @param caster_ptr プレーヤーへの参照ポインタ
249 * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
250 * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
251 * @param y 目標Y座標 / Target y location (or location to travel "towards")
252 * @param x 目標X座標 / Target x location (or location to travel "towards")
253 * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
254 * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
255 * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
258 * We are called both for "beam" effects and "ball" effects.
260 * The "r" parameter is the "distance from ground zero".
262 * Note that we determine if the player can "see" anything that happens
263 * by taking into account: blindness, line-of-sight, and illumination.
265 * We return "TRUE" if the effect of the projection is "obvious".
267 * We also "see" grids which are "memorized", probably a hack
269 * Perhaps we should affect doors?
272 static bool project_f(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
274 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
275 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
276 feature_type *f_ptr = &f_info[g_ptr->feat];
278 bool obvious = FALSE;
279 bool known = player_has_los_bold(caster_ptr, y, x);
283 /* Reduce damage by distance */
284 dam = (dam + r) / (r + 1);
286 if (have_flag(f_ptr->flags, FF_TREE))
294 message = _("枯れた", "was blasted."); break;
296 message = _("縮んだ", "shrank."); break;
298 message = _("溶けた", "melted."); break;
301 message = _("凍り、砕け散った", "was frozen and smashed."); break;
305 message = _("燃えた", "burns up!"); break;
317 message = _("粉砕された", "was crushed."); break;
319 message = NULL; break;
323 msg_format(_("木は%s。", "A tree %s"), message);
324 cave_set_feat(caster_ptr, y, x, one_in_(3) ? feat_brake : feat_grass);
327 if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
331 /* Analyze the type */
334 /* Ignore most effects */
369 /* Destroy Traps (and Locks) */
372 /* Reveal secret doors */
373 if (is_hidden_door(caster_ptr, g_ptr))
376 disclose_grid(caster_ptr, y, x);
378 /* Check line of sight */
386 if (is_trap(caster_ptr, g_ptr->feat))
388 /* Check line of sight */
391 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
395 /* Destroy the trap */
396 cave_alter_feat(caster_ptr, y, x, FF_DISARM);
399 /* Locked doors are unlocked */
400 if (is_closed_door(caster_ptr, g_ptr->feat) && f_ptr->power && have_flag(f_ptr->flags, FF_OPEN))
402 FEAT_IDX old_feat = g_ptr->feat;
404 /* Unlock the door */
405 cave_alter_feat(caster_ptr, y, x, FF_DISARM);
407 /* Check line of sound */
408 if (known && (old_feat != g_ptr->feat))
410 msg_print(_("カチッと音がした!", "Click!"));
415 /* Remove "unsafe" flag if player is not blind */
416 if (!caster_ptr->blind && player_has_los_bold(caster_ptr, y, x))
418 g_ptr->info &= ~(CAVE_UNSAFE);
419 lite_spot(caster_ptr, y, x);
426 /* Destroy Doors (and traps) */
429 /* Destroy all doors and traps */
430 if (is_trap(caster_ptr, g_ptr->feat) || have_flag(f_ptr->flags, FF_DOOR))
432 /* Check line of sight */
435 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
439 /* Destroy the feature */
440 cave_alter_feat(caster_ptr, y, x, FF_TUNNEL);
443 /* Remove "unsafe" flag if player is not blind */
444 if (!caster_ptr->blind && player_has_los_bold(caster_ptr, y, x))
446 g_ptr->info &= ~(CAVE_UNSAFE);
447 lite_spot(caster_ptr, y, x);
454 case GF_JAM_DOOR: /* Jams a door (as if with a spike) */
456 if (have_flag(f_ptr->flags, FF_SPIKE))
458 s16b old_mimic = g_ptr->mimic;
459 feature_type *mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
461 cave_alter_feat(caster_ptr, y, x, FF_SPIKE);
462 g_ptr->mimic = old_mimic;
464 note_spot(caster_ptr, y, x);
465 lite_spot(caster_ptr, y, x);
467 /* Check line of sight */
468 if (known && have_flag(mimic_f_ptr->flags, FF_OPEN))
470 msg_format(_("%sに何かがつっかえて開かなくなった。", "The %s seems stuck."), f_name + mimic_f_ptr->name);
478 /* Destroy walls (and doors) */
481 if (have_flag(f_ptr->flags, FF_HURT_ROCK))
483 if (known && (g_ptr->info & (CAVE_MARK)))
485 msg_format(_("%sが溶けて泥になった!", "The %s turns into mud!"), f_name + f_info[get_feat_mimic(g_ptr)].name);
489 /* Destroy the wall */
490 cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK);
491 caster_ptr->update |= (PU_FLOW);
499 if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
500 if (player_bold(caster_ptr, y, x)) break;
501 cave_set_feat(caster_ptr, y, x, feat_door[DOOR_DOOR].closed);
502 if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
508 place_trap(caster_ptr, y, x);
514 if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
515 if (player_bold(caster_ptr, y, x)) break;
516 cave_set_feat(caster_ptr, y, x, feat_tree);
517 if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
523 if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
524 g_ptr->info |= CAVE_OBJECT;
525 g_ptr->mimic = feat_glyph;
526 note_spot(caster_ptr, y, x);
527 lite_spot(caster_ptr, y, x);
533 if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
534 if (player_bold(caster_ptr, y, x)) break;
535 cave_set_feat(caster_ptr, y, x, feat_granite);
541 if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
544 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
545 cave_set_feat(caster_ptr, y, x, feat_shallow_lava);
549 cave_set_feat(caster_ptr, y, x, feat_deep_lava);
557 if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
560 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
561 cave_set_feat(caster_ptr, y, x, feat_shallow_water);
565 cave_set_feat(caster_ptr, y, x, feat_deep_water);
571 /* Lite up the grid */
575 /* Turn on the light */
576 if (!(d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
578 g_ptr->info |= (CAVE_GLOW);
579 note_spot(caster_ptr, y, x);
580 lite_spot(caster_ptr, y, x);
581 update_local_illumination(caster_ptr, y, x);
584 if (player_can_see_bold(caster_ptr, y, x)) obvious = TRUE;
586 /* Mega-Hack -- Update the monster in the affected grid */
587 /* This allows "spear of light" (etc) to work "correctly" */
588 if (g_ptr->m_idx) update_monster(caster_ptr, g_ptr->m_idx, FALSE);
590 if (caster_ptr->special_defense & NINJA_S_STEALTH)
592 if (player_bold(caster_ptr, y, x)) set_superstealth(caster_ptr, FALSE);
599 /* Darken the grid */
603 bool do_dark = !caster_ptr->phase_out && !is_mirror_grid(g_ptr);
606 /* Turn off the light. */
609 if (floor_ptr->dun_level || !is_daytime())
611 for (j = 0; j < 9; j++)
613 int by = y + ddy_ddd[j];
614 int bx = x + ddx_ddd[j];
616 if (in_bounds2(floor_ptr, by, bx))
618 grid_type *cc_ptr = &floor_ptr->grid_array[by][bx];
620 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
631 g_ptr->info &= ~(CAVE_GLOW);
633 /* Hack -- Forget "boring" grids */
634 if (!have_flag(f_ptr->flags, FF_REMEMBER))
637 g_ptr->info &= ~(CAVE_MARK);
639 note_spot(caster_ptr, y, x);
642 lite_spot(caster_ptr, y, x);
644 update_local_illumination(caster_ptr, y, x);
646 if (player_can_see_bold(caster_ptr, y, x)) obvious = TRUE;
648 /* Mega-Hack -- Update the monster in the affected grid */
649 /* This allows "spear of light" (etc) to work "correctly" */
650 if (g_ptr->m_idx) update_monster(caster_ptr, g_ptr->m_idx, FALSE);
660 if (is_mirror_grid(g_ptr))
662 msg_print(_("鏡が割れた!", "The mirror was shattered!"));
664 remove_mirror(caster_ptr, y, x);
665 project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
668 if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 50))
670 if (known && (g_ptr->info & CAVE_MARK))
672 msg_format(_("%sが割れた!", "The %s crumbled!"), f_name + f_info[get_feat_mimic(g_ptr)].name);
676 /* Destroy the wall */
677 cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK);
678 caster_ptr->update |= (PU_FLOW);
686 if (is_mirror_grid(g_ptr) && caster_ptr->lev < 40)
688 msg_print(_("鏡が割れた!", "The mirror was shattered!"));
690 remove_mirror(caster_ptr, y, x);
691 project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
694 if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 200))
696 if (known && (g_ptr->info & CAVE_MARK))
698 msg_format(_("%sが割れた!", "The %s crumbled!"), f_name + f_info[get_feat_mimic(g_ptr)].name);
702 /* Destroy the wall */
703 cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK);
704 caster_ptr->update |= (PU_FLOW);
710 case GF_DISINTEGRATE:
712 /* Destroy mirror/glyph */
713 if (is_mirror_grid(g_ptr) || is_glyph_grid(g_ptr) || is_explosive_rune_grid(g_ptr))
714 remove_mirror(caster_ptr, y, x);
716 /* Permanent features don't get effect */
717 /* But not protect monsters and other objects */
718 if (have_flag(f_ptr->flags, FF_HURT_DISI) && !have_flag(f_ptr->flags, FF_PERMANENT))
720 cave_alter_feat(caster_ptr, y, x, FF_HURT_DISI);
722 /* Update some things -- similar to GF_KILL_WALL */
723 caster_ptr->update |= (PU_FLOW);
730 lite_spot(caster_ptr, y, x);
731 /* Return "Anything seen?" */
738 * @brief 汎用的なビーム/ボルト/ボール系によるアイテムオブジェクトへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
739 * @param caster_ptr プレーヤーへの参照ポインタ
740 * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
741 * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
742 * @param y 目標Y座標 / Target y location (or location to travel "towards")
743 * @param x 目標X座標 / Target x location (or location to travel "towards")
744 * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
745 * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
746 * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
749 * We are called from "project()" to "damage" objects
751 * We are called both for "beam" effects and "ball" effects.
753 * Perhaps we should only SOMETIMES damage things on the ground.
755 * The "r" parameter is the "distance from ground zero".
757 * Note that we determine if the player can "see" anything that happens
758 * by taking into account: blindness, line-of-sight, and illumination.
760 * We also "see" grids which are "memorized", probably a hack
762 * We return "TRUE" if the effect of the projection is "obvious".
765 static bool project_o(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
767 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
769 OBJECT_IDX this_o_idx, next_o_idx = 0;
771 bool obvious = FALSE;
772 bool known = player_has_los_bold(caster_ptr, y, x);
774 BIT_FLAGS flgs[TR_FLAG_SIZE];
776 GAME_TEXT o_name[MAX_NLEN];
778 KIND_OBJECT_IDX k_idx = 0;
779 bool is_potion = FALSE;
784 /* Reduce damage by distance */
785 dam = (dam + r) / (r + 1);
788 /* Scan all objects in the grid */
789 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
791 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[this_o_idx];
795 bool do_kill = FALSE;
797 concptr note_kill = NULL;
802 /* Get the "plural"-ness */
803 bool plural = (o_ptr->number > 1);
805 next_o_idx = o_ptr->next_o_idx;
806 object_flags(o_ptr, flgs);
808 /* Check for artifact */
809 if (object_is_artifact(o_ptr)) is_art = TRUE;
811 /* Analyze the type */
814 /* Acid -- Lots of things */
817 if (hates_acid(o_ptr))
820 note_kill = _("融けてしまった!", (plural ? " melt!" : " melts!"));
821 if (have_flag(flgs, TR_IGNORE_ACID)) ignore = TRUE;
826 /* Elec -- Rings and Wands */
829 if (hates_elec(o_ptr))
832 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
833 if (have_flag(flgs, TR_IGNORE_ELEC)) ignore = TRUE;
838 /* Fire -- Flammable objects */
841 if (hates_fire(o_ptr))
844 note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
845 if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
850 /* Cold -- potions and flasks */
853 if (hates_cold(o_ptr))
855 note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
857 if (have_flag(flgs, TR_IGNORE_COLD)) ignore = TRUE;
865 if (hates_fire(o_ptr))
868 note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
869 if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
871 if (hates_elec(o_ptr))
875 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
876 if (have_flag(flgs, TR_IGNORE_ELEC)) ignore = TRUE;
884 if (hates_fire(o_ptr))
887 note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
888 if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
890 if (hates_cold(o_ptr))
894 note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
895 if (have_flag(flgs, TR_IGNORE_COLD)) ignore = TRUE;
900 /* Hack -- break potions and such */
906 if (hates_cold(o_ptr))
908 note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
914 /* Mana and Chaos -- destroy everything */
920 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
924 case GF_DISINTEGRATE:
927 note_kill = _("蒸発してしまった!", (plural ? " evaporate!" : " evaporates!"));
934 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
935 if (have_flag(flgs, TR_RES_CHAOS)) ignore = TRUE;
936 else if ((o_ptr->tval == TV_SCROLL) && (o_ptr->sval == SV_SCROLL_CHAOS)) ignore = TRUE;
940 /* Holy Fire and Hell Fire -- destroys cursed non-artifacts */
944 if (object_is_cursed(o_ptr))
947 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
954 identify_item(caster_ptr, o_ptr);
956 /* Auto-inscription */
957 autopick_alter_item(caster_ptr, (-this_o_idx), FALSE);
965 /* Chests are noticed only if trapped or locked */
966 if (o_ptr->tval == TV_CHEST)
968 /* Disarm/Unlock traps */
971 /* Disarm or Unlock */
972 o_ptr->pval = (0 - o_ptr->pval);
977 if (known && (o_ptr->marked & OM_FOUND))
979 msg_print(_("カチッと音がした!", "Click!"));
989 if (o_ptr->tval == TV_CORPSE)
994 if (!who || is_pet(&caster_ptr->current_floor_ptr->m_list[who]))
995 mode |= PM_FORCE_PET;
997 for (i = 0; i < o_ptr->number; i++)
999 if (((o_ptr->sval == SV_CORPSE) && (randint1(100) > 80)) ||
1000 ((o_ptr->sval == SV_SKELETON) && (randint1(100) > 60)))
1004 note_kill = _("灰になった。", (plural ? " become dust." : " becomes dust."));
1008 else if (summon_named_creature(caster_ptr, who, y, x, o_ptr->pval, mode))
1010 note_kill = _("生き返った。", " revived.");
1012 else if (!note_kill)
1014 note_kill = _("灰になった。", (plural ? " become dust." : " becomes dust."));
1025 /* Attempt to destroy the object */
1028 /* Effect "observed" */
1029 if (known && (o_ptr->marked & OM_FOUND))
1032 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1035 /* Artifacts, and other objects, get to resist */
1036 if (is_art || ignore)
1038 /* Observe the resist */
1039 if (known && (o_ptr->marked & OM_FOUND))
1041 msg_format(_("%sは影響を受けない!",
1042 (plural ? "The %s are unaffected!" : "The %s is unaffected!")), o_name);
1049 /* Describe if needed */
1050 if (known && (o_ptr->marked & OM_FOUND) && note_kill)
1052 msg_format(_("%sは%s", "The %s%s"), o_name, note_kill);
1055 k_idx = o_ptr->k_idx;
1056 is_potion = object_is_potion(o_ptr);
1057 delete_object_idx(caster_ptr, this_o_idx);
1059 /* Potions produce effects when 'shattered' */
1062 (void)potion_smash_effect(caster_ptr, who, y, x, k_idx);
1065 lite_spot(caster_ptr, y, x);
1070 /* Return "Anything seen?" */
1076 * @brief 汎用的なビーム/ボルト/ボール系によるモンスターへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
1077 * @param caster_ptr プレーヤーへの参照ポインタ
1078 * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
1079 * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
1080 * @param y 目標Y座標 / Target y location (or location to travel "towards")
1081 * @param x 目標X座標 / Target x location (or location to travel "towards")
1082 * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
1083 * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
1085 * @param see_s_msg TRUEならばメッセージを表示する
1086 * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
1089 * This routine takes a "source monster" (by index) which is mostly used to
1090 * determine if the player is causing the damage, and a "radius" (see below),
1091 * which is used to decrease the power of explosions with distance, and a
1092 * location, via integers which are modified by certain types of attacks
1093 * (polymorph and teleport being the obvious ones), a default damage, which
1094 * is modified as needed based on various properties, and finally a "damage
1095 * type" (see below).
1098 * Note that this routine can handle "no damage" attacks (like teleport) by
1099 * taking a "zero" damage, and can even take "parameters" to attacks (like
1100 * confuse) by accepting a "damage", using it to calculate the effect, and
1101 * then setting the damage to zero. Note that the "damage" parameter is
1102 * divided by the radius, so monsters not at the "epicenter" will not take
1103 * as much damage (or whatever)...
1106 * Note that "polymorph" is dangerous, since a failure in "place_monster()"'
1107 * may result in a dereference of an invalid pointer.
1110 * Various messages are produced, and damage is applied.
1113 * Just "casting" a substance (i.e. plasma) does not make you immune, you must
1114 * actually be "made" of that substance, or "breathe" big balls of it.
1115 * We assume that "Plasma" monsters, and "Plasma" breathers, are immune
1117 * We assume "Nether" is an evil, necromantic force, so it doesn't hurt undead,
1118 * and hurts evil less. If can breath nether, then it resists it as well.
1121 * Damage reductions use the following formulas:
1122 * Note that "dam = dam * 6 / (randint1(6) + 6);"
1123 * gives avg damage of .655, ranging from .858 to .500
1124 * Note that "dam = dam * 5 / (randint1(6) + 6);"
1125 * gives avg damage of .544, ranging from .714 to .417
1126 * Note that "dam = dam * 4 / (randint1(6) + 6);"
1127 * gives avg damage of .444, ranging from .556 to .333
1128 * Note that "dam = dam * 3 / (randint1(6) + 6);"
1129 * gives avg damage of .327, ranging from .427 to .250
1130 * Note that "dam = dam * 2 / (randint1(6) + 6);"
1131 * gives something simple.
1134 * In this function, "result" messages are postponed until the end, where
1135 * the "note" string is appended to the monster name, if not NULL. So,
1136 * to make a spell have "no effect" just set "note" to NULL. You should
1137 * also set "notice" to FALSE, or the player will learn what the spell does.
1140 * We attempt to return "TRUE" if the player saw anything "useful" happen.
1144 static bool project_m(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, bool see_s_msg)
1148 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
1149 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1151 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
1152 monster_type *m_caster_ptr = (who > 0) ? &floor_ptr->m_list[who] : NULL;
1154 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1158 /* Is the monster "seen"? */
1159 bool seen = m_ptr->ml;
1160 bool seen_msg = is_seen(m_ptr);
1162 bool slept = (bool)MON_CSLEEP(m_ptr);
1164 /* Were the effects "obvious" (if seen)? */
1165 bool obvious = FALSE;
1167 /* Can the player know about this effect? */
1168 bool known = ((m_ptr->cdis <= MAX_SIGHT) || caster_ptr->phase_out);
1170 /* Were the effects "irrelevant"? */
1171 bool skipped = FALSE;
1173 /* Gets the monster angry at the source of the effect? */
1174 bool get_angry = FALSE;
1176 /* Polymorph setting (true or false) */
1177 bool do_poly = FALSE;
1179 /* Teleport setting (max distance) */
1182 /* Confusion setting (amount to confuse) */
1185 /* Stunning setting (amount to stun) */
1188 /* Sleep amount (amount to sleep) */
1191 /* Fear amount (amount to fear) */
1194 /* Time amount (amount to time) */
1197 bool heal_leper = FALSE;
1199 /* Hold the monster name */
1200 GAME_TEXT m_name[MAX_NLEN];
1203 PARAMETER_VALUE photo = 0;
1205 /* Assume no note */
1206 concptr note = NULL;
1208 /* Assume a default death */
1209 concptr note_dies = extract_note_dies(real_r_idx(m_ptr));
1211 DEPTH caster_lev = (who > 0) ? r_info[m_caster_ptr->r_idx].level : (caster_ptr->lev * 2);
1214 if (!g_ptr->m_idx) return FALSE;
1216 /* Never affect projector */
1217 if (who && (g_ptr->m_idx == who)) return FALSE;
1218 if ((g_ptr->m_idx == caster_ptr->riding) && !who && !(typ == GF_OLD_HEAL) && !(typ == GF_OLD_SPEED) && !(typ == GF_STAR_HEAL)) return FALSE;
1219 if (sukekaku && ((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) return FALSE;
1221 /* Don't affect already death monsters */
1222 /* Prevents problems with chain reactions of exploding monsters */
1223 if (m_ptr->hp < 0) return FALSE;
1225 /* Reduce damage by distance */
1226 dam = (dam + r) / (r + 1);
1229 /* Get the monster name (BEFORE polymorphing) */
1230 monster_desc(caster_ptr, m_name, m_ptr, 0);
1232 /* Get the monster possessive ("his"/"her"/"its") */
1233 monster_desc(caster_ptr, m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
1235 if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) disturb(caster_ptr, TRUE, TRUE);
1237 if (r_ptr->flagsr & RFR_RES_ALL &&
1238 typ != GF_OLD_CLONE && typ != GF_STAR_HEAL && typ != GF_OLD_HEAL
1239 && typ != GF_OLD_SPEED && typ != GF_CAPTURE && typ != GF_PHOTO)
1241 note = _("には完全な耐性がある!", " is immune.");
1243 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1244 if (typ == GF_LITE_WEAK || typ == GF_KILL_WALL) skipped = TRUE;
1248 /* Analyze the damage type */
1251 /* Magic Missile -- pure damage */
1254 if (seen) obvious = TRUE;
1261 if (seen) obvious = TRUE;
1262 if (r_ptr->flagsr & RFR_IM_ACID)
1264 note = _("にはかなり耐性がある!", " resists a lot.");
1266 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_IM_ACID);
1274 if (seen) obvious = TRUE;
1275 if (r_ptr->flagsr & RFR_IM_ELEC)
1277 note = _("にはかなり耐性がある!", " resists a lot.");
1279 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_IM_ELEC);
1287 if (seen) obvious = TRUE;
1288 if (r_ptr->flagsr & RFR_IM_FIRE)
1290 note = _("にはかなり耐性がある!", " resists a lot.");
1292 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_IM_FIRE);
1294 else if (r_ptr->flags3 & (RF3_HURT_FIRE))
1296 note = _("はひどい痛手をうけた。", " is hit hard.");
1298 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_FIRE);
1306 if (seen) obvious = TRUE;
1307 if (r_ptr->flagsr & RFR_IM_COLD)
1309 note = _("にはかなり耐性がある!", " resists a lot.");
1311 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_IM_COLD);
1313 else if (r_ptr->flags3 & (RF3_HURT_COLD))
1315 note = _("はひどい痛手をうけた。", " is hit hard.");
1317 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_COLD);
1325 if (seen) obvious = TRUE;
1326 if (r_ptr->flagsr & RFR_IM_POIS)
1328 note = _("にはかなり耐性がある!", " resists a lot.");
1330 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_IM_POIS);
1338 if (seen) obvious = TRUE;
1339 if (r_ptr->flagsr & RFR_IM_POIS)
1341 note = _("には耐性がある。", " resists.");
1342 dam *= 3; dam /= randint1(6) + 6;
1343 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_IM_POIS);
1345 else if (one_in_(3)) do_poly = TRUE;
1349 /* Hellfire -- hurts Evil */
1352 if (seen) obvious = TRUE;
1353 if (r_ptr->flags3 & RF3_GOOD)
1355 note = _("はひどい痛手をうけた。", " is hit hard.");
1357 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
1362 /* Holy Fire -- hurts Evil, Good are immune, others _resist_ */
1365 if (seen) obvious = TRUE;
1366 if (r_ptr->flags3 & RF3_EVIL)
1369 note = _("はひどい痛手をうけた。", " is hit hard.");
1370 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= RF3_EVIL;
1374 note = _("には耐性がある。", " resists.");
1375 dam *= 3; dam /= randint1(6) + 6;
1380 /* Arrow -- XXX no defense */
1383 if (seen) obvious = TRUE;
1387 /* Plasma -- XXX perhaps check ELEC or FIRE */
1390 if (seen) obvious = TRUE;
1391 if (r_ptr->flagsr & RFR_RES_PLAS)
1393 note = _("には耐性がある。", " resists.");
1394 dam *= 3; dam /= randint1(6) + 6;
1395 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_PLAS);
1400 /* Nether -- see above */
1403 if (seen) obvious = TRUE;
1404 if (r_ptr->flagsr & RFR_RES_NETH)
1406 if (r_ptr->flags3 & RF3_UNDEAD)
1408 note = _("には完全な耐性がある!", " is immune.");
1410 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
1414 note = _("には耐性がある。", " resists.");
1415 dam *= 3; dam /= randint1(6) + 6;
1417 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_NETH);
1419 else if (r_ptr->flags3 & RF3_EVIL)
1421 note = _("はいくらか耐性を示した。", " resists somewhat.");
1423 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
1428 /* Water (acid) damage -- Water spirits/elementals are immune */
1431 if (seen) obvious = TRUE;
1432 if (r_ptr->flagsr & RFR_RES_WATE)
1434 if ((m_ptr->r_idx == MON_WATER_ELEM) || (m_ptr->r_idx == MON_UNMAKER))
1436 note = _("には完全な耐性がある!", " is immune.");
1441 note = _("には耐性がある。", " resists.");
1442 dam *= 3; dam /= randint1(6) + 6;
1444 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_WATE);
1449 /* Chaos -- Chaos breathers resist */
1452 if (seen) obvious = TRUE;
1453 if (r_ptr->flagsr & RFR_RES_CHAO)
1455 note = _("には耐性がある。", " resists.");
1456 dam *= 3; dam /= randint1(6) + 6;
1457 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_CHAO);
1459 else if ((r_ptr->flags3 & RF3_DEMON) && one_in_(3))
1461 note = _("はいくらか耐性を示した。", " resists somewhat.");
1462 dam *= 3; dam /= randint1(6) + 6;
1463 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
1468 do_conf = (5 + randint1(11) + r) / (r + 1);
1473 /* Shards -- Shard breathers resist */
1476 if (seen) obvious = TRUE;
1477 if (r_ptr->flagsr & RFR_RES_SHAR)
1479 note = _("には耐性がある。", " resists.");
1480 dam *= 3; dam /= randint1(6) + 6;
1481 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SHAR);
1486 /* Rocket: Shard resistance helps */
1489 if (seen) obvious = TRUE;
1490 if (r_ptr->flagsr & RFR_RES_SHAR)
1492 note = _("はいくらか耐性を示した。", " resists somewhat.");
1494 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SHAR);
1500 /* Sound -- Sound breathers resist */
1503 if (seen) obvious = TRUE;
1504 if (r_ptr->flagsr & RFR_RES_SOUN)
1506 note = _("には耐性がある。", " resists.");
1507 dam *= 2; dam /= randint1(6) + 6;
1508 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SOUN);
1510 else do_stun = (10 + randint1(15) + r) / (r + 1);
1517 if (seen) obvious = TRUE;
1518 if (r_ptr->flags3 & RF3_NO_CONF)
1520 note = _("には耐性がある。", " resists.");
1521 dam *= 3; dam /= randint1(6) + 6;
1522 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
1524 else do_conf = (10 + randint1(15) + r) / (r + 1);
1528 /* Disenchantment -- Breathers and Disenchanters resist */
1531 if (seen) obvious = TRUE;
1532 if (r_ptr->flagsr & RFR_RES_DISE)
1534 note = _("には耐性がある。", " resists.");
1535 dam *= 3; dam /= randint1(6) + 6;
1536 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_DISE);
1541 /* Nexus -- Breathers and Existers resist */
1544 if (seen) obvious = TRUE;
1545 if (r_ptr->flagsr & RFR_RES_NEXU)
1547 note = _("には耐性がある。", " resists.");
1548 dam *= 3; dam /= randint1(6) + 6;
1549 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_NEXU);
1557 if (seen) obvious = TRUE;
1558 if (r_ptr->flagsr & RFR_RES_WALL)
1560 note = _("には耐性がある。", " resists.");
1561 dam *= 3; dam /= randint1(6) + 6;
1562 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_WALL);
1564 else do_stun = (randint1(15) + r) / (r + 1);
1568 /* Inertia -- breathers resist */
1571 if (seen) obvious = TRUE;
1572 if (r_ptr->flagsr & RFR_RES_INER)
1574 note = _("には耐性がある。", " resists.");
1575 dam *= 3; dam /= randint1(6) + 6;
1576 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_INER);
1580 /* Powerful monsters can resist */
1581 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
1582 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
1586 /* Normal monsters slow down */
1589 if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
1591 note = _("の動きが遅くなった。", " starts moving slower.");
1598 /* Time -- breathers resist */
1601 if (seen) obvious = TRUE;
1602 if (r_ptr->flagsr & RFR_RES_TIME)
1604 note = _("には耐性がある。", " resists.");
1605 dam *= 3; dam /= randint1(6) + 6;
1606 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_TIME);
1608 else do_time = (dam + 1) / 2;
1612 /* Gravity -- breathers resist */
1615 bool resist_tele = FALSE;
1617 if (seen) obvious = TRUE;
1618 if (r_ptr->flagsr & RFR_RES_TELE)
1620 if (r_ptr->flags1 & (RF1_UNIQUE))
1622 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
1623 note = _("には効果がなかった。", " is unaffected!");
1626 else if (r_ptr->level > randint1(100))
1628 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
1629 note = _("には耐性がある!", " resists!");
1634 if (!resist_tele) do_dist = 10;
1636 if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) do_dist = 0;
1638 if (r_ptr->flagsr & RFR_RES_GRAV)
1640 note = _("には耐性がある!", " resists!");
1641 dam *= 3; dam /= randint1(6) + 6;
1643 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_GRAV);
1648 /* Powerful monsters can resist */
1649 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
1650 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
1654 /* Normal monsters slow down */
1657 if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
1659 note = _("の動きが遅くなった。", " starts moving slower.");
1664 do_stun = damroll((caster_lev / 20) + 3, (dam)) + 1;
1666 /* Attempt a saving throw */
1667 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
1668 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
1672 /* No obvious effect */
1673 note = _("には効果がなかった。", " is unaffected!");
1685 if (seen) obvious = TRUE;
1691 case GF_DISINTEGRATE:
1693 if (seen) obvious = TRUE;
1694 if (r_ptr->flags3 & RF3_HURT_ROCK)
1696 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
1697 note = _("の皮膚がただれた!", " loses some skin!");
1698 note_dies = _("は蒸発した!", " evaporates!");
1706 if (seen) obvious = TRUE;
1708 /* PSI only works if the monster can see you! -- RG */
1709 if (!(los(caster_ptr, m_ptr->fy, m_ptr->fx, caster_ptr->y, caster_ptr->x)))
1712 msg_format(_("%sはあなたが見えないので影響されない!", "%^s can't see you, and isn't affected!"), m_name);
1716 if (r_ptr->flags2 & RF2_EMPTY_MIND)
1719 note = _("には完全な耐性がある!", " is immune.");
1720 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
1723 else if ((r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
1724 (r_ptr->flags3 & RF3_ANIMAL) ||
1725 (r_ptr->level > randint1(3 * dam)))
1727 note = _("には耐性がある!", " resists!");
1731 * Powerful demons & undead can turn a mindcrafter's
1732 * attacks back on them
1734 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
1735 (r_ptr->level > caster_ptr->lev / 2) &&
1739 msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!",
1740 (seen ? "%^s's corrupted mind backlashes your attack!" :
1741 "%^ss corrupted mind backlashes your attack!")), m_name);
1744 if ((randint0(100 + r_ptr->level / 2) < caster_ptr->skill_sav) && !CHECK_MULTISHADOW(caster_ptr))
1746 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1750 /* Injure +/- confusion */
1751 monster_desc(caster_ptr, killer, m_ptr, MD_WRONGDOER_NAME);
1752 take_hit(caster_ptr, DAMAGE_ATTACK, dam, killer, -1); /* has already been /3 */
1753 if (one_in_(4) && !CHECK_MULTISHADOW(caster_ptr))
1755 switch (randint1(4))
1758 set_confused(caster_ptr, caster_ptr->confused + 3 + randint1(dam));
1761 set_stun(caster_ptr, caster_ptr->stun + randint1(dam));
1765 if (r_ptr->flags3 & RF3_NO_FEAR)
1766 note = _("には効果がなかった。", " is unaffected.");
1768 set_afraid(caster_ptr, caster_ptr->afraid + 3 + randint1(dam));
1772 if (!caster_ptr->free_act)
1773 (void)set_paralyzed(caster_ptr, caster_ptr->paralyzed + randint1(dam));
1782 if ((dam > 0) && one_in_(4))
1784 switch (randint1(4))
1787 do_conf = 3 + randint1(dam);
1790 do_stun = 3 + randint1(dam);
1793 do_fear = 3 + randint1(dam);
1796 note = _("は眠り込んでしまった!", " falls asleep!");
1797 do_sleep = 3 + randint1(dam);
1802 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
1808 if (seen) obvious = TRUE;
1809 if (r_ptr->flags2 & RF2_EMPTY_MIND)
1812 note = _("には完全な耐性がある!", " is immune.");
1814 else if ((r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
1815 (r_ptr->flags3 & RF3_ANIMAL) ||
1816 (r_ptr->level > randint1(3 * dam)))
1818 note = _("には耐性がある!", " resists!");
1822 * Powerful demons & undead can turn a mindcrafter's
1823 * attacks back on them
1825 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
1826 (r_ptr->level > caster_ptr->lev / 2) &&
1830 msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!",
1831 (seen ? "%^s's corrupted mind backlashes your attack!" :
1832 "%^ss corrupted mind backlashes your attack!")), m_name);
1834 if ((randint0(100 + r_ptr->level / 2) < caster_ptr->skill_sav) && !CHECK_MULTISHADOW(caster_ptr))
1836 msg_print(_("あなたは効力を跳ね返した!", "You resist the effects!"));
1840 /* Injure + mana drain */
1841 monster_desc(caster_ptr, killer, m_ptr, MD_WRONGDOER_NAME);
1842 if (!CHECK_MULTISHADOW(caster_ptr))
1844 msg_print(_("超能力パワーを吸いとられた!", "Your psychic energy is drained!"));
1845 caster_ptr->csp -= damroll(5, dam) / 2;
1846 if (caster_ptr->csp < 0) caster_ptr->csp = 0;
1847 caster_ptr->redraw |= PR_MANA;
1848 caster_ptr->window |= (PW_SPELL);
1850 take_hit(caster_ptr, DAMAGE_ATTACK, dam, killer, -1); /* has already been /3 */
1857 int b = damroll(5, dam) / 4;
1858 concptr str = (caster_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
1859 concptr msg = _("あなたは%sの苦痛を%sに変換した!",
1860 (seen ? "You convert %s's pain into %s!" :
1861 "You convert %ss pain into %s!"));
1862 msg_format(msg, m_name, str);
1864 b = MIN(caster_ptr->msp, caster_ptr->csp + b);
1865 caster_ptr->csp = b;
1866 caster_ptr->redraw |= PR_MANA;
1867 caster_ptr->window |= (PW_SPELL);
1869 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
1873 case GF_TELEKINESIS:
1875 if (seen) obvious = TRUE;
1878 if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) do_dist = 0;
1883 do_stun = damroll((caster_lev / 20) + 3, dam) + 1;
1885 /* Attempt a saving throw */
1886 if ((r_ptr->flags1 & RF1_UNIQUE) ||
1887 (r_ptr->level > 5 + randint1(dam)))
1891 /* No obvious effect */
1897 /* Psycho-spear -- powerful magic missile */
1900 if (seen) obvious = TRUE;
1904 /* Meteor -- powerful magic missile */
1907 if (seen) obvious = TRUE;
1913 if (!is_hostile(m_ptr)) break;
1914 if (seen) obvious = TRUE;
1915 /* Attempt a saving throw */
1916 if ((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) ||
1917 (r_ptr->flags3 & RF3_NO_CONF) ||
1918 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
1920 /* Memorize a flag */
1921 if (r_ptr->flags3 & RF3_NO_CONF)
1923 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
1930 * Powerful demons & undead can turn a mindcrafter's
1931 * attacks back on them
1933 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
1934 (r_ptr->level > caster_ptr->lev / 2) &&
1938 msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!",
1939 (seen ? "%^s's corrupted mind backlashes your attack!" :
1940 "%^ss corrupted mind backlashes your attack!")), m_name);
1943 if (randint0(100 + r_ptr->level / 2) < caster_ptr->skill_sav)
1945 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1949 /* Confuse, stun, terrify */
1950 switch (randint1(4))
1953 set_stun(caster_ptr, caster_ptr->stun + dam / 2);
1956 set_confused(caster_ptr, caster_ptr->confused + dam / 2);
1960 if (r_ptr->flags3 & RF3_NO_FEAR)
1961 note = _("には効果がなかった。", " is unaffected.");
1963 set_afraid(caster_ptr, caster_ptr->afraid + dam);
1970 /* No obvious effect */
1971 note = _("には効果がなかった。", " is unaffected.");
1977 if (!common_saving_throw_charm(caster_ptr, dam, m_ptr))
1979 note = _("があなたに隷属した。", " is in your thrall!");
1980 set_pet(caster_ptr, m_ptr);
1984 switch (randint1(4))
1998 /* No "real" damage */
2003 /* Ice -- Cold + Cuts + Stun */
2006 if (seen) obvious = TRUE;
2007 do_stun = (randint1(15) + 1) / (r + 1);
2008 if (r_ptr->flagsr & RFR_IM_COLD)
2010 note = _("にはかなり耐性がある!", " resists a lot.");
2012 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_IM_COLD);
2014 else if (r_ptr->flags3 & (RF3_HURT_COLD))
2016 note = _("はひどい痛手をうけた。", " is hit hard.");
2018 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_COLD);
2025 case GF_HYPODYNAMIA:
2027 if (seen) obvious = TRUE;
2028 if (!monster_living(m_ptr->r_idx))
2030 if (is_original_ap_and_seen(caster_ptr, m_ptr))
2032 if (r_ptr->flags3 & RF3_DEMON) r_ptr->r_flags3 |= (RF3_DEMON);
2033 if (r_ptr->flags3 & RF3_UNDEAD) r_ptr->r_flags3 |= (RF3_UNDEAD);
2034 if (r_ptr->flags3 & RF3_NONLIVING) r_ptr->r_flags3 |= (RF3_NONLIVING);
2036 note = _("には効果がなかった。", " is unaffected.");
2040 else do_time = (dam + 7) / 8;
2048 if (seen) obvious = TRUE;
2049 if (!monster_living(m_ptr->r_idx))
2051 if (is_original_ap_and_seen(caster_ptr, m_ptr))
2053 if (r_ptr->flags3 & RF3_DEMON) r_ptr->r_flags3 |= (RF3_DEMON);
2054 if (r_ptr->flags3 & RF3_UNDEAD) r_ptr->r_flags3 |= (RF3_UNDEAD);
2055 if (r_ptr->flags3 & RF3_NONLIVING) r_ptr->r_flags3 |= (RF3_NONLIVING);
2057 note = _("には完全な耐性がある!", " is immune.");
2061 else if (((r_ptr->flags1 & RF1_UNIQUE) &&
2062 (randint1(888) != 666)) ||
2063 (((r_ptr->level + randint1(20)) > randint1((caster_lev / 2) + randint1(10))) &&
2064 randint1(100) != 66))
2066 note = _("には耐性がある!", " resists!");
2074 /* Polymorph monster (Use "dam" as "power") */
2077 if (seen) obvious = TRUE;
2078 /* Attempt to polymorph (see below) */
2081 /* Powerful monsters can resist */
2082 if ((r_ptr->flags1 & RF1_UNIQUE) ||
2083 (r_ptr->flags1 & RF1_QUESTOR) ||
2084 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2086 note = _("には効果がなかった。", " is unaffected.");
2091 /* No "real" damage */
2098 /* Clone monsters (Ignore "dam") */
2101 if (seen) obvious = TRUE;
2103 if ((floor_ptr->inside_arena) || is_pet(m_ptr) || (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)))
2105 note = _("には効果がなかった。", " is unaffected.");
2110 m_ptr->hp = m_ptr->maxhp;
2112 /* Attempt to clone. */
2113 if (multiply_monster(caster_ptr, g_ptr->m_idx, TRUE, 0L))
2115 note = _("が分裂した!", " spawns!");
2119 /* No "real" damage */
2126 /* Heal Monster (use "dam" as amount of healing) */
2129 if (seen) obvious = TRUE;
2132 (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
2134 if (m_ptr->maxhp < m_ptr->max_maxhp)
2136 if (seen_msg) msg_format(_("%^sの強さが戻った。", "%^s recovers %s vitality."), m_name, m_poss);
2137 m_ptr->maxhp = m_ptr->max_maxhp;
2142 /* Redraw (later) if needed */
2143 if (caster_ptr->health_who == g_ptr->m_idx) caster_ptr->redraw |= (PR_HEALTH);
2144 if (caster_ptr->riding == g_ptr->m_idx) caster_ptr->redraw |= (PR_UHEALTH);
2152 if (seen) obvious = TRUE;
2155 (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
2156 if (MON_STUNNED(m_ptr))
2158 if (seen_msg) msg_format(_("%^sは朦朧状態から立ち直った。", "%^s is no longer stunned."), m_name);
2159 (void)set_monster_stunned(caster_ptr, g_ptr->m_idx, 0);
2161 if (MON_CONFUSED(m_ptr))
2163 if (seen_msg) msg_format(_("%^sは混乱から立ち直った。", "%^s is no longer confused."), m_name);
2164 (void)set_monster_confused(caster_ptr, g_ptr->m_idx, 0);
2166 if (MON_MONFEAR(m_ptr))
2168 if (seen_msg) msg_format(_("%^sは勇気を取り戻した。", "%^s recovers %s courage."), m_name);
2169 (void)set_monster_monfear(caster_ptr, g_ptr->m_idx, 0);
2173 if (m_ptr->hp < 30000) m_ptr->hp += dam;
2176 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
2180 chg_virtue(caster_ptr, V_VITALITY, 1);
2182 if (r_ptr->flags1 & RF1_UNIQUE)
2183 chg_virtue(caster_ptr, V_INDIVIDUALISM, 1);
2185 if (is_friendly(m_ptr))
2186 chg_virtue(caster_ptr, V_HONOUR, 1);
2187 else if (!(r_ptr->flags3 & RF3_EVIL))
2189 if (r_ptr->flags3 & RF3_GOOD)
2190 chg_virtue(caster_ptr, V_COMPASSION, 2);
2192 chg_virtue(caster_ptr, V_COMPASSION, 1);
2195 if (r_ptr->flags3 & RF3_ANIMAL)
2196 chg_virtue(caster_ptr, V_NATURE, 1);
2199 if (m_ptr->r_idx == MON_LEPER)
2202 if (!who) chg_virtue(caster_ptr, V_COMPASSION, 5);
2205 /* Redraw (later) if needed */
2206 if (caster_ptr->health_who == g_ptr->m_idx) caster_ptr->redraw |= (PR_HEALTH);
2207 if (caster_ptr->riding == g_ptr->m_idx) caster_ptr->redraw |= (PR_UHEALTH);
2209 note = _("は体力を回復したようだ。", " looks healthier.");
2211 /* No "real" damage */
2217 /* Speed Monster (Ignore "dam") */
2220 if (seen) obvious = TRUE;
2223 if (set_monster_fast(caster_ptr, g_ptr->m_idx, MON_FAST(m_ptr) + 100))
2225 note = _("の動きが速くなった。", " starts moving faster.");
2230 if (r_ptr->flags1 & RF1_UNIQUE)
2231 chg_virtue(caster_ptr, V_INDIVIDUALISM, 1);
2232 if (is_friendly(m_ptr))
2233 chg_virtue(caster_ptr, V_HONOUR, 1);
2236 /* No "real" damage */
2242 /* Slow Monster (Use "dam" as "power") */
2245 if (seen) obvious = TRUE;
2247 /* Powerful monsters can resist */
2248 if ((r_ptr->flags1 & RF1_UNIQUE) ||
2249 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2251 note = _("には効果がなかった。", " is unaffected.");
2255 /* Normal monsters slow down */
2258 if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
2260 note = _("の動きが遅くなった。", " starts moving slower.");
2264 /* No "real" damage */
2270 /* Sleep (Use "dam" as "power") */
2273 if (seen) obvious = TRUE;
2275 /* Attempt a saving throw */
2276 if ((r_ptr->flags1 & RF1_UNIQUE) ||
2277 (r_ptr->flags3 & RF3_NO_SLEEP) ||
2278 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2280 /* Memorize a flag */
2281 if (r_ptr->flags3 & RF3_NO_SLEEP)
2283 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
2285 /* No obvious effect */
2286 note = _("には効果がなかった。", " is unaffected.");
2291 /* Go to sleep (much) later */
2292 note = _("は眠り込んでしまった!", " falls asleep!");
2296 /* No "real" damage */
2302 /* Sleep (Use "dam" as "power") */
2303 case GF_STASIS_EVIL:
2305 if (seen) obvious = TRUE;
2307 /* Attempt a saving throw */
2308 if ((r_ptr->flags1 & RF1_UNIQUE) ||
2309 !(r_ptr->flags3 & RF3_EVIL) ||
2310 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2312 note = _("には効果がなかった。", " is unaffected.");
2317 /* Go to sleep (much) later */
2318 note = _("は動けなくなった!", " is suspended!");
2322 /* No "real" damage */
2327 /* Sleep (Use "dam" as "power") */
2330 if (seen) obvious = TRUE;
2332 /* Attempt a saving throw */
2333 if ((r_ptr->flags1 & RF1_UNIQUE) ||
2334 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2336 note = _("には効果がなかった。", " is unaffected.");
2341 /* Go to sleep (much) later */
2342 note = _("は動けなくなった!", " is suspended!");
2346 /* No "real" damage */
2355 vir = virtue_number(caster_ptr, V_HARMONY);
2358 dam += caster_ptr->virtues[vir - 1] / 10;
2361 vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
2364 dam -= caster_ptr->virtues[vir - 1] / 20;
2367 if (seen) obvious = TRUE;
2369 /* Attempt a saving throw */
2370 if (common_saving_throw_charm(caster_ptr, dam, m_ptr))
2374 /* No obvious effect */
2375 note = _("には効果がなかった。", " is unaffected.");
2378 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2380 else if (caster_ptr->cursed & TRC_AGGRAVATE)
2382 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2383 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2387 note = _("は突然友好的になったようだ!", " suddenly seems friendly!");
2388 set_pet(caster_ptr, m_ptr);
2390 chg_virtue(caster_ptr, V_INDIVIDUALISM, -1);
2391 if (r_ptr->flags3 & RF3_ANIMAL)
2392 chg_virtue(caster_ptr, V_NATURE, 1);
2395 /* No "real" damage */
2400 /* Control undead */
2401 case GF_CONTROL_UNDEAD:
2404 if (seen) obvious = TRUE;
2406 vir = virtue_number(caster_ptr, V_UNLIFE);
2409 dam += caster_ptr->virtues[vir - 1] / 10;
2412 vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
2415 dam -= caster_ptr->virtues[vir - 1] / 20;
2418 /* Attempt a saving throw */
2419 if (common_saving_throw_control(caster_ptr, dam, m_ptr) ||
2420 !(r_ptr->flags3 & RF3_UNDEAD))
2422 /* No obvious effect */
2423 note = _("には効果がなかった。", " is unaffected.");
2425 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2427 else if (caster_ptr->cursed & TRC_AGGRAVATE)
2429 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2430 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2434 note = _("は既にあなたの奴隷だ!", " is in your thrall!");
2435 set_pet(caster_ptr, m_ptr);
2438 /* No "real" damage */
2444 case GF_CONTROL_DEMON:
2447 if (seen) obvious = TRUE;
2449 vir = virtue_number(caster_ptr, V_UNLIFE);
2452 dam += caster_ptr->virtues[vir - 1] / 10;
2455 vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
2458 dam -= caster_ptr->virtues[vir - 1] / 20;
2461 /* Attempt a saving throw */
2462 if (common_saving_throw_control(caster_ptr, dam, m_ptr) ||
2463 !(r_ptr->flags3 & RF3_DEMON))
2465 /* No obvious effect */
2466 note = _("には効果がなかった。", " is unaffected.");
2468 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2470 else if (caster_ptr->cursed & TRC_AGGRAVATE)
2472 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2473 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2477 note = _("は既にあなたの奴隷だ!", " is in your thrall!");
2478 set_pet(caster_ptr, m_ptr);
2481 /* No "real" damage */
2487 case GF_CONTROL_ANIMAL:
2490 if (seen) obvious = TRUE;
2492 vir = virtue_number(caster_ptr, V_NATURE);
2495 dam += caster_ptr->virtues[vir - 1] / 10;
2498 vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
2501 dam -= caster_ptr->virtues[vir - 1] / 20;
2504 /* Attempt a saving throw */
2505 if (common_saving_throw_control(caster_ptr, dam, m_ptr) ||
2506 !(r_ptr->flags3 & RF3_ANIMAL))
2509 /* No obvious effect */
2510 note = _("には効果がなかった。", " is unaffected.");
2512 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2514 else if (caster_ptr->cursed & TRC_AGGRAVATE)
2516 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2517 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2521 note = _("はなついた。", " is tamed!");
2522 set_pet(caster_ptr, m_ptr);
2523 if (r_ptr->flags3 & RF3_ANIMAL)
2524 chg_virtue(caster_ptr, V_NATURE, 1);
2527 /* No "real" damage */
2533 case GF_CHARM_LIVING:
2537 vir = virtue_number(caster_ptr, V_UNLIFE);
2538 if (seen) obvious = TRUE;
2540 vir = virtue_number(caster_ptr, V_UNLIFE);
2543 dam -= caster_ptr->virtues[vir - 1] / 10;
2546 vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
2549 dam -= caster_ptr->virtues[vir - 1] / 20;
2552 msg_format(_("%sを見つめた。", "You stare into %s."), m_name);
2554 /* Attempt a saving throw */
2555 if (common_saving_throw_charm(caster_ptr, dam, m_ptr) ||
2556 !monster_living(m_ptr->r_idx))
2559 /* No obvious effect */
2560 note = _("には効果がなかった。", " is unaffected.");
2562 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2564 else if (caster_ptr->cursed & TRC_AGGRAVATE)
2566 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2567 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2571 note = _("を支配した。", " is tamed!");
2572 set_pet(caster_ptr, m_ptr);
2573 if (r_ptr->flags3 & RF3_ANIMAL)
2574 chg_virtue(caster_ptr, V_NATURE, 1);
2577 /* No "real" damage */
2582 /* Confusion (Use "dam" as "power") */
2585 if (seen) obvious = TRUE;
2587 /* Get confused later */
2588 do_conf = damroll(3, (dam / 2)) + 1;
2590 /* Attempt a saving throw */
2591 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
2592 (r_ptr->flags3 & (RF3_NO_CONF)) ||
2593 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2595 /* Memorize a flag */
2596 if (r_ptr->flags3 & (RF3_NO_CONF))
2598 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
2604 /* No obvious effect */
2605 note = _("には効果がなかった。", " is unaffected.");
2609 /* No "real" damage */
2616 if (seen) obvious = TRUE;
2618 do_stun = damroll((caster_lev / 20) + 3, (dam)) + 1;
2620 /* Attempt a saving throw */
2621 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
2622 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2627 /* No obvious effect */
2628 note = _("には効果がなかった。", " is unaffected.");
2632 /* No "real" damage */
2637 /* Lite, but only hurts susceptible creatures */
2646 if (r_ptr->flags3 & (RF3_HURT_LITE))
2648 /* Obvious effect */
2649 if (seen) obvious = TRUE;
2651 /* Memorize the effects */
2652 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
2654 /* Special effect */
2655 note = _("は光に身をすくめた!", " cringes from the light!");
2656 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
2659 /* Normally no damage */
2671 /* Lite -- opposite of Dark */
2674 if (seen) obvious = TRUE;
2676 if (r_ptr->flagsr & RFR_RES_LITE)
2678 note = _("には耐性がある!", " resists!");
2679 dam *= 2; dam /= (randint1(6) + 6);
2680 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_LITE);
2682 else if (r_ptr->flags3 & (RF3_HURT_LITE))
2684 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
2685 note = _("は光に身をすくめた!", " cringes from the light!");
2686 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
2693 /* Dark -- opposite of Lite */
2696 if (seen) obvious = TRUE;
2698 if (r_ptr->flagsr & RFR_RES_DARK)
2700 note = _("には耐性がある!", " resists!");
2701 dam *= 2; dam /= (randint1(6) + 6);
2702 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= (RFR_RES_DARK);
2711 /* Hurt by rock remover */
2712 if (r_ptr->flags3 & (RF3_HURT_ROCK))
2715 if (seen) obvious = TRUE;
2717 /* Memorize the effects */
2718 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
2720 /* Cute little message */
2721 note = _("の皮膚がただれた!", " loses some skin!");
2722 note_dies = _("はドロドロに溶けた!", " dissolves!");
2725 /* Usually, ignore the effects */
2736 /* Teleport undead (Use "dam" as "power") */
2737 case GF_AWAY_UNDEAD:
2739 /* Only affect undead */
2740 if (r_ptr->flags3 & (RF3_UNDEAD))
2742 bool resists_tele = FALSE;
2744 if (r_ptr->flagsr & RFR_RES_TELE)
2746 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
2748 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2749 note = _("には効果がなかった。", " is unaffected.");
2750 resists_tele = TRUE;
2752 else if (r_ptr->level > randint1(100))
2754 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2755 note = _("には耐性がある!", " resists!");
2756 resists_tele = TRUE;
2762 if (seen) obvious = TRUE;
2763 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
2775 /* No "real" damage */
2781 /* Teleport evil (Use "dam" as "power") */
2784 /* Only affect evil */
2785 if (r_ptr->flags3 & (RF3_EVIL))
2787 bool resists_tele = FALSE;
2789 if (r_ptr->flagsr & RFR_RES_TELE)
2791 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
2793 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2794 note = _("には効果がなかった。", " is unaffected.");
2795 resists_tele = TRUE;
2797 else if (r_ptr->level > randint1(100))
2799 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2800 note = _("には耐性がある!", " resists!");
2801 resists_tele = TRUE;
2807 if (seen) obvious = TRUE;
2808 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
2820 /* No "real" damage */
2826 /* Teleport monster (Use "dam" as "power") */
2829 bool resists_tele = FALSE;
2830 if (r_ptr->flagsr & RFR_RES_TELE)
2832 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
2834 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2835 note = _("には効果がなかった。", " is unaffected.");
2836 resists_tele = TRUE;
2838 else if (r_ptr->level > randint1(100))
2840 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2841 note = _("には耐性がある!", " resists!");
2842 resists_tele = TRUE;
2848 if (seen) obvious = TRUE;
2850 /* Prepare to teleport */
2854 /* No "real" damage */
2860 /* Turn undead (Use "dam" as "power") */
2861 case GF_TURN_UNDEAD:
2863 /* Only affect undead */
2864 if (r_ptr->flags3 & (RF3_UNDEAD))
2866 if (seen) obvious = TRUE;
2868 /* Learn about type */
2869 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
2871 /* Apply some fear */
2872 do_fear = damroll(3, (dam / 2)) + 1;
2874 /* Attempt a saving throw */
2875 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
2877 /* No obvious effect */
2878 note = _("には効果がなかった。", " is unaffected.");
2891 /* No "real" damage */
2897 /* Turn evil (Use "dam" as "power") */
2900 /* Only affect evil */
2901 if (r_ptr->flags3 & (RF3_EVIL))
2903 if (seen) obvious = TRUE;
2905 /* Learn about type */
2906 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
2908 /* Apply some fear */
2909 do_fear = damroll(3, (dam / 2)) + 1;
2911 /* Attempt a saving throw */
2912 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
2914 /* No obvious effect */
2915 note = _("には効果がなかった。", " is unaffected.");
2928 /* No "real" damage */
2934 /* Turn monster (Use "dam" as "power") */
2937 if (seen) obvious = TRUE;
2939 /* Apply some fear */
2940 do_fear = damroll(3, (dam / 2)) + 1;
2942 /* Attempt a saving throw */
2943 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
2944 (r_ptr->flags3 & (RF3_NO_FEAR)) ||
2945 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2947 /* No obvious effect */
2948 note = _("には効果がなかった。", " is unaffected.");
2953 /* No "real" damage */
2960 case GF_DISP_UNDEAD:
2962 /* Only affect undead */
2963 if (r_ptr->flags3 & (RF3_UNDEAD))
2965 if (seen) obvious = TRUE;
2967 /* Learn about type */
2968 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
2970 note = _("は身震いした。", " shudders.");
2971 note_dies = _("はドロドロに溶けた!", " dissolves!");
2991 /* Only affect evil */
2992 if (r_ptr->flags3 & (RF3_EVIL))
2994 if (seen) obvious = TRUE;
2996 /* Learn about type */
2997 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
2999 note = _("は身震いした。", " shudders.");
3000 note_dies = _("はドロドロに溶けた!", " dissolves!");
3019 /* Only affect good */
3020 if (r_ptr->flags3 & (RF3_GOOD))
3022 if (seen) obvious = TRUE;
3024 /* Learn about type */
3025 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
3027 note = _("は身震いした。", " shudders.");
3028 note_dies = _("はドロドロに溶けた!", " dissolves!");
3045 case GF_DISP_LIVING:
3047 /* Only affect non-undead */
3048 if (monster_living(m_ptr->r_idx))
3050 if (seen) obvious = TRUE;
3052 note = _("は身震いした。", " shudders.");
3053 note_dies = _("はドロドロに溶けた!", " dissolves!");
3072 /* Only affect demons */
3073 if (r_ptr->flags3 & (RF3_DEMON))
3075 if (seen) obvious = TRUE;
3077 /* Learn about type */
3078 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
3080 note = _("は身震いした。", " shudders.");
3081 note_dies = _("はドロドロに溶けた!", " dissolves!");
3097 /* Dispel monster */
3100 if (seen) obvious = TRUE;
3101 note = _("は身震いした。", " shudders.");
3102 note_dies = _("はドロドロに溶けた!", " dissolves!");
3109 if (seen) obvious = TRUE;
3110 if ((r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) || (r_ptr->a_ability_flags1 & ~(RF5_NOMAGIC_MASK)) || (r_ptr->a_ability_flags2 & ~(RF6_NOMAGIC_MASK)))
3114 /* Heal the monster */
3115 if (m_caster_ptr->hp < m_caster_ptr->maxhp)
3118 m_caster_ptr->hp += dam;
3119 if (m_caster_ptr->hp > m_caster_ptr->maxhp) m_caster_ptr->hp = m_caster_ptr->maxhp;
3121 /* Redraw (later) if needed */
3122 if (caster_ptr->health_who == who) caster_ptr->redraw |= (PR_HEALTH);
3123 if (caster_ptr->riding == who) caster_ptr->redraw |= (PR_UHEALTH);
3125 /* Special message */
3128 monster_desc(caster_ptr, killer, m_caster_ptr, 0);
3129 msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), killer);
3135 msg_format(_("%sから精神エネルギーを吸いとった。", "You draw psychic energy from %s."), m_name);
3136 (void)hp_player(caster_ptr, dam);
3141 if (see_s_msg) msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
3150 if (seen) obvious = TRUE;
3151 if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
3152 /* Attempt a saving throw */
3153 if ((r_ptr->flags1 & RF1_UNIQUE) ||
3154 (r_ptr->flags3 & RF3_NO_CONF) ||
3155 (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
3157 /* Memorize a flag */
3158 if (r_ptr->flags3 & (RF3_NO_CONF))
3160 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3162 note = _("には効果がなかった。", " is unaffected.");
3165 else if (r_ptr->flags2 & RF2_EMPTY_MIND)
3167 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
3168 note = _("には完全な耐性がある!", " is immune.");
3171 else if (r_ptr->flags2 & RF2_WEIRD_MIND)
3173 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
3174 note = _("には耐性がある。", " resists.");
3179 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
3180 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
3182 if (who > 0) do_conf = randint0(4) + 4;
3183 else do_conf = randint0(8) + 8;
3189 case GF_BRAIN_SMASH:
3191 if (seen) obvious = TRUE;
3192 if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
3194 /* Attempt a saving throw */
3195 if ((r_ptr->flags1 & RF1_UNIQUE) ||
3196 (r_ptr->flags3 & RF3_NO_CONF) ||
3197 (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
3199 /* Memorize a flag */
3200 if (r_ptr->flags3 & (RF3_NO_CONF))
3202 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3204 note = _("には効果がなかった。", " is unaffected.");
3207 else if (r_ptr->flags2 & RF2_EMPTY_MIND)
3209 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
3210 note = _("には完全な耐性がある!", " is immune.");
3213 else if (r_ptr->flags2 & RF2_WEIRD_MIND)
3215 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
3216 note = _("には耐性がある!", " resists!");
3221 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
3222 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
3226 do_conf = randint0(4) + 4;
3227 do_stun = randint0(4) + 4;
3231 do_conf = randint0(8) + 8;
3232 do_stun = randint0(8) + 8;
3234 (void)set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 10);
3242 if (seen) obvious = TRUE;
3243 if (!who) msg_format(_("%sを指差して呪いをかけた。", "You point at %s and curse."), m_name);
3244 /* Attempt a saving throw */
3245 if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
3247 note = _("には効果がなかった。", " is unaffected.");
3256 if (seen) obvious = TRUE;
3257 if (!who) msg_format(_("%sを指差して恐ろしげに呪いをかけた。", "You point at %s and curse horribly."), m_name);
3258 /* Attempt a saving throw */
3259 if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
3261 note = _("には効果がなかった。", " is unaffected.");
3270 if (seen) obvious = TRUE;
3271 if (!who) msg_format(_("%sを指差し、恐ろしげに呪文を唱えた!", "You point at %s, incanting terribly!"), m_name);
3272 /* Attempt a saving throw */
3273 if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
3275 note = _("には効果がなかった。", " is unaffected.");
3284 if (seen) obvious = TRUE;
3286 msg_format(_("%sの秘孔を突いて、「お前は既に死んでいる」と叫んだ。",
3287 "You point at %s, screaming the word, 'DIE!'."), m_name);
3288 /* Attempt a saving throw */
3289 if ((randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35)) && ((who <= 0) || (m_caster_ptr->r_idx != MON_KENSHIROU)))
3291 note = _("には効果がなかった。", " is unaffected.");
3300 if (seen) obvious = TRUE;
3301 if (r_ptr->flags1 & RF1_UNIQUE)
3303 note = _("には効果がなかった。", " is unaffected.");
3308 if ((who > 0) ? ((caster_lev + randint1(dam)) > (r_ptr->level + 10 + randint1(20))) :
3309 (((caster_lev / 2) + randint1(dam)) > (r_ptr->level + randint1(200))))
3311 dam = ((40 + randint1(20)) * m_ptr->hp) / 100;
3313 if (m_ptr->hp < dam) dam = m_ptr->hp - 1;
3317 note = _("は耐性を持っている!", "resists!");
3324 /* Capture monster */
3328 if ((floor_ptr->inside_quest && (quest[floor_ptr->inside_quest].type == QUEST_TYPE_KILL_ALL) && !is_pet(m_ptr)) ||
3329 (r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_NAZGUL)) || (r_ptr->flags7 & (RF7_UNIQUE2)) || (r_ptr->flags1 & RF1_QUESTOR) || m_ptr->parent_m_idx)
3331 msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
3336 if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp * 4L;
3337 else if ((caster_ptr->pclass == CLASS_BEASTMASTER) && monster_living(m_ptr->r_idx))
3338 nokori_hp = m_ptr->maxhp * 3 / 10;
3340 nokori_hp = m_ptr->maxhp * 3 / 20;
3342 if (m_ptr->hp >= nokori_hp)
3344 msg_format(_("もっと弱らせないと。", "You need to weaken %s more."), m_name);
3347 else if (m_ptr->hp < randint0(nokori_hp))
3349 if (m_ptr->mflag2 & MFLAG2_CHAMELEON) choose_new_monster(caster_ptr, g_ptr->m_idx, FALSE, MON_CHAMELEON);
3350 msg_format(_("%sを捕えた!", "You capture %^s!"), m_name);
3351 cap_mon = m_ptr->r_idx;
3352 cap_mspeed = m_ptr->mspeed;
3354 cap_maxhp = m_ptr->max_maxhp;
3355 cap_nickname = m_ptr->nickname; /* Quark transfer */
3356 if (g_ptr->m_idx == caster_ptr->riding)
3358 if (rakuba(caster_ptr, -1, FALSE))
3360 msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
3364 delete_monster_idx(caster_ptr, g_ptr->m_idx);
3370 msg_format(_("うまく捕まえられなかった。", "You failed to capture %s."), m_name);
3376 /* Attack (Use "dam" as attack type) */
3379 /* Return this monster's death */
3380 return py_attack(caster_ptr, y, x, dam);
3383 /* Sleep (Use "dam" as "power") */
3389 if (seen) obvious = TRUE;
3390 if (r_ptr->flags2 & RF2_EMPTY_MIND)
3392 note = _("には効果がなかった。", " is unaffected.");
3395 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
3398 if (MON_CSLEEP(m_ptr))
3400 note = _("には効果がなかった。", " is unaffected.");
3406 if (one_in_(5)) effect = 1;
3407 else if (one_in_(4)) effect = 2;
3408 else if (one_in_(3)) effect = 3;
3413 /* Powerful monsters can resist */
3414 if ((r_ptr->flags1 & RF1_UNIQUE) ||
3415 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3417 note = _("には効果がなかった。", " is unaffected.");
3421 /* Normal monsters slow down */
3424 if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
3426 note = _("の動きが遅くなった。", " starts moving slower.");
3431 else if (effect == 2)
3433 do_stun = damroll((caster_ptr->lev / 10) + 3, (dam)) + 1;
3435 /* Attempt a saving throw */
3436 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
3437 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3442 /* No obvious effect */
3443 note = _("には効果がなかった。", " is unaffected.");
3448 else if (effect == 3)
3450 /* Attempt a saving throw */
3451 if ((r_ptr->flags1 & RF1_UNIQUE) ||
3452 (r_ptr->flags3 & RF3_NO_SLEEP) ||
3453 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3455 /* Memorize a flag */
3456 if (r_ptr->flags3 & RF3_NO_SLEEP)
3458 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
3461 /* No obvious effect */
3462 note = _("には効果がなかった。", " is unaffected.");
3467 /* Go to sleep (much) later */
3468 note = _("は眠り込んでしまった!", " falls asleep!");
3475 note = _("には効果がなかった。", " is unaffected.");
3478 /* No "real" damage */
3486 if (seen) obvious = TRUE;
3487 if (genocide_aux(caster_ptr, g_ptr->m_idx, dam, !who, (r_ptr->level + 1) / 2, _("モンスター消滅", "Genocide One")))
3489 if (seen_msg) msg_format(_("%sは消滅した!", "%^s disappeared!"), m_name);
3490 chg_virtue(caster_ptr, V_VITALITY, -1);
3500 if (!who) msg_format(_("%sを写真に撮った。", "You take a photograph of %s."), m_name);
3502 if (r_ptr->flags3 & (RF3_HURT_LITE))
3504 /* Obvious effect */
3505 if (seen) obvious = TRUE;
3507 /* Memorize the effects */
3508 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
3510 /* Special effect */
3511 note = _("は光に身をすくめた!", " cringes from the light!");
3512 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
3515 /* Normally no damage */
3522 photo = m_ptr->r_idx;
3529 case GF_BLOOD_CURSE:
3531 if (seen) obvious = TRUE;
3537 bool success = FALSE;
3538 if (seen) obvious = TRUE;
3540 if ((r_ptr->flags3 & (RF3_GOOD)) && !floor_ptr->inside_arena)
3542 if (r_ptr->flags3 & (RF3_NO_CONF)) dam -= 50;
3543 if (dam < 1) dam = 1;
3545 /* No need to tame your pet */
3548 note = _("の動きが速くなった。", " starts moving faster.");
3549 (void)set_monster_fast(caster_ptr, g_ptr->m_idx, MON_FAST(m_ptr) + 100);
3553 /* Attempt a saving throw */
3554 else if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
3555 (r_ptr->flags1 & (RF1_UNIQUE)) ||
3556 (m_ptr->mflag2 & MFLAG2_NOPET) ||
3557 (caster_ptr->cursed & TRC_AGGRAVATE) ||
3558 ((r_ptr->level + 10) > randint1(dam)))
3561 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3565 note = _("を支配した。", " is tamed!");
3566 set_pet(caster_ptr, m_ptr);
3567 (void)set_monster_fast(caster_ptr, g_ptr->m_idx, MON_FAST(m_ptr) + 100);
3569 /* Learn about type */
3570 if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
3577 if (!(r_ptr->flags3 & RF3_NO_FEAR))
3579 do_fear = randint1(90) + 10;
3581 else if (is_original_ap_and_seen(caster_ptr, m_ptr)) r_ptr->r_flags3 |= (RF3_NO_FEAR);
3584 /* No "real" damage */
3591 if (seen) obvious = TRUE;
3592 /* Attempt a saving throw */
3593 if (randint0(100 + dam) < (r_ptr->level + 50))
3595 note = _("には効果がなかった。", " is unaffected.");
3615 /* Absolutely no effect */
3616 if (skipped) return FALSE;
3618 /* "Unique" monsters cannot be polymorphed */
3619 if (r_ptr->flags1 & (RF1_UNIQUE)) do_poly = FALSE;
3621 /* Quest monsters cannot be polymorphed */
3622 if (r_ptr->flags1 & RF1_QUESTOR) do_poly = FALSE;
3624 if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) do_poly = FALSE;
3626 /* "Unique" and "quest" monsters can only be "killed" by the player. */
3627 if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & RF7_NAZGUL)) && !caster_ptr->phase_out)
3629 if (who && (dam > m_ptr->hp)) dam = m_ptr->hp;
3634 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(caster_ptr, V_COMPASSION, -1);
3635 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(caster_ptr, V_HONOUR, -1);
3638 /* Modify the damage */
3640 dam = mon_damage_mod(caster_ptr, m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
3641 if ((tmp > 0) && (dam == 0)) note = _("はダメージを受けていない。", " is unharmed.");
3643 /* Check for death */
3644 if (dam > m_ptr->hp)
3646 /* Extract method of death */
3651 /* Sound and Impact resisters never stun */
3653 !(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
3654 !(r_ptr->flags3 & RF3_NO_STUN))
3656 if (seen) obvious = TRUE;
3659 if (MON_STUNNED(m_ptr))
3661 note = _("はひどくもうろうとした。", " is more dazed.");
3662 tmp = MON_STUNNED(m_ptr) + (do_stun / 2);
3666 note = _("はもうろうとした。", " is dazed.");
3671 (void)set_monster_stunned(caster_ptr, g_ptr->m_idx, tmp);
3677 /* Confusion and Chaos resisters (and sleepers) never confuse */
3679 !(r_ptr->flags3 & RF3_NO_CONF) &&
3680 !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
3682 if (seen) obvious = TRUE;
3684 /* Already partially confused */
3685 if (MON_CONFUSED(m_ptr))
3687 note = _("はさらに混乱したようだ。", " looks more confused.");
3688 tmp = MON_CONFUSED(m_ptr) + (do_conf / 2);
3691 /* Was not confused */
3694 note = _("は混乱したようだ。", " looks confused.");
3698 /* Apply confusion */
3699 (void)set_monster_confused(caster_ptr, g_ptr->m_idx, tmp);
3707 if (seen) obvious = TRUE;
3709 if (do_time >= m_ptr->maxhp) do_time = m_ptr->maxhp - 1;
3713 note = _("は弱くなったようだ。", " seems weakened.");
3714 m_ptr->maxhp -= do_time;
3715 if ((m_ptr->hp - dam) > m_ptr->maxhp) dam = m_ptr->hp - m_ptr->maxhp;
3720 /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
3721 if (do_poly && (randint1(90) > r_ptr->level))
3723 if (polymorph_monster(caster_ptr, y, x))
3725 if (seen) obvious = TRUE;
3727 /* Monster polymorphs */
3728 note = _("が変身した!", " changes!");
3730 /* Turn off the damage */
3734 /* Hack -- Get new monster */
3735 m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
3737 /* Hack -- Get new race */
3738 r_ptr = &r_info[m_ptr->r_idx];
3741 /* Handle "teleport" */
3744 if (seen) obvious = TRUE;
3746 note = _("が消え去った!", " disappears!");
3748 if (!who) chg_virtue(caster_ptr, V_VALOUR, -1);
3751 teleport_away(caster_ptr, g_ptr->m_idx, do_dist,
3752 (!who ? TELEPORT_DEC_VALOUR : 0L) | TELEPORT_PASSIVE);
3754 /* Hack -- get new location */
3758 /* Hack -- get new grid */
3759 g_ptr = &floor_ptr->grid_array[y][x];
3766 (void)set_monster_monfear(caster_ptr, g_ptr->m_idx, MON_MONFEAR(m_ptr) + do_fear);
3773 if (typ == GF_DRAIN_MANA)
3775 /* Drain mana does nothing */
3778 /* If another monster did the damage, hurt the monster by hand */
3781 /* Redraw (later) if needed */
3782 if (caster_ptr->health_who == g_ptr->m_idx) caster_ptr->redraw |= (PR_HEALTH);
3783 if (caster_ptr->riding == g_ptr->m_idx) caster_ptr->redraw |= (PR_UHEALTH);
3785 /* Wake the monster up */
3786 (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
3788 /* Hurt the monster */
3796 if (is_pet(m_ptr) && !(m_ptr->ml))
3799 /* Give detailed messages if destroyed */
3802 monster_desc(caster_ptr, m_name, m_ptr, MD_TRUE_NAME);
3805 msg_format("%^s%s", m_name, note);
3809 floor_ptr->monster_noise = TRUE;
3813 if (who > 0) monster_gain_exp(caster_ptr, who, m_ptr->r_idx);
3815 /* Generate treasure, etc */
3816 monster_death(caster_ptr, g_ptr->m_idx, FALSE);
3819 delete_monster_idx(caster_ptr, g_ptr->m_idx);
3823 msg_print(_("少し悲しい気分がした。", "You feel sad for a moment."));
3827 /* Damaged monster */
3830 /* Give detailed messages if visible or destroyed */
3831 if (note && seen_msg) msg_format("%^s%s", m_name, note);
3833 /* Hack -- Pain message */
3836 message_pain(caster_ptr, g_ptr->m_idx, dam);
3840 floor_ptr->monster_noise = TRUE;
3843 /* Hack -- handle sleep */
3844 if (do_sleep) (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, do_sleep);
3848 else if (heal_leper)
3850 if (seen_msg) msg_print(_("不潔な病人は病気が治った!", "The Mangy looking leper is healed!"));
3852 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
3854 char m2_name[MAX_NLEN];
3856 monster_desc(caster_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
3857 exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_HEAL_LEPER, m2_name);
3860 delete_monster_idx(caster_ptr, g_ptr->m_idx);
3863 /* If the player did it, give him experience, check fear */
3868 /* Hurt the monster, check for fear and death */
3869 if (mon_take_hit(caster_ptr, g_ptr->m_idx, dam, &fear, note_dies))
3874 /* Damaged monster */
3877 /* HACK - anger the monster before showing the sleep message */
3878 if (do_sleep) anger_monster(caster_ptr, m_ptr);
3880 /* Give detailed messages if visible or destroyed */
3881 if (note && seen_msg)
3882 msg_format(_("%s%s", "%^s%s"), m_name, note);
3884 /* Hack -- Pain message */
3885 else if (known && (dam || !do_fear))
3887 message_pain(caster_ptr, g_ptr->m_idx, dam);
3890 /* Anger monsters */
3891 if (((dam > 0) || get_angry) && !do_sleep)
3892 anger_monster(caster_ptr, m_ptr);
3894 if ((fear || do_fear) && seen)
3897 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3900 /* Hack -- handle sleep */
3901 if (do_sleep) (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, do_sleep);
3905 if ((typ == GF_BLOOD_CURSE) && one_in_(4))
3907 blood_curse_to_enemy(caster_ptr, who);
3910 if (caster_ptr->phase_out)
3912 caster_ptr->health_who = g_ptr->m_idx;
3913 caster_ptr->redraw |= (PR_HEALTH);
3914 handle_stuff(caster_ptr);
3917 /* Verify this code */
3918 if (m_ptr->r_idx) update_monster(caster_ptr, g_ptr->m_idx, FALSE);
3920 /* Redraw the monster grid */
3921 lite_spot(caster_ptr, y, x);
3923 /* Update monster recall window */
3924 if ((caster_ptr->monster_race_idx == m_ptr->r_idx) && (seen || !m_ptr->r_idx))
3926 caster_ptr->window |= (PW_MONSTER);
3929 if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
3933 if (!(flg & PROJECT_NO_HANGEKI))
3935 set_target(m_ptr, monster_target_y, monster_target_x);
3938 else if ((who > 0) && is_pet(m_caster_ptr) && !player_bold(caster_ptr, m_ptr->target_y, m_ptr->target_x))
3940 set_target(m_ptr, m_caster_ptr->fy, m_caster_ptr->fx);
3944 if (caster_ptr->riding && (caster_ptr->riding == g_ptr->m_idx) && (dam > 0))
3946 if (m_ptr->hp > m_ptr->maxhp / 3) dam = (dam + 1) / 2;
3947 rakubadam_m = (dam > 200) ? 200 : dam;
3957 /* Prepare to make a Blade of Chaos */
3958 object_prep(q_ptr, lookup_kind(TV_STATUE, SV_PHOTO));
3960 q_ptr->pval = photo;
3962 /* Mark the item as fully known */
3963 q_ptr->ident |= (IDENT_MENTAL);
3964 (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x);
3972 /* Return "Anything seen?" */
3978 * @brief 汎用的なビーム/ボルト/ボール系によるプレイヤーへの効果処理 / Helper function for "project()" below.
3979 * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
3980 * @param who_name 効果を起こしたモンスターの名前
3981 * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
3982 * @param y 目標Y座標 / Target y location (or location to travel "towards")
3983 * @param x 目標X座標 / Target x location (or location to travel "towards")
3984 * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
3985 * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
3987 * @param monspell 効果元のモンスター魔法ID
3988 * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
3990 * Handle a beam/bolt/ball causing damage to the player.
3991 * This routine takes a "source monster" (by index), a "distance", a default
3992 * "damage", and a "damage type". See "project_m()" above.
3993 * If "rad" is non-zero, then the blast was centered elsewhere, and the damage
3994 * is reduced (see "project_m()" above). This can happen if a monster breathes
3995 * at the player and hits a wall instead.
3996 * NOTE (Zangband): 'Bolt' attacks can be reflected back, so we need
3997 * to know if this is actually a ball or a bolt spell
3998 * We return "TRUE" if any "obvious" effects were observed. XXX XXX Actually,
3999 * we just assume that the effects were obvious, for historical reasons.
4001 static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name, int r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
4006 /* Hack -- assume obvious */
4007 bool obvious = TRUE;
4009 /* Player blind-ness */
4010 bool blind = (target_ptr->blind ? TRUE : FALSE);
4012 /* Player needs a "description" (he is blind) */
4015 /* Source monster */
4016 monster_type *m_ptr = NULL;
4018 /* Monster name (for attacks) */
4019 GAME_TEXT m_name[MAX_NLEN];
4021 /* Monster name (for damage) */
4024 /* Hack -- messages */
4030 /* Player is not here */
4031 if (!player_bold(target_ptr, y, x)) return FALSE;
4033 if ((target_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (target_ptr->lev * 3 / 5 + 20)) && who && (who != target_ptr->riding))
4035 if (kawarimi(target_ptr, TRUE)) return FALSE;
4038 /* Player cannot hurt himself */
4039 if (!who) return FALSE;
4040 if (who == target_ptr->riding) return FALSE;
4042 if ((target_ptr->reflect || ((target_ptr->special_defense & KATA_FUUJIN) && !target_ptr->blind)) && (flg & PROJECT_REFLECTABLE) && !one_in_(10))
4045 int max_attempts = 10;
4046 sound(SOUND_REFLECT);
4049 msg_print(_("何かが跳ね返った!", "Something bounces!"));
4050 else if (target_ptr->special_defense & KATA_FUUJIN)
4051 msg_print(_("風の如く武器を振るって弾き返した!", "The attack bounces!"));
4053 msg_print(_("攻撃が跳ね返った!", "The attack bounces!"));
4055 /* Choose 'new' target */
4060 t_y = target_ptr->current_floor_ptr->m_list[who].fy - 1 + randint1(3);
4061 t_x = target_ptr->current_floor_ptr->m_list[who].fx - 1 + randint1(3);
4063 } while (max_attempts && in_bounds2u(target_ptr->current_floor_ptr, t_y, t_x) && !projectable(target_ptr, target_ptr->y, target_ptr->x, t_y, t_x));
4065 if (max_attempts < 1)
4067 t_y = target_ptr->current_floor_ptr->m_list[who].fy;
4068 t_x = target_ptr->current_floor_ptr->m_list[who].fx;
4073 t_y = target_ptr->y - 1 + randint1(3);
4074 t_x = target_ptr->x - 1 + randint1(3);
4077 project(target_ptr, 0, 0, t_y, t_x, dam, typ, (PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE), monspell);
4079 disturb(target_ptr, TRUE, TRUE);
4083 /* Limit maximum damage */
4084 if (dam > 1600) dam = 1600;
4086 /* Reduce damage by distance */
4087 dam = (dam + r) / (r + 1);
4090 /* If the player is blind, be more descriptive */
4091 if (blind) fuzzy = TRUE;
4096 m_ptr = &target_ptr->current_floor_ptr->m_list[who];
4097 rlev = (((&r_info[m_ptr->r_idx])->level >= 1) ? (&r_info[m_ptr->r_idx])->level : 1);
4098 monster_desc(target_ptr, m_name, m_ptr, 0);
4100 /* Get the monster's real name (gotten before polymorph!) */
4101 strcpy(killer, who_name);
4107 case PROJECT_WHO_UNCTRL_POWER:
4108 strcpy(killer, _("制御できない力の氾流", "uncontrollable power storm"));
4111 case PROJECT_WHO_GLASS_SHARDS:
4112 strcpy(killer, _("ガラスの破片", "shards of glass"));
4116 strcpy(killer, _("罠", "a trap"));
4119 strcpy(m_name, killer);
4122 /* Analyze the damage */
4125 /* Standard damage -- hurts target_ptr->inventory_list too */
4128 if (fuzzy) msg_print(_("酸で攻撃された!", "You are hit by acid!"));
4129 get_damage = acid_dam(target_ptr, dam, killer, monspell, FALSE);
4133 /* Standard damage -- hurts target_ptr->inventory_list too */
4136 if (fuzzy) msg_print(_("火炎で攻撃された!", "You are hit by fire!"));
4137 get_damage = fire_dam(target_ptr, dam, killer, monspell, FALSE);
4141 /* Standard damage -- hurts target_ptr->inventory_list too */
4144 if (fuzzy) msg_print(_("冷気で攻撃された!", "You are hit by cold!"));
4145 get_damage = cold_dam(target_ptr, dam, killer, monspell, FALSE);
4149 /* Standard damage -- hurts target_ptr->inventory_list too */
4152 if (fuzzy) msg_print(_("電撃で攻撃された!", "You are hit by lightning!"));
4153 get_damage = elec_dam(target_ptr, dam, killer, monspell, FALSE);
4157 /* Standard damage -- also poisons player */
4160 bool double_resist = is_oppose_pois(target_ptr);
4161 if (fuzzy) msg_print(_("毒で攻撃された!", "You are hit by poison!"));
4163 if (target_ptr->resist_pois) dam = (dam + 2) / 3;
4164 if (double_resist) dam = (dam + 2) / 3;
4166 if ((!(double_resist || target_ptr->resist_pois)) && one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW(target_ptr))
4168 do_dec_stat(target_ptr, A_CON);
4171 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4173 if (!(double_resist || target_ptr->resist_pois) && !CHECK_MULTISHADOW(target_ptr))
4175 set_poisoned(target_ptr, target_ptr->poisoned + randint0(dam) + 10);
4180 /* Standard damage -- also poisons / mutates player */
4183 bool double_resist = is_oppose_pois(target_ptr);
4184 if (fuzzy) msg_print(_("放射能で攻撃された!", "You are hit by radiation!"));
4186 if (target_ptr->resist_pois) dam = (2 * dam + 2) / 5;
4187 if (double_resist) dam = (2 * dam + 2) / 5;
4188 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4189 if (!(double_resist || target_ptr->resist_pois) && !CHECK_MULTISHADOW(target_ptr))
4191 set_poisoned(target_ptr, target_ptr->poisoned + randint0(dam) + 10);
4193 if (one_in_(5)) /* 6 */
4195 msg_print(_("奇形的な変身を遂げた!", "You undergo a freakish metamorphosis!"));
4196 if (one_in_(4)) /* 4 */
4197 do_poly_self(target_ptr);
4199 status_shuffle(target_ptr);
4204 inventory_damage(target_ptr, set_acid_destroy, 2);
4210 /* Standard damage */
4213 if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4214 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4218 /* Holy Orb -- Player only takes partial damage */
4221 if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4222 if (target_ptr->align > 10)
4224 else if (target_ptr->align < -10)
4226 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4232 if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4233 if (target_ptr->align > 10)
4235 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4239 /* Arrow -- XXX no dodging */
4244 msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
4246 else if ((target_ptr->inventory_list[INVEN_RARM].name1 == ART_ZANTETSU) || (target_ptr->inventory_list[INVEN_LARM].name1 == ART_ZANTETSU))
4248 msg_print(_("矢を斬り捨てた!", "You cut down the arrow!"));
4251 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4255 /* Plasma -- XXX No resist */
4258 if (fuzzy) msg_print(_("何かとても熱いもので攻撃された!", "You are hit by something *HOT*!"));
4259 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4261 if (!target_ptr->resist_sound && !CHECK_MULTISHADOW(target_ptr))
4263 int plus_stun = (randint1((dam > 40) ? 35 : (dam * 3 / 4 + 5)));
4264 (void)set_stun(target_ptr, target_ptr->stun + plus_stun);
4267 if (!(target_ptr->resist_fire || is_oppose_fire(target_ptr) || target_ptr->immune_fire))
4269 inventory_damage(target_ptr, set_acid_destroy, 3);
4275 /* Nether -- drain experience */
4278 if (fuzzy) msg_print(_("地獄の力で攻撃された!", "You are hit by nether forces!"));
4279 if (target_ptr->resist_neth)
4281 if (!PRACE_IS_(target_ptr, RACE_SPECTRE))
4283 dam *= 6; dam /= (randint1(4) + 7);
4286 else if (!CHECK_MULTISHADOW(target_ptr)) drain_exp(target_ptr, 200 + (target_ptr->exp / 100), 200 + (target_ptr->exp / 1000), 75);
4288 if (PRACE_IS_(target_ptr, RACE_SPECTRE) && !CHECK_MULTISHADOW(target_ptr))
4290 msg_print(_("気分がよくなった。", "You feel invigorated!"));
4291 hp_player(target_ptr, dam / 4);
4292 learn_spell(target_ptr, monspell);
4296 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4302 /* Water -- stun/confuse */
4305 if (fuzzy) msg_print(_("何か湿ったもので攻撃された!", "You are hit by something wet!"));
4306 if (!CHECK_MULTISHADOW(target_ptr))
4308 if (!target_ptr->resist_sound && !target_ptr->resist_water)
4310 set_stun(target_ptr, target_ptr->stun + randint1(40));
4312 if (!target_ptr->resist_conf && !target_ptr->resist_water)
4314 set_confused(target_ptr, target_ptr->confused + randint1(5) + 5);
4317 if (one_in_(5) && !target_ptr->resist_water)
4319 inventory_damage(target_ptr, set_cold_destroy, 3);
4322 if (target_ptr->resist_water) get_damage /= 4;
4325 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4329 /* Chaos -- many effects */
4332 if (fuzzy) msg_print(_("無秩序の波動で攻撃された!", "You are hit by a wave of anarchy!"));
4333 if (target_ptr->resist_chaos)
4335 dam *= 6; dam /= (randint1(4) + 7);
4338 if (!CHECK_MULTISHADOW(target_ptr))
4340 if (!target_ptr->resist_conf)
4342 (void)set_confused(target_ptr, target_ptr->confused + randint0(20) + 10);
4344 if (!target_ptr->resist_chaos)
4346 (void)set_image(target_ptr, target_ptr->image + randint1(10));
4349 msg_print(_("あなたの身体はカオスの力で捻じ曲げられた!", "Your body is twisted by chaos!"));
4350 (void)gain_mutation(target_ptr, 0);
4353 if (!target_ptr->resist_neth && !target_ptr->resist_chaos)
4355 drain_exp(target_ptr, 5000 + (target_ptr->exp / 100), 500 + (target_ptr->exp / 1000), 75);
4358 if (!target_ptr->resist_chaos || one_in_(9))
4360 inventory_damage(target_ptr, set_elec_destroy, 2);
4361 inventory_damage(target_ptr, set_fire_destroy, 2);
4365 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4369 /* Shards -- mostly cutting */
4372 if (fuzzy) msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
4373 if (target_ptr->resist_shard)
4375 dam *= 6; dam /= (randint1(4) + 7);
4377 else if (!CHECK_MULTISHADOW(target_ptr))
4379 (void)set_cut(target_ptr, target_ptr->cut + dam);
4382 if (!target_ptr->resist_shard || one_in_(13))
4384 inventory_damage(target_ptr, set_cold_destroy, 2);
4387 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4391 /* Sound -- mostly stunning */
4394 if (fuzzy) msg_print(_("轟音で攻撃された!", "You are hit by a loud noise!"));
4395 if (target_ptr->resist_sound)
4397 dam *= 5; dam /= (randint1(4) + 7);
4399 else if (!CHECK_MULTISHADOW(target_ptr))
4401 int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
4402 (void)set_stun(target_ptr, target_ptr->stun + plus_stun);
4405 if (!target_ptr->resist_sound || one_in_(13))
4407 inventory_damage(target_ptr, set_cold_destroy, 2);
4410 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4414 /* Pure confusion */
4417 if (fuzzy) msg_print(_("何か混乱するもので攻撃された!", "You are hit by something puzzling!"));
4418 if (target_ptr->resist_conf)
4420 dam *= 5; dam /= (randint1(4) + 7);
4422 else if (!CHECK_MULTISHADOW(target_ptr))
4424 (void)set_confused(target_ptr, target_ptr->confused + randint1(20) + 10);
4426 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4430 /* Disenchantment -- see above */
4433 if (fuzzy) msg_print(_("何かさえないもので攻撃された!", "You are hit by something static!"));
4434 if (target_ptr->resist_disen)
4436 dam *= 6; dam /= (randint1(4) + 7);
4438 else if (!CHECK_MULTISHADOW(target_ptr))
4440 (void)apply_disenchant(target_ptr, 0);
4442 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4446 /* Nexus -- see above */
4449 if (fuzzy) msg_print(_("何か奇妙なもので攻撃された!", "You are hit by something strange!"));
4450 if (target_ptr->resist_nexus)
4452 dam *= 6; dam /= (randint1(4) + 7);
4454 else if (!CHECK_MULTISHADOW(target_ptr))
4456 apply_nexus(m_ptr, target_ptr);
4458 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4462 /* Force -- mostly stun */
4465 if (fuzzy) msg_print(_("運動エネルギーで攻撃された!", "You are hit by kinetic force!"));
4466 if (!target_ptr->resist_sound && !CHECK_MULTISHADOW(target_ptr))
4468 (void)set_stun(target_ptr, target_ptr->stun + randint1(20));
4470 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4475 /* Rocket -- stun, cut */
4478 if (fuzzy) msg_print(_("爆発があった!", "There is an explosion!"));
4479 if (!target_ptr->resist_sound && !CHECK_MULTISHADOW(target_ptr))
4481 (void)set_stun(target_ptr, target_ptr->stun + randint1(20));
4484 if (target_ptr->resist_shard)
4488 else if (!CHECK_MULTISHADOW(target_ptr))
4490 (void)set_cut(target_ptr, target_ptr->cut + (dam / 2));
4493 if (!target_ptr->resist_shard || one_in_(12))
4495 inventory_damage(target_ptr, set_cold_destroy, 3);
4498 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4502 /* Inertia -- slowness */
4505 if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
4506 if (!CHECK_MULTISHADOW(target_ptr)) (void)set_slow(target_ptr, target_ptr->slow + randint0(4) + 4, FALSE);
4507 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4511 /* Lite -- blinding */
4514 if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4515 if (target_ptr->resist_lite)
4517 dam *= 4; dam /= (randint1(4) + 7);
4519 else if (!blind && !target_ptr->resist_blind && !CHECK_MULTISHADOW(target_ptr))
4521 (void)set_blind(target_ptr, target_ptr->blind + randint1(5) + 2);
4524 if (PRACE_IS_(target_ptr, RACE_VAMPIRE) || (target_ptr->mimic_form == MIMIC_VAMPIRE))
4526 if (!CHECK_MULTISHADOW(target_ptr)) msg_print(_("光で肉体が焦がされた!", "The light scorches your flesh!"));
4529 else if (PRACE_IS_(target_ptr, RACE_S_FAIRY))
4534 if (target_ptr->wraith_form) dam *= 2;
4535 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4537 if (target_ptr->wraith_form && !CHECK_MULTISHADOW(target_ptr))
4539 target_ptr->wraith_form = 0;
4540 msg_print(_("閃光のため非物質的な影の存在でいられなくなった。",
4541 "The light forces you out of your incorporeal shadow form."));
4543 target_ptr->redraw |= (PR_MAP | PR_STATUS);
4544 target_ptr->update |= (PU_MONSTERS);
4545 target_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4551 /* Dark -- blinding */
4554 if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4555 if (target_ptr->resist_dark)
4557 dam *= 4; dam /= (randint1(4) + 7);
4559 if (PRACE_IS_(target_ptr, RACE_VAMPIRE) || (target_ptr->mimic_form == MIMIC_VAMPIRE) || target_ptr->wraith_form) dam = 0;
4561 else if (!blind && !target_ptr->resist_blind && !CHECK_MULTISHADOW(target_ptr))
4563 (void)set_blind(target_ptr, target_ptr->blind + randint1(5) + 2);
4565 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4569 /* Time -- bolt fewer effects XXX */
4572 if (fuzzy) msg_print(_("過去からの衝撃に攻撃された!", "You are hit by a blast from the past!"));
4573 if (target_ptr->resist_time)
4576 dam /= (randint1(4) + 7);
4577 msg_print(_("時間が通り過ぎていく気がする。", "You feel as if time is passing you by."));
4579 else if (!CHECK_MULTISHADOW(target_ptr))
4581 switch (randint1(10))
4583 case 1: case 2: case 3: case 4: case 5:
4585 if (target_ptr->prace == RACE_ANDROID) break;
4586 msg_print(_("人生が逆戻りした気がする。", "You feel life has clocked back."));
4587 lose_exp(target_ptr, 100 + (target_ptr->exp / 100) * MON_DRAIN_LIFE);
4591 case 6: case 7: case 8: case 9:
4593 switch (randint1(6))
4595 case 1: k = A_STR; act = _("強く", "strong"); break;
4596 case 2: k = A_INT; act = _("聡明で", "bright"); break;
4597 case 3: k = A_WIS; act = _("賢明で", "wise"); break;
4598 case 4: k = A_DEX; act = _("器用で", "agile"); break;
4599 case 5: k = A_CON; act = _("健康で", "hale"); break;
4600 case 6: k = A_CHR; act = _("美しく", "beautiful"); break;
4603 msg_format(_("あなたは以前ほど%sなくなってしまった...。",
4604 "You're not as %s as you used to be..."), act);
4606 target_ptr->stat_cur[k] = (target_ptr->stat_cur[k] * 3) / 4;
4607 if (target_ptr->stat_cur[k] < 3) target_ptr->stat_cur[k] = 3;
4608 target_ptr->update |= (PU_BONUS);
4614 msg_print(_("あなたは以前ほど力強くなくなってしまった...。",
4615 "You're not as powerful as you used to be..."));
4617 for (k = 0; k < A_MAX; k++)
4619 target_ptr->stat_cur[k] = (target_ptr->stat_cur[k] * 7) / 8;
4620 if (target_ptr->stat_cur[k] < 3) target_ptr->stat_cur[k] = 3;
4622 target_ptr->update |= (PU_BONUS);
4628 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4632 /* Gravity -- stun plus slowness plus teleport */
4635 if (fuzzy) msg_print(_("何か重いもので攻撃された!", "You are hit by something heavy!"));
4636 msg_print(_("周辺の重力がゆがんだ。", "Gravity warps around you."));
4638 if (!CHECK_MULTISHADOW(target_ptr))
4640 teleport_player(target_ptr, 5, TELEPORT_PASSIVE);
4641 if (!target_ptr->levitation)
4642 (void)set_slow(target_ptr, target_ptr->slow + randint0(4) + 4, FALSE);
4643 if (!(target_ptr->resist_sound || target_ptr->levitation))
4645 int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
4646 (void)set_stun(target_ptr, target_ptr->stun + plus_stun);
4649 if (target_ptr->levitation)
4651 dam = (dam * 2) / 3;
4654 if (!target_ptr->levitation || one_in_(13))
4656 inventory_damage(target_ptr, set_cold_destroy, 2);
4659 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4663 /* Standard damage */
4664 case GF_DISINTEGRATE:
4666 if (fuzzy) msg_print(_("純粋なエネルギーで攻撃された!", "You are hit by pure energy!"));
4668 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4674 if (fuzzy) msg_print(_("何らかの攻撃によって気分がよくなった。", "You are hit by something invigorating!"));
4676 (void)hp_player(target_ptr, dam);
4683 if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4684 (void)set_fast(target_ptr, target_ptr->fast + randint1(5), FALSE);
4691 if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
4692 (void)set_slow(target_ptr, target_ptr->slow + randint0(4) + 4, FALSE);
4698 if (target_ptr->free_act) break;
4699 if (fuzzy) msg_print(_("眠ってしまった!", "You fall asleep!"));
4701 if (ironman_nightmare)
4703 msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind."));
4704 /* Have some nightmares */
4705 sanity_blast(target_ptr, NULL, FALSE);
4708 set_paralyzed(target_ptr, target_ptr->paralyzed + dam);
4718 if (fuzzy) msg_print(_("魔法のオーラで攻撃された!", "You are hit by an aura of magic!"));
4719 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4726 if (fuzzy) msg_print(_("エネルギーの塊で攻撃された!", "You are hit by an energy!"));
4727 get_damage = take_hit(target_ptr, DAMAGE_FORCE, dam, killer, monspell);
4734 if (fuzzy) msg_print(_("何かが空からあなたの頭上に落ちてきた!", "Something falls from the sky on you!"));
4736 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4737 if (!target_ptr->resist_shard || one_in_(13))
4739 if (!target_ptr->immune_fire) inventory_damage(target_ptr, set_fire_destroy, 2);
4740 inventory_damage(target_ptr, set_cold_destroy, 2);
4746 /* Ice -- cold plus stun plus cuts */
4749 if (fuzzy) msg_print(_("何か鋭く冷たいもので攻撃された!", "You are hit by something sharp and cold!"));
4750 get_damage = cold_dam(target_ptr, dam, killer, monspell, FALSE);
4751 if (!CHECK_MULTISHADOW(target_ptr))
4753 if (!target_ptr->resist_shard)
4755 (void)set_cut(target_ptr, target_ptr->cut + damroll(5, 8));
4757 if (!target_ptr->resist_sound)
4759 (void)set_stun(target_ptr, target_ptr->stun + randint1(15));
4762 if ((!(target_ptr->resist_cold || is_oppose_cold(target_ptr))) || one_in_(12))
4764 if (!target_ptr->immune_cold) inventory_damage(target_ptr, set_cold_destroy, 3);
4774 if (fuzzy) msg_print(_("何か非常に冷たいもので攻撃された!", "You are hit by something extremely cold!"));
4776 if (target_ptr->mimic_form)
4778 if (!(mimic_info[target_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
4779 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4784 switch (target_ptr->prace)
4786 /* Some races are immune */
4800 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4812 if (CHECK_MULTISHADOW(target_ptr))
4814 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, you are unharmed!"));
4816 else if (target_ptr->csp)
4820 msg_format(_("%^sに精神エネルギーを吸い取られてしまった!", "%^s draws psychic energy from you!"), m_name);
4822 msg_print(_("精神エネルギーを吸い取られてしまった!", "Your psychic energy is drawn!"));
4825 if (dam >= target_ptr->csp)
4827 dam = target_ptr->csp;
4828 target_ptr->csp = 0;
4829 target_ptr->csp_frac = 0;
4835 target_ptr->csp -= dam;
4838 learn_spell(target_ptr, monspell);
4839 target_ptr->redraw |= (PR_MANA);
4840 target_ptr->window |= (PW_PLAYER | PW_SPELL);
4844 /* Heal the monster */
4845 if (m_ptr->hp < m_ptr->maxhp)
4849 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
4851 /* Redraw (later) if needed */
4852 if (target_ptr->health_who == who) target_ptr->redraw |= (PR_HEALTH);
4853 if (target_ptr->riding == who) target_ptr->redraw |= (PR_UHEALTH);
4855 /* Special message */
4858 msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), m_name);
4871 if ((randint0(100 + rlev / 2) < MAX(5, target_ptr->skill_sav)) && !CHECK_MULTISHADOW(target_ptr))
4873 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
4874 learn_spell(target_ptr, monspell);
4878 if (!CHECK_MULTISHADOW(target_ptr))
4880 msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
4882 if (!target_ptr->resist_conf)
4884 (void)set_confused(target_ptr, target_ptr->confused + randint0(4) + 4);
4887 if (!target_ptr->resist_chaos && one_in_(3))
4889 (void)set_image(target_ptr, target_ptr->image + randint0(250) + 150);
4892 target_ptr->csp -= 50;
4893 if (target_ptr->csp < 0)
4895 target_ptr->csp = 0;
4896 target_ptr->csp_frac = 0;
4898 target_ptr->redraw |= PR_MANA;
4901 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4907 case GF_BRAIN_SMASH:
4909 if ((randint0(100 + rlev / 2) < MAX(5, target_ptr->skill_sav)) && !CHECK_MULTISHADOW(target_ptr))
4911 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
4912 learn_spell(target_ptr, monspell);
4916 if (!CHECK_MULTISHADOW(target_ptr))
4918 msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
4920 target_ptr->csp -= 100;
4921 if (target_ptr->csp < 0)
4923 target_ptr->csp = 0;
4924 target_ptr->csp_frac = 0;
4926 target_ptr->redraw |= PR_MANA;
4929 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4930 if (!CHECK_MULTISHADOW(target_ptr))
4932 if (!target_ptr->resist_blind)
4934 (void)set_blind(target_ptr, target_ptr->blind + 8 + randint0(8));
4936 if (!target_ptr->resist_conf)
4938 (void)set_confused(target_ptr, target_ptr->confused + randint0(4) + 4);
4940 if (!target_ptr->free_act)
4942 (void)set_paralyzed(target_ptr, target_ptr->paralyzed + randint0(4) + 4);
4944 (void)set_slow(target_ptr, target_ptr->slow + randint0(4) + 4, FALSE);
4946 while (randint0(100 + rlev / 2) > (MAX(5, target_ptr->skill_sav)))
4947 (void)do_dec_stat(target_ptr, A_INT);
4948 while (randint0(100 + rlev / 2) > (MAX(5, target_ptr->skill_sav)))
4949 (void)do_dec_stat(target_ptr, A_WIS);
4951 if (!target_ptr->resist_chaos)
4953 (void)set_image(target_ptr, target_ptr->image + randint0(250) + 150);
4963 if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
4965 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
4966 learn_spell(target_ptr, monspell);
4970 if (!CHECK_MULTISHADOW(target_ptr)) curse_equipment(target_ptr, 15, 0);
4971 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4979 if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
4981 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
4982 learn_spell(target_ptr, monspell);
4986 if (!CHECK_MULTISHADOW(target_ptr)) curse_equipment(target_ptr, 25, MIN(rlev / 2 - 15, 5));
4987 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
4995 if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
4997 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
4998 learn_spell(target_ptr, monspell);
5002 if (!CHECK_MULTISHADOW(target_ptr)) curse_equipment(target_ptr, 33, MIN(rlev / 2 - 15, 15));
5003 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
5011 if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !(m_ptr->r_idx == MON_KENSHIROU) && !CHECK_MULTISHADOW(target_ptr))
5013 msg_print(_("しかし秘孔を跳ね返した!", "You resist the effects!"));
5014 learn_spell(target_ptr, monspell);
5018 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
5019 if (!CHECK_MULTISHADOW(target_ptr)) (void)set_cut(target_ptr, target_ptr->cut + damroll(10, 10));
5027 if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
5029 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5030 learn_spell(target_ptr, monspell);
5034 if (!CHECK_MULTISHADOW(target_ptr))
5036 msg_print(_("あなたは命が薄まっていくように感じた!", "You feel your life fade away!"));
5037 curse_equipment(target_ptr, 40, 20);
5040 get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, m_name, monspell);
5042 if (target_ptr->chp < 1) target_ptr->chp = 1;
5057 /* Hex - revenge damage stored */
5058 revenge_store(target_ptr, get_damage);
5060 if ((target_ptr->tim_eyeeye || hex_spelling(target_ptr, HEX_EYE_FOR_EYE))
5061 && (get_damage > 0) && !target_ptr->is_dead && (who > 0))
5063 GAME_TEXT m_name_self[80];
5066 monster_desc(target_ptr, m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
5068 msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
5069 project(target_ptr, 0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
5070 if (target_ptr->tim_eyeeye) set_tim_eyeeye(target_ptr, target_ptr->tim_eyeeye - 5, TRUE);
5073 if (target_ptr->riding && dam > 0)
5075 rakubadam_p = (dam > 200) ? 200 : dam;
5079 disturb(target_ptr, TRUE, TRUE);
5082 if ((target_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != target_ptr->riding))
5084 (void)kawarimi(target_ptr, FALSE);
5087 /* Return "Anything seen?" */
5093 * Find the distance from (x, y) to a line.
5095 POSITION dist_to_line(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
5097 /* Vector from (x, y) to (x1, y1) */
5098 POSITION py = y1 - y;
5099 POSITION px = x1 - x;
5102 POSITION ny = x2 - x1;
5103 POSITION nx = y1 - y2;
5106 POSITION pd = distance(y1, x1, y, x);
5107 POSITION nd = distance(y1, x1, y2, x2);
5109 if (pd > nd) return distance(y, x, y2, x2);
5111 /* Component of P on N */
5112 nd = ((nd) ? ((py * ny + px * nx) / nd) : 0);
5114 /* Absolute value */
5115 return((nd >= 0) ? nd : 0 - nd);
5121 * Modified version of los() for calculation of disintegration balls.
5122 * Disintegration effects are stopped by permanent walls.
5124 bool in_disintegration_range(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
5126 POSITION dx, dy; /* Delta */
5127 POSITION ax, ay; /* Absolute */
5128 POSITION sx, sy; /* Signs */
5129 POSITION qx, qy; /* Fractions */
5130 POSITION tx, ty; /* Scanners */
5131 POSITION f1, f2; /* Scale factors */
5132 POSITION m; /* Slope, or 1/Slope, of LOS */
5134 /* Extract the offset */
5138 /* Extract the absolute offset */
5142 /* Handle adjacent (or identical) grids */
5143 if ((ax < 2) && (ay < 2)) return TRUE;
5145 /* Paranoia -- require "safe" origin */
5146 /* if (!in_bounds(floor_ptr, y1, x1)) return FALSE; */
5148 /* Directly South/North */
5151 /* South -- check for walls */
5154 for (ty = y1 + 1; ty < y2; ty++)
5156 if (cave_stop_disintegration(floor_ptr, ty, x1)) return FALSE;
5160 /* North -- check for walls */
5163 for (ty = y1 - 1; ty > y2; ty--)
5165 if (cave_stop_disintegration(floor_ptr, ty, x1)) return FALSE;
5173 /* Directly East/West */
5176 /* East -- check for walls */
5179 for (tx = x1 + 1; tx < x2; tx++)
5181 if (cave_stop_disintegration(floor_ptr, y1, tx)) return FALSE;
5185 /* West -- check for walls */
5188 for (tx = x1 - 1; tx > x2; tx--)
5190 if (cave_stop_disintegration(floor_ptr, y1, tx)) return FALSE;
5198 /* Extract some signs */
5199 sx = (dx < 0) ? -1 : 1;
5200 sy = (dy < 0) ? -1 : 1;
5202 /* Vertical "knights" */
5207 if (!cave_stop_disintegration(floor_ptr, y1 + sy, x1)) return TRUE;
5211 /* Horizontal "knights" */
5216 if (!cave_stop_disintegration(floor_ptr, y1, x1 + sx)) return TRUE;
5220 /* Calculate scale factor div 2 */
5223 /* Calculate scale factor */
5227 /* Travel horizontally */
5230 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
5236 /* Consider the special case where slope == 1. */
5247 /* Note (below) the case (qy == f2), where */
5248 /* the LOS exactly meets the corner of a tile. */
5251 if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
5262 if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
5277 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
5293 /* Note (below) the case (qx == f2), where */
5294 /* the LOS exactly meets the corner of a tile. */
5297 if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
5308 if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
5327 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)
5332 int brev = rad * rad / dist;
5336 int mdis = distance(y1, x1, y2, x2) + rad;
5338 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
5339 while (bdis <= mdis)
5343 if ((0 < dist) && (path_n < dist))
5345 POSITION ny = GRID_Y(path_g[path_n]);
5346 POSITION nx = GRID_X(path_g[path_n]);
5347 POSITION nd = distance(ny, nx, y1, x1);
5349 /* Get next base point */
5358 /* Travel from center outward */
5359 for (cdis = 0; cdis <= brad; cdis++)
5361 /* Scan the maximal blast area of radius "cdis" */
5362 for (y = by - cdis; y <= by + cdis; y++)
5364 for (x = bx - cdis; x <= bx + cdis; x++)
5366 /* Ignore "illegal" locations */
5367 if (!in_bounds(floor_ptr, y, x)) continue;
5369 /* Enforce a circular "ripple" */
5370 if (distance(y1, x1, y, x) != bdis) continue;
5372 /* Enforce an arc */
5373 if (distance(by, bx, y, x) != cdis) continue;
5379 /* Lights are stopped by opaque terrains */
5380 if (!los(caster_ptr, by, bx, y, x)) continue;
5382 case GF_DISINTEGRATE:
5383 /* Disintegration are stopped only by perma-walls */
5384 if (!in_disintegration_range(floor_ptr, by, bx, y, x)) continue;
5387 /* Ball explosions are stopped by walls */
5388 if (!projectable(caster_ptr, by, bx, y, x)) continue;
5392 /* Save this grid */
5400 /* Encode some more "radius" info */
5401 gm[bdis + 1] = *pgrids;
5403 /* Increase the size */
5404 brad = rad * (path_n + brev) / (dist + brev);
5406 /* Find the next ripple */
5410 /* Store the effect size */
5416 * @brief 汎用的なビーム/ボルト/ボール系処理のルーチン Generic "beam"/"bolt"/"ball" projection routine.
5417 * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
5418 * @param rad 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
5419 * @param y 目標Y座標 / Target y location (or location to travel "towards")
5420 * @param x 目標X座標 / Target x location (or location to travel "towards")
5421 * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
5422 * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
5423 * @param flg 効果フラグ / Extra bit flags (see PROJECT_xxxx)
5424 * @param monspell 効果元のモンスター魔法ID
5425 * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
5428 * Allows a monster (or player) to project a beam/bolt/ball of a given kind
5429 * towards a given location (optionally passing over the heads of interposing
5430 * monsters), and have it do a given amount of damage to the monsters (and
5431 * optionally objects) within the given radius of the final location.
5433 * A "bolt" travels from source to target and affects only the target grid.
5434 * A "beam" travels from source to target, affecting all grids passed through.
5435 * A "ball" travels from source to the target, exploding at the target, and
5436 * affecting everything within the given radius of the target location.
5438 * Traditionally, a "bolt" does not affect anything on the ground, and does
5439 * not pass over the heads of interposing monsters, much like a traditional
5440 * missile, and will "stop" abruptly at the "target" even if no monster is
5441 * positioned there, while a "ball", on the other hand, passes over the heads
5442 * of monsters between the source and target, and affects everything except
5443 * the source monster which lies within the final radius, while a "beam"
5444 * affects every monster between the source and target, except for the casting
5445 * monster (or player), and rarely affects things on the ground.
5447 * Two special flags allow us to use this function in special ways, the
5448 * "PROJECT_HIDE" flag allows us to perform "invisible" projections, while
5449 * the "PROJECT_JUMP" flag allows us to affect a specific grid, without
5450 * actually projecting from the source monster (or player).
5452 * The player will only get "experience" for monsters killed by himself
5453 * Unique monsters can only be destroyed by attacks from the player
5455 * Only 256 grids can be affected per projection, limiting the effective
5456 * "radius" of standard ball attacks to nine units (diameter nineteen).
5458 * One can project in a given "direction" by combining PROJECT_THRU with small
5459 * offsets to the initial location (see "line_spell()"), or by calculating
5460 * "virtual targets" far away from the player.
5462 * One can also use PROJECT_THRU to send a beam/bolt along an angled path,
5463 * continuing until it actually hits somethings (useful for "stone to mud").
5465 * Bolts and Beams explode INSIDE walls, so that they can destroy doors.
5467 * Balls must explode BEFORE hitting walls, or they would affect monsters
5468 * on both sides of a wall. Some bug reports indicate that this is still
5469 * happening in 2.7.8 for Windows, though it appears to be impossible.
5471 * We "pre-calculate" the blast area only in part for efficiency.
5472 * More importantly, this lets us do "explosions" from the "inside" out.
5473 * This results in a more logical distribution of "blast" treasure.
5474 * It also produces a better (in my opinion) animation of the explosion.
5475 * It could be (but is not) used to have the treasure dropped by monsters
5476 * in the middle of the explosion fall "outwards", and then be damaged by
5477 * the blast as it spreads outwards towards the treasure drop location.
5479 * Walls and doors are included in the blast area, so that they can be
5480 * "burned" or "melted" in later versions.
5482 * This algorithm is intended to maximize simplicity, not necessarily
5483 * efficiency, since this function is not a bottleneck in the code.
5485 * We apply the blast effect from ground zero outwards, in several passes,
5486 * first affecting features, then objects, then monsters, then the player.
5487 * This allows walls to be removed before checking the object or monster
5488 * in the wall, and protects objects which are dropped by monsters killed
5489 * in the blast, and allows the player to see all affects before he is
5490 * killed or teleported away. The semantics of this method are open to
5491 * various interpretations, but they seem to work well in practice.
5493 * We process the blast area from ground-zero outwards to allow for better
5494 * distribution of treasure dropped by monsters, and because it provides a
5495 * pleasing visual effect at low cost.
5497 * Note that the damage done by "ball" explosions decreases with distance.
5498 * This decrease is rapid, grids at radius "dist" take "1/dist" damage.
5500 * Notice the "napalm" effect of "beam" weapons. First they "project" to
5501 * the target, and then the damage "flows" along this beam of destruction.
5502 * The damage at every grid is the same as at the "center" of a "ball"
5503 * explosion, since the "beam" grids are treated as if they ARE at the
5504 * center of a "ball" explosion.
5506 * Currently, specifying "beam" plus "ball" means that locations which are
5507 * covered by the initial "beam", and also covered by the final "ball", except
5508 * for the final grid (the epicenter of the ball), will be "hit twice", once
5509 * by the initial beam, and once by the exploding ball. For the grid right
5510 * next to the epicenter, this results in 150% damage being done. The center
5511 * does not have this problem, for the same reason the final grid in a "beam"
5512 * plus "bolt" does not -- it is explicitly removed. Simply removing "beam"
5513 * grids which are covered by the "ball" will NOT work, as then they will
5514 * receive LESS damage than they should. Do not combine "beam" with "ball".
5516 * The array "gy[],gx[]" with current size "grids" is used to hold the
5517 * collected locations of all grids in the "blast area" plus "beam path".
5519 * Note the rather complex usage of the "gm[]" array. First, gm[0] is always
5520 * zero. Second, for N>1, gm[N] is always the index (in gy[],gx[]) of the
5521 * first blast grid (see above) with radius "N" from the blast center. Note
5522 * that only the first gm[1] grids in the blast area thus take full damage.
5523 * Also, note that gm[rad+1] is always equal to "grids", which is the total
5524 * number of blast grids.
5526 * Note that once the projection is complete, (y2,x2) holds the final location
5527 * of bolts/beams, and the "epicenter" of balls.
5529 * Note also that "rad" specifies the "inclusive" radius of projection blast,
5530 * so that a "rad" of "one" actually covers 5 or 9 grids, depending on the
5531 * implementation of the "distance" function. Also, a bolt can be properly
5532 * viewed as a "ball" with a "rad" of "zero".
5534 * Note that if no "target" is reached before the beam/bolt/ball travels the
5535 * maximum distance allowed (MAX_RANGE), no "blast" will be induced. This
5536 * may be relevant even for bolts, since they have a "1x1" mini-blast.
5538 * Note that for consistency, we "pretend" that the bolt actually takes "time"
5539 * to move from point A to point B, even if the player cannot see part of the
5540 * projection path. Note that in general, the player will *always* see part
5541 * of the path, since it either starts at the player or ends on the player.
5543 * Hack -- we assume that every "projection" is "self-illuminating".
5545 * Hack -- when only a single monster is affected, we automatically track
5546 * (and recall) that monster, unless "PROJECT_JUMP" is used.
5548 * Note that all projections now "explode" at their final destination, even
5549 * if they were being projected at a more distant destination. This means
5550 * that "ball" spells will *always* explode.
5552 * Note that we must call "handle_stuff()" after affecting terrain features
5553 * in the blast radius, in case the "illumination" of the grid was changed,
5554 * and "update_view()" and "update_monsters()" need to be called.
5557 bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
5567 POSITION y_saver, x_saver; /* For reflecting monsters */
5569 int msec = delay_factor * delay_factor * delay_factor;
5571 /* Assume the player sees nothing */
5572 bool notice = FALSE;
5574 /* Assume the player has seen nothing */
5575 bool visual = FALSE;
5577 /* Assume the player has seen no blast grids */
5580 /* Assume to be a normal ball spell */
5581 bool breath = FALSE;
5583 /* Is the player blind? */
5584 bool blind = (caster_ptr->blind ? TRUE : FALSE);
5586 bool old_hide = FALSE;
5588 /* Number of grids in the "path" */
5591 /* Actual grids in the "path" */
5594 /* Number of grids in the "blast area" (including the "beam" path) */
5597 /* Coordinates of the affected grids */
5598 POSITION gx[1024], gy[1024];
5600 /* Encoded "radius" info (see above) */
5603 /* Actual radius encoded in gm[] */
5604 POSITION gm_rad = rad;
5608 /* Attacker's name (prepared before polymorph)*/
5609 GAME_TEXT who_name[MAX_NLEN];
5611 /* Can the player see the source of this effect? */
5612 bool see_s_msg = TRUE;
5614 /* Initialize by null string */
5620 /* Default target of monsterspell is player */
5621 monster_target_y = caster_ptr->y;
5622 monster_target_x = caster_ptr->x;
5624 /* Hack -- Jump to target */
5625 if (flg & (PROJECT_JUMP))
5630 /* Clear the flag */
5631 flg &= ~(PROJECT_JUMP);
5636 /* Start at player */
5643 /* Start at monster */
5646 x1 = caster_ptr->current_floor_ptr->m_list[who].fx;
5647 y1 = caster_ptr->current_floor_ptr->m_list[who].fy;
5648 monster_desc(caster_ptr, who_name, &caster_ptr->current_floor_ptr->m_list[who], MD_WRONGDOER_NAME);
5660 /* Default "destination" */
5665 /* Hack -- verify stuff */
5666 if (flg & (PROJECT_THRU))
5668 if ((x1 == x2) && (y1 == y2))
5670 flg &= ~(PROJECT_THRU);
5674 /* Handle a breath attack */
5679 if (flg & PROJECT_HIDE) old_hide = TRUE;
5680 flg |= PROJECT_HIDE;
5683 /* Hack -- Assume there will be no blast (max radius 32) */
5684 for (dist = 0; dist < 32; dist++) gm[dist] = 0;
5692 /* Collect beam grids */
5693 if (flg & (PROJECT_BEAM))
5704 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_LOS);
5706 case GF_DISINTEGRATE:
5707 flg |= (PROJECT_GRID);
5708 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_DISI);
5712 /* Calculate the projection path */
5714 path_n = project_path(caster_ptr, path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
5715 handle_stuff(caster_ptr);
5717 /* Giga-Hack SEEKER & SUPER_RAY */
5719 if (typ == GF_SEEKER)
5729 for (i = 0; i < path_n; ++i)
5734 POSITION ny = GRID_Y(path_g[i]);
5735 POSITION nx = GRID_X(path_g[i]);
5745 /* Only do visuals if requested */
5746 if (!blind && !(flg & (PROJECT_HIDE)))
5748 /* Only do visuals if the player can "see" the bolt */
5749 if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
5754 /* Obtain the bolt pict */
5755 u16b p = bolt_pict(oy, ox, y, x, typ);
5757 /* Extract attr/char */
5761 /* Visual effects */
5762 print_rel(caster_ptr, c, a, y, x);
5763 move_cursor_relative(y, x);
5765 Term_xtra(TERM_XTRA_DELAY, msec);
5766 lite_spot(caster_ptr, y, x);
5769 /* Display "beam" grids */
5770 if (flg & (PROJECT_BEAM))
5772 /* Obtain the explosion pict */
5773 p = bolt_pict(y, x, y, x, typ);
5775 /* Extract attr/char */
5779 /* Visual effects */
5780 print_rel(caster_ptr, c, a, y, x);
5783 /* Hack -- Activate delay */
5787 /* Hack -- delay anyway for consistency */
5790 /* Delay for consistency */
5791 Term_xtra(TERM_XTRA_DELAY, msec);
5795 if (project_o(caster_ptr, 0, 0, y, x, dam, GF_SEEKER))notice = TRUE;
5796 if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
5798 /* The target of monsterspell becomes tha mirror(broken) */
5799 monster_target_y = y;
5800 monster_target_x = x;
5802 remove_mirror(caster_ptr, y, x);
5803 next_mirror(caster_ptr, &oy, &ox, y, x);
5805 path_n = i + project_path(caster_ptr, &(path_g[i + 1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
5806 for (j = last_i; j <= i; j++)
5808 y = GRID_Y(path_g[j]);
5809 x = GRID_X(path_g[j]);
5810 if (project_m(caster_ptr, 0, 0, y, x, dam, GF_SEEKER, flg, TRUE)) notice = TRUE;
5811 if (!who && (project_m_n == 1) && !jump) {
5812 if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0)
5814 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];
5818 if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
5819 health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
5824 (void)project_f(caster_ptr, 0, 0, y, x, dam, GF_SEEKER);
5831 for (i = last_i; i < path_n; i++)
5834 py = GRID_Y(path_g[i]);
5835 px = GRID_X(path_g[i]);
5836 if (project_m(caster_ptr, 0, 0, py, px, dam, GF_SEEKER, flg, TRUE))
5838 if (!who && (project_m_n == 1) && !jump) {
5839 if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0)
5841 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];
5845 if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
5846 health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
5851 (void)project_f(caster_ptr, 0, 0, py, px, dam, GF_SEEKER);
5856 else if (typ == GF_SUPER_RAY)
5859 int second_step = 0;
5866 for (i = 0; i < path_n; ++i)
5871 POSITION ny = GRID_Y(path_g[i]);
5872 POSITION nx = GRID_X(path_g[i]);
5882 /* Only do visuals if requested */
5883 if (!blind && !(flg & (PROJECT_HIDE)))
5885 /* Only do visuals if the player can "see" the bolt */
5886 if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
5893 /* Obtain the bolt pict */
5894 p = bolt_pict(oy, ox, y, x, typ);
5896 /* Extract attr/char */
5900 /* Visual effects */
5901 print_rel(caster_ptr, c, a, y, x);
5902 move_cursor_relative(y, x);
5903 /*if (fresh_before)*/ Term_fresh();
5904 Term_xtra(TERM_XTRA_DELAY, msec);
5905 lite_spot(caster_ptr, y, x);
5906 /*if (fresh_before)*/ Term_fresh();
5908 /* Display "beam" grids */
5909 if (flg & (PROJECT_BEAM))
5911 /* Obtain the explosion pict */
5912 p = bolt_pict(y, x, y, x, typ);
5914 /* Extract attr/char */
5918 /* Visual effects */
5919 print_rel(caster_ptr, c, a, y, x);
5922 /* Hack -- Activate delay */
5926 /* Hack -- delay anyway for consistency */
5929 /* Delay for consistency */
5930 Term_xtra(TERM_XTRA_DELAY, msec);
5934 if (project_o(caster_ptr, 0, 0, y, x, dam, GF_SUPER_RAY))notice = TRUE;
5935 if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT))
5937 if (second_step)continue;
5941 if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && !second_step)
5943 /* The target of monsterspell becomes tha mirror(broken) */
5944 monster_target_y = y;
5945 monster_target_x = x;
5947 remove_mirror(caster_ptr, y, x);
5948 for (j = 0; j <= i; j++)
5950 y = GRID_Y(path_g[j]);
5951 x = GRID_X(path_g[j]);
5952 (void)project_f(caster_ptr, 0, 0, y, x, dam, GF_SUPER_RAY);
5956 second_step = i + 1;
5957 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x - 1, flg);
5958 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x, flg);
5959 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x + 1, flg);
5960 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x - 1, flg);
5961 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x + 1, flg);
5962 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x - 1, flg);
5963 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x, flg);
5964 path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x + 1, flg);
5968 for (i = 0; i < path_n; i++)
5970 POSITION py = GRID_Y(path_g[i]);
5971 POSITION px = GRID_X(path_g[i]);
5972 (void)project_m(caster_ptr, 0, 0, py, px, dam, GF_SUPER_RAY, flg, TRUE);
5973 if (!who && (project_m_n == 1) && !jump) {
5974 if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0) {
5975 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];
5979 if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
5980 health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
5985 (void)project_f(caster_ptr, 0, 0, py, px, dam, GF_SUPER_RAY);
5991 /* Project along the path */
5992 for (i = 0; i < path_n; ++i)
5997 POSITION ny = GRID_Y(path_g[i]);
5998 POSITION nx = GRID_X(path_g[i]);
6000 if (flg & PROJECT_DISI)
6002 /* Hack -- Balls explode before reaching walls */
6003 if (cave_stop_disintegration(caster_ptr->current_floor_ptr, ny, nx) && (rad > 0)) break;
6005 else if (flg & PROJECT_LOS)
6007 /* Hack -- Balls explode before reaching walls */
6008 if (!cave_los_bold(caster_ptr->current_floor_ptr, ny, nx) && (rad > 0)) break;
6012 /* Hack -- Balls explode before reaching walls */
6013 if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, ny, nx, FF_PROJECT) && (rad > 0)) break;
6020 /* Collect beam grids */
6021 if (flg & (PROJECT_BEAM))
6028 /* Only do visuals if requested */
6029 if (!blind && !(flg & (PROJECT_HIDE | PROJECT_FAST)))
6031 /* Only do visuals if the player can "see" the bolt */
6032 if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
6039 /* Obtain the bolt pict */
6040 p = bolt_pict(oy, ox, y, x, typ);
6042 /* Extract attr/char */
6046 /* Visual effects */
6047 print_rel(caster_ptr, c, a, y, x);
6048 move_cursor_relative(y, x);
6049 /*if (fresh_before)*/ Term_fresh();
6050 Term_xtra(TERM_XTRA_DELAY, msec);
6051 lite_spot(caster_ptr, y, x);
6052 /*if (fresh_before)*/ Term_fresh();
6054 /* Display "beam" grids */
6055 if (flg & (PROJECT_BEAM))
6057 /* Obtain the explosion pict */
6058 p = bolt_pict(y, x, y, x, typ);
6060 /* Extract attr/char */
6064 /* Visual effects */
6065 print_rel(caster_ptr, c, a, y, x);
6068 /* Hack -- Activate delay */
6072 /* Hack -- delay anyway for consistency */
6075 /* Delay for consistency */
6076 Term_xtra(TERM_XTRA_DELAY, msec);
6083 /* Save the "blast epicenter" */
6087 if (breath && !path_n)
6093 flg &= ~(PROJECT_HIDE);
6097 /* Start the "explosion" */
6100 /* Hack -- make sure beams get to "explode" */
6108 /* If we found a "target", explode there */
6109 if (dist <= MAX_RANGE)
6111 /* Mega-Hack -- remove the final "beam" grid */
6112 if ((flg & (PROJECT_BEAM)) && (grids > 0)) grids--;
6115 * Create a conical breath attack
6126 flg &= ~(PROJECT_HIDE);
6128 breath_shape(caster_ptr, path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
6132 /* Determine the blast area, work from the inside out */
6133 for (dist = 0; dist <= rad; dist++)
6135 /* Scan the maximal blast area of radius "dist" */
6136 for (y = by - dist; y <= by + dist; y++)
6138 for (x = bx - dist; x <= bx + dist; x++)
6140 /* Ignore "illegal" locations */
6141 if (!in_bounds2(caster_ptr->current_floor_ptr, y, x)) continue;
6143 /* Enforce a "circular" explosion */
6144 if (distance(by, bx, y, x) != dist) continue;
6150 /* Lights are stopped by opaque terrains */
6151 if (!los(caster_ptr, by, bx, y, x)) continue;
6153 case GF_DISINTEGRATE:
6154 /* Disintegration are stopped only by perma-walls */
6155 if (!in_disintegration_range(caster_ptr->current_floor_ptr, by, bx, y, x)) continue;
6158 /* Ball explosions are stopped by walls */
6159 if (!projectable(caster_ptr, by, bx, y, x)) continue;
6163 /* Save this grid */
6170 /* Encode some more "radius" info */
6171 gm[dist + 1] = grids;
6176 /* Speed -- ignore "non-explosions" */
6177 if (!grids) return FALSE;
6180 /* Display the "blast area" if requested */
6181 if (!blind && !(flg & (PROJECT_HIDE)))
6183 /* Then do the "blast", from inside out */
6184 for (t = 0; t <= gm_rad; t++)
6186 /* Dump everything with this radius */
6187 for (i = gm[t]; i < gm[t + 1]; i++)
6192 /* Only do visuals if the player can "see" the blast */
6193 if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
6202 /* Obtain the explosion pict */
6203 p = bolt_pict(y, x, y, x, typ);
6205 /* Extract attr/char */
6209 /* Visual effects -- Display */
6210 print_rel(caster_ptr, c, a, y, x);
6214 /* Hack -- center the cursor */
6215 move_cursor_relative(by, bx);
6217 /* Flush each "radius" seperately */
6218 /*if (fresh_before)*/ Term_fresh();
6220 /* Delay (efficiently) */
6221 if (visual || drawn)
6223 Term_xtra(TERM_XTRA_DELAY, msec);
6227 /* Flush the erasing */
6230 /* Erase the explosion drawn above */
6231 for (i = 0; i < grids; i++)
6236 /* Hack -- Erase if needed */
6237 if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
6239 lite_spot(caster_ptr, y, x);
6243 /* Hack -- center the cursor */
6244 move_cursor_relative(by, bx);
6246 /* Flush the explosion */
6247 /*if (fresh_before)*/ Term_fresh();
6251 update_creature(caster_ptr);
6253 if (flg & PROJECT_KILL)
6255 see_s_msg = (who > 0) ? is_seen(&caster_ptr->current_floor_ptr->m_list[who]) :
6256 (!who ? TRUE : (player_can_see_bold(caster_ptr, y1, x1) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y1, x1)));
6259 /* Check features */
6260 if (flg & (PROJECT_GRID))
6262 /* Start with "dist" of zero */
6265 /* Scan for features */
6266 for (i = 0; i < grids; i++)
6268 /* Hack -- Notice new "dist" values */
6269 if (gm[dist + 1] == i) dist++;
6271 /* Get the grid location */
6275 /* Find the closest point in the blast */
6278 int d = dist_to_line(y, x, y1, x1, by, bx);
6280 /* Affect the grid */
6281 if (project_f(caster_ptr, who, d, y, x, dam, typ)) notice = TRUE;
6286 /* Affect the grid */
6287 if (project_f(caster_ptr, who, dist, y, x, dam, typ)) notice = TRUE;
6292 update_creature(caster_ptr);
6295 if (flg & (PROJECT_ITEM))
6297 /* Start with "dist" of zero */
6300 /* Scan for objects */
6301 for (i = 0; i < grids; i++)
6303 /* Hack -- Notice new "dist" values */
6304 if (gm[dist + 1] == i) dist++;
6306 /* Get the grid location */
6310 /* Find the closest point in the blast */
6313 int d = dist_to_line(y, x, y1, x1, by, bx);
6315 /* Affect the object in the grid */
6316 if (project_o(caster_ptr, who, d, y, x, dam, typ)) notice = TRUE;
6320 /* Affect the object in the grid */
6321 if (project_o(caster_ptr, who, dist, y, x, dam, typ)) notice = TRUE;
6326 /* Check monsters */
6327 if (flg & (PROJECT_KILL))
6334 /* Start with "dist" of zero */
6337 /* Scan for monsters */
6338 for (i = 0; i < grids; i++)
6342 /* Hack -- Notice new "dist" values */
6343 if (gm[dist + 1] == i) dist++;
6345 /* Get the grid location */
6349 /* A single bolt may be reflected */
6352 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[y][x].m_idx];
6353 monster_race *ref_ptr = &r_info[m_ptr->r_idx];
6355 if ((flg & PROJECT_REFLECTABLE) && caster_ptr->current_floor_ptr->grid_array[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) &&
6356 ((caster_ptr->current_floor_ptr->grid_array[y][x].m_idx != caster_ptr->riding) || !(flg & PROJECT_PLAYER)) &&
6357 (!who || dist_hack > 1) && !one_in_(10))
6360 int max_attempts = 10;
6362 /* Choose 'new' target */
6365 t_y = y_saver - 1 + randint1(3);
6366 t_x = x_saver - 1 + randint1(3);
6368 } while (max_attempts && in_bounds2u(caster_ptr->current_floor_ptr, t_y, t_x) && !projectable(caster_ptr, y, x, t_y, t_x));
6370 if (max_attempts < 1)
6376 sound(SOUND_REFLECT);
6379 if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU))
6380 msg_print(_("「北斗神拳奥義・二指真空把!」", "The attack bounces!"));
6381 else if (m_ptr->r_idx == MON_DIO)
6382 msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", "The attack bounces!"));
6384 msg_print(_("攻撃は跳ね返った!", "The attack bounces!"));
6386 if (is_original_ap_and_seen(caster_ptr, m_ptr)) ref_ptr->r_flags2 |= RF2_REFLECTING;
6388 /* Reflected bolts randomly target either one */
6389 if (player_bold(caster_ptr, y, x) || one_in_(2)) flg &= ~(PROJECT_PLAYER);
6390 else flg |= PROJECT_PLAYER;
6392 /* The bolt is reflected */
6393 project(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
6395 /* Don't affect the monster any longer */
6400 /* Find the closest point in the blast */
6403 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
6407 effective_dist = dist;
6410 /* There is the riding player on this monster */
6411 if (caster_ptr->riding && player_bold(caster_ptr, y, x))
6413 /* Aimed on the player */
6414 if (flg & PROJECT_PLAYER)
6416 if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
6419 * A beam or bolt is well aimed
6421 * So don't affects the mount.
6428 * The spell is not well aimed,
6429 * So partly affect the mount too.
6436 * This grid is the original target.
6437 * Or aimed on your horse.
6439 else if (((y == y2) && (x == x2)) || (flg & PROJECT_AIMED))
6441 /* Hit the mount with full damage */
6445 * Otherwise this grid is not the
6446 * original target, it means that line
6447 * of fire is obstructed by this
6451 * A beam or bolt will hit either
6452 * player or mount. Choose randomly.
6454 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE))
6458 /* Hit the mount with full damage */
6462 /* Hit the player later */
6463 flg |= PROJECT_PLAYER;
6465 /* Don't affect the mount */
6471 * The spell is not well aimed, so
6472 * partly affect both player and
6481 /* Affect the monster in the grid */
6482 if (project_m(caster_ptr, who, effective_dist, y, x, dam, typ, flg, see_s_msg)) notice = TRUE;
6486 /* Player affected one monster (without "jumping") */
6487 if (!who && (project_m_n == 1) && !jump)
6492 /* Track if possible */
6493 if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx > 0)
6495 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[y][x].m_idx];
6499 if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
6500 health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].m_idx);
6507 if (flg & (PROJECT_KILL))
6509 /* Start with "dist" of zero */
6512 /* Scan for player */
6513 for (i = 0; i < grids; i++)
6517 /* Hack -- Notice new "dist" values */
6518 if (gm[dist + 1] == i) dist++;
6520 /* Get the grid location */
6524 /* Affect the player? */
6525 if (!player_bold(caster_ptr, y, x)) continue;
6527 /* Find the closest point in the blast */
6530 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
6534 effective_dist = dist;
6537 /* Target may be your horse */
6538 if (caster_ptr->riding)
6540 /* Aimed on the player */
6541 if (flg & PROJECT_PLAYER)
6543 /* Hit the player with full damage */
6547 * Hack -- When this grid was not the
6548 * original target, a beam or bolt
6549 * would hit either player or mount,
6550 * and should be choosen randomly.
6552 * But already choosen to hit the
6553 * mount at this point.
6555 * Or aimed on your horse.
6557 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
6560 * A beam or bolt is well aimed
6562 * So don't affects the player.
6569 * The spell is not well aimed,
6570 * So partly affect the player too.
6576 /* Affect the player */
6577 if (project_p(who, caster_ptr, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
6581 if (caster_ptr->riding)
6583 GAME_TEXT m_name[MAX_NLEN];
6585 monster_desc(caster_ptr, m_name, &caster_ptr->current_floor_ptr->m_list[caster_ptr->riding], 0);
6587 if (rakubadam_m > 0)
6589 if (rakuba(caster_ptr, rakubadam_m, FALSE))
6591 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
6594 if (caster_ptr->riding && rakubadam_p > 0)
6596 if (rakuba(caster_ptr, rakubadam_p, FALSE))
6598 msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_name);
6603 /* Return "something was noticed" */
6608 * @brief 鏡魔法「封魔結界」の効果処理
6610 * @return 効果があったらTRUEを返す
6612 bool binding_field(player_type *caster_ptr, HIT_POINT dam)
6614 POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
6615 int mirror_num = 0; /* 鏡の数 */
6617 POSITION centersign;
6618 POSITION x1, x2, y1, y2;
6620 int msec = delay_factor * delay_factor*delay_factor;
6623 POSITION point_x[3];
6624 POSITION point_y[3];
6626 /* Default target of monsterspell is player */
6627 monster_target_y = caster_ptr->y;
6628 monster_target_x = caster_ptr->x;
6630 for (x = 0; x < caster_ptr->current_floor_ptr->width; x++)
6632 for (y = 0; y < caster_ptr->current_floor_ptr->height; y++)
6634 if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) &&
6635 distance(caster_ptr->y, caster_ptr->x, y, x) <= MAX_RANGE &&
6636 distance(caster_ptr->y, caster_ptr->x, y, x) != 0 &&
6637 player_has_los_bold(caster_ptr, y, x) &&
6638 projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
6640 mirror_y[mirror_num] = y;
6641 mirror_x[mirror_num] = x;
6647 if (mirror_num < 2)return FALSE;
6649 point_x[0] = randint0(mirror_num);
6651 point_x[1] = randint0(mirror_num);
6652 } while (point_x[0] == point_x[1]);
6654 point_y[0] = mirror_y[point_x[0]];
6655 point_x[0] = mirror_x[point_x[0]];
6656 point_y[1] = mirror_y[point_x[1]];
6657 point_x[1] = mirror_x[point_x[1]];
6658 point_y[2] = caster_ptr->y;
6659 point_x[2] = caster_ptr->x;
6661 x = point_x[0] + point_x[1] + point_x[2];
6662 y = point_y[0] + point_y[1] + point_y[2];
6664 centersign = (point_x[0] * 3 - x)*(point_y[1] * 3 - y)
6665 - (point_y[0] * 3 - y)*(point_x[1] * 3 - x);
6666 if (centersign == 0)return FALSE;
6668 x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
6669 x1 = x1 < point_x[2] ? x1 : point_x[2];
6670 y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
6671 y1 = y1 < point_y[2] ? y1 : point_y[2];
6673 x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
6674 x2 = x2 > point_x[2] ? x2 : point_x[2];
6675 y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
6676 y2 = y2 > point_y[2] ? y2 : point_y[2];
6678 for (y = y1; y <= y2; y++)
6680 for (x = x1; x <= x2; x++)
6682 if (centersign*((point_x[0] - x)*(point_y[1] - y)
6683 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
6684 centersign*((point_x[1] - x)*(point_y[2] - y)
6685 - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
6686 centersign*((point_x[2] - x)*(point_y[0] - y)
6687 - (point_y[2] - y)*(point_x[0] - x)) >= 0)
6689 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
6691 /* Visual effects */
6692 if (!(caster_ptr->blind)
6693 && panel_contains(y, x))
6695 p = bolt_pict(y, x, y, x, GF_MANA);
6696 print_rel(caster_ptr, PICT_C(p), PICT_A(p), y, x);
6697 move_cursor_relative(y, x);
6698 /*if (fresh_before)*/ Term_fresh();
6699 Term_xtra(TERM_XTRA_DELAY, msec);
6706 for (y = y1; y <= y2; y++)
6708 for (x = x1; x <= x2; x++)
6710 if (centersign*((point_x[0] - x)*(point_y[1] - y)
6711 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
6712 centersign*((point_x[1] - x)*(point_y[2] - y)
6713 - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
6714 centersign*((point_x[2] - x)*(point_y[0] - y)
6715 - (point_y[2] - y)*(point_x[0] - x)) >= 0)
6717 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
6719 (void)project_f(caster_ptr, 0, 0, y, x, dam, GF_MANA);
6725 for (y = y1; y <= y2; y++)
6727 for (x = x1; x <= x2; x++)
6729 if (centersign*((point_x[0] - x)*(point_y[1] - y)
6730 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
6731 centersign*((point_x[1] - x)*(point_y[2] - y)
6732 - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
6733 centersign*((point_x[2] - x)*(point_y[0] - y)
6734 - (point_y[2] - y)*(point_x[0] - x)) >= 0)
6736 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
6738 (void)project_o(caster_ptr, 0, 0, y, x, dam, GF_MANA);
6744 for (y = y1; y <= y2; y++)
6746 for (x = x1; x <= x2; x++)
6748 if (centersign*((point_x[0] - x)*(point_y[1] - y)
6749 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
6750 centersign*((point_x[1] - x)*(point_y[2] - y)
6751 - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
6752 centersign*((point_x[2] - x)*(point_y[0] - y)
6753 - (point_y[2] - y)*(point_x[0] - x)) >= 0)
6755 if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
6757 (void)project_m(caster_ptr, 0, 0, y, x, dam, GF_MANA,
6758 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
6766 msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
6767 remove_mirror(caster_ptr, point_y[0], point_x[0]);
6774 * @brief 鏡魔法「鏡の封印」の効果処理
6776 * @return 効果があったらTRUEを返す
6778 void seal_of_mirror(player_type *caster_ptr, HIT_POINT dam)
6780 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++)
6782 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++)
6784 if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
6787 if (!project_m(caster_ptr, 0, 0, y, x, dam, GF_GENOCIDE,
6788 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
6791 if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
6793 remove_mirror(caster_ptr, y, x);
6801 * @brief 領域魔法に応じて技能の名称を返す。
6802 * @param tval 魔法書のtval
6803 * @return 領域魔法の技能名称を保管した文字列ポインタ
6805 concptr spell_category_name(OBJECT_TYPE_VALUE tval)
6809 case TV_HISSATSU_BOOK:
6810 return _("必殺技", "art");
6812 return _("祈り", "prayer");
6814 return _("歌", "song");
6816 return _("呪文", "spell");