From 74452e9855a912690aa90014a2dd11c025211fb2 Mon Sep 17 00:00:00 2001 From: deskull Date: Thu, 20 Jun 2019 23:27:10 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20dec=5Fstat()=20=E3=81=AB?= =?utf8?q?=20player=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92=E8=BF=BD?= =?utf8?q?=E5=8A=A0=EF=BC=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd-quaff.c | 12 ++++++------ src/cmd-spell.c | 2 +- src/core.c | 2 +- src/melee1.c | 2 +- src/mind.c | 2 +- src/mspells3.c | 2 +- src/patron.c | 6 +++--- src/player-effects.c | 31 +++++++++++++++---------------- src/player-effects.h | 2 +- src/spells2.c | 12 ++++++------ 10 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/cmd-quaff.c b/src/cmd-quaff.c index 0d8540cda..ec0c638eb 100644 --- a/src/cmd-quaff.c +++ b/src/cmd-quaff.c @@ -208,12 +208,12 @@ void exe_quaff_potion(INVENTORY_IDX item) msg_print(_("身も心も弱ってきて、精気が抜けていくようだ。", "Your nerves and muscles feel weak and lifeless!")); take_hit(DAMAGE_LOSELIFE, damroll(10, 10), _("破滅の薬", "a potion of Ruination"), -1); - (void)dec_stat(A_DEX, 25, TRUE); - (void)dec_stat(A_WIS, 25, TRUE); - (void)dec_stat(A_CON, 25, TRUE); - (void)dec_stat(A_STR, 25, TRUE); - (void)dec_stat(A_CHR, 25, TRUE); - (void)dec_stat(A_INT, 25, TRUE); + (void)dec_stat(p_ptr, A_DEX, 25, TRUE); + (void)dec_stat(p_ptr, A_WIS, 25, TRUE); + (void)dec_stat(p_ptr, A_CON, 25, TRUE); + (void)dec_stat(p_ptr, A_STR, 25, TRUE); + (void)dec_stat(p_ptr, A_CHR, 25, TRUE); + (void)dec_stat(p_ptr, A_INT, 25, TRUE); ident = TRUE; break; diff --git a/src/cmd-spell.c b/src/cmd-spell.c index 31a8260e1..8556f1439 100644 --- a/src/cmd-spell.c +++ b/src/cmd-spell.c @@ -1463,7 +1463,7 @@ void do_cmd_cast(void) msg_print(_("体を悪くしてしまった!", "You have damaged your health!")); /* Reduce constitution */ - (void)dec_stat(A_CON, 15 + randint1(10), perm); + (void)dec_stat(p_ptr, A_CON, 15 + randint1(10), perm); } } diff --git a/src/core.c b/src/core.c index 87cb7846d..4744268fd 100644 --- a/src/core.c +++ b/src/core.c @@ -2438,7 +2438,7 @@ static void process_world_aux_mutation(void) disturb(FALSE, TRUE); msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!")); msg_print(NULL); - (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3)); + (void)dec_stat(p_ptr, which_stat, randint1(6) + 6, one_in_(3)); } } if ((p_ptr->muta2 & MUT2_ATT_DRAGON) && !p_ptr->anti_magic && one_in_(3000)) diff --git a/src/melee1.c b/src/melee1.c index 16ea27755..fa912a3d0 100644 --- a/src/melee1.c +++ b/src/melee1.c @@ -3462,7 +3462,7 @@ bool make_attack_normal(MONSTER_IDX m_idx) { /* 1% chance for perm. damage */ bool perm = one_in_(10); - if (dec_stat(A_CON, randint1(10), perm)) + if (dec_stat(p_ptr, A_CON, randint1(10), perm)) { msg_print(_("病があなたを蝕んでいる気がする。", "You feel strange sickness.")); obvious = TRUE; diff --git a/src/mind.c b/src/mind.c index 3cef07d35..be0ff79cf 100644 --- a/src/mind.c +++ b/src/mind.c @@ -2051,7 +2051,7 @@ void do_cmd_mind(void) msg_print(_("自分の精神を攻撃してしまった!", "You have damaged your mind!")); /* Reduce constitution */ - (void)dec_stat(A_WIS, 15 + randint1(10), perm); + (void)dec_stat(p_ptr, A_WIS, 15 + randint1(10), perm); } } p_ptr->redraw |= (PR_MANA); diff --git a/src/mspells3.c b/src/mspells3.c index 33a35622c..861afb756 100644 --- a/src/mspells3.c +++ b/src/mspells3.c @@ -1759,7 +1759,7 @@ bool do_cmd_cast_learned(void) msg_print(_("体を悪くしてしまった!", "You have damaged your health!")); /* Reduce constitution */ - (void)dec_stat(A_CON, 15 + randint1(10), perm); + (void)dec_stat(p_ptr, A_CON, 15 + randint1(10), perm); } } diff --git a/src/patron.c b/src/patron.c index 2639376b1..35a855676 100644 --- a/src/patron.c +++ b/src/patron.c @@ -444,7 +444,7 @@ void gain_level_reward(int chosen_reward) for (dummy = 0; dummy < A_MAX; dummy++) { - (void)dec_stat(dummy, 10 + randint1(15), TRUE); + (void)dec_stat(p_ptr, dummy, 10 + randint1(15), TRUE); } reward = _("全能力値が下がった。", "decreasing all stats"); break; @@ -557,7 +557,7 @@ void gain_level_reward(int chosen_reward) default: for (dummy = 0; dummy < A_MAX; dummy++) { - (void)dec_stat(dummy, 10 + randint1(15), TRUE); + (void)dec_stat(p_ptr, dummy, 10 + randint1(15), TRUE); } reward = _("全能力値が下がった。", "decreasing all stats"); break; @@ -572,7 +572,7 @@ void gain_level_reward(int chosen_reward) take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1); for (dummy = 0; dummy < A_MAX; dummy++) { - (void)dec_stat(dummy, 10 + randint1(15), FALSE); + (void)dec_stat(p_ptr, dummy, 10 + randint1(15), FALSE); } activate_hi_summon(p_ptr->y, p_ptr->x, FALSE); (void)activate_ty_curse(FALSE, &count); diff --git a/src/player-effects.c b/src/player-effects.c index d1810492c..b83a71a6c 100644 --- a/src/player-effects.c +++ b/src/player-effects.c @@ -2266,8 +2266,8 @@ bool set_tsuyoshi(TIME_EFFECT v, bool do_dec) { msg_print(_("肉体が急速にしぼんでいった。", "Your body had quickly shriveled.")); - (void)dec_stat(A_CON, 20, TRUE); - (void)dec_stat(A_STR, 20, TRUE); + (void)dec_stat(p_ptr, A_CON, 20, TRUE); + (void)dec_stat(p_ptr, A_STR, 20, TRUE); notice = TRUE; chg_virtue(V_VITALITY, -3); @@ -3285,16 +3285,15 @@ bool inc_stat(int stat) * if your stat is already drained, the "max" value will not drop all\n * the way down to the "cur" value.\n */ -bool dec_stat(int stat, int amount, int permanent) +bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent) { BASE_STATUS cur, max; int loss, same; bool res = FALSE; - /* Acquire current value */ - cur = p_ptr->stat_cur[stat]; - max = p_ptr->stat_max[stat]; + cur = creature_ptr->stat_cur[stat]; + max = creature_ptr->stat_max[stat]; /* Note when the values are identical */ same = (cur == max); @@ -3337,7 +3336,7 @@ bool dec_stat(int stat, int amount, int permanent) if (cur < 3) cur = 3; /* Something happened */ - if (cur != p_ptr->stat_cur[stat]) res = TRUE; + if (cur != creature_ptr->stat_cur[stat]) res = TRUE; } /* Damage "max" value */ @@ -3377,17 +3376,17 @@ bool dec_stat(int stat, int amount, int permanent) if (same || (max < cur)) max = cur; /* Something happened */ - if (max != p_ptr->stat_max[stat]) res = TRUE; + if (max != creature_ptr->stat_max[stat]) res = TRUE; } if (res) { /* Actually set the stat to its new value. */ - p_ptr->stat_cur[stat] = cur; - p_ptr->stat_max[stat] = max; + creature_ptr->stat_cur[stat] = cur; + creature_ptr->stat_max[stat] = max; - p_ptr->redraw |= (PR_STATS); - p_ptr->update |= (PU_BONUS); + creature_ptr->redraw |= (PR_STATS); + creature_ptr->update |= (PU_BONUS); } return (res); @@ -3539,7 +3538,7 @@ bool do_dec_stat(player_type *creature_ptr, int stat) } /* Attempt to reduce the stat */ - if (dec_stat(stat, 10, (ironman_nightmare && !randint0(13)))) + if (dec_stat(p_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) { msg_format(_("ひどく%sなった気がする。", "You feel very %s."), desc_stat_neg[stat]); @@ -3817,14 +3816,14 @@ void do_poly_self(void) { if (one_in_(2)) { - (void)dec_stat(tmp, randint1(6) + 6, one_in_(3)); + (void)dec_stat(p_ptr, tmp, randint1(6) + 6, one_in_(3)); power -= 1; } tmp++; } /* Deformities are discriminated against! */ - (void)dec_stat(A_CHR, randint1(6), TRUE); + (void)dec_stat(p_ptr, A_CHR, randint1(6), TRUE); if (effect_msg[0]) { @@ -3866,7 +3865,7 @@ void do_poly_self(void) while (tmp < A_MAX) { - (void)dec_stat(tmp, randint1(6) + 6, one_in_(3)); + (void)dec_stat(p_ptr, tmp, randint1(6) + 6, one_in_(3)); tmp++; } if (one_in_(6)) diff --git a/src/player-effects.h b/src/player-effects.h index 37aac3279..8e4ace383 100644 --- a/src/player-effects.h +++ b/src/player-effects.h @@ -58,7 +58,7 @@ extern bool set_stun(TIME_EFFECT v); extern bool set_cut(TIME_EFFECT v); extern bool set_food(TIME_EFFECT v); extern bool inc_stat(int stat); -extern bool dec_stat(int stat, int amount, int permanent); +extern bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent); extern bool res_stat(player_type *creature_ptr, int stat); extern bool hp_player(int num); extern bool do_dec_stat(player_type *creature_ptr, int stat); diff --git a/src/spells2.c b/src/spells2.c index e282931ce..b64a5462c 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -3143,12 +3143,12 @@ void ring_of_power(DIRECTION dir) sound(SOUND_EVIL); /* Decrease all stats (permanently) */ - (void)dec_stat(A_STR, 50, TRUE); - (void)dec_stat(A_INT, 50, TRUE); - (void)dec_stat(A_WIS, 50, TRUE); - (void)dec_stat(A_DEX, 50, TRUE); - (void)dec_stat(A_CON, 50, TRUE); - (void)dec_stat(A_CHR, 50, TRUE); + (void)dec_stat(p_ptr, A_STR, 50, TRUE); + (void)dec_stat(p_ptr, A_INT, 50, TRUE); + (void)dec_stat(p_ptr, A_WIS, 50, TRUE); + (void)dec_stat(p_ptr, A_DEX, 50, TRUE); + (void)dec_stat(p_ptr, A_CON, 50, TRUE); + (void)dec_stat(p_ptr, A_CHR, 50, TRUE); /* Lose some experience (permanently) */ p_ptr->exp -= (p_ptr->exp / 4); -- 2.11.0