• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisiona30679669a5a9c2fc49797085740c65d2af109f1 (tree)
Time2019-03-13 23:26:39
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #37353 object-boost 追加。 / Add object-boost.

Change Summary

Incremental Difference

--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj
@@ -157,6 +157,7 @@
157157 <ClCompile Include="..\..\src\monster-process.c" />
158158 <ClCompile Include="..\..\src\monster-status.c" />
159159 <ClCompile Include="..\..\src\monsterrace-hook.c" />
160+ <ClCompile Include="..\..\src\object-boost.c" />
160161 <ClCompile Include="..\..\src\object-curse.c" />
161162 <ClCompile Include="..\..\src\object-hook.c" />
162163 <ClCompile Include="..\..\src\objectkind-hook.c" />
@@ -301,6 +302,7 @@
301302 <ClInclude Include="..\..\src\monster.h" />
302303 <ClInclude Include="..\..\src\monsterrace-hook.h" />
303304 <ClInclude Include="..\..\src\mutation.h" />
305+ <ClInclude Include="..\..\src\object-boost.h" />
304306 <ClInclude Include="..\..\src\object-curse.h" />
305307 <ClInclude Include="..\..\src\object-hook.h" />
306308 <ClInclude Include="..\..\src\object-broken.h" />
--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
@@ -249,6 +249,9 @@
249249 <ClCompile Include="..\..\src\mspells4.c">
250250 <Filter>monster</Filter>
251251 </ClCompile>
252+ <ClCompile Include="..\..\src\object-boost.c">
253+ <Filter>object</Filter>
254+ </ClCompile>
252255 </ItemGroup>
253256 <ItemGroup>
254257 <ClInclude Include="..\..\src\angband.h" />
@@ -439,6 +442,9 @@
439442 <ClInclude Include="..\..\src\monster-status.h">
440443 <Filter>monster</Filter>
441444 </ClInclude>
445+ <ClInclude Include="..\..\src\object-boost.h">
446+ <Filter>object</Filter>
447+ </ClInclude>
442448 </ItemGroup>
443449 <ItemGroup>
444450 <ResourceCompile Include="..\..\src\angband.rc" />
--- a/src/externs.h
+++ b/src/externs.h
@@ -707,8 +707,6 @@ extern byte get_mspeed(monster_race *r_ptr);
707707 extern void monster_drop_carried_objects(monster_type *m_ptr);
708708
709709 /* object1.c */
710-extern int m_bonus(int max, DEPTH level);
711-
712710 extern void reset_visuals(void);
713711 extern void object_flags(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE]);
714712 extern void object_flags_known(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE]);
--- /dev/null
+++ b/src/object-boost.c
@@ -0,0 +1,85 @@
1+#include "angband.h"
2+#include "object-boost.h"
3+
4+/*!
5+ * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
6+ * Help determine an "enchantment bonus" for an object.
7+ * @param max ボーナス値の限度
8+ * @param level ボーナス値に加味する基準生成階
9+ * @return 算出されたボーナス値
10+ * @details
11+ * To avoid floating point but still provide a smooth distribution of bonuses,\n
12+ * we simply round the results of division in such a way as to "average" the\n
13+ * correct floating point value.\n
14+ *\n
15+ * This function has been changed. It uses "randnor()" to choose values from\n
16+ * a normal distribution, whose mean moves from zero towards the max as the\n
17+ * level increases, and whose standard deviation is equal to 1/4 of the max,\n
18+ * and whose values are forced to lie between zero and the max, inclusive.\n
19+ *\n
20+ * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
21+ * rare to get the "full" enchantment on an object, even a deep levels.\n
22+ *\n
23+ * It is always possible (albeit unlikely) to get the "full" enchantment.\n
24+ *\n
25+ * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
26+ *\n
27+ * N 0 1 2 3 4 5 6 7 8 9 10\n
28+ * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
29+ * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
30+ * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
31+ * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
32+ * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
33+ * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
34+ * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
35+ * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
36+ * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
37+ * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
38+ * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
39+ * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
40+ * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
41+ * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
42+ * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
43+ * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
44+ * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
45+ * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
46+ */
47+int m_bonus(int max, DEPTH level)
48+{
49+ int bonus, stand, extra, value;
50+
51+
52+ /* Paranoia -- enforce maximal "level" */
53+ if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
54+
55+
56+ /* The "bonus" moves towards the max */
57+ bonus = ((max * level) / MAX_DEPTH);
58+
59+ /* Hack -- determine fraction of error */
60+ extra = ((max * level) % MAX_DEPTH);
61+
62+ /* Hack -- simulate floating point computations */
63+ if (randint0(MAX_DEPTH) < extra) bonus++;
64+
65+
66+ /* The "stand" is equal to one quarter of the max */
67+ stand = (max / 4);
68+
69+ /* Hack -- determine fraction of error */
70+ extra = (max % 4);
71+
72+ /* Hack -- simulate floating point computations */
73+ if (randint0(4) < extra) stand++;
74+
75+
76+ /* Choose an "interesting" value */
77+ value = randnor(bonus, stand);
78+
79+ /* Enforce the minimum value */
80+ if (value < 0) return (0);
81+
82+ /* Enforce the maximum value */
83+ if (value > max) return (max);
84+ return (value);
85+}
--- /dev/null
+++ b/src/object-boost.h
@@ -0,0 +1,3 @@
1+#pragma once
2+extern int m_bonus(int max, DEPTH level);
3+
--- a/src/object2.c
+++ b/src/object2.c
@@ -12,6 +12,7 @@
1212 */
1313
1414 #include "angband.h"
15+#include "object-boost.h"
1516 #include "object-hook.h"
1617 #include "object-curse.h"
1718 #include "artifact.h"
@@ -1988,90 +1989,6 @@ void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
19881989
19891990
19901991 /*!
1991- * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
1992- * Help determine an "enchantment bonus" for an object.
1993- * @param max ボーナス値の限度
1994- * @param level ボーナス値に加味する基準生成階
1995- * @return 算出されたボーナス値
1996- * @details
1997- * To avoid floating point but still provide a smooth distribution of bonuses,\n
1998- * we simply round the results of division in such a way as to "average" the\n
1999- * correct floating point value.\n
2000- *\n
2001- * This function has been changed. It uses "randnor()" to choose values from\n
2002- * a normal distribution, whose mean moves from zero towards the max as the\n
2003- * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2004- * and whose values are forced to lie between zero and the max, inclusive.\n
2005- *\n
2006- * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2007- * rare to get the "full" enchantment on an object, even a deep levels.\n
2008- *\n
2009- * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2010- *\n
2011- * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2012- *\n
2013- * N 0 1 2 3 4 5 6 7 8 9 10\n
2014- * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2015- * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2016- * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2017- * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2018- * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2019- * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2020- * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2021- * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2022- * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2023- * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2024- * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2025- * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2026- * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2027- * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2028- * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2029- * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2030- * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2031- * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2032- */
2033-int m_bonus(int max, DEPTH level)
2034-{
2035- int bonus, stand, extra, value;
2036-
2037-
2038- /* Paranoia -- enforce maximal "level" */
2039- if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2040-
2041-
2042- /* The "bonus" moves towards the max */
2043- bonus = ((max * level) / MAX_DEPTH);
2044-
2045- /* Hack -- determine fraction of error */
2046- extra = ((max * level) % MAX_DEPTH);
2047-
2048- /* Hack -- simulate floating point computations */
2049- if (randint0(MAX_DEPTH) < extra) bonus++;
2050-
2051-
2052- /* The "stand" is equal to one quarter of the max */
2053- stand = (max / 4);
2054-
2055- /* Hack -- determine fraction of error */
2056- extra = (max % 4);
2057-
2058- /* Hack -- simulate floating point computations */
2059- if (randint0(4) < extra) stand++;
2060-
2061-
2062- /* Choose an "interesting" value */
2063- value = randnor(bonus, stand);
2064-
2065- /* Enforce the minimum value */
2066- if (value < 0) return (0);
2067-
2068- /* Enforce the maximum value */
2069- if (value > max) return (max);
2070- return (value);
2071-}
2072-
2073-
2074-/*!
20751992 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
20761993 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
20771994 * @return なし
--- a/src/spells-object.c
+++ b/src/spells-object.c
@@ -2,6 +2,7 @@
22 #include "angband.h"
33 #include "artifact.h"
44 #include "spells-object.h"
5+#include "object-boost.h"
56 #include "object-hook.h"
67 #include "player-status.h"
78 #include "avatar.h"
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -13,6 +13,7 @@
1313
1414 #include "angband.h"
1515 #include "floor.h"
16+#include "object-boost.h"
1617 #include "object-hook.h"
1718 #include "melee.h"
1819 #include "player-status.h"
Show on old repository browser