OSDN Git Service

Merge pull request #3532 from sikabane-works/release/3.0.0.87-alpha
[hengbandforosx/hengbandosx.git] / src / racial / racial-vampire.cpp
1 #include "racial/racial-vampire.h"
2 #include "dungeon/dungeon-flag-types.h"
3 #include "floor/geometry.h"
4 #include "hpmp/hp-mp-processor.h"
5 #include "player/digestion-processor.h"
6 #include "player/player-status.h"
7 #include "spell-kind/spells-specific-bolt.h"
8 #include "system/dungeon-info.h"
9 #include "system/floor-type-definition.h"
10 #include "system/grid-type-definition.h"
11 #include "system/player-type-definition.h"
12 #include "target/target-getter.h"
13 #include "view/display-messages.h"
14
15 bool vampirism(PlayerType *player_ptr)
16 {
17     const auto &floor = *player_ptr->current_floor_ptr;
18     if (floor.get_dungeon_definition().flags.has(DungeonFeatureType::NO_MELEE)) {
19         msg_print(_("なぜか攻撃することができない。", "Something prevents you from attacking."));
20         return false;
21     }
22
23     DIRECTION dir;
24     if (!get_direction(player_ptr, &dir)) {
25         return false;
26     }
27
28     POSITION y = player_ptr->y + ddy[dir];
29     POSITION x = player_ptr->x + ddx[dir];
30     const auto *g_ptr = &floor.grid_array[y][x];
31     stop_mouth(player_ptr);
32     if (!(g_ptr->m_idx)) {
33         msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
34         return false;
35     }
36
37     msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs..."));
38
39     int dummy = player_ptr->lev * 2;
40     if (!hypodynamic_bolt(player_ptr, dir, dummy)) {
41         msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul."));
42         return true;
43     }
44
45     if (player_ptr->food < PY_FOOD_FULL) {
46         (void)hp_player(player_ptr, dummy);
47     } else {
48         msg_print(_("あなたは空腹ではありません。", "You were not hungry."));
49     }
50
51     /* Gain nutritional sustenance: 150/hp drained */
52     /* A Food ration gives 5000 food points (by contrast) */
53     /* Don't ever get more than "Full" this way */
54     /* But if we ARE Gorged,  it won't cure us */
55     dummy = player_ptr->food + std::min(5000, 100 * dummy);
56     if (player_ptr->food < PY_FOOD_MAX) { /* Not gorged already */
57         (void)set_food(player_ptr, dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
58     }
59
60     return true;
61 }