OSDN Git Service

[Refactor] #37353 ACT_* と activation_info を cmd-activate.c/h へ移動。 / Move ACT_* and...
[hengband/hengband.git] / src / object1.c
index 30cb285..c4163a4 100644 (file)
@@ -12,6 +12,8 @@
  */
 
 #include "angband.h"
+#include "artifact.h"
+#include "cmd-activate.h"
 
 #if defined(MACINTOSH) || defined(MACH_O_CARBON)
 #ifdef verify
@@ -339,9 +341,9 @@ void object_flags_known(object_type *o_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
 /*!
  * @brief オブジェクトの発動効果名称を返す(サブルーチン/ブレス)
  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
- * @return cptr 発動名称を返す文字列ポインタ
+ * @return concptr 発動名称を返す文字列ポインタ
  */
-static cptr item_activation_dragon_breath(object_type *o_ptr)
+static concptr item_activation_dragon_breath(object_type *o_ptr)
 {
        static char desc[256];
        BIT_FLAGS flgs[TR_FLAG_SIZE]; /* for resistance flags */
@@ -368,12 +370,12 @@ static cptr item_activation_dragon_breath(object_type *o_ptr)
 /*!
  * @brief オブジェクトの発動効果名称を返す(サブルーチン/汎用)
  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
- * @return cptr 発動名称を返す文字列ポインタ
+ * @return concptr 発動名称を返す文字列ポインタ
  */
-static cptr item_activation_aux(object_type *o_ptr)
+static concptr item_activation_aux(object_type *o_ptr)
 {
        static char activation_detail[256];
-       cptr desc;
+       concptr desc;
        char timeout[32];
        int constant, dice;
        const activation_type* const act_ptr = find_activation_info(o_ptr);
@@ -469,13 +471,11 @@ static cptr item_activation_aux(object_type *o_ptr)
  * @brief オブジェクトの発動効果名称を返す(メインルーチン) /
  * Determine the "Activation" (if any) for an artifact Return a string, or NULL for "no activation"
  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
- * @return cptr 発動名称を返す文字列ポインタ
+ * @return concptr 発動名称を返す文字列ポインタ
  */
-cptr item_activation(object_type *o_ptr)
+concptr item_activation(object_type *o_ptr)
 {
        BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-       /* Extract the flags */
        object_flags(o_ptr, flgs);
 
        /* Require activation ability */
@@ -516,15 +516,13 @@ bool screen_object(object_type *o_ptr, BIT_FLAGS mode)
        BIT_FLAGS flgs[TR_FLAG_SIZE];
 
        char temp[70 * 20];
-       cptr            info[128];
+       concptr            info[128];
        GAME_TEXT o_name[MAX_NLEN];
        int wid, hgt;
        POSITION rad;
        char desc[256];
 
        int trivial_info = 0;
-
-       /* Extract the flags */
        object_flags(o_ptr, flgs);
 
        /* Extract the description */
@@ -1464,9 +1462,9 @@ s16b wield_slot(object_type *o_ptr)
  * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
  * @return 部位表現の文字列ポインタ
  */
-cptr mention_use(int i)
+concptr mention_use(int i)
 {
-       cptr p;
+       concptr p;
 
        /* Examine the location */
        switch (i)
@@ -1509,9 +1507,9 @@ cptr mention_use(int i)
  * @details
  * Currently, only used for items in the equipment, not inventory.
  */
-cptr describe_use(int i)
+concptr describe_use(int i)
 {
-       cptr p;
+       concptr p;
 
        switch (i)
        {
@@ -1821,7 +1819,7 @@ static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
 {
        COMMAND_CODE i;
        COMMAND_CODE start, end;
-       cptr s;
+       concptr s;
 
        /* Extract index from mode */
        switch (mode)
@@ -1946,7 +1944,7 @@ static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode)
 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
 {
        COMMAND_CODE i;
-       cptr s;
+       concptr s;
 
        /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
 
@@ -2032,7 +2030,7 @@ static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], IT
  */
 static void prepare_label_string(char *label, BIT_FLAGS mode)
 {
-       cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+       concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
        int  i;
 
@@ -2043,7 +2041,7 @@ static void prepare_label_string(char *label, BIT_FLAGS mode)
        for (i = 0; i < 52; i++)
        {
                COMMAND_CODE index;
-               char c = alphabet_chars[i];
+               SYMBOL_CODE c = alphabet_chars[i];
 
                /* Find a tag with this label */
                if (get_tag(&index, c, mode))
@@ -2070,7 +2068,7 @@ static void prepare_label_string(char *label, BIT_FLAGS mode)
  */
 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
 {
-       cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+       concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int  i;
 
        /* Prepare normal labels */
@@ -2080,7 +2078,7 @@ static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM
        for (i = 0; i < 52; i++)
        {
                COMMAND_CODE index;
-               char c = alphabet_chars[i];
+               SYMBOL_CODE c = alphabet_chars[i];
 
                /* Find a tag with this label */
                if (get_tag_floor(&index, c, floor_list, floor_num))
@@ -2108,7 +2106,7 @@ COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
        COMMAND_CODE i;
        int j, k, l, z = 0;
        int             col, cur_col, len;
-       object_type     *o_ptr;
+       object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
        char            tmp_val[80];
        COMMAND_CODE    out_index[23];
@@ -2225,8 +2223,8 @@ COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
                /* Display graphics for object, if desired */
                if (show_item_graph)
                {
-                       byte  a = object_attr(o_ptr);
-                       char c = object_char(o_ptr);
+                       TERM_COLOR a = object_attr(o_ptr);
+                       SYMBOL_CODE c = object_char(o_ptr);
                        Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
                        if (use_bigtile) cur_col++;
 
@@ -2272,7 +2270,7 @@ COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
        COMMAND_CODE i;
        int j, k, l;
        int             col, cur_col, len;
-       object_type     *o_ptr;
+       object_type *o_ptr;
        char            tmp_val[80];
        GAME_TEXT o_name[MAX_NLEN];
        COMMAND_CODE    out_index[23];
@@ -2397,8 +2395,8 @@ COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
                /* Display graphics for object, if desired */
                if (show_item_graph)
                {
-                       byte a = object_attr(o_ptr);
-                       char c = object_char(o_ptr);
+                       TERM_COLOR a = object_attr(o_ptr);
+                       SYMBOL_CODE c = object_char(o_ptr);
                        Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
                        if (use_bigtile) cur_col++;
 
@@ -2492,7 +2490,7 @@ void toggle_inven_equip(void)
  * @return 確認がYesならTRUEを返す。
  * @details The item can be negative to mean "item on floor".
  */
-static bool verify(cptr prompt, INVENTORY_IDX item)
+static bool verify(concptr prompt, INVENTORY_IDX item)
 {
        GAME_TEXT o_name[MAX_NLEN];
        char        out_val[MAX_NLEN+20];
@@ -2529,7 +2527,7 @@ static bool verify(cptr prompt, INVENTORY_IDX item)
  */
 static bool get_item_allow(INVENTORY_IDX item)
 {
-       cptr s;
+       concptr s;
        object_type *o_ptr;
        if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
 
@@ -2668,7 +2666,7 @@ bool can_get_item(void)
  * We always erase the prompt when we are done, leaving a blank line,\n
  * or a warning message, if appropriate, if no items are available.\n
  */
-bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
+bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode)
 {
        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
@@ -3443,7 +3441,7 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
 /*
  * Choose an item and get auto-picker entry from it.
  */
-object_type *choose_object(OBJECT_IDX *idx, cptr q, cptr s, BIT_FLAGS option)
+object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
 {
        OBJECT_IDX item;
        if (!get_item(&item, q, s, option)) return NULL;
@@ -3654,7 +3652,7 @@ COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_w
  * @param mode オプションフラグ
  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
  */
-bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
+bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode)
 {
        char n1 = ' ', n2 = ' ', which = ' ';
 
@@ -4799,7 +4797,7 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
 static bool py_pickup_floor_aux(void)
 {
        OBJECT_IDX this_o_idx;
-       cptr q, s;
+       concptr q, s;
        OBJECT_IDX item;
 
        /* Restrict the choices */
@@ -4809,7 +4807,7 @@ static bool py_pickup_floor_aux(void)
        q = _("どれを拾いますか?", "Get which item? ");
        s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
 
-       if (get_item(&item, q, s, (USE_FLOOR)))
+       if (choose_object(&item, q, s, (USE_FLOOR)))
        {
                this_o_idx = 0 - item;
        }
@@ -5037,3 +5035,61 @@ void py_pickup_floor(bool pickup)
                }
        }
 }
+
+
+/*!
+ * @brief 矢弾を射撃した場合の破損確率を返す /
+ * Determines the odds of an object breaking when thrown at a monster
+ * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
+ * @return 破損確率(%)
+ * @details
+ * Note that artifacts never break, see the "drop_near()" function.
+ */
+PERCENTAGE breakage_chance(object_type *o_ptr)
+{
+       PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev - 1) / 7 + 4 : 0);
+
+       /* Examine the snipe type */
+       if (snipe_type)
+       {
+               if (snipe_type == SP_KILL_WALL) return (100);
+               if (snipe_type == SP_EXPLODE) return (100);
+               if (snipe_type == SP_PIERCE) return (100);
+               if (snipe_type == SP_FINAL) return (100);
+               if (snipe_type == SP_NEEDLE) return (100);
+               if (snipe_type == SP_EVILNESS) return (40);
+               if (snipe_type == SP_HOLYNESS) return (40);
+       }
+
+       /* Examine the item type */
+       switch (o_ptr->tval)
+       {
+               /* Always break */
+       case TV_FLASK:
+       case TV_POTION:
+       case TV_BOTTLE:
+       case TV_FOOD:
+       case TV_JUNK:
+               return (100);
+
+               /* Often break */
+       case TV_LITE:
+       case TV_SCROLL:
+       case TV_SKELETON:
+               return (50);
+
+               /* Sometimes break */
+       case TV_WAND:
+       case TV_SPIKE:
+               return (25);
+       case TV_ARROW:
+               return (20 - archer_bonus * 2);
+
+               /* Rarely break */
+       case TV_SHOT:
+       case TV_BOLT:
+               return (10 - archer_bonus);
+       default:
+               return (10);
+       }
+}