OSDN Git Service

[Refactor] #37353 プレイヤーの召喚処理を cmd-spell.c から spells-summon.c/h へ分離。
authorDeskull <deskull@users.sourceforge.jp>
Sun, 9 Sep 2018 05:13:28 +0000 (14:13 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Sun, 9 Sep 2018 05:13:28 +0000 (14:13 +0900)
Separate player's summoning from cmd-spell.c to spells-summon.c/h.

Hengband_vcs2015/Hengband/Hengband.vcxproj
Hengband_vcs2015/Hengband/Hengband.vcxproj.filters
src/cmd-spell.c
src/externs.h
src/spells-summon.c [new file with mode: 0644]
src/spells-summon.h [new file with mode: 0644]
src/spells1.c

index 39e744e..d55461a 100644 (file)
     <ClCompile Include="..\..\src\scores.c" />\r
     <ClCompile Include="..\..\src\selfinfo.c" />\r
     <ClCompile Include="..\..\src\snipe.c" />\r
+    <ClCompile Include="..\..\src\spells-summon.c" />\r
     <ClCompile Include="..\..\src\spells1.c" />\r
     <ClCompile Include="..\..\src\spells2.c" />\r
     <ClCompile Include="..\..\src\spells3.c" />\r
     <ClInclude Include="..\..\src\readdib.h" />\r
     <ClInclude Include="..\..\src\rooms.h" />\r
     <ClInclude Include="..\..\src\selfinfo.h" />\r
+    <ClInclude Include="..\..\src\spells-summon.h" />\r
     <ClInclude Include="..\..\src\streams.h" />\r
     <ClInclude Include="..\..\src\types.h" />\r
     <ClInclude Include="..\..\src\z-config.h" />\r
index 8fb443d..a8b2b0c 100644 (file)
     <ClCompile Include="..\..\src\chest.c">\r
       <Filter>Source</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\src\spells-summon.c">\r
+      <Filter>Source</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\src\angband.h">\r
     <ClInclude Include="..\..\src\chest.h">\r
       <Filter>Header</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\src\spells-summon.h">\r
+      <Filter>Header</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ResourceCompile Include="..\..\src\angband.rc" />\r
index ed4ca8f..5bf7a97 100644 (file)
@@ -9,6 +9,7 @@
 #include "angband.h"\r
 #include "selfinfo.h"\r
 #include "cmd-quaff.h"\r
+#include "spells-summon.h"\r
 \r
 \r
 /*!\r
@@ -168,164 +169,6 @@ static cptr info_weight(int weight)
 \r
 \r
 /*!\r
- * @brief 一部ボルト魔法のビーム化確率を算出する / Prepare standard probability to become beam for fire_bolt_or_beam()\r
- * @return ビーム化確率(%)\r
- * @details\r
- * ハードコーティングによる実装が行われている。\r
- * メイジは(レベル)%、ハイメイジ、スペルマスターは(レベル)%、それ以外の職業は(レベル/2)%\r
- */\r
-int beam_chance(void)\r
-{\r
-       if (p_ptr->pclass == CLASS_MAGE)\r
-               return p_ptr->lev;\r
-       if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER)\r
-               return p_ptr->lev + 10;\r
-\r
-       return p_ptr->lev / 2;\r
-}\r
-\r
-/*!\r
- * @brief トランプ魔法独自の召喚処理を行う / Handle summoning and failure of trump spells\r
- * @param num summon_specific()関数を呼び出す回数\r
- * @param pet ペット化として召喚されるか否か\r
- * @param y 召喚位置のy座標\r
- * @param x 召喚位置のx座標\r
- * @param lev 召喚レベル\r
- * @param type 召喚条件ID\r
- * @param mode モンスター生成条件フラグ\r
- * @return モンスターが(敵対も含めて)召還されたならばTRUEを返す。\r
- */\r
-bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode)\r
-{\r
-       PLAYER_LEVEL plev = p_ptr->lev;\r
-\r
-       MONSTER_IDX who;\r
-       int i;\r
-       bool success = FALSE;\r
-\r
-       /* Default level */\r
-       if (!lev) lev = plev * 2 / 3 + randint1(plev / 2);\r
-\r
-       if (pet)\r
-       {\r
-               /* Become pet */\r
-               mode |= PM_FORCE_PET;\r
-\r
-               /* Only sometimes allow unique monster */\r
-               if (mode & PM_ALLOW_UNIQUE)\r
-               {\r
-                       /* Forbid often */\r
-                       if (randint1(50 + plev) >= plev / 10)\r
-                               mode &= ~PM_ALLOW_UNIQUE;\r
-               }\r
-\r
-               /* Player is who summons */\r
-               who = -1;\r
-       }\r
-       else\r
-       {\r
-               /* Prevent taming, allow unique monster */\r
-               mode |= PM_NO_PET;\r
-\r
-               /* Behave as if they appear by themselfs */\r
-               who = 0;\r
-       }\r
-\r
-       for (i = 0; i < num; i++)\r
-       {\r
-               if (summon_specific(who, y, x, lev, type, mode))\r
-                       success = TRUE;\r
-       }\r
-\r
-       if (!success)\r
-       {\r
-               msg_print(_("誰もあなたのカードの呼び声に答えない。", "Nobody answers to your Trump call."));\r
-       }\r
-\r
-       return success;\r
-}\r
-\r
-\r
-\r
-/*!\r
- * @brief 悪魔領域のグレーターデーモン召喚に利用可能な死体かどうかを返す。 / An "item_tester_hook" for offer\r
- * @param o_ptr オブジェクト構造体の参照ポインタ\r
- * @return 生贄に使用可能な死体ならばTRUEを返す。\r
- */\r
-static bool item_tester_offer(object_type *o_ptr)\r
-{\r
-       /* Flasks of oil are okay */\r
-       if (o_ptr->tval != TV_CORPSE) return (FALSE);\r
-\r
-       if (o_ptr->sval != SV_CORPSE) return (FALSE);\r
-\r
-       if (my_strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE);\r
-\r
-       /* Assume not okay */\r
-       return (FALSE);\r
-}\r
-\r
-/*!\r
- * @brief 悪魔領域のグレーターデーモン召喚を処理する / Daemon spell Summon Greater Demon\r
- * @return 処理を実行したならばTRUEを返す。\r
- */\r
-static bool cast_summon_greater_demon(void)\r
-{\r
-       PLAYER_LEVEL plev = p_ptr->lev;\r
-       OBJECT_IDX item;\r
-       cptr q, s;\r
-       int summon_lev;\r
-       object_type *o_ptr;\r
-\r
-       item_tester_hook = item_tester_offer;\r
-       q = _("どの死体を捧げますか? ", "Sacrifice which corpse? ");\r
-       s = _("捧げられる死体を持っていない。", "You have nothing to scrifice.");\r
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;\r
-\r
-       /* Get the item (in the pack) */\r
-       if (item >= 0)\r
-       {\r
-               o_ptr = &inventory[item];\r
-       }\r
-\r
-       /* Get the item (on the floor) */\r
-       else\r
-       {\r
-               o_ptr = &o_list[0 - item];\r
-       }\r
-\r
-       summon_lev = plev * 2 / 3 + r_info[o_ptr->pval].level;\r
-\r
-       if (summon_specific(-1, p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET)))\r
-       {\r
-               msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));\r
-               msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'"));\r
-\r
-               /* Decrease the item (from the pack) */\r
-               if (item >= 0)\r
-               {\r
-                       inven_item_increase(item, -1);\r
-                       inven_item_describe(item);\r
-                       inven_item_optimize(item);\r
-               }\r
-\r
-               /* Decrease the item (from the floor) */\r
-               else\r
-               {\r
-                       floor_item_increase(0 - item, -1);\r
-                       floor_item_describe(0 - item);\r
-                       floor_item_optimize(0 - item);\r
-               }\r
-       }\r
-       else\r
-       {\r
-               msg_print(_("悪魔は現れなかった。", "No Greater Demon arrive."));\r
-       }\r
-\r
-       return TRUE;\r
-}\r
-\r
-/*!\r
  * @brief 歌の開始を処理する / Start singing if the player is a Bard \r
  * @param spell 領域魔法としてのID\r
  * @param song 魔法効果のID\r
index cacc337..7a019e2 100644 (file)
@@ -807,7 +807,6 @@ extern void do_cmd_pet(void);
 extern void stop_singing(void);
 extern cptr do_spell(REALM_IDX realm, SPELL_IDX spell, BIT_FLAGS mode);
 extern bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode);
-extern int beam_chance(void);
 
 /* dungeon.c */
 extern void leave_quest_check(void);
@@ -1078,6 +1077,7 @@ extern void remove_loc(void);
 extern bool save_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode);
 
 /* spells1.c */
+extern int beam_chance(void);
 extern bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2);
 extern void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *gy, POSITION *gm, POSITION *pgm_rad, POSITION rad, POSITION y1, POSITION x1, POSITION y2, POSITION x2, int typ);
 extern int take_hit(int damage_type, HIT_POINT damage, cptr kb_str, int monspell);
diff --git a/src/spells-summon.c b/src/spells-summon.c
new file mode 100644 (file)
index 0000000..b911fa2
--- /dev/null
@@ -0,0 +1,141 @@
+#include "angband.h"\r
+\r
+/*!\r
+* @brief \83g\83\89\83\93\83v\96\82\96@\93Æ\8e©\82Ì\8f¢\8a«\8f\88\97\9d\82ð\8ds\82¤ / Handle summoning and failure of trump spells\r
+* @param num summon_specific()\8aÖ\90\94\82ð\8cÄ\82Ñ\8fo\82·\89ñ\90\94\r
+* @param pet \83y\83b\83g\89»\82Æ\82µ\82Ä\8f¢\8a«\82³\82ê\82é\82©\94Û\82©\r
+* @param y \8f¢\8a«\88Ê\92u\82Ìy\8dÀ\95W\r
+* @param x \8f¢\8a«\88Ê\92u\82Ìx\8dÀ\95W\r
+* @param lev \8f¢\8a«\83\8c\83x\83\8b\r
+* @param type \8f¢\8a«\8fð\8c\8fID\r
+* @param mode \83\82\83\93\83X\83^\81[\90\90¬\8fð\8c\8f\83t\83\89\83O\r
+* @return \83\82\83\93\83X\83^\81[\82ª\81i\93G\91Î\82à\8aÜ\82ß\82Ä\81j\8f¢\8aÒ\82³\82ê\82½\82È\82ç\82ÎTRUE\82ð\95Ô\82·\81B\r
+*/\r
+bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode)\r
+{\r
+       PLAYER_LEVEL plev = p_ptr->lev;\r
+\r
+       MONSTER_IDX who;\r
+       int i;\r
+       bool success = FALSE;\r
+\r
+       /* Default level */\r
+       if (!lev) lev = plev * 2 / 3 + randint1(plev / 2);\r
+\r
+       if (pet)\r
+       {\r
+               /* Become pet */\r
+               mode |= PM_FORCE_PET;\r
+\r
+               /* Only sometimes allow unique monster */\r
+               if (mode & PM_ALLOW_UNIQUE)\r
+               {\r
+                       /* Forbid often */\r
+                       if (randint1(50 + plev) >= plev / 10)\r
+                               mode &= ~PM_ALLOW_UNIQUE;\r
+               }\r
+\r
+               /* Player is who summons */\r
+               who = -1;\r
+       }\r
+       else\r
+       {\r
+               /* Prevent taming, allow unique monster */\r
+               mode |= PM_NO_PET;\r
+\r
+               /* Behave as if they appear by themselfs */\r
+               who = 0;\r
+       }\r
+\r
+       for (i = 0; i < num; i++)\r
+       {\r
+               if (summon_specific(who, y, x, lev, type, mode))\r
+                       success = TRUE;\r
+       }\r
+\r
+       if (!success)\r
+       {\r
+               msg_print(_("\92N\82à\82 \82È\82½\82Ì\83J\81[\83h\82Ì\8cÄ\82Ñ\90º\82É\93\9a\82¦\82È\82¢\81B", "Nobody answers to your Trump call."));\r
+       }\r
+\r
+       return success;\r
+}\r
+\r
+\r
+\r
+/*!\r
+* @brief \88«\96\82\97Ì\88æ\82Ì\83O\83\8c\81[\83^\81[\83f\81[\83\82\83\93\8f¢\8a«\82É\97\98\97p\89Â\94\\82È\8e\80\91Ì\82©\82Ç\82¤\82©\82ð\95Ô\82·\81B / An "item_tester_hook" for offer\r
+* @param o_ptr \83I\83u\83W\83F\83N\83g\8d\\91¢\91Ì\82Ì\8eQ\8fÆ\83|\83C\83\93\83^\r
+* @return \90¶æÑ\82É\8eg\97p\89Â\94\\82È\8e\80\91Ì\82È\82ç\82ÎTRUE\82ð\95Ô\82·\81B\r
+*/\r
+bool item_tester_offer(object_type *o_ptr)\r
+{\r
+       /* Flasks of oil are okay */\r
+       if (o_ptr->tval != TV_CORPSE) return (FALSE);\r
+       if (o_ptr->sval != SV_CORPSE) return (FALSE);\r
+\r
+       if (my_strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE);\r
+\r
+       /* Assume not okay */\r
+       return (FALSE);\r
+}\r
+\r
+/*!\r
+* @brief \88«\96\82\97Ì\88æ\82Ì\83O\83\8c\81[\83^\81[\83f\81[\83\82\83\93\8f¢\8a«\82ð\8f\88\97\9d\82·\82é / Daemon spell Summon Greater Demon\r
+* @return \8f\88\97\9d\82ð\8eÀ\8ds\82µ\82½\82È\82ç\82ÎTRUE\82ð\95Ô\82·\81B\r
+*/\r
+bool cast_summon_greater_demon(void)\r
+{\r
+       PLAYER_LEVEL plev = p_ptr->lev;\r
+       OBJECT_IDX item;\r
+       cptr q, s;\r
+       int summon_lev;\r
+       object_type *o_ptr;\r
+\r
+       item_tester_hook = item_tester_offer;\r
+       q = _("\82Ç\82Ì\8e\80\91Ì\82ð\95ù\82°\82Ü\82·\82©? ", "Sacrifice which corpse? ");\r
+       s = _("\95ù\82°\82ç\82ê\82é\8e\80\91Ì\82ð\8e\9d\82Á\82Ä\82¢\82È\82¢\81B", "You have nothing to scrifice.");\r
+       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;\r
+\r
+       /* Get the item (in the pack) */\r
+       if (item >= 0)\r
+       {\r
+               o_ptr = &inventory[item];\r
+       }\r
+\r
+       /* Get the item (on the floor) */\r
+       else\r
+       {\r
+               o_ptr = &o_list[0 - item];\r
+       }\r
+\r
+       summon_lev = plev * 2 / 3 + r_info[o_ptr->pval].level;\r
+\r
+       if (summon_specific(-1, p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET)))\r
+       {\r
+               msg_print(_("\97°\89©\82Ì\88«\8fL\82ª\8f[\96\9e\82µ\82½\81B", "The area fills with a stench of sulphur and brimstone."));\r
+               msg_print(_("\81u\82²\97p\82Å\82²\82´\82¢\82Ü\82·\82©\81A\82²\8eå\90l\97l\81v", "'What is thy bidding... Master?'"));\r
+\r
+               /* Decrease the item (from the pack) */\r
+               if (item >= 0)\r
+               {\r
+                       inven_item_increase(item, -1);\r
+                       inven_item_describe(item);\r
+                       inven_item_optimize(item);\r
+               }\r
+\r
+               /* Decrease the item (from the floor) */\r
+               else\r
+               {\r
+                       floor_item_increase(0 - item, -1);\r
+                       floor_item_describe(0 - item);\r
+                       floor_item_optimize(0 - item);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               msg_print(_("\88«\96\82\82Í\8c»\82ê\82È\82©\82Á\82½\81B", "No Greater Demon arrive."));\r
+       }\r
+\r
+       return TRUE;\r
+}\r
diff --git a/src/spells-summon.h b/src/spells-summon.h
new file mode 100644 (file)
index 0000000..2576586
--- /dev/null
@@ -0,0 +1,3 @@
+extern bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode);\r
+extern bool item_tester_offer(object_type *o_ptr);\r
+extern bool cast_summon_greater_demon(void);\r
index 50e789c..e35cf96 100644 (file)
@@ -78,6 +78,23 @@ static bool_hack common_saving_throw_control(player_type *player_ptr, HIT_POINT
        return (r_ptr->level > randint1((pow - 10) < 1 ? 1 : (pow - 10)) + 5);
 }
 
+/*!
+* @brief 一部ボルト魔法のビーム化確率を算出する / Prepare standard probability to become beam for fire_bolt_or_beam()
+* @return ビーム化確率(%)
+* @details
+* ハードコーティングによる実装が行われている。
+* メイジは(レベル)%、ハイメイジ、スペルマスターは(レベル)%、それ以外の職業は(レベル/2)%
+*/
+int beam_chance(void)
+{
+       if (p_ptr->pclass == CLASS_MAGE)
+               return p_ptr->lev;
+       if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER)
+               return p_ptr->lev + 10;
+
+       return p_ptr->lev / 2;
+}
+
 
 /*!
  * @brief 配置した鏡リストの次を取得する /