• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

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


Commit MetaInfo

Revision0fc2cee314349fef6578de267570041b71df41f7 (tree)
Time2019-02-02 16:31:12
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Refactor] #37353 amusement() を spell-object.c に移動。 / Move amusement() to spells-object.c.

Change Summary

Incremental Difference

--- a/src/cmd-read.c
+++ b/src/cmd-read.c
@@ -8,14 +8,16 @@
88
99 #include "angband.h"
1010 #include "object-hook.h"
11-#include "spells-summon.h"
1211 #include "artifact.h"
1312 #include "avatar.h"
1413 #include "player-status.h"
15-#include "spells-status.h"
1614 #include "rumor.h"
1715 #include "realm-hex.h"
1816
17+#include "spells-object.h"
18+#include "spells-summon.h"
19+#include "spells-status.h"
20+
1921 /*!
2022 * @brief 巻物を読むコマンドのサブルーチン
2123 * Read a scroll (from the pack or floor).
--- a/src/externs.h
+++ b/src/externs.h
@@ -822,7 +822,6 @@ extern bool make_gold(object_type *j_ptr);
822822 extern void place_gold(POSITION y, POSITION x);
823823 extern OBJECT_IDX drop_near(object_type *o_ptr, PERCENTAGE chance, POSITION y, POSITION x);
824824 extern void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known);
825-extern void amusement(POSITION y1, POSITION x1, int num, bool known);
826825 extern void inven_item_charges(INVENTORY_IDX item);
827826 extern void inven_item_describe(INVENTORY_IDX item);
828827 extern void inven_item_increase(INVENTORY_IDX item, ITEM_NUMBER num);
--- a/src/object2.c
+++ b/src/object2.c
@@ -5414,129 +5414,6 @@ void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bo
54145414 }
54155415 }
54165416
5417-/*
5418- * Scatter some "amusing" objects near the player
5419- */
5420-
5421-#define AMS_NOTHING 0x00 /* No restriction */
5422-#define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5423-#define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5424-#define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5425-#define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5426-
5427-typedef struct
5428-{
5429- OBJECT_TYPE_VALUE tval;
5430- OBJECT_SUBTYPE_VALUE sval;
5431- PERCENTAGE prob;
5432- byte flag;
5433-} amuse_type;
5434-
5435-amuse_type amuse_info[] =
5436-{
5437- { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5438- { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5439- { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5440- { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5441- { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5442- { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5443- { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5444- { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5445- { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5446- { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5447- { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5448- { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5449- { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5450-
5451- { 0, 0, 0 }
5452-};
5453-
5454-/*!
5455- * @brief 誰得ドロップを行う。
5456- * @param y1 配置したいフロアのY座標
5457- * @param x1 配置したいフロアのX座標
5458- * @param num 誰得の処理回数
5459- * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5460- * @return なし
5461- */
5462-void amusement(POSITION y1, POSITION x1, int num, bool known)
5463-{
5464- object_type *i_ptr;
5465- object_type object_type_body;
5466- int n, t = 0;
5467-
5468- for (n = 0; amuse_info[n].tval != 0; n++)
5469- {
5470- t += amuse_info[n].prob;
5471- }
5472-
5473- /* Acquirement */
5474- while (num)
5475- {
5476- int i;
5477- KIND_OBJECT_IDX k_idx;
5478- ARTIFACT_IDX a_idx = 0;
5479- int r = randint0(t);
5480- bool insta_art, fixed_art;
5481-
5482- for (i = 0; ; i++)
5483- {
5484- r -= amuse_info[i].prob;
5485- if (r <= 0) break;
5486- }
5487- i_ptr = &object_type_body;
5488- object_wipe(i_ptr);
5489- k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5490-
5491- /* Paranoia - reroll if nothing */
5492- if (!k_idx) continue;
5493-
5494- /* Search an artifact index if need */
5495- insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5496- fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5497-
5498- if (insta_art || fixed_art)
5499- {
5500- for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5501- {
5502- if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5503- if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5504- if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5505- if (a_info[a_idx].cur_num > 0) continue;
5506- break;
5507- }
5508-
5509- if (a_idx >= max_a_idx) continue;
5510- }
5511-
5512- /* Make an object (if possible) */
5513- object_prep(i_ptr, k_idx);
5514- if (a_idx) i_ptr->name1 = a_idx;
5515- apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5516-
5517- if (amuse_info[i].flag & AMS_NO_UNIQUE)
5518- {
5519- if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5520- }
5521-
5522- if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5523- if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5524-
5525- if (known)
5526- {
5527- object_aware(i_ptr);
5528- object_known(i_ptr);
5529- }
5530-
5531- /* Paranoia - reroll if nothing */
5532- if (!(i_ptr->k_idx)) continue;
5533-
5534- /* Drop the object */
5535- (void)drop_near(i_ptr, -1, y1, x1);
5536-
5537- num--;
5538- }
5539-}
55405417
55415418
55425419 /*!
--- a/src/spells-object.c
+++ b/src/spells-object.c
@@ -4,6 +4,44 @@
44 #include "object-hook.h"
55 #include "player-status.h"
66
7+
8+typedef struct
9+{
10+ OBJECT_TYPE_VALUE tval;
11+ OBJECT_SUBTYPE_VALUE sval;
12+ PERCENTAGE prob;
13+ byte flag;
14+} amuse_type;
15+
16+/*
17+ * Scatter some "amusing" objects near the player
18+ */
19+
20+#define AMS_NOTHING 0x00 /* No restriction */
21+#define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
22+#define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
23+#define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
24+#define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
25+
26+static amuse_type amuse_info[] =
27+{
28+ { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
29+ { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
30+ { TV_SPIKE, SV_ANY, 10, AMS_PILE },
31+ { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
32+ { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
33+ { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
34+ { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
35+ { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
36+ { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
37+ { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
38+ { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
39+ { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
40+ { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
41+
42+ { 0, 0, 0 }
43+};
44+
745 /*!
846 * @brief「弾/矢の製造」処理 / do_cmd_cast calls this function if the player's class is 'archer'.
947 * Hook to determine if an object is contertible in an arrow/bolt
@@ -302,3 +340,90 @@ bool import_magic_device(void)
302340 take_turn(p_ptr, 100);;
303341 return TRUE;
304342 }
343+
344+/*!
345+ * @brief 誰得ドロップを行う。
346+ * @param y1 配置したいフロアのY座標
347+ * @param x1 配置したいフロアのX座標
348+ * @param num 誰得の処理回数
349+ * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
350+ * @return なし
351+ */
352+void amusement(POSITION y1, POSITION x1, int num, bool known)
353+{
354+ object_type *i_ptr;
355+ object_type object_type_body;
356+ int n, t = 0;
357+
358+ for (n = 0; amuse_info[n].tval != 0; n++)
359+ {
360+ t += amuse_info[n].prob;
361+ }
362+
363+ /* Acquirement */
364+ while (num)
365+ {
366+ int i;
367+ KIND_OBJECT_IDX k_idx;
368+ ARTIFACT_IDX a_idx = 0;
369+ int r = randint0(t);
370+ bool insta_art, fixed_art;
371+
372+ for (i = 0; ; i++)
373+ {
374+ r -= amuse_info[i].prob;
375+ if (r <= 0) break;
376+ }
377+ i_ptr = &object_type_body;
378+ object_wipe(i_ptr);
379+ k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
380+
381+ /* Paranoia - reroll if nothing */
382+ if (!k_idx) continue;
383+
384+ /* Search an artifact index if need */
385+ insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
386+ fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
387+
388+ if (insta_art || fixed_art)
389+ {
390+ for (a_idx = 1; a_idx < max_a_idx; a_idx++)
391+ {
392+ if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
393+ if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
394+ if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
395+ if (a_info[a_idx].cur_num > 0) continue;
396+ break;
397+ }
398+
399+ if (a_idx >= max_a_idx) continue;
400+ }
401+
402+ /* Make an object (if possible) */
403+ object_prep(i_ptr, k_idx);
404+ if (a_idx) i_ptr->name1 = a_idx;
405+ apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
406+
407+ if (amuse_info[i].flag & AMS_NO_UNIQUE)
408+ {
409+ if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
410+ }
411+
412+ if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
413+ if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
414+
415+ if (known)
416+ {
417+ object_aware(i_ptr);
418+ object_known(i_ptr);
419+ }
420+
421+ /* Paranoia - reroll if nothing */
422+ if (!(i_ptr->k_idx)) continue;
423+
424+ /* Drop the object */
425+ (void)drop_near(i_ptr, -1, y1, x1);
426+
427+ num--;
428+ }
429+}
--- a/src/spells-object.h
+++ b/src/spells-object.h
@@ -2,3 +2,4 @@
22
33 extern bool create_ammo(void);
44 extern bool import_magic_device(void);
5+extern void amusement(POSITION y1, POSITION x1, int num, bool known);
Show on old repository browser