OSDN Git Service

[Refactor] #38997 teleport_player() に player_type * 引数を追加. / Add player_type * argume...
[hengband/hengband.git] / src / combat / melee1.c
index e3a1b80..d52cb1e 100644 (file)
@@ -427,7 +427,7 @@ const byte adj_dex_blow[] =
  * @brief
  * 腕力、器用さに応じた攻撃回数テーブル /
  * This table is used to help calculate the number of blows the player can
- * make in a single round of attacks (one player current_world_ptr->game_turn) with a normal weapon.
+ * make in a single round of attacks (one player turn) with a normal weapon.
  * @details
  * <pre>
  * This number ranges from a single blow/round for weak players to up to six
@@ -1125,15 +1125,16 @@ static void touch_zap_player_aux(monster_type *m_ptr, bool immune, int flags_off
 /*!
 * @brief 敵オーラによるプレイヤーのダメージ処理(メイン)
 * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
+* @param touched_ptr オーラを持つ相手に振れたクリーチャーの参照ポインタ
 * @return なし
 */
-static void touch_zap_player(monster_type *m_ptr)
+static void touch_zap_player(monster_type *m_ptr, player_type *touched_ptr)
 {
-       touch_zap_player_aux(m_ptr, p_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
+       touch_zap_player_aux(m_ptr, touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
                fire_dam, _("突然とても熱くなった!", "You are suddenly very hot!"));
-       touch_zap_player_aux(m_ptr, p_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
+       touch_zap_player_aux(m_ptr, touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
                cold_dam, _("突然とても寒くなった!", "You are suddenly very cold!"));
-       touch_zap_player_aux(m_ptr, p_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
+       touch_zap_player_aux(m_ptr, touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
                elec_dam, _("電撃をくらった!", "You get zapped!"));
 }
 
@@ -1150,7 +1151,7 @@ static void natural_attack(MONSTER_IDX m_idx, int attack, bool *fear, bool *mdea
        HIT_POINT k;
        int bonus, chance;
        WEIGHT n_weight = 0;
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        GAME_TEXT m_name[MAX_NLEN];
 
@@ -1256,7 +1257,7 @@ static void natural_attack(MONSTER_IDX m_idx, int attack, bool *fear, bool *mdea
                        *mdeath = mon_take_hit(m_idx, k, fear, NULL);
                }
 
-               touch_zap_player(m_ptr);
+               touch_zap_player(m_ptr, p_ptr);
        }
        /* Player misses */
        else
@@ -1284,9 +1285,10 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
        int num = 0, bonus, chance, vir;
        HIT_POINT k;
 
-       grid_type       *g_ptr = &current_floor_ptr->grid_array[y][x];
+       floor_type *floor_ptr = attacker_ptr->current_floor_ptr;
+       grid_type       *g_ptr = &floor_ptr->grid_array[y][x];
 
-       monster_type    *m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
+       monster_type    *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Access the weapon */
@@ -1845,7 +1847,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                        /* Anger the monster */
                        if (k > 0) anger_monster(m_ptr);
 
-                       touch_zap_player(m_ptr);
+                       touch_zap_player(m_ptr, attacker_ptr);
 
                        /* Are we draining it?  A little note: If the monster is
                        dead, the drain does not work... */
@@ -1975,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;
                                }
@@ -1986,7 +1988,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                                if (!(r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) &&
                                        !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
                                {
-                                       if (polymorph_monster(y, x))
+                                       if (polymorph_monster(attacker_ptr, y, x))
                                        {
                                                msg_format(_("%^sは変化した!", "%^s changes!"), m_name);
                                                *fear = FALSE;
@@ -1998,7 +2000,7 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                                        }
 
                                        /* Hack -- Get new monster */
-                                       m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
+                                       m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
 
                                        /* Oops, we need a different name... */
                                        monster_desc(m_name, m_ptr, 0);
@@ -2009,11 +2011,11 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
                        }
                        else if (o_ptr->name1 == ART_G_HAMMER)
                        {
-                               monster_type *target_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
+                               monster_type *target_ptr = &floor_ptr->m_list[g_ptr->m_idx];
 
                                if (target_ptr->hold_o_idx)
                                {
-                                       object_type *q_ptr = &current_floor_ptr->o_list[target_ptr->hold_o_idx];
+                                       object_type *q_ptr = &floor_ptr->o_list[target_ptr->hold_o_idx];
                                        GAME_TEXT o_name[MAX_NLEN];
 
                                        object_desc(o_name, q_ptr, OD_NAME_ONLY);
@@ -2152,8 +2154,8 @@ static void py_attack_aux(player_type *attacker_ptr, POSITION y, POSITION x, boo
        /* Mega-Hack -- apply earthquake brand */
        if (do_quake)
        {
-               earthquake(attacker_ptr->y, attacker_ptr->x, 10, 0);
-               if (!current_floor_ptr->grid_array[y][x].m_idx) *mdeath = TRUE;
+               earthquake(attacker_ptr, attacker_ptr->y, attacker_ptr->x, 10, 0);
+               if (!floor_ptr->grid_array[y][x].m_idx) *mdeath = TRUE;
        }
 }
 
@@ -2172,8 +2174,8 @@ bool py_attack(player_type *attacker_ptr, POSITION y, POSITION x, COMBAT_OPTION_
        bool            mdeath = FALSE;
        bool            stormbringer = FALSE;
 
-       grid_type       *g_ptr = &current_floor_ptr->grid_array[y][x];
-       monster_type    *m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
+       grid_type       *g_ptr = &attacker_ptr->current_floor_ptr->grid_array[y][x];
+       monster_type    *m_ptr = &attacker_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        GAME_TEXT m_name[MAX_NLEN];
 
@@ -2292,7 +2294,7 @@ bool py_attack(player_type *attacker_ptr, POSITION y, POSITION x, COMBAT_OPTION_
 
                if (cur < max)
                {
-                       DEPTH ridinglevel = r_info[current_floor_ptr->m_list[attacker_ptr->riding].r_idx].level;
+                       DEPTH ridinglevel = r_info[attacker_ptr->current_floor_ptr->m_list[attacker_ptr->riding].r_idx].level;
                        DEPTH targetlevel = r_ptr->level;
                        int inc = 0;
 
@@ -2355,7 +2357,7 @@ bool py_attack(player_type *attacker_ptr, POSITION y, POSITION x, COMBAT_OPTION_
  */
 bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        int ap_cnt;
@@ -2838,7 +2840,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                        if (!target_ptr->resist_disen && !CHECK_MULTISHADOW(target_ptr))
                                        {
                                                /* Apply disenchantment */
-                                               if (apply_disenchant(0))
+                                               if (apply_disenchant(target_ptr, 0))
                                                {
                                                        /* Hack -- Update AC */
                                                        update_creature(target_ptr);
@@ -3018,7 +3020,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                                if (o_idx)
                                                {
                                                        object_type *j_ptr;
-                                                       j_ptr = &current_floor_ptr->o_list[o_idx];
+                                                       j_ptr = &p_ptr->current_floor_ptr->o_list[o_idx];
                                                        object_copy(j_ptr, o_ptr);
 
                                                        /* Modify number */
@@ -3377,7 +3379,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                        /* Radius 8 earthquake centered at the monster */
                                        if (damage > 23 || explode)
                                        {
-                                               earthquake(m_ptr->fy, m_ptr->fx, 8, m_idx);
+                                               earthquake(target_ptr, m_ptr->fy, m_ptr->fx, 8, m_idx);
                                        }
 
                                        break;
@@ -3833,9 +3835,9 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                                        r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_RES_SHAR_MASK);
                                        }
 
-                                       if (is_mirror_grid(&current_floor_ptr->grid_array[target_ptr->y][target_ptr->x]))
+                                       if (is_mirror_grid(&p_ptr->current_floor_ptr->grid_array[target_ptr->y][target_ptr->x]))
                                        {
-                                               teleport_player(10, 0L);
+                                               teleport_player(target_ptr, 10, 0L);
                                        }
                                }
 
@@ -4031,7 +4033,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                if (target_ptr->riding && damage)
                {
                        char m_steed_name[MAX_NLEN];
-                       monster_desc(m_steed_name, &current_floor_ptr->m_list[target_ptr->riding], 0);
+                       monster_desc(m_steed_name, &p_ptr->current_floor_ptr->m_list[target_ptr->riding], 0);
                        if (rakuba(target_ptr, (damage > 200) ? 200 : damage, FALSE))
                        {
                                msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_steed_name);
@@ -4086,13 +4088,13 @@ 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);
                }
        }
 
 
        /* Always notice cause of death */
-       if (target_ptr->is_dead && (r_ptr->r_deaths < MAX_SHORT) && !target_ptr->inside_arena)
+       if (target_ptr->is_dead && (r_ptr->r_deaths < MAX_SHORT) && !target_ptr->current_floor_ptr->inside_arena)
        {
                r_ptr->r_deaths++;
        }
@@ -4124,10 +4126,10 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
  * @param t_idx 目標側モンスターの参照ID
  * @return 実際に打撃処理が行われた場合TRUEを返す
  */
-bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
+bool monst_attack_monst(player_type *subject_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 {
-       monster_type    *m_ptr = &current_floor_ptr->m_list[m_idx];
-       monster_type    *t_ptr = &current_floor_ptr->m_list[t_idx];
+       monster_type    *m_ptr = &subject_ptr->current_floor_ptr->m_list[m_idx];
+       monster_type    *t_ptr = &subject_ptr->current_floor_ptr->m_list[t_idx];
 
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        monster_race    *tr_ptr = &r_info[t_ptr->r_idx];
@@ -4150,7 +4152,7 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 
        /* Can the player be aware of this attack? */
        bool known = (m_ptr->cdis <= MAX_SIGHT) || (t_ptr->cdis <= MAX_SIGHT);
-       bool do_silly_attack = (one_in_(2) && p_ptr->image);
+       bool do_silly_attack = (one_in_(2) && subject_ptr->image);
 
        /* Cannot attack self */
        if (m_idx == t_idx) return FALSE;
@@ -4158,7 +4160,7 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
        /* Not allowed to attack */
        if (r_ptr->flags1 & RF1_NEVER_BLOW) return FALSE;
 
-       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE) return (FALSE);
+       if (d_info[subject_ptr->dungeon_idx].flags1 & DF1_NO_MELEE) return (FALSE);
 
        /* Total armor */
        ac = tr_ptr->ac;
@@ -4174,10 +4176,10 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 
        if (!see_either && known)
        {
-               current_floor_ptr->monster_noise = TRUE;
+               subject_ptr->current_floor_ptr->monster_noise = TRUE;
        }
 
-       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(p_ptr, TRUE, TRUE);
+       if (subject_ptr->riding && (m_idx == subject_ptr->riding)) disturb(subject_ptr, TRUE, TRUE);
 
        /* Scan through all four blows */
        for (ap_cnt = 0; ap_cnt < 4; ap_cnt++)
@@ -4217,8 +4219,8 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                        if (t_ptr->ml)
                        {
                                /* Redraw the health bar */
-                               if (p_ptr->health_who == t_idx) p_ptr->redraw |= (PR_HEALTH);
-                               if (p_ptr->riding == t_idx) p_ptr->redraw |= (PR_UHEALTH);
+                               if (subject_ptr->health_who == t_idx) subject_ptr->redraw |= (PR_HEALTH);
+                               if (subject_ptr->riding == t_idx) subject_ptr->redraw |= (PR_UHEALTH);
                        }
 
                        /* Describe the attack method */
@@ -4330,7 +4332,7 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 
                        case RBM_EXPLODE:
                        {
-                               if (see_either) disturb(p_ptr, TRUE, TRUE);
+                               if (see_either) disturb(subject_ptr, TRUE, TRUE);
                                act = _("爆発した。", "explodes.");
                                explode = TRUE;
                                touched = FALSE;
@@ -4456,7 +4458,7 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 
                        case RBE_EAT_ITEM:
                        case RBE_EAT_GOLD:
-                               if ((p_ptr->riding != m_idx) && one_in_(2)) blinked = TRUE;
+                               if ((subject_ptr->riding != m_idx) && one_in_(2)) blinked = TRUE;
                                break;
 
                        case RBE_EAT_FOOD:
@@ -4501,7 +4503,7 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 
                        case RBE_SHATTER:
                                damage -= (damage * ((ac < 150) ? ac : 150) / 250);
-                               if (damage > 23) earthquake(m_ptr->fy, m_ptr->fx, 8, m_idx);
+                               if (damage > 23) earthquake(subject_ptr, m_ptr->fy, m_ptr->fx, 8, m_idx);
                                break;
 
                        case RBE_EXP_10:
@@ -4566,8 +4568,8 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                                                if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
 
                                                /* Redraw (later) if needed */
-                                               if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-                                               if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
+                                               if (subject_ptr->health_who == m_idx) subject_ptr->redraw |= (PR_HEALTH);
+                                               if (subject_ptr->riding == m_idx) subject_ptr->redraw |= (PR_UHEALTH);
 
                                                /* Special message */
                                                if (see_m && did_heal)
@@ -4719,7 +4721,7 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                        }
                        else if (known)
                        {
-                               current_floor_ptr->monster_noise = TRUE;
+                               subject_ptr->current_floor_ptr->monster_noise = TRUE;
                        }
                }
                else
@@ -4730,10 +4732,10 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                        }
                        else if (known)
                        {
-                               current_floor_ptr->monster_noise = TRUE;
+                               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);
                }
        }
 
@@ -4755,7 +4757,7 @@ bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
  */
 void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *dead, bool *fear, concptr note, MONSTER_IDX who)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        GAME_TEXT m_name[160];
        bool seen = is_seen(m_ptr);
@@ -4834,7 +4836,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *dead, bool *fear,
                                /* Unseen death by normal attack */
                                if (!seen)
                                {
-                                       current_floor_ptr->monster_noise = TRUE;
+                                       p_ptr->current_floor_ptr->monster_noise = TRUE;
                                }
                                /* Death by special attack */
                                else if (note)
@@ -4907,9 +4909,9 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *dead, bool *fear,
 
        if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr) && (who != m_idx))
        {
-               if (is_pet(&current_floor_ptr->m_list[who]) && !player_bold(m_ptr->target_y, m_ptr->target_x))
+               if (is_pet(&p_ptr->current_floor_ptr->m_list[who]) && !player_bold(p_ptr, m_ptr->target_y, m_ptr->target_x))
                {
-                       set_target(m_ptr, current_floor_ptr->m_list[who].fy, current_floor_ptr->m_list[who].fx);
+                       set_target(m_ptr, p_ptr->current_floor_ptr->m_list[who].fy, p_ptr->current_floor_ptr->m_list[who].fx);
                }
        }