OSDN Git Service

[Refactor] #37353 吸血処理をvampirism()にまとめる。
authorDeskull <deskull@users.sourceforge.jp>
Fri, 28 Sep 2018 12:06:18 +0000 (21:06 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Fri, 28 Sep 2018 12:06:18 +0000 (21:06 +0900)
Integrate some processes to vampirism().

src/externs.h
src/mutation.c
src/racial.c
src/spells2.c

index 62dccc2..fba7bd6 100644 (file)
@@ -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);
index d65127d..7c3ec49 100644 (file)
@@ -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:
index 88b211c..7b42f45 100644 (file)
@@ -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:
index ce46b5e..6cc14d5 100644 (file)
@@ -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;
+}
+