OSDN Git Service

[Refactor] #38997 teleport_away() に player_type * 引数を追加. / Add player_type * argument...
authordeskull <deskull@users.sourceforge.jp>
Fri, 6 Dec 2019 07:13:35 +0000 (16:13 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Fri, 6 Dec 2019 07:13:35 +0000 (16:13 +0900)
src/combat/melee1.c
src/mspells4.c
src/spells-floor.c
src/spells.h
src/spells1.c
src/spells3.c

index d1c18ba..69ee55a 100644 (file)
@@ -1977,7 +1977,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                                if (!resists_tele)
                                {
                                        msg_format(_("%^sは消えた!", "%^s disappears!"), m_name);
-                                       teleport_away(g_ptr->m_idx, 50, TELEPORT_PASSIVE);
+                                       teleport_away(attacker_ptr, g_ptr->m_idx, 50, TELEPORT_PASSIVE);
                                        num = num_blow + 1; /* Can't hit it anymore! */
                                        *mdeath = TRUE;
                                }
@@ -4088,7 +4088,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                else
                {
                        msg_print(_("泥棒は笑って逃げた!", "The thief flees laughing!"));
-                       teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
+                       teleport_away(target_ptr, m_idx, MAX_SIGHT * 2 + 5, 0L);
                }
        }
 
@@ -4735,7 +4735,7 @@ bool monst_attack_monst(player_type *subject_ptr, MONSTER_IDX m_idx, MONSTER_IDX
                                subject_ptr->current_floor_ptr->monster_noise = TRUE;
                        }
 
-                       teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
+                       teleport_away(subject_ptr, m_idx, MAX_SIGHT * 2 + 5, 0L);
                }
        }
 
index 94a0152..107ce16 100644 (file)
@@ -1876,7 +1876,7 @@ void spell_RF6_BLINK(MONSTER_IDX m_idx, int TARGET_TYPE)
                if(see_monster(m_idx))
                        msg_format(_("%^sが瞬時に消えた。", "%^s blinks away."), m_name);
 
-               teleport_away(m_idx, 10, 0L);
+               teleport_away(p_ptr, m_idx, 10, 0L);
 
                if (TARGET_TYPE==MONSTER_TO_PLAYER)
                        p_ptr->update |= (PU_MONSTERS);
@@ -2054,7 +2054,7 @@ HIT_POINT spell_RF6_SPECIAL_B(POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER
                        _("%^sは突然急上昇して視界から消えた!", "%^s suddenly go out of your sight!"),
                        TARGET_TYPE);
                                
-               teleport_away(m_idx, 10, TELEPORT_NONMAGICAL);
+               teleport_away(p_ptr, m_idx, 10, TELEPORT_NONMAGICAL);
                p_ptr->update |= (PU_MONSTERS);
        }
        else
@@ -2290,7 +2290,7 @@ void spell_RF6_TELE_AWAY(MONSTER_IDX m_idx, MONSTER_IDX t_idx, int TARGET_TYPE)
                        if (t_idx == p_ptr->riding) 
                                teleport_player_away(m_idx, MAX_SIGHT * 2 + 5);
                        else 
-                               teleport_away(t_idx, MAX_SIGHT * 2 + 5, TELEPORT_PASSIVE);
+                               teleport_away(p_ptr, t_idx, MAX_SIGHT * 2 + 5, TELEPORT_PASSIVE);
                }
 
                set_monster_csleep(t_idx, 0);
index 7a2e65f..14402b0 100644 (file)
@@ -535,7 +535,7 @@ bool destroy_area(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION r, b
                                        m_ptr->hp = m_ptr->maxhp;
 
                                        /* Try to teleport away quest monsters */
-                                       if (!teleport_away(g_ptr->m_idx, (r * 2) + 1, TELEPORT_DEC_VALOUR)) continue;
+                                       if (!teleport_away(p_ptr, g_ptr->m_idx, (r * 2) + 1, TELEPORT_DEC_VALOUR)) continue;
                                }
                                else
                                {
index b0be074..12dd815 100644 (file)
@@ -282,7 +282,7 @@ extern bool concentration(player_type *creature_ptr);
 #define TELEPORT_DEC_VALOUR 0x00000004
 
 /* spells3.c */
-extern bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode);
+extern bool teleport_away(player_type *caster_ptr, MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode);
 extern void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode);
 extern bool teleport_player_aux(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode);
 extern void teleport_player(POSITION dis, BIT_FLAGS mode);
index 52d1f13..b2109ad 100644 (file)
@@ -3741,7 +3741,7 @@ static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                        if (!who) chg_virtue(p_ptr, V_VALOUR, -1);
 
                        /* Teleport */
-                       teleport_away(g_ptr->m_idx, do_dist,
+                       teleport_away(p_ptr, g_ptr->m_idx, do_dist,
                                                (!who ? TELEPORT_DEC_VALOUR : 0L) | TELEPORT_PASSIVE);
 
                        /* Hack -- get new location */
index 6db77d0..542f91f 100644 (file)
@@ -74,7 +74,7 @@
  * Attempt to move the monster at least "dis/2" grids away.
  * But allow variation to prevent infinite loops.
  */
-bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
+bool teleport_away(player_type *caster_ptr, MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
 {
        POSITION oy, ox, d, i, min;
        int tries = 0;
@@ -82,7 +82,7 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
 
        bool look = TRUE;
 
-       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
        if (!monster_is_valid(m_ptr)) return (FALSE);
 
        oy = m_ptr->fy;
@@ -92,10 +92,10 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        min = dis / 2;
 
        if ((mode & TELEPORT_DEC_VALOUR) &&
-           (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
-               (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
+           (((caster_ptr->chp * 10) / caster_ptr->mhp) > 5) &&
+               (4+randint1(5) < ((caster_ptr->chp * 10) / caster_ptr->mhp)))
        {
-               chg_virtue(p_ptr, V_VALOUR, -1);
+               chg_virtue(caster_ptr, V_VALOUR, -1);
        }
 
        /* Look until done */
@@ -119,13 +119,13 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
                        }
 
                        /* Ignore illegal locations */
-                       if (!in_bounds(p_ptr->current_floor_ptr, ny, nx)) continue;
+                       if (!in_bounds(caster_ptr->current_floor_ptr, ny, nx)) continue;
 
                        if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
 
                        /* No teleporting into vaults and such */
-                       if (!(p_ptr->inside_quest || p_ptr->inside_arena))
-                               if (p_ptr->current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
+                       if (!(caster_ptr->inside_quest || caster_ptr->inside_arena))
+                               if (caster_ptr->current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
 
                        /* This grid looks good */
                        look = FALSE;
@@ -147,10 +147,10 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        sound(SOUND_TPOTHER);
 
        /* Update the old location */
-       p_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
+       caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
 
        /* Update the new location */
-       p_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
+       caster_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
 
        /* Move the monster */
        m_ptr->fy = ny;
@@ -164,7 +164,7 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        lite_spot(ny, nx);
 
        if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
-               p_ptr->update |= (PU_MON_LITE);
+               caster_ptr->update |= (PU_MON_LITE);
 
        return (TRUE);
 }
@@ -540,7 +540,7 @@ void teleport_away_followable(MONSTER_IDX m_idx)
        bool old_ml = m_ptr->ml;
        POSITION old_cdis = m_ptr->cdis;
 
-       teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
+       teleport_away(p_ptr, m_idx, MAX_SIGHT * 2 + 5, 0L);
 
        if (old_ml && (old_cdis <= MAX_SIGHT) && !current_world_ptr->timewalk_m_idx && !p_ptr->phase_out && los(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, oldfy, oldfx))
        {
@@ -3507,7 +3507,7 @@ void blood_curse_to_enemy(MONSTER_IDX m_idx)
                        {
                                msg_print(_("空間が歪んだ!", "Space warps about you!"));
 
-                               if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
+                               if (m_ptr->r_idx) teleport_away(p_ptr, g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
                                if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
                                if (!one_in_(6)) break;
                        }