OSDN Git Service

[Refactor] #37353 型の置換。 / Type replacement.
[hengband/hengband.git] / src / object1.c
index 3189a6e..9de2810 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include "angband.h"
+#include "artifact.h"
 
 #if defined(MACINTOSH) || defined(MACH_O_CARBON)
 #ifdef verify
@@ -2104,7 +2105,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];
@@ -2268,7 +2269,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];
@@ -5033,3 +5034,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);
+       }
+}