1 #include "status/base-status.h"
2 #include "core/player-redraw-types.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "game-option/birth-options.h"
6 #include "inventory/inventory-slot-types.h"
7 #include "object-enchant/item-feeling.h"
8 #include "object-enchant/special-object-flags.h"
9 #include "perception/object-perception.h"
10 #include "player/player-status-flags.h"
11 #include "player-info/avatar.h"
12 #include "spell-kind/spells-floor.h"
13 #include "system/object-type-definition.h"
14 #include "util/bit-flags-calculator.h"
15 #include "view/display-messages.h"
17 /* Array of stat "descriptions" */
18 static concptr desc_stat_pos[]
19 = { _("強く", "stronger"), _("知的に", "smarter"), _("賢く", "wiser"), _("器用に", "more dextrous"), _("健康に", "healthier"), _("美しく", "cuter") };
21 /* Array of stat "descriptions" */
22 static concptr desc_stat_neg[]
23 = { _("弱く", "weaker"), _("無知に", "stupider"), _("愚かに", "more naive"), _("不器用に", "clumsier"), _("不健康に", "more sickly"), _("醜く", "uglier") };
26 * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK-
27 * @param stat 上昇させるステータスID
28 * @return 実際に上昇した場合TRUEを返す。
30 * Note that this function (used by stat potions) now restores\n
31 * the stat BEFORE increasing it.\n
33 bool inc_stat(player_type *creature_ptr, int stat)
36 BASE_STATUS value = creature_ptr->stat_cur[stat];
37 if (value >= creature_ptr->stat_max_max[stat])
41 gain = ((randint0(100) < 75) ? 1 : 2);
43 } else if (value < (creature_ptr->stat_max_max[stat] - 2)) {
44 gain = (((creature_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
48 value += randint1(gain) + gain / 2;
49 if (value > (creature_ptr->stat_max_max[stat] - 1))
50 value = creature_ptr->stat_max_max[stat] - 1;
55 creature_ptr->stat_cur[stat] = value;
56 if (value > creature_ptr->stat_max[stat]) {
57 creature_ptr->stat_max[stat] = value;
60 creature_ptr->update |= PU_BONUS;
65 * @brief プレイヤーの基本能力値を減少させる / Decreases a stat by an amount indended to vary from 0 to 100 percent.
66 * @param stat 減少させるステータスID
67 * @param amount 減少させる基本量
68 * @param permanent TRUEならば現在の最大値を減少させる
69 * @return 実際に減少した場合TRUEを返す。
72 * Amount could be a little higher in extreme cases to mangle very high\n
73 * stats from massive assaults. -CWS\n
75 * Note that "permanent" means that the *given* amount is permanent,\n
76 * not that the new value becomes permanent. This may not work exactly\n
77 * as expected, due to "weirdness" in the algorithm, but in general,\n
78 * if your stat is already drained, the "max" value will not drop all\n
79 * the way down to the "cur" value.\n
81 bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent)
84 BASE_STATUS cur = creature_ptr->stat_cur[stat];
85 BASE_STATUS max = creature_ptr->stat_max[stat];
86 int same = (cur == max);
97 int loss = (((cur - 18) / 2 + 1) / 2 + 1);
101 loss = ((randint1(loss) + loss) * amount) / 100;
102 if (loss < amount / 2)
107 cur = (amount <= 20) ? 18 : 17;
113 if (cur != creature_ptr->stat_cur[stat])
117 if (permanent && (max > 3)) {
118 chg_virtue(creature_ptr, V_SACRIFICE, 1);
119 if (stat == A_WIS || stat == A_INT)
120 chg_virtue(creature_ptr, V_ENLIGHTEN, -2);
131 int loss = (((max - 18) / 2 + 1) / 2 + 1);
132 loss = ((randint1(loss) + loss) * amount) / 100;
133 if (loss < amount / 2)
138 max = (amount <= 20) ? 18 : 17;
141 if (same || (max < cur))
144 if (max != creature_ptr->stat_max[stat])
149 creature_ptr->stat_cur[stat] = cur;
150 creature_ptr->stat_max[stat] = max;
151 creature_ptr->redraw |= (PR_STATS);
152 creature_ptr->update |= (PU_BONUS);
159 * @brief プレイヤーの基本能力値を回復させる / Restore a stat. Return TRUE only if this actually makes a difference.
160 * @param stat 回復ステータスID
161 * @return 実際に回復した場合TRUEを返す。
163 bool res_stat(player_type *creature_ptr, int stat)
165 if (creature_ptr->stat_cur[stat] != creature_ptr->stat_max[stat]) {
166 creature_ptr->stat_cur[stat] = creature_ptr->stat_max[stat];
167 creature_ptr->update |= (PU_BONUS);
168 creature_ptr->redraw |= (PR_STATS);
178 bool do_dec_stat(player_type *creature_ptr, int stat)
183 if (has_sustain_str(creature_ptr))
187 if (has_sustain_int(creature_ptr))
191 if (has_sustain_wis(creature_ptr))
195 if (has_sustain_dex(creature_ptr))
199 if (has_sustain_con(creature_ptr))
203 if (has_sustain_chr(creature_ptr))
208 if (sust && (!ironman_nightmare || randint0(13))) {
209 msg_format(_("%sなった気がしたが、すぐに元に戻った。", "You feel %s for a moment, but the feeling passes."), desc_stat_neg[stat]);
213 if (dec_stat(creature_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) {
214 msg_format(_("ひどく%sなった気がする。", "You feel %s."), desc_stat_neg[stat]);
222 * Restore lost "points" in a stat
224 bool do_res_stat(player_type *creature_ptr, int stat)
226 if (res_stat(creature_ptr, stat)) {
227 msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
235 * Gain a "point" in a stat
237 bool do_inc_stat(player_type *creature_ptr, int stat)
239 bool res = res_stat(creature_ptr, stat);
240 if (inc_stat(creature_ptr, stat)) {
242 chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
243 chg_virtue(creature_ptr, V_FAITH, 1);
244 } else if (stat == A_INT) {
245 chg_virtue(creature_ptr, V_KNOWLEDGE, 1);
246 chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
247 } else if (stat == A_CON)
248 chg_virtue(creature_ptr, V_VITALITY, 1);
250 msg_format(_("ワーオ!とても%sなった!", "Wow! You feel %s!"), desc_stat_pos[stat]);
255 msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
265 bool lose_all_info(player_type *creature_ptr)
267 chg_virtue(creature_ptr, V_KNOWLEDGE, -5);
268 chg_virtue(creature_ptr, V_ENLIGHTEN, -5);
269 for (int i = 0; i < INVEN_TOTAL; i++) {
270 object_type *o_ptr = &creature_ptr->inventory_list[i];
271 if ((o_ptr->k_idx == 0) || object_is_fully_known(o_ptr))
274 o_ptr->feeling = FEEL_NONE;
275 o_ptr->ident &= ~(IDENT_EMPTY);
276 o_ptr->ident &= ~(IDENT_KNOWN);
277 o_ptr->ident &= ~(IDENT_SENSE);
280 set_bits(creature_ptr->update, PU_BONUS | PU_COMBINE | PU_REORDER);
281 set_bits(creature_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
282 wiz_dark(creature_ptr);