OSDN Git Service

[Refactor] #41156 Conflict 対策に have_flag() を has_flag() へ / Rename have_flag() to...
[hengband/hengband.git] / src / cmd-item / cmd-throw.c
index 40aefd6..90f8a6f 100644 (file)
@@ -30,6 +30,7 @@
 #include "monster-floor/place-monster-types.h"
 #include "monster/monster-describer.h"
 #include "monster/monster-info.h"
+#include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
 #include "object-enchant/tr-types.h"
 #include "object-hook/hook-checker.h"
@@ -45,6 +46,7 @@
 #include "object/object-stack.h"
 #include "player/attack-defense-types.h"
 #include "player/special-defense-types.h"
+#include "player/player-status-table.h"
 #include "racial/racial-android.h"
 #include "specific-object/torch.h"
 #include "status/action-setter.h"
@@ -142,7 +144,7 @@ static void calc_throw_range(player_type *creature_ptr, it_type *it_ptr)
 
     int mul = 10 + 2 * (it_ptr->mult - 1);
     int div = ((it_ptr->q_ptr->weight > 10) ? it_ptr->q_ptr->weight : 10);
-    if ((have_flag(it_ptr->obj_flags, TR_THROW)) || it_ptr->boomerang)
+    if ((has_flag(it_ptr->obj_flags, TR_THROW)) || it_ptr->boomerang)
         div /= 2;
 
     it_ptr->tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
@@ -202,12 +204,12 @@ static void set_class_specific_throw_params(player_type *creature_ptr, it_type *
     it_ptr->x = creature_ptr->x;
     handle_stuff(creature_ptr);
     it_ptr->shuriken = (creature_ptr->pclass == CLASS_NINJA)
-        && ((it_ptr->q_ptr->tval == TV_SPIKE) || ((have_flag(it_ptr->obj_flags, TR_THROW)) && (it_ptr->q_ptr->tval == TV_SWORD)));
+        && ((it_ptr->q_ptr->tval == TV_SPIKE) || ((has_flag(it_ptr->obj_flags, TR_THROW)) && (it_ptr->q_ptr->tval == TV_SWORD)));
 }
 
 static void set_racial_chance(player_type *creature_ptr, it_type *it_ptr)
 {
-    if (have_flag(it_ptr->obj_flags, TR_THROW))
+    if (has_flag(it_ptr->obj_flags, TR_THROW))
         it_ptr->chance = ((creature_ptr->skill_tht) + ((creature_ptr->to_h_b + it_ptr->q_ptr->to_h) * BTH_PLUS_ADJ));
     else
         it_ptr->chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
@@ -290,7 +292,7 @@ static void calc_racial_power_damage(player_type *creature_ptr, it_type *it_ptr)
     if (it_ptr->boomerang) {
         it_ptr->tdam *= (it_ptr->mult + creature_ptr->num_blow[it_ptr->item - INVEN_RARM]);
         it_ptr->tdam += creature_ptr->to_d_m;
-    } else if (have_flag(it_ptr->obj_flags, TR_THROW)) {
+    } else if (has_flag(it_ptr->obj_flags, TR_THROW)) {
         it_ptr->tdam *= (3 + it_ptr->mult);
         it_ptr->tdam += creature_ptr->to_d_m;
     } else {
@@ -330,7 +332,7 @@ static void attack_racial_power(player_type *creature_ptr, it_type *it_ptr)
     }
 }
 
-static exe_throw(player_type *creature_ptr, it_type *it_ptr)
+static void exe_throw(player_type *creature_ptr, it_type *it_ptr)
 {
     it_ptr->cur_dis = 0;
     while (it_ptr->cur_dis <= it_ptr->tdis) {
@@ -484,13 +486,24 @@ static void process_boomerang_back(player_type *creature_ptr, it_type *it_ptr)
     }
 }
 
+static void drop_thrown_item(player_type *creature_ptr, it_type *it_ptr)
+{
+    if (!it_ptr->do_drop)
+        return;
+
+    if (cave_have_flag_bold(creature_ptr->current_floor_ptr, it_ptr->y, it_ptr->x, FF_PROJECT))
+        (void)drop_near(creature_ptr, it_ptr->q_ptr, it_ptr->corruption_possibility, it_ptr->y, it_ptr->x);
+    else
+        (void)drop_near(creature_ptr, it_ptr->q_ptr, it_ptr->corruption_possibility, it_ptr->prev_y, it_ptr->prev_x);
+}
+
 /*!
  * @brief 投射処理メインルーチン /
  * Throw an object from the pack or floor.
  * @param mult 威力の倍率
  * @param creature_ptr プレーヤーへの参照ポインタ
  * @param boomerang ブーメラン処理ならばTRUE
- * @param shuriken 忍者の手裏剣処理ならばTRUE
+ * @param shuriken 忍者の手裏剣処理ならばTRUE ← 間違い、-1が渡されてくることがある。要調査.
  * @return ターンを消費した場合TRUEを返す
  * @details
  * <pre>
@@ -538,12 +551,6 @@ bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_ID
     display_potion_throw(creature_ptr, it_ptr);
     check_boomerang_throw(creature_ptr, it_ptr);
     process_boomerang_back(creature_ptr, it_ptr);
-    if (it_ptr->do_drop) {
-        if (cave_have_flag_bold(creature_ptr->current_floor_ptr, it_ptr->y, it_ptr->x, FF_PROJECT))
-            (void)drop_near(creature_ptr, it_ptr->q_ptr, it_ptr->corruption_possibility, it_ptr->y, it_ptr->x);
-        else
-            (void)drop_near(creature_ptr, it_ptr->q_ptr, it_ptr->corruption_possibility, it_ptr->prev_y, it_ptr->prev_x);
-    }
-
+    drop_thrown_item(creature_ptr, it_ptr);
     return TRUE;
 }