OSDN Git Service

[Refactor] #39010 Separated set_racial_chance() from do_cmd_throw()
authorHourier <hourier@users.sourceforge.jp>
Sat, 8 Aug 2020 12:23:02 +0000 (21:23 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 8 Aug 2020 12:23:25 +0000 (21:23 +0900)
src/cmd-item/cmd-throw.c

index a5fe3ef..1756f0c 100644 (file)
@@ -205,6 +205,17 @@ static void set_class_specific_throw_params(player_type *creature_ptr, it_type *
         && ((it_ptr->q_ptr->tval == TV_SPIKE) || ((have_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))
+        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));
+
+    if (it_ptr->shuriken != 0)
+        it_ptr->chance *= 2;
+}
+
 /*!
  * @brief 投射処理メインルーチン /
  * Throw an object from the pack or floor.
@@ -247,14 +258,7 @@ bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_ID
     }
 
     set_class_specific_throw_params(creature_ptr, it_ptr);
-    if (have_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));
-
-    if (it_ptr->shuriken != 0)
-        it_ptr->chance *= 2;
-
+    set_racial_chance(creature_ptr, it_ptr);
     it_ptr->prev_y = it_ptr->y;
     it_ptr->prev_x = it_ptr->x;
     for (it_ptr->cur_dis = 0; it_ptr->cur_dis <= it_ptr->tdis;) {