1 #include "player/player-status.h"
2 #include "artifact/fixed-art-types.h"
3 #include "autopick/autopick-reader-writer.h"
4 #include "autopick/autopick.h"
5 #include "cmd-action/cmd-pet.h"
6 #include "cmd-action/cmd-spell.h"
7 #include "cmd-io/cmd-dump.h"
8 #include "cmd-item/cmd-magiceat.h"
9 #include "combat/attack-power-table.h"
10 #include "core/asking-player.h"
11 #include "core/player-redraw-types.h"
12 #include "core/player-update-types.h"
13 #include "core/stuff-handler.h"
14 #include "core/window-redrawer.h"
15 #include "dungeon/dungeon-flag-types.h"
16 #include "dungeon/dungeon.h"
17 #include "effect/effect-characteristics.h"
18 #include "floor/cave.h"
19 #include "floor/floor-events.h"
20 #include "floor/floor-leaver.h"
21 #include "floor/floor-save.h"
22 #include "floor/floor-util.h"
23 #include "game-option/birth-options.h"
24 #include "grid/feature.h"
25 #include "inventory/inventory-object.h"
26 #include "inventory/inventory-slot-types.h"
27 #include "io/input-key-acceptor.h"
28 #include "io/write-diary.h"
29 #include "main/sound-definitions-table.h"
30 #include "main/sound-of-music.h"
31 #include "market/arena-info-table.h"
32 #include "mind/mind-force-trainer.h"
33 #include "mind/mind-ninja.h"
34 #include "monster-floor/monster-lite.h"
35 #include "monster-floor/monster-remover.h"
36 #include "monster-race/monster-race-hook.h"
37 #include "monster-race/monster-race.h"
38 #include "monster-race/race-flags1.h"
39 #include "monster-race/race-flags2.h"
40 #include "monster-race/race-flags3.h"
41 #include "monster-race/race-flags7.h"
42 #include "monster/monster-info.h"
43 #include "monster/monster-status.h"
44 #include "monster/monster-update.h"
45 #include "monster/smart-learn-types.h"
46 #include "mutation/mutation-calculator.h"
47 #include "mutation/mutation-flag-types.h"
48 #include "mutation/mutation-investor-remover.h"
49 #include "object-enchant/object-ego.h"
50 #include "object-enchant/special-object-flags.h"
51 #include "object-enchant/tr-types.h"
52 #include "object-enchant/trc-types.h"
53 #include "object-hook/hook-armor.h"
54 #include "object-hook/hook-checker.h"
55 #include "object-hook/hook-weapon.h"
56 #include "object/object-flags.h"
57 #include "object/object-info.h"
58 #include "object/object-mark-types.h"
59 #include "perception/object-perception.h"
60 #include "pet/pet-util.h"
61 #include "player-info/avatar.h"
62 #include "player/attack-defense-types.h"
63 #include "player/digestion-processor.h"
64 #include "player/mimic-info-table.h"
65 #include "player/patron.h"
66 #include "player/player-class.h"
67 #include "player/player-damage.h"
68 #include "player/player-move.h"
69 #include "player/player-personalities-types.h"
70 #include "player/player-personality.h"
71 #include "player/player-race-types.h"
72 #include "player/player-skill.h"
73 #include "player/player-status-flags.h"
74 #include "player/player-status-table.h"
75 #include "player/player-view.h"
76 #include "player/race-info-table.h"
77 #include "player/special-defense-types.h"
78 #include "realm/realm-hex-numbers.h"
79 #include "realm/realm-names-table.h"
80 #include "realm/realm-song-numbers.h"
81 #include "specific-object/bow.h"
82 #include "specific-object/torch.h"
83 #include "spell-realm/spells-hex.h"
84 #include "spell/range-calc.h"
85 #include "spell/spells-describer.h"
86 #include "spell/spells-execution.h"
87 #include "spell/spells-status.h"
88 #include "spell/technic-info-table.h"
89 #include "status/action-setter.h"
90 #include "status/base-status.h"
91 #include "sv-definition/sv-lite-types.h"
92 #include "sv-definition/sv-weapon-types.h"
93 #include "system/angband.h"
94 #include "system/floor-type-definition.h"
95 #include "term/screen-processor.h"
96 #include "util/bit-flags-calculator.h"
97 #include "util/quarks.h"
98 #include "util/string-processor.h"
99 #include "view/display-messages.h"
100 #include "world/world.h"
102 static bool is_martial_arts_mode(player_type *creature_ptr);
104 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr);
105 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr);
106 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
107 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
108 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
109 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
110 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
111 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
112 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
113 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
114 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
115 static s16b calc_num_blow(player_type *creature_ptr, int i);
116 static s16b calc_strength_addition(player_type *creature_ptr);
117 static s16b calc_intelligence_addition(player_type *creature_ptr);
118 static s16b calc_wisdom_addition(player_type *creature_ptr);
119 static s16b calc_dexterity_addition(player_type *creature_ptr);
120 static s16b calc_constitution_addition(player_type *creature_ptr);
121 static s16b calc_charisma_addition(player_type *creature_ptr);
122 static s16b calc_to_magic_chance(player_type *creature_ptr);
123 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
124 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_true_value);
125 static s16b calc_speed(player_type *creature_ptr);
126 static s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
127 static void calc_use_status(player_type *creature_ptr, int status);
128 static void calc_top_status(player_type *creature_ptr, int status);
129 static void calc_ind_status(player_type *creature_ptr, int status);
130 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
131 static void put_equipment_warning(player_type *creature_ptr);
133 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value);
134 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value);
136 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_true_value);
138 static s16b calc_to_damage_misc(player_type *creature_ptr);
139 static s16b calc_to_hit_misc(player_type *creature_ptr);
141 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
142 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot);
144 static int get_default_hand(player_type *creature_ptr);
146 /*** Player information ***/
149 * @brief プレイヤー用のクリーチャー構造体実体 / Static player info record
154 * @brief プレイヤー用のクリーチャー構造体参照ポインタ / Pointer to the player info
156 player_type *p_ptr = &p_body;
159 * @brief クリーチャーの抽象的善悪アライメントの表記を返す。 / Return alignment title
160 * @param creature_ptr 算出するクリーチャーの参照ポインタ。
161 * @return アライメントの表記を返す。
163 concptr your_alignment(player_type *creature_ptr)
165 if (creature_ptr->align > 150)
166 return _("大善", "Lawful");
167 else if (creature_ptr->align > 50)
168 return _("中善", "Good");
169 else if (creature_ptr->align > 10)
170 return _("小善", "Neutral Good");
171 else if (creature_ptr->align > -11)
172 return _("中立", "Neutral");
173 else if (creature_ptr->align > -51)
174 return _("小悪", "Neutral Evil");
175 else if (creature_ptr->align > -151)
176 return _("中悪", "Evil");
178 return _("大悪", "Chaotic");
182 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
183 * @param weapon_exp 経験値
186 int weapon_exp_level(int weapon_exp)
188 if (weapon_exp < WEAPON_EXP_BEGINNER)
189 return EXP_LEVEL_UNSKILLED;
190 else if (weapon_exp < WEAPON_EXP_SKILLED)
191 return EXP_LEVEL_BEGINNER;
192 else if (weapon_exp < WEAPON_EXP_EXPERT)
193 return EXP_LEVEL_SKILLED;
194 else if (weapon_exp < WEAPON_EXP_MASTER)
195 return EXP_LEVEL_EXPERT;
197 return EXP_LEVEL_MASTER;
201 * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
202 * @param weapon_exp 経験値
205 int riding_exp_level(int riding_exp)
207 if (riding_exp < RIDING_EXP_BEGINNER)
208 return EXP_LEVEL_UNSKILLED;
209 else if (riding_exp < RIDING_EXP_SKILLED)
210 return EXP_LEVEL_BEGINNER;
211 else if (riding_exp < RIDING_EXP_EXPERT)
212 return EXP_LEVEL_SKILLED;
213 else if (riding_exp < RIDING_EXP_MASTER)
214 return EXP_LEVEL_EXPERT;
216 return EXP_LEVEL_MASTER;
220 * @brief クリーチャーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
221 * @param spell_exp 経験値
224 int spell_exp_level(int spell_exp)
226 if (spell_exp < SPELL_EXP_BEGINNER)
227 return EXP_LEVEL_UNSKILLED;
228 else if (spell_exp < SPELL_EXP_SKILLED)
229 return EXP_LEVEL_BEGINNER;
230 else if (spell_exp < SPELL_EXP_EXPERT)
231 return EXP_LEVEL_SKILLED;
232 else if (spell_exp < SPELL_EXP_MASTER)
233 return EXP_LEVEL_EXPERT;
235 return EXP_LEVEL_MASTER;
239 * @brief 遅延描画更新 / Delayed visual update
240 * @details update_view(), update_lite(), update_mon_lite() においてのみ更新すること / Only used if update_view(), update_lite() or update_mon_lite() was called
241 * @param player_ptr 主観となるプレイヤー構造体参照ポインタ
242 * @todo 将来独自インターフェース実装にはz-term系に追い出すべきか?
245 static void delayed_visual_update(player_type *player_ptr)
247 floor_type *floor_ptr = player_ptr->current_floor_ptr;
248 for (int i = 0; i < floor_ptr->redraw_n; i++) {
249 POSITION y = floor_ptr->redraw_y[i];
250 POSITION x = floor_ptr->redraw_x[i];
252 g_ptr = &floor_ptr->grid_array[y][x];
253 if (!(g_ptr->info & CAVE_REDRAW))
256 if (g_ptr->info & CAVE_NOTE)
257 note_spot(player_ptr, y, x);
259 lite_spot(player_ptr, y, x);
261 update_monster(player_ptr, g_ptr->m_idx, FALSE);
263 g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
266 floor_ptr->redraw_n = 0;
270 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
271 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
272 * @return 重すぎるならばTRUE
274 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
276 int hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
277 return (hold < o_ptr->weight / 10);
282 * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
285 WEIGHT calc_inventory_weight(player_type *creature_ptr)
290 for (inventory_slot_type i = 0; i < INVEN_TOTAL; i++) {
291 o_ptr = &creature_ptr->inventory_list[i];
294 weight += o_ptr->weight * o_ptr->number;
299 * @brief プレイヤーの全ステータスを更新する /
300 * Calculate the players current "state", taking into account
301 * not only race/class intrinsics, but also objects being worn
302 * and temporary spell effects.
306 * See also calc_mana() and calc_hitpoints().
308 * Take note of the new "speed code", in particular, a very strong
309 * player will start slowing down as soon as he reaches 150 pounds,
310 * but not until he reaches 450 pounds will he be half as fast as
311 * a normal kobold. This both hurts and helps the player, hurts
312 * because in the old days a player could just avoid 300 pounds,
313 * and helps because now carrying 300 pounds is not very painful.
315 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
316 * damage, since that would affect non-combat things. These values
317 * are actually added in later, at the appropriate place.
319 * This function induces various "status" messages.
321 * @todo ここで計算していた各値は一部の状態変化メッセージ処理を除き、今後必要な時に適示計算する形に移行するためほぼすべて削られる。
323 void calc_bonuses(player_type *creature_ptr)
325 int empty_hands_status = empty_hands(creature_ptr, TRUE);
328 /* Save the old vision stuff */
329 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
330 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
331 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
332 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
333 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
334 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
335 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
336 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
337 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
338 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
339 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
340 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
341 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
342 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
343 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
344 s16b old_speed = creature_ptr->pspeed;
346 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
347 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
349 creature_ptr->pass_wall = has_pass_wall(creature_ptr);
350 creature_ptr->kill_wall = has_kill_wall(creature_ptr);
351 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
352 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
353 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
354 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
355 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
356 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
357 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
358 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
359 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
360 creature_ptr->esp_human = has_esp_human(creature_ptr);
361 creature_ptr->esp_good = has_esp_good(creature_ptr);
362 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
363 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
364 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
365 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
366 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
367 creature_ptr->down_saving = has_down_saving(creature_ptr);
368 creature_ptr->yoiyami = has_no_ac(creature_ptr);
369 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
370 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
371 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
372 creature_ptr->warning = has_warning(creature_ptr);
373 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
374 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
375 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
376 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
377 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
378 creature_ptr->see_inv = has_see_inv(creature_ptr);
379 creature_ptr->free_act = has_free_act(creature_ptr);
380 creature_ptr->sustain_con = has_sustain_con(creature_ptr);
381 creature_ptr->sustain_chr = has_sustain_chr(creature_ptr);
382 creature_ptr->levitation = has_levitation(creature_ptr);
383 has_can_swim(creature_ptr);
384 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
385 creature_ptr->regenerate = has_regenerate(creature_ptr);
386 has_curses(creature_ptr);
387 creature_ptr->impact = has_impact(creature_ptr);
388 has_extra_blow(creature_ptr);
390 creature_ptr->lite = has_lite(creature_ptr);
392 if (creature_ptr->special_defense & KAMAE_MASK) {
393 if (!(empty_hands_status & EMPTY_HAND_RARM)) {
394 set_action(creature_ptr, ACTION_NONE);
398 creature_ptr->stat_add[A_STR] = calc_strength_addition(creature_ptr);
399 creature_ptr->stat_add[A_INT] = calc_intelligence_addition(creature_ptr);
400 creature_ptr->stat_add[A_WIS] = calc_wisdom_addition(creature_ptr);
401 creature_ptr->stat_add[A_DEX] = calc_dexterity_addition(creature_ptr);
402 creature_ptr->stat_add[A_CON] = calc_constitution_addition(creature_ptr);
403 creature_ptr->stat_add[A_CHR] = calc_charisma_addition(creature_ptr);
404 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
405 creature_ptr->ac = calc_base_ac(creature_ptr);
406 creature_ptr->to_a = calc_to_ac(creature_ptr, TRUE);
407 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
408 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, FALSE);
410 for (int i = 0; i < A_MAX; i++) {
411 calc_top_status(creature_ptr, i);
412 calc_use_status(creature_ptr, i);
413 calc_ind_status(creature_ptr, i);
416 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
418 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
419 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
420 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
424 for (int i = 0; i < 2; i++) {
425 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
426 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
427 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
428 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_RARM + i);
429 creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_RARM + i);
432 creature_ptr->pspeed = calc_speed(creature_ptr);
433 creature_ptr->see_infra = calc_intra_vision(creature_ptr);
434 creature_ptr->skill_stl = calc_stealth(creature_ptr);
435 creature_ptr->skill_dis = calc_disarming(creature_ptr);
436 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
437 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
438 creature_ptr->skill_srh = calc_search(creature_ptr);
439 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
440 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
441 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
442 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
443 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, TRUE);
444 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, TRUE);
445 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, FALSE);
446 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, FALSE);
447 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_RARM, TRUE);
448 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_LARM, TRUE);
449 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_RARM, FALSE);
450 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_LARM, FALSE);
451 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, TRUE);
452 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, FALSE);
453 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
454 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
455 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
457 if (old_mighty_throw != creature_ptr->mighty_throw) {
458 creature_ptr->window |= PW_INVEN;
461 if (creature_ptr->telepathy != old_telepathy) {
462 creature_ptr->update |= (PU_MONSTERS);
465 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
466 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
467 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
468 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
469 creature_ptr->update |= (PU_MONSTERS);
472 if (creature_ptr->see_inv != old_see_inv) {
473 creature_ptr->update |= (PU_MONSTERS);
476 if (creature_ptr->pspeed != old_speed) {
477 creature_ptr->redraw |= (PR_SPEED);
480 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
481 creature_ptr->redraw |= (PR_ARMOR);
482 creature_ptr->window |= (PW_PLAYER);
485 if (current_world_ptr->character_xtra)
488 put_equipment_warning(creature_ptr);
491 static void calc_alignment(player_type *creature_ptr)
493 creature_ptr->align = 0;
494 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
495 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
498 m_ptr = &floor_ptr->m_list[m_idx];
499 if (!monster_is_valid(m_ptr))
501 r_ptr = &r_info[m_ptr->r_idx];
506 if (r_ptr->flags3 & RF3_GOOD)
507 creature_ptr->align += r_ptr->level;
508 if (r_ptr->flags3 & RF3_EVIL)
509 creature_ptr->align -= r_ptr->level;
512 if (creature_ptr->mimic_form) {
513 switch (creature_ptr->mimic_form) {
515 creature_ptr->align -= 200;
517 case MIMIC_DEMON_LORD:
518 creature_ptr->align -= 200;
522 switch (creature_ptr->prace) {
524 creature_ptr->align += 200;
527 creature_ptr->align -= 200;
532 for (int i = 0; i < 2; i++) {
533 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i))
535 if (creature_ptr->inventory_list[INVEN_RARM + i].name1 != ART_IRON_BALL)
537 creature_ptr->align -= 1000;
542 for (int i = 0; i < 8; i++) {
543 switch (creature_ptr->vir_types[i]) {
545 creature_ptr->align += creature_ptr->virtues[i] * 2;
554 creature_ptr->align -= creature_ptr->virtues[i];
557 creature_ptr->align += creature_ptr->virtues[i];
562 for (int i = 0; i < j; i++) {
563 if (creature_ptr->align > 0) {
564 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
565 if (creature_ptr->align < 0)
566 creature_ptr->align = 0;
567 } else if (creature_ptr->align < 0) {
568 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
569 if (creature_ptr->align > 0)
570 creature_ptr->align = 0;
576 * @brief プレイヤーの最大HPを計算する /
577 * Calculate the players (maximal) hit points
578 * Adjust current hitpoints if necessary
582 static void calc_hitpoints(player_type *creature_ptr)
584 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
585 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
588 if (creature_ptr->mimic_form) {
589 if (creature_ptr->pclass == CLASS_SORCERER)
590 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
592 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
593 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
596 if (creature_ptr->pclass == CLASS_SORCERER) {
597 if (creature_ptr->lev < 30)
598 mhp = (mhp * (45 + creature_ptr->lev) / 100);
600 mhp = (mhp * 75 / 100);
601 bonus = (bonus * 65 / 100);
606 if (creature_ptr->pclass == CLASS_BERSERKER) {
607 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
610 if (mhp < creature_ptr->lev + 1)
611 mhp = creature_ptr->lev + 1;
612 if (is_hero(creature_ptr))
614 if (is_shero(creature_ptr))
616 if (creature_ptr->tsuyoshi)
618 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
620 if (hex_spelling(creature_ptr, HEX_BUILDING))
622 if (creature_ptr->mhp == mhp)
625 if (creature_ptr->chp >= mhp) {
626 creature_ptr->chp = mhp;
627 creature_ptr->chp_frac = 0;
631 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
632 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
635 creature_ptr->mhp = mhp;
637 creature_ptr->redraw |= PR_HP;
638 creature_ptr->window |= PW_PLAYER;
642 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
643 * Calculate number of spells player should have, and forget,
644 * or remember, spells until that number is properly reflected.
647 * Note that this function induces various "status" messages,
648 * which must be bypasses until the character is created.
650 static void calc_spells(player_type *creature_ptr)
652 if (!mp_ptr->spell_book)
654 if (!current_world_ptr->character_generated)
656 if (current_world_ptr->character_xtra)
658 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
659 creature_ptr->new_spells = 0;
663 concptr p = spell_category_name(mp_ptr->spell_book);
664 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
668 int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
670 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
674 if (creature_ptr->pclass == CLASS_SAMURAI) {
676 } else if (creature_ptr->realm2 == REALM_NONE) {
677 num_allowed = (num_allowed + 1) / 2;
678 if (num_allowed > (32 + bonus))
679 num_allowed = 32 + bonus;
680 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
681 if (num_allowed > (96 + bonus))
682 num_allowed = 96 + bonus;
684 if (num_allowed > (80 + bonus))
685 num_allowed = 80 + bonus;
688 int num_boukyaku = 0;
689 for (int j = 0; j < 64; j++) {
690 if ((j < 32) ? (creature_ptr->spell_forgotten1 & (1L << j)) : (creature_ptr->spell_forgotten2 & (1L << (j - 32)))) {
695 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
696 for (int i = 63; i >= 0; i--) {
697 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
700 int j = creature_ptr->spell_order[i];
704 const magic_type *s_ptr;
705 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
707 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
709 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
711 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
713 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
715 if (s_ptr->slevel <= creature_ptr->lev)
718 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_learned1 & (1L << j)) : (creature_ptr->spell_learned2 & (1L << (j - 32)));
719 if (!is_spell_learned)
724 creature_ptr->spell_forgotten1 |= (1L << j);
725 which = creature_ptr->realm1;
727 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
728 which = creature_ptr->realm2;
732 creature_ptr->spell_learned1 &= ~(1L << j);
733 which = creature_ptr->realm1;
735 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
736 which = creature_ptr->realm2;
740 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
742 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
744 creature_ptr->new_spells++;
747 /* Forget spells if we know too many spells */
748 for (int i = 63; i >= 0; i--) {
749 if (creature_ptr->new_spells >= 0)
751 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
754 int j = creature_ptr->spell_order[i];
758 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_learned1 & (1L << j)) : (creature_ptr->spell_learned2 & (1L << (j - 32)));
759 if (!is_spell_learned)
764 creature_ptr->spell_forgotten1 |= (1L << j);
765 which = creature_ptr->realm1;
767 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
768 which = creature_ptr->realm2;
772 creature_ptr->spell_learned1 &= ~(1L << j);
773 which = creature_ptr->realm1;
775 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
776 which = creature_ptr->realm2;
780 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
782 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
784 creature_ptr->new_spells++;
787 /* Check for spells to remember */
788 for (int i = 0; i < 64; i++) {
789 if (creature_ptr->new_spells <= 0)
791 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
793 int j = creature_ptr->spell_order[i];
797 const magic_type *s_ptr;
798 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
800 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
802 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
804 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
806 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
808 if (s_ptr->slevel > creature_ptr->lev)
811 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_forgotten1 & (1L << j)) : (creature_ptr->spell_forgotten2 & (1L << (j - 32)));
812 if (!is_spell_learned)
817 creature_ptr->spell_forgotten1 &= ~(1L << j);
818 which = creature_ptr->realm1;
820 creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
821 which = creature_ptr->realm2;
825 creature_ptr->spell_learned1 |= (1L << j);
826 which = creature_ptr->realm1;
828 creature_ptr->spell_learned2 |= (1L << (j - 32));
829 which = creature_ptr->realm2;
833 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
835 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
837 creature_ptr->new_spells--;
840 if (creature_ptr->realm2 == REALM_NONE) {
842 for (int j = 0; j < 32; j++) {
843 const magic_type *s_ptr;
844 if (!is_magic(creature_ptr->realm1))
845 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
847 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
849 if (s_ptr->slevel > creature_ptr->lev)
852 if (creature_ptr->spell_learned1 & (1L << j)) {
861 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
862 creature_ptr->new_spells = (s16b)k;
866 if (creature_ptr->new_spells < 0)
867 creature_ptr->new_spells = 0;
869 if (creature_ptr->old_spells == creature_ptr->new_spells)
872 if (creature_ptr->new_spells) {
874 if (creature_ptr->new_spells < 10) {
875 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
877 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
880 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
884 creature_ptr->old_spells = creature_ptr->new_spells;
885 creature_ptr->redraw |= PR_STUDY;
886 creature_ptr->window |= PW_OBJECT;
890 * @brief プレイヤーの最大MPを計算する /
891 * Calculate maximum mana. You do not need to know any spells.
892 * Note that mana is lowered by heavy (or inappropriate) armor.
895 * This function induces status messages.
897 static void calc_mana(player_type *creature_ptr)
899 if (!mp_ptr->spell_book)
903 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)) {
904 levels = creature_ptr->lev;
906 if (mp_ptr->spell_first > creature_ptr->lev) {
907 creature_ptr->msp = 0;
908 creature_ptr->redraw |= (PR_MANA);
912 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
916 if (creature_ptr->pclass == CLASS_SAMURAI) {
917 msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
919 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
921 msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
925 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
926 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
928 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
930 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
931 msp += msp * (25 + creature_ptr->lev) / 100;
934 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA) {
935 BIT_FLAGS flgs[TR_FLAG_SIZE];
936 creature_ptr->cumber_glove = FALSE;
938 o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
939 object_flags(creature_ptr, o_ptr, flgs);
940 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
941 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
942 creature_ptr->cumber_glove = TRUE;
947 creature_ptr->cumber_armor = FALSE;
950 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD)
951 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
952 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD)
953 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
954 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
955 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
956 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
957 cur_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
958 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
960 switch (creature_ptr->pclass) {
962 case CLASS_HIGH_MAGE:
963 case CLASS_BLUE_MAGE:
965 case CLASS_FORCETRAINER:
966 case CLASS_SORCERER: {
967 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
968 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
969 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
970 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
975 case CLASS_TOURIST: {
976 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
977 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight * 2 / 3;
978 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
979 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
982 case CLASS_MINDCRAFTER:
983 case CLASS_BEASTMASTER:
984 case CLASS_MIRROR_MASTER: {
985 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
986 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 2;
987 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
988 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 2;
994 case CLASS_WARRIOR_MAGE: {
995 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
996 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 3;
997 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
998 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 3;
1002 case CLASS_CHAOS_WARRIOR: {
1003 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
1004 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 5;
1005 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
1006 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 5;
1014 int max_wgt = mp_ptr->spell_weight;
1015 if ((cur_wgt - max_wgt) > 0) {
1016 creature_ptr->cumber_armor = TRUE;
1017 switch (creature_ptr->pclass) {
1019 case CLASS_HIGH_MAGE:
1020 case CLASS_BLUE_MAGE: {
1021 msp -= msp * (cur_wgt - max_wgt) / 600;
1025 case CLASS_MINDCRAFTER:
1026 case CLASS_BEASTMASTER:
1028 case CLASS_FORCETRAINER:
1030 case CLASS_MIRROR_MASTER: {
1031 msp -= msp * (cur_wgt - max_wgt) / 800;
1034 case CLASS_SORCERER: {
1035 msp -= msp * (cur_wgt - max_wgt) / 900;
1041 case CLASS_RED_MAGE: {
1042 msp -= msp * (cur_wgt - max_wgt) / 1000;
1046 case CLASS_CHAOS_WARRIOR:
1047 case CLASS_WARRIOR_MAGE: {
1048 msp -= msp * (cur_wgt - max_wgt) / 1200;
1051 case CLASS_SAMURAI: {
1052 creature_ptr->cumber_armor = FALSE;
1056 msp -= msp * (cur_wgt - max_wgt) / 800;
1065 if (creature_ptr->msp != msp) {
1066 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
1067 creature_ptr->csp = msp;
1068 creature_ptr->csp_frac = 0;
1072 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
1073 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
1076 creature_ptr->msp = msp;
1077 creature_ptr->redraw |= (PR_MANA);
1078 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
1081 if (current_world_ptr->character_xtra)
1084 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
1085 if (creature_ptr->cumber_glove)
1086 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
1088 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
1090 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
1093 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
1096 if (creature_ptr->cumber_armor)
1097 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
1099 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
1101 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
1105 * @brief 装備中の射撃武器の威力倍率を返す /
1106 * calcurate the fire rate of target object
1107 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
1108 * @return 射撃倍率の値(100で1.00倍)
1110 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
1112 int extra_shots = 0;
1113 BIT_FLAGS flgs[TR_FLAG_SIZE];
1115 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1117 q_ptr = &creature_ptr->inventory_list[i];
1124 object_flags(creature_ptr, q_ptr, flgs);
1125 if (has_flag(flgs, TR_XTRA_SHOTS))
1129 object_flags(creature_ptr, o_ptr, flgs);
1130 if (has_flag(flgs, TR_XTRA_SHOTS))
1134 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1138 num += (extra_shots * 100);
1140 tval_type tval_ammo = bow_tval_ammo(o_ptr);
1141 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1142 num += (creature_ptr->lev * 4);
1145 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1146 num += (creature_ptr->lev * 3);
1149 if (creature_ptr->pclass == CLASS_ARCHER) {
1150 if (tval_ammo == TV_ARROW)
1151 num += ((creature_ptr->lev * 5) + 50);
1152 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1153 num += (creature_ptr->lev * 4);
1156 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1157 num += (creature_ptr->lev * 2);
1160 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1161 num += (creature_ptr->lev * 4);
1169 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1173 * * 変異MUT3_INFRAVISによる加算(+3)
1174 * * 魔法効果tim_infraによる加算(+3)
1175 * * 装備がTR_INFRAフラグ持ちなら加算(+pval*1)
1177 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr)
1179 ACTION_SKILL_POWER pow;
1180 const player_race *tmp_rp_ptr;
1182 if (creature_ptr->mimic_form)
1183 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1185 tmp_rp_ptr = &race_info[creature_ptr->prace];
1187 pow = tmp_rp_ptr->infra;
1189 if (creature_ptr->muta3 & MUT3_INFRAVIS) {
1193 if (creature_ptr->tim_infra) {
1197 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1199 BIT_FLAGS flgs[TR_FLAG_SIZE];
1200 o_ptr = &creature_ptr->inventory_list[i];
1203 object_flags(creature_ptr, o_ptr, flgs);
1204 if (has_flag(flgs, TR_INFRA))
1213 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1219 * * 装備による修正(TR_STEALTHがあれば+pval*1)
1220 * * 変異MUT3_XTRA_NOISで減算(-3)
1221 * * 変異MUT3_MOTIONで加算(+1)
1222 * * 呪術を唱えていると減算(-(詠唱数+1))
1223 * * セクシーギャルでない影フェアリーがTRC_AGGRAVATE持ちの時、別処理でTRC_AGGRAVATEを無効にする代わりに減算(-3か3未満なら(現在値+2)/2)
1225 * * 忍者がheavy_armorならば減算(-レベル/10)
1226 * * 忍者がheavy_armorでなく適正な武器を持っていれば加算(+レベル/10)
1230 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr)
1232 ACTION_SKILL_POWER pow;
1233 const player_race *tmp_rp_ptr;
1235 if (creature_ptr->mimic_form)
1236 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1238 tmp_rp_ptr = &race_info[creature_ptr->prace];
1239 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1240 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1242 pow = 1 + tmp_rp_ptr->r_stl + c_ptr->c_stl + a_ptr->a_stl;
1243 pow += (c_ptr->x_stl * creature_ptr->lev / 10);
1245 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1247 BIT_FLAGS flgs[TR_FLAG_SIZE];
1248 o_ptr = &creature_ptr->inventory_list[i];
1251 object_flags(creature_ptr, o_ptr, flgs);
1252 if (has_flag(flgs, TR_STEALTH))
1256 if (creature_ptr->muta3 & MUT3_XTRA_NOIS) {
1259 if (creature_ptr->muta3 & MUT3_MOTION) {
1262 if (creature_ptr->realm1 == REALM_HEX) {
1263 if (hex_spelling_any(creature_ptr))
1264 pow -= (1 + casting_hex_num(creature_ptr));
1266 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
1267 pow = MIN(pow - 3, (pow + 2) / 2);
1270 if (is_shero(creature_ptr)) {
1274 if (creature_ptr->pclass == CLASS_NINJA && heavy_armor(creature_ptr)) {
1275 pow -= (creature_ptr->lev) / 10;
1276 } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
1277 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
1278 pow += (creature_ptr->lev) / 10;
1281 if (is_time_limit_stealth(creature_ptr))
1294 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1298 * * 職業と性格とレベルによる追加加算
1299 * * 器用さに応じたadj_dex_disテーブルによる加算
1300 * * 知力に応じたadj_int_disテーブルによる加算
1302 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1304 ACTION_SKILL_POWER pow;
1305 const player_race *tmp_rp_ptr;
1307 if (creature_ptr->mimic_form)
1308 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1310 tmp_rp_ptr = &race_info[creature_ptr->prace];
1311 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1312 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1314 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1315 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1316 pow += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
1317 pow += adj_int_dis[creature_ptr->stat_ind[A_INT]];
1323 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1327 * * 職業と性格とレベルによる追加加算
1328 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1329 * * 知力に応じたadj_int_devテーブルによる加算
1332 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1334 ACTION_SKILL_POWER pow;
1335 const player_race *tmp_rp_ptr;
1337 if (creature_ptr->mimic_form)
1338 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1340 tmp_rp_ptr = &race_info[creature_ptr->prace];
1341 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1342 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1344 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1345 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1347 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1349 BIT_FLAGS flgs[TR_FLAG_SIZE];
1350 o_ptr = &creature_ptr->inventory_list[i];
1353 object_flags(creature_ptr, o_ptr, flgs);
1354 if (has_flag(flgs, TR_MAGIC_MASTERY))
1355 pow += 8 * o_ptr->pval;
1358 pow += adj_int_dev[creature_ptr->stat_ind[A_INT]];
1360 if (is_shero(creature_ptr)) {
1368 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1372 * * 職業と性格とレベルによる追加加算
1373 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1374 * * 賢さによるadj_wis_savテーブル加算
1376 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1377 * * クターのつぶれ状態なら(10に上書き)
1378 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1379 * * 呪いのdown_savingがかかっているなら半減
1381 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1383 ACTION_SKILL_POWER pow;
1384 const player_race *tmp_rp_ptr;
1386 if (creature_ptr->mimic_form)
1387 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1389 tmp_rp_ptr = &race_info[creature_ptr->prace];
1390 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1391 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1393 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1394 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1396 if (creature_ptr->muta3 & MUT3_MAGIC_RES)
1397 pow += (15 + (creature_ptr->lev / 5));
1399 pow += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
1401 if (is_shero(creature_ptr))
1404 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1405 pow = 90 + creature_ptr->lev;
1407 if (creature_ptr->tsubureru)
1410 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1411 pow = 95 + creature_ptr->lev;
1413 if (creature_ptr->down_saving)
1421 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1426 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1428 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1430 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1432 ACTION_SKILL_POWER pow;
1433 const player_race *tmp_rp_ptr;
1435 if (creature_ptr->mimic_form)
1436 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1438 tmp_rp_ptr = &race_info[creature_ptr->prace];
1439 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1440 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1442 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1443 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1445 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1447 BIT_FLAGS flgs[TR_FLAG_SIZE];
1448 o_ptr = &creature_ptr->inventory_list[i];
1451 object_flags(creature_ptr, o_ptr, flgs);
1452 if (has_flag(flgs, TR_SEARCH))
1453 pow += (o_ptr->pval * 5);
1456 if (creature_ptr->muta3 & MUT3_XTRA_EYES) {
1460 if (is_shero(creature_ptr)) {
1469 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1474 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1476 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1478 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1480 ACTION_SKILL_POWER pow;
1481 const player_race *tmp_rp_ptr;
1483 if (creature_ptr->mimic_form)
1484 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1486 tmp_rp_ptr = &race_info[creature_ptr->prace];
1487 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1488 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1490 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1491 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1493 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1495 BIT_FLAGS flgs[TR_FLAG_SIZE];
1496 o_ptr = &creature_ptr->inventory_list[i];
1499 object_flags(creature_ptr, o_ptr, flgs);
1500 if (has_flag(flgs, TR_SEARCH))
1501 pow += (o_ptr->pval * 5);
1504 if (is_shero(creature_ptr)) {
1508 if (creature_ptr->muta3 & MUT3_XTRA_EYES) {
1517 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1520 * * 種族/職業/性格による加算とレベルによる追加加算
1522 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1524 ACTION_SKILL_POWER pow;
1525 const player_race *tmp_rp_ptr;
1526 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1527 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1529 if (creature_ptr->mimic_form)
1530 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1532 tmp_rp_ptr = &race_info[creature_ptr->prace];
1534 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1535 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1541 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1544 * * 種族/職業/性格による加算とレベルによる追加加算
1546 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1548 ACTION_SKILL_POWER pow;
1549 const player_race *tmp_rp_ptr;
1550 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1551 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1553 if (creature_ptr->mimic_form)
1554 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1556 tmp_rp_ptr = &race_info[creature_ptr->prace];
1558 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1559 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1565 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1568 * * 種族/職業/性格による加算とレベルによる追加加算
1571 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1573 ACTION_SKILL_POWER pow;
1574 const player_race *tmp_rp_ptr;
1575 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1576 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1578 if (creature_ptr->mimic_form)
1579 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1581 tmp_rp_ptr = &race_info[creature_ptr->prace];
1583 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1584 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1586 if (is_shero(creature_ptr)) {
1595 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1606 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1609 BIT_FLAGS flgs[TR_FLAG_SIZE];
1611 ACTION_SKILL_POWER pow;
1615 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_RARM].k_idx) {
1616 pow += creature_ptr->lev * 10;
1619 if (is_shero(creature_ptr))
1622 pow += adj_str_dig[creature_ptr->stat_ind[A_STR]];
1624 if (creature_ptr->pclass == CLASS_BERSERKER)
1625 pow += (100 + creature_ptr->lev * 8);
1627 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1628 o_ptr = &creature_ptr->inventory_list[i];
1631 object_flags(creature_ptr, o_ptr, flgs);
1632 if (has_flag(flgs, TR_TUNNEL))
1633 pow += (o_ptr->pval * 20);
1636 for (int i = 0; i < 2; i++) {
1637 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1638 if (has_melee_weapon(creature_ptr, INVEN_RARM + i) && !creature_ptr->heavy_wield[i]) {
1639 pow += (o_ptr->weight / 10);
1643 if (is_shero(creature_ptr)) {
1653 static bool is_martial_arts_mode(player_type *creature_ptr)
1655 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1656 && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM) && !has_left_hand_weapon(creature_ptr);
1659 static s16b calc_num_blow(player_type *creature_ptr, int i)
1662 BIT_FLAGS flgs[TR_FLAG_SIZE];
1665 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1666 object_flags(creature_ptr, o_ptr, flgs);
1667 creature_ptr->heavy_wield[i] = FALSE;
1668 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1671 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
1672 creature_ptr->heavy_wield[i] = TRUE;
1675 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1676 int str_index, dex_index;
1677 int num = 0, wgt = 0, mul = 0, div = 0;
1679 num = class_info[creature_ptr->pclass].num;
1680 wgt = class_info[creature_ptr->pclass].wgt;
1681 mul = class_info[creature_ptr->pclass].mul;
1683 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1689 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1695 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1696 str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
1698 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1700 if (creature_ptr->pclass == CLASS_NINJA)
1701 str_index = MAX(0, str_index - 1);
1705 dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
1709 num_blow = blows_table[str_index][dex_index];
1711 num_blow = (s16b)num;
1713 num_blow += (s16b)creature_ptr->extra_blows[i];
1714 if (creature_ptr->pclass == CLASS_WARRIOR)
1715 num_blow += (creature_ptr->lev / 40);
1716 else if (creature_ptr->pclass == CLASS_BERSERKER)
1717 num_blow += (creature_ptr->lev / 23);
1718 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
1721 if (creature_ptr->special_defense & KATA_FUUJIN)
1724 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1734 /* Different calculation for monks with empty hands */
1735 if (is_martial_arts_mode(creature_ptr)) {
1736 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
1739 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1749 MAGIC_NUM1 current_ki = get_current_ki(creature_ptr);
1750 if (current_ki != i) {
1751 creature_ptr->to_d[i] += current_ki / 5;
1752 creature_ptr->dis_to_d[i] += current_ki / 5;
1771 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1774 if (creature_ptr->special_defense & KAMAE_GENBU) {
1775 creature_ptr->to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
1776 creature_ptr->dis_to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
1778 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1782 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1783 creature_ptr->to_h[i] -= (creature_ptr->lev / 3);
1784 creature_ptr->to_d[i] -= (creature_ptr->lev / 6);
1786 creature_ptr->dis_to_h[i] -= (creature_ptr->lev / 3);
1787 creature_ptr->dis_to_d[i] -= (creature_ptr->lev / 6);
1791 num_blow += 1 + creature_ptr->extra_blows[0];
1794 if (has_not_ninja_weapon(creature_ptr, i)) {
1805 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1809 * * エントは別途レベル26,41,46到達ごとに加算(+1)
1810 * * 装備がTR_STRフラグを持っていれば加算(+pval*1)
1816 * * 変異MUT3_HYPER_STRで加算(+4)
1817 * * 変異MUT3_PUNYで減算(-4)
1818 * * ネオ・つよしスペシャル中で加算(+4)
1820 static s16b calc_strength_addition(player_type *creature_ptr)
1823 const player_race *tmp_rp_ptr;
1824 if (creature_ptr->mimic_form)
1825 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1827 tmp_rp_ptr = &race_info[creature_ptr->prace];
1828 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1829 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1830 pow = tmp_rp_ptr->r_adj[A_STR] + c_ptr->c_adj[A_STR] + a_ptr->a_adj[A_STR];
1832 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
1833 if (creature_ptr->lev > 25)
1835 if (creature_ptr->lev > 40)
1837 if (creature_ptr->lev > 45)
1841 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1843 BIT_FLAGS flgs[TR_FLAG_SIZE];
1844 o_ptr = &creature_ptr->inventory_list[i];
1847 object_flags(creature_ptr, o_ptr, flgs);
1848 if (has_flag(flgs, TR_STR)) {
1853 if (creature_ptr->realm1 == REALM_HEX) {
1854 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) {
1857 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
1862 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1866 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
1868 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1872 if (creature_ptr->muta3) {
1874 if (creature_ptr->muta3 & MUT3_HYPER_STR) {
1878 if (creature_ptr->muta3 & MUT3_PUNY) {
1883 if (creature_ptr->tsuyoshi) {
1891 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1895 * * 装備がTR_INTフラグを持っていれば加算(+pval*1)
1901 * * 変異MUT3_HYPER_INTで加算(+4)
1902 * * 変異MUT3_MORONICで減算(-4)
1904 s16b calc_intelligence_addition(player_type *creature_ptr)
1907 const player_race *tmp_rp_ptr;
1908 if (creature_ptr->mimic_form)
1909 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1911 tmp_rp_ptr = &race_info[creature_ptr->prace];
1912 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1913 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1914 pow = tmp_rp_ptr->r_adj[A_INT] + c_ptr->c_adj[A_INT] + a_ptr->a_adj[A_INT];
1916 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1918 BIT_FLAGS flgs[TR_FLAG_SIZE];
1919 o_ptr = &creature_ptr->inventory_list[i];
1922 object_flags(creature_ptr, o_ptr, flgs);
1923 if (has_flag(flgs, TR_INT)) {
1928 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1932 if (creature_ptr->special_defense & KAMAE_GENBU) {
1934 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1938 if (creature_ptr->muta3) {
1939 if (creature_ptr->muta3 & MUT3_HYPER_INT) {
1943 if (creature_ptr->muta3 & MUT3_MORONIC) {
1953 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1957 * * 装備がTR_WISフラグを持っていれば加算(+pval*1)
1963 * * 変異MUT3_HYPER_INTで加算(+4)
1964 * * 変異MUT3_MORONICで減算(-4)
1966 static s16b calc_wisdom_addition(player_type *creature_ptr)
1969 const player_race *tmp_rp_ptr;
1970 if (creature_ptr->mimic_form)
1971 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1973 tmp_rp_ptr = &race_info[creature_ptr->prace];
1974 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1975 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1976 pow = tmp_rp_ptr->r_adj[A_WIS] + c_ptr->c_adj[A_WIS] + a_ptr->a_adj[A_WIS];
1978 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1980 BIT_FLAGS flgs[TR_FLAG_SIZE];
1981 o_ptr = &creature_ptr->inventory_list[i];
1984 object_flags(creature_ptr, o_ptr, flgs);
1985 if (has_flag(flgs, TR_WIS)) {
1990 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1994 if (creature_ptr->special_defense & KAMAE_GENBU) {
1996 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2000 if (creature_ptr->muta3) {
2002 if (creature_ptr->muta3 & MUT3_HYPER_INT) {
2006 if (creature_ptr->muta3 & MUT3_MORONIC) {
2016 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2020 * * エントは別途レベル26,41,46到達ごとに減算(-1)
2021 * * 装備がTR_DEXフラグを持っていれば加算(+pval*1)
2027 * * 変異MUT3_IRON_SKINで減算(-1)
2028 * * 変異MUT3_LIMBERで加算(+3)
2029 * * 変異MUT3_ARTHRITISで減算(-3)
2031 static s16b calc_dexterity_addition(player_type *creature_ptr)
2034 const player_race *tmp_rp_ptr;
2035 if (creature_ptr->mimic_form)
2036 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2038 tmp_rp_ptr = &race_info[creature_ptr->prace];
2039 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2040 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2041 pow = tmp_rp_ptr->r_adj[A_DEX] + c_ptr->c_adj[A_DEX] + a_ptr->a_adj[A_DEX];
2043 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2044 if (creature_ptr->lev > 25)
2046 if (creature_ptr->lev > 40)
2048 if (creature_ptr->lev > 45)
2052 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2054 BIT_FLAGS flgs[TR_FLAG_SIZE];
2055 o_ptr = &creature_ptr->inventory_list[i];
2058 object_flags(creature_ptr, o_ptr, flgs);
2059 if (has_flag(flgs, TR_DEX)) {
2064 if (creature_ptr->realm1 == REALM_HEX) {
2065 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2070 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2074 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2076 } else if (creature_ptr->special_defense & KAMAE_GENBU) {
2078 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2082 if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
2086 if (creature_ptr->muta3 & MUT3_LIMBER) {
2090 if (creature_ptr->muta3 & MUT3_ARTHRITIS) {
2099 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2103 * * エントは別途レベル26,41,46到達ごとに加算(+1)
2104 * * 装備がTR_CONフラグを持っていれば加算(+pval*1)
2110 * * 変異MUT3_RESILIENTで加算(+4)
2111 * * 変異MUT3_ALBINOで減算(-4)
2112 * * 変異MUT3_XTRA_FATで加算(+2)
2113 * * 変異MUT3_FLESH_ROTで減算(-2)
2114 * * ネオ・つよしスペシャル中で加算(+4)
2116 static s16b calc_constitution_addition(player_type *creature_ptr)
2119 const player_race *tmp_rp_ptr;
2120 if (creature_ptr->mimic_form)
2121 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2123 tmp_rp_ptr = &race_info[creature_ptr->prace];
2124 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2125 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2126 pow = tmp_rp_ptr->r_adj[A_CON] + c_ptr->c_adj[A_CON] + a_ptr->a_adj[A_CON];
2128 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2129 if (creature_ptr->lev > 25)
2131 if (creature_ptr->lev > 40)
2133 if (creature_ptr->lev > 45)
2137 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2139 BIT_FLAGS flgs[TR_FLAG_SIZE];
2140 o_ptr = &creature_ptr->inventory_list[i];
2143 object_flags(creature_ptr, o_ptr, flgs);
2144 if (has_flag(flgs, TR_CON))
2148 if (creature_ptr->realm1 == REALM_HEX) {
2149 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2154 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2158 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2160 } else if (creature_ptr->special_defense & KAMAE_GENBU) {
2162 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2166 if (creature_ptr->muta3) {
2167 if (creature_ptr->muta3 & MUT3_RESILIENT) {
2171 if (creature_ptr->muta3 & MUT3_ALBINO) {
2175 if (creature_ptr->muta3 & MUT3_XTRA_FAT) {
2179 if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
2184 if (creature_ptr->tsuyoshi) {
2193 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2197 * * 装備がTR_CHRフラグを持っていれば加算(+pval*1)
2200 * * 変異MUT3_FLESH_ROTで減算(-1)
2201 * * 変異MUT3_SILLY_VOIで減算(-4)
2202 * * 変異MUT3_BLANK_FACで減算(-1)
2203 * * 変異MUT3_WART_SKINで減算(-2)
2204 * * 変異MUT3_SCALESで減算(-1)
2205 * * 変異MUT3_ILL_NORMで0固定(後で個体値のみ上書きを行う)
2207 static s16b calc_charisma_addition(player_type *creature_ptr)
2210 const player_race *tmp_rp_ptr;
2211 if (creature_ptr->mimic_form)
2212 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2214 tmp_rp_ptr = &race_info[creature_ptr->prace];
2215 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2216 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2217 pow = tmp_rp_ptr->r_adj[A_CHR] + c_ptr->c_adj[A_CHR] + a_ptr->a_adj[A_CHR];
2219 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2221 BIT_FLAGS flgs[TR_FLAG_SIZE];
2222 o_ptr = &creature_ptr->inventory_list[i];
2225 object_flags(creature_ptr, o_ptr, flgs);
2226 if (has_flag(flgs, TR_CHR))
2230 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2234 if (creature_ptr->muta3) {
2235 if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
2238 if (creature_ptr->muta3 & MUT3_SILLY_VOI) {
2241 if (creature_ptr->muta3 & MUT3_BLANK_FAC) {
2244 if (creature_ptr->muta3 & MUT3_WART_SKIN) {
2247 if (creature_ptr->muta3 & MUT3_SCALES) {
2250 if (creature_ptr->muta3 & MUT3_ILL_NORM) {
2260 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2263 * * 性格なまけものなら加算(+10)
2265 * * 性格ちからじまんとがまんづよいなら加算(+1)
2266 * * 性格チャージマンなら加算(+5)
2267 * * 装備品にTRC_LOW_MAGICがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
2269 static s16b calc_to_magic_chance(player_type *creature_ptr)
2273 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
2275 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
2277 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
2279 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
2282 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2284 BIT_FLAGS flgs[TR_FLAG_SIZE];
2285 o_ptr = &creature_ptr->inventory_list[i];
2288 object_flags(creature_ptr, o_ptr, flgs);
2289 if (o_ptr->curse_flags & TRC_LOW_MAGIC) {
2290 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
2300 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
2302 ARMOUR_CLASS ac = 0;
2303 if (creature_ptr->yoiyami)
2306 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2308 o_ptr = &creature_ptr->inventory_list[i];
2314 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_RARM])
2315 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_LARM])) {
2316 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2322 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_true_value)
2324 ARMOUR_CLASS ac = 0;
2325 if (creature_ptr->yoiyami)
2328 ac += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2330 if (creature_ptr->mimic_form) {
2331 switch (creature_ptr->mimic_form) {
2335 case MIMIC_DEMON_LORD:
2343 if (creature_ptr->pclass == CLASS_BERSERKER) {
2344 ac += 10 + creature_ptr->lev / 2;
2346 if (creature_ptr->pclass == CLASS_SORCERER) {
2350 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2352 o_ptr = &creature_ptr->inventory_list[i];
2355 if (is_true_value || object_is_known(o_ptr))
2358 if (o_ptr->curse_flags & TRC_LOW_AC) {
2359 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
2360 if (is_true_value || object_is_fully_known(o_ptr))
2363 if (is_true_value || object_is_fully_known(o_ptr))
2368 if ((i == INVEN_LARM) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI))) {
2373 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
2374 ac += 10 + (creature_ptr->lev * 2 / 5);
2377 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2381 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI)) {
2385 if (creature_ptr->muta3 & MUT3_WART_SKIN) {
2389 if (creature_ptr->muta3 & MUT3_SCALES) {
2393 if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
2397 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
2398 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
2399 ac += (creature_ptr->lev * 3) / 2;
2401 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
2402 ac += ((creature_ptr->lev - 13) / 3);
2404 if (!(creature_ptr->inventory_list[INVEN_LARM].k_idx) && (creature_ptr->lev > 10)) {
2405 ac += ((creature_ptr->lev - 8) / 3);
2407 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
2408 ac += (creature_ptr->lev - 2) / 3;
2410 if (!(creature_ptr->inventory_list[INVEN_HANDS].k_idx)) {
2411 ac += (creature_ptr->lev / 2);
2413 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
2414 ac += (creature_ptr->lev / 3);
2418 if (creature_ptr->realm1 == REALM_HEX) {
2419 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
2423 for (inventory_slot_type i = INVEN_RARM; i <= INVEN_FEET; i++) {
2424 object_type *o_ptr = &creature_ptr->inventory_list[i];
2427 if (!object_is_armour(creature_ptr, o_ptr))
2429 if (!object_is_cursed(o_ptr))
2431 if (o_ptr->curse_flags & TRC_CURSED)
2433 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2435 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2440 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2442 } else if (creature_ptr->special_defense & KAMAE_SEIRYU) {
2444 } else if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2448 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
2450 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
2454 if (is_blessed(creature_ptr)) {
2458 if (is_shero(creature_ptr)) {
2462 if (creature_ptr->pclass == CLASS_NINJA) {
2463 if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
2464 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
2465 ac += creature_ptr->lev / 2 + 5;
2474 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2479 * ** クラッコンと妖精に加算(+レベル/10)
2480 * ** 悪魔変化/吸血鬼変化で加算(+3)
2482 * ** 装備品にTR_SPEEDがあれば加算(+pval+1
2483 * ** 忍者の装備が重ければ減算(-レベル/10)
2484 * ** 忍者の装備が適正ならば加算(+3)さらにクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2485 * ** 錬気術師で装備が重くなくクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2486 * ** 狂戦士なら加算(+3),レベル20/30/40/50ごとに+1
2487 * ** いかさまでクラッコン/妖精以外なら加算(+5+レベル/10)
2490 * ** 呪術「衝撃のクローク」で加算(+3)
2493 * ** 変異MUT3_XTRA_FATなら減算(-2)
2494 * ** 変異MUT3_XTRA_LEGなら加算(+3)
2495 * ** 変異MUT3_SHORT_LEGなら減算(-3)
2496 * ** マーフォークがFF_WATER地形にいれば加算(+2+レベル/10)
2497 * ** そうでなく浮遊を持っていないなら減算(-2)
2498 * ** 棘セット装備中ならば加算(+7)
2499 * * 騎乗中ならばモンスターの加速に準拠、ただし騎乗技能値とモンスターレベルによるキャップ処理あり
2501 * * 光速移動中かこの時点で+99を超えていたら+99にキャップ
2504 static s16b calc_speed(player_type *creature_ptr)
2506 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2507 feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
2511 int j = calc_inventory_weight(creature_ptr);
2514 if (!creature_ptr->riding) {
2515 if (is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE))
2516 pow += (creature_ptr->lev) / 10;
2518 if (creature_ptr->mimic_form) {
2519 switch (creature_ptr->mimic_form) {
2523 case MIMIC_DEMON_LORD:
2532 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2533 object_type *o_ptr = &creature_ptr->inventory_list[i];
2534 BIT_FLAGS flgs[TR_FLAG_SIZE];
2535 object_flags(creature_ptr, o_ptr, flgs);
2539 if (has_flag(flgs, TR_SPEED))
2543 if (creature_ptr->pclass == CLASS_NINJA) {
2544 if (heavy_armor(creature_ptr)) {
2545 pow -= (creature_ptr->lev) / 10;
2546 } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
2547 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
2549 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2550 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2551 pow += (creature_ptr->lev) / 10;
2555 if (creature_ptr->pclass == CLASS_FORCETRAINER && !(heavy_armor(creature_ptr))) {
2556 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2557 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2558 pow += (creature_ptr->lev) / 10;
2561 if (creature_ptr->pclass == CLASS_BERSERKER) {
2563 if (creature_ptr->lev > 29)
2565 if (creature_ptr->lev > 39)
2567 if (creature_ptr->lev > 44)
2569 if (creature_ptr->lev > 49)
2573 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN && creature_ptr->prace != RACE_KLACKON && creature_ptr->prace != RACE_SPRITE) {
2574 pow += (creature_ptr->lev) / 10 + 5;
2577 if (is_fast(creature_ptr)) {
2581 if (creature_ptr->slow) {
2585 if (creature_ptr->realm1 == REALM_HEX) {
2586 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) {
2591 if (creature_ptr->food >= PY_FOOD_MAX)
2594 if (creature_ptr->special_defense & KAMAE_SUZAKU)
2597 if (creature_ptr->muta3) {
2599 if (creature_ptr->muta3 & MUT3_XTRA_FAT) {
2603 if (creature_ptr->muta3 & MUT3_XTRA_LEGS) {
2607 if (creature_ptr->muta3 & MUT3_SHORT_LEG) {
2612 if (creature_ptr->prace == RACE_MERFOLK) {
2613 if (has_flag(f_ptr->flags, FF_WATER)) {
2614 pow += (2 + creature_ptr->lev / 10);
2615 } else if (!creature_ptr->levitation) {
2620 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
2621 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2626 count = (int)calc_weight_limit(creature_ptr);
2628 pow -= ((j - count) / (count / 5));
2631 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
2632 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2633 SPEED speed = riding_m_ptr->mspeed;
2635 if (riding_m_ptr->mspeed > 110) {
2636 pow = 110 + (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2643 pow += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2645 if (monster_fast_remaining(riding_m_ptr))
2647 if (monster_slow_remaining(riding_m_ptr))
2650 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED)
2651 j += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2653 count = 1500 + riding_r_ptr->level * 25;
2655 pow -= ((j - count) / (count / 5));
2658 if (creature_ptr->action == ACTION_SEARCH)
2661 /* Maximum speed is (+99). (internally it's 110 + 99) */
2662 /* Temporary lightspeed forces to be maximum speed */
2663 if ((creature_ptr->lightspeed && !creature_ptr->riding) || (pow > 209)) {
2667 /* Minimum speed is (-99). (internally it's 110 - 99) */
2675 * @brief 二刀流ペナルティ量計算
2676 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2677 * @param slot ペナルティ量を計算する武器スロット
2683 * * マンゴーシュ/脇差を左に装備した場合の軽減
2687 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
2690 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
2691 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
2692 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2693 penalty = penalty / 2 - 5;
2695 if (creature_ptr->easy_2weapon) {
2698 } else if ((creature_ptr->inventory_list[INVEN_LARM].tval == TV_SWORD)
2699 && ((creature_ptr->inventory_list[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (creature_ptr->inventory_list[INVEN_LARM].sval == SV_WAKIZASHI))) {
2700 penalty = MAX(0, penalty - 10);
2702 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI)) {
2703 penalty = MIN(0, penalty);
2705 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty > 0))
2707 if ((creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty > 0))
2711 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
2714 return (s16b)penalty;
2717 static void calc_ind_status(player_type *creature_ptr, int status)
2720 if (creature_ptr->stat_use[status] <= 18)
2721 ind = (creature_ptr->stat_use[status] - 3);
2722 else if (creature_ptr->stat_use[status] <= 18 + 219)
2723 ind = (15 + (creature_ptr->stat_use[status] - 18) / 10);
2727 if (creature_ptr->stat_ind[status] == ind)
2730 creature_ptr->stat_ind[status] = (s16b)ind;
2731 if (status == A_CON) {
2732 creature_ptr->update |= (PU_HP);
2733 } else if (status == A_INT) {
2734 if (mp_ptr->spell_stat == A_INT) {
2735 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2737 } else if (status == A_WIS) {
2738 if (mp_ptr->spell_stat == A_WIS) {
2739 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2741 } else if (status == A_CHR) {
2742 if (mp_ptr->spell_stat == A_CHR) {
2743 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2747 creature_ptr->window |= (PW_PLAYER);
2750 static void calc_use_status(player_type *creature_ptr, int status)
2752 int use = modify_stat_value(creature_ptr->stat_cur[status], creature_ptr->stat_add[status]);
2754 if ((status == A_CHR) && (creature_ptr->muta3 & MUT3_ILL_NORM)) {
2755 /* 10 to 18/90 charisma, guaranteed, based on level */
2756 if (use < 8 + 2 * creature_ptr->lev) {
2757 use = 8 + 2 * creature_ptr->lev;
2761 if (creature_ptr->stat_use[status] != use) {
2762 creature_ptr->stat_use[status] = (s16b)use;
2763 creature_ptr->redraw |= (PR_STATS);
2764 creature_ptr->window |= (PW_PLAYER);
2768 static void calc_top_status(player_type *creature_ptr, int status)
2770 int top = modify_stat_value(creature_ptr->stat_max[status], creature_ptr->stat_add[status]);
2772 if (creature_ptr->stat_top[status] != top) {
2773 creature_ptr->stat_top[status] = (s16b)top;
2774 creature_ptr->redraw |= (PR_STATS);
2775 creature_ptr->window |= (PW_PLAYER);
2779 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
2781 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2782 if (!creature_ptr->riding)
2787 creature_ptr->riding_ryoute = FALSE;
2789 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
2790 creature_ptr->riding_ryoute = TRUE;
2791 else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) {
2792 switch (creature_ptr->pclass) {
2794 case CLASS_FORCETRAINER:
2795 case CLASS_BERSERKER:
2796 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM)
2797 && !has_melee_weapon(creature_ptr, INVEN_LARM))
2798 creature_ptr->riding_ryoute = TRUE;
2803 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2804 if (creature_ptr->tval_ammo != TV_ARROW)
2807 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2813 if (creature_ptr->tval_ammo == TV_BOLT)
2819 void put_equipment_warning(player_type *creature_ptr)
2821 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
2822 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
2824 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2825 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
2826 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2828 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2830 creature_ptr->old_heavy_shoot = heavy_shoot;
2833 for (int i = 0; i < 2; i++) {
2834 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
2835 if (creature_ptr->heavy_wield[i]) {
2836 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2837 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2838 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2839 } else if (creature_ptr->heavy_wield[1 - i]) {
2840 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
2842 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2845 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
2848 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
2849 if (creature_ptr->riding_wield[i]) {
2850 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2851 } else if (!creature_ptr->riding) {
2852 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
2853 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2854 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2857 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
2860 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
2863 if (creature_ptr->icky_wield[i]) {
2864 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2865 if (current_world_ptr->is_loading_now) {
2866 chg_virtue(creature_ptr, V_FAITH, -1);
2868 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2869 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2871 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2874 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
2877 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
2878 if (creature_ptr->riding_ryoute) {
2880 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2882 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
2886 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2888 msg_print("You began to control the pet you're riding with one hand.");
2892 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
2895 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
2896 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
2897 if (heavy_armor(creature_ptr)) {
2898 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2899 if (current_world_ptr->is_loading_now) {
2900 chg_virtue(creature_ptr, V_HARMONY, -1);
2903 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2906 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
2910 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value)
2912 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2913 int id = slot - INVEN_RARM;
2914 BIT_FLAGS flgs[TR_FLAG_SIZE];
2915 object_flags(creature_ptr, o_ptr, flgs);
2918 damage += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2920 if (is_shero(creature_ptr)) {
2921 damage += 3 + (creature_ptr->lev / 5);
2924 if (creature_ptr->stun > 50) {
2926 } else if (creature_ptr->stun) {
2930 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2932 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2933 damage += creature_ptr->lev / 6;
2934 if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2935 damage += creature_ptr->lev / 6;
2937 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2938 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2945 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2946 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2947 if (o_ptr->curse_flags & (TRC_CURSED)) {
2950 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) {
2953 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) {
2959 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2961 o_ptr = &creature_ptr->inventory_list[i];
2962 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
2963 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2966 if (!object_is_known(o_ptr) && !is_true_value)
2968 bonus_to_d = o_ptr->to_d;
2970 if (creature_ptr->pclass == CLASS_NINJA) {
2971 if (o_ptr->to_d > 0)
2972 bonus_to_d = (o_ptr->to_d + 1) / 2;
2975 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
2976 damage += (s16b)bonus_to_d;
2977 } else if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) {
2979 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2981 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2982 } else if (id == get_default_hand(creature_ptr)) {
2983 damage += (s16b)bonus_to_d;
2987 if (get_default_hand(creature_ptr) == id) {
2988 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
2989 || !has_disable_two_handed_bonus(creature_ptr, 0)) {
2991 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
2992 damage += MAX(bonus_to_d, 1);
2996 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2997 damage += (creature_ptr->lev / 6);
3004 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
3006 * 'slot' MUST be INVEN_RARM or INVEM_LARM.
3008 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value)
3013 hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3014 hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3016 /* Temporary bonuses */
3017 if (is_blessed(creature_ptr)) {
3021 if (is_hero(creature_ptr)) {
3025 if (is_shero(creature_ptr)) {
3029 if (creature_ptr->stun > 50) {
3031 } else if (creature_ptr->stun) {
3035 /* Default hand bonuses */
3036 int id = slot - INVEN_RARM;
3037 int default_hand = get_default_hand(creature_ptr);
3038 if (default_hand == id) {
3039 /* Add trained bonus of empty hands' combat when having no weapon and riding */
3040 if ((!has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_LARM))
3041 || (!has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))) {
3042 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
3045 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
3046 || !has_disable_two_handed_bonus(creature_ptr, 0)) {
3048 bonus_to_h = ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3049 hit += MAX(bonus_to_h, 1);
3053 /* Bonuses and penalties by weapon */
3054 if (has_melee_weapon(creature_ptr, slot)) {
3055 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3056 BIT_FLAGS flgs[TR_FLAG_SIZE];
3057 object_flags(creature_ptr, o_ptr, flgs);
3059 tval_type tval = o_ptr->tval - TV_WEAPON_BEGIN;
3060 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
3062 /* Traind bonuses */
3063 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3065 /* Weight penalty */
3066 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
3067 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3070 /* Low melee penalty */
3071 if ((object_is_fully_known(o_ptr) || is_true_value) && o_ptr->curse_flags & TRC_LOW_MELEE) {
3072 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
3079 /* Riding bonus and penalty */
3080 if (creature_ptr->riding) {
3081 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3086 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
3087 && !has_flag(flgs, TR_RIDING)) {
3090 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
3093 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3098 hit -= (s16b)penalty;
3101 /* Class penalties */
3102 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
3104 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
3105 hit += creature_ptr->lev / 5;
3106 if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
3107 hit += creature_ptr->lev / 5;
3109 } else if (creature_ptr->pclass == CLASS_SORCERER) {
3110 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
3117 if (has_not_ninja_weapon(creature_ptr, id) || has_not_monk_weapon(creature_ptr, id)) {
3121 /* Hex realm bonuses */
3122 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
3123 if (o_ptr->curse_flags & (TRC_CURSED)) {
3126 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) {
3129 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) {
3132 if (o_ptr->curse_flags & (TRC_TY_CURSE)) {
3138 /* Bonuses from inventory */
3139 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3140 object_type *o_ptr = &creature_ptr->inventory_list[i];
3142 /* Ignore empty hands, handed weapons, bows and capture balls */
3144 || o_ptr->tval == TV_CAPTURE
3145 || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
3146 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i))
3150 /* Fake value does not include unknown objects' value */
3151 if (is_true_value || !object_is_known(o_ptr))
3154 int bonus_to_h = o_ptr->to_h;
3156 /* When wields only a weapon */
3157 if (creature_ptr->pclass == CLASS_NINJA) {
3158 if (o_ptr->to_h > 0)
3159 bonus_to_h = (o_ptr->to_h + 1) / 2;
3162 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
3163 hit += (s16b)bonus_to_h;
3167 /* When wields two weapons on each hand */
3168 if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) {
3169 if (default_hand == 0)
3170 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
3171 if (default_hand == 1)
3172 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
3176 if (default_hand == id)
3177 hit += (s16b)bonus_to_h;
3180 /* Martial arts bonus */
3181 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3182 hit += (creature_ptr->lev / 3);
3185 /* Two handed combat penalty */
3186 hit -= calc_double_weapon_penalty(creature_ptr, slot);
3191 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_true_value)
3195 pow += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3196 pow += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3200 BIT_FLAGS flgs[TR_FLAG_SIZE];
3201 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3203 object_flags(creature_ptr, o_ptr, flgs);
3205 if (o_ptr->curse_flags & TRC_LOW_MELEE) {
3206 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
3215 if (creature_ptr->stun > 50) {
3217 } else if (creature_ptr->stun) {
3221 if (is_blessed(creature_ptr)) {
3225 if (is_hero(creature_ptr)) {
3229 if (is_shero(creature_ptr)) {
3233 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3235 if (is_heavy_shoot(creature_ptr, o_ptr)) {
3236 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3240 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
3241 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
3242 pow += (10 + (creature_ptr->lev / 5));
3248 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3250 o_ptr = &creature_ptr->inventory_list[i];
3251 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
3252 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3255 bonus_to_h = o_ptr->to_h;
3257 if (creature_ptr->pclass == CLASS_NINJA) {
3258 if (o_ptr->to_h > 0)
3259 bonus_to_h = (o_ptr->to_h + 1) / 2;
3262 if (is_true_value || object_is_known(o_ptr))
3263 pow += (s16b)bonus_to_h;
3266 pow -= calc_riding_bow_penalty(creature_ptr);
3271 static s16b calc_to_damage_misc(player_type *creature_ptr)
3274 BIT_FLAGS flgs[TR_FLAG_SIZE];
3278 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3279 o_ptr = &creature_ptr->inventory_list[i];
3283 object_flags(creature_ptr, o_ptr, flgs);
3285 int bonus_to_d = o_ptr->to_d;
3286 if (creature_ptr->pclass == CLASS_NINJA) {
3287 if (o_ptr->to_d > 0)
3288 bonus_to_d = (o_ptr->to_d + 1) / 2;
3290 to_dam += (s16b)bonus_to_d;
3293 if (is_shero(creature_ptr)) {
3294 to_dam += 3 + (creature_ptr->lev / 5);
3297 if (creature_ptr->stun > 50) {
3299 } else if (creature_ptr->stun) {
3303 to_dam += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
3307 static s16b calc_to_hit_misc(player_type *creature_ptr)
3310 BIT_FLAGS flgs[TR_FLAG_SIZE];
3314 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3315 o_ptr = &creature_ptr->inventory_list[i];
3319 object_flags(creature_ptr, o_ptr, flgs);
3321 int bonus_to_h = o_ptr->to_h;
3322 if (creature_ptr->pclass == CLASS_NINJA) {
3323 if (o_ptr->to_h > 0)
3324 bonus_to_h = (o_ptr->to_h + 1) / 2;
3326 to_hit += (s16b)bonus_to_h;
3329 if (is_blessed(creature_ptr)) {
3333 if (is_hero(creature_ptr)) {
3337 if (is_shero(creature_ptr)) {
3341 if (creature_ptr->stun > 50) {
3343 } else if (creature_ptr->stun) {
3347 to_hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3348 to_hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3353 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
3355 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3358 if (creature_ptr->riding) {
3360 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3368 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
3370 (void)creature_ptr; // unused
3371 (void)slot; // unused
3376 * @brief プレイヤーの所持重量制限を計算する /
3377 * Computes current weight limit.
3380 WEIGHT calc_weight_limit(player_type *creature_ptr)
3382 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
3383 if (creature_ptr->pclass == CLASS_BERSERKER)
3389 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3390 * @param i 判定する手のID(右手:INVEN_RARM 左手:INVEN_LARM)
3391 * @return 持っているならばTRUE
3393 bool has_melee_weapon(player_type *creature_ptr, int slot)
3395 return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot]));
3399 * @brief プレイヤーの現在開いている手の状態を返す
3400 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3401 * @return 開いている手のビットフラグ
3403 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
3405 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3406 if (!creature_ptr->inventory_list[INVEN_RARM].k_idx)
3407 status |= EMPTY_HAND_RARM;
3408 if (!creature_ptr->inventory_list[INVEN_LARM].k_idx)
3409 status |= EMPTY_HAND_LARM;
3411 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS)) {
3412 if (status & EMPTY_HAND_LARM)
3413 status &= ~(EMPTY_HAND_LARM);
3414 else if (status & EMPTY_HAND_RARM)
3415 status &= ~(EMPTY_HAND_RARM);
3422 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3423 * @return ペナルティが適用されるならばTRUE。
3425 bool heavy_armor(player_type *creature_ptr)
3427 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
3430 WEIGHT monk_arm_wgt = 0;
3431 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD)
3432 monk_arm_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
3433 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD)
3434 monk_arm_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
3435 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
3436 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
3437 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
3438 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
3439 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
3441 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
3445 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
3447 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3449 void update_creature(player_type *creature_ptr)
3451 if (!creature_ptr->update)
3454 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3455 if (creature_ptr->update & (PU_AUTODESTROY)) {
3456 creature_ptr->update &= ~(PU_AUTODESTROY);
3457 autopick_delayed_alter(creature_ptr);
3460 if (creature_ptr->update & (PU_COMBINE)) {
3461 creature_ptr->update &= ~(PU_COMBINE);
3462 combine_pack(creature_ptr);
3465 if (creature_ptr->update & (PU_REORDER)) {
3466 creature_ptr->update &= ~(PU_REORDER);
3467 reorder_pack(creature_ptr);
3470 if (creature_ptr->update & (PU_BONUS)) {
3471 creature_ptr->update &= ~(PU_BONUS);
3472 calc_alignment(creature_ptr);
3473 calc_bonuses(creature_ptr);
3476 if (creature_ptr->update & (PU_TORCH)) {
3477 creature_ptr->update &= ~(PU_TORCH);
3478 calc_lite_radius(creature_ptr);
3481 if (creature_ptr->update & (PU_HP)) {
3482 creature_ptr->update &= ~(PU_HP);
3483 calc_hitpoints(creature_ptr);
3486 if (creature_ptr->update & (PU_MANA)) {
3487 creature_ptr->update &= ~(PU_MANA);
3488 calc_mana(creature_ptr);
3491 if (creature_ptr->update & (PU_SPELLS)) {
3492 creature_ptr->update &= ~(PU_SPELLS);
3493 calc_spells(creature_ptr);
3496 if (!current_world_ptr->character_generated)
3498 if (current_world_ptr->character_icky)
3500 if (creature_ptr->update & (PU_UN_LITE)) {
3501 creature_ptr->update &= ~(PU_UN_LITE);
3502 forget_lite(floor_ptr);
3505 if (creature_ptr->update & (PU_UN_VIEW)) {
3506 creature_ptr->update &= ~(PU_UN_VIEW);
3507 forget_view(floor_ptr);
3510 if (creature_ptr->update & (PU_VIEW)) {
3511 creature_ptr->update &= ~(PU_VIEW);
3512 update_view(creature_ptr);
3515 if (creature_ptr->update & (PU_LITE)) {
3516 creature_ptr->update &= ~(PU_LITE);
3517 update_lite(creature_ptr);
3520 if (creature_ptr->update & (PU_FLOW)) {
3521 creature_ptr->update &= ~(PU_FLOW);
3522 update_flow(creature_ptr);
3525 if (creature_ptr->update & (PU_DISTANCE)) {
3526 creature_ptr->update &= ~(PU_DISTANCE);
3528 update_monsters(creature_ptr, TRUE);
3531 if (creature_ptr->update & (PU_MON_LITE)) {
3532 creature_ptr->update &= ~(PU_MON_LITE);
3533 update_mon_lite(creature_ptr);
3536 if (creature_ptr->update & (PU_DELAY_VIS)) {
3537 creature_ptr->update &= ~(PU_DELAY_VIS);
3538 delayed_visual_update(creature_ptr);
3541 if (creature_ptr->update & (PU_MONSTERS)) {
3542 creature_ptr->update &= ~(PU_MONSTERS);
3543 update_monsters(creature_ptr, FALSE);
3548 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
3549 * @return 魔道書を一冊も持っていないならTRUEを返す
3551 bool player_has_no_spellbooks(player_type *creature_ptr)
3554 for (int i = 0; i < INVEN_PACK; i++) {
3555 o_ptr = &creature_ptr->inventory_list[i];
3556 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3560 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3561 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
3562 o_ptr = &floor_ptr->o_list[i];
3563 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3570 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost) { creature_ptr->energy_use = (ENERGY)need_cost; }
3572 void free_turn(player_type *creature_ptr) { creature_ptr->energy_use = 0; }
3575 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
3578 * @return 配置に成功したらTRUE
3580 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
3582 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
3585 /* Save player location */
3586 creature_ptr->y = y;
3587 creature_ptr->x = x;
3592 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
3595 void wreck_the_pattern(player_type *creature_ptr)
3597 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3598 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
3599 if (pattern_type == PATTERN_TILE_WRECKED)
3602 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
3603 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
3605 if (!is_invuln(creature_ptr))
3606 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
3608 int to_ruin = randint1(45) + 35;
3611 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
3613 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
3614 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
3618 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
3622 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
3623 * Advance experience levels and print experience
3626 void check_experience(player_type *creature_ptr)
3628 if (creature_ptr->exp < 0)
3629 creature_ptr->exp = 0;
3630 if (creature_ptr->max_exp < 0)
3631 creature_ptr->max_exp = 0;
3632 if (creature_ptr->max_max_exp < 0)
3633 creature_ptr->max_max_exp = 0;
3635 if (creature_ptr->exp > PY_MAX_EXP)
3636 creature_ptr->exp = PY_MAX_EXP;
3637 if (creature_ptr->max_exp > PY_MAX_EXP)
3638 creature_ptr->max_exp = PY_MAX_EXP;
3639 if (creature_ptr->max_max_exp > PY_MAX_EXP)
3640 creature_ptr->max_max_exp = PY_MAX_EXP;
3642 if (creature_ptr->exp > creature_ptr->max_exp)
3643 creature_ptr->max_exp = creature_ptr->exp;
3644 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
3645 creature_ptr->max_max_exp = creature_ptr->max_exp;
3647 creature_ptr->redraw |= (PR_EXP);
3648 handle_stuff(creature_ptr);
3650 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
3651 PLAYER_LEVEL old_lev = creature_ptr->lev;
3652 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
3653 creature_ptr->lev--;
3654 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3655 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
3656 creature_ptr->window |= (PW_PLAYER);
3657 handle_stuff(creature_ptr);
3660 bool level_reward = FALSE;
3661 bool level_mutation = FALSE;
3662 bool level_inc_stat = FALSE;
3663 while ((creature_ptr->lev < PY_MAX_LEVEL)
3664 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
3665 creature_ptr->lev++;
3666 if (creature_ptr->lev > creature_ptr->max_plv) {
3667 creature_ptr->max_plv = creature_ptr->lev;
3669 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || (creature_ptr->muta2 & MUT2_CHAOS_GIFT)) {
3670 level_reward = TRUE;
3672 if (creature_ptr->prace == RACE_BEASTMAN) {
3674 level_mutation = TRUE;
3676 level_inc_stat = TRUE;
3678 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
3682 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
3683 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3684 creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
3685 creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
3686 creature_ptr->level_up_message = TRUE;
3687 handle_stuff(creature_ptr);
3689 creature_ptr->level_up_message = FALSE;
3690 if (level_inc_stat) {
3691 if (!(creature_ptr->max_plv % 10)) {
3698 cnv_stat(creature_ptr->stat_max[0], tmp);
3699 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
3700 cnv_stat(creature_ptr->stat_max[1], tmp);
3701 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
3702 cnv_stat(creature_ptr->stat_max[2], tmp);
3703 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
3704 cnv_stat(creature_ptr->stat_max[3], tmp);
3705 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
3706 cnv_stat(creature_ptr->stat_max[4], tmp);
3707 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
3708 cnv_stat(creature_ptr->stat_max[5], tmp);
3709 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
3712 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
3716 if ((choice >= 'a') && (choice <= 'f'))
3719 for (n = 0; n < A_MAX; n++)
3720 if (n != choice - 'a')
3722 if (get_check(_("よろしいですか?", "Are you sure? ")))
3725 do_inc_stat(creature_ptr, choice - 'a');
3727 } else if (!(creature_ptr->max_plv % 2))
3728 do_inc_stat(creature_ptr, randint0(6));
3731 if (level_mutation) {
3732 msg_print(_("あなたは変わった気がする...", "You feel different..."));
3733 (void)gain_mutation(creature_ptr, 0);
3734 level_mutation = FALSE;
3738 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
3742 gain_level_reward(creature_ptr, 0);
3743 level_reward = FALSE;
3746 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3747 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
3748 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
3749 handle_stuff(creature_ptr);
3752 if (old_lev != creature_ptr->lev)
3753 autopick_load_pref(creature_ptr, FALSE);
3757 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
3759 * @param out_val 出力先文字列ポインタ
3762 void cnv_stat(int val, char *out_val)
3765 sprintf(out_val, " %2d", val);
3769 int bonus = (val - 18);
3771 sprintf(out_val, "18/%3s", "***");
3772 } else if (bonus >= 100) {
3773 sprintf(out_val, "18/%03d", bonus);
3775 sprintf(out_val, " 18/%02d", bonus);
3780 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
3781 * Modify a stat value by a "modifier", return new value
3783 * @param amount 加減算値
3787 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
3788 * Or even: 18/13, 18/23, 18/33, ..., 18/220
3789 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
3790 * Or even: 18/13, 18/03, 18, 17, ..., 3
3793 s16b modify_stat_value(int value, int amount)
3796 for (int i = 0; i < amount; i++) {
3802 } else if (amount < 0) {
3803 for (int i = 0; i < (0 - amount); i++) {
3804 if (value >= 18 + 10)
3806 else if (value > 18)
3818 * Hack -- Calculates the total number of points earned -JWT-
3822 long calc_score(player_type *creature_ptr)
3824 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
3837 if (ironman_small_levels)
3839 if (ironman_empty_levels)
3845 if (ironman_nightmare)
3852 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
3853 if (max_dlv[i] > max_dl)
3854 max_dl = max_dlv[i];
3856 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
3857 u32b point_h = point_l / 0x10000L;
3858 point_l = point_l % 0x10000L;
3861 point_h += point_l / 0x10000L;
3862 point_l %= 0x10000L;
3864 point_l += ((point_h % 100) << 16);
3868 u32b point = (point_h << 16) + (point_l);
3869 if (creature_ptr->arena_number >= 0)
3870 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
3872 if (ironman_downward)
3874 if (creature_ptr->pclass == CLASS_BERSERKER) {
3875 if (creature_ptr->prace == RACE_SPECTRE)
3879 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
3881 if (current_world_ptr->total_winner)
3886 point = (0 - point);
3892 * @param creature_ptr プレーヤーへの参照ポインタ
3893 * @return 祝福状態ならばTRUE
3895 bool is_blessed(player_type *creature_ptr)
3897 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
3900 bool is_tim_esp(player_type *creature_ptr)
3902 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3905 bool is_tim_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
3907 bool is_time_limit_esp(player_type *creature_ptr)
3909 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3912 bool is_time_limit_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
3914 bool can_two_hands_wielding(player_type *creature_ptr) { return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS); }
3917 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
3920 void stop_singing(player_type *creature_ptr)
3922 if (creature_ptr->pclass != CLASS_BARD)
3925 /* Are there interupted song? */
3926 if (INTERUPTING_SONG_EFFECT(creature_ptr)) {
3927 /* Forget interupted song */
3928 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3932 /* The player is singing? */
3933 if (!SINGING_SONG_EFFECT(creature_ptr))
3936 /* Hack -- if called from set_action(), avoid recursive loop */
3937 if (creature_ptr->action == ACTION_SING)
3938 set_action(creature_ptr, ACTION_NONE);
3940 /* Message text of each song or etc. */
3941 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
3943 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3944 SINGING_SONG_ID(creature_ptr) = 0;
3945 creature_ptr->update |= (PU_BONUS);
3946 creature_ptr->redraw |= (PR_STATUS);
3950 * @brief 口を使う継続的な処理を中断する
3951 * @param caster_ptr プレーヤーへの参照ポインタ
3954 void stop_mouth(player_type *caster_ptr)
3956 if (music_singing_any(caster_ptr))
3957 stop_singing(caster_ptr);
3958 if (hex_spelling_any(caster_ptr))
3959 stop_hex_spell_all(caster_ptr);
3963 * @brief ペットの維持コスト計算
3966 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
3969 bool has_a_unique = FALSE;
3970 DEPTH total_friend_levels = 0;
3974 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
3975 monster_type *m_ptr;
3976 monster_race *r_ptr;
3978 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
3979 if (!monster_is_valid(m_ptr))
3981 r_ptr = &r_info[m_ptr->r_idx];
3983 if (is_pet(m_ptr)) {
3985 if (r_ptr->flags1 & RF1_UNIQUE) {
3986 if (creature_ptr->pclass == CLASS_CAVALRY) {
3987 if (creature_ptr->riding == m_idx)
3988 total_friend_levels += (r_ptr->level + 5) * 2;
3989 else if (!has_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
3990 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
3992 total_friend_levels += (r_ptr->level + 5) * 10;
3993 has_a_unique = TRUE;
3995 total_friend_levels += (r_ptr->level + 5) * 10;
3997 total_friend_levels += r_ptr->level;
4001 if (total_friends) {
4003 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
4004 if (upkeep_factor < 0)
4006 if (upkeep_factor > 1000)
4007 upkeep_factor = 1000;
4008 return upkeep_factor;
4013 bool music_singing(player_type *caster_ptr, int music_songs) { return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs); }
4015 bool is_fast(player_type *creature_ptr) { return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO); }
4017 bool is_invuln(player_type *creature_ptr) { return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN); }
4019 bool is_hero(player_type *creature_ptr) { return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO); }
4021 bool is_shero(player_type *creature_ptr) { return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER; }
4023 bool is_echizen(player_type *creature_ptr)
4025 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
4028 int calc_weapon_weight_limit(player_type *creature_ptr)
4030 int weight = adj_str_hold[creature_ptr->stat_ind[A_STR]];
4032 if (has_two_handed_weapons(creature_ptr))
4038 static int get_default_hand(player_type *creature_ptr)
4040 int default_hand = 0;
4042 if (has_melee_weapon(creature_ptr, INVEN_LARM)) {
4043 if (!has_right_hand_weapon(creature_ptr))
4047 if (can_two_hands_wielding(creature_ptr)) {
4048 if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
4049 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
4050 } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
4051 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
4057 return default_hand;