OSDN Git Service

[Refactor] #3397 mind-elementalist.cpp で、element_powers を調整してコピーではなく参照で受けるようにした
[hengbandforosx/hengbandosx.git] / src / mind / mind-warrior.cpp
1 #include "mind/mind-warrior.h"
2 #include "cmd-action/cmd-attack.h"
3 #include "floor/geometry.h"
4 #include "spell-kind/spells-teleport.h"
5 #include "system/floor-type-definition.h"
6 #include "system/grid-type-definition.h"
7 #include "system/player-type-definition.h"
8 #include "target/target-getter.h"
9 #include "view/display-messages.h"
10
11 /*!
12  * 戦士と盗賊における、ヒット&アウェイのレイシャルパワー/突然変異
13  * @param player_ptr プレイヤーへの参照ポインタ
14  * @return コマンドの入力先にモンスターがいたらTRUE
15  */
16 bool hit_and_away(PlayerType *player_ptr)
17 {
18     DIRECTION dir;
19     if (!get_direction(player_ptr, &dir, false, false)) {
20         return false;
21     }
22     POSITION y = player_ptr->y + ddy[dir];
23     POSITION x = player_ptr->x + ddx[dir];
24     if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
25         do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
26         if (randint0(player_ptr->skill_dis) < 7) {
27             msg_print(_("うまく逃げられなかった。", "You failed to run away."));
28         } else {
29             teleport_player(player_ptr, 30, TELEPORT_SPONTANEOUS);
30         }
31         return true;
32     }
33
34     msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
35     msg_print(nullptr);
36     return false;
37 }
38
39 /*!
40  * 剣の舞い
41  * @param player_ptr プレイヤーへの参照ポインタ
42  * @return 常にTRUE
43  */
44 bool sword_dancing(PlayerType *player_ptr)
45 {
46     DIRECTION dir;
47     POSITION y = 0, x = 0;
48     grid_type *g_ptr;
49     for (int i = 0; i < 6; i++) {
50         dir = randint0(8);
51         y = player_ptr->y + ddy_ddd[dir];
52         x = player_ptr->x + ddx_ddd[dir];
53         g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
54
55         /* Hack -- attack monsters */
56         if (g_ptr->m_idx) {
57             do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
58         } else {
59             msg_print(_("攻撃が空をきった。", "You attack the empty air."));
60         }
61     }
62
63     return true;
64 }