OSDN Git Service

[Refactor] #40482 Separated spells-world.c/h from spells3.c/h and spells-teleport.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 06:17:00 +0000 (15:17 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 06:17:00 +0000 (15:17 +0900)
27 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-action/cmd-mane.c
src/cmd-building/cmd-building.c
src/cmd-item/cmd-activate.c
src/cmd-item/cmd-read.c
src/mind/mind.c
src/mind/racial.c
src/mspell/mspell-floor.c
src/mspell/mspells1.c
src/mspell/mspells2.c
src/mspell/mspells3.c
src/mutation/mutation-processor.c
src/realm/realm-arcane.c
src/realm/realm-chaos.c
src/realm/realm-life.c
src/realm/realm-song.c
src/realm/realm-sorcery.c
src/realm/realm-trump.c
src/spell-kind/spells-teleport.c
src/spell-kind/spells-teleport.h
src/spell-kind/spells-world.c [new file with mode: 0644]
src/spell-kind/spells-world.h [new file with mode: 0644]
src/spell/spells-status.c
src/spell/spells3.c
src/spell/spells3.h

index 08c14b1..5fa4e7b 100644 (file)
     <ClCompile Include="..\..\src\spell-kind\spells-equipment.c" />\r
     <ClCompile Include="..\..\src\spell-kind\spells-fetcher.c" />\r
     <ClCompile Include="..\..\src\spell-kind\spells-polymorph.c" />\r
+    <ClCompile Include="..\..\src\spell-kind\spells-world.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-craft.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-demon.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-sorcery.c" />\r
     <ClInclude Include="..\..\src\spell-kind\spells-equipment.h" />\r
     <ClInclude Include="..\..\src\spell-kind\spells-fetcher.h" />\r
     <ClInclude Include="..\..\src\spell-kind\spells-polymorph.h" />\r
+    <ClInclude Include="..\..\src\spell-kind\spells-world.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-craft.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-demon.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-sorcery.h" />\r
index 48e9b93..20efafb 100644 (file)
     <ClCompile Include="..\..\src\spell-kind\blood-curse.c">
       <Filter>spell-kind</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\spell-kind\spells-world.c">
+      <Filter>spell-kind</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\spell-kind\blood-curse.h">
       <Filter>spell-kind</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\spell-kind\spells-world.h">
+      <Filter>spell-kind</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 3ef729b..58eeb16 100644 (file)
@@ -563,6 +563,7 @@ hengband_SOURCES = \
        spell-kind/spells-sight.c spell-kind/spells-sight.h \
        spell-kind/spells-specific-bolt.c spell-kind/spells-specific-bolt.h \
        spell-kind/spells-teleport.c spell-kind/spells-teleport.h \
+       spell-kind/spells-world.c spell-kind/spells-world.h \
        \
        spell-realm/spells-chaos.c spell-realm/spells-chaos.h \
        spell-realm/spells-craft.c spell-realm/spells-craft.h \
index 7efb445..b066871 100644 (file)
 #include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-neighbor.h"
 #include "spell-kind/spells-sight.h"
+#include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
-#include "spell-kind/spells-teleport.h"
 #include "spell/spell-types.h"
 #include "status/bad-status-setter.h"
 #include "status/body-improvement.h"
index 0b90ad9..4ab0ba2 100644 (file)
@@ -57,7 +57,7 @@
 #include "player/player-status.h"
 #include "spell-kind/spells-perception.h"
 #include "spell-kind/spells-recall.h"
-#include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spells-status.h"
 #include "system/building-type-definition.h"
 #include "term/screen-processor.h"
index 8f381eb..ddd3f28 100644 (file)
@@ -72,6 +72,7 @@
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-specific-bolt.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell-realm/spells-sorcery.h"
 #include "spell/process-effect.h"
index d0d49a1..7b36ab8 100644 (file)
@@ -43,6 +43,7 @@
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell/spell-types.h"
 #include "spell/spells-object.h"
index 1a16e05..09642b7 100644 (file)
@@ -63,6 +63,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
index 2435064..d7164ef 100644 (file)
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
-#include "spell/spells3.h"
 #include "status/experience.h"
 #include "term/screen-processor.h"
 #include "util/int-char-converter.h"
index c1eeda5..9fcaf78 100644 (file)
@@ -28,6 +28,7 @@
 #include "spell-kind/spells-neighbor.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spell-types.h"
 #include "view/display-messages.h"
 
index 7c940c3..ffc7c34 100644 (file)
@@ -46,7 +46,7 @@
 #include "player/player-race.h"
 #include "player/special-defense-types.h"
 #include "realm/realm-song-numbers.h"
-#include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell/process-effect.h"
 #include "spell/range-calc.h"
index 6d54ff3..3099ec4 100644 (file)
@@ -37,7 +37,7 @@
 #include "pet/pet-util.h"
 #include "player/player-class.h"
 #include "player/player-move.h"
-#include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell/range-calc.h"
 #include "spell/spell-types.h"
index 157760f..41a2139 100644 (file)
@@ -51,6 +51,7 @@
 #include "spell-kind/spells-neighbor.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spell-info.h"
 #include "spell/spell-types.h"
 #include "spell/spells-status.h"
index 4c6fa58..b3ae9d9 100644 (file)
 #include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell/spell-types.h"
 #include "spell/spells-summon.h"
-#include "spell/spells3.h"
 #include "status/bad-status-setter.h"
 #include "status/base-status.h"
 #include "status/body-improvement.h"
index 1906429..6a0c334 100644 (file)
@@ -14,6 +14,7 @@
 #include "spell-kind/spells-perception.h"
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spell-types.h"
 #include "spell/spells-diceroll.h"
 #include "spell/spells-object.h"
index 87b33d5..9f1734c 100644 (file)
@@ -12,6 +12,7 @@
 #include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-neighbor.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-chaos.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
index ed14503..e6cf9d9 100644 (file)
@@ -14,9 +14,9 @@
 #include "spell-kind/spells-perception.h"
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spell-types.h"
 #include "spell/spells-status.h"
-#include "spell/spells3.h"
 #include "status/bad-status-setter.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
index 746d3a5..b4804d0 100644 (file)
@@ -15,9 +15,9 @@
 #include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-neighbor.h"
 #include "spell-kind/spells-sight.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
-#include "spell/spells3.h"
 #include "status/experience.h"
 #include "view/display-messages.h"
 
index fcfee1b..b6621b9 100644 (file)
@@ -16,6 +16,7 @@
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-sorcery.h"
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
index 691cb25..8e02a4a 100644 (file)
@@ -15,6 +15,7 @@
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell-realm/spells-trump.h"
 #include "spell/spell-types.h"
 #include "spell/spells-object.h"
index d4ea0d7..729eca1 100644 (file)
@@ -1,39 +1,26 @@
 /*!
- * todo 少し長いかも
  * @brief テレポート魔法全般
  * @date 2020/06/04
  * @author Hourier
  */
 
 #include "spell-kind/spells-teleport.h"
-#include "cmd-io/cmd-save.h"
 #include "core/asking-player.h"
 #include "core/speed-table.h"
-#include "dungeon/dungeon.h"
-#include "dungeon/quest.h"
 #include "effect/effect-characteristics.h"
-#include "game-option/birth-options.h"
-#include "game-option/play-record-options.h"
-#include "game-option/special-options.h"
 #include "grid/grid.h"
 #include "inventory/inventory-slot-types.h"
 #include "io/targeting.h"
-#include "io/write-diary.h"
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
 #include "monster-floor/monster-move.h"
-#include "monster-floor/monster-remover.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags-ability2.h"
 #include "monster-race/race-flags-resistance.h"
-#include "monster-race/race-flags1.h"
 #include "monster-race/race-flags7.h"
-#include "monster/monster-describer.h"
-#include "monster/monster-description-types.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/smart-learn-types.h"
 #include "mutation/mutation-flag-types.h"
 #include "object-enchant/tr-types.h"
 #include "object-hook/hook-checker.h"
@@ -548,208 +535,6 @@ void teleport_away_followable(player_type *tracer_ptr, MONSTER_IDX m_idx)
     tracer_ptr->energy_need += ENERGY_NEED();
 }
 
-bool teleport_level_other(player_type *caster_ptr)
-{
-    if (!target_set(caster_ptr, TARGET_KILL))
-        return FALSE;
-    MONSTER_IDX target_m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
-    if (!target_m_idx)
-        return TRUE;
-    if (!player_has_los_bold(caster_ptr, target_row, target_col))
-        return TRUE;
-    if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
-        return TRUE;
-
-    monster_type *m_ptr;
-    monster_race *r_ptr;
-    m_ptr = &caster_ptr->current_floor_ptr->m_list[target_m_idx];
-    r_ptr = &r_info[m_ptr->r_idx];
-    GAME_TEXT m_name[MAX_NLEN];
-    monster_desc(caster_ptr, m_name, m_ptr, 0);
-    msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
-
-    if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) || (r_ptr->flags1 & RF1_QUESTOR)
-        || (r_ptr->level + randint1(50) > caster_ptr->lev + randint1(60))) {
-        msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
-    } else {
-        teleport_level(caster_ptr, target_m_idx);
-    }
-
-    return TRUE;
-}
-
-/*!
- * todo cmd-save.h への依存あり。コールバックで何とかしたい
- * @brief プレイヤー及びモンスターをレベルテレポートさせる /
- * Teleport the player one level up or down (random when legal)
- * @param creature_ptr プレーヤーへの参照ポインタ
- * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
- * @return なし
- */
-void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx)
-{
-    GAME_TEXT m_name[160];
-    bool see_m = TRUE;
-    if (m_idx <= 0) {
-        strcpy(m_name, _("あなた", "you"));
-    } else {
-        monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
-        monster_desc(creature_ptr, m_name, m_ptr, 0);
-        see_m = is_seen(creature_ptr, m_ptr);
-    }
-
-    if (is_teleport_level_ineffective(creature_ptr, m_idx)) {
-        if (see_m)
-            msg_print(_("効果がなかった。", "There is no effect."));
-        return;
-    }
-
-    if ((m_idx <= 0) && creature_ptr->anti_tele) {
-        msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
-        return;
-    }
-
-    bool go_up;
-    if (randint0(100) < 50)
-        go_up = TRUE;
-    else
-        go_up = FALSE;
-
-    if ((m_idx <= 0) && current_world_ptr->wizard) {
-        if (get_check("Force to go up? "))
-            go_up = TRUE;
-        else if (get_check("Force to go down? "))
-            go_up = FALSE;
-    }
-
-    if ((ironman_downward && (m_idx <= 0)) || (creature_ptr->current_floor_ptr->dun_level <= d_info[creature_ptr->dungeon_idx].mindepth)) {
-#ifdef JP
-        if (see_m)
-            msg_format("%^sは床を突き破って沈んでいく。", m_name);
-#else
-        if (see_m)
-            msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
-#endif
-        if (m_idx <= 0) {
-            if (!creature_ptr->current_floor_ptr->dun_level) {
-                creature_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : creature_ptr->recall_dungeon;
-                creature_ptr->oldpy = creature_ptr->y;
-                creature_ptr->oldpx = creature_ptr->x;
-            }
-
-            if (record_stair)
-                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, 1, NULL);
-
-            if (autosave_l)
-                do_cmd_save_game(creature_ptr, TRUE);
-
-            if (!creature_ptr->current_floor_ptr->dun_level) {
-                creature_ptr->current_floor_ptr->dun_level = d_info[creature_ptr->dungeon_idx].mindepth;
-                prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
-            } else {
-                prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
-            }
-
-            creature_ptr->leaving = TRUE;
-        }
-    } else if (quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level)
-        || (creature_ptr->current_floor_ptr->dun_level >= d_info[creature_ptr->dungeon_idx].maxdepth)) {
-#ifdef JP
-        if (see_m)
-            msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
-#else
-        if (see_m)
-            msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
-#endif
-
-        if (m_idx <= 0) {
-            if (record_stair)
-                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, -1, NULL);
-
-            if (autosave_l)
-                do_cmd_save_game(creature_ptr, TRUE);
-
-            prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
-
-            leave_quest_check(creature_ptr);
-            creature_ptr->current_floor_ptr->inside_quest = 0;
-            creature_ptr->leaving = TRUE;
-        }
-    } else if (go_up) {
-#ifdef JP
-        if (see_m)
-            msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
-#else
-        if (see_m)
-            msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
-#endif
-
-        if (m_idx <= 0) {
-            if (record_stair)
-                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, -1, NULL);
-
-            if (autosave_l)
-                do_cmd_save_game(creature_ptr, TRUE);
-
-            prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
-            creature_ptr->leaving = TRUE;
-        }
-    } else {
-#ifdef JP
-        if (see_m)
-            msg_format("%^sは床を突き破って沈んでいく。", m_name);
-#else
-        if (see_m)
-            msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
-#endif
-
-        if (m_idx <= 0) {
-            if (record_stair)
-                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, 1, NULL);
-            if (autosave_l)
-                do_cmd_save_game(creature_ptr, TRUE);
-
-            prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
-            creature_ptr->leaving = TRUE;
-        }
-    }
-
-    if (m_idx <= 0) {
-        sound(SOUND_TPLEVEL);
-        return;
-    }
-
-    monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
-    check_quest_completion(creature_ptr, m_ptr);
-    if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
-        char m2_name[MAX_NLEN];
-
-        monster_desc(creature_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
-        exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
-    }
-
-    delete_monster_idx(creature_ptr, m_idx);
-    sound(SOUND_TPLEVEL);
-}
-
-/*!
- * todo 変数名が実態と合っているかどうかは要確認
- * テレポート・レベルが効かないモンスターであるかどうかを判定する
- * @param caster_ptr プレーヤーへの参照ポインタ
- * @param idx テレポート・レベル対象のモンスター
- */
-bool is_teleport_level_ineffective(player_type *caster_ptr, MONSTER_IDX idx)
-{
-    floor_type *floor_ptr = caster_ptr->current_floor_ptr;
-    bool is_special_floor
-        = floor_ptr->inside_arena || caster_ptr->phase_out || (floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level));
-    bool is_invalid_floor = idx <= 0;
-    is_invalid_floor &= quest_number(caster_ptr, floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth);
-    is_invalid_floor &= caster_ptr->current_floor_ptr->dun_level >= 1;
-    is_invalid_floor &= ironman_downward;
-    return is_special_floor || is_invalid_floor;
-}
-
 /*!
  * @brief 次元の扉処理 /
  * Dimension Door
index efac35f..e9f760e 100644 (file)
@@ -12,9 +12,5 @@ void teleport_player(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode);
 void teleport_player_away(MONSTER_IDX m_idx, player_type *target_ptr, POSITION dis, bool is_quantum_effect);
 void teleport_player_to(player_type *creature_ptr, POSITION ny, POSITION nx, teleport_flags mode);
 void teleport_away_followable(player_type *creature_ptr, MONSTER_IDX m_idx);
-bool teleport_level_other(player_type *caster_ptr);
-void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx);
-bool tele_town(player_type *caster_ptr);
-bool is_teleport_level_ineffective(player_type *caster_ptr, MONSTER_IDX idx);
 bool dimension_door(player_type *caster_ptr);
 bool exe_dimension_door(player_type *caster_ptr, POSITION x, POSITION y);
diff --git a/src/spell-kind/spells-world.c b/src/spell-kind/spells-world.c
new file mode 100644 (file)
index 0000000..c43b455
--- /dev/null
@@ -0,0 +1,331 @@
+#include "spell-kind/spells-world.h"
+#include "cmd-io/cmd-save.h"
+#include "core/asking-player.h"
+#include "dungeon/dungeon.h"
+#include "dungeon/quest.h"
+#include "floor/floor-town.h"
+#include "floor/floor.h"
+#include "floor/geometry.h"
+#include "floor/wild.h"
+#include "game-option/birth-options.h"
+#include "game-option/play-record-options.h"
+#include "game-option/special-options.h"
+#include "grid/grid.h"
+#include "io/input-key-acceptor.h"
+#include "io/targeting.h"
+#include "io/write-diary.h"
+#include "main/sound-definitions-table.h"
+#include "main/sound-of-music.h"
+#include "market/building-util.h"
+#include "monster-race/monster-race.h"
+#include "monster-race/race-flags-resistance.h"
+#include "monster-race/race-flags1.h"
+#include "monster/monster-describer.h"
+#include "monster/monster-description-types.h"
+#include "monster/monster-info.h"
+#include "monster-floor/monster-remover.h"
+#include "system/monster-type-definition.h"
+#include "term/screen-processor.h"
+#include "util/int-char-converter.h"
+#include "view/display-messages.h"
+#include "world/world.h"
+
+/*!
+ * todo 変数名が実態と合っているかどうかは要確認
+ * テレポート・レベルが効かないモンスターであるかどうかを判定する
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param idx テレポート・レベル対象のモンスター
+ */
+bool is_teleport_level_ineffective(player_type *caster_ptr, MONSTER_IDX idx)
+{
+    floor_type *floor_ptr = caster_ptr->current_floor_ptr;
+    bool is_special_floor
+        = floor_ptr->inside_arena || caster_ptr->phase_out || (floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level));
+    bool is_invalid_floor = idx <= 0;
+    is_invalid_floor &= quest_number(caster_ptr, floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth);
+    is_invalid_floor &= caster_ptr->current_floor_ptr->dun_level >= 1;
+    is_invalid_floor &= ironman_downward;
+    return is_special_floor || is_invalid_floor;
+}
+
+/*!
+ * todo cmd-save.h への依存あり。コールバックで何とかしたい
+ * @brief プレイヤー及びモンスターをレベルテレポートさせる /
+ * Teleport the player one level up or down (random when legal)
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
+ * @return なし
+ */
+void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx)
+{
+    GAME_TEXT m_name[160];
+    bool see_m = TRUE;
+    if (m_idx <= 0) {
+        strcpy(m_name, _("あなた", "you"));
+    } else {
+        monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
+        monster_desc(creature_ptr, m_name, m_ptr, 0);
+        see_m = is_seen(creature_ptr, m_ptr);
+    }
+
+    if (is_teleport_level_ineffective(creature_ptr, m_idx)) {
+        if (see_m)
+            msg_print(_("効果がなかった。", "There is no effect."));
+        return;
+    }
+
+    if ((m_idx <= 0) && creature_ptr->anti_tele) {
+        msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
+        return;
+    }
+
+    bool go_up;
+    if (randint0(100) < 50)
+        go_up = TRUE;
+    else
+        go_up = FALSE;
+
+    if ((m_idx <= 0) && current_world_ptr->wizard) {
+        if (get_check("Force to go up? "))
+            go_up = TRUE;
+        else if (get_check("Force to go down? "))
+            go_up = FALSE;
+    }
+
+    if ((ironman_downward && (m_idx <= 0)) || (creature_ptr->current_floor_ptr->dun_level <= d_info[creature_ptr->dungeon_idx].mindepth)) {
+#ifdef JP
+        if (see_m)
+            msg_format("%^sは床を突き破って沈んでいく。", m_name);
+#else
+        if (see_m)
+            msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
+#endif
+        if (m_idx <= 0) {
+            if (!creature_ptr->current_floor_ptr->dun_level) {
+                creature_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : creature_ptr->recall_dungeon;
+                creature_ptr->oldpy = creature_ptr->y;
+                creature_ptr->oldpx = creature_ptr->x;
+            }
+
+            if (record_stair)
+                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, 1, NULL);
+
+            if (autosave_l)
+                do_cmd_save_game(creature_ptr, TRUE);
+
+            if (!creature_ptr->current_floor_ptr->dun_level) {
+                creature_ptr->current_floor_ptr->dun_level = d_info[creature_ptr->dungeon_idx].mindepth;
+                prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
+            } else {
+                prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
+            }
+
+            creature_ptr->leaving = TRUE;
+        }
+    } else if (quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level)
+        || (creature_ptr->current_floor_ptr->dun_level >= d_info[creature_ptr->dungeon_idx].maxdepth)) {
+#ifdef JP
+        if (see_m)
+            msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
+#else
+        if (see_m)
+            msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
+#endif
+
+        if (m_idx <= 0) {
+            if (record_stair)
+                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, -1, NULL);
+
+            if (autosave_l)
+                do_cmd_save_game(creature_ptr, TRUE);
+
+            prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
+
+            leave_quest_check(creature_ptr);
+            creature_ptr->current_floor_ptr->inside_quest = 0;
+            creature_ptr->leaving = TRUE;
+        }
+    } else if (go_up) {
+#ifdef JP
+        if (see_m)
+            msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
+#else
+        if (see_m)
+            msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
+#endif
+
+        if (m_idx <= 0) {
+            if (record_stair)
+                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, -1, NULL);
+
+            if (autosave_l)
+                do_cmd_save_game(creature_ptr, TRUE);
+
+            prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
+            creature_ptr->leaving = TRUE;
+        }
+    } else {
+#ifdef JP
+        if (see_m)
+            msg_format("%^sは床を突き破って沈んでいく。", m_name);
+#else
+        if (see_m)
+            msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
+#endif
+
+        if (m_idx <= 0) {
+            if (record_stair)
+                exe_write_diary(creature_ptr, DIARY_TELEPORT_LEVEL, 1, NULL);
+            if (autosave_l)
+                do_cmd_save_game(creature_ptr, TRUE);
+
+            prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
+            creature_ptr->leaving = TRUE;
+        }
+    }
+
+    if (m_idx <= 0) {
+        sound(SOUND_TPLEVEL);
+        return;
+    }
+
+    monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
+    check_quest_completion(creature_ptr, m_ptr);
+    if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+        char m2_name[MAX_NLEN];
+
+        monster_desc(creature_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
+        exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
+    }
+
+    delete_monster_idx(creature_ptr, m_idx);
+    sound(SOUND_TPLEVEL);
+}
+
+bool teleport_level_other(player_type *caster_ptr)
+{
+    if (!target_set(caster_ptr, TARGET_KILL))
+        return FALSE;
+    MONSTER_IDX target_m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
+    if (!target_m_idx)
+        return TRUE;
+    if (!player_has_los_bold(caster_ptr, target_row, target_col))
+        return TRUE;
+    if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
+        return TRUE;
+
+    monster_type *m_ptr;
+    monster_race *r_ptr;
+    m_ptr = &caster_ptr->current_floor_ptr->m_list[target_m_idx];
+    r_ptr = &r_info[m_ptr->r_idx];
+    GAME_TEXT m_name[MAX_NLEN];
+    monster_desc(caster_ptr, m_name, m_ptr, 0);
+    msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
+
+    if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) || (r_ptr->flags1 & RF1_QUESTOR)
+        || (r_ptr->level + randint1(50) > caster_ptr->lev + randint1(60))) {
+        msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
+    } else {
+        teleport_level(caster_ptr, target_m_idx);
+    }
+
+    return TRUE;
+}
+
+/*!
+ * @brief 町間のテレポートを行うメインルーチン
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @return テレポート処理を決定したか否か
+ */
+bool tele_town(player_type *caster_ptr)
+{
+    if (caster_ptr->current_floor_ptr->dun_level) {
+        msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
+        return FALSE;
+    }
+
+    if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out) {
+        msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
+        return FALSE;
+    }
+
+    screen_save();
+    clear_bldg(4, 10);
+
+    int i;
+    int num = 0;
+    for (i = 1; i < max_towns; i++) {
+        char buf[80];
+
+        if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == caster_ptr->town_num) || !(caster_ptr->visit & (1L << (i - 1))))
+            continue;
+
+        sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
+        prt(buf, 5 + i, 5);
+        num++;
+    }
+
+    if (num == 0) {
+        msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
+        msg_print(NULL);
+        screen_load();
+        return FALSE;
+    }
+
+    prt(_("どこに行きますか:", "Where do you want to go: "), 0, 0);
+    while (TRUE) {
+        i = inkey();
+
+        if (i == ESCAPE) {
+            screen_load();
+            return FALSE;
+        }
+
+        else if ((i < 'a') || (i > ('a' + max_towns - 2)))
+            continue;
+        else if (((i - 'a' + 1) == caster_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN)
+            || !(caster_ptr->visit & (1L << (i - 'a'))))
+            continue;
+        break;
+    }
+
+    for (POSITION y = 0; y < current_world_ptr->max_wild_y; y++) {
+        for (POSITION x = 0; x < current_world_ptr->max_wild_x; x++) {
+            if (wilderness[y][x].town == (i - 'a' + 1)) {
+                caster_ptr->wilderness_y = y;
+                caster_ptr->wilderness_x = x;
+            }
+        }
+    }
+
+    caster_ptr->leaving = TRUE;
+    caster_ptr->leave_bldg = TRUE;
+    caster_ptr->teleport_town = TRUE;
+    screen_load();
+    return TRUE;
+}
+
+/*!
+ * @brief 現実変容処理
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void reserve_alter_reality(player_type *caster_ptr)
+{
+    if (caster_ptr->current_floor_ptr->inside_arena || ironman_downward) {
+        msg_print(_("何も起こらなかった。", "Nothing happens."));
+        return;
+    }
+
+    if (caster_ptr->alter_reality) {
+        caster_ptr->alter_reality = 0;
+        msg_print(_("景色が元に戻った...", "The view around you returns to normal..."));
+        caster_ptr->redraw |= PR_STATUS;
+        return;
+    }
+
+    TIME_EFFECT turns = randint0(21) + 15;
+    caster_ptr->alter_reality = turns;
+    msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
+    caster_ptr->redraw |= PR_STATUS;
+}
diff --git a/src/spell-kind/spells-world.h b/src/spell-kind/spells-world.h
new file mode 100644 (file)
index 0000000..34c39b6
--- /dev/null
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "system/angband.h"
+
+void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx);
+bool teleport_level_other(player_type *caster_ptr);
+bool tele_town(player_type *caster_ptr);
+void reserve_alter_reality(player_type *caster_ptr);
+bool is_teleport_level_ineffective(player_type *caster_ptr, MONSTER_IDX idx);
index a33c25b..79d478c 100644 (file)
@@ -29,6 +29,7 @@
 #include "player/player-status.h"
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-world.h"
 #include "spell/spell-types.h"
 #include "status/bad-status-setter.h"
 #include "status/base-status.h"
index 6c60ea1..b3ff1ab 100644 (file)
 #include "world/world.h"
 
 /*!
- * @brief 現実変容処理
- * @param caster_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-void reserve_alter_reality(player_type *caster_ptr)
-{
-    if (caster_ptr->current_floor_ptr->inside_arena || ironman_downward) {
-        msg_print(_("何も起こらなかった。", "Nothing happens."));
-        return;
-    }
-
-    if (caster_ptr->alter_reality) {
-        caster_ptr->alter_reality = 0;
-        msg_print(_("景色が元に戻った...", "The view around you returns to normal..."));
-        caster_ptr->redraw |= PR_STATUS;
-        return;
-    }
-
-    TIME_EFFECT turns = randint0(21) + 15;
-    caster_ptr->alter_reality = turns;
-    msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
-    caster_ptr->redraw |= PR_STATUS;
-}
-
-/*!
  * @brief アーティファクト生成の巻物処理 /
  * @param caster_ptr プレーヤーへの参照ポインタ
  * @return 生成が実際に試みられたらTRUEを返す
@@ -535,76 +510,3 @@ bool shock_power(player_type *caster_ptr)
         caster_ptr->update |= (PU_MON_LITE);
     return TRUE;
 }
-
-/*!
- * @brief 町間のテレポートを行うメインルーチン
- * @param caster_ptr プレーヤーへの参照ポインタ
- * @return テレポート処理を決定したか否か
- */
-bool tele_town(player_type *caster_ptr)
-{
-    if (caster_ptr->current_floor_ptr->dun_level) {
-        msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
-        return FALSE;
-    }
-
-    if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out) {
-        msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
-        return FALSE;
-    }
-
-    screen_save();
-    clear_bldg(4, 10);
-
-    int i;
-    int num = 0;
-    for (i = 1; i < max_towns; i++) {
-        char buf[80];
-
-        if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == caster_ptr->town_num) || !(caster_ptr->visit & (1L << (i - 1))))
-            continue;
-
-        sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
-        prt(buf, 5 + i, 5);
-        num++;
-    }
-
-    if (num == 0) {
-        msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
-        msg_print(NULL);
-        screen_load();
-        return FALSE;
-    }
-
-    prt(_("どこに行きますか:", "Where do you want to go: "), 0, 0);
-    while (TRUE) {
-        i = inkey();
-
-        if (i == ESCAPE) {
-            screen_load();
-            return FALSE;
-        }
-
-        else if ((i < 'a') || (i > ('a' + max_towns - 2)))
-            continue;
-        else if (((i - 'a' + 1) == caster_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN)
-            || !(caster_ptr->visit & (1L << (i - 'a'))))
-            continue;
-        break;
-    }
-
-    for (POSITION y = 0; y < current_world_ptr->max_wild_y; y++) {
-        for (POSITION x = 0; x < current_world_ptr->max_wild_x; x++) {
-            if (wilderness[y][x].town == (i - 'a' + 1)) {
-                caster_ptr->wilderness_y = y;
-                caster_ptr->wilderness_x = x;
-            }
-        }
-    }
-
-    caster_ptr->leaving = TRUE;
-    caster_ptr->leave_bldg = TRUE;
-    caster_ptr->teleport_town = TRUE;
-    screen_load();
-    return TRUE;
-}
index 2c9a575..fa1ddf5 100644 (file)
@@ -2,7 +2,6 @@
 
 #include "system/angband.h"
 
-void reserve_alter_reality(player_type* caster_ptr);
 bool artifact_scroll(player_type* caster_ptr);
 bool mundane_spell(player_type* ownner_ptr, bool only_equip);
 bool recharge(player_type* caster_ptr, int power);