OSDN Git Service

[Refactor] #37353 object-boost 追加。 / Add object-boost.
authordeskull <deskull@users.sourceforge.jp>
Wed, 13 Mar 2019 14:26:39 +0000 (23:26 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Wed, 13 Mar 2019 14:26:39 +0000 (23:26 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/externs.h
src/object-boost.c [new file with mode: 0644]
src/object-boost.h [new file with mode: 0644]
src/object2.c
src/spells-object.c
src/spells3.c

index 59fcd1d..f6daa58 100644 (file)
     <ClCompile Include="..\..\src\monster-process.c" />\r
     <ClCompile Include="..\..\src\monster-status.c" />\r
     <ClCompile Include="..\..\src\monsterrace-hook.c" />\r
+    <ClCompile Include="..\..\src\object-boost.c" />\r
     <ClCompile Include="..\..\src\object-curse.c" />\r
     <ClCompile Include="..\..\src\object-hook.c" />\r
     <ClCompile Include="..\..\src\objectkind-hook.c" />\r
     <ClInclude Include="..\..\src\monster.h" />\r
     <ClInclude Include="..\..\src\monsterrace-hook.h" />\r
     <ClInclude Include="..\..\src\mutation.h" />\r
+    <ClInclude Include="..\..\src\object-boost.h" />\r
     <ClInclude Include="..\..\src\object-curse.h" />\r
     <ClInclude Include="..\..\src\object-hook.h" />\r
     <ClInclude Include="..\..\src\object-broken.h" />\r
index 1104f90..610073c 100644 (file)
     <ClCompile Include="..\..\src\mspells4.c">
       <Filter>monster</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\object-boost.c">
+      <Filter>object</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\angband.h" />
     <ClInclude Include="..\..\src\monster-status.h">
       <Filter>monster</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\object-boost.h">
+      <Filter>object</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\src\angband.rc" />
index 7323739..d14ffd4 100644 (file)
@@ -707,8 +707,6 @@ extern byte get_mspeed(monster_race *r_ptr);
 extern void monster_drop_carried_objects(monster_type *m_ptr);
 
 /* object1.c */
-extern int m_bonus(int max, DEPTH level);
-
 extern void reset_visuals(void);
 extern void object_flags(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE]);
 extern void object_flags_known(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE]);
diff --git a/src/object-boost.c b/src/object-boost.c
new file mode 100644 (file)
index 0000000..8a56d32
--- /dev/null
@@ -0,0 +1,85 @@
+#include "angband.h"
+#include "object-boost.h"
+
+/*!
+ * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
+ * Help determine an "enchantment bonus" for an object.
+ * @param max ボーナス値の限度
+ * @param level ボーナス値に加味する基準生成階
+ * @return 算出されたボーナス値
+ * @details
+ * To avoid floating point but still provide a smooth distribution of bonuses,\n
+ * we simply round the results of division in such a way as to "average" the\n
+ * correct floating point value.\n
+ *\n
+ * This function has been changed.  It uses "randnor()" to choose values from\n
+ * a normal distribution, whose mean moves from zero towards the max as the\n
+ * level increases, and whose standard deviation is equal to 1/4 of the max,\n
+ * and whose values are forced to lie between zero and the max, inclusive.\n
+ *\n
+ * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
+ * rare to get the "full" enchantment on an object, even a deep levels.\n
+ *\n
+ * It is always possible (albeit unlikely) to get the "full" enchantment.\n
+ *\n
+ * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
+ *\n
+ *   N       0     1     2     3     4     5     6     7     8     9    10\n
+ * ---    ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----\n
+ *   0   66.37 13.01  9.73  5.47  2.89  1.31  0.72  0.26  0.12  0.09  0.03\n
+ *   8   46.85 24.66 12.13  8.13  4.20  2.30  1.05  0.36  0.19  0.08  0.05\n
+ *  16   30.12 27.62 18.52 10.52  6.34  3.52  1.95  0.90  0.31  0.15  0.05\n
+ *  24   22.44 15.62 30.14 12.92  8.55  5.30  2.39  1.63  0.62  0.28  0.11\n
+ *  32   16.23 11.43 23.01 22.31 11.19  7.18  4.46  2.13  1.20  0.45  0.41\n
+ *  40   10.76  8.91 12.80 29.51 16.00  9.69  5.90  3.43  1.47  0.88  0.65\n
+ *  48    7.28  6.81 10.51 18.27 27.57 11.76  7.85  4.99  2.80  1.22  0.94\n
+ *  56    4.41  4.73  8.52 11.96 24.94 19.78 11.06  7.18  3.68  1.96  1.78\n
+ *  64    2.81  3.07  5.65  9.17 13.01 31.57 13.70  9.30  6.04  3.04  2.64\n
+ *  72    1.87  1.99  3.68  7.15 10.56 20.24 25.78 12.17  7.52  4.42  4.62\n
+ *  80    1.02  1.23  2.78  4.75  8.37 12.04 27.61 18.07 10.28  6.52  7.33\n
+ *  88    0.70  0.57  1.56  3.12  6.34 10.06 15.76 30.46 12.58  8.47 10.38\n
+ *  96    0.27  0.60  1.25  2.28  4.30  7.60 10.77 22.52 22.51 11.37 16.53\n
+ * 104    0.22  0.42  0.77  1.36  2.62  5.33  8.93 13.05 29.54 15.23 22.53\n
+ * 112    0.15  0.20  0.56  0.87  2.00  3.83  6.86 10.06 17.89 27.31 30.27\n
+ * 120    0.03  0.11  0.31  0.46  1.31  2.48  4.60  7.78 11.67 25.53 45.72\n
+ * 128    0.02  0.01  0.13  0.33  0.83  1.41  3.24  6.17  9.57 14.22 64.07\n
+ */
+int m_bonus(int max, DEPTH level)
+{
+       int bonus, stand, extra, value;
+
+
+       /* Paranoia -- enforce maximal "level" */
+       if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
+
+
+       /* The "bonus" moves towards the max */
+       bonus = ((max * level) / MAX_DEPTH);
+
+       /* Hack -- determine fraction of error */
+       extra = ((max * level) % MAX_DEPTH);
+
+       /* Hack -- simulate floating point computations */
+       if (randint0(MAX_DEPTH) < extra) bonus++;
+
+
+       /* The "stand" is equal to one quarter of the max */
+       stand = (max / 4);
+
+       /* Hack -- determine fraction of error */
+       extra = (max % 4);
+
+       /* Hack -- simulate floating point computations */
+       if (randint0(4) < extra) stand++;
+
+
+       /* Choose an "interesting" value */
+       value = randnor(bonus, stand);
+
+       /* Enforce the minimum value */
+       if (value < 0) return (0);
+
+       /* Enforce the maximum value */
+       if (value > max) return (max);
+       return (value);
+}
diff --git a/src/object-boost.h b/src/object-boost.h
new file mode 100644 (file)
index 0000000..e330f92
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+extern int m_bonus(int max, DEPTH level);
+
index f22ffd6..57a4a99 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include "angband.h"
+#include "object-boost.h"
 #include "object-hook.h"
 #include "object-curse.h"
 #include "artifact.h"
@@ -1988,90 +1989,6 @@ void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
 
 
 /*!
- * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
- * Help determine an "enchantment bonus" for an object.
- * @param max ボーナス値の限度
- * @param level ボーナス値に加味する基準生成階
- * @return 算出されたボーナス値
- * @details
- * To avoid floating point but still provide a smooth distribution of bonuses,\n
- * we simply round the results of division in such a way as to "average" the\n
- * correct floating point value.\n
- *\n
- * This function has been changed.  It uses "randnor()" to choose values from\n
- * a normal distribution, whose mean moves from zero towards the max as the\n
- * level increases, and whose standard deviation is equal to 1/4 of the max,\n
- * and whose values are forced to lie between zero and the max, inclusive.\n
- *\n
- * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
- * rare to get the "full" enchantment on an object, even a deep levels.\n
- *\n
- * It is always possible (albeit unlikely) to get the "full" enchantment.\n
- *\n
- * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
- *\n
- *   N       0     1     2     3     4     5     6     7     8     9    10\n
- * ---    ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----\n
- *   0   66.37 13.01  9.73  5.47  2.89  1.31  0.72  0.26  0.12  0.09  0.03\n
- *   8   46.85 24.66 12.13  8.13  4.20  2.30  1.05  0.36  0.19  0.08  0.05\n
- *  16   30.12 27.62 18.52 10.52  6.34  3.52  1.95  0.90  0.31  0.15  0.05\n
- *  24   22.44 15.62 30.14 12.92  8.55  5.30  2.39  1.63  0.62  0.28  0.11\n
- *  32   16.23 11.43 23.01 22.31 11.19  7.18  4.46  2.13  1.20  0.45  0.41\n
- *  40   10.76  8.91 12.80 29.51 16.00  9.69  5.90  3.43  1.47  0.88  0.65\n
- *  48    7.28  6.81 10.51 18.27 27.57 11.76  7.85  4.99  2.80  1.22  0.94\n
- *  56    4.41  4.73  8.52 11.96 24.94 19.78 11.06  7.18  3.68  1.96  1.78\n
- *  64    2.81  3.07  5.65  9.17 13.01 31.57 13.70  9.30  6.04  3.04  2.64\n
- *  72    1.87  1.99  3.68  7.15 10.56 20.24 25.78 12.17  7.52  4.42  4.62\n
- *  80    1.02  1.23  2.78  4.75  8.37 12.04 27.61 18.07 10.28  6.52  7.33\n
- *  88    0.70  0.57  1.56  3.12  6.34 10.06 15.76 30.46 12.58  8.47 10.38\n
- *  96    0.27  0.60  1.25  2.28  4.30  7.60 10.77 22.52 22.51 11.37 16.53\n
- * 104    0.22  0.42  0.77  1.36  2.62  5.33  8.93 13.05 29.54 15.23 22.53\n
- * 112    0.15  0.20  0.56  0.87  2.00  3.83  6.86 10.06 17.89 27.31 30.27\n
- * 120    0.03  0.11  0.31  0.46  1.31  2.48  4.60  7.78 11.67 25.53 45.72\n
- * 128    0.02  0.01  0.13  0.33  0.83  1.41  3.24  6.17  9.57 14.22 64.07\n
- */
-int m_bonus(int max, DEPTH level)
-{
-       int bonus, stand, extra, value;
-
-
-       /* Paranoia -- enforce maximal "level" */
-       if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
-
-
-       /* The "bonus" moves towards the max */
-       bonus = ((max * level) / MAX_DEPTH);
-
-       /* Hack -- determine fraction of error */
-       extra = ((max * level) % MAX_DEPTH);
-
-       /* Hack -- simulate floating point computations */
-       if (randint0(MAX_DEPTH) < extra) bonus++;
-
-
-       /* The "stand" is equal to one quarter of the max */
-       stand = (max / 4);
-
-       /* Hack -- determine fraction of error */
-       extra = (max % 4);
-
-       /* Hack -- simulate floating point computations */
-       if (randint0(4) < extra) stand++;
-
-
-       /* Choose an "interesting" value */
-       value = randnor(bonus, stand);
-
-       /* Enforce the minimum value */
-       if (value < 0) return (0);
-
-       /* Enforce the maximum value */
-       if (value > max) return (max);
-       return (value);
-}
-
-
-/*!
  * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
  * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
  * @return なし
index 179b8d9..5f51f57 100644 (file)
@@ -2,6 +2,7 @@
 #include "angband.h"
 #include "artifact.h"
 #include "spells-object.h"
+#include "object-boost.h"
 #include "object-hook.h"
 #include "player-status.h"
 #include "avatar.h"
index a3f462e..daabd33 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "angband.h"
 #include "floor.h"
+#include "object-boost.h"
 #include "object-hook.h"
 #include "melee.h"
 #include "player-status.h"