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 "view/display-messages.h"
16 /* Array of stat "descriptions" */
17 static concptr desc_stat_pos[]
18 = { _("強く", "stronger"), _("知的に", "smarter"), _("賢く", "wiser"), _("器用に", "more dextrous"), _("健康に", "healthier"), _("美しく", "cuter") };
20 /* Array of stat "descriptions" */
21 static concptr desc_stat_neg[]
22 = { _("弱く", "weaker"), _("無知に", "stupider"), _("愚かに", "more naive"), _("不器用に", "clumsier"), _("不健康に", "more sickly"), _("醜く", "uglier") };
25 * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK-
26 * @param stat 上昇させるステータスID
27 * @return 実際に上昇した場合TRUEを返す。
29 * Note that this function (used by stat potions) now restores\n
30 * the stat BEFORE increasing it.\n
32 bool inc_stat(player_type *creature_ptr, int stat)
35 BASE_STATUS value = creature_ptr->stat_cur[stat];
36 if (value >= creature_ptr->stat_max_max[stat])
40 gain = ((randint0(100) < 75) ? 1 : 2);
42 } else if (value < (creature_ptr->stat_max_max[stat] - 2)) {
43 gain = (((creature_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
47 value += randint1(gain) + gain / 2;
48 if (value > (creature_ptr->stat_max_max[stat] - 1))
49 value = creature_ptr->stat_max_max[stat] - 1;
54 creature_ptr->stat_cur[stat] = value;
55 if (value > creature_ptr->stat_max[stat]) {
56 creature_ptr->stat_max[stat] = value;
59 creature_ptr->update |= PU_BONUS;
64 * @brief プレイヤーの基本能力値を減少させる / Decreases a stat by an amount indended to vary from 0 to 100 percent.
65 * @param stat 減少させるステータスID
66 * @param amount 減少させる基本量
67 * @param permanent TRUEならば現在の最大値を減少させる
68 * @return 実際に減少した場合TRUEを返す。
71 * Amount could be a little higher in extreme cases to mangle very high\n
72 * stats from massive assaults. -CWS\n
74 * Note that "permanent" means that the *given* amount is permanent,\n
75 * not that the new value becomes permanent. This may not work exactly\n
76 * as expected, due to "weirdness" in the algorithm, but in general,\n
77 * if your stat is already drained, the "max" value will not drop all\n
78 * the way down to the "cur" value.\n
80 bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent)
83 BASE_STATUS cur = creature_ptr->stat_cur[stat];
84 BASE_STATUS max = creature_ptr->stat_max[stat];
85 int same = (cur == max);
96 int loss = (((cur - 18) / 2 + 1) / 2 + 1);
100 loss = ((randint1(loss) + loss) * amount) / 100;
101 if (loss < amount / 2)
106 cur = (amount <= 20) ? 18 : 17;
112 if (cur != creature_ptr->stat_cur[stat])
116 if (permanent && (max > 3)) {
117 chg_virtue(creature_ptr, V_SACRIFICE, 1);
118 if (stat == A_WIS || stat == A_INT)
119 chg_virtue(creature_ptr, V_ENLIGHTEN, -2);
130 int loss = (((max - 18) / 2 + 1) / 2 + 1);
131 loss = ((randint1(loss) + loss) * amount) / 100;
132 if (loss < amount / 2)
137 max = (amount <= 20) ? 18 : 17;
140 if (same || (max < cur))
143 if (max != creature_ptr->stat_max[stat])
148 creature_ptr->stat_cur[stat] = cur;
149 creature_ptr->stat_max[stat] = max;
150 creature_ptr->redraw |= (PR_STATS);
151 creature_ptr->update |= (PU_BONUS);
158 * @brief プレイヤーの基本能力値を回復させる / Restore a stat. Return TRUE only if this actually makes a difference.
159 * @param stat 回復ステータスID
160 * @return 実際に回復した場合TRUEを返す。
162 bool res_stat(player_type *creature_ptr, int stat)
164 if (creature_ptr->stat_cur[stat] != creature_ptr->stat_max[stat]) {
165 creature_ptr->stat_cur[stat] = creature_ptr->stat_max[stat];
166 creature_ptr->update |= (PU_BONUS);
167 creature_ptr->redraw |= (PR_STATS);
177 bool do_dec_stat(player_type *creature_ptr, int stat)
182 if (has_sustain_str(creature_ptr))
186 if (has_sustain_int(creature_ptr))
190 if (has_sustain_wis(creature_ptr))
194 if (has_sustain_dex(creature_ptr))
198 if (has_sustain_con(creature_ptr))
202 if (has_sustain_chr(creature_ptr))
207 if (sust && (!ironman_nightmare || randint0(13))) {
208 msg_format(_("%sなった気がしたが、すぐに元に戻った。", "You feel %s for a moment, but the feeling passes."), desc_stat_neg[stat]);
212 if (dec_stat(creature_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) {
213 msg_format(_("ひどく%sなった気がする。", "You feel %s."), desc_stat_neg[stat]);
221 * Restore lost "points" in a stat
223 bool do_res_stat(player_type *creature_ptr, int stat)
225 if (res_stat(creature_ptr, stat)) {
226 msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
234 * Gain a "point" in a stat
236 bool do_inc_stat(player_type *creature_ptr, int stat)
238 bool res = res_stat(creature_ptr, stat);
239 if (inc_stat(creature_ptr, stat)) {
241 chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
242 chg_virtue(creature_ptr, V_FAITH, 1);
243 } else if (stat == A_INT) {
244 chg_virtue(creature_ptr, V_KNOWLEDGE, 1);
245 chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
246 } else if (stat == A_CON)
247 chg_virtue(creature_ptr, V_VITALITY, 1);
249 msg_format(_("ワーオ!とても%sなった!", "Wow! You feel %s!"), desc_stat_pos[stat]);
254 msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
264 bool lose_all_info(player_type *creature_ptr)
266 chg_virtue(creature_ptr, V_KNOWLEDGE, -5);
267 chg_virtue(creature_ptr, V_ENLIGHTEN, -5);
268 for (int i = 0; i < INVEN_TOTAL; i++) {
269 object_type *o_ptr = &creature_ptr->inventory_list[i];
270 if ((o_ptr->k_idx == 0) || object_is_fully_known(o_ptr))
273 o_ptr->feeling = FEEL_NONE;
274 o_ptr->ident &= ~(IDENT_EMPTY);
275 o_ptr->ident &= ~(IDENT_KNOWN);
276 o_ptr->ident &= ~(IDENT_SENSE);
279 creature_ptr->update |= (PU_BONUS);
280 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
281 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
282 wiz_dark(creature_ptr);