OSDN Git Service

Separated check_fall_off_horse() from monster-attack-player.c and process_fall_off_ho...
authorHourier <hourier@users.sourceforge.jp>
Sun, 31 May 2020 11:59:07 +0000 (20:59 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 31 May 2020 11:59:07 +0000 (20:59 +0900)
17 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd/cmd-pet.c
src/cmd/cmd-pet.h
src/combat/melee-postprocess.c
src/combat/monster-attack-player.c
src/effect/effect-monster-domination.c
src/effect/effect-monster-domination.h
src/monster/monster-process.c
src/monster/monster-runaway.c
src/monster/monster1.c
src/monster/monster2.c
src/monster/pet-fall-off.c [new file with mode: 0644]
src/monster/pet-fall-off.h [new file with mode: 0644]
src/spell/process-effect.c
src/spell/spells2.c

index 88a96b1..4f5db61 100644 (file)
     <ClCompile Include="..\..\src\mind\racial-samurai.c" />\r
     <ClCompile Include="..\..\src\mind\samurai-slaying.c" />\r
     <ClCompile Include="..\..\src\mind\surprise-attack.c" />\r
+    <ClCompile Include="..\..\src\monster\pet-fall-off.c" />\r
     <ClCompile Include="..\..\src\mspell\mspell-floor.c" />\r
     <ClCompile Include="..\..\src\mspell\mspell-particularity.c" />\r
     <ClCompile Include="..\..\src\mspell\mspell-special.c" />\r
     <ClInclude Include="..\..\src\mind\racial-samurai.h" />\r
     <ClInclude Include="..\..\src\mind\samurai-slaying.h" />\r
     <ClInclude Include="..\..\src\mind\surprise-attack.h" />\r
+    <ClInclude Include="..\..\src\monster\pet-fall-off.h" />\r
     <ClInclude Include="..\..\src\mspell\assign-monster-spell.h" />\r
     <ClInclude Include="..\..\src\mspell\mspell-floor.h" />\r
     <ClInclude Include="..\..\src\mspell\mspell-particularity.h" />\r
index d194795..deb322c 100644 (file)
     <ClCompile Include="..\..\src\combat\aura-counterattack.c">
       <Filter>combat</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\monster\pet-fall-off.c">
+      <Filter>monster</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-activate.h">
     <ClInclude Include="..\..\src\combat\aura-counterattack.h">
       <Filter>combat</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\monster\pet-fall-off.h">
+      <Filter>monster</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index ef2a034..9e79a1f 100644 (file)
@@ -186,6 +186,7 @@ hengband_SOURCES = \
        monster/monster-status.c monster/monster-status.h \
        monster/monster1.c monster/monster2.c \
        monster/horror-descriptions.c monster/horror-descriptions.h \
+       monster/pet-fall-off.c monster/pet-fall-off.h \
        \
        mutation/mutation.c mutation/mutation.h \
        mutation/mutation-processor.c mutation/mutation-processor.h \
index 8a34a0b..6f91bf4 100644 (file)
@@ -15,8 +15,8 @@
 #include "object/object-hook.h"
 #include "monster/monster.h"
 #include "monster/monster-status.h"
-#include "cmd-pet.h"
-#include "cmd-basic.h"
+#include "cmd/cmd-pet.h"
+#include "cmd/cmd-basic.h"
 #include "view/display-main-window.h"
 #include "io/targeting.h"
 #include "world/world.h"
@@ -902,142 +902,3 @@ void do_cmd_pet(player_type *creature_ptr)
        }
        }
 }
-
-
-/*!
-* @brief プレイヤーの落馬判定処理
-* @param dam 落馬判定を発した際に受けたダメージ量
-* @param force TRUEならば強制的に落馬する
-* @return 実際に落馬したらTRUEを返す
-*/
-bool process_fall_off_horse(player_type *creature_ptr, HIT_POINT dam, bool force)
-{
-       DIRECTION i;
-       POSITION y, x, oy, ox, sy = 0, sx = 0;
-       int sn = 0;
-       GAME_TEXT m_name[MAX_NLEN];
-       monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
-       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       bool fall_dam = FALSE;
-
-       if (!creature_ptr->riding) return FALSE;
-       if (creature_ptr->wild_mode) return FALSE;
-
-       if (dam >= 0 || force)
-       {
-               if (!force)
-               {
-                       int cur = creature_ptr->skill_exp[GINOU_RIDING];
-                       int max = s_info[creature_ptr->pclass].s_max[GINOU_RIDING];
-                       int ridinglevel = r_ptr->level;
-
-                       /* 落馬のしやすさ */
-                       int rakubalevel = r_ptr->level;
-                       if (creature_ptr->riding_ryoute) rakubalevel += 20;
-
-                       if ((cur < max) && (max > 1000) &&
-                               (dam / 2 + ridinglevel) > (cur / 30 + 10))
-                       {
-                               int inc = 0;
-
-                               if (ridinglevel > (cur / 100 + 15))
-                                       inc += 1 + (ridinglevel - cur / 100 - 15);
-                               else
-                                       inc += 1;
-
-                               creature_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
-                       }
-
-                       /* レベルの低い乗馬からは落馬しにくい */
-                       if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
-                       {
-                               if ((((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) && !creature_ptr->riding_ryoute) || !one_in_(creature_ptr->lev*(creature_ptr->riding_ryoute ? 2 : 3) + 30))
-                               {
-                                       return FALSE;
-                               }
-                       }
-               }
-
-               /* Check around the player */
-               for (i = 0; i < 8; i++)
-               {
-                       grid_type *g_ptr;
-
-                       y = creature_ptr->y + ddy_ddd[i];
-                       x = creature_ptr->x + ddx_ddd[i];
-
-                       g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
-
-                       if (g_ptr->m_idx) continue;
-
-                       /* Skip non-empty grids */
-                       if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !cave_have_flag_grid(g_ptr, FF_CAN_FLY))
-                       {
-                               if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE)) continue;
-                       }
-
-                       if (cave_have_flag_grid(g_ptr, FF_PATTERN)) continue;
-
-                       /* Count "safe" grids */
-                       sn++;
-
-                       /* Randomize choice */
-                       if (randint0(sn) > 0) continue;
-
-                       /* Save the safe location */
-                       sy = y; sx = x;
-               }
-               if (!sn)
-               {
-                       monster_desc(creature_ptr, m_name, m_ptr, 0);
-                       msg_format(_("%sから振り落とされそうになって、壁にぶつかった。", "You have nearly fallen from %s, but bumped into wall."), m_name);
-                       take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("壁への衝突", "bumping into wall"), -1);
-                       return FALSE;
-               }
-
-               oy = creature_ptr->y;
-               ox = creature_ptr->x;
-
-               creature_ptr->y = sy;
-               creature_ptr->x = sx;
-
-               /* Redraw the old spot */
-               lite_spot(creature_ptr, oy, ox);
-
-               /* Redraw the new spot */
-               lite_spot(creature_ptr, creature_ptr->y, creature_ptr->x);
-
-               /* Check for new panel */
-               verify_panel(creature_ptr);
-       }
-
-       creature_ptr->riding = 0;
-       creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
-       creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
-
-       creature_ptr->update |= (PU_BONUS | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
-       handle_stuff(creature_ptr);
-
-
-       creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-       creature_ptr->redraw |= (PR_EXTRA);
-
-       /* Update health track of mount */
-       creature_ptr->redraw |= (PR_UHEALTH);
-
-       if (creature_ptr->levitation && !force)
-       {
-               monster_desc(creature_ptr, m_name, m_ptr, 0);
-               msg_format(_("%sから落ちたが、空中でうまく体勢を立て直して着地した。", "You are thrown from %s, but make a good landing."), m_name);
-       }
-       else
-       {
-               take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("落馬", "Falling from riding"), -1);
-               fall_dam = TRUE;
-       }
-
-       if (sy && !creature_ptr->is_dead)
-               (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
-
-       return fall_dam;
-}
index b870bd7..3aeae0d 100644 (file)
@@ -6,7 +6,6 @@ extern bool do_cmd_riding(player_type *creature_ptr, bool force);
 extern void do_cmd_pet_dismiss(player_type *creature_pt);
 extern void do_cmd_pet(player_type *creature_ptr);
 extern bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_riding);
-extern bool process_fall_off_horse(player_type *creature_ptr, HIT_POINT dam, bool force);
 
 extern int total_friends;
 
index ac92f41..c0af6a8 100644 (file)
  */
 
 #include "combat/melee-postprocess.h"
-#include "cmd-pet.h"
 #include "combat/monster-attack-types.h"
 #include "grid/grid.h"
 #include "main/sound-definitions-table.h"
 #include "monster/monster-race-hook.h"
 #include "monster/monster-status.h"
 #include "monster/monster.h"
+#include "monster/pet-fall-off.h"
 #include "mspell/monster-spell.h"
 #include "player/player-class.h"
 #include "player/player-move.h"
index 609f82d..db7198c 100644 (file)
@@ -21,6 +21,7 @@
 #include "main/sound-definitions-table.h"
 #include "mind/racial-samurai.h"
 #include "monster/monster-status.h"
+#include "monster/pet-fall-off.h"
 #include "object/object-hook.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
@@ -349,23 +350,6 @@ static void increase_blow_type_seen(player_type *target_ptr, monap_type *monap_p
         r_ptr->r_blows[monap_ptr->ap_cnt]++;
 }
 
-/*!
- * @brief モンスターから直接攻撃を受けた時に落馬するかどうかを判定し、判定アウトならば落馬させる
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param monap_ptr モンスターからプレーヤーへの直接攻撃構造体への参照ポインタ
- * @return なし
- */
-static void check_fall_off_horse(player_type *target_ptr, monap_type *monap_ptr)
-{
-    if ((target_ptr->riding == 0) || (monap_ptr->damage == 0))
-        return;
-
-    char m_steed_name[MAX_NLEN];
-    monster_desc(target_ptr, m_steed_name, &target_ptr->current_floor_ptr->m_list[target_ptr->riding], 0);
-    if (process_fall_off_horse(target_ptr, (monap_ptr->damage > 200) ? 200 : monap_ptr->damage, FALSE))
-        msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_steed_name);
-}
-
 static bool process_monster_blows(player_type *target_ptr, monap_type *monap_ptr)
 {
     monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
index ef8b4dc..d5878a5 100644 (file)
@@ -1,15 +1,13 @@
-#include "system/angband.h"
-#include "effect/effect-monster-util.h"
-#include "effect/effect-monster-domination.h"
-#include "floor/floor.h"
-#include "player/player-effects.h"
-#include "spell/spells-diceroll.h"
-#include "monster/monster-status.h"
-#include "effect/spells-effect-util.h"
-#include "cmd/cmd-pet.h" // 暫定、後で消すかも.
+#include "effect/effect-monster-domination.h"
 #include "dungeon/quest.h"
+#include "effect/spells-effect-util.h"
+#include "floor/floor.h"
 #include "monster/monster-race-hook.h"
+#include "monster/monster-status.h"
+#include "monster/pet-fall-off.h"
 #include "object/trc-types.h"
+#include "player/player-effects.h"
+#include "spell/spells-diceroll.h"
 
 static void effect_monster_domination_corrupted_addition(player_type *caster_ptr, effect_monster_type *em_ptr)
 {
index b723597..e1c3f4f 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include "system/angband.h"
+#include "effect/effect-monster-util.h"
+
 gf_switch_result effect_monster_domination(player_type *caster_ptr, effect_monster_type *em_ptr);
 gf_switch_result effect_monster_crusade(player_type *caster_ptr, effect_monster_type *em_ptr);
 gf_switch_result effect_monster_capture(player_type *caster_ptr, effect_monster_type *em_ptr);
index 4031f4d..8f0b163 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "io/write-diary.h"
 #include "cmd/cmd-dump.h"
-#include "cmd/cmd-pet.h"
+#include "monster/pet-fall-off.h"
 #include "monster/creature.h"
 #include "combat/melee-postprocess.h"
 #include "spell/spells-summon.h"
index 7d9ab90..9b68889 100644 (file)
@@ -5,9 +5,9 @@
  */
 
 #include "monster/monster-runaway.h"
-#include "player/player-move.h"
-#include "cmd/cmd-pet.h"
 #include "dungeon/quest.h"
+#include "monster/pet-fall-off.h"
+#include "player/player-move.h"
 
  /*!
   * @brief HPが1/3未満になった有効的なユニークモンスターの逃走処理を行う
index cda6e55..8da4a4b 100644 (file)
@@ -18,7 +18,7 @@
 #include "io/write-diary.h"
 #include "cmd/cmd-dump.h"
 #include "cmd/cmd-building.h"
-#include "cmd-pet.h"
+#include "monster/pet-fall-off.h"
 #include "effect/effect-characteristics.h"
 #include "object/object-kind-hook.h"
 #include "player/player-personalities-table.h"
index 3711854..5e39128 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "io/write-diary.h"
 #include "cmd/cmd-dump.h"
-#include "cmd-pet.h"
+#include "monster/pet-fall-off.h"
 #include "dungeon/dungeon.h"
 #include "effect/effect-characteristics.h"
 #include "object/object2.h"
diff --git a/src/monster/pet-fall-off.c b/src/monster/pet-fall-off.c
new file mode 100644 (file)
index 0000000..612db81
--- /dev/null
@@ -0,0 +1,158 @@
+#include "monster/pet-fall-off.h"
+#include "cmd/cmd-pet.h" // 暫定、定数を見ているだけなのでutilへの分離を検討する.
+#include "floor/floor.h"
+#include "io/targeting.h"
+#include "player/player-damage.h"
+#include "player/player-move.h"
+#include "player/player-skill.h"
+
+/*!
+ * @brief モンスターから直接攻撃を受けた時に落馬するかどうかを判定し、判定アウトならば落馬させる
+ * @param target_ptr プレーヤーへの参照ポインタ
+ * @param monap_ptr モンスターからプレーヤーへの直接攻撃構造体への参照ポインタ
+ * @return なし
+ */
+void check_fall_off_horse(player_type *target_ptr, monap_type *monap_ptr)
+{
+    if ((target_ptr->riding == 0) || (monap_ptr->damage == 0))
+        return;
+
+    char m_steed_name[MAX_NLEN];
+    monster_desc(target_ptr, m_steed_name, &target_ptr->current_floor_ptr->m_list[target_ptr->riding], 0);
+    if (process_fall_off_horse(target_ptr, (monap_ptr->damage > 200) ? 200 : monap_ptr->damage, FALSE))
+        msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_steed_name);
+}
+
+/*!
+ * @brief プレイヤーの落馬判定処理
+ * @param dam 落馬判定を発した際に受けたダメージ量
+ * @param force TRUEならば強制的に落馬する
+ * @return 実際に落馬したらTRUEを返す
+ */
+bool process_fall_off_horse(player_type *creature_ptr, HIT_POINT dam, bool force)
+{
+    DIRECTION i;
+    POSITION y, x, oy, ox, sy = 0, sx = 0;
+    int sn = 0;
+    GAME_TEXT m_name[MAX_NLEN];
+    monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
+    monster_race *r_ptr = &r_info[m_ptr->r_idx];
+    bool fall_dam = FALSE;
+
+    if (!creature_ptr->riding)
+        return FALSE;
+    if (creature_ptr->wild_mode)
+        return FALSE;
+
+    if (dam >= 0 || force) {
+        if (!force) {
+            int cur = creature_ptr->skill_exp[GINOU_RIDING];
+            int max = s_info[creature_ptr->pclass].s_max[GINOU_RIDING];
+            int ridinglevel = r_ptr->level;
+
+            /* 落馬のしやすさ */
+            int rakubalevel = r_ptr->level;
+            if (creature_ptr->riding_ryoute)
+                rakubalevel += 20;
+
+            if ((cur < max) && (max > 1000) && (dam / 2 + ridinglevel) > (cur / 30 + 10)) {
+                int inc = 0;
+
+                if (ridinglevel > (cur / 100 + 15))
+                    inc += 1 + (ridinglevel - cur / 100 - 15);
+                else
+                    inc += 1;
+
+                creature_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
+            }
+
+            /* レベルの低い乗馬からは落馬しにくい */
+            if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10) {
+                if ((((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) && !creature_ptr->riding_ryoute)
+                    || !one_in_(creature_ptr->lev * (creature_ptr->riding_ryoute ? 2 : 3) + 30)) {
+                    return FALSE;
+                }
+            }
+        }
+
+        /* Check around the player */
+        for (i = 0; i < 8; i++) {
+            grid_type *g_ptr;
+
+            y = creature_ptr->y + ddy_ddd[i];
+            x = creature_ptr->x + ddx_ddd[i];
+
+            g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
+
+            if (g_ptr->m_idx)
+                continue;
+
+            /* Skip non-empty grids */
+            if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !cave_have_flag_grid(g_ptr, FF_CAN_FLY)) {
+                if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE))
+                    continue;
+            }
+
+            if (cave_have_flag_grid(g_ptr, FF_PATTERN))
+                continue;
+
+            /* Count "safe" grids */
+            sn++;
+
+            /* Randomize choice */
+            if (randint0(sn) > 0)
+                continue;
+
+            /* Save the safe location */
+            sy = y;
+            sx = x;
+        }
+        if (!sn) {
+            monster_desc(creature_ptr, m_name, m_ptr, 0);
+            msg_format(_("%sから振り落とされそうになって、壁にぶつかった。", "You have nearly fallen from %s, but bumped into wall."), m_name);
+            take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("壁への衝突", "bumping into wall"), -1);
+            return FALSE;
+        }
+
+        oy = creature_ptr->y;
+        ox = creature_ptr->x;
+
+        creature_ptr->y = sy;
+        creature_ptr->x = sx;
+
+        /* Redraw the old spot */
+        lite_spot(creature_ptr, oy, ox);
+
+        /* Redraw the new spot */
+        lite_spot(creature_ptr, creature_ptr->y, creature_ptr->x);
+
+        /* Check for new panel */
+        verify_panel(creature_ptr);
+    }
+
+    creature_ptr->riding = 0;
+    creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
+    creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
+
+    creature_ptr->update |= (PU_BONUS | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
+    handle_stuff(creature_ptr);
+
+    creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+    creature_ptr->redraw |= (PR_EXTRA);
+
+    /* Update health track of mount */
+    creature_ptr->redraw |= (PR_UHEALTH);
+
+    if (creature_ptr->levitation && !force) {
+        monster_desc(creature_ptr, m_name, m_ptr, 0);
+        msg_format(_("%sから落ちたが、空中でうまく体勢を立て直して着地した。", "You are thrown from %s, but make a good landing."), m_name);
+    } else {
+        take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("落馬", "Falling from riding"), -1);
+        fall_dam = TRUE;
+    }
+
+    if (sy && !creature_ptr->is_dead)
+        (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
+
+    return fall_dam;
+}
diff --git a/src/monster/pet-fall-off.h b/src/monster/pet-fall-off.h
new file mode 100644 (file)
index 0000000..45362e0
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "system/angband.h"
+#include "combat/monster-attack-util.h"
+
+void check_fall_off_horse(player_type *target_ptr, monap_type *monap_ptr);
+bool process_fall_off_horse(player_type *creature_ptr, HIT_POINT dam, bool force);
index 2510e13..90c9234 100644 (file)
@@ -2,7 +2,7 @@
 #include "effect/spells-effect-util.h"
 #include "spell/process-effect.h"
 #include "floor/floor.h"
-#include "cmd-pet.h" // 暫定、後で消すかも.
+#include "monster/pet-fall-off.h"
 #include "core/stuff-handler.h"
 #include "effect/effect-feature.h"
 #include "effect/effect-item.h"
index c76aec1..59be051 100644 (file)
@@ -22,6 +22,7 @@
 #include "object/artifact.h"
 #include "io/write-diary.h"
 #include "cmd/cmd-pet.h"
+#include "monster/pet-fall-off.h"
 #include "cmd/cmd-dump.h"
 #include "effect/effect-characteristics.h"
 #include "grid/grid.h"