OSDN Git Service

プレイヤーのテレポート関数をteleport_player()とteleport_player_aux()
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 3 Feb 2004 14:10:46 +0000 (14:10 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 3 Feb 2004 14:10:46 +0000 (14:10 +0000)
に分割. teleport_player_aux()で実際のテレポート処理を行い,
teleport_player()はteleport_player_aux()を呼んでからモンスターの追尾
処理を行う. これを利用し, 以下の変更と修正を行った.
* モンスターのテレポートアウェイでプレイヤーが飛ばされた際に, テレ
  ポートアウェイを使ったモンスター自身が追尾してくるバグを修正. モン
  スターがプレイヤーをテレポートさせる処理はteleport_player_away()と
  してまとめ, teleport_player_aux()を呼ぶようにした.
* spells3.c 1.134で, 広域マップまたは反テレポートでテレポートを禁止す
  る処理が削除されてしまっていたので復帰させた.
* アルコールで記憶が飛んで知らない場所に "歩いた" 場合のテレポートに
  は追尾しないように変更. また, 非魔法的な移動と見て反テレポートや
  CAVE_ICKYを無視するように変更.
* テレポートしてプレイヤー位置が変わらない場合はupdateや効果音などの
  処理を行わないように変更.

src/cmd6.c
src/dungeon.c
src/externs.h
src/mspells1.c
src/mspells2.c
src/spells3.c

index b5071e7..ebd8d1a 100644 (file)
@@ -884,11 +884,11 @@ static void do_cmd_quaff_potion_aux(int item)
                                        ident = TRUE;
                                        if (one_in_(3)) lose_all_info();
                                        else wiz_dark();
-                                       teleport_player(100, TRUE);
+                                       (void)teleport_player_aux(100, TRUE, TRUE);
                                        wiz_dark();
 #ifdef JP
-msg_print("ÃΤé¤Ê¤¤¾ì½ê¤ÇÌܤ¬Àä᤿¡£Æ¬Äˤ¬¤¹¤ë¡£");
-msg_print("²¿¤â»×¤¤½Ð¤»¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ØÍ褿¤Î¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
+                                       msg_print("ÃΤé¤Ê¤¤¾ì½ê¤ÇÌܤ¬Àä᤿¡£Æ¬Äˤ¬¤¹¤ë¡£");
+                                       msg_print("²¿¤â»×¤¤½Ð¤»¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ØÍ褿¤Î¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
 #else
                                        msg_print("You wake up somewhere with a sore head...");
                                        msg_print("You can't remember a thing, or how you got here!");
index 29083b4..be59821 100644 (file)
@@ -2294,7 +2294,7 @@ static void process_world_aux_mutation(void)
                                msg_print(NULL);
                                if (one_in_(3)) lose_all_info();
                                else wiz_dark();
-                               teleport_player(100, TRUE);
+                               (void)teleport_player_aux(100, TRUE, TRUE);
                                wiz_dark();
 #ifdef JP
                                msg_print("¤¢¤Ê¤¿¤Ï¸«ÃΤé¤Ì¾ì½ê¤ÇÌܤ¬Àä᤿...Ƭ¤¬Äˤ¤¡£");
index ad3d6ff..81c0386 100644 (file)
@@ -1143,7 +1143,9 @@ extern void remove_all_mirrors(bool explode);
 extern bool teleport_away(int m_idx, int dis, bool dec_valour, bool passive);
 extern void teleport_monster_to(int m_idx, int ty, int tx, int power, bool passive);
 extern bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical);
+extern bool teleport_player_aux(int dis, bool passive, bool nonmagical);
 extern void teleport_player(int dis, bool passive);
+extern void teleport_player_away(int m_idx, int dis);
 extern void teleport_player_to(int ny, int nx, bool no_tele, bool passive);
 extern void teleport_away_followable(int m_idx);
 extern void teleport_level(int m_idx);
index fd885b0..3d29ace 100644 (file)
@@ -3636,7 +3636,7 @@ msg_format("%^s
 #endif
 
                        learn_spell(MS_TELE_AWAY);
-                       teleport_player(100, TRUE);
+                       teleport_player_away(m_idx, 100);
                        break;
                }
 
index a5d90b0..520fcf1 100644 (file)
@@ -3342,7 +3342,7 @@ bool monst_spell_monst(int m_idx)
 
                if (!resists_tele)
                {
-                       if (t_idx == p_ptr->riding) teleport_player(MAX_SIGHT * 2 + 5, TRUE);
+                       if (t_idx == p_ptr->riding) teleport_player_away(m_idx, MAX_SIGHT * 2 + 5);
                        else teleport_away(t_idx, MAX_SIGHT * 2 + 5, FALSE, TRUE);
                }
 
index 36fa0d5..2a0da69 100644 (file)
@@ -314,18 +314,30 @@ bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical)
 
 #define MAX_TELEPORT_DISTANCE 200
 
-void teleport_player(int dis, bool passive)
+bool teleport_player_aux(int dis, bool passive, bool nonmagical)
 {
        int candidates_at[MAX_TELEPORT_DISTANCE + 1];
        int total_candidates, cur_candidates;
        int y = 0, x = 0, min, pick, i;
-       int yy, xx, oy, ox;
 
        int left = MAX(1, px - dis);
        int right = MIN(cur_wid - 2, px + dis);
        int top = MAX(1, py - dis);
        int bottom = MIN(cur_hgt - 2, py + dis);
 
+       if (p_ptr->wild_mode) return FALSE;
+
+       if (p_ptr->anti_tele && !nonmagical)
+       {
+#ifdef JP
+               msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
+#else
+               msg_print("A mysterious force prevents you from teleporting!");
+#endif
+
+               return FALSE;
+       }
+
        /* Initialize counters */
        total_candidates = 0;
        for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
@@ -342,7 +354,7 @@ void teleport_player(int dis, bool passive)
                        int d;
 
                        /* Skip illegal locations */
-                       if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
+                       if (!cave_player_teleportable_bold(y, x, passive, nonmagical)) continue;
 
                        /* Calculate distance */
                        d = distance(py, px, y, x);
@@ -351,15 +363,15 @@ void teleport_player(int dis, bool passive)
                        if (d > dis) continue;
 
                        /* Count the total number of candidates */
-                       total_candidates++; 
+                       total_candidates++;
 
                        /* Count the number of candidates in this circumference */
-                       candidates_at[d]++; 
+                       candidates_at[d]++;
                }
        }
 
        /* No valid location! */
-       if (0 == total_candidates) return;
+       if (0 == total_candidates) return FALSE;
 
        /* Fix the minimum distance */
        for (cur_candidates = 0, min = dis; min >= 0; min--)
@@ -401,6 +413,8 @@ void teleport_player(int dis, bool passive)
                if (!pick) break;
        }
 
+       if (player_bold(y, x)) return FALSE;
+
        /* Sound */
        sound(SOUND_TELEPORT);
 
@@ -409,13 +423,22 @@ void teleport_player(int dis, bool passive)
                msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
 #endif
 
-       /* Save the old location */
-       oy = py;
-       ox = px;
-
        /* Move the player */
        (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
 
+       return TRUE;
+}
+
+void teleport_player(int dis, bool passive)
+{
+       int yy, xx;
+
+       /* Save the old location */
+       int oy = py;
+       int ox = px;
+
+       if (!teleport_player_aux(dis, passive, FALSE)) return;
+
        /* Monsters with teleport ability may follow the player */
        for (xx = -1; xx < 2; xx++)
        {
@@ -424,7 +447,45 @@ void teleport_player(int dis, bool passive)
                        int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
 
                        /* A monster except your mount may follow */
-                       if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
+                       if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
+                       {
+                               monster_type *m_ptr = &m_list[tmp_m_idx];
+                               monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+                               /*
+                                * The latter limitation is to avoid
+                                * totally unkillable suckers...
+                                */
+                               if ((r_ptr->flags6 & RF6_TPORT) &&
+                                   !(r_ptr->flagsr & RFR_RES_TELE))
+                               {
+                                       if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, FALSE);
+                               }
+                       }
+               }
+       }
+}
+
+
+void teleport_player_away(int m_idx, int dis)
+{
+       int yy, xx;
+
+       /* Save the old location */
+       int oy = py;
+       int ox = px;
+
+       if (!teleport_player_aux(dis, TRUE, FALSE)) return;
+
+       /* Monsters with teleport ability may follow the player */
+       for (xx = -1; xx < 2; xx++)
+       {
+               for (yy = -1; yy < 2; yy++)
+               {
+                       int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
+
+                       /* A monster except your mount or caster may follow */
+                       if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
                        {
                                monster_type *m_ptr = &m_list[tmp_m_idx];
                                monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -436,7 +497,7 @@ void teleport_player(int dis, bool passive)
                                if ((r_ptr->flags6 & RF6_TPORT) &&
                                    !(r_ptr->flagsr & RFR_RES_TELE))
                                {
-                                       if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level, FALSE);
+                                       if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, FALSE);
                                }
                        }
                }