OSDN Git Service

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