2 * @brief フロアの一定範囲に効果を及ぼす (悲鳴、テレポート等)スペルの効果
7 #include "mspell/mspell-floor.h"
8 #include "blue-magic/blue-magic-checker.h"
9 #include "core/disturbance.h"
10 #include "core/player-update-types.h"
11 #include "effect/attribute-types.h"
12 #include "effect/effect-characteristics.h"
13 #include "effect/effect-processor.h"
14 #include "mind/drs-types.h"
15 #include "monster-race/monster-race.h"
16 #include "monster-race/race-ability-flags.h"
17 #include "monster-race/race-flags-resistance.h"
18 #include "monster-race/race-flags1.h"
19 #include "monster-race/race-flags3.h"
20 #include "monster-race/race-flags7.h"
21 #include "monster-race/race-indice-types.h"
22 #include "monster-race/race-resistance-mask.h"
23 #include "monster/monster-info.h"
24 #include "monster/monster-status-setter.h"
25 #include "monster/monster-status.h"
26 #include "monster/monster-update.h"
27 #include "mspell/mspell-result.h"
28 #include "mspell/mspell-status.h"
29 #include "mspell/mspell-util.h"
30 #include "player-base/player-class.h"
31 #include "player/player-personality-types.h"
32 #include "player/player-status-flags.h"
33 #include "player/player-status.h"
34 #include "spell-kind/spells-lite.h"
35 #include "spell-kind/spells-neighbor.h"
36 #include "spell-kind/spells-sight.h"
37 #include "spell-kind/spells-teleport.h"
38 #include "spell-kind/spells-world.h"
39 #include "spell-realm/spells-hex.h"
40 #include "system/floor-type-definition.h"
41 #include "system/monster-race-definition.h"
42 #include "system/monster-type-definition.h"
43 #include "system/player-type-definition.h"
44 #include "util/bit-flags-calculator.h"
45 #include "view/display-messages.h"
48 * @brief RF4_SHRIEKの処理。叫び。 /
49 * @param m_idx 呪文を唱えるモンスターID
50 * @param player_ptr プレイヤーへの参照ポインタ
51 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
52 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
56 MonsterSpellResult spell_RF4_SHRIEK(MONSTER_IDX m_idx, PlayerType *player_ptr, MONSTER_IDX t_idx, int target_type)
58 mspell_cast_msg_simple msg(_("%^sがかん高い金切り声をあげた。", "%^s makes a high pitched shriek."),
59 _("%^sが%sに向かって叫んだ。", "%^s shrieks at %s."));
61 simple_monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
63 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
64 auto result = MonsterSpellResult::make_valid();
65 if (m_ptr->r_idx == MonsterRaceId::LEE_QIEZI) {
66 msg_print(_("しかし、その声は誰の心にも響かなかった…。", "However, that voice didn't touch anyone's heart..."));
70 if (target_type == MONSTER_TO_PLAYER) {
71 aggravate_monsters(player_ptr, m_idx);
72 } else if (target_type == MONSTER_TO_MONSTER) {
73 set_monster_csleep(player_ptr, t_idx, 0);
80 * @brief RF6_WORLDの処理。時を止める。 /
81 * @param player_ptr プレイヤーへの参照ポインタ
82 * @param m_idx 呪文を唱えるモンスターID
86 MonsterSpellResult spell_RF6_WORLD(PlayerType *player_ptr, MONSTER_IDX m_idx)
88 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
89 GAME_TEXT m_name[MAX_NLEN];
90 monster_name(player_ptr, m_idx, m_name);
91 disturb(player_ptr, true, true);
92 (void)set_monster_timewalk(player_ptr, randint1(2) + 2, m_ptr->r_idx, true);
94 return MonsterSpellResult::make_valid();
98 * @brief RF6_BLINKの処理。ショート・テレポート。 /
99 * @param player_ptr プレイヤーへの参照ポインタ
100 * @param m_idx 呪文を唱えるモンスターID
101 * @param is_quantum_effect 量子的効果によるショート・テレポートの場合時TRUE
102 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
106 MonsterSpellResult spell_RF6_BLINK(PlayerType *player_ptr, MONSTER_IDX m_idx, int target_type, bool is_quantum_effect)
108 const auto res = MonsterSpellResult::make_valid();
110 GAME_TEXT m_name[MAX_NLEN];
111 monster_name(player_ptr, m_idx, m_name);
113 if (target_type == MONSTER_TO_PLAYER) {
114 disturb(player_ptr, true, true);
117 if (!is_quantum_effect && SpellHex(player_ptr).check_hex_barrier(m_idx, HEX_ANTI_TELE)) {
118 if (see_monster(player_ptr, m_idx)) {
119 msg_format(_("魔法のバリアが%^sのテレポートを邪魔した。", "Magic barrier obstructs teleporting of %^s."), m_name);
124 if (see_monster(player_ptr, m_idx)) {
125 msg_format(_("%^sが瞬時に消えた。", "%^s blinks away."), m_name);
128 teleport_away(player_ptr, m_idx, 10, TELEPORT_SPONTANEOUS);
130 if (target_type == MONSTER_TO_PLAYER) {
131 player_ptr->update |= (PU_MONSTERS);
138 * @brief RF6_TPORTの処理。テレポート。 /
139 * @param player_ptr プレイヤーへの参照ポインタ
140 * @param m_idx 呪文を唱えるモンスターID
141 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
145 MonsterSpellResult spell_RF6_TPORT(PlayerType *player_ptr, MONSTER_IDX m_idx, int target_type)
147 const auto res = MonsterSpellResult::make_valid();
149 GAME_TEXT m_name[MAX_NLEN];
150 monster_name(player_ptr, m_idx, m_name);
152 if (target_type == MONSTER_TO_PLAYER) {
153 disturb(player_ptr, true, true);
155 if (SpellHex(player_ptr).check_hex_barrier(m_idx, HEX_ANTI_TELE)) {
156 if (see_monster(player_ptr, m_idx)) {
157 msg_format(_("魔法のバリアが%^sのテレポートを邪魔した。", "Magic barrier obstructs teleporting of %^s."), m_name);
162 if (see_monster(player_ptr, m_idx)) {
163 msg_format(_("%^sがテレポートした。", "%^s teleports away."), m_name);
166 teleport_away_followable(player_ptr, m_idx);
172 * @brief RF6_TELE_TOの処理。テレポート・バック。 /
173 * @param player_ptr プレイヤーへの参照ポインタ
174 * @param m_idx 呪文を唱えるモンスターID
175 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
176 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
180 MonsterSpellResult spell_RF6_TELE_TO(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
182 auto res = MonsterSpellResult::make_valid();
183 res.learnable = target_type == MONSTER_TO_PLAYER;
185 auto *floor_ptr = player_ptr->current_floor_ptr;
186 auto *m_ptr = &floor_ptr->m_list[m_idx];
187 monster_type *t_ptr = &floor_ptr->m_list[t_idx];
188 monster_race *tr_ptr = &r_info[t_ptr->r_idx];
190 mspell_cast_msg_simple msg(_("%^sがあなたを引き戻した。", "%^s commands you to return."),
191 _("%^sが%sを引き戻した。", "%^s commands %s to return."));
193 simple_monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
195 if (target_type == MONSTER_TO_PLAYER) {
196 teleport_player_to(player_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
200 if (target_type != MONSTER_TO_MONSTER) {
204 bool resists_tele = false;
205 GAME_TEXT t_name[MAX_NLEN];
206 monster_name(player_ptr, t_idx, t_name);
208 if (tr_ptr->resistance_flags.has(MonsterResistanceType::RESIST_TELEPORT)) {
209 if (tr_ptr->kind_flags.has(MonsterKindType::UNIQUE) || tr_ptr->resistance_flags.has(MonsterResistanceType::RESIST_ALL)) {
210 if (is_original_ap_and_seen(player_ptr, t_ptr)) {
211 tr_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
213 if (see_monster(player_ptr, t_idx)) {
214 msg_format(_("%^sには効果がなかった。", "%^s is unaffected!"), t_name);
217 } else if (tr_ptr->level > randint1(100)) {
218 if (is_original_ap_and_seen(player_ptr, t_ptr)) {
219 tr_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
221 if (see_monster(player_ptr, t_idx)) {
222 msg_format(_("%^sは耐性を持っている!", "%^s resists!"), t_name);
229 set_monster_csleep(player_ptr, t_idx, 0);
233 if (t_idx == player_ptr->riding) {
234 teleport_player_to(player_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
236 teleport_monster_to(player_ptr, t_idx, m_ptr->fy, m_ptr->fx, 100, TELEPORT_PASSIVE);
238 set_monster_csleep(player_ptr, t_idx, 0);
244 * @brief RF6_TELE_AWAYの処理。テレポート・アウェイ。 /
245 * @param player_ptr プレイヤーへの参照ポインタ
246 * @param m_idx 呪文を唱えるモンスターID
247 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
248 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
252 MonsterSpellResult spell_RF6_TELE_AWAY(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
254 auto res = MonsterSpellResult::make_valid();
255 res.learnable = target_type == MONSTER_TO_PLAYER;
257 auto *floor_ptr = player_ptr->current_floor_ptr;
258 monster_type *t_ptr = &floor_ptr->m_list[t_idx];
259 monster_race *tr_ptr = &r_info[t_ptr->r_idx];
261 mspell_cast_msg_simple msg(_("%^sにテレポートさせられた。", "%^s teleports you away."),
262 _("%^sは%sをテレポートさせた。", "%^s teleports %s away."));
264 simple_monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
266 if (target_type == MONSTER_TO_PLAYER) {
267 if (is_echizen(player_ptr)) {
268 msg_print(_("くっそ~", ""));
269 } else if (is_chargeman(player_ptr)) {
270 if (randint0(2) == 0) {
271 msg_print(_("ジュラル星人め!", ""));
273 msg_print(_("弱い者いじめは止めるんだ!", ""));
277 teleport_player_away(m_idx, player_ptr, 100, false);
281 if (target_type != MONSTER_TO_MONSTER) {
285 bool resists_tele = false;
286 GAME_TEXT t_name[MAX_NLEN];
287 monster_name(player_ptr, t_idx, t_name);
289 if (tr_ptr->resistance_flags.has(MonsterResistanceType::RESIST_TELEPORT)) {
290 if (tr_ptr->kind_flags.has(MonsterKindType::UNIQUE) || tr_ptr->resistance_flags.has(MonsterResistanceType::RESIST_ALL)) {
291 if (is_original_ap_and_seen(player_ptr, t_ptr)) {
292 tr_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
294 if (see_monster(player_ptr, t_idx)) {
295 msg_format(_("%^sには効果がなかった。", "%^s is unaffected!"), t_name);
298 } else if (tr_ptr->level > randint1(100)) {
299 if (is_original_ap_and_seen(player_ptr, t_ptr)) {
300 tr_ptr->r_resistance_flags.set(MonsterResistanceType::RESIST_TELEPORT);
302 if (see_monster(player_ptr, t_idx)) {
303 msg_format(_("%^sは耐性を持っている!", "%^s resists!"), t_name);
310 set_monster_csleep(player_ptr, t_idx, 0);
314 if (t_idx == player_ptr->riding) {
315 teleport_player_away(m_idx, player_ptr, MAX_SIGHT * 2 + 5, false);
317 teleport_away(player_ptr, t_idx, MAX_SIGHT * 2 + 5, TELEPORT_PASSIVE);
319 set_monster_csleep(player_ptr, t_idx, 0);
325 * @brief RF6_TELE_LEVELの処理。テレポート・レベル。 /
326 * @param player_ptr プレイヤーへの参照ポインタ
327 * @param m_idx 呪文を唱えるモンスターID
328 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
329 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
333 MonsterSpellResult spell_RF6_TELE_LEVEL(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
335 const auto res = MonsterSpellResult::make_valid();
337 auto *floor_ptr = player_ptr->current_floor_ptr;
338 monster_type *t_ptr = &floor_ptr->m_list[t_idx];
339 monster_race *tr_ptr = &r_info[t_ptr->r_idx];
340 DEPTH rlev = monster_level_idx(floor_ptr, m_idx);
341 bool resist, saving_throw;
343 if (target_type == MONSTER_TO_PLAYER) {
344 resist = (has_resist_nexus(player_ptr) != 0);
345 saving_throw = (randint0(100 + rlev / 2) < player_ptr->skill_sav);
347 mspell_cast_msg_bad_status_to_player msg(_("%^sが何か奇妙な言葉をつぶやいた。", "%^s mumbles strangely."),
348 _("%^sがあなたの足を指さした。", "%^s gestures at your feet."), _("しかし効果がなかった!", "You are unaffected!"),
349 _("しかし効力を跳ね返した!", "You resist the effects!"));
351 spell_badstatus_message_to_player(player_ptr, m_idx, msg, resist, saving_throw);
353 if (!resist && !saving_throw) {
354 teleport_level(player_ptr, 0);
357 update_smart_learn(player_ptr, m_idx, DRS_NEXUS);
361 if (target_type != MONSTER_TO_MONSTER) {
365 resist = tr_ptr->resistance_flags.has_any_of(RFR_EFF_RESIST_NEXUS_MASK) || tr_ptr->resistance_flags.has(MonsterResistanceType::RESIST_TELEPORT);
366 saving_throw = (tr_ptr->flags1 & RF1_QUESTOR) || (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10);
368 mspell_cast_msg_bad_status_to_monster msg(_("%^sが%sの足を指さした。", "%^s gestures at %s's feet."),
369 _("%^sには効果がなかった。", "%^s is unaffected!"), _("%^sは効力を跳ね返した!", "%^s resist the effects!"), "");
371 spell_badstatus_message_to_mons(player_ptr, m_idx, t_idx, msg, resist, saving_throw);
373 if (!resist && !saving_throw) {
374 teleport_level(player_ptr, (t_idx == player_ptr->riding) ? 0 : t_idx);
381 * @brief RF6_DARKNESSの処理。暗闇or閃光。 /
382 * @param target_type プレイヤーへの参照ポインタ
385 * @param m_idx 呪文を唱えるモンスターID
386 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
387 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
389 * プレイヤーが対象かつ暗闇ならラーニング可。
391 MonsterSpellResult spell_RF6_DARKNESS(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
393 mspell_cast_msg_blind msg;
395 auto *floor_ptr = player_ptr->current_floor_ptr;
396 auto *m_ptr = &floor_ptr->m_list[m_idx];
397 monster_type *t_ptr = &floor_ptr->m_list[t_idx];
398 auto *r_ptr = &r_info[m_ptr->r_idx];
399 bool can_use_lite_area = false;
400 bool monster_to_monster = target_type == MONSTER_TO_MONSTER;
401 bool monster_to_player = target_type == MONSTER_TO_PLAYER;
402 GAME_TEXT t_name[MAX_NLEN];
403 monster_name(player_ptr, t_idx, t_name);
405 if (PlayerClass(player_ptr).equals(PlayerClassType::NINJA) && r_ptr->kind_flags.has_not(MonsterKindType::UNDEAD) && r_ptr->resistance_flags.has_not(MonsterResistanceType::HURT_LITE) && !(r_ptr->flags7 & RF7_DARK_MASK)) {
406 can_use_lite_area = true;
409 if (monster_to_monster && !is_hostile(t_ptr)) {
410 can_use_lite_area = false;
413 auto res = MonsterSpellResult::make_valid();
414 res.learnable = monster_to_player && !can_use_lite_area;
416 if (can_use_lite_area) {
417 msg.blind = _("%^sが何かをつぶやいた。", "%^s mumbles.");
418 msg.to_player = _("%^sが辺りを明るく照らした。", "%^s cast a spell to light up.");
419 msg.to_mons = _("%^sが辺りを明るく照らした。", "%^s cast a spell to light up.");
421 msg_done = _("%^sは白い光に包まれた。", "%^s is surrounded by a white light.");
423 msg.blind = _("%^sが何かをつぶやいた。", "%^s mumbles.");
424 msg.to_player = _("%^sが暗闇の中で手を振った。", "%^s gestures in shadow.");
425 msg.to_mons = _("%^sが暗闇の中で手を振った。", "%^s gestures in shadow.");
427 msg_done = _("%^sは暗闇に包まれた。", "%^s is surrounded by darkness.");
430 monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
432 if (see_monster(player_ptr, t_idx) && monster_to_monster) {
433 msg_format(msg_done, t_name);
436 if (monster_to_player) {
437 if (can_use_lite_area) {
438 (void)lite_area(player_ptr, 0, 3);
440 (void)unlite_area(player_ptr, 0, 3);
442 } else if (monster_to_monster) {
443 if (can_use_lite_area) {
444 (void)project(player_ptr, m_idx, 3, y, x, 0, AttributeType::LITE_WEAK, PROJECT_GRID | PROJECT_KILL);
445 lite_room(player_ptr, y, x);
447 (void)project(player_ptr, m_idx, 3, y, x, 0, AttributeType::DARK_WEAK, PROJECT_GRID | PROJECT_KILL);
448 unlite_room(player_ptr, y, x);
456 * @brief RF6_TRAPSの処理。トラップ。 /
457 * @param player_ptr プレイヤーへの参照ポインタ
460 * @param m_idx 呪文を唱えるモンスターID
464 MonsterSpellResult spell_RF6_TRAPS(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx)
466 GAME_TEXT m_name[MAX_NLEN];
467 monster_name(player_ptr, m_idx, m_name);
468 disturb(player_ptr, true, true);
470 if (player_ptr->blind) {
471 msg_format(_("%^sが何かをつぶやいて邪悪に微笑んだ。", "%^s mumbles, and then cackles evilly."), m_name);
473 msg_format(_("%^sが呪文を唱えて邪悪に微笑んだ。", "%^s casts a spell and cackles evilly."), m_name);
476 (void)trap_creation(player_ptr, y, x);
478 auto res = MonsterSpellResult::make_valid();
479 res.learnable = true;
485 * @brief RF6_RAISE_DEADの処理。死者復活。 /
486 * @param player_ptr プレイヤーへの参照ポインタ
487 * @param m_idx 呪文を唱えるモンスターID
488 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
489 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
493 MonsterSpellResult spell_RF6_RAISE_DEAD(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
495 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
496 mspell_cast_msg_blind msg(_("%^sが何かをつぶやいた。", "%^s mumbles."),
497 _("%^sが死者復活の呪文を唱えた。", "%^s casts a spell to revive corpses."), _("%^sが死者復活の呪文を唱えた。", "%^s casts a spell to revive corpses."));
499 monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
501 animate_dead(player_ptr, m_idx, m_ptr->fy, m_ptr->fx);
503 return MonsterSpellResult::make_valid();