• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision502f8f8d3b435af1f6984233b36c74a72b3d32c3 (tree)
Time2004-02-03 23:10:46
Authornothere <nothere@0568...>
Commiternothere

Log Message

プレイヤーのテレポート関数をteleport_player()とteleport_player_aux()
に分割. teleport_player_aux()で実際のテレポート処理を行い,
teleport_player()はteleport_player_aux()を呼んでからモンスターの追尾
処理を行う. これを利用し, 以下の変更と修正を行った.
* モンスターのテレポートアウェイでプレイヤーが飛ばされた際に, テレ

ポートアウェイを使ったモンスター自身が追尾してくるバグを修正. モン
スターがプレイヤーをテレポートさせる処理はteleport_player_away()と
してまとめ, teleport_player_aux()を呼ぶようにした.

* spells3.c 1.134で, 広域マップまたは反テレポートでテレポートを禁止す

る処理が削除されてしまっていたので復帰させた.

* アルコールで記憶が飛んで知らない場所に "歩いた" 場合のテレポートに

は追尾しないように変更. また, 非魔法的な移動と見て反テレポートや
CAVE_ICKYを無視するように変更.

* テレポートしてプレイヤー位置が変わらない場合はupdateや効果音などの

処理を行わないように変更.

Change Summary

Incremental Difference

--- a/src/cmd6.c
+++ b/src/cmd6.c
@@ -884,11 +884,11 @@ static void do_cmd_quaff_potion_aux(int item)
884884 ident = TRUE;
885885 if (one_in_(3)) lose_all_info();
886886 else wiz_dark();
887- teleport_player(100, TRUE);
887+ (void)teleport_player_aux(100, TRUE, TRUE);
888888 wiz_dark();
889889 #ifdef JP
890-msg_print("知らない場所で目が醒めた。頭痛がする。");
891-msg_print("何も思い出せない。どうやってここへ来たのかも分からない!");
890+ msg_print("知らない場所で目が醒めた。頭痛がする。");
891+ msg_print("何も思い出せない。どうやってここへ来たのかも分からない!");
892892 #else
893893 msg_print("You wake up somewhere with a sore head...");
894894 msg_print("You can't remember a thing, or how you got here!");
--- a/src/dungeon.c
+++ b/src/dungeon.c
@@ -2294,7 +2294,7 @@ static void process_world_aux_mutation(void)
22942294 msg_print(NULL);
22952295 if (one_in_(3)) lose_all_info();
22962296 else wiz_dark();
2297- teleport_player(100, TRUE);
2297+ (void)teleport_player_aux(100, TRUE, TRUE);
22982298 wiz_dark();
22992299 #ifdef JP
23002300 msg_print("あなたは見知らぬ場所で目が醒めた...頭が痛い。");
--- a/src/externs.h
+++ b/src/externs.h
@@ -1143,7 +1143,9 @@ extern void remove_all_mirrors(bool explode);
11431143 extern bool teleport_away(int m_idx, int dis, bool dec_valour, bool passive);
11441144 extern void teleport_monster_to(int m_idx, int ty, int tx, int power, bool passive);
11451145 extern bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical);
1146+extern bool teleport_player_aux(int dis, bool passive, bool nonmagical);
11461147 extern void teleport_player(int dis, bool passive);
1148+extern void teleport_player_away(int m_idx, int dis);
11471149 extern void teleport_player_to(int ny, int nx, bool no_tele, bool passive);
11481150 extern void teleport_away_followable(int m_idx);
11491151 extern void teleport_level(int m_idx);
--- a/src/mspells1.c
+++ b/src/mspells1.c
@@ -3636,7 +3636,7 @@ msg_format("%^s
36363636 #endif
36373637
36383638 learn_spell(MS_TELE_AWAY);
3639- teleport_player(100, TRUE);
3639+ teleport_player_away(m_idx, 100);
36403640 break;
36413641 }
36423642
--- a/src/mspells2.c
+++ b/src/mspells2.c
@@ -3342,7 +3342,7 @@ bool monst_spell_monst(int m_idx)
33423342
33433343 if (!resists_tele)
33443344 {
3345- if (t_idx == p_ptr->riding) teleport_player(MAX_SIGHT * 2 + 5, TRUE);
3345+ if (t_idx == p_ptr->riding) teleport_player_away(m_idx, MAX_SIGHT * 2 + 5);
33463346 else teleport_away(t_idx, MAX_SIGHT * 2 + 5, FALSE, TRUE);
33473347 }
33483348
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -314,18 +314,30 @@ bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical)
314314
315315 #define MAX_TELEPORT_DISTANCE 200
316316
317-void teleport_player(int dis, bool passive)
317+bool teleport_player_aux(int dis, bool passive, bool nonmagical)
318318 {
319319 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
320320 int total_candidates, cur_candidates;
321321 int y = 0, x = 0, min, pick, i;
322- int yy, xx, oy, ox;
323322
324323 int left = MAX(1, px - dis);
325324 int right = MIN(cur_wid - 2, px + dis);
326325 int top = MAX(1, py - dis);
327326 int bottom = MIN(cur_hgt - 2, py + dis);
328327
328+ if (p_ptr->wild_mode) return FALSE;
329+
330+ if (p_ptr->anti_tele && !nonmagical)
331+ {
332+#ifdef JP
333+ msg_print("不思議な力がテレポートを防いだ!");
334+#else
335+ msg_print("A mysterious force prevents you from teleporting!");
336+#endif
337+
338+ return FALSE;
339+ }
340+
329341 /* Initialize counters */
330342 total_candidates = 0;
331343 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
@@ -342,7 +354,7 @@ void teleport_player(int dis, bool passive)
342354 int d;
343355
344356 /* Skip illegal locations */
345- if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
357+ if (!cave_player_teleportable_bold(y, x, passive, nonmagical)) continue;
346358
347359 /* Calculate distance */
348360 d = distance(py, px, y, x);
@@ -351,15 +363,15 @@ void teleport_player(int dis, bool passive)
351363 if (d > dis) continue;
352364
353365 /* Count the total number of candidates */
354- total_candidates++;
366+ total_candidates++;
355367
356368 /* Count the number of candidates in this circumference */
357- candidates_at[d]++;
369+ candidates_at[d]++;
358370 }
359371 }
360372
361373 /* No valid location! */
362- if (0 == total_candidates) return;
374+ if (0 == total_candidates) return FALSE;
363375
364376 /* Fix the minimum distance */
365377 for (cur_candidates = 0, min = dis; min >= 0; min--)
@@ -401,6 +413,8 @@ void teleport_player(int dis, bool passive)
401413 if (!pick) break;
402414 }
403415
416+ if (player_bold(y, x)) return FALSE;
417+
404418 /* Sound */
405419 sound(SOUND_TELEPORT);
406420
@@ -409,13 +423,22 @@ void teleport_player(int dis, bool passive)
409423 msg_format("『こっちだぁ、%s』", player_name);
410424 #endif
411425
412- /* Save the old location */
413- oy = py;
414- ox = px;
415-
416426 /* Move the player */
417427 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
418428
429+ return TRUE;
430+}
431+
432+void teleport_player(int dis, bool passive)
433+{
434+ int yy, xx;
435+
436+ /* Save the old location */
437+ int oy = py;
438+ int ox = px;
439+
440+ if (!teleport_player_aux(dis, passive, FALSE)) return;
441+
419442 /* Monsters with teleport ability may follow the player */
420443 for (xx = -1; xx < 2; xx++)
421444 {
@@ -424,7 +447,45 @@ void teleport_player(int dis, bool passive)
424447 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
425448
426449 /* A monster except your mount may follow */
427- if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
450+ if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
451+ {
452+ monster_type *m_ptr = &m_list[tmp_m_idx];
453+ monster_race *r_ptr = &r_info[m_ptr->r_idx];
454+
455+ /*
456+ * The latter limitation is to avoid
457+ * totally unkillable suckers...
458+ */
459+ if ((r_ptr->flags6 & RF6_TPORT) &&
460+ !(r_ptr->flagsr & RFR_RES_TELE))
461+ {
462+ if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, FALSE);
463+ }
464+ }
465+ }
466+ }
467+}
468+
469+
470+void teleport_player_away(int m_idx, int dis)
471+{
472+ int yy, xx;
473+
474+ /* Save the old location */
475+ int oy = py;
476+ int ox = px;
477+
478+ if (!teleport_player_aux(dis, TRUE, FALSE)) return;
479+
480+ /* Monsters with teleport ability may follow the player */
481+ for (xx = -1; xx < 2; xx++)
482+ {
483+ for (yy = -1; yy < 2; yy++)
484+ {
485+ int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
486+
487+ /* A monster except your mount or caster may follow */
488+ if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
428489 {
429490 monster_type *m_ptr = &m_list[tmp_m_idx];
430491 monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -436,7 +497,7 @@ void teleport_player(int dis, bool passive)
436497 if ((r_ptr->flags6 & RF6_TPORT) &&
437498 !(r_ptr->flagsr & RFR_RES_TELE))
438499 {
439- if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level, FALSE);
500+ if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, FALSE);
440501 }
441502 }
442503 }
Show on old repository browser