OSDN Git Service

[Refactor] #40573 Separated mind-berserker.c/h from mind-switcher.c
[hengband/hengband.git] / src / mind / mind-berserker.c
1 #include "mind/mind-berserker.h"
2 #include "action/movement-execution.h"
3 #include "cmd-action/cmd-attack.h"
4 #include "floor/geometry.h"
5 #include "game-option/input-options.h"
6 #include "grid/feature.h"
7 #include "grid/grid.h"
8 #include "player-attack/player-attack.h"
9 #include "player/player-move.h"
10 #include "spell-kind/earthquake.h"
11 #include "system/floor-type-definition.h"
12 #include "spell-kind/spells-detection.h"
13 #include "target/target-getter.h"
14 #include "view/display-messages.h"
15
16 /*!
17  * @brief 怒りの発動 /
18  * do_cmd_cast calls this function if the player's class is 'berserker'.
19  * @param spell 発動する特殊技能のID
20  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
21  */
22 bool cast_berserk_spell(player_type *caster_ptr, int spell)
23 {
24     POSITION y, x;
25     DIRECTION dir;
26
27     // todo enum化する!
28     switch (spell) {
29     case 0:
30         detect_monsters_mind(caster_ptr, DETECT_RAD_DEFAULT);
31         break;
32     case 1: {
33         if (caster_ptr->riding) {
34             msg_print(_("乗馬中には無理だ。", "You cannot do it when riding."));
35             return FALSE;
36         }
37
38         if (!get_direction(caster_ptr, &dir, FALSE, FALSE) || (dir == 5))
39             return FALSE;
40
41         y = caster_ptr->y + ddy[dir];
42         x = caster_ptr->x + ddx[dir];
43         if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
44             msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
45             return FALSE;
46         }
47
48         do_cmd_attack(caster_ptr, y, x, 0);
49         if (!player_can_enter(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat, 0)
50             || is_trap(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat))
51             break;
52
53         y += ddy[dir];
54         x += ddx[dir];
55         if (player_can_enter(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat, 0)
56             && !is_trap(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].feat) && !caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
57             msg_print(NULL);
58             (void)move_player_effect(caster_ptr, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
59         }
60
61         break;
62     }
63     case 2: {
64         if (!get_direction(caster_ptr, &dir, FALSE, FALSE))
65             return FALSE;
66
67         y = caster_ptr->y + ddy[dir];
68         x = caster_ptr->x + ddx[dir];
69         exe_movement(caster_ptr, dir, easy_disarm, TRUE);
70         break;
71     }
72     case 3:
73         earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 8 + randint0(5), 0);
74         break;
75     case 4:
76         massacre(caster_ptr);
77         break;
78     default:
79         msg_print(_("なに?", "Zap?"));
80         break;
81     }
82
83     return TRUE;
84 }