From 863a51065492ae85f4678f6494d4415aacd5c405 Mon Sep 17 00:00:00 2001 From: Deskull Date: Sun, 9 Sep 2018 14:13:28 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=E3=80=80=E3=83=97=E3=83=AC?= =?utf8?q?=E3=82=A4=E3=83=A4=E3=83=BC=E3=81=AE=E5=8F=AC=E5=96=9A=E5=87=A6?= =?utf8?q?=E7=90=86=E3=82=92=20cmd-spell.c=20=E3=81=8B=E3=82=89=20spells-s?= =?utf8?q?ummon.c/h=20=E3=81=B8=E5=88=86=E9=9B=A2=E3=80=82=20Separate=20pl?= =?utf8?q?ayer's=20summoning=20from=20cmd-spell.c=20to=20spells-summon.c/h?= =?utf8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Hengband_vcs2015/Hengband/Hengband.vcxproj | 2 + Hengband_vcs2015/Hengband/Hengband.vcxproj.filters | 6 + src/cmd-spell.c | 159 +-------------------- src/externs.h | 2 +- src/spells-summon.c | 141 ++++++++++++++++++ src/spells-summon.h | 3 + src/spells1.c | 17 +++ 7 files changed, 171 insertions(+), 159 deletions(-) create mode 100644 src/spells-summon.c create mode 100644 src/spells-summon.h diff --git a/Hengband_vcs2015/Hengband/Hengband.vcxproj b/Hengband_vcs2015/Hengband/Hengband.vcxproj index 39e744e2a..d55461a3e 100644 --- a/Hengband_vcs2015/Hengband/Hengband.vcxproj +++ b/Hengband_vcs2015/Hengband/Hengband.vcxproj @@ -198,6 +198,7 @@ + @@ -241,6 +242,7 @@ + diff --git a/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters b/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters index 8fb443d6e..a8b2b0c36 100644 --- a/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters +++ b/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters @@ -238,6 +238,9 @@ Source + + Source + @@ -343,6 +346,9 @@ Header + + Header + diff --git a/src/cmd-spell.c b/src/cmd-spell.c index ed4ca8f34..5bf7a9789 100644 --- a/src/cmd-spell.c +++ b/src/cmd-spell.c @@ -9,6 +9,7 @@ #include "angband.h" #include "selfinfo.h" #include "cmd-quaff.h" +#include "spells-summon.h" /*! @@ -168,164 +169,6 @@ static cptr info_weight(int weight) /*! - * @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 トランプ魔法独自の召喚処理を行う / Handle summoning and failure of trump spells - * @param num summon_specific()関数を呼び出す回数 - * @param pet ペット化として召喚されるか否か - * @param y 召喚位置のy座標 - * @param x 召喚位置のx座標 - * @param lev 召喚レベル - * @param type 召喚条件ID - * @param mode モンスター生成条件フラグ - * @return モンスターが(敵対も含めて)召還されたならばTRUEを返す。 - */ -bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode) -{ - PLAYER_LEVEL plev = p_ptr->lev; - - MONSTER_IDX who; - int i; - bool success = FALSE; - - /* Default level */ - if (!lev) lev = plev * 2 / 3 + randint1(plev / 2); - - if (pet) - { - /* Become pet */ - mode |= PM_FORCE_PET; - - /* Only sometimes allow unique monster */ - if (mode & PM_ALLOW_UNIQUE) - { - /* Forbid often */ - if (randint1(50 + plev) >= plev / 10) - mode &= ~PM_ALLOW_UNIQUE; - } - - /* Player is who summons */ - who = -1; - } - else - { - /* Prevent taming, allow unique monster */ - mode |= PM_NO_PET; - - /* Behave as if they appear by themselfs */ - who = 0; - } - - for (i = 0; i < num; i++) - { - if (summon_specific(who, y, x, lev, type, mode)) - success = TRUE; - } - - if (!success) - { - msg_print(_("誰もあなたのカードの呼び声に答えない。", "Nobody answers to your Trump call.")); - } - - return success; -} - - - -/*! - * @brief 悪魔領域のグレーターデーモン召喚に利用可能な死体かどうかを返す。 / An "item_tester_hook" for offer - * @param o_ptr オブジェクト構造体の参照ポインタ - * @return 生贄に使用可能な死体ならばTRUEを返す。 - */ -static bool item_tester_offer(object_type *o_ptr) -{ - /* Flasks of oil are okay */ - if (o_ptr->tval != TV_CORPSE) return (FALSE); - - if (o_ptr->sval != SV_CORPSE) return (FALSE); - - if (my_strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE); - - /* Assume not okay */ - return (FALSE); -} - -/*! - * @brief 悪魔領域のグレーターデーモン召喚を処理する / Daemon spell Summon Greater Demon - * @return 処理を実行したならばTRUEを返す。 - */ -static bool cast_summon_greater_demon(void) -{ - PLAYER_LEVEL plev = p_ptr->lev; - OBJECT_IDX item; - cptr q, s; - int summon_lev; - object_type *o_ptr; - - item_tester_hook = item_tester_offer; - q = _("どの死体を捧げますか? ", "Sacrifice which corpse? "); - s = _("捧げられる死体を持っていない。", "You have nothing to scrifice."); - if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE; - - /* Get the item (in the pack) */ - if (item >= 0) - { - o_ptr = &inventory[item]; - } - - /* Get the item (on the floor) */ - else - { - o_ptr = &o_list[0 - item]; - } - - summon_lev = plev * 2 / 3 + r_info[o_ptr->pval].level; - - if (summon_specific(-1, p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET))) - { - msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone.")); - msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'")); - - /* Decrease the item (from the pack) */ - if (item >= 0) - { - inven_item_increase(item, -1); - inven_item_describe(item); - inven_item_optimize(item); - } - - /* Decrease the item (from the floor) */ - else - { - floor_item_increase(0 - item, -1); - floor_item_describe(0 - item); - floor_item_optimize(0 - item); - } - } - else - { - msg_print(_("悪魔は現れなかった。", "No Greater Demon arrive.")); - } - - return TRUE; -} - -/*! * @brief 歌の開始を処理する / Start singing if the player is a Bard * @param spell 領域魔法としてのID * @param song 魔法効果のID diff --git a/src/externs.h b/src/externs.h index cacc33767..7a019e271 100644 --- a/src/externs.h +++ b/src/externs.h @@ -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 index 000000000..b911fa2a8 --- /dev/null +++ b/src/spells-summon.c @@ -0,0 +1,141 @@ +#include "angband.h" + +/*! +* @brief ƒgƒ‰ƒ“ƒv–‚–@“ÆŽ©‚̏¢Š«ˆ—‚ðs‚¤ / Handle summoning and failure of trump spells +* @param num summon_specific()ŠÖ”‚ðŒÄ‚яo‚·‰ñ” +* @param pet ƒyƒbƒg‰»‚Æ‚µ‚ď¢Š«‚³‚ê‚é‚©”Û‚© +* @param y ¢Š«ˆÊ’u‚ÌyÀ•W +* @param x ¢Š«ˆÊ’u‚ÌxÀ•W +* @param lev ¢Š«ƒŒƒxƒ‹ +* @param type ¢Š«ðŒID +* @param mode ƒ‚ƒ“ƒXƒ^[¶¬ðŒƒtƒ‰ƒO +* @return ƒ‚ƒ“ƒXƒ^[‚ªi“G‘΂àŠÜ‚߂āj¢ŠÒ‚³‚ꂽ‚È‚ç‚ÎTRUE‚ð•Ô‚·B +*/ +bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode) +{ + PLAYER_LEVEL plev = p_ptr->lev; + + MONSTER_IDX who; + int i; + bool success = FALSE; + + /* Default level */ + if (!lev) lev = plev * 2 / 3 + randint1(plev / 2); + + if (pet) + { + /* Become pet */ + mode |= PM_FORCE_PET; + + /* Only sometimes allow unique monster */ + if (mode & PM_ALLOW_UNIQUE) + { + /* Forbid often */ + if (randint1(50 + plev) >= plev / 10) + mode &= ~PM_ALLOW_UNIQUE; + } + + /* Player is who summons */ + who = -1; + } + else + { + /* Prevent taming, allow unique monster */ + mode |= PM_NO_PET; + + /* Behave as if they appear by themselfs */ + who = 0; + } + + for (i = 0; i < num; i++) + { + if (summon_specific(who, y, x, lev, type, mode)) + success = TRUE; + } + + if (!success) + { + msg_print(_("’N‚à‚ ‚È‚½‚̃J[ƒh‚̌Ăѐº‚É“š‚¦‚È‚¢B", "Nobody answers to your Trump call.")); + } + + return success; +} + + + +/*! +* @brief ˆ«–‚—̈æ‚̃OƒŒ[ƒ^[ƒf[ƒ‚ƒ“¢Š«‚É—˜—p‰Â”\‚ÈŽ€‘Ì‚©‚Ç‚¤‚©‚ð•Ô‚·B / An "item_tester_hook" for offer +* @param o_ptr ƒIƒuƒWƒFƒNƒg\‘¢‘Ì‚ÌŽQÆƒ|ƒCƒ“ƒ^ +* @return ¶æтɎg—p‰Â”\‚ÈŽ€‘Ì‚È‚ç‚ÎTRUE‚ð•Ô‚·B +*/ +bool item_tester_offer(object_type *o_ptr) +{ + /* Flasks of oil are okay */ + if (o_ptr->tval != TV_CORPSE) return (FALSE); + if (o_ptr->sval != SV_CORPSE) return (FALSE); + + if (my_strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE); + + /* Assume not okay */ + return (FALSE); +} + +/*! +* @brief ˆ«–‚—̈æ‚̃OƒŒ[ƒ^[ƒf[ƒ‚ƒ“¢Š«‚ðˆ—‚·‚é / Daemon spell Summon Greater Demon +* @return ˆ—‚ðŽÀs‚µ‚½‚È‚ç‚ÎTRUE‚ð•Ô‚·B +*/ +bool cast_summon_greater_demon(void) +{ + PLAYER_LEVEL plev = p_ptr->lev; + OBJECT_IDX item; + cptr q, s; + int summon_lev; + object_type *o_ptr; + + item_tester_hook = item_tester_offer; + q = _("‚Ç‚ÌŽ€‘Ì‚ð•ù‚°‚Ü‚·‚©? ", "Sacrifice which corpse? "); + s = _("•ù‚°‚ç‚ê‚鎀‘Ì‚ðŽ‚Á‚Ä‚¢‚È‚¢B", "You have nothing to scrifice."); + if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE; + + /* Get the item (in the pack) */ + if (item >= 0) + { + o_ptr = &inventory[item]; + } + + /* Get the item (on the floor) */ + else + { + o_ptr = &o_list[0 - item]; + } + + summon_lev = plev * 2 / 3 + r_info[o_ptr->pval].level; + + if (summon_specific(-1, p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET))) + { + msg_print(_("—°‰©‚̈«L‚ª[–ž‚µ‚½B", "The area fills with a stench of sulphur and brimstone.")); + msg_print(_("u‚²—p‚Å‚²‚´‚¢‚Ü‚·‚©A‚²Žål—lv", "'What is thy bidding... Master?'")); + + /* Decrease the item (from the pack) */ + if (item >= 0) + { + inven_item_increase(item, -1); + inven_item_describe(item); + inven_item_optimize(item); + } + + /* Decrease the item (from the floor) */ + else + { + floor_item_increase(0 - item, -1); + floor_item_describe(0 - item); + floor_item_optimize(0 - item); + } + } + else + { + msg_print(_("ˆ«–‚‚ÍŒ»‚ê‚È‚©‚Á‚½B", "No Greater Demon arrive.")); + } + + return TRUE; +} diff --git a/src/spells-summon.h b/src/spells-summon.h new file mode 100644 index 000000000..257658612 --- /dev/null +++ b/src/spells-summon.h @@ -0,0 +1,3 @@ +extern bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode); +extern bool item_tester_offer(object_type *o_ptr); +extern bool cast_summon_greater_demon(void); diff --git a/src/spells1.c b/src/spells1.c index 50e789ceb..e35cf9660 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -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 配置した鏡リストの次を取得する / -- 2.11.0