1 #include "mspell/mspell-attack/mspell-curse.h"
2 #include "core/disturbance.h"
3 #include "effect/attribute-types.h"
4 #include "effect/effect-processor.h"
5 #include "monster/monster-info.h"
6 #include "monster/monster-list.h"
7 #include "mspell/mspell-checker.h"
8 #include "mspell/mspell-damage-calculator.h"
9 #include "mspell/mspell-data.h"
10 #include "mspell/mspell-result.h"
11 #include "mspell/mspell-util.h"
12 #include "system/floor-type-definition.h"
13 #include "view/display-messages.h"
15 static bool message_curse(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, std::string_view msg1, std::string_view msg2, std::string_view msg3, int target_type)
17 GAME_TEXT m_name[MAX_NLEN], t_name[MAX_NLEN];
18 monster_name(player_ptr, m_idx, m_name);
19 monster_name(player_ptr, t_idx, t_name);
21 if (target_type == MONSTER_TO_PLAYER) {
22 disturb(player_ptr, true, true);
23 if (player_ptr->blind) {
24 msg_format(msg1.data(), m_name);
26 msg_format(msg2.data(), m_name);
28 } else if (target_type == MONSTER_TO_MONSTER) {
29 if (see_monster(player_ptr, m_idx)) {
30 msg_format(msg3.data(), m_name, t_name);
32 player_ptr->current_floor_ptr->monster_noise = true;
38 CurseData::CurseData(const std::string_view &msg1, const std::string_view &msg2, const std::string_view &msg3, const AttributeType &typ)
39 : MSpellData([=](auto *player_ptr, auto m_idx, auto t_idx, int target_type) {
40 return message_curse(player_ptr, m_idx, t_idx, msg1, msg2, msg3, target_type);
46 const std::unordered_map<MonsterAbilityType, CurseData> curse_list = {
47 { MonsterAbilityType::CAUSE_1, { _("%^sが何かをつぶやいた。", "%^s mumbles."),
48 _("%^sがあなたを指さして呪った。", "%^s points at you and curses."), _("%^sは%sを指さして呪いをかけた。", "%^s points at %s and curses."),
49 AttributeType::CAUSE_1 } },
50 { MonsterAbilityType::CAUSE_2, { _("%^sが何かをつぶやいた。", "%^s mumbles."),
51 _("%^sがあなたを指さして恐ろしげに呪った。", "%^s points at you and curses horribly."),
52 _("%^sは%sを指さして恐ろしげに呪いをかけた。", "%^s points at %s and curses horribly."),
53 AttributeType::CAUSE_2 } },
54 { MonsterAbilityType::CAUSE_3, { _("%^sが何かを大声で叫んだ。", "%^s mumbles loudly."),
55 _("%^sがあなたを指さして恐ろしげに呪文を唱えた!", "%^s points at you, incanting terribly!"),
56 _("%^sは%sを指さし、恐ろしげに呪文を唱えた!", "%^s points at %s, incanting terribly!"),
57 AttributeType::CAUSE_3 } },
58 { MonsterAbilityType::CAUSE_4, { _("%^sが「お前は既に死んでいる」と叫んだ。", "%^s screams the word 'DIE!'"),
59 _("%^sがあなたの秘孔を突いて「お前は既に死んでいる」と叫んだ。", "%^s points at you, screaming the word DIE!"),
60 _("%^sが%sの秘孔を突いて、「お前は既に死んでいる」と叫んだ。", "%^s points at %s, screaming the word, 'DIE!'"),
61 AttributeType::CAUSE_4 } },
65 * @brief RF5_CAUSE_* の処理関数
66 * @param player_ptr プレイヤーへの参照ポインタ
67 * @param ms_type 呪文の番号
68 * @param dam 攻撃に使用するダメージ量
71 * @param m_idx 呪文を唱えるモンスターID
72 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
73 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
75 MonsterSpellResult spell_RF5_CAUSE(PlayerType *player_ptr, MonsterAbilityType ms_type, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
77 if (curse_list.find(ms_type) == curse_list.end()) {
78 return MonsterSpellResult::make_invalid();
81 curse_list.at(ms_type).msg.output(player_ptr, m_idx, t_idx, target_type);
83 const auto dam = monspell_damage(player_ptr, ms_type, m_idx, DAM_ROLL);
85 pointed(player_ptr, y, x, m_idx, curse_list.at(ms_type).type, dam, target_type);
87 auto res = MonsterSpellResult::make_valid(dam);
88 res.learnable = target_type == MONSTER_TO_PLAYER;