OSDN Git Service

[Refactor] #37353 空白整理。 / Refactor spaces.
[hengband/hengband.git] / src / artifact.c
index 37f82a2..78fb9ee 100644 (file)
  */
 
 #include "angband.h"
-#include "cmd-activate.h"
 
-static int suppression_evil_dam(object_type *o_ptr);
-static int weakening_artifact(object_type *o_ptr);
+#include "avatar.h"
+#include "cmd-activate.h"
+#include "object-curse.h"
+#include "artifact.h"
 
+static bool has_extreme_damage_rate(object_type *o_ptr);
+static bool weakening_artifact(object_type *o_ptr);
 
 
 /*!
@@ -1325,13 +1328,13 @@ static void random_slay(object_type *o_ptr)
                        break;
                case 3:
                case 4:
-                       if (one_in_(4))
+                       if (one_in_(8))
                        {
                                add_flag(o_ptr->art_flags, TR_KILL_EVIL);
                        }
                        else
                        {
-                       add_flag(o_ptr->art_flags, TR_SLAY_EVIL); 
+                               add_flag(o_ptr->art_flags, TR_SLAY_EVIL); 
                        }
                        if (!o_ptr->artifact_bias && one_in_(2))
                                o_ptr->artifact_bias = BIAS_LAW;
@@ -1677,7 +1680,7 @@ static void give_activation_power(object_type *o_ptr)
  */
 static void get_random_name(object_type *o_ptr, char *return_name, bool armour, int power)
 {
-       int prob = randint1(100);
+       PERCENTAGE prob = randint1(100);
 
        if (prob <= SINDARIN_NAME)
        {
@@ -1689,7 +1692,7 @@ static void get_random_name(object_type *o_ptr, char *return_name, bool armour,
        }
        else
        {
-               cptr filename;
+               concptr filename;
 
                switch (armour)
                {
@@ -1742,8 +1745,8 @@ static void get_random_name(object_type *o_ptr, char *return_name, bool armour,
  */
 bool create_artifact(object_type *o_ptr, bool a_scroll)
 {
-       char    new_name[1024];
-       int     has_pval = 0;
+       GAME_TEXT new_name[1024];
+       PARAMETER_VALUE has_pval = 0;
        int     powers = randint1(5) + 1;
        int     max_powers;
        int     max_type = (object_is_weapon_ammo(o_ptr) ? 7 : 5);
@@ -1899,14 +1902,6 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
 
        if (has_pval)
        {
-#if 0
-               add_flag(o_ptr->art_flags, TR_SHOW_MODS);
-
-               /* This one commented out by gw's request... */
-               if (!a_scroll)
-                       add_flag(o_ptr->art_flags, TR_HIDE_TYPE);
-#endif
-
                if (have_flag(o_ptr->art_flags, TR_BLOWS))
                {
                        o_ptr->pval = randint1(2);
@@ -1959,14 +1954,14 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                while ((o_ptr->to_d+o_ptr->to_h) > 20)
                {
                        if (one_in_(o_ptr->to_d) && one_in_(o_ptr->to_h)) break;
-                       o_ptr->to_d -= (s16b)randint0(3);
-                       o_ptr->to_h -= (s16b)randint0(3);
+                       o_ptr->to_d -= (HIT_POINT)randint0(3);
+                       o_ptr->to_h -= (HIT_PROB)randint0(3);
                }
                while ((o_ptr->to_d+o_ptr->to_h) > 10)
                {
                        if (one_in_(o_ptr->to_d) || one_in_(o_ptr->to_h)) break;
-                       o_ptr->to_d -= (s16b)randint0(3);
-                       o_ptr->to_h -= (s16b)randint0(3);
+                       o_ptr->to_d -= (HIT_POINT)randint0(3);
+                       o_ptr->to_h -= (HIT_PROB)randint0(3);
                }
        }
 
@@ -2014,22 +2009,17 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
                else power_level = 3;
        }
 
-       /* 平均対邪ダメージが一定以上なら11/12(WEIRD_LUCK)でダメージ抑制処理を行う */
-       if(suppression_evil_dam(o_ptr) && !one_in_(WEIRD_LUCK) && object_is_weapon(o_ptr))
+       /* ダメージ抑制処理を行う */
+       while (has_extreme_damage_rate(o_ptr) && !one_in_(SWORDFISH_LUCK))
        {
-               msg_format_wizard(CHEAT_OBJECT, "アーティファクトの抑制処理を行います。");
-               do
-               {
-                       if (weakening_artifact(o_ptr) == 0) break;
-               } while (suppression_evil_dam(o_ptr));
+               weakening_artifact(o_ptr);
        }
 
        if (a_scroll)
        {
-               char dummy_name[80] = "";
-               cptr ask_msg = _("このアーティファクトを何と名付けますか?", "What do you want to call the artifact? ");
+               GAME_TEXT dummy_name[MAX_NLEN] = "";
+               concptr ask_msg = _("このアーティファクトを何と名付けますか?", "What do you want to call the artifact? ");
 
-               /* Identify it fully */
                object_aware(o_ptr);
                object_known(o_ptr);
 
@@ -2069,7 +2059,6 @@ bool create_artifact(object_type *o_ptr, bool a_scroll)
        msg_format_wizard(CHEAT_OBJECT, _("パワー %d で 価値%ld のランダムアーティファクト生成 バイアスは「%s」",
                "Random artifact generated - Power:%d Value:%d Bias:%s."), max_powers, total_flags, artifact_bias_name[o_ptr->artifact_bias]);
 
-       /* Window stuff */
        p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
        return TRUE;
@@ -2258,15 +2247,13 @@ void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr)
  * 仮に2個以上存在可能かつ装備品以外の固定アーティファクトが作成されれば
  * drop_near()関数の返り値は信用できなくなる.
  */
-bool create_named_art(int a_idx, int y, int x)
+bool create_named_art(ARTIFACT_IDX a_idx, POSITION y, POSITION x)
 {
        object_type forge;
        object_type *q_ptr;
-       IDX i;
+       KIND_OBJECT_IDX i;
 
        artifact_type *a_ptr = &a_info[a_idx];
-
-       /* Get local object */
        q_ptr = &forge;
 
        /* Ignore "empty" artifacts */
@@ -2275,14 +2262,13 @@ bool create_named_art(int a_idx, int y, int x)
        /* Acquire the "kind" index */
        i = lookup_kind(a_ptr->tval, a_ptr->sval);
 
-       /* Oops */
        if (!i) return FALSE;
 
        /* Create the artifact */
        object_prep(q_ptr, i);
 
        /* Save the name */
-       q_ptr->name1 = (byte_hack)a_idx;
+       q_ptr->name1 = a_idx;
 
        /* Extract the fields */
        q_ptr->pval = a_ptr->pval;
@@ -2309,14 +2295,13 @@ bool create_named_art(int a_idx, int y, int x)
 }
 
 /*対邪平均ダメージの計算処理*/
-int calc_arm_avgdamage(object_type *o_ptr)
+HIT_POINT calc_arm_avgdamage(object_type *o_ptr)
 {
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
        object_flags(o_ptr, flgs);
 
        HIT_POINT dam, base, s_evil, forced, vorpal;
-       dam = base = s_evil = forced = vorpal = 0;
-
+       s_evil = forced = vorpal = 0;
        dam = base = (o_ptr->dd * o_ptr->ds + o_ptr->dd) / 2;
 
        if(have_flag(flgs, TR_KILL_EVIL))
@@ -2343,99 +2328,88 @@ int calc_arm_avgdamage(object_type *o_ptr)
 
        dam = dam + o_ptr->to_d;
 
-       msg_format_wizard(CHEAT_OBJECT,"素:%d> 対邪:%d> 理力:%d> 切:%d> 最終:%d",
-               base, s_evil, forced, vorpal, dam);
+       msg_format_wizard(CHEAT_OBJECT,"素:%d> 対邪:%d> 理力:%d> 切:%d> 最終:%d", base, s_evil, forced, vorpal, dam);
 
-       return(dam);
+       return dam;
 }
 
-static int suppression_evil_dam(object_type *o_ptr)
+static bool has_extreme_damage_rate(object_type *o_ptr)
 {
-       int num = FALSE;
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
        object_flags(o_ptr, flgs);
 
        if (have_flag(flgs, TR_VAMPIRIC))
        {
                if(have_flag(flgs, TR_BLOWS) && (o_ptr->pval == 1) && (calc_arm_avgdamage(o_ptr) > 52))
                {
-                       num = TRUE;
+                       return TRUE;
                }
                else if(have_flag(flgs, TR_BLOWS) && (o_ptr->pval == 2) && (calc_arm_avgdamage(o_ptr) > 43))
                {
-                       num = TRUE;
+                       return TRUE;
                }
                else if( have_flag(flgs, TR_BLOWS) && (o_ptr->pval == 3) && (calc_arm_avgdamage(o_ptr) > 33))
                {
-                       num = TRUE;
+                       return TRUE;
                }
                else if (calc_arm_avgdamage(o_ptr) > 63)
                {
-                       num = TRUE;
+                       return TRUE;
                }
        }
        else
        {
                if (have_flag(flgs, TR_BLOWS) && (o_ptr->pval == 1) && (calc_arm_avgdamage(o_ptr) > 65))
                {
-                       num = TRUE;
+                       return TRUE;
                }
                else if (have_flag(flgs, TR_BLOWS) && (o_ptr->pval == 2) && (calc_arm_avgdamage(o_ptr) > 52))
                {
-                       num = TRUE;
+                       return TRUE;
                }
                else if (have_flag(flgs, TR_BLOWS) && (o_ptr->pval == 3) && (calc_arm_avgdamage(o_ptr) > 40))
                {
-                       num = TRUE;
+                       return TRUE;
                }
                else if (calc_arm_avgdamage(o_ptr) > 75)
                {
-                       num = TRUE;
+                       return TRUE;
                }
        }
-       return(num);
+       return FALSE;
 }
 
-static int weakening_artifact(object_type *o_ptr)
+static bool weakening_artifact(object_type *o_ptr)
 {
-        KIND_OBJECT_IDX k_idx = lookup_kind(o_ptr->sval, o_ptr->tval);
-        object_kind *k_ptr = &k_info[k_idx];
-
-        if ((k_ptr->dd < o_ptr->dd) || (k_ptr->ds < o_ptr->ds))
-        {
-               int pre_dd = o_ptr->dd;
-               int pre_ds = o_ptr->ds;
-
-               if (o_ptr->dd > o_ptr->ds)
-               {
-                       o_ptr->dd--;
-               }
-               else
-               {
-                       o_ptr->ds--;
-               }
+       KIND_OBJECT_IDX k_idx = lookup_kind(o_ptr->tval, o_ptr->sval);
+       object_kind *k_ptr = &k_info[k_idx];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
+       object_flags(o_ptr, flgs);
 
-               msg_format_wizard(CHEAT_OBJECT, 
-                       _("ダイスが抑制されました。%dd%d -> %dd%d", "Dice Supress %dd%d -> %dd%d"),
-                       pre_dd, pre_ds, o_ptr->dd, o_ptr->ds);
-               return 1;
+       if (have_flag(flgs, TR_KILL_EVIL))
+       {
+               remove_flag(o_ptr->art_flags, TR_KILL_EVIL);
+               add_flag(o_ptr->art_flags, TR_SLAY_EVIL);
+               return TRUE;
        }
-       
-       if (o_ptr->to_d > 10)
+       else if (k_ptr->dd < o_ptr->dd)
+       {
+               o_ptr->dd--;
+               return TRUE;
+       }
+       else if (k_ptr->ds < o_ptr->ds)
+       {
+               o_ptr->ds--;
+               return TRUE;
+       }
+       else if (o_ptr->to_d > 10)
        {
-               int pre_damage = o_ptr->to_d;
-
                o_ptr->to_d = o_ptr->to_d - damroll(1, 6);
                if (o_ptr->to_d < 10)
                {
                        o_ptr->to_d = 10;
                }
-
-               msg_format_wizard(CHEAT_OBJECT,
-                       _("ダメージ修正が抑制されました。 %d -> %d", "Plus-Damage Supress %d -> %d"),
-                       pre_damage, o_ptr->to_d);
-
-               return 1;
-        }
-        return 0;
+               return TRUE;
+       }
+       return FALSE;
 }
\ No newline at end of file