From f2867d61951199da47091e5f670ee5933570122f Mon Sep 17 00:00:00 2001 From: deskull Date: Tue, 5 Mar 2019 23:51:52 +0900 Subject: [PATCH] [Refactor] #37353 bless_weapon() and pulish_shield() to spells-object.c.c. --- src/externs.h | 2 - src/melee1.c | 2 +- src/realm-craft.c | 1 + src/spells-object.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++- src/spells-object.h | 2 + src/spells3.c | 200 ---------------------------------------------------- 6 files changed, 201 insertions(+), 204 deletions(-) diff --git a/src/externs.h b/src/externs.h index 050f5c805..f4f763bf1 100644 --- a/src/externs.h +++ b/src/externs.h @@ -974,8 +974,6 @@ extern bool mundane_spell(bool only_equip); extern bool identify_item(object_type *o_ptr); extern bool identify_fully(bool only_equip); extern bool recharge(int power); -extern bool bless_weapon(void); -extern bool pulish_shield(void); extern bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx); extern void display_spell_list(void); extern EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm); diff --git a/src/melee1.c b/src/melee1.c index 86c17da93..936a7f442 100644 --- a/src/melee1.c +++ b/src/melee1.c @@ -1,6 +1,6 @@ /*! * @file melee1.c - * @brief モンスターの打撃処理 / Monster attacks + * @brief 打撃処理 / Melee process. * @date 2014/01/17 * @author * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n diff --git a/src/realm-craft.c b/src/realm-craft.c index 3ecd1336c..9f11cf969 100644 --- a/src/realm-craft.c +++ b/src/realm-craft.c @@ -2,6 +2,7 @@ #include "cmd-spell.h" #include "selfinfo.h" #include "projection.h" +#include "spells-object.h" #include "spells-summon.h" #include "spells-status.h" #include "mutation.h" diff --git a/src/spells-object.c b/src/spells-object.c index 7e6687d17..179b8d9c9 100644 --- a/src/spells-object.c +++ b/src/spells-object.c @@ -703,7 +703,6 @@ bool curse_weapon_object(bool force, object_type *o_ptr) */ bool curse_weapon(bool force, int slot) { - /* Curse the weapon */ return curse_weapon_object(force, &inventory[slot]); } @@ -920,4 +919,201 @@ void phlogiston(void) p_ptr->update |= (PU_TORCH); } +/*! + * @brief 武器の祝福処理 / + * Bless a weapon + * @return ターン消費を要する処理を行ったならばTRUEを返す + */ +bool bless_weapon(void) +{ + OBJECT_IDX item; + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + GAME_TEXT o_name[MAX_NLEN]; + concptr q, s; + + /* Bless only weapons */ + item_tester_hook = object_is_weapon; + + q = _("どのアイテムを祝福しますか?", "Bless which weapon? "); + s = _("祝福できる武器がありません。", "You have weapon to bless."); + + o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT)); + if (!o_ptr) return FALSE; + + object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); + object_flags(o_ptr, flgs); + + if (object_is_cursed(o_ptr)) + { + if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) || + have_flag(flgs, TR_ADD_L_CURSE) || + have_flag(flgs, TR_ADD_H_CURSE) || + (o_ptr->curse_flags & TRC_PERMA_CURSE)) + { +#ifdef JP + msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name); +#else + msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name); +#endif + + return TRUE; + } + +#ifdef JP + msg_format("%s から邪悪なオーラが消えた。", o_name); +#else + msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name); +#endif + + + o_ptr->curse_flags = 0L; + + o_ptr->ident |= (IDENT_SENSE); + o_ptr->feeling = FEEL_NONE; + + /* Recalculate the bonuses */ + p_ptr->update |= (PU_BONUS); + p_ptr->window |= (PW_EQUIP); + } + + /* + * Next, we try to bless it. Artifacts have a 1/3 chance of + * being blessed, otherwise, the operation simply disenchants + * them, godly power negating the magic. Ok, the explanation + * is silly, but otherwise priests would always bless every + * artifact weapon they find. Ego weapons and normal weapons + * can be blessed automatically. + */ + if (have_flag(flgs, TR_BLESSED)) + { +#ifdef JP + msg_format("%s は既に祝福されている。", o_name); +#else + msg_format("%s %s %s blessed already.", + ((item >= 0) ? "Your" : "The"), o_name, + ((o_ptr->number > 1) ? "were" : "was")); +#endif + + return TRUE; + } + + if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3)) + { +#ifdef JP + msg_format("%sは輝いた!", o_name); +#else + msg_format("%s %s shine%s!", + ((item >= 0) ? "Your" : "The"), o_name, + ((o_ptr->number > 1) ? "" : "s")); +#endif + + add_flag(o_ptr->art_flags, TR_BLESSED); + o_ptr->discount = 99; + } + else + { + bool dis_happened = FALSE; + msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!")); + + /* Disenchant tohit */ + if (o_ptr->to_h > 0) + { + o_ptr->to_h--; + dis_happened = TRUE; + } + + if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--; + /* Disenchant todam */ + if (o_ptr->to_d > 0) + { + o_ptr->to_d--; + dis_happened = TRUE; + } + + if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--; + + /* Disenchant toac */ + if (o_ptr->to_a > 0) + { + o_ptr->to_a--; + dis_happened = TRUE; + } + + if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--; + + if (dis_happened) + { + msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air...")); + +#ifdef JP + msg_format("%s は劣化した!", o_name); +#else + msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name, + ((o_ptr->number > 1) ? "were" : "was")); +#endif + + } + } + + p_ptr->update |= (PU_BONUS); + p_ptr->window |= (PW_EQUIP | PW_PLAYER); + calc_android_exp(); + + return TRUE; +} + + +/*! + * @brief 盾磨き処理 / + * pulish shield + * @return ターン消費を要する処理を行ったならばTRUEを返す + */ +bool pulish_shield(void) +{ + OBJECT_IDX item; + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + GAME_TEXT o_name[MAX_NLEN]; + concptr q, s; + + /* Assume enchant weapon */ + item_tester_tval = TV_SHIELD; + + q = _("どの盾を磨きますか?", "Pulish which weapon? "); + s = _("磨く盾がありません。", "You have weapon to pulish."); + + o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT)); + if (!o_ptr) return FALSE; + + object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); + object_flags(o_ptr, flgs); + + if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) && + !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD)) + { +#ifdef JP + msg_format("%sは輝いた!", o_name); +#else + msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s")); +#endif + o_ptr->name2 = EGO_REFLECTION; + enchant(o_ptr, randint0(3) + 4, ENCH_TOAC); + + o_ptr->discount = 99; + chg_virtue(V_ENCHANT, 2); + + return TRUE; + } + else + { + if (flush_failure) flush(); + + msg_print(_("失敗した。", "Failed.")); + chg_virtue(V_ENCHANT, -2); + } + calc_android_exp(); + + return FALSE; +} diff --git a/src/spells-object.h b/src/spells-object.h index 0fff32213..c509d44d7 100644 --- a/src/spells-object.h +++ b/src/spells-object.h @@ -13,4 +13,6 @@ extern bool brand_bolts(void); extern bool perilous_secrets(player_type *creature_ptr); extern void get_bloody_moon_flags(object_type *o_ptr); extern void phlogiston(void); +extern bool bless_weapon(void); +extern bool pulish_shield(void); diff --git a/src/spells3.c b/src/spells3.c index fcaf7ad28..b9d0f3302 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -2702,206 +2702,6 @@ bool recharge(int power) /*! - * @brief 武器の祝福処理 / - * Bless a weapon - * @return ターン消費を要する処理を行ったならばTRUEを返す - */ -bool bless_weapon(void) -{ - OBJECT_IDX item; - object_type *o_ptr; - BIT_FLAGS flgs[TR_FLAG_SIZE]; - GAME_TEXT o_name[MAX_NLEN]; - concptr q, s; - - /* Bless only weapons */ - item_tester_hook = object_is_weapon; - - q = _("どのアイテムを祝福しますか?", "Bless which weapon? "); - s = _("祝福できる武器がありません。", "You have weapon to bless."); - - o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT)); - if (!o_ptr) return FALSE; - - object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); - object_flags(o_ptr, flgs); - - if (object_is_cursed(o_ptr)) - { - if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) || - have_flag(flgs, TR_ADD_L_CURSE) || - have_flag(flgs, TR_ADD_H_CURSE) || - (o_ptr->curse_flags & TRC_PERMA_CURSE)) - { -#ifdef JP - msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name); -#else - msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name); -#endif - - return TRUE; - } - -#ifdef JP - msg_format("%s から邪悪なオーラが消えた。", o_name); -#else - msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name); -#endif - - - o_ptr->curse_flags = 0L; - - o_ptr->ident |= (IDENT_SENSE); - o_ptr->feeling = FEEL_NONE; - - /* Recalculate the bonuses */ - p_ptr->update |= (PU_BONUS); - p_ptr->window |= (PW_EQUIP); - } - - /* - * Next, we try to bless it. Artifacts have a 1/3 chance of - * being blessed, otherwise, the operation simply disenchants - * them, godly power negating the magic. Ok, the explanation - * is silly, but otherwise priests would always bless every - * artifact weapon they find. Ego weapons and normal weapons - * can be blessed automatically. - */ - if (have_flag(flgs, TR_BLESSED)) - { -#ifdef JP - msg_format("%s は既に祝福されている。", o_name); -#else - msg_format("%s %s %s blessed already.", - ((item >= 0) ? "Your" : "The"), o_name, - ((o_ptr->number > 1) ? "were" : "was")); -#endif - - return TRUE; - } - - if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3)) - { -#ifdef JP - msg_format("%sは輝いた!", o_name); -#else - msg_format("%s %s shine%s!", - ((item >= 0) ? "Your" : "The"), o_name, - ((o_ptr->number > 1) ? "" : "s")); -#endif - - add_flag(o_ptr->art_flags, TR_BLESSED); - o_ptr->discount = 99; - } - else - { - bool dis_happened = FALSE; - msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!")); - - /* Disenchant tohit */ - if (o_ptr->to_h > 0) - { - o_ptr->to_h--; - dis_happened = TRUE; - } - - if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--; - - /* Disenchant todam */ - if (o_ptr->to_d > 0) - { - o_ptr->to_d--; - dis_happened = TRUE; - } - - if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--; - - /* Disenchant toac */ - if (o_ptr->to_a > 0) - { - o_ptr->to_a--; - dis_happened = TRUE; - } - - if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--; - - if (dis_happened) - { - msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air...")); - -#ifdef JP - msg_format("%s は劣化した!", o_name); -#else - msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name, - ((o_ptr->number > 1) ? "were" : "was")); -#endif - - } - } - - p_ptr->update |= (PU_BONUS); - p_ptr->window |= (PW_EQUIP | PW_PLAYER); - calc_android_exp(); - - return TRUE; -} - - -/*! - * @brief 盾磨き処理 / - * pulish shield - * @return ターン消費を要する処理を行ったならばTRUEを返す - */ -bool pulish_shield(void) -{ - OBJECT_IDX item; - object_type *o_ptr; - BIT_FLAGS flgs[TR_FLAG_SIZE]; - GAME_TEXT o_name[MAX_NLEN]; - concptr q, s; - - /* Assume enchant weapon */ - item_tester_tval = TV_SHIELD; - - q = _("どの盾を磨きますか?", "Pulish which weapon? "); - s = _("磨く盾がありません。", "You have weapon to pulish."); - - o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT)); - if (!o_ptr) return FALSE; - - object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); - object_flags(o_ptr, flgs); - - if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) && - !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD)) - { -#ifdef JP - msg_format("%sは輝いた!", o_name); -#else - msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s")); -#endif - o_ptr->name2 = EGO_REFLECTION; - enchant(o_ptr, randint0(3) + 4, ENCH_TOAC); - - o_ptr->discount = 99; - chg_virtue(V_ENCHANT, 2); - - return TRUE; - } - else - { - if (flush_failure) flush(); - - msg_print(_("失敗した。", "Failed.")); - chg_virtue(V_ENCHANT, -2); - } - calc_android_exp(); - - return FALSE; -} - - -/*! * @brief 薬の破損効果処理 / * Potions "smash open" and cause an area effect when * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID) -- 2.11.0