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->sh_fire = has_sh_fire(creature_ptr);
376 creature_ptr->sh_elec = has_sh_elec(creature_ptr);
377 creature_ptr->sh_cold = has_sh_cold(creature_ptr);
378 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
379 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
380 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
381 creature_ptr->see_inv = has_see_inv(creature_ptr);
382 creature_ptr->free_act = has_free_act(creature_ptr);
383 creature_ptr->sustain_str = has_sustain_str(creature_ptr);
384 creature_ptr->sustain_int = has_sustain_int(creature_ptr);
385 creature_ptr->sustain_wis = has_sustain_wis(creature_ptr);
386 creature_ptr->sustain_dex = has_sustain_dex(creature_ptr);
387 creature_ptr->sustain_con = has_sustain_con(creature_ptr);
388 creature_ptr->sustain_chr = has_sustain_chr(creature_ptr);
389 creature_ptr->levitation = has_levitation(creature_ptr);
390 has_can_swim(creature_ptr);
391 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
392 creature_ptr->regenerate = has_regenerate(creature_ptr);
393 has_curses(creature_ptr);
394 creature_ptr->impact = has_impact(creature_ptr);
395 has_extra_blow(creature_ptr);
397 creature_ptr->lite = has_lite(creature_ptr);
399 if (creature_ptr->special_defense & KAMAE_MASK) {
400 if (!(empty_hands_status & EMPTY_HAND_RARM)) {
401 set_action(creature_ptr, ACTION_NONE);
405 creature_ptr->stat_add[A_STR] = calc_strength_addition(creature_ptr);
406 creature_ptr->stat_add[A_INT] = calc_intelligence_addition(creature_ptr);
407 creature_ptr->stat_add[A_WIS] = calc_wisdom_addition(creature_ptr);
408 creature_ptr->stat_add[A_DEX] = calc_dexterity_addition(creature_ptr);
409 creature_ptr->stat_add[A_CON] = calc_constitution_addition(creature_ptr);
410 creature_ptr->stat_add[A_CHR] = calc_charisma_addition(creature_ptr);
411 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
412 creature_ptr->ac = calc_base_ac(creature_ptr);
413 creature_ptr->to_a = calc_to_ac(creature_ptr, TRUE);
414 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
415 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, FALSE);
417 for (int i = 0; i < A_MAX; i++) {
418 calc_top_status(creature_ptr, i);
419 calc_use_status(creature_ptr, i);
420 calc_ind_status(creature_ptr, i);
423 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
425 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
426 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
427 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
431 for (int i = 0; i < 2; i++) {
432 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
433 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
434 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
435 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_RARM + i);
436 creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_RARM + i);
439 creature_ptr->pspeed = calc_speed(creature_ptr);
440 creature_ptr->see_infra = calc_intra_vision(creature_ptr);
441 creature_ptr->skill_stl = calc_stealth(creature_ptr);
442 creature_ptr->skill_dis = calc_disarming(creature_ptr);
443 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
444 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
445 creature_ptr->skill_srh = calc_search(creature_ptr);
446 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
447 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
448 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
449 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
450 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, TRUE);
451 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, TRUE);
452 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, FALSE);
453 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, FALSE);
454 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_RARM, TRUE);
455 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_LARM, TRUE);
456 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_RARM, FALSE);
457 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_LARM, FALSE);
458 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, TRUE);
459 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, FALSE);
460 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
461 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
462 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
464 if (old_mighty_throw != creature_ptr->mighty_throw) {
465 creature_ptr->window |= PW_INVEN;
468 if (creature_ptr->telepathy != old_telepathy) {
469 creature_ptr->update |= (PU_MONSTERS);
472 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
473 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
474 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
475 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
476 creature_ptr->update |= (PU_MONSTERS);
479 if (creature_ptr->see_inv != old_see_inv) {
480 creature_ptr->update |= (PU_MONSTERS);
483 if (creature_ptr->pspeed != old_speed) {
484 creature_ptr->redraw |= (PR_SPEED);
487 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
488 creature_ptr->redraw |= (PR_ARMOR);
489 creature_ptr->window |= (PW_PLAYER);
492 if (current_world_ptr->character_xtra)
495 put_equipment_warning(creature_ptr);
498 static void calc_alignment(player_type *creature_ptr)
500 creature_ptr->align = 0;
501 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
502 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
505 m_ptr = &floor_ptr->m_list[m_idx];
506 if (!monster_is_valid(m_ptr))
508 r_ptr = &r_info[m_ptr->r_idx];
513 if (r_ptr->flags3 & RF3_GOOD)
514 creature_ptr->align += r_ptr->level;
515 if (r_ptr->flags3 & RF3_EVIL)
516 creature_ptr->align -= r_ptr->level;
519 if (creature_ptr->mimic_form) {
520 switch (creature_ptr->mimic_form) {
522 creature_ptr->align -= 200;
524 case MIMIC_DEMON_LORD:
525 creature_ptr->align -= 200;
529 switch (creature_ptr->prace) {
531 creature_ptr->align += 200;
534 creature_ptr->align -= 200;
539 for (int i = 0; i < 2; i++) {
540 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i))
542 if (creature_ptr->inventory_list[INVEN_RARM + i].name1 != ART_IRON_BALL)
544 creature_ptr->align -= 1000;
549 for (int i = 0; i < 8; i++) {
550 switch (creature_ptr->vir_types[i]) {
552 creature_ptr->align += creature_ptr->virtues[i] * 2;
561 creature_ptr->align -= creature_ptr->virtues[i];
564 creature_ptr->align += creature_ptr->virtues[i];
569 for (int i = 0; i < j; i++) {
570 if (creature_ptr->align > 0) {
571 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
572 if (creature_ptr->align < 0)
573 creature_ptr->align = 0;
574 } else if (creature_ptr->align < 0) {
575 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
576 if (creature_ptr->align > 0)
577 creature_ptr->align = 0;
583 * @brief プレイヤーの最大HPを計算する /
584 * Calculate the players (maximal) hit points
585 * Adjust current hitpoints if necessary
589 static void calc_hitpoints(player_type *creature_ptr)
591 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
592 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
595 if (creature_ptr->mimic_form) {
596 if (creature_ptr->pclass == CLASS_SORCERER)
597 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
599 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
600 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
603 if (creature_ptr->pclass == CLASS_SORCERER) {
604 if (creature_ptr->lev < 30)
605 mhp = (mhp * (45 + creature_ptr->lev) / 100);
607 mhp = (mhp * 75 / 100);
608 bonus = (bonus * 65 / 100);
613 if (creature_ptr->pclass == CLASS_BERSERKER) {
614 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
617 if (mhp < creature_ptr->lev + 1)
618 mhp = creature_ptr->lev + 1;
619 if (is_hero(creature_ptr))
621 if (is_shero(creature_ptr))
623 if (creature_ptr->tsuyoshi)
625 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
627 if (hex_spelling(creature_ptr, HEX_BUILDING))
629 if (creature_ptr->mhp == mhp)
632 if (creature_ptr->chp >= mhp) {
633 creature_ptr->chp = mhp;
634 creature_ptr->chp_frac = 0;
638 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
639 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
642 creature_ptr->mhp = mhp;
644 creature_ptr->redraw |= PR_HP;
645 creature_ptr->window |= PW_PLAYER;
649 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
650 * Calculate number of spells player should have, and forget,
651 * or remember, spells until that number is properly reflected.
654 * Note that this function induces various "status" messages,
655 * which must be bypasses until the character is created.
657 static void calc_spells(player_type *creature_ptr)
659 if (!mp_ptr->spell_book)
661 if (!current_world_ptr->character_generated)
663 if (current_world_ptr->character_xtra)
665 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
666 creature_ptr->new_spells = 0;
670 concptr p = spell_category_name(mp_ptr->spell_book);
671 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
675 int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
677 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
681 if (creature_ptr->pclass == CLASS_SAMURAI) {
683 } else if (creature_ptr->realm2 == REALM_NONE) {
684 num_allowed = (num_allowed + 1) / 2;
685 if (num_allowed > (32 + bonus))
686 num_allowed = 32 + bonus;
687 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
688 if (num_allowed > (96 + bonus))
689 num_allowed = 96 + bonus;
691 if (num_allowed > (80 + bonus))
692 num_allowed = 80 + bonus;
695 int num_boukyaku = 0;
696 for (int j = 0; j < 64; j++) {
697 if ((j < 32) ? (creature_ptr->spell_forgotten1 & (1L << j)) : (creature_ptr->spell_forgotten2 & (1L << (j - 32)))) {
702 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
703 for (int i = 63; i >= 0; i--) {
704 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
707 int j = creature_ptr->spell_order[i];
711 const magic_type *s_ptr;
712 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
714 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
716 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
718 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
720 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
722 if (s_ptr->slevel <= creature_ptr->lev)
725 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_learned1 & (1L << j)) : (creature_ptr->spell_learned2 & (1L << (j - 32)));
726 if (!is_spell_learned)
731 creature_ptr->spell_forgotten1 |= (1L << j);
732 which = creature_ptr->realm1;
734 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
735 which = creature_ptr->realm2;
739 creature_ptr->spell_learned1 &= ~(1L << j);
740 which = creature_ptr->realm1;
742 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
743 which = creature_ptr->realm2;
747 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
749 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
751 creature_ptr->new_spells++;
754 /* Forget spells if we know too many spells */
755 for (int i = 63; i >= 0; i--) {
756 if (creature_ptr->new_spells >= 0)
758 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
761 int j = creature_ptr->spell_order[i];
765 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_learned1 & (1L << j)) : (creature_ptr->spell_learned2 & (1L << (j - 32)));
766 if (!is_spell_learned)
771 creature_ptr->spell_forgotten1 |= (1L << j);
772 which = creature_ptr->realm1;
774 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
775 which = creature_ptr->realm2;
779 creature_ptr->spell_learned1 &= ~(1L << j);
780 which = creature_ptr->realm1;
782 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
783 which = creature_ptr->realm2;
787 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
789 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
791 creature_ptr->new_spells++;
794 /* Check for spells to remember */
795 for (int i = 0; i < 64; i++) {
796 if (creature_ptr->new_spells <= 0)
798 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
800 int j = creature_ptr->spell_order[i];
804 const magic_type *s_ptr;
805 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
807 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
809 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
811 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
813 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
815 if (s_ptr->slevel > creature_ptr->lev)
818 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_forgotten1 & (1L << j)) : (creature_ptr->spell_forgotten2 & (1L << (j - 32)));
819 if (!is_spell_learned)
824 creature_ptr->spell_forgotten1 &= ~(1L << j);
825 which = creature_ptr->realm1;
827 creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
828 which = creature_ptr->realm2;
832 creature_ptr->spell_learned1 |= (1L << j);
833 which = creature_ptr->realm1;
835 creature_ptr->spell_learned2 |= (1L << (j - 32));
836 which = creature_ptr->realm2;
840 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
842 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
844 creature_ptr->new_spells--;
847 if (creature_ptr->realm2 == REALM_NONE) {
849 for (int j = 0; j < 32; j++) {
850 const magic_type *s_ptr;
851 if (!is_magic(creature_ptr->realm1))
852 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
854 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
856 if (s_ptr->slevel > creature_ptr->lev)
859 if (creature_ptr->spell_learned1 & (1L << j)) {
868 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
869 creature_ptr->new_spells = (s16b)k;
873 if (creature_ptr->new_spells < 0)
874 creature_ptr->new_spells = 0;
876 if (creature_ptr->old_spells == creature_ptr->new_spells)
879 if (creature_ptr->new_spells) {
881 if (creature_ptr->new_spells < 10) {
882 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
884 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
887 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
891 creature_ptr->old_spells = creature_ptr->new_spells;
892 creature_ptr->redraw |= PR_STUDY;
893 creature_ptr->window |= PW_OBJECT;
897 * @brief プレイヤーの最大MPを計算する /
898 * Calculate maximum mana. You do not need to know any spells.
899 * Note that mana is lowered by heavy (or inappropriate) armor.
902 * This function induces status messages.
904 static void calc_mana(player_type *creature_ptr)
906 if (!mp_ptr->spell_book)
910 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)) {
911 levels = creature_ptr->lev;
913 if (mp_ptr->spell_first > creature_ptr->lev) {
914 creature_ptr->msp = 0;
915 creature_ptr->redraw |= (PR_MANA);
919 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
923 if (creature_ptr->pclass == CLASS_SAMURAI) {
924 msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
926 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
928 msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
932 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
933 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
935 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
937 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
938 msp += msp * (25 + creature_ptr->lev) / 100;
941 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA) {
942 BIT_FLAGS flgs[TR_FLAG_SIZE];
943 creature_ptr->cumber_glove = FALSE;
945 o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
946 object_flags(creature_ptr, o_ptr, flgs);
947 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
948 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
949 creature_ptr->cumber_glove = TRUE;
954 creature_ptr->cumber_armor = FALSE;
957 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD)
958 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
959 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD)
960 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
961 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
962 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
963 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
964 cur_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
965 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
967 switch (creature_ptr->pclass) {
969 case CLASS_HIGH_MAGE:
970 case CLASS_BLUE_MAGE:
972 case CLASS_FORCETRAINER:
973 case CLASS_SORCERER: {
974 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
975 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
976 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
977 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
982 case CLASS_TOURIST: {
983 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
984 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight * 2 / 3;
985 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
986 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
989 case CLASS_MINDCRAFTER:
990 case CLASS_BEASTMASTER:
991 case CLASS_MIRROR_MASTER: {
992 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
993 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 2;
994 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
995 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 2;
1000 case CLASS_RED_MAGE:
1001 case CLASS_WARRIOR_MAGE: {
1002 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
1003 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 3;
1004 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
1005 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 3;
1009 case CLASS_CHAOS_WARRIOR: {
1010 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
1011 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 5;
1012 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
1013 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 5;
1021 int max_wgt = mp_ptr->spell_weight;
1022 if ((cur_wgt - max_wgt) > 0) {
1023 creature_ptr->cumber_armor = TRUE;
1024 switch (creature_ptr->pclass) {
1026 case CLASS_HIGH_MAGE:
1027 case CLASS_BLUE_MAGE: {
1028 msp -= msp * (cur_wgt - max_wgt) / 600;
1032 case CLASS_MINDCRAFTER:
1033 case CLASS_BEASTMASTER:
1035 case CLASS_FORCETRAINER:
1037 case CLASS_MIRROR_MASTER: {
1038 msp -= msp * (cur_wgt - max_wgt) / 800;
1041 case CLASS_SORCERER: {
1042 msp -= msp * (cur_wgt - max_wgt) / 900;
1048 case CLASS_RED_MAGE: {
1049 msp -= msp * (cur_wgt - max_wgt) / 1000;
1053 case CLASS_CHAOS_WARRIOR:
1054 case CLASS_WARRIOR_MAGE: {
1055 msp -= msp * (cur_wgt - max_wgt) / 1200;
1058 case CLASS_SAMURAI: {
1059 creature_ptr->cumber_armor = FALSE;
1063 msp -= msp * (cur_wgt - max_wgt) / 800;
1072 if (creature_ptr->msp != msp) {
1073 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
1074 creature_ptr->csp = msp;
1075 creature_ptr->csp_frac = 0;
1079 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
1080 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
1083 creature_ptr->msp = msp;
1084 creature_ptr->redraw |= (PR_MANA);
1085 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
1088 if (current_world_ptr->character_xtra)
1091 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
1092 if (creature_ptr->cumber_glove)
1093 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
1095 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
1097 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
1100 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
1103 if (creature_ptr->cumber_armor)
1104 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
1106 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
1108 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
1112 * @brief 装備中の射撃武器の威力倍率を返す /
1113 * calcurate the fire rate of target object
1114 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
1115 * @return 射撃倍率の値(100で1.00倍)
1117 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
1119 int extra_shots = 0;
1120 BIT_FLAGS flgs[TR_FLAG_SIZE];
1122 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1124 q_ptr = &creature_ptr->inventory_list[i];
1131 object_flags(creature_ptr, q_ptr, flgs);
1132 if (has_flag(flgs, TR_XTRA_SHOTS))
1136 object_flags(creature_ptr, o_ptr, flgs);
1137 if (has_flag(flgs, TR_XTRA_SHOTS))
1141 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1145 num += (extra_shots * 100);
1147 tval_type tval_ammo = bow_tval_ammo(o_ptr);
1148 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1149 num += (creature_ptr->lev * 4);
1152 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1153 num += (creature_ptr->lev * 3);
1156 if (creature_ptr->pclass == CLASS_ARCHER) {
1157 if (tval_ammo == TV_ARROW)
1158 num += ((creature_ptr->lev * 5) + 50);
1159 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1160 num += (creature_ptr->lev * 4);
1163 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1164 num += (creature_ptr->lev * 2);
1167 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1168 num += (creature_ptr->lev * 4);
1176 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1180 * * 変異MUT3_INFRAVISによる加算(+3)
1181 * * 魔法効果tim_infraによる加算(+3)
1182 * * 装備がTR_INFRAフラグ持ちなら加算(+pval*1)
1184 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr)
1186 ACTION_SKILL_POWER pow;
1187 const player_race *tmp_rp_ptr;
1189 if (creature_ptr->mimic_form)
1190 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1192 tmp_rp_ptr = &race_info[creature_ptr->prace];
1194 pow = tmp_rp_ptr->infra;
1196 if (creature_ptr->muta3 & MUT3_INFRAVIS) {
1200 if (creature_ptr->tim_infra) {
1204 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1206 BIT_FLAGS flgs[TR_FLAG_SIZE];
1207 o_ptr = &creature_ptr->inventory_list[i];
1210 object_flags(creature_ptr, o_ptr, flgs);
1211 if (has_flag(flgs, TR_INFRA))
1220 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1226 * * 装備による修正(TR_STEALTHがあれば+pval*1)
1227 * * 変異MUT3_XTRA_NOISで減算(-3)
1228 * * 変異MUT3_MOTIONで加算(+1)
1229 * * 呪術を唱えていると減算(-(詠唱数+1))
1230 * * セクシーギャルでない影フェアリーがTRC_AGGRAVATE持ちの時、別処理でTRC_AGGRAVATEを無効にする代わりに減算(-3か3未満なら(現在値+2)/2)
1232 * * 忍者がheavy_armorならば減算(-レベル/10)
1233 * * 忍者がheavy_armorでなく適正な武器を持っていれば加算(+レベル/10)
1237 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr)
1239 ACTION_SKILL_POWER pow;
1240 const player_race *tmp_rp_ptr;
1242 if (creature_ptr->mimic_form)
1243 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1245 tmp_rp_ptr = &race_info[creature_ptr->prace];
1246 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1247 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1249 pow = 1 + tmp_rp_ptr->r_stl + c_ptr->c_stl + a_ptr->a_stl;
1250 pow += (c_ptr->x_stl * creature_ptr->lev / 10);
1252 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1254 BIT_FLAGS flgs[TR_FLAG_SIZE];
1255 o_ptr = &creature_ptr->inventory_list[i];
1258 object_flags(creature_ptr, o_ptr, flgs);
1259 if (has_flag(flgs, TR_STEALTH))
1263 if (creature_ptr->muta3 & MUT3_XTRA_NOIS) {
1266 if (creature_ptr->muta3 & MUT3_MOTION) {
1269 if (creature_ptr->realm1 == REALM_HEX) {
1270 if (hex_spelling_any(creature_ptr))
1271 pow -= (1 + casting_hex_num(creature_ptr));
1273 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
1274 pow = MIN(pow - 3, (pow + 2) / 2);
1277 if (is_shero(creature_ptr)) {
1281 if (creature_ptr->pclass == CLASS_NINJA && heavy_armor(creature_ptr)) {
1282 pow -= (creature_ptr->lev) / 10;
1283 } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
1284 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
1285 pow += (creature_ptr->lev) / 10;
1288 if (is_time_limit_stealth(creature_ptr))
1301 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1305 * * 職業と性格とレベルによる追加加算
1306 * * 器用さに応じたadj_dex_disテーブルによる加算
1307 * * 知力に応じたadj_int_disテーブルによる加算
1309 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1311 ACTION_SKILL_POWER pow;
1312 const player_race *tmp_rp_ptr;
1314 if (creature_ptr->mimic_form)
1315 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1317 tmp_rp_ptr = &race_info[creature_ptr->prace];
1318 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1319 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1321 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1322 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1323 pow += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
1324 pow += adj_int_dis[creature_ptr->stat_ind[A_INT]];
1330 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1334 * * 職業と性格とレベルによる追加加算
1335 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1336 * * 知力に応じたadj_int_devテーブルによる加算
1339 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1341 ACTION_SKILL_POWER pow;
1342 const player_race *tmp_rp_ptr;
1344 if (creature_ptr->mimic_form)
1345 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1347 tmp_rp_ptr = &race_info[creature_ptr->prace];
1348 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1349 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1351 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1352 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1354 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1356 BIT_FLAGS flgs[TR_FLAG_SIZE];
1357 o_ptr = &creature_ptr->inventory_list[i];
1360 object_flags(creature_ptr, o_ptr, flgs);
1361 if (has_flag(flgs, TR_MAGIC_MASTERY))
1362 pow += 8 * o_ptr->pval;
1365 pow += adj_int_dev[creature_ptr->stat_ind[A_INT]];
1367 if (is_shero(creature_ptr)) {
1375 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1379 * * 職業と性格とレベルによる追加加算
1380 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1381 * * 賢さによるadj_wis_savテーブル加算
1383 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1384 * * クターのつぶれ状態なら(10に上書き)
1385 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1386 * * 呪いのdown_savingがかかっているなら半減
1388 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1390 ACTION_SKILL_POWER pow;
1391 const player_race *tmp_rp_ptr;
1393 if (creature_ptr->mimic_form)
1394 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1396 tmp_rp_ptr = &race_info[creature_ptr->prace];
1397 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1398 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1400 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1401 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1403 if (creature_ptr->muta3 & MUT3_MAGIC_RES)
1404 pow += (15 + (creature_ptr->lev / 5));
1406 pow += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
1408 if (is_shero(creature_ptr))
1411 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1412 pow = 90 + creature_ptr->lev;
1414 if (creature_ptr->tsubureru)
1417 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1418 pow = 95 + creature_ptr->lev;
1420 if (creature_ptr->down_saving)
1428 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1433 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1435 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1437 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1439 ACTION_SKILL_POWER pow;
1440 const player_race *tmp_rp_ptr;
1442 if (creature_ptr->mimic_form)
1443 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1445 tmp_rp_ptr = &race_info[creature_ptr->prace];
1446 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1447 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1449 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1450 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1452 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1454 BIT_FLAGS flgs[TR_FLAG_SIZE];
1455 o_ptr = &creature_ptr->inventory_list[i];
1458 object_flags(creature_ptr, o_ptr, flgs);
1459 if (has_flag(flgs, TR_SEARCH))
1460 pow += (o_ptr->pval * 5);
1463 if (creature_ptr->muta3 & MUT3_XTRA_EYES) {
1467 if (is_shero(creature_ptr)) {
1476 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1481 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1483 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1485 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1487 ACTION_SKILL_POWER pow;
1488 const player_race *tmp_rp_ptr;
1490 if (creature_ptr->mimic_form)
1491 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1493 tmp_rp_ptr = &race_info[creature_ptr->prace];
1494 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1495 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1497 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1498 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1500 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1502 BIT_FLAGS flgs[TR_FLAG_SIZE];
1503 o_ptr = &creature_ptr->inventory_list[i];
1506 object_flags(creature_ptr, o_ptr, flgs);
1507 if (has_flag(flgs, TR_SEARCH))
1508 pow += (o_ptr->pval * 5);
1511 if (is_shero(creature_ptr)) {
1515 if (creature_ptr->muta3 & MUT3_XTRA_EYES) {
1524 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1527 * * 種族/職業/性格による加算とレベルによる追加加算
1529 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1531 ACTION_SKILL_POWER pow;
1532 const player_race *tmp_rp_ptr;
1533 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1534 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1536 if (creature_ptr->mimic_form)
1537 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1539 tmp_rp_ptr = &race_info[creature_ptr->prace];
1541 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1542 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1548 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1551 * * 種族/職業/性格による加算とレベルによる追加加算
1553 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1555 ACTION_SKILL_POWER pow;
1556 const player_race *tmp_rp_ptr;
1557 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1558 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1560 if (creature_ptr->mimic_form)
1561 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1563 tmp_rp_ptr = &race_info[creature_ptr->prace];
1565 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1566 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1572 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1575 * * 種族/職業/性格による加算とレベルによる追加加算
1578 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1580 ACTION_SKILL_POWER pow;
1581 const player_race *tmp_rp_ptr;
1582 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1583 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1585 if (creature_ptr->mimic_form)
1586 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1588 tmp_rp_ptr = &race_info[creature_ptr->prace];
1590 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1591 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1593 if (is_shero(creature_ptr)) {
1602 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1613 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1616 BIT_FLAGS flgs[TR_FLAG_SIZE];
1618 ACTION_SKILL_POWER pow;
1622 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_RARM].k_idx) {
1623 pow += creature_ptr->lev * 10;
1626 if (is_shero(creature_ptr))
1629 pow += adj_str_dig[creature_ptr->stat_ind[A_STR]];
1631 if (creature_ptr->pclass == CLASS_BERSERKER)
1632 pow += (100 + creature_ptr->lev * 8);
1634 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1635 o_ptr = &creature_ptr->inventory_list[i];
1638 object_flags(creature_ptr, o_ptr, flgs);
1639 if (has_flag(flgs, TR_TUNNEL))
1640 pow += (o_ptr->pval * 20);
1643 for (int i = 0; i < 2; i++) {
1644 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1645 if (has_melee_weapon(creature_ptr, INVEN_RARM + i) && !creature_ptr->heavy_wield[i]) {
1646 pow += (o_ptr->weight / 10);
1650 if (is_shero(creature_ptr)) {
1660 static bool is_martial_arts_mode(player_type *creature_ptr)
1662 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1663 && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM) && !has_left_hand_weapon(creature_ptr);
1666 static s16b calc_num_blow(player_type *creature_ptr, int i)
1669 BIT_FLAGS flgs[TR_FLAG_SIZE];
1672 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1673 object_flags(creature_ptr, o_ptr, flgs);
1674 creature_ptr->heavy_wield[i] = FALSE;
1675 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1678 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
1679 creature_ptr->heavy_wield[i] = TRUE;
1682 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1683 int str_index, dex_index;
1684 int num = 0, wgt = 0, mul = 0, div = 0;
1686 num = class_info[creature_ptr->pclass].num;
1687 wgt = class_info[creature_ptr->pclass].wgt;
1688 mul = class_info[creature_ptr->pclass].mul;
1690 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1696 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1702 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1703 str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
1705 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1707 if (creature_ptr->pclass == CLASS_NINJA)
1708 str_index = MAX(0, str_index - 1);
1712 dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
1716 num_blow = blows_table[str_index][dex_index];
1718 num_blow = (s16b)num;
1720 num_blow += (s16b)creature_ptr->extra_blows[i];
1721 if (creature_ptr->pclass == CLASS_WARRIOR)
1722 num_blow += (creature_ptr->lev / 40);
1723 else if (creature_ptr->pclass == CLASS_BERSERKER)
1724 num_blow += (creature_ptr->lev / 23);
1725 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
1728 if (creature_ptr->special_defense & KATA_FUUJIN)
1731 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1741 /* Different calculation for monks with empty hands */
1742 if (is_martial_arts_mode(creature_ptr)) {
1743 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
1746 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1756 MAGIC_NUM1 current_ki = get_current_ki(creature_ptr);
1757 if (current_ki != i) {
1758 creature_ptr->to_d[i] += current_ki / 5;
1759 creature_ptr->dis_to_d[i] += current_ki / 5;
1778 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1781 if (creature_ptr->special_defense & KAMAE_GENBU) {
1782 creature_ptr->to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
1783 creature_ptr->dis_to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
1785 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1789 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1790 creature_ptr->to_h[i] -= (creature_ptr->lev / 3);
1791 creature_ptr->to_d[i] -= (creature_ptr->lev / 6);
1793 creature_ptr->dis_to_h[i] -= (creature_ptr->lev / 3);
1794 creature_ptr->dis_to_d[i] -= (creature_ptr->lev / 6);
1798 num_blow += 1 + creature_ptr->extra_blows[0];
1801 if (has_not_ninja_weapon(creature_ptr, i)) {
1812 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1816 * * エントは別途レベル26,41,46到達ごとに加算(+1)
1817 * * 装備がTR_STRフラグを持っていれば加算(+pval*1)
1823 * * 変異MUT3_HYPER_STRで加算(+4)
1824 * * 変異MUT3_PUNYで減算(-4)
1825 * * ネオ・つよしスペシャル中で加算(+4)
1827 static s16b calc_strength_addition(player_type *creature_ptr)
1830 const player_race *tmp_rp_ptr;
1831 if (creature_ptr->mimic_form)
1832 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1834 tmp_rp_ptr = &race_info[creature_ptr->prace];
1835 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1836 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1837 pow = tmp_rp_ptr->r_adj[A_STR] + c_ptr->c_adj[A_STR] + a_ptr->a_adj[A_STR];
1839 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
1840 if (creature_ptr->lev > 25)
1842 if (creature_ptr->lev > 40)
1844 if (creature_ptr->lev > 45)
1848 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1850 BIT_FLAGS flgs[TR_FLAG_SIZE];
1851 o_ptr = &creature_ptr->inventory_list[i];
1854 object_flags(creature_ptr, o_ptr, flgs);
1855 if (has_flag(flgs, TR_STR)) {
1860 if (creature_ptr->realm1 == REALM_HEX) {
1861 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) {
1864 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
1869 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1873 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
1875 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1879 if (creature_ptr->muta3) {
1881 if (creature_ptr->muta3 & MUT3_HYPER_STR) {
1885 if (creature_ptr->muta3 & MUT3_PUNY) {
1890 if (creature_ptr->tsuyoshi) {
1898 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1902 * * 装備がTR_INTフラグを持っていれば加算(+pval*1)
1908 * * 変異MUT3_HYPER_INTで加算(+4)
1909 * * 変異MUT3_MORONICで減算(-4)
1911 s16b calc_intelligence_addition(player_type *creature_ptr)
1914 const player_race *tmp_rp_ptr;
1915 if (creature_ptr->mimic_form)
1916 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1918 tmp_rp_ptr = &race_info[creature_ptr->prace];
1919 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1920 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1921 pow = tmp_rp_ptr->r_adj[A_INT] + c_ptr->c_adj[A_INT] + a_ptr->a_adj[A_INT];
1923 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1925 BIT_FLAGS flgs[TR_FLAG_SIZE];
1926 o_ptr = &creature_ptr->inventory_list[i];
1929 object_flags(creature_ptr, o_ptr, flgs);
1930 if (has_flag(flgs, TR_INT)) {
1935 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1939 if (creature_ptr->special_defense & KAMAE_GENBU) {
1941 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1945 if (creature_ptr->muta3) {
1946 if (creature_ptr->muta3 & MUT3_HYPER_INT) {
1950 if (creature_ptr->muta3 & MUT3_MORONIC) {
1960 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1964 * * 装備がTR_WISフラグを持っていれば加算(+pval*1)
1970 * * 変異MUT3_HYPER_INTで加算(+4)
1971 * * 変異MUT3_MORONICで減算(-4)
1973 static s16b calc_wisdom_addition(player_type *creature_ptr)
1976 const player_race *tmp_rp_ptr;
1977 if (creature_ptr->mimic_form)
1978 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1980 tmp_rp_ptr = &race_info[creature_ptr->prace];
1981 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1982 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1983 pow = tmp_rp_ptr->r_adj[A_WIS] + c_ptr->c_adj[A_WIS] + a_ptr->a_adj[A_WIS];
1985 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1987 BIT_FLAGS flgs[TR_FLAG_SIZE];
1988 o_ptr = &creature_ptr->inventory_list[i];
1991 object_flags(creature_ptr, o_ptr, flgs);
1992 if (has_flag(flgs, TR_WIS)) {
1997 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2001 if (creature_ptr->special_defense & KAMAE_GENBU) {
2003 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2007 if (creature_ptr->muta3) {
2009 if (creature_ptr->muta3 & MUT3_HYPER_INT) {
2013 if (creature_ptr->muta3 & MUT3_MORONIC) {
2023 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2027 * * エントは別途レベル26,41,46到達ごとに減算(-1)
2028 * * 装備がTR_DEXフラグを持っていれば加算(+pval*1)
2034 * * 変異MUT3_IRON_SKINで減算(-1)
2035 * * 変異MUT3_LIMBERで加算(+3)
2036 * * 変異MUT3_ARTHRITISで減算(-3)
2038 static s16b calc_dexterity_addition(player_type *creature_ptr)
2041 const player_race *tmp_rp_ptr;
2042 if (creature_ptr->mimic_form)
2043 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2045 tmp_rp_ptr = &race_info[creature_ptr->prace];
2046 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2047 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2048 pow = tmp_rp_ptr->r_adj[A_DEX] + c_ptr->c_adj[A_DEX] + a_ptr->a_adj[A_DEX];
2050 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2051 if (creature_ptr->lev > 25)
2053 if (creature_ptr->lev > 40)
2055 if (creature_ptr->lev > 45)
2059 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2061 BIT_FLAGS flgs[TR_FLAG_SIZE];
2062 o_ptr = &creature_ptr->inventory_list[i];
2065 object_flags(creature_ptr, o_ptr, flgs);
2066 if (has_flag(flgs, TR_DEX)) {
2071 if (creature_ptr->realm1 == REALM_HEX) {
2072 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2077 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2081 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2083 } else if (creature_ptr->special_defense & KAMAE_GENBU) {
2085 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2089 if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
2093 if (creature_ptr->muta3 & MUT3_LIMBER) {
2097 if (creature_ptr->muta3 & MUT3_ARTHRITIS) {
2106 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2110 * * エントは別途レベル26,41,46到達ごとに加算(+1)
2111 * * 装備がTR_CONフラグを持っていれば加算(+pval*1)
2117 * * 変異MUT3_RESILIENTで加算(+4)
2118 * * 変異MUT3_ALBINOで減算(-4)
2119 * * 変異MUT3_XTRA_FATで加算(+2)
2120 * * 変異MUT3_FLESH_ROTで減算(-2)
2121 * * ネオ・つよしスペシャル中で加算(+4)
2123 static s16b calc_constitution_addition(player_type *creature_ptr)
2126 const player_race *tmp_rp_ptr;
2127 if (creature_ptr->mimic_form)
2128 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2130 tmp_rp_ptr = &race_info[creature_ptr->prace];
2131 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2132 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2133 pow = tmp_rp_ptr->r_adj[A_CON] + c_ptr->c_adj[A_CON] + a_ptr->a_adj[A_CON];
2135 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2136 if (creature_ptr->lev > 25)
2138 if (creature_ptr->lev > 40)
2140 if (creature_ptr->lev > 45)
2144 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2146 BIT_FLAGS flgs[TR_FLAG_SIZE];
2147 o_ptr = &creature_ptr->inventory_list[i];
2150 object_flags(creature_ptr, o_ptr, flgs);
2151 if (has_flag(flgs, TR_CON))
2155 if (creature_ptr->realm1 == REALM_HEX) {
2156 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2161 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2165 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2167 } else if (creature_ptr->special_defense & KAMAE_GENBU) {
2169 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2173 if (creature_ptr->muta3) {
2174 if (creature_ptr->muta3 & MUT3_RESILIENT) {
2178 if (creature_ptr->muta3 & MUT3_ALBINO) {
2182 if (creature_ptr->muta3 & MUT3_XTRA_FAT) {
2186 if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
2191 if (creature_ptr->tsuyoshi) {
2200 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2204 * * 装備がTR_CHRフラグを持っていれば加算(+pval*1)
2207 * * 変異MUT3_FLESH_ROTで減算(-1)
2208 * * 変異MUT3_SILLY_VOIで減算(-4)
2209 * * 変異MUT3_BLANK_FACで減算(-1)
2210 * * 変異MUT3_WART_SKINで減算(-2)
2211 * * 変異MUT3_SCALESで減算(-1)
2212 * * 変異MUT3_ILL_NORMで0固定(後で個体値のみ上書きを行う)
2214 static s16b calc_charisma_addition(player_type *creature_ptr)
2217 const player_race *tmp_rp_ptr;
2218 if (creature_ptr->mimic_form)
2219 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2221 tmp_rp_ptr = &race_info[creature_ptr->prace];
2222 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2223 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2224 pow = tmp_rp_ptr->r_adj[A_CHR] + c_ptr->c_adj[A_CHR] + a_ptr->a_adj[A_CHR];
2226 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2228 BIT_FLAGS flgs[TR_FLAG_SIZE];
2229 o_ptr = &creature_ptr->inventory_list[i];
2232 object_flags(creature_ptr, o_ptr, flgs);
2233 if (has_flag(flgs, TR_CHR))
2237 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2241 if (creature_ptr->muta3) {
2242 if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
2245 if (creature_ptr->muta3 & MUT3_SILLY_VOI) {
2248 if (creature_ptr->muta3 & MUT3_BLANK_FAC) {
2251 if (creature_ptr->muta3 & MUT3_WART_SKIN) {
2254 if (creature_ptr->muta3 & MUT3_SCALES) {
2257 if (creature_ptr->muta3 & MUT3_ILL_NORM) {
2267 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2270 * * 性格なまけものなら加算(+10)
2272 * * 性格ちからじまんとがまんづよいなら加算(+1)
2273 * * 性格チャージマンなら加算(+5)
2274 * * 装備品にTRC_LOW_MAGICがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
2276 static s16b calc_to_magic_chance(player_type *creature_ptr)
2280 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
2282 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
2284 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
2286 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
2289 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2291 BIT_FLAGS flgs[TR_FLAG_SIZE];
2292 o_ptr = &creature_ptr->inventory_list[i];
2295 object_flags(creature_ptr, o_ptr, flgs);
2296 if (o_ptr->curse_flags & TRC_LOW_MAGIC) {
2297 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
2307 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
2309 ARMOUR_CLASS ac = 0;
2310 if (creature_ptr->yoiyami)
2313 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2315 o_ptr = &creature_ptr->inventory_list[i];
2321 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_RARM])
2322 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_LARM])) {
2323 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2329 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_true_value)
2331 ARMOUR_CLASS ac = 0;
2332 if (creature_ptr->yoiyami)
2335 ac += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2337 if (creature_ptr->mimic_form) {
2338 switch (creature_ptr->mimic_form) {
2342 case MIMIC_DEMON_LORD:
2350 if (creature_ptr->pclass == CLASS_BERSERKER) {
2351 ac += 10 + creature_ptr->lev / 2;
2353 if (creature_ptr->pclass == CLASS_SORCERER) {
2357 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2359 o_ptr = &creature_ptr->inventory_list[i];
2362 if (is_true_value || object_is_known(o_ptr))
2365 if (o_ptr->curse_flags & TRC_LOW_AC) {
2366 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
2367 if (is_true_value || object_is_fully_known(o_ptr))
2370 if (is_true_value || object_is_fully_known(o_ptr))
2375 if ((i == INVEN_LARM) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI))) {
2380 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
2381 ac += 10 + (creature_ptr->lev * 2 / 5);
2384 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2388 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI)) {
2392 if (creature_ptr->muta3 & MUT3_WART_SKIN) {
2396 if (creature_ptr->muta3 & MUT3_SCALES) {
2400 if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
2404 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
2405 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
2406 ac += (creature_ptr->lev * 3) / 2;
2408 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
2409 ac += ((creature_ptr->lev - 13) / 3);
2411 if (!(creature_ptr->inventory_list[INVEN_LARM].k_idx) && (creature_ptr->lev > 10)) {
2412 ac += ((creature_ptr->lev - 8) / 3);
2414 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
2415 ac += (creature_ptr->lev - 2) / 3;
2417 if (!(creature_ptr->inventory_list[INVEN_HANDS].k_idx)) {
2418 ac += (creature_ptr->lev / 2);
2420 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
2421 ac += (creature_ptr->lev / 3);
2425 if (creature_ptr->realm1 == REALM_HEX) {
2426 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
2430 for (inventory_slot_type i = INVEN_RARM; i <= INVEN_FEET; i++) {
2431 object_type *o_ptr = &creature_ptr->inventory_list[i];
2434 if (!object_is_armour(creature_ptr, o_ptr))
2436 if (!object_is_cursed(o_ptr))
2438 if (o_ptr->curse_flags & TRC_CURSED)
2440 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2442 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2447 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2449 } else if (creature_ptr->special_defense & KAMAE_SEIRYU) {
2451 } else if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2455 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
2457 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
2461 if (is_blessed(creature_ptr)) {
2465 if (is_shero(creature_ptr)) {
2469 if (creature_ptr->pclass == CLASS_NINJA) {
2470 if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
2471 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
2472 ac += creature_ptr->lev / 2 + 5;
2481 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2486 * ** クラッコンと妖精に加算(+レベル/10)
2487 * ** 悪魔変化/吸血鬼変化で加算(+3)
2489 * ** 装備品にTR_SPEEDがあれば加算(+pval+1
2490 * ** 忍者の装備が重ければ減算(-レベル/10)
2491 * ** 忍者の装備が適正ならば加算(+3)さらにクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2492 * ** 錬気術師で装備が重くなくクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2493 * ** 狂戦士なら加算(+3),レベル20/30/40/50ごとに+1
2494 * ** いかさまでクラッコン/妖精以外なら加算(+5+レベル/10)
2497 * ** 呪術「衝撃のクローク」で加算(+3)
2500 * ** 変異MUT3_XTRA_FATなら減算(-2)
2501 * ** 変異MUT3_XTRA_LEGなら加算(+3)
2502 * ** 変異MUT3_SHORT_LEGなら減算(-3)
2503 * ** マーフォークがFF_WATER地形にいれば加算(+2+レベル/10)
2504 * ** そうでなく浮遊を持っていないなら減算(-2)
2505 * ** 棘セット装備中ならば加算(+7)
2506 * * 騎乗中ならばモンスターの加速に準拠、ただし騎乗技能値とモンスターレベルによるキャップ処理あり
2508 * * 光速移動中かこの時点で+99を超えていたら+99にキャップ
2511 static s16b calc_speed(player_type *creature_ptr)
2513 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2514 feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
2518 int j = calc_inventory_weight(creature_ptr);
2521 if (!creature_ptr->riding) {
2522 if (is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE))
2523 pow += (creature_ptr->lev) / 10;
2525 if (creature_ptr->mimic_form) {
2526 switch (creature_ptr->mimic_form) {
2530 case MIMIC_DEMON_LORD:
2539 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2540 object_type *o_ptr = &creature_ptr->inventory_list[i];
2541 BIT_FLAGS flgs[TR_FLAG_SIZE];
2542 object_flags(creature_ptr, o_ptr, flgs);
2546 if (has_flag(flgs, TR_SPEED))
2550 if (creature_ptr->pclass == CLASS_NINJA) {
2551 if (heavy_armor(creature_ptr)) {
2552 pow -= (creature_ptr->lev) / 10;
2553 } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
2554 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(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;
2562 if (creature_ptr->pclass == CLASS_FORCETRAINER && !(heavy_armor(creature_ptr))) {
2563 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2564 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2565 pow += (creature_ptr->lev) / 10;
2568 if (creature_ptr->pclass == CLASS_BERSERKER) {
2570 if (creature_ptr->lev > 29)
2572 if (creature_ptr->lev > 39)
2574 if (creature_ptr->lev > 44)
2576 if (creature_ptr->lev > 49)
2580 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN && creature_ptr->prace != RACE_KLACKON && creature_ptr->prace != RACE_SPRITE) {
2581 pow += (creature_ptr->lev) / 10 + 5;
2584 if (is_fast(creature_ptr)) {
2588 if (creature_ptr->slow) {
2592 if (creature_ptr->realm1 == REALM_HEX) {
2593 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) {
2598 if (creature_ptr->food >= PY_FOOD_MAX)
2601 if (creature_ptr->special_defense & KAMAE_SUZAKU)
2604 if (creature_ptr->muta3) {
2606 if (creature_ptr->muta3 & MUT3_XTRA_FAT) {
2610 if (creature_ptr->muta3 & MUT3_XTRA_LEGS) {
2614 if (creature_ptr->muta3 & MUT3_SHORT_LEG) {
2619 if (creature_ptr->prace == RACE_MERFOLK) {
2620 if (has_flag(f_ptr->flags, FF_WATER)) {
2621 pow += (2 + creature_ptr->lev / 10);
2622 } else if (!creature_ptr->levitation) {
2627 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
2628 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2633 count = (int)calc_weight_limit(creature_ptr);
2635 pow -= ((j - count) / (count / 5));
2638 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
2639 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2640 SPEED speed = riding_m_ptr->mspeed;
2642 if (riding_m_ptr->mspeed > 110) {
2643 pow = 110 + (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2650 pow += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2652 if (monster_fast_remaining(riding_m_ptr))
2654 if (monster_slow_remaining(riding_m_ptr))
2657 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED)
2658 j += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2660 count = 1500 + riding_r_ptr->level * 25;
2662 pow -= ((j - count) / (count / 5));
2665 if (creature_ptr->action == ACTION_SEARCH)
2668 /* Maximum speed is (+99). (internally it's 110 + 99) */
2669 /* Temporary lightspeed forces to be maximum speed */
2670 if ((creature_ptr->lightspeed && !creature_ptr->riding) || (pow > 209)) {
2674 /* Minimum speed is (-99). (internally it's 110 - 99) */
2682 * @brief 二刀流ペナルティ量計算
2683 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2684 * @param slot ペナルティ量を計算する武器スロット
2690 * * マンゴーシュ/脇差を左に装備した場合の軽減
2694 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
2697 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
2698 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
2699 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2700 penalty = penalty / 2 - 5;
2702 if (creature_ptr->easy_2weapon) {
2705 } else if ((creature_ptr->inventory_list[INVEN_LARM].tval == TV_SWORD)
2706 && ((creature_ptr->inventory_list[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (creature_ptr->inventory_list[INVEN_LARM].sval == SV_WAKIZASHI))) {
2707 penalty = MAX(0, penalty - 10);
2709 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI)) {
2710 penalty = MIN(0, penalty);
2712 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty > 0))
2714 if ((creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty > 0))
2718 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
2721 return (s16b)penalty;
2724 static void calc_ind_status(player_type *creature_ptr, int status)
2727 if (creature_ptr->stat_use[status] <= 18)
2728 ind = (creature_ptr->stat_use[status] - 3);
2729 else if (creature_ptr->stat_use[status] <= 18 + 219)
2730 ind = (15 + (creature_ptr->stat_use[status] - 18) / 10);
2734 if (creature_ptr->stat_ind[status] == ind)
2737 creature_ptr->stat_ind[status] = (s16b)ind;
2738 if (status == A_CON) {
2739 creature_ptr->update |= (PU_HP);
2740 } else if (status == A_INT) {
2741 if (mp_ptr->spell_stat == A_INT) {
2742 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2744 } else if (status == A_WIS) {
2745 if (mp_ptr->spell_stat == A_WIS) {
2746 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2748 } else if (status == A_CHR) {
2749 if (mp_ptr->spell_stat == A_CHR) {
2750 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2754 creature_ptr->window |= (PW_PLAYER);
2757 static void calc_use_status(player_type *creature_ptr, int status)
2759 int use = modify_stat_value(creature_ptr->stat_cur[status], creature_ptr->stat_add[status]);
2761 if ((status == A_CHR) && (creature_ptr->muta3 & MUT3_ILL_NORM)) {
2762 /* 10 to 18/90 charisma, guaranteed, based on level */
2763 if (use < 8 + 2 * creature_ptr->lev) {
2764 use = 8 + 2 * creature_ptr->lev;
2768 if (creature_ptr->stat_use[status] != use) {
2769 creature_ptr->stat_use[status] = (s16b)use;
2770 creature_ptr->redraw |= (PR_STATS);
2771 creature_ptr->window |= (PW_PLAYER);
2775 static void calc_top_status(player_type *creature_ptr, int status)
2777 int top = modify_stat_value(creature_ptr->stat_max[status], creature_ptr->stat_add[status]);
2779 if (creature_ptr->stat_top[status] != top) {
2780 creature_ptr->stat_top[status] = (s16b)top;
2781 creature_ptr->redraw |= (PR_STATS);
2782 creature_ptr->window |= (PW_PLAYER);
2786 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
2788 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2789 if (!creature_ptr->riding)
2794 creature_ptr->riding_ryoute = FALSE;
2796 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
2797 creature_ptr->riding_ryoute = TRUE;
2798 else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) {
2799 switch (creature_ptr->pclass) {
2801 case CLASS_FORCETRAINER:
2802 case CLASS_BERSERKER:
2803 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM)
2804 && !has_melee_weapon(creature_ptr, INVEN_LARM))
2805 creature_ptr->riding_ryoute = TRUE;
2810 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2811 if (creature_ptr->tval_ammo != TV_ARROW)
2814 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2820 if (creature_ptr->tval_ammo == TV_BOLT)
2826 void put_equipment_warning(player_type *creature_ptr)
2828 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
2829 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
2831 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2832 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
2833 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2835 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2837 creature_ptr->old_heavy_shoot = heavy_shoot;
2840 for (int i = 0; i < 2; i++) {
2841 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
2842 if (creature_ptr->heavy_wield[i]) {
2843 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2844 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2845 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2846 } else if (creature_ptr->heavy_wield[1 - i]) {
2847 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
2849 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2852 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
2855 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
2856 if (creature_ptr->riding_wield[i]) {
2857 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2858 } else if (!creature_ptr->riding) {
2859 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
2860 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2861 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2864 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
2867 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
2870 if (creature_ptr->icky_wield[i]) {
2871 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2872 if (current_world_ptr->is_loading_now) {
2873 chg_virtue(creature_ptr, V_FAITH, -1);
2875 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2876 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2878 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2881 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
2884 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
2885 if (creature_ptr->riding_ryoute) {
2887 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2889 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
2893 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2895 msg_print("You began to control the pet you're riding with one hand.");
2899 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
2902 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
2903 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
2904 if (heavy_armor(creature_ptr)) {
2905 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2906 if (current_world_ptr->is_loading_now) {
2907 chg_virtue(creature_ptr, V_HARMONY, -1);
2910 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2913 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
2917 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value)
2919 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2920 int id = slot - INVEN_RARM;
2921 BIT_FLAGS flgs[TR_FLAG_SIZE];
2922 object_flags(creature_ptr, o_ptr, flgs);
2925 damage += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2927 if (is_shero(creature_ptr)) {
2928 damage += 3 + (creature_ptr->lev / 5);
2931 if (creature_ptr->stun > 50) {
2933 } else if (creature_ptr->stun) {
2937 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2939 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2940 damage += creature_ptr->lev / 6;
2941 if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2942 damage += creature_ptr->lev / 6;
2944 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2945 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2952 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2953 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2954 if (o_ptr->curse_flags & (TRC_CURSED)) {
2957 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) {
2960 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) {
2966 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2968 o_ptr = &creature_ptr->inventory_list[i];
2969 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
2970 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2973 if (!object_is_known(o_ptr) && !is_true_value)
2975 bonus_to_d = o_ptr->to_d;
2977 if (creature_ptr->pclass == CLASS_NINJA) {
2978 if (o_ptr->to_d > 0)
2979 bonus_to_d = (o_ptr->to_d + 1) / 2;
2982 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
2983 damage += (s16b)bonus_to_d;
2984 } else if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) {
2986 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2988 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2989 } else if (id == get_default_hand(creature_ptr)) {
2990 damage += (s16b)bonus_to_d;
2994 if (get_default_hand(creature_ptr) == id) {
2995 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
2996 || !has_disable_two_handed_bonus(creature_ptr, 0)) {
2998 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
2999 damage += MAX(bonus_to_d, 1);
3003 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3004 damage += (creature_ptr->lev / 6);
3011 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
3013 * 'slot' MUST be INVEN_RARM or INVEM_LARM.
3015 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value)
3020 hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3021 hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3023 /* Temporary bonuses */
3024 if (is_blessed(creature_ptr)) {
3028 if (is_hero(creature_ptr)) {
3032 if (is_shero(creature_ptr)) {
3036 if (creature_ptr->stun > 50) {
3038 } else if (creature_ptr->stun) {
3042 /* Default hand bonuses */
3043 int id = slot - INVEN_RARM;
3044 int default_hand = get_default_hand(creature_ptr);
3045 if (default_hand == id) {
3046 /* Add trained bonus of empty hands' combat when having no weapon and riding */
3047 if ((!has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_LARM))
3048 || (!has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))) {
3049 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
3052 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
3053 || !has_disable_two_handed_bonus(creature_ptr, 0)) {
3055 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);
3056 hit += MAX(bonus_to_h, 1);
3060 /* Bonuses and penalties by weapon */
3061 if (has_melee_weapon(creature_ptr, slot)) {
3062 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3063 BIT_FLAGS flgs[TR_FLAG_SIZE];
3064 object_flags(creature_ptr, o_ptr, flgs);
3066 tval_type tval = o_ptr->tval - TV_WEAPON_BEGIN;
3067 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
3069 /* Traind bonuses */
3070 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3072 /* Weight penalty */
3073 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
3074 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3077 /* Low melee penalty */
3078 if ((object_is_fully_known(o_ptr) || is_true_value) && o_ptr->curse_flags & TRC_LOW_MELEE) {
3079 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
3086 /* Riding bonus and penalty */
3087 if (creature_ptr->riding) {
3088 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3093 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
3094 && !has_flag(flgs, TR_RIDING)) {
3097 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
3100 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3105 hit -= (s16b)penalty;
3108 /* Class penalties */
3109 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
3111 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
3112 hit += creature_ptr->lev / 5;
3113 if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
3114 hit += creature_ptr->lev / 5;
3116 } else if (creature_ptr->pclass == CLASS_SORCERER) {
3117 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
3124 if (has_not_ninja_weapon(creature_ptr, id) || has_not_monk_weapon(creature_ptr, id)) {
3128 /* Hex realm bonuses */
3129 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
3130 if (o_ptr->curse_flags & (TRC_CURSED)) {
3133 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) {
3136 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) {
3139 if (o_ptr->curse_flags & (TRC_TY_CURSE)) {
3145 /* Bonuses from inventory */
3146 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3147 object_type *o_ptr = &creature_ptr->inventory_list[i];
3149 /* Ignore empty hands, handed weapons, bows and capture balls */
3151 || o_ptr->tval == TV_CAPTURE
3152 || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
3153 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i))
3157 /* Fake value does not include unknown objects' value */
3158 if (is_true_value || !object_is_known(o_ptr))
3161 int bonus_to_h = o_ptr->to_h;
3163 /* When wields only a weapon */
3164 if (creature_ptr->pclass == CLASS_NINJA) {
3165 if (o_ptr->to_h > 0)
3166 bonus_to_h = (o_ptr->to_h + 1) / 2;
3169 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
3170 hit += (s16b)bonus_to_h;
3174 /* When wields two weapons on each hand */
3175 if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) {
3176 if (default_hand == 0)
3177 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
3178 if (default_hand == 1)
3179 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
3183 if (default_hand == id)
3184 hit += (s16b)bonus_to_h;
3187 /* Martial arts bonus */
3188 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3189 hit += (creature_ptr->lev / 3);
3192 /* Two handed combat penalty */
3193 hit -= calc_double_weapon_penalty(creature_ptr, slot);
3198 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_true_value)
3202 pow += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3203 pow += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3207 BIT_FLAGS flgs[TR_FLAG_SIZE];
3208 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3210 object_flags(creature_ptr, o_ptr, flgs);
3212 if (o_ptr->curse_flags & TRC_LOW_MELEE) {
3213 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
3222 if (creature_ptr->stun > 50) {
3224 } else if (creature_ptr->stun) {
3228 if (is_blessed(creature_ptr)) {
3232 if (is_hero(creature_ptr)) {
3236 if (is_shero(creature_ptr)) {
3240 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3242 if (is_heavy_shoot(creature_ptr, o_ptr)) {
3243 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3247 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
3248 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
3249 pow += (10 + (creature_ptr->lev / 5));
3255 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3257 o_ptr = &creature_ptr->inventory_list[i];
3258 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
3259 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3262 bonus_to_h = o_ptr->to_h;
3264 if (creature_ptr->pclass == CLASS_NINJA) {
3265 if (o_ptr->to_h > 0)
3266 bonus_to_h = (o_ptr->to_h + 1) / 2;
3269 if (is_true_value || object_is_known(o_ptr))
3270 pow += (s16b)bonus_to_h;
3273 pow -= calc_riding_bow_penalty(creature_ptr);
3278 static s16b calc_to_damage_misc(player_type *creature_ptr)
3281 BIT_FLAGS flgs[TR_FLAG_SIZE];
3285 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3286 o_ptr = &creature_ptr->inventory_list[i];
3290 object_flags(creature_ptr, o_ptr, flgs);
3292 int bonus_to_d = o_ptr->to_d;
3293 if (creature_ptr->pclass == CLASS_NINJA) {
3294 if (o_ptr->to_d > 0)
3295 bonus_to_d = (o_ptr->to_d + 1) / 2;
3297 to_dam += (s16b)bonus_to_d;
3300 if (is_shero(creature_ptr)) {
3301 to_dam += 3 + (creature_ptr->lev / 5);
3304 if (creature_ptr->stun > 50) {
3306 } else if (creature_ptr->stun) {
3310 to_dam += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
3314 static s16b calc_to_hit_misc(player_type *creature_ptr)
3317 BIT_FLAGS flgs[TR_FLAG_SIZE];
3321 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3322 o_ptr = &creature_ptr->inventory_list[i];
3326 object_flags(creature_ptr, o_ptr, flgs);
3328 int bonus_to_h = o_ptr->to_h;
3329 if (creature_ptr->pclass == CLASS_NINJA) {
3330 if (o_ptr->to_h > 0)
3331 bonus_to_h = (o_ptr->to_h + 1) / 2;
3333 to_hit += (s16b)bonus_to_h;
3336 if (is_blessed(creature_ptr)) {
3340 if (is_hero(creature_ptr)) {
3344 if (is_shero(creature_ptr)) {
3348 if (creature_ptr->stun > 50) {
3350 } else if (creature_ptr->stun) {
3354 to_hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3355 to_hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3360 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
3362 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3365 if (creature_ptr->riding) {
3367 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3375 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
3377 (void)creature_ptr; // unused
3378 (void)slot; // unused
3383 * @brief プレイヤーの所持重量制限を計算する /
3384 * Computes current weight limit.
3387 WEIGHT calc_weight_limit(player_type *creature_ptr)
3389 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
3390 if (creature_ptr->pclass == CLASS_BERSERKER)
3396 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3397 * @param i 判定する手のID(右手:INVEN_RARM 左手:INVEN_LARM)
3398 * @return 持っているならばTRUE
3400 bool has_melee_weapon(player_type *creature_ptr, int slot)
3402 return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot]));
3406 * @brief プレイヤーの現在開いている手の状態を返す
3407 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3408 * @return 開いている手のビットフラグ
3410 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
3412 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3413 if (!creature_ptr->inventory_list[INVEN_RARM].k_idx)
3414 status |= EMPTY_HAND_RARM;
3415 if (!creature_ptr->inventory_list[INVEN_LARM].k_idx)
3416 status |= EMPTY_HAND_LARM;
3418 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS)) {
3419 if (status & EMPTY_HAND_LARM)
3420 status &= ~(EMPTY_HAND_LARM);
3421 else if (status & EMPTY_HAND_RARM)
3422 status &= ~(EMPTY_HAND_RARM);
3429 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3430 * @return ペナルティが適用されるならばTRUE。
3432 bool heavy_armor(player_type *creature_ptr)
3434 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
3437 WEIGHT monk_arm_wgt = 0;
3438 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD)
3439 monk_arm_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
3440 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD)
3441 monk_arm_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
3442 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
3443 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
3444 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
3445 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
3446 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
3448 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
3452 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
3454 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3456 void update_creature(player_type *creature_ptr)
3458 if (!creature_ptr->update)
3461 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3462 if (creature_ptr->update & (PU_AUTODESTROY)) {
3463 creature_ptr->update &= ~(PU_AUTODESTROY);
3464 autopick_delayed_alter(creature_ptr);
3467 if (creature_ptr->update & (PU_COMBINE)) {
3468 creature_ptr->update &= ~(PU_COMBINE);
3469 combine_pack(creature_ptr);
3472 if (creature_ptr->update & (PU_REORDER)) {
3473 creature_ptr->update &= ~(PU_REORDER);
3474 reorder_pack(creature_ptr);
3477 if (creature_ptr->update & (PU_BONUS)) {
3478 creature_ptr->update &= ~(PU_BONUS);
3479 calc_alignment(creature_ptr);
3480 calc_bonuses(creature_ptr);
3483 if (creature_ptr->update & (PU_TORCH)) {
3484 creature_ptr->update &= ~(PU_TORCH);
3485 calc_lite_radius(creature_ptr);
3488 if (creature_ptr->update & (PU_HP)) {
3489 creature_ptr->update &= ~(PU_HP);
3490 calc_hitpoints(creature_ptr);
3493 if (creature_ptr->update & (PU_MANA)) {
3494 creature_ptr->update &= ~(PU_MANA);
3495 calc_mana(creature_ptr);
3498 if (creature_ptr->update & (PU_SPELLS)) {
3499 creature_ptr->update &= ~(PU_SPELLS);
3500 calc_spells(creature_ptr);
3503 if (!current_world_ptr->character_generated)
3505 if (current_world_ptr->character_icky)
3507 if (creature_ptr->update & (PU_UN_LITE)) {
3508 creature_ptr->update &= ~(PU_UN_LITE);
3509 forget_lite(floor_ptr);
3512 if (creature_ptr->update & (PU_UN_VIEW)) {
3513 creature_ptr->update &= ~(PU_UN_VIEW);
3514 forget_view(floor_ptr);
3517 if (creature_ptr->update & (PU_VIEW)) {
3518 creature_ptr->update &= ~(PU_VIEW);
3519 update_view(creature_ptr);
3522 if (creature_ptr->update & (PU_LITE)) {
3523 creature_ptr->update &= ~(PU_LITE);
3524 update_lite(creature_ptr);
3527 if (creature_ptr->update & (PU_FLOW)) {
3528 creature_ptr->update &= ~(PU_FLOW);
3529 update_flow(creature_ptr);
3532 if (creature_ptr->update & (PU_DISTANCE)) {
3533 creature_ptr->update &= ~(PU_DISTANCE);
3535 update_monsters(creature_ptr, TRUE);
3538 if (creature_ptr->update & (PU_MON_LITE)) {
3539 creature_ptr->update &= ~(PU_MON_LITE);
3540 update_mon_lite(creature_ptr);
3543 if (creature_ptr->update & (PU_DELAY_VIS)) {
3544 creature_ptr->update &= ~(PU_DELAY_VIS);
3545 delayed_visual_update(creature_ptr);
3548 if (creature_ptr->update & (PU_MONSTERS)) {
3549 creature_ptr->update &= ~(PU_MONSTERS);
3550 update_monsters(creature_ptr, FALSE);
3555 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
3556 * @return 魔道書を一冊も持っていないならTRUEを返す
3558 bool player_has_no_spellbooks(player_type *creature_ptr)
3561 for (int i = 0; i < INVEN_PACK; i++) {
3562 o_ptr = &creature_ptr->inventory_list[i];
3563 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3567 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3568 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
3569 o_ptr = &floor_ptr->o_list[i];
3570 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3577 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost) { creature_ptr->energy_use = (ENERGY)need_cost; }
3579 void free_turn(player_type *creature_ptr) { creature_ptr->energy_use = 0; }
3582 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
3585 * @return 配置に成功したらTRUE
3587 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
3589 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
3592 /* Save player location */
3593 creature_ptr->y = y;
3594 creature_ptr->x = x;
3599 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
3602 void wreck_the_pattern(player_type *creature_ptr)
3604 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3605 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
3606 if (pattern_type == PATTERN_TILE_WRECKED)
3609 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
3610 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
3612 if (!is_invuln(creature_ptr))
3613 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
3615 int to_ruin = randint1(45) + 35;
3618 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
3620 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
3621 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
3625 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
3629 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
3630 * Advance experience levels and print experience
3633 void check_experience(player_type *creature_ptr)
3635 if (creature_ptr->exp < 0)
3636 creature_ptr->exp = 0;
3637 if (creature_ptr->max_exp < 0)
3638 creature_ptr->max_exp = 0;
3639 if (creature_ptr->max_max_exp < 0)
3640 creature_ptr->max_max_exp = 0;
3642 if (creature_ptr->exp > PY_MAX_EXP)
3643 creature_ptr->exp = PY_MAX_EXP;
3644 if (creature_ptr->max_exp > PY_MAX_EXP)
3645 creature_ptr->max_exp = PY_MAX_EXP;
3646 if (creature_ptr->max_max_exp > PY_MAX_EXP)
3647 creature_ptr->max_max_exp = PY_MAX_EXP;
3649 if (creature_ptr->exp > creature_ptr->max_exp)
3650 creature_ptr->max_exp = creature_ptr->exp;
3651 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
3652 creature_ptr->max_max_exp = creature_ptr->max_exp;
3654 creature_ptr->redraw |= (PR_EXP);
3655 handle_stuff(creature_ptr);
3657 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
3658 PLAYER_LEVEL old_lev = creature_ptr->lev;
3659 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
3660 creature_ptr->lev--;
3661 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3662 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
3663 creature_ptr->window |= (PW_PLAYER);
3664 handle_stuff(creature_ptr);
3667 bool level_reward = FALSE;
3668 bool level_mutation = FALSE;
3669 bool level_inc_stat = FALSE;
3670 while ((creature_ptr->lev < PY_MAX_LEVEL)
3671 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
3672 creature_ptr->lev++;
3673 if (creature_ptr->lev > creature_ptr->max_plv) {
3674 creature_ptr->max_plv = creature_ptr->lev;
3676 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || (creature_ptr->muta2 & MUT2_CHAOS_GIFT)) {
3677 level_reward = TRUE;
3679 if (creature_ptr->prace == RACE_BEASTMAN) {
3681 level_mutation = TRUE;
3683 level_inc_stat = TRUE;
3685 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
3689 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
3690 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3691 creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
3692 creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
3693 creature_ptr->level_up_message = TRUE;
3694 handle_stuff(creature_ptr);
3696 creature_ptr->level_up_message = FALSE;
3697 if (level_inc_stat) {
3698 if (!(creature_ptr->max_plv % 10)) {
3705 cnv_stat(creature_ptr->stat_max[0], tmp);
3706 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
3707 cnv_stat(creature_ptr->stat_max[1], tmp);
3708 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
3709 cnv_stat(creature_ptr->stat_max[2], tmp);
3710 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
3711 cnv_stat(creature_ptr->stat_max[3], tmp);
3712 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
3713 cnv_stat(creature_ptr->stat_max[4], tmp);
3714 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
3715 cnv_stat(creature_ptr->stat_max[5], tmp);
3716 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
3719 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
3723 if ((choice >= 'a') && (choice <= 'f'))
3726 for (n = 0; n < A_MAX; n++)
3727 if (n != choice - 'a')
3729 if (get_check(_("よろしいですか?", "Are you sure? ")))
3732 do_inc_stat(creature_ptr, choice - 'a');
3734 } else if (!(creature_ptr->max_plv % 2))
3735 do_inc_stat(creature_ptr, randint0(6));
3738 if (level_mutation) {
3739 msg_print(_("あなたは変わった気がする...", "You feel different..."));
3740 (void)gain_mutation(creature_ptr, 0);
3741 level_mutation = FALSE;
3745 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
3749 gain_level_reward(creature_ptr, 0);
3750 level_reward = FALSE;
3753 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3754 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
3755 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
3756 handle_stuff(creature_ptr);
3759 if (old_lev != creature_ptr->lev)
3760 autopick_load_pref(creature_ptr, FALSE);
3764 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
3766 * @param out_val 出力先文字列ポインタ
3769 void cnv_stat(int val, char *out_val)
3772 sprintf(out_val, " %2d", val);
3776 int bonus = (val - 18);
3778 sprintf(out_val, "18/%3s", "***");
3779 } else if (bonus >= 100) {
3780 sprintf(out_val, "18/%03d", bonus);
3782 sprintf(out_val, " 18/%02d", bonus);
3787 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
3788 * Modify a stat value by a "modifier", return new value
3790 * @param amount 加減算値
3794 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
3795 * Or even: 18/13, 18/23, 18/33, ..., 18/220
3796 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
3797 * Or even: 18/13, 18/03, 18, 17, ..., 3
3800 s16b modify_stat_value(int value, int amount)
3803 for (int i = 0; i < amount; i++) {
3809 } else if (amount < 0) {
3810 for (int i = 0; i < (0 - amount); i++) {
3811 if (value >= 18 + 10)
3813 else if (value > 18)
3825 * Hack -- Calculates the total number of points earned -JWT-
3829 long calc_score(player_type *creature_ptr)
3831 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
3844 if (ironman_small_levels)
3846 if (ironman_empty_levels)
3852 if (ironman_nightmare)
3859 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
3860 if (max_dlv[i] > max_dl)
3861 max_dl = max_dlv[i];
3863 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
3864 u32b point_h = point_l / 0x10000L;
3865 point_l = point_l % 0x10000L;
3868 point_h += point_l / 0x10000L;
3869 point_l %= 0x10000L;
3871 point_l += ((point_h % 100) << 16);
3875 u32b point = (point_h << 16) + (point_l);
3876 if (creature_ptr->arena_number >= 0)
3877 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
3879 if (ironman_downward)
3881 if (creature_ptr->pclass == CLASS_BERSERKER) {
3882 if (creature_ptr->prace == RACE_SPECTRE)
3886 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
3888 if (current_world_ptr->total_winner)
3893 point = (0 - point);
3899 * @param creature_ptr プレーヤーへの参照ポインタ
3900 * @return 祝福状態ならばTRUE
3902 bool is_blessed(player_type *creature_ptr)
3904 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
3907 bool is_tim_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_tim_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
3914 bool is_time_limit_esp(player_type *creature_ptr)
3916 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3919 bool is_time_limit_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
3921 bool can_two_hands_wielding(player_type *creature_ptr) { return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS); }
3924 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
3927 void stop_singing(player_type *creature_ptr)
3929 if (creature_ptr->pclass != CLASS_BARD)
3932 /* Are there interupted song? */
3933 if (INTERUPTING_SONG_EFFECT(creature_ptr)) {
3934 /* Forget interupted song */
3935 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3939 /* The player is singing? */
3940 if (!SINGING_SONG_EFFECT(creature_ptr))
3943 /* Hack -- if called from set_action(), avoid recursive loop */
3944 if (creature_ptr->action == ACTION_SING)
3945 set_action(creature_ptr, ACTION_NONE);
3947 /* Message text of each song or etc. */
3948 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
3950 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3951 SINGING_SONG_ID(creature_ptr) = 0;
3952 creature_ptr->update |= (PU_BONUS);
3953 creature_ptr->redraw |= (PR_STATUS);
3957 * @brief 口を使う継続的な処理を中断する
3958 * @param caster_ptr プレーヤーへの参照ポインタ
3961 void stop_mouth(player_type *caster_ptr)
3963 if (music_singing_any(caster_ptr))
3964 stop_singing(caster_ptr);
3965 if (hex_spelling_any(caster_ptr))
3966 stop_hex_spell_all(caster_ptr);
3970 * @brief ペットの維持コスト計算
3973 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
3976 bool has_a_unique = FALSE;
3977 DEPTH total_friend_levels = 0;
3981 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
3982 monster_type *m_ptr;
3983 monster_race *r_ptr;
3985 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
3986 if (!monster_is_valid(m_ptr))
3988 r_ptr = &r_info[m_ptr->r_idx];
3990 if (is_pet(m_ptr)) {
3992 if (r_ptr->flags1 & RF1_UNIQUE) {
3993 if (creature_ptr->pclass == CLASS_CAVALRY) {
3994 if (creature_ptr->riding == m_idx)
3995 total_friend_levels += (r_ptr->level + 5) * 2;
3996 else if (!has_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
3997 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
3999 total_friend_levels += (r_ptr->level + 5) * 10;
4000 has_a_unique = TRUE;
4002 total_friend_levels += (r_ptr->level + 5) * 10;
4004 total_friend_levels += r_ptr->level;
4008 if (total_friends) {
4010 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
4011 if (upkeep_factor < 0)
4013 if (upkeep_factor > 1000)
4014 upkeep_factor = 1000;
4015 return upkeep_factor;
4020 bool music_singing(player_type *caster_ptr, int music_songs) { return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs); }
4022 bool is_fast(player_type *creature_ptr) { return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO); }
4024 bool is_invuln(player_type *creature_ptr) { return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN); }
4026 bool is_hero(player_type *creature_ptr) { return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO); }
4028 bool is_shero(player_type *creature_ptr) { return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER; }
4030 bool is_echizen(player_type *creature_ptr)
4032 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
4035 int calc_weapon_weight_limit(player_type *creature_ptr)
4037 int weight = adj_str_hold[creature_ptr->stat_ind[A_STR]];
4039 if (has_two_handed_weapons(creature_ptr))
4045 static int get_default_hand(player_type *creature_ptr)
4047 int default_hand = 0;
4049 if (has_melee_weapon(creature_ptr, INVEN_LARM)) {
4050 if (!has_right_hand_weapon(creature_ptr))
4054 if (can_two_hands_wielding(creature_ptr)) {
4055 if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
4056 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
4057 } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
4058 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
4064 return default_hand;