OSDN Git Service

[Refactor] #40479 Moved ome functions from mspell-attack.c to mspell-lite.c/h
authorHourier <hourier@users.sourceforge.jp>
Thu, 23 Jul 2020 12:09:08 +0000 (21:09 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 23 Jul 2020 12:09:08 +0000 (21:09 +0900)
src/mspell/mspell-attack.c
src/mspell/mspell-lite.c
src/mspell/mspell-lite.h

index 4083170..88b03d7 100644 (file)
@@ -6,18 +6,13 @@
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
 #include "floor/cave.h"
-#include "floor/floor.h"
-#include "grid/feature.h"
-#include "grid/grid.h"
 #include "io/targeting.h"
 #include "monster-floor/monster-move.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags-ability1.h"
 #include "monster-race/race-flags-ability2.h"
 #include "monster-race/race-flags2.h"
-#include "monster-race/race-flags3.h"
 #include "monster-race/race-flags4.h"
-#include "monster-race/race-flags7.h"
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-describer.h"
 #include "monster/monster-flag-types.h"
@@ -27,7 +22,6 @@
 #include "mspell/improper-mspell-remover.h"
 #include "mspell/mspell-attack-util.h"
 #include "mspell/mspell-checker.h"
-#include "mspell/mspell-judgement.h"
 #include "mspell/mspell-lite.h"
 #include "mspell/mspell-mask-definitions.h"
 #include "mspell/mspell-selector.h"
 #include "player/attack-defense-types.h"
 #include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
-#include "spell/range-calc.h"
 #include "system/floor-type-definition.h"
-#include "system/monster-type-definition.h"
-#include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 #ifdef JP
 #include "monster/monster-description-types.h"
 #endif
 
-static void feature_projection(floor_type *floor_ptr, msa_type *msa_ptr)
-{
-    feature_type *f_ptr = &f_info[floor_ptr->grid_array[msa_ptr->y][msa_ptr->x].feat];
-    if (have_flag(f_ptr->flags, FF_PROJECT))
-        return;
-
-    if ((msa_ptr->f4 & RF4_BR_DISI) && have_flag(f_ptr->flags, FF_HURT_DISI) && one_in_(2)) {
-        msa_ptr->do_spell = DO_SPELL_BR_DISI;
-        return;
-    }
-
-    if ((msa_ptr->f4 & RF4_BR_LITE) && have_flag(f_ptr->flags, FF_LOS) && one_in_(2))
-        msa_ptr->do_spell = DO_SPELL_BR_LITE;
-}
-
-static void check_lite_area_by_mspell(player_type *target_ptr, msa_type *msa_ptr)
-{
-    if ((msa_ptr->f4 & RF4_BR_DISI) && (msa_ptr->m_ptr->cdis < get_max_range(target_ptr) / 2)
-        && in_disintegration_range(target_ptr->current_floor_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y, msa_ptr->x)
-        && (one_in_(10) || (projectable(target_ptr, msa_ptr->y, msa_ptr->x, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx) && one_in_(2)))) {
-        msa_ptr->do_spell = DO_SPELL_BR_DISI;
-        msa_ptr->success = TRUE;
-        return;
-    }
-
-    if ((msa_ptr->f4 & RF4_BR_LITE) && (msa_ptr->m_ptr->cdis < get_max_range(target_ptr) / 2)
-        && los(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y, msa_ptr->x) && one_in_(5)) {
-        msa_ptr->do_spell = DO_SPELL_BR_LITE;
-        msa_ptr->success = TRUE;
-        return;
-    }
-
-    if (((msa_ptr->f5 & RF5_BA_LITE) == 0) || (msa_ptr->m_ptr->cdis > get_max_range(target_ptr)))
-        return;
-
-    POSITION by = msa_ptr->y, bx = msa_ptr->x;
-    get_project_point(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, &by, &bx, 0L);
-    if ((distance(by, bx, msa_ptr->y, msa_ptr->x) <= 3) && los(target_ptr, by, bx, msa_ptr->y, msa_ptr->x) && one_in_(5)) {
-        msa_ptr->do_spell = DO_SPELL_BA_LITE;
-        msa_ptr->success = TRUE;
-    }
-}
-
-static void decide_lite_breath(player_type *target_ptr, msa_type *msa_ptr)
-{
-    if (msa_ptr->success)
-        return;
-
-    if (msa_ptr->m_ptr->target_y && msa_ptr->m_ptr->target_x) {
-        msa_ptr->y = msa_ptr->m_ptr->target_y;
-        msa_ptr->x = msa_ptr->m_ptr->target_x;
-        msa_ptr->f4 &= RF4_INDIRECT_MASK;
-        msa_ptr->f5 &= RF5_INDIRECT_MASK;
-        msa_ptr->f6 &= RF6_INDIRECT_MASK;
-        msa_ptr->success = TRUE;
-    }
-
-    if ((msa_ptr->y_br_lite == 0) || (msa_ptr->x_br_lite == 0) || (msa_ptr->m_ptr->cdis > get_max_range(target_ptr) / 2) || !one_in_(5))
-        return;
-
-    if (msa_ptr->success) {
-        msa_ptr->f4 |= RF4_BR_LITE;
-        return;
-    }
-
-    msa_ptr->y = msa_ptr->y_br_lite;
-    msa_ptr->x = msa_ptr->x_br_lite;
-    msa_ptr->do_spell = DO_SPELL_BR_LITE;
-    msa_ptr->success = TRUE;
-}
-
-static bool decide_lite_projection(player_type *target_ptr, msa_type *msa_ptr)
-{
-    if (projectable(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y, msa_ptr->x)) {
-        feature_projection(target_ptr->current_floor_ptr, msa_ptr);
-        return TRUE;
-    }
-
-    msa_ptr->success = FALSE;
-    check_lite_area_by_mspell(target_ptr, msa_ptr);
-    if (!msa_ptr->success)
-        msa_ptr->success = adjacent_grid_check(target_ptr, msa_ptr->m_ptr, &msa_ptr->y, &msa_ptr->x, FF_PROJECT, projectable);
-
-    decide_lite_breath(target_ptr, msa_ptr);
-    return msa_ptr->success;
-}
-
 static void set_no_magic_mask(msa_type *msa_ptr)
 {
     if (!msa_ptr->no_inate)
@@ -143,26 +47,6 @@ static void set_no_magic_mask(msa_type *msa_ptr)
     msa_ptr->f6 &= ~(RF6_NOMAGIC_MASK);
 }
 
-static void decide_lite_area(player_type *target_ptr, msa_type *msa_ptr)
-{
-    if ((msa_ptr->f6 & RF6_DARKNESS) == 0)
-        return;
-
-    bool can_use_lite_area = (target_ptr->pclass == CLASS_NINJA) && ((msa_ptr->r_ptr->flags3 & (RF3_UNDEAD | RF3_HURT_LITE)) == 0)
-        && ((msa_ptr->r_ptr->flags7 & RF7_DARK_MASK) == 0);
-
-    if ((msa_ptr->r_ptr->flags2 & RF2_STUPID) != 0)
-        return;
-
-    if (d_info[target_ptr->dungeon_idx].flags1 & DF1_DARKNESS) {
-        msa_ptr->f6 &= ~(RF6_DARKNESS);
-        return;
-    }
-
-    if ((target_ptr->pclass == CLASS_NINJA) && !can_use_lite_area)
-        msa_ptr->f6 &= ~(RF6_DARKNESS);
-}
-
 static void check_mspell_stupid(player_type *target_ptr, msa_type *msa_ptr)
 {
     floor_type *floor_ptr = target_ptr->current_floor_ptr;
index f2d77a8..f8f250d 100644 (file)
@@ -5,12 +5,24 @@
  */
 
 #include "mspell/mspell-lite.h"
+#include "dungeon/dungeon-flag-types.h"
+#include "dungeon/dungeon.h"
 #include "floor/cave.h"
 #include "floor/floor.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
+#include "io/targeting.h"
+#include "monster-race/monster-race.h"
+#include "monster-race/race-flags-ability1.h"
+#include "monster-race/race-flags-ability2.h"
+#include "monster-race/race-flags2.h"
+#include "monster-race/race-flags3.h"
 #include "monster-race/race-flags4.h"
+#include "monster-race/race-flags7.h"
 #include "mspell/mspell-attack-util.h"
+#include "mspell/mspell-judgement.h"
+#include "mspell/mspell-mask-definitions.h"
+#include "spell/range-calc.h"
 #include "system/floor-type-definition.h"
 #include "system/monster-type-definition.h"
 #include "util/bit-flags-calculator.h"
@@ -78,3 +90,110 @@ void decide_lite_range(player_type *target_ptr, msa_type *msa_ptr)
     msa_ptr->y_br_lite = 0;
     msa_ptr->x_br_lite = 0;
 }
+
+static void feature_projection(floor_type *floor_ptr, msa_type *msa_ptr)
+{
+    feature_type *f_ptr = &f_info[floor_ptr->grid_array[msa_ptr->y][msa_ptr->x].feat];
+    if (have_flag(f_ptr->flags, FF_PROJECT))
+        return;
+
+    if ((msa_ptr->f4 & RF4_BR_DISI) && have_flag(f_ptr->flags, FF_HURT_DISI) && one_in_(2)) {
+        msa_ptr->do_spell = DO_SPELL_BR_DISI;
+        return;
+    }
+
+    if ((msa_ptr->f4 & RF4_BR_LITE) && have_flag(f_ptr->flags, FF_LOS) && one_in_(2))
+        msa_ptr->do_spell = DO_SPELL_BR_LITE;
+}
+
+static void check_lite_area_by_mspell(player_type *target_ptr, msa_type *msa_ptr)
+{
+    if ((msa_ptr->f4 & RF4_BR_DISI) && (msa_ptr->m_ptr->cdis < get_max_range(target_ptr) / 2)
+        && in_disintegration_range(target_ptr->current_floor_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y, msa_ptr->x)
+        && (one_in_(10) || (projectable(target_ptr, msa_ptr->y, msa_ptr->x, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx) && one_in_(2)))) {
+        msa_ptr->do_spell = DO_SPELL_BR_DISI;
+        msa_ptr->success = TRUE;
+        return;
+    }
+
+    if ((msa_ptr->f4 & RF4_BR_LITE) && (msa_ptr->m_ptr->cdis < get_max_range(target_ptr) / 2)
+        && los(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y, msa_ptr->x) && one_in_(5)) {
+        msa_ptr->do_spell = DO_SPELL_BR_LITE;
+        msa_ptr->success = TRUE;
+        return;
+    }
+
+    if (((msa_ptr->f5 & RF5_BA_LITE) == 0) || (msa_ptr->m_ptr->cdis > get_max_range(target_ptr)))
+        return;
+
+    POSITION by = msa_ptr->y, bx = msa_ptr->x;
+    get_project_point(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, &by, &bx, 0L);
+    if ((distance(by, bx, msa_ptr->y, msa_ptr->x) <= 3) && los(target_ptr, by, bx, msa_ptr->y, msa_ptr->x) && one_in_(5)) {
+        msa_ptr->do_spell = DO_SPELL_BA_LITE;
+        msa_ptr->success = TRUE;
+    }
+}
+
+static void decide_lite_breath(player_type *target_ptr, msa_type *msa_ptr)
+{
+    if (msa_ptr->success)
+        return;
+
+    if (msa_ptr->m_ptr->target_y && msa_ptr->m_ptr->target_x) {
+        msa_ptr->y = msa_ptr->m_ptr->target_y;
+        msa_ptr->x = msa_ptr->m_ptr->target_x;
+        msa_ptr->f4 &= RF4_INDIRECT_MASK;
+        msa_ptr->f5 &= RF5_INDIRECT_MASK;
+        msa_ptr->f6 &= RF6_INDIRECT_MASK;
+        msa_ptr->success = TRUE;
+    }
+
+    if ((msa_ptr->y_br_lite == 0) || (msa_ptr->x_br_lite == 0) || (msa_ptr->m_ptr->cdis > get_max_range(target_ptr) / 2) || !one_in_(5))
+        return;
+
+    if (msa_ptr->success) {
+        msa_ptr->f4 |= RF4_BR_LITE;
+        return;
+    }
+
+    msa_ptr->y = msa_ptr->y_br_lite;
+    msa_ptr->x = msa_ptr->x_br_lite;
+    msa_ptr->do_spell = DO_SPELL_BR_LITE;
+    msa_ptr->success = TRUE;
+}
+
+bool decide_lite_projection(player_type *target_ptr, msa_type *msa_ptr)
+{
+    if (projectable(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y, msa_ptr->x)) {
+        feature_projection(target_ptr->current_floor_ptr, msa_ptr);
+        return TRUE;
+    }
+
+    msa_ptr->success = FALSE;
+    check_lite_area_by_mspell(target_ptr, msa_ptr);
+    if (!msa_ptr->success)
+        msa_ptr->success = adjacent_grid_check(target_ptr, msa_ptr->m_ptr, &msa_ptr->y, &msa_ptr->x, FF_PROJECT, projectable);
+
+    decide_lite_breath(target_ptr, msa_ptr);
+    return msa_ptr->success;
+}
+
+void decide_lite_area(player_type *target_ptr, msa_type *msa_ptr)
+{
+    if ((msa_ptr->f6 & RF6_DARKNESS) == 0)
+        return;
+
+    bool can_use_lite_area = (target_ptr->pclass == CLASS_NINJA) && ((msa_ptr->r_ptr->flags3 & (RF3_UNDEAD | RF3_HURT_LITE)) == 0)
+        && ((msa_ptr->r_ptr->flags7 & RF7_DARK_MASK) == 0);
+
+    if ((msa_ptr->r_ptr->flags2 & RF2_STUPID) != 0)
+        return;
+
+    if (d_info[target_ptr->dungeon_idx].flags1 & DF1_DARKNESS) {
+        msa_ptr->f6 &= ~(RF6_DARKNESS);
+        return;
+    }
+
+    if ((target_ptr->pclass == CLASS_NINJA) && !can_use_lite_area)
+        msa_ptr->f6 &= ~(RF6_DARKNESS);
+}
index 16feb9e..6406385 100644 (file)
@@ -7,3 +7,5 @@ typedef struct msa_type msa_type;
 typedef bool (*path_check_pf)(player_type *, POSITION, POSITION, POSITION, POSITION);
 bool adjacent_grid_check(player_type *target_ptr, monster_type *m_ptr, POSITION *yp, POSITION *xp, int f_flag, path_check_pf path_check);
 void decide_lite_range(player_type *target_ptr, msa_type *msa_ptr);
+bool decide_lite_projection(player_type *target_ptr, msa_type *msa_ptr);
+void decide_lite_area(player_type *target_ptr, msa_type *msa_ptr);