OSDN Git Service

[Fix] include漏れを修正
[hengband/hengband.git] / src / mind / mind-blue-mage.c
1 #include "mind/mind-blue-mage.h"
2 #include "action/action-limited.h"
3 #include "blue-magic/blue-magic-caster.h"
4 #include "blue-magic/learnt-power-getter.h"
5 #include "core/asking-player.h"
6 #include "core/player-redraw-types.h"
7 #include "core/window-redrawer.h"
8 #include "game-option/disturbance-options.h"
9 #include "game-option/input-options.h"
10 #include "main/sound-definitions-table.h"
11 #include "main/sound-of-music.h"
12 #include "mspell/monster-power-table.h"
13 #include "mspell/mspell-type.h"
14 #include "player/player-status-table.h"
15 #include "player-info/avatar.h"
16 #include "realm/realm-types.h"
17 #include "spell/spell-info.h"
18 #include "status/bad-status-setter.h"
19 #include "status/base-status.h"
20 #include "term/screen-processor.h"
21 #include "view/display-messages.h"
22
23 /*!
24  * @brief 青魔法コマンドのメインルーチン /
25  * do_cmd_cast calls this function if the player's class is 'Blue-Mage'.
26  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
27  */
28 bool do_cmd_cast_learned(player_type *caster_ptr)
29 {
30     SPELL_IDX n = 0;
31     PERCENTAGE chance;
32     PERCENTAGE minfail = 0;
33     PLAYER_LEVEL plev = caster_ptr->lev;
34     monster_power spell;
35     bool cast;
36     MANA_POINT need_mana;
37
38     if (cmd_limit_confused(caster_ptr))
39         return FALSE;
40
41     if (!get_learned_power(caster_ptr, &n))
42         return FALSE;
43
44     spell = monster_powers[n];
45     need_mana = mod_need_mana(caster_ptr, spell.smana, 0, REALM_NONE);
46     if (need_mana > caster_ptr->csp) {
47         msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
48         if (!over_exert)
49             return FALSE;
50
51         if (!get_check(_("それでも挑戦しますか? ", "Attempt it anyway? ")))
52             return FALSE;
53     }
54
55     chance = spell.fail;
56     if (plev > spell.level)
57         chance -= 3 * (plev - spell.level);
58     else
59         chance += (spell.level - plev);
60
61     chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[A_INT]] - 1);
62     chance = mod_spell_chance_1(caster_ptr, chance);
63     if (need_mana > caster_ptr->csp) {
64         chance += 5 * (need_mana - caster_ptr->csp);
65     }
66
67     minfail = adj_mag_fail[caster_ptr->stat_ind[A_INT]];
68     if (chance < minfail)
69         chance = minfail;
70
71     if (caster_ptr->stun > 50)
72         chance += 25;
73     else if (caster_ptr->stun)
74         chance += 15;
75
76     if (chance > 95)
77         chance = 95;
78
79     chance = mod_spell_chance_2(caster_ptr, chance);
80     if (randint0(100) < chance) {
81         if (flush_failure)
82             flush();
83
84         msg_print(_("魔法をうまく唱えられなかった。", "You failed to concentrate hard enough!"));
85         sound(SOUND_FAIL);
86         if (n >= MS_S_KIN)
87             cast = cast_learned_spell(caster_ptr, n, FALSE);
88     } else {
89         sound(SOUND_ZAP);
90         cast = cast_learned_spell(caster_ptr, n, TRUE);
91         if (!cast)
92             return FALSE;
93     }
94
95     if (need_mana <= caster_ptr->csp) {
96         caster_ptr->csp -= need_mana;
97     } else {
98         int oops = need_mana;
99         caster_ptr->csp = 0;
100         caster_ptr->csp_frac = 0;
101         msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
102         (void)set_paralyzed(caster_ptr, caster_ptr->paralyzed + randint1(5 * oops + 1));
103         chg_virtue(caster_ptr, V_KNOWLEDGE, -10);
104         if (randint0(100) < 50) {
105             bool perm = (randint0(100) < 25);
106             msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
107             (void)dec_stat(caster_ptr, A_CON, 15 + randint1(10), perm);
108         }
109     }
110
111     take_turn(caster_ptr, 100);
112     caster_ptr->redraw |= PR_MANA;
113     caster_ptr->window |= PW_PLAYER | PW_SPELL;
114     return TRUE;
115 }