OSDN Git Service

[Refactor] #40030 Separated quantum-effect.c/h from monster-process.c
authorHourier <hourier@users.sourceforge.jp>
Sat, 7 Mar 2020 05:56:28 +0000 (14:56 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 7 Mar 2020 05:56:28 +0000 (14:56 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/monster-process.c
src/monster/quantum-effect.c [new file with mode: 0644]
src/monster/quantum-effect.h [new file with mode: 0644]

index 8af109e..6c65061 100644 (file)
     <ClCompile Include="..\..\src\monster-status.c" />\r
     <ClCompile Include="..\..\src\monsterrace-hook.c" />\r
     <ClCompile Include="..\..\src\monsterrace.c" />\r
+    <ClCompile Include="..\..\src\monster\quantum-effect.c" />\r
     <ClCompile Include="..\..\src\object-boost.c" />\r
     <ClCompile Include="..\..\src\object-curse.c" />\r
     <ClCompile Include="..\..\src\object-ego.c" />\r
     <ClInclude Include="..\..\src\io\read-pref-file.h" />\r
     <ClInclude Include="..\..\src\io\tokenizer.h" />\r
     <ClInclude Include="..\..\src\monster-dist-offsets.h" />\r
+    <ClInclude Include="..\..\src\monster\quantum-effect.h" />\r
     <ClInclude Include="..\..\src\object-flavor.h" />\r
     <ClInclude Include="..\..\src\player-inventory.h" />\r
     <ClInclude Include="..\..\src\player\permanent-resistances.h" />\r
index 8144c82..d4bf875 100644 (file)
     <ClCompile Include="..\..\src\io\interpret-pref-file.c">
       <Filter>io</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\monster\quantum-effect.c">
+      <Filter>monster</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\io\interpret-pref-file.h">
       <Filter>io</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\monster\quantum-effect.h">
+      <Filter>monster</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index e61ab35..d6fa32f 100644 (file)
@@ -56,6 +56,7 @@ hengband_SOURCES = \
        mind.c mind.h \
        \
        monster.h monsterrace.c monsterrace.h \
+       monster/quantum-effect.c monster/quantum-effect.c \
        monsterrace-hook.c monsterrace-hook.h \
        monster-dist-offsets.c monster-dist-offsets.h \
        monster-process.c monster-process.h \
index af7cef4..c946348 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "angband.h"
 #include "util.h"
+#include "monster/quantum-effect.h"
 
 #include "cmd-dump.h"
 #include "cmd-pet.h"
@@ -102,9 +103,6 @@ bool process_stealth(player_type *target_ptr, MONSTER_IDX m_idx);
 bool vanish_summoned_children(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m);
 void awake_monster(player_type *target_ptr, MONSTER_IDX m_idx);
 void process_angar(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m);
-bool process_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m);
-void vanish_nonunique(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m);
-void produce_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m);
 bool explode_monster(player_type *target_ptr, MONSTER_IDX m_idx);
 bool decide_monster_multiplication(player_type *target_ptr, MONSTER_IDX m_idx, POSITION oy, POSITION ox);
 bool decide_monster_movement_direction(player_type *target_ptr, DIRECTION *mm, MONSTER_IDX m_idx, bool aware);
@@ -1344,101 +1342,6 @@ void process_angar(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m)
 
 
 /*!
- * @brief 量子生物の量子的効果を実行する
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param m_idx モンスターID
- * @param see_m モンスターが視界内にいたらTRUE
- * @return モンスターが量子的効果により消滅したらTRUE
- */
-bool process_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m)
-{
-       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
-       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       if ((r_ptr->flags2 & RF2_QUANTUM) == 0) return FALSE;
-       if (!randint0(2)) return FALSE;
-       if (randint0((m_idx % 100) + 10)) return FALSE;
-
-       bool can_disappear = (r_ptr->flags1 & RF1_UNIQUE) == 0;
-       can_disappear &= (r_ptr->flags1 & RF1_QUESTOR) == 0;
-       if (can_disappear)
-       {
-               vanish_nonunique(target_ptr, m_idx, see_m);
-               return TRUE;
-       }
-
-       produce_quantum_effect(target_ptr, m_idx, see_m);
-       return FALSE;
-}
-
-
-/*!
- * @brief ユニークでない量子生物を消滅させる
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param m_idx モンスターID
- * @param see_m モンスターが視界内にいたらTRUE
- * @return なし
- */
-void vanish_nonunique(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m)
-{
-       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
-       if (see_m)
-       {
-               GAME_TEXT m_name[MAX_NLEN];
-               monster_desc(target_ptr, m_name, m_ptr, 0);
-               msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
-       }
-
-       monster_death(target_ptr, m_idx, FALSE);
-       delete_monster_idx(target_ptr, m_idx);
-       if (is_pet(m_ptr) && !(m_ptr->ml))
-       {
-               msg_print(_("少しの間悲しい気分になった。", "You feel sad for a moment."));
-       }
-}
-
-
-/*!
- * @brief 量子生物ユニークの量子的効果 (ショート・テレポートまたは距離10のテレポート・アウェイ)を実行する
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param m_idx モンスターID
- * @param see_m モンスターが視界内にいたらTRUE
- * @return なし
- * @details
- * プレーヤーが量子生物を観測しているか、量子生物がプレーヤーを観測している場合、互いの相対的な位置を確定させる
- * 波動関数の収縮はテレポートではないので反テレポート無効
- * todo パターンは収縮どころか拡散しているが、この際気にしてはいけない
- */
-void produce_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m)
-{
-       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
-       bool coherent = los(target_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x);
-       if (!see_m && !coherent) return;
-
-       if (see_m)
-       {
-               GAME_TEXT m_name[MAX_NLEN];
-               monster_desc(target_ptr, m_name, m_ptr, 0);
-               msg_format(_("%sは量子的効果を起こした!", "%^s produced a decoherence!"), m_name);
-       }
-       else
-       {
-               msg_print(_("量子的効果が起こった!", "A decoherence was produced!"));
-       }
-
-       bool target = one_in_(2);
-       const int blink = 32 * 5 + 4;
-       if (target)
-       {
-               (void)monspell_to_monster(target_ptr, blink, m_ptr->fy, m_ptr->fx, m_idx, m_idx);
-       }
-       else
-       {
-               teleport_player_away(m_idx, target_ptr, 10, TRUE);
-       }
-}
-
-
-/*!
  * @brief モンスターの爆発処理
  * @param target_ptr プレーヤーへの参照ポインタ
  * @param m_idx モンスターID
diff --git a/src/monster/quantum-effect.c b/src/monster/quantum-effect.c
new file mode 100644 (file)
index 0000000..06f7a1b
--- /dev/null
@@ -0,0 +1,99 @@
+#include "angband.h"
+#include "quantum-effect.h"
+#include "monster-spell.h"
+
+/*!
+ * @brief ユニークでない量子生物を消滅させる
+ * @param target_ptr プレーヤーへの参照ポインタ
+ * @param m_idx モンスターID
+ * @param see_m モンスターが視界内にいたらTRUE
+ * @return なし
+ */
+static void vanish_nonunique(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m)
+{
+       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
+       if (see_m)
+       {
+               GAME_TEXT m_name[MAX_NLEN];
+               monster_desc(target_ptr, m_name, m_ptr, 0);
+               msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
+       }
+
+       monster_death(target_ptr, m_idx, FALSE);
+       delete_monster_idx(target_ptr, m_idx);
+       if (is_pet(m_ptr) && !(m_ptr->ml))
+       {
+               msg_print(_("少しの間悲しい気分になった。", "You feel sad for a moment."));
+       }
+}
+
+
+/*!
+ * todo ユニークとプレーヤーとの間でしか効果が発生しない。ユニークとその他のモンスター間では何もしなくてよい?
+ * @brief 量子生物ユニークの量子的効果 (ショート・テレポートまたは距離10のテレポート・アウェイ)を実行する
+ * @param target_ptr プレーヤーへの参照ポインタ
+ * @param m_idx モンスターID
+ * @param see_m モンスターが視界内にいたらTRUE
+ * @return なし
+ * @details
+ * プレーヤーが量子生物を観測しているか、量子生物がプレーヤーを観測している場合、互いの相対的な位置を確定させる
+ * 波動関数の収縮はテレポートではないので反テレポート無効
+ * @notes
+ * パターンは収縮どころか拡散しているが、この際気にしてはいけない
+ */
+static void produce_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m)
+{
+       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
+       bool coherent = los(target_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x);
+       if (!see_m && !coherent) return;
+
+       if (see_m)
+       {
+               GAME_TEXT m_name[MAX_NLEN];
+               monster_desc(target_ptr, m_name, m_ptr, 0);
+               msg_format(_("%sは量子的効果を起こした!", "%^s produced a decoherence!"), m_name);
+       }
+       else
+       {
+               msg_print(_("量子的効果が起こった!", "A decoherence was produced!"));
+       }
+
+       bool target = one_in_(2);
+       const int blink = 32 * 5 + 4;
+       if (target)
+       {
+               (void)monspell_to_monster(target_ptr, blink, m_ptr->fy, m_ptr->fx, m_idx, m_idx);
+       }
+       else
+       {
+               teleport_player_away(m_idx, target_ptr, 10, TRUE);
+       }
+}
+
+
+/*!
+ * @brief 量子生物の量子的効果を実行する
+ * @param target_ptr プレーヤーへの参照ポインタ
+ * @param m_idx モンスターID
+ * @param see_m モンスターが視界内にいたらTRUE
+ * @return モンスターが量子的効果により消滅したらTRUE
+ */
+bool process_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m)
+{
+       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
+       monster_race *r_ptr = &r_info[m_ptr->r_idx];
+       if ((r_ptr->flags2 & RF2_QUANTUM) == 0) return FALSE;
+       if (!randint0(2)) return FALSE;
+       if (randint0((m_idx % 100) + 10)) return FALSE;
+
+       bool can_disappear = (r_ptr->flags1 & RF1_UNIQUE) == 0;
+       can_disappear &= (r_ptr->flags1 & RF1_QUESTOR) == 0;
+       if (can_disappear)
+       {
+               vanish_nonunique(target_ptr, m_idx, see_m);
+               return TRUE;
+       }
+
+       produce_quantum_effect(target_ptr, m_idx, see_m);
+       return FALSE;
+}
diff --git a/src/monster/quantum-effect.h b/src/monster/quantum-effect.h
new file mode 100644 (file)
index 0000000..1b1acbc
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+bool process_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m);