From: deskull Date: Fri, 6 Dec 2019 07:13:35 +0000 (+0900) Subject: [Refactor] #38997 teleport_away() に player_type * 引数を追加. / Add player_type * argument... X-Git-Tag: vmacos3.0.0-alpha52~2467 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=338960bc2953738c3634a7fe4d8c41d09562ed8c;p=hengbandforosx%2Fhengbandosx.git [Refactor] #38997 teleport_away() に player_type * 引数を追加. / Add player_type * argument to teleport_away(). --- diff --git a/src/combat/melee1.c b/src/combat/melee1.c index d1c18ba6e..69ee55ae3 100644 --- a/src/combat/melee1.c +++ b/src/combat/melee1.c @@ -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); } } diff --git a/src/mspells4.c b/src/mspells4.c index 94a0152de..107ce161a 100644 --- a/src/mspells4.c +++ b/src/mspells4.c @@ -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); diff --git a/src/spells-floor.c b/src/spells-floor.c index 7a2e65f89..14402b098 100644 --- a/src/spells-floor.c +++ b/src/spells-floor.c @@ -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 { diff --git a/src/spells.h b/src/spells.h index b0be0741a..12dd815fa 100644 --- a/src/spells.h +++ b/src/spells.h @@ -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); diff --git a/src/spells1.c b/src/spells1.c index 52d1f134a..b2109ad38 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -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 */ diff --git a/src/spells3.c b/src/spells3.c index 6db77d0f8..542f91f8d 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -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; }