From: Deskull Date: Fri, 28 Sep 2018 12:06:18 +0000 (+0900) Subject: [Refactor] #37353 吸血処理をvampirism()にまとめる。 X-Git-Url: http://git.osdn.net/view?p=hengband%2Fhengband.git;a=commitdiff_plain;h=7daf0016d9b527052fdcf79ccad360872b9de35d [Refactor] #37353 吸血処理をvampirism()にまとめる。 Integrate some processes to vampirism(). --- diff --git a/src/externs.h b/src/externs.h index 62dccc274..fba7bd66f 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1181,6 +1181,7 @@ extern bool_hack true_healing(HIT_POINT pow); extern bool_hack restore_mana(bool_hack magic_eater); extern bool restore_all_status(void); extern void stop_mouth(void); +extern bool_hack vampirism(void); /* spells3.c */ extern bool teleport_away(MONSTER_IDX m_idx, int dis, BIT_FLAGS mode); diff --git a/src/mutation.c b/src/mutation.c index d65127da0..7c3ec4910 100644 --- a/src/mutation.c +++ b/src/mutation.c @@ -2147,50 +2147,7 @@ bool mutation_power_aux(u32b power) break; case MUT1_VAMPIRISM: - { - int x, y, dummy; - cave_type *c_ptr; - - /* Only works on adjacent monsters */ - if (!get_rep_dir2(&dir)) return FALSE; - y = p_ptr->y + ddy[dir]; - x = p_ptr->x + ddx[dir]; - c_ptr = &cave[y][x]; - - stop_mouth(); - - if (!(c_ptr->m_idx)) - { - msg_print(_("何もない場所に噛みついた!", "You bite into thin air!")); - - break; - } - - msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs...")); - - - dummy = lvl * 2; - - if (hypodynamic_bolt(dir, dummy)) - { - if (p_ptr->food < PY_FOOD_FULL) - /* No heal if we are "full" */ - (void)hp_player(dummy); - else - msg_print(_("あなたは空腹ではありません。", "You were not hungry.")); - - /* Gain nutritional sustenance: 150/hp drained */ - /* A Food ration gives 5000 food points (by contrast) */ - /* Don't ever get more than "Full" this way */ - /* But if we ARE Gorged, it won't cure us */ - dummy = p_ptr->food + MIN(5000, 100 * dummy); - if (p_ptr->food < PY_FOOD_MAX) /* Not gorged already */ - (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX-1 : dummy); - } - else - msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul.")); - - } + vampirism(); break; case MUT1_SMELL_MET: diff --git a/src/racial.c b/src/racial.c index 88b211c7c..7b42f4546 100644 --- a/src/racial.c +++ b/src/racial.c @@ -1218,51 +1218,7 @@ static bool cmd_racial_power_aux(s32b command) break; } case MIMIC_VAMPIRE: - if (d_info[dungeon_type].flags1 & DF1_NO_MELEE) - { - msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking.")); - return FALSE; - } - else - { - int y, x, dummy = 0; - cave_type *c_ptr; - - /* Only works on adjacent monsters */ - if (!get_rep_dir(&dir, FALSE)) return FALSE; /* was get_aim_dir */ - y = p_ptr->y + ddy[dir]; - x = p_ptr->x + ddx[dir]; - c_ptr = &cave[y][x]; - - stop_mouth(); - - if (!c_ptr->m_idx) - { - msg_print(_("何もない場所に噛みついた!", "You bite into thin air!")); - break; - } - - msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs...")); - dummy = plev + randint1(plev) * MAX(1, plev / 10); /* Dmg */ - if (hypodynamic_bolt(dir, dummy)) - { - if (p_ptr->food < PY_FOOD_FULL) - /* No heal if we are "full" */ - (void)hp_player(dummy); - else - msg_print(_("あなたは空腹ではありません。", "You were not hungry.")); - - /* Gain nutritional sustenance: 150/hp drained */ - /* A Food ration gives 5000 food points (by contrast) */ - /* Don't ever get more than "Full" this way */ - /* But if we ARE Gorged, it won't cure us */ - dummy = p_ptr->food + MIN(5000, 100 * dummy); - if (p_ptr->food < PY_FOOD_MAX) /* Not gorged already */ - (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy); - } - else - msg_print(_("げぇ。ひどい味だ。", "Yechh. That tastes foul.")); - } + vampirism(); break; } } @@ -1557,51 +1513,7 @@ static bool cmd_racial_power_aux(s32b command) break; case RACE_VAMPIRE: - if (d_info[dungeon_type].flags1 & DF1_NO_MELEE) - { - msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking.")); - return FALSE; - } - else - { - int y, x, dummy = 0; - cave_type *c_ptr; - - /* Only works on adjacent monsters */ - if (!get_rep_dir(&dir,FALSE)) return FALSE; /* was get_aim_dir */ - y = p_ptr->y + ddy[dir]; - x = p_ptr->x + ddx[dir]; - c_ptr = &cave[y][x]; - - stop_mouth(); - - if (!c_ptr->m_idx) - { - msg_print(_("何もない場所に噛みついた!", "You bite into thin air!")); - break; - } - - msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs...")); - dummy = plev + randint1(plev) * MAX(1, plev / 10); /* Dmg */ - if (hypodynamic_bolt(dir, dummy)) - { - if (p_ptr->food < PY_FOOD_FULL) - /* No heal if we are "full" */ - (void)hp_player(dummy); - else - msg_print(_("あなたは空腹ではありません。", "You were not hungry.")); - - /* Gain nutritional sustenance: 150/hp drained */ - /* A Food ration gives 5000 food points (by contrast) */ - /* Don't ever get more than "Full" this way */ - /* But if we ARE Gorged, it won't cure us */ - dummy = p_ptr->food + MIN(5000, 100 * dummy); - if (p_ptr->food < PY_FOOD_MAX) /* Not gorged already */ - (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy); - } - else - msg_print(_("げぇ。ひどい味だ。", "Yechh. That tastes foul.")); - } + vampirism(); break; case RACE_SPECTRE: diff --git a/src/spells2.c b/src/spells2.c index ce46b5ee3..6cc14d5c3 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -5123,3 +5123,56 @@ void stop_mouth(void) if (music_singing_any()) stop_singing(); if (hex_spelling_any()) stop_hex_spell_all(); } + + +bool_hack vampirism(void) +{ + DIRECTION dir; + int x, y, dummy; + cave_type *c_ptr; + + if (d_info[dungeon_type].flags1 & DF1_NO_MELEE) + { + msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking.")); + return FALSE; + } + + /* Only works on adjacent monsters */ + if (!get_rep_dir2(&dir)) return FALSE; + y = p_ptr->y + ddy[dir]; + x = p_ptr->x + ddx[dir]; + c_ptr = &cave[y][x]; + + stop_mouth(); + + if (!(c_ptr->m_idx)) + { + msg_print(_("何もない場所に噛みついた!", "You bite into thin air!")); + return FALSE; + } + + msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs...")); + + dummy = p_ptr->lev * 2; + + if (hypodynamic_bolt(dir, dummy)) + { + if (p_ptr->food < PY_FOOD_FULL) + /* No heal if we are "full" */ + (void)hp_player(dummy); + else + msg_print(_("あなたは空腹ではありません。", "You were not hungry.")); + + /* Gain nutritional sustenance: 150/hp drained */ + /* A Food ration gives 5000 food points (by contrast) */ + /* Don't ever get more than "Full" this way */ + /* But if we ARE Gorged, it won't cure us */ + dummy = p_ptr->food + MIN(5000, 100 * dummy); + if (p_ptr->food < PY_FOOD_MAX) /* Not gorged already */ + (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy); + } + else + msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul.")); + return TRUE; +} +