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 "monster-race/race-ability-mask.h"
13 #include "mspell/monster-power-table.h"
14 #include "player-info/avatar.h"
15 #include "player-status/player-energy.h"
16 #include "player/player-status-table.h"
17 #include "realm/realm-types.h"
18 #include "spell/spell-info.h"
19 #include "status/bad-status-setter.h"
20 #include "status/base-status.h"
21 #include "system/player-type-definition.h"
22 #include "term/screen-processor.h"
23 #include "view/display-messages.h"
26 * @brief 青魔法コマンドのメインルーチン /
27 * do_cmd_cast calls this function if the player's class is 'Blue-Mage'.
28 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
30 bool do_cmd_cast_learned(player_type *caster_ptr)
34 PERCENTAGE minfail = 0;
35 PLAYER_LEVEL plev = caster_ptr->lev;
40 if (cmd_limit_confused(caster_ptr))
43 if (!get_learned_power(caster_ptr, &n))
46 spell = monster_powers[n];
47 need_mana = mod_need_mana(caster_ptr, spell.smana, 0, REALM_NONE);
48 if (need_mana > caster_ptr->csp) {
49 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
53 if (!get_check(_("それでも挑戦しますか? ", "Attempt it anyway? ")))
58 if (plev > spell.level)
59 chance -= 3 * (plev - spell.level);
61 chance += (spell.level - plev);
63 chance -= 3 * (adj_mag_stat[caster_ptr->stat_index[A_INT]] - 1);
64 chance = mod_spell_chance_1(caster_ptr, chance);
65 if (need_mana > caster_ptr->csp) {
66 chance += 5 * (need_mana - caster_ptr->csp);
69 minfail = adj_mag_fail[caster_ptr->stat_index[A_INT]];
73 if (caster_ptr->stun > 50)
75 else if (caster_ptr->stun)
81 chance = mod_spell_chance_2(caster_ptr, chance);
82 const auto spell_type = static_cast<RF_ABILITY>(n);
83 if (randint0(100) < chance) {
87 msg_print(_("魔法をうまく唱えられなかった。", "You failed to concentrate hard enough!"));
89 if (RF_ABILITY_SUMMON_MASK.has(spell_type))
90 cast = cast_learned_spell(caster_ptr, spell_type, FALSE);
93 cast = cast_learned_spell(caster_ptr, spell_type, TRUE);
98 if (need_mana <= caster_ptr->csp) {
99 caster_ptr->csp -= need_mana;
101 int oops = need_mana;
103 caster_ptr->csp_frac = 0;
104 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
105 (void)set_paralyzed(caster_ptr, caster_ptr->paralyzed + randint1(5 * oops + 1));
106 chg_virtue(caster_ptr, V_KNOWLEDGE, -10);
107 if (randint0(100) < 50) {
108 bool perm = (randint0(100) < 25);
109 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
110 (void)dec_stat(caster_ptr, A_CON, 15 + randint1(10), perm);
114 PlayerEnergy(caster_ptr).set_player_turn_energy(100);
115 caster_ptr->redraw |= PR_MANA;
116 caster_ptr->window_flags |= PW_PLAYER | PW_SPELL;