X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fobject-enchant%2Fapply-magic.c;h=e81baeee9f3cd9edfdab6275f739e9ebec9e0ecf;hb=50697ffd12bf8e29359341dd57b02e0c5c29a122;hp=71b1c78c0ad3fc66ddbae0efeef3f89275ab3129;hpb=50ad3428cd44e6bdf8c2611e912bdacab1e30d7a;p=hengband%2Fhengband.git diff --git a/src/object-enchant/apply-magic.c b/src/object-enchant/apply-magic.c index 71b1c78c0..e81baeee9 100644 --- a/src/object-enchant/apply-magic.c +++ b/src/object-enchant/apply-magic.c @@ -6,15 +6,14 @@ */ #include "object-enchant/apply-magic.h" +#include "artifact/fixed-art-types.h" #include "artifact/fixed-art-generator.h" -#include "art-definition/art-armor-types.h" #include "dungeon/dungeon.h" #include "mutation/mutation-flag-types.h" #include "object-enchant/apply-magic-accessory.h" #include "object-enchant/apply-magic-armor.h" #include "object-enchant/apply-magic-others.h" #include "object-enchant/apply-magic-weapon.h" -#include "system/artifact-type-definition.h" #include "object-enchant/item-apply-magic.h" #include "object-enchant/object-boost.h" #include "object-enchant/object-curse.h" @@ -26,14 +25,30 @@ #include "object-hook/hook-checker.h" #include "object-hook/hook-enchant.h" #include "object/object-kind.h" +#include "player/player-status-flags.h" #include "sv-definition/sv-armor-types.h" #include "sv-definition/sv-protector-types.h" #include "sv-definition/sv-weapon-types.h" +#include "system/artifact-type-definition.h" #include "system/floor-type-definition.h" #include "util/bit-flags-calculator.h" #include "world/world.h" -#include "player/player-status-flags.h" +/*! + * @brief 0 および負数に対応した randint1() + * @param n + * + * n == 0 のとき、常に 0 を返す。 + * n > 0 のとき、[1, n] の乱数を返す。 + * n < 0 のとき、[n,-1] の乱数を返す。 + */ +static int randint1_signed(const int n) +{ + if (n == 0) + return 0; + + return n > 0 ? randint1(n) : -randint1(-n); +} /*! * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン @@ -61,7 +76,7 @@ void apply_magic(player_type *owner_ptr, object_type *o_ptr, DEPTH lev, BIT_FLAG if ((owner_ptr->pseikaku != PERSONALITY_MUNCHKIN) && (f2 > d_info[owner_ptr->dungeon_idx].obj_great)) f2 = d_info[owner_ptr->dungeon_idx].obj_great; - if (have_good_luck(owner_ptr)) { + if (has_good_luck(owner_ptr)) { f1 += 5; f2 += 2; } else if (owner_ptr->muta3 & MUT3_BAD_LUCK) { @@ -102,7 +117,7 @@ void apply_magic(player_type *owner_ptr, object_type *o_ptr, DEPTH lev, BIT_FLAG for (int i = 0; i < rolls; i++) { if (make_artifact(owner_ptr, o_ptr)) break; - if (have_good_luck(owner_ptr) && one_in_(77)) { + if (has_good_luck(owner_ptr) && one_in_(77)) { if (make_artifact(owner_ptr, o_ptr)) break; } @@ -265,26 +280,9 @@ void apply_magic(player_type *owner_ptr, object_type *o_ptr, DEPTH lev, BIT_FLAG if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval); } else { - if (e_ptr->max_to_h) { - if (e_ptr->max_to_h > 127) - o_ptr->to_h -= randint1(256 - e_ptr->max_to_h); - else - o_ptr->to_h += randint1(e_ptr->max_to_h); - } - - if (e_ptr->max_to_d) { - if (e_ptr->max_to_d > 127) - o_ptr->to_d -= randint1(256 - e_ptr->max_to_d); - else - o_ptr->to_d += randint1(e_ptr->max_to_d); - } - - if (e_ptr->max_to_a) { - if (e_ptr->max_to_a > 127) - o_ptr->to_a -= randint1(256 - e_ptr->max_to_a); - else - o_ptr->to_a += randint1(e_ptr->max_to_a); - } + o_ptr->to_h += (HIT_PROB)randint1_signed(e_ptr->max_to_h); + o_ptr->to_d += randint1_signed(e_ptr->max_to_d); + o_ptr->to_a += (ARMOUR_CLASS)randint1_signed(e_ptr->max_to_a); if (o_ptr->name2 == EGO_ACCURACY) { while (o_ptr->to_h < o_ptr->to_d + 10) { @@ -307,12 +305,12 @@ void apply_magic(player_type *owner_ptr, object_type *o_ptr, DEPTH lev, BIT_FLAG } if (e_ptr->max_pval) { - if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS))) { + if ((o_ptr->name2 == EGO_HA) && (has_flag(o_ptr->art_flags, TR_BLOWS))) { o_ptr->pval++; if ((lev > 60) && one_in_(3) && ((o_ptr->dd * (o_ptr->ds + 1)) < 15)) o_ptr->pval++; } else if (o_ptr->name2 == EGO_DEMON) { - if (have_flag(o_ptr->art_flags, TR_BLOWS)) { + if (has_flag(o_ptr->art_flags, TR_BLOWS)) { o_ptr->pval += randint1(2); } else { o_ptr->pval += randint1(e_ptr->max_pval);