1 #include "status/base-status.h"
2 #include "avatar/avatar.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/window-redrawer.h"
6 #include "game-option/birth-options.h"
7 #include "inventory/inventory-slot-types.h"
8 #include "object-enchant/item-feeling.h"
9 #include "object-enchant/special-object-flags.h"
10 #include "perception/object-perception.h"
11 #include "player/player-status-flags.h"
12 #include "spell-kind/spells-floor.h"
13 #include "system/object-type-definition.h"
14 #include "system/player-type-definition.h"
15 #include "util/bit-flags-calculator.h"
16 #include "view/display-messages.h"
18 /* Array of stat "descriptions" */
19 static concptr desc_stat_pos[]
20 = { _("強く", "stronger"), _("知的に", "smarter"), _("賢く", "wiser"), _("器用に", "more dextrous"), _("健康に", "healthier"), _("美しく", "cuter") };
22 /* Array of stat "descriptions" */
23 static concptr desc_stat_neg[]
24 = { _("弱く", "weaker"), _("無知に", "stupider"), _("愚かに", "more naive"), _("不器用に", "clumsier"), _("不健康に", "more sickly"), _("醜く", "uglier") };
27 * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK-
28 * @param stat 上昇させるステータスID
29 * @return 実際に上昇した場合TRUEを返す。
31 * Note that this function (used by stat potions) now restores\n
32 * the stat BEFORE increasing it.\n
34 bool inc_stat(PlayerType *player_ptr, int stat)
37 BASE_STATUS value = player_ptr->stat_cur[stat];
38 if (value >= player_ptr->stat_max_max[stat])
42 gain = ((randint0(100) < 75) ? 1 : 2);
44 } else if (value < (player_ptr->stat_max_max[stat] - 2)) {
45 gain = (((player_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
49 value += randint1(gain) + gain / 2;
50 if (value > (player_ptr->stat_max_max[stat] - 1))
51 value = player_ptr->stat_max_max[stat] - 1;
56 player_ptr->stat_cur[stat] = value;
57 if (value > player_ptr->stat_max[stat]) {
58 player_ptr->stat_max[stat] = value;
61 player_ptr->update |= PU_BONUS;
66 * @brief プレイヤーの基本能力値を減少させる / Decreases a stat by an amount indended to vary from 0 to 100 percent.
67 * @param stat 減少させるステータスID
68 * @param amount 減少させる基本量
69 * @param permanent TRUEならば現在の最大値を減少させる
70 * @return 実際に減少した場合TRUEを返す。
73 * Amount could be a little higher in extreme cases to mangle very high\n
74 * stats from massive assaults. -CWS\n
76 * Note that "permanent" means that the *given* amount is permanent,\n
77 * not that the new value becomes permanent. This may not work exactly\n
78 * as expected, due to "weirdness" in the algorithm, but in general,\n
79 * if your stat is already drained, the "max" value will not drop all\n
80 * the way down to the "cur" value.\n
82 bool dec_stat(PlayerType *player_ptr, int stat, int amount, int permanent)
85 BASE_STATUS cur = player_ptr->stat_cur[stat];
86 BASE_STATUS max = player_ptr->stat_max[stat];
87 int same = (cur == max);
98 int loss = (((cur - 18) / 2 + 1) / 2 + 1);
102 loss = ((randint1(loss) + loss) * amount) / 100;
103 if (loss < amount / 2)
108 cur = (amount <= 20) ? 18 : 17;
114 if (cur != player_ptr->stat_cur[stat])
118 if (permanent && (max > 3)) {
119 chg_virtue(player_ptr, V_SACRIFICE, 1);
120 if (stat == A_WIS || stat == A_INT)
121 chg_virtue(player_ptr, V_ENLIGHTEN, -2);
132 int loss = (((max - 18) / 2 + 1) / 2 + 1);
133 loss = ((randint1(loss) + loss) * amount) / 100;
134 if (loss < amount / 2)
139 max = (amount <= 20) ? 18 : 17;
142 if (same || (max < cur))
145 if (max != player_ptr->stat_max[stat])
150 player_ptr->stat_cur[stat] = cur;
151 player_ptr->stat_max[stat] = max;
152 player_ptr->redraw |= (PR_STATS);
153 player_ptr->update |= (PU_BONUS);
160 * @brief プレイヤーの基本能力値を回復させる / Restore a stat. Return TRUE only if this actually makes a difference.
161 * @param stat 回復ステータスID
162 * @return 実際に回復した場合TRUEを返す。
164 bool res_stat(PlayerType *player_ptr, int stat)
166 if (player_ptr->stat_cur[stat] != player_ptr->stat_max[stat]) {
167 player_ptr->stat_cur[stat] = player_ptr->stat_max[stat];
168 player_ptr->update |= (PU_BONUS);
169 player_ptr->redraw |= (PR_STATS);
179 bool do_dec_stat(PlayerType *player_ptr, int stat)
184 if (has_sustain_str(player_ptr))
188 if (has_sustain_int(player_ptr))
192 if (has_sustain_wis(player_ptr))
196 if (has_sustain_dex(player_ptr))
200 if (has_sustain_con(player_ptr))
204 if (has_sustain_chr(player_ptr))
209 if (sust && (!ironman_nightmare || randint0(13))) {
210 msg_format(_("%sなった気がしたが、すぐに元に戻った。", "You feel %s for a moment, but the feeling passes."), desc_stat_neg[stat]);
214 if (dec_stat(player_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) {
215 msg_format(_("ひどく%sなった気がする。", "You feel %s."), desc_stat_neg[stat]);
223 * Restore lost "points" in a stat
225 bool do_res_stat(PlayerType *player_ptr, int stat)
227 if (res_stat(player_ptr, stat)) {
228 msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
236 * Gain a "point" in a stat
238 bool do_inc_stat(PlayerType *player_ptr, int stat)
240 bool res = res_stat(player_ptr, stat);
241 if (inc_stat(player_ptr, stat)) {
243 chg_virtue(player_ptr, V_ENLIGHTEN, 1);
244 chg_virtue(player_ptr, V_FAITH, 1);
245 } else if (stat == A_INT) {
246 chg_virtue(player_ptr, V_KNOWLEDGE, 1);
247 chg_virtue(player_ptr, V_ENLIGHTEN, 1);
248 } else if (stat == A_CON)
249 chg_virtue(player_ptr, V_VITALITY, 1);
251 msg_format(_("ワーオ!とても%sなった!", "Wow! You feel %s!"), desc_stat_pos[stat]);
256 msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
266 bool lose_all_info(PlayerType *player_ptr)
268 chg_virtue(player_ptr, V_KNOWLEDGE, -5);
269 chg_virtue(player_ptr, V_ENLIGHTEN, -5);
270 for (int i = 0; i < INVEN_TOTAL; i++) {
271 auto *o_ptr = &player_ptr->inventory_list[i];
272 if ((o_ptr->k_idx == 0) || o_ptr->is_fully_known())
275 o_ptr->feeling = FEEL_NONE;
276 o_ptr->ident &= ~(IDENT_EMPTY);
277 o_ptr->ident &= ~(IDENT_KNOWN);
278 o_ptr->ident &= ~(IDENT_SENSE);
281 set_bits(player_ptr->update, PU_BONUS | PU_COMBINE | PU_REORDER);
282 set_bits(player_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
283 wiz_dark(player_ptr);