2 * @file status-first-page.c
3 * @brief キャラ基本情報及び技能値の表示
8 #include "view/status-first-page.h"
9 #include "art-definition/art-bow-types.h"
10 #include "art-definition/art-sword-types.h"
11 #include "combat/attack-power-table.h"
12 #include "combat/shoot.h"
13 #include "display-util.h"
14 #include "game-option/text-display-options.h"
15 #include "object-enchant/special-object-flags.h"
16 #include "object-enchant/tr-types.h"
17 #include "object/object-flags.h"
18 #include "perception/object-perception.h"
19 #include "player/special-defense-types.h"
20 #include "sv-definition/sv-weapon-types.h"
21 #include "term/term-color-types.h"
22 #include "util/bit-flags-calculator.h"
24 static TERM_COLOR likert_color = TERM_WHITE;
28 * @param creature_ptr プレーヤーへの参照ポインタ
29 * @param o_ptr 装備中の弓への参照ポインタ
31 * @param shot_frac 射撃速度
34 static void calc_shot_params(player_type *creature_ptr, object_type *o_ptr, int *shots, int *shot_frac)
36 if (o_ptr->k_idx == 0) return;
38 ENERGY energy_fire = bow_energy(o_ptr->sval);
39 *shots = creature_ptr->num_fire * 100;
40 *shot_frac = ((*shots) * 100 / energy_fire) % 100;
41 *shots = (*shots) / energy_fire;
42 if (o_ptr->name1 != ART_CRIMSON) return;
46 if (creature_ptr->pclass != CLASS_ARCHER) return;
48 if (creature_ptr->lev >= 10) (*shots)++;
49 if (creature_ptr->lev >= 30) (*shots)++;
50 if (creature_ptr->lev >= 45) (*shots)++;
55 * @brief 武器装備に制限のあるクラスで、直接攻撃のダメージを計算する
56 * @param creature_ptr プレーヤーへの参照ポインタ
57 * @param hand 手 (利き手が0、反対の手が1…のはず)
58 * @param damage 直接攻撃のダメージ
59 * @param basedam 素手における直接攻撃のダメージ
60 * @param o_ptr 装備中の武器への参照ポインタ
61 * @return 利き手ならTRUE、反対の手ならFALSE
63 static bool calc_weapon_damage_limit(player_type *creature_ptr, int hand, int *damage, int *basedam, object_type *o_ptr)
65 PLAYER_LEVEL level = creature_ptr->lev;
72 if (creature_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
73 if (creature_ptr->special_defense & KAMAE_BYAKKO)
74 *basedam = monk_ave_damage[level][1];
75 else if (creature_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
76 *basedam = monk_ave_damage[level][2];
78 *basedam = monk_ave_damage[level][0];
80 damage[hand] += *basedam;
81 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) damage[hand] = 1;
82 if (damage[hand] < 0) damage[hand] = 0;
89 * @brief 片手あたりのダメージ量を計算する
90 * @param o_ptr 装備中の武器への参照ポインタ
92 * @param damage 直接攻撃のダメージ
93 * @param basedam 素手における直接攻撃のダメージ
94 * @return 素手ならFALSE、武器を持っていればTRUE
96 static bool calc_weapon_one_hand(object_type *o_ptr, int hand, int *damage, int *basedam)
98 if (o_ptr->k_idx == 0) return FALSE;
101 damage[hand] += *basedam;
102 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
105 if (damage[hand] < 0)
113 * @brief ヴォーパル武器等によるダメージ強化
114 * @param creature_ptr プレーヤーへの参照ポインタ
115 * @param o_ptr 装備中の武器への参照ポインタ
116 * @param basedam 素手における直接攻撃のダメージ
117 * @param flgs オブジェクトフラグ群
120 static int strengthen_basedam(player_type *creature_ptr, object_type *o_ptr, int basedam, BIT_FLAGS *flgs)
122 if (object_is_fully_known(o_ptr) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
128 else if (have_flag(flgs, TR_VORPAL))
130 /* vorpal flag only */
136 bool is_force = creature_ptr->pclass != CLASS_SAMURAI;
137 is_force &= have_flag(flgs, TR_FORCE_WEAPON);
138 is_force &= creature_ptr->csp > (o_ptr->dd * o_ptr->ds / 5);
139 if (is_force) basedam = basedam * 7 / 2;
146 * @brief 技能ランクの表示基準を定める
147 * Returns a "rating" of x depending on y
149 * @param y 技能値に対するランク基準比
152 static concptr likert(int x, int y)
154 static char dummy[20] = "", dummy2[20] = "";
155 memset(dummy, 0, strlen(dummy));
156 memset(dummy2, 0, strlen(dummy2));
159 if (show_actual_value)
160 sprintf(dummy, "%3d-", x);
164 likert_color = TERM_L_DARK;
165 strcat(dummy, _("最低", "Very Bad"));
174 likert_color = TERM_RED;
175 strcat(dummy, _("悪い", "Bad"));
181 likert_color = TERM_L_RED;
182 strcat(dummy, _("劣る", "Poor"));
188 likert_color = TERM_ORANGE;
189 strcat(dummy, _("普通", "Fair"));
194 likert_color = TERM_YELLOW;
195 strcat(dummy, _("良い", "Good"));
200 likert_color = TERM_YELLOW;
201 strcat(dummy, _("大変良い", "Very Good"));
207 likert_color = TERM_L_GREEN;
208 strcat(dummy, _("卓越", "Excellent"));
217 likert_color = TERM_GREEN;
218 strcat(dummy, _("超越", "Superb"));
226 likert_color = TERM_BLUE;
227 strcat(dummy, _("英雄的", "Heroic"));
232 likert_color = TERM_VIOLET;
233 sprintf(dummy2, _("伝説的[%d]", "Legendary[%d]"), (int)((((x / y) - 17) * 5) / 2));
234 strcat(dummy, dummy2);
244 * @brief 弓+両手の武器それぞれについてダメージを計算する
245 * @param creature_ptr プレーヤーへの参照ポインタ
246 * @param damage 直接攻撃のダメージ
250 static void calc_two_hands(player_type *creature_ptr, int *damage, int *to_h)
253 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
254 BIT_FLAGS flgs[TR_FLAG_SIZE];
255 for (int i = 0; i < 2; i++)
258 damage[i] = creature_ptr->dis_to_d[i] * 100;
259 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))
261 if (!calc_weapon_damage_limit(creature_ptr, i, damage, &basedam, o_ptr))
267 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
268 if (!calc_weapon_one_hand(o_ptr, i, damage, &basedam)) continue;
271 bool poison_needle = FALSE;
272 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) poison_needle = TRUE;
273 if (object_is_known(o_ptr))
275 damage[i] += o_ptr->to_d * 100;
276 to_h[i] += o_ptr->to_h;
279 basedam = ((o_ptr->dd + creature_ptr->to_dd[i]) * (o_ptr->ds + creature_ptr->to_ds[i] + 1)) * 50;
280 object_flags_known(creature_ptr, o_ptr, flgs);
282 basedam = calc_expect_crit(creature_ptr, o_ptr->weight, to_h[i], basedam, creature_ptr->dis_to_h[i], poison_needle);
283 basedam = strengthen_basedam(creature_ptr, o_ptr, basedam, flgs);
284 damage[i] += basedam;
285 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) damage[i] = 1;
286 if (damage[i] < 0) damage[i] = 0;
292 * @brief キャラ基本情報及び技能値をメインウィンドウに表示する
293 * @param creature_ptr プレーヤーへの参照ポインタ
294 * @param xthb 武器等を含めた最終命中率
297 * @param shot_frac 射撃速度
298 * @param display_player_one_line 1行表示用のコールバック関数
301 static void display_first_page(player_type *creature_ptr, int xthb, int *damage, int shots, int shot_frac)
303 int xthn = creature_ptr->skill_thn + (creature_ptr->to_h_m * BTH_PLUS_ADJ);
306 if (creature_ptr->muta2 & MUT2_HORNS) muta_att++;
307 if (creature_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
308 if (creature_ptr->muta2 & MUT2_BEAK) muta_att++;
309 if (creature_ptr->muta2 & MUT2_TRUNK) muta_att++;
310 if (creature_ptr->muta2 & MUT2_TENTACLES) muta_att++;
312 int blows1 = creature_ptr->migite ? creature_ptr->num_blow[0] : 0;
313 int blows2 = creature_ptr->hidarite ? creature_ptr->num_blow[1] : 0;
314 int xdis = creature_ptr->skill_dis;
315 int xdev = creature_ptr->skill_dev;
316 int xsav = creature_ptr->skill_sav;
317 int xstl = creature_ptr->skill_stl;
318 int xsrh = creature_ptr->skill_srh;
319 int xfos = creature_ptr->skill_fos;
320 int xdig = creature_ptr->skill_dig;
322 concptr desc = likert(xthn, 12);
323 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
325 desc = likert(xthb, 12);
326 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
328 desc = likert(xsav, 7);
329 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
331 desc = likert((xstl > 0) ? xstl : -1, 1);
332 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
334 desc = likert(xfos, 6);
335 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
337 desc = likert(xsrh, 6);
338 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
340 desc = likert(xdis, 8);
341 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
343 desc = likert(xdev, 6);
344 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
346 desc = likert(xdev, 6);
347 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
349 desc = likert(xdig, 4);
350 display_player_one_line(ENTRY_SKILL_DIG, desc, likert_color);
353 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
355 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
357 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
359 if ((damage[0] + damage[1]) == 0)
362 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
364 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
365 display_player_one_line(ENTRY_INFRA, format("%d feet", creature_ptr->see_infra * 10), TERM_WHITE);
370 * @brief プレイヤーステータスの1ページ目各種詳細をまとめて表示する
371 * Prints ratings on certain abilities
372 * @param creature_ptr プレーヤーへの参照ポインタ
373 * @param display_player_one_line 1行表示用のコールバック関数
376 * This code is "imitated" elsewhere to "dump" a character sheet.
378 void display_player_various(player_type *creature_ptr)
381 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
382 int tmp = creature_ptr->to_h_b + o_ptr->to_h;
383 int xthb = creature_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
386 calc_shot_params(creature_ptr, o_ptr, &shots, &shot_frac);
390 calc_two_hands(creature_ptr, damage, to_h);
391 display_first_page(creature_ptr, xthb, damage, shots, shot_frac);