1 #include "mind/mind-blue-mage.h"
2 #include "action/action-limited.h"
3 #include "avatar/avatar.h"
4 #include "blue-magic/blue-magic-caster.h"
5 #include "blue-magic/learnt-power-getter.h"
6 #include "core/asking-player.h"
7 #include "core/player-redraw-types.h"
8 #include "core/window-redrawer.h"
9 #include "game-option/disturbance-options.h"
10 #include "game-option/input-options.h"
11 #include "main/sound-definitions-table.h"
12 #include "main/sound-of-music.h"
13 #include "monster-race/race-ability-mask.h"
14 #include "mspell/monster-power-table.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 "timed-effect/player-stun.h"
24 #include "timed-effect/timed-effects.h"
25 #include "view/display-messages.h"
28 * @brief 青魔法コマンドのメインルーチン /
29 * do_cmd_cast calls this function if the player's class is 'Blue-Mage'.
30 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
32 bool do_cmd_cast_learned(player_type *player_ptr)
34 if (cmd_limit_confused(player_ptr))
37 auto selected_spell = get_learned_power(player_ptr);
38 if (!selected_spell.has_value()) {
42 const auto &spell = monster_powers.at(selected_spell.value());
43 const auto need_mana = mod_need_mana(player_ptr, spell.smana, 0, REALM_NONE);
44 if (need_mana > player_ptr->csp) {
45 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
49 if (!get_check(_("それでも挑戦しますか? ", "Attempt it anyway? ")))
53 const auto chance = calculate_blue_magic_failure_probability(player_ptr, spell, need_mana);
55 if (randint0(100) < chance) {
59 msg_print(_("魔法をうまく唱えられなかった。", "You failed to concentrate hard enough!"));
61 if (RF_ABILITY_SUMMON_MASK.has(selected_spell.value())) {
62 cast_learned_spell(player_ptr, selected_spell.value(), false);
66 if (!cast_learned_spell(player_ptr, selected_spell.value(), true)) {
71 if (need_mana <= player_ptr->csp) {
72 player_ptr->csp -= need_mana;
76 player_ptr->csp_frac = 0;
77 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
78 (void)BadStatusSetter(player_ptr).mod_paralysis(randint1(5 * oops + 1));
79 chg_virtue(player_ptr, V_KNOWLEDGE, -10);
80 if (randint0(100) < 50) {
81 bool perm = (randint0(100) < 25);
82 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
83 (void)dec_stat(player_ptr, A_CON, 15 + randint1(10), perm);
87 PlayerEnergy(player_ptr).set_player_turn_energy(100);
88 player_ptr->redraw |= PR_MANA;
89 player_ptr->window_flags |= PW_PLAYER | PW_SPELL;