OSDN Git Service

[Fix] 朱雀の構えによる格闘命中/ダメージ修正が機能していなかった
[hengband/hengband.git] / src / spell-realm / spells-song.c
1 #include "spell-realm/spells-song.h"
2 #include "core/disturbance.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "core/window-redrawer.h"
7 #include "game-option/disturbance-options.h"
8 #include "player/attack-defense-types.h"
9 #include "player/player-skill.h"
10 #include "realm/realm-song-numbers.h"
11 #include "spell/spell-info.h"
12 #include "spell/spells-execution.h"
13 #include "spell/technic-info-table.h"
14 #include "system/floor-type-definition.h"
15 #include "view/display-messages.h"
16
17 /*!
18  * @brief プレイヤーの歌に関する継続処理
19  * @return なし
20  */
21 void check_music(player_type *caster_ptr)
22 {
23     if (caster_ptr->pclass != CLASS_BARD)
24         return;
25     if (!SINGING_SONG_EFFECT(caster_ptr) && !INTERUPTING_SONG_EFFECT(caster_ptr))
26         return;
27
28     if (caster_ptr->anti_magic) {
29         stop_singing(caster_ptr);
30         return;
31     }
32
33     int spell = SINGING_SONG_ID(caster_ptr);
34     const magic_type *s_ptr;
35     s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
36
37     MANA_POINT need_mana = mod_need_mana(caster_ptr, s_ptr->smana, spell, REALM_MUSIC);
38     u32b need_mana_frac = 0;
39
40     s64b_RSHIFT(need_mana, need_mana_frac, 1);
41     if (s64b_cmp(caster_ptr->csp, caster_ptr->csp_frac, need_mana, need_mana_frac) < 0) {
42         stop_singing(caster_ptr);
43         return;
44     } else {
45         s64b_sub(&(caster_ptr->csp), &(caster_ptr->csp_frac), need_mana, need_mana_frac);
46
47         caster_ptr->redraw |= PR_MANA;
48         if (INTERUPTING_SONG_EFFECT(caster_ptr)) {
49             SINGING_SONG_EFFECT(caster_ptr) = INTERUPTING_SONG_EFFECT(caster_ptr);
50             INTERUPTING_SONG_EFFECT(caster_ptr) = MUSIC_NONE;
51             msg_print(_("歌を再開した。", "You restart singing."));
52             caster_ptr->action = ACTION_SING;
53             caster_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
54             caster_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
55             caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
56         }
57     }
58
59     if (caster_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
60         caster_ptr->spell_exp[spell] += 5;
61     else if (caster_ptr->spell_exp[spell] < SPELL_EXP_SKILLED) {
62         if (one_in_(2) && (caster_ptr->current_floor_ptr->dun_level > 4) && ((caster_ptr->current_floor_ptr->dun_level + 10) > caster_ptr->lev))
63             caster_ptr->spell_exp[spell] += 1;
64     } else if (caster_ptr->spell_exp[spell] < SPELL_EXP_EXPERT) {
65         if (one_in_(5) && ((caster_ptr->current_floor_ptr->dun_level + 5) > caster_ptr->lev)
66             && ((caster_ptr->current_floor_ptr->dun_level + 5) > s_ptr->slevel))
67             caster_ptr->spell_exp[spell] += 1;
68     } else if (caster_ptr->spell_exp[spell] < SPELL_EXP_MASTER) {
69         if (one_in_(5) && ((caster_ptr->current_floor_ptr->dun_level + 5) > caster_ptr->lev) && (caster_ptr->current_floor_ptr->dun_level > s_ptr->slevel))
70             caster_ptr->spell_exp[spell] += 1;
71     }
72
73     exe_spell(caster_ptr, REALM_MUSIC, spell, SPELL_CONT);
74 }
75
76 /*!
77  * @brief 隠遁の歌の継続時間をセットする / Set "tim_stealth", notice observable changes
78  * @param v 継続時間
79  * @param do_dec 現在の継続時間より長い値のみ上書きする
80  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
81  */
82 bool set_tim_stealth(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
83 {
84     bool notice = FALSE;
85     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
86
87     if (creature_ptr->is_dead)
88         return FALSE;
89
90     if (v) {
91         if (creature_ptr->tim_stealth && !do_dec) {
92             if (creature_ptr->tim_stealth > v)
93                 return FALSE;
94         } else if (!is_time_limit_stealth(creature_ptr)) {
95             msg_print(_("足音が小さくなった!", "You begin to walk silently!"));
96             notice = TRUE;
97         }
98     } else {
99         if (creature_ptr->tim_stealth && !music_singing(creature_ptr, MUSIC_STEALTH)) {
100             msg_print(_("足音が大きくなった。", "You no longer walk silently."));
101             notice = TRUE;
102         }
103     }
104
105     creature_ptr->tim_stealth = v;
106     creature_ptr->redraw |= (PR_STATUS);
107
108     if (!notice)
109         return FALSE;
110
111     if (disturb_state)
112         disturb(creature_ptr, FALSE, FALSE);
113     creature_ptr->update |= (PU_BONUS);
114     handle_stuff(creature_ptr);
115     return TRUE;
116 }