OSDN Git Service

[Refactor] #40482 Moved shock_power() from spells3.c/h to mind-force-trainer.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 06:33:05 +0000 (15:33 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 06:33:05 +0000 (15:33 +0900)
src/mind/mind-force-trainer.c
src/mind/mind-force-trainer.h
src/spell/spells3.c
src/spell/spells3.h

index f798805..2b33c32 100644 (file)
@@ -1,9 +1,20 @@
 #include "mind/mind-force-trainer.h"
 #include "cmd-action/cmd-pet.h"
 #include "core/stuff-handler.h"
+#include "effect/spells-effect-util.h"
+#include "floor/floor.h"
+#include "floor/geometry.h"
 #include "game-option/disturbance-options.h"
+#include "grid/grid.h"
+#include "io/targeting.h"
+#include "monster-race/monster-race.h"
+#include "monster-race/race-flags7.h"
+#include "monster/monster-describer.h"
+#include "monster/monster-update.h"
 #include "player/avatar.h"
 #include "player/player-move.h"
+#include "spell-kind/spells-launcher.h"
+#include "spell/spell-types.h"
 #include "view/display-messages.h"
 
 /*!
  * @param caster_ptr プレーヤーの参照ポインタ
  * @return 現在溜まっている気の量
  */
-MAGIC_NUM1 get_current_ki(player_type *caster_ptr)
-{
-    return caster_ptr->magic_num1[0];
-}
+MAGIC_NUM1 get_current_ki(player_type *caster_ptr) { return caster_ptr->magic_num1[0]; }
 
 /*!
  * @brief 練気術師において、気を溜める
@@ -137,3 +145,72 @@ bool set_tim_sh_force(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
     handle_stuff(creature_ptr);
     return TRUE;
 }
+
+/*!
+ * @brief 衝波
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @return 命中したらTRUE
+ */
+bool shock_power(player_type *caster_ptr)
+{
+    int boost = get_current_ki(caster_ptr);
+    if (heavy_armor(caster_ptr))
+        boost /= 2;
+
+    project_length = 1;
+    DIRECTION dir;
+    if (!get_aim_dir(caster_ptr, &dir))
+        return FALSE;
+
+    POSITION y = caster_ptr->y + ddy[dir];
+    POSITION x = caster_ptr->x + ddx[dir];
+    PLAYER_LEVEL plev = caster_ptr->lev;
+    HIT_POINT dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
+    fire_beam(caster_ptr, GF_MISSILE, dir, dam);
+    if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
+        return TRUE;
+
+    POSITION ty = y, tx = x;
+    POSITION oy = y, ox = x;
+    MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[y][x].m_idx;
+    monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
+    monster_race *r_ptr = &r_info[m_ptr->r_idx];
+    GAME_TEXT m_name[MAX_NLEN];
+    monster_desc(caster_ptr, m_name, m_ptr, 0);
+
+    if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2) {
+        msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
+        return TRUE;
+    }
+
+    for (int i = 0; i < 5; i++) {
+        y += ddy[dir];
+        x += ddx[dir];
+        if (is_cave_empty_bold(caster_ptr, y, x)) {
+            ty = y;
+            tx = x;
+        } else {
+            break;
+        }
+    }
+
+    bool is_shock_successful = ty != oy;
+    is_shock_successful |= tx != ox;
+    if (is_shock_successful)
+        return TRUE;
+
+    msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
+    caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
+    caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
+    m_ptr->fy = ty;
+    m_ptr->fx = tx;
+
+    update_monster(caster_ptr, m_idx, TRUE);
+    lite_spot(caster_ptr, oy, ox);
+    lite_spot(caster_ptr, ty, tx);
+
+    if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
+        caster_ptr->update |= (PU_MON_LITE);
+
+    return TRUE;
+}
index 800c7d3..40da791 100644 (file)
@@ -7,3 +7,4 @@ void set_current_ki(player_type *caster_ptr, bool is_reset, MAGIC_NUM1 ki);
 bool clear_mind(player_type *creature_ptr);
 void set_lightspeed(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
 bool set_tim_sh_force(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
+bool shock_power(player_type *caster_ptr);
index bffc269..25bf465 100644 (file)
@@ -313,66 +313,3 @@ void massacre(player_type *caster_ptr)
             do_cmd_attack(caster_ptr, y, x, 0);
     }
 }
-
-bool shock_power(player_type *caster_ptr)
-{
-    int boost = get_current_ki(caster_ptr);
-    if (heavy_armor(caster_ptr))
-        boost /= 2;
-
-    project_length = 1;
-    DIRECTION dir;
-    if (!get_aim_dir(caster_ptr, &dir))
-        return FALSE;
-
-    POSITION y = caster_ptr->y + ddy[dir];
-    POSITION x = caster_ptr->x + ddx[dir];
-    PLAYER_LEVEL plev = caster_ptr->lev;
-    HIT_POINT dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
-    fire_beam(caster_ptr, GF_MISSILE, dir, dam);
-    if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
-        return TRUE;
-
-    POSITION ty = y, tx = x;
-    POSITION oy = y, ox = x;
-    MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[y][x].m_idx;
-    monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
-    monster_race *r_ptr = &r_info[m_ptr->r_idx];
-    GAME_TEXT m_name[MAX_NLEN];
-    monster_desc(caster_ptr, m_name, m_ptr, 0);
-
-    if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2) {
-        msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
-        return TRUE;
-    }
-
-    for (int i = 0; i < 5; i++) {
-        y += ddy[dir];
-        x += ddx[dir];
-        if (is_cave_empty_bold(caster_ptr, y, x)) {
-            ty = y;
-            tx = x;
-        } else {
-            break;
-        }
-    }
-
-    bool is_shock_successful = ty != oy;
-    is_shock_successful |= tx != ox;
-    if (is_shock_successful)
-        return TRUE;
-
-    msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
-    caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
-    caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
-    m_ptr->fy = ty;
-    m_ptr->fx = tx;
-
-    update_monster(caster_ptr, m_idx, TRUE);
-    lite_spot(caster_ptr, oy, ox);
-    lite_spot(caster_ptr, ty, tx);
-
-    if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
-        caster_ptr->update |= (PU_MON_LITE);
-    return TRUE;
-}
index 1e59a12..cd2eebf 100644 (file)
@@ -4,4 +4,3 @@
 
 bool recharge(player_type* caster_ptr, int power);
 void massacre(player_type* caster_ptr);
-bool shock_power(player_type* caster_ptr);