1 #include "player/player-status.h"
2 #include "art-definition/art-bow-types.h"
3 #include "art-definition/art-sword-types.h"
4 #include "art-definition/art-weapon-types.h"
5 #include "autopick/autopick-reader-writer.h"
6 #include "autopick/autopick.h"
7 #include "cmd-action/cmd-pet.h"
8 #include "cmd-action/cmd-spell.h"
9 #include "cmd-io/cmd-dump.h"
10 #include "cmd-item/cmd-magiceat.h"
11 #include "combat/attack-power-table.h"
12 #include "core/asking-player.h"
13 #include "core/player-redraw-types.h"
14 #include "core/player-update-types.h"
15 #include "core/stuff-handler.h"
16 #include "core/window-redrawer.h"
17 #include "dungeon/dungeon-flag-types.h"
18 #include "dungeon/dungeon.h"
19 //#include "dungeon/quest.h"
20 #include "effect/effect-characteristics.h"
21 #include "floor/cave.h"
22 #include "floor/floor-events.h"
23 #include "floor/floor-leaver.h"
24 #include "floor/floor-save.h"
25 #include "floor/floor-util.h"
26 #include "game-option/birth-options.h"
27 #include "grid/feature.h"
28 #include "inventory/inventory-object.h"
29 #include "inventory/inventory-slot-types.h"
30 #include "io/input-key-acceptor.h"
31 #include "io/write-diary.h"
32 #include "main/sound-definitions-table.h"
33 #include "main/sound-of-music.h"
34 #include "market/arena-info-table.h"
35 #include "mind/mind-force-trainer.h"
36 #include "mind/mind-ninja.h"
37 #include "monster-floor/monster-lite.h"
38 #include "monster-floor/monster-remover.h"
39 #include "monster-race/monster-race-hook.h"
40 #include "monster-race/monster-race.h"
41 #include "monster-race/race-flags1.h"
42 #include "monster-race/race-flags2.h"
43 #include "monster-race/race-flags3.h"
44 #include "monster-race/race-flags7.h"
45 #include "monster/monster-info.h"
46 #include "monster/monster-status.h"
47 #include "monster/monster-update.h"
48 #include "monster/smart-learn-types.h"
49 #include "mutation/mutation-calculator.h"
50 #include "mutation/mutation-flag-types.h"
51 #include "mutation/mutation-investor-remover.h"
52 #include "object-enchant/object-ego.h"
53 #include "object-enchant/special-object-flags.h"
54 #include "object-enchant/tr-types.h"
55 #include "object-enchant/trc-types.h"
56 #include "object-hook/hook-armor.h"
57 #include "object-hook/hook-checker.h"
58 #include "object-hook/hook-weapon.h"
59 #include "object/object-flags.h"
60 #include "object/object-info.h"
61 #include "object/object-mark-types.h"
62 #include "perception/object-perception.h"
63 #include "pet/pet-util.h"
64 #include "player-info/avatar.h"
65 #include "player/attack-defense-types.h"
66 #include "player/digestion-processor.h"
67 #include "player/mimic-info-table.h"
68 #include "player/patron.h"
69 #include "player/player-class.h"
70 #include "player/player-damage.h"
71 #include "player/player-move.h"
72 #include "player/player-personalities-types.h"
73 #include "player/player-personality.h"
74 #include "player/player-race-types.h"
75 #include "player/player-skill.h"
76 #include "player/player-status-flags.h"
77 #include "player/player-status-table.h"
78 #include "player/player-view.h"
79 #include "player/race-info-table.h"
80 #include "player/special-defense-types.h"
81 #include "realm/realm-hex-numbers.h"
82 #include "realm/realm-names-table.h"
83 #include "realm/realm-song-numbers.h"
84 #include "specific-object/bow.h"
85 #include "specific-object/torch.h"
86 #include "spell-realm/spells-hex.h"
87 #include "spell/range-calc.h"
88 #include "spell/spells-describer.h"
89 #include "spell/spells-execution.h"
90 #include "spell/spells-status.h"
91 #include "spell/technic-info-table.h"
92 #include "status/action-setter.h"
93 #include "status/base-status.h"
94 #include "sv-definition/sv-lite-types.h"
95 #include "sv-definition/sv-weapon-types.h"
96 #include "system/angband.h"
97 #include "system/floor-type-definition.h"
98 #include "term/screen-processor.h"
99 #include "util/bit-flags-calculator.h"
100 #include "util/quarks.h"
101 #include "util/string-processor.h"
102 #include "view/display-messages.h"
103 #include "world/world.h"
105 static bool is_martial_arts_mode(player_type *creature_ptr);
107 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr);
108 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr);
109 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
110 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
111 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
112 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
113 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
114 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
115 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
116 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
117 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
118 static s16b calc_num_blow(player_type *creature_ptr, int i);
119 static s16b calc_strength_addition(player_type *creature_ptr);
120 static s16b calc_intelligence_addition(player_type *creature_ptr);
121 static s16b calc_wisdom_addition(player_type *creature_ptr);
122 static s16b calc_dexterity_addition(player_type *creature_ptr);
123 static s16b calc_constitution_addition(player_type *creature_ptr);
124 static s16b calc_charisma_addition(player_type *creature_ptr);
125 static s16b calc_to_magic_chance(player_type *creature_ptr);
126 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
127 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_true_value);
128 static s16b calc_speed(player_type *creature_ptr);
129 static s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
130 static void calc_use_status(player_type *creature_ptr, int status);
131 static void calc_top_status(player_type *creature_ptr, int status);
132 static void calc_ind_status(player_type *creature_ptr, int status);
133 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
134 static void put_equipment_warning(player_type *creature_ptr);
136 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value);
137 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value);
139 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_true_value);
141 static s16b calc_to_damage_misc(player_type *creature_ptr);
142 static s16b calc_to_hit_misc(player_type *creature_ptr);
144 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
145 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot);
147 static int get_default_hand(player_type *creature_ptr);
149 /*** Player information ***/
152 * Static player info record
157 * Pointer to the player info
159 player_type *p_ptr = &p_body;
162 * Return alignment title
164 concptr your_alignment(player_type *creature_ptr)
166 if (creature_ptr->align > 150)
167 return _("大善", "Lawful");
168 else if (creature_ptr->align > 50)
169 return _("中善", "Good");
170 else if (creature_ptr->align > 10)
171 return _("小善", "Neutral Good");
172 else if (creature_ptr->align > -11)
173 return _("中立", "Neutral");
174 else if (creature_ptr->align > -51)
175 return _("小悪", "Neutral Evil");
176 else if (creature_ptr->align > -151)
177 return _("中悪", "Evil");
179 return _("大悪", "Chaotic");
183 * Return proficiency level of weapons and misc. skills (except riding)
185 int weapon_exp_level(int weapon_exp)
187 if (weapon_exp < WEAPON_EXP_BEGINNER)
188 return EXP_LEVEL_UNSKILLED;
189 else if (weapon_exp < WEAPON_EXP_SKILLED)
190 return EXP_LEVEL_BEGINNER;
191 else if (weapon_exp < WEAPON_EXP_EXPERT)
192 return EXP_LEVEL_SKILLED;
193 else if (weapon_exp < WEAPON_EXP_MASTER)
194 return EXP_LEVEL_EXPERT;
196 return EXP_LEVEL_MASTER;
200 * Return proficiency level of riding
202 int riding_exp_level(int riding_exp)
204 if (riding_exp < RIDING_EXP_BEGINNER)
205 return EXP_LEVEL_UNSKILLED;
206 else if (riding_exp < RIDING_EXP_SKILLED)
207 return EXP_LEVEL_BEGINNER;
208 else if (riding_exp < RIDING_EXP_EXPERT)
209 return EXP_LEVEL_SKILLED;
210 else if (riding_exp < RIDING_EXP_MASTER)
211 return EXP_LEVEL_EXPERT;
213 return EXP_LEVEL_MASTER;
217 * Return proficiency level of spells
219 int spell_exp_level(int spell_exp)
221 if (spell_exp < SPELL_EXP_BEGINNER)
222 return EXP_LEVEL_UNSKILLED;
223 else if (spell_exp < SPELL_EXP_SKILLED)
224 return EXP_LEVEL_BEGINNER;
225 else if (spell_exp < SPELL_EXP_EXPERT)
226 return EXP_LEVEL_SKILLED;
227 else if (spell_exp < SPELL_EXP_MASTER)
228 return EXP_LEVEL_EXPERT;
230 return EXP_LEVEL_MASTER;
234 * Delayed visual update
235 * Only used if update_view(), update_lite() or update_mon_lite() was called
237 static void delayed_visual_update(player_type *player_ptr)
239 floor_type *floor_ptr = player_ptr->current_floor_ptr;
240 for (int i = 0; i < floor_ptr->redraw_n; i++) {
241 POSITION y = floor_ptr->redraw_y[i];
242 POSITION x = floor_ptr->redraw_x[i];
244 g_ptr = &floor_ptr->grid_array[y][x];
245 if (!(g_ptr->info & CAVE_REDRAW))
248 if (g_ptr->info & CAVE_NOTE)
249 note_spot(player_ptr, y, x);
251 lite_spot(player_ptr, y, x);
253 update_monster(player_ptr, g_ptr->m_idx, FALSE);
255 g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
258 floor_ptr->redraw_n = 0;
262 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
263 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
264 * @return 重すぎるならばTRUE
266 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
268 int hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
269 return (hold < o_ptr->weight / 10);
273 * @brief プレイヤーの全ステータスを更新する /
274 * Calculate the players current "state", taking into account
275 * not only race/class intrinsics, but also objects being worn
276 * and temporary spell effects.
280 * See also calc_mana() and calc_hitpoints().
282 * Take note of the new "speed code", in particular, a very strong
283 * player will start slowing down as soon as he reaches 150 pounds,
284 * but not until he reaches 450 pounds will he be half as fast as
285 * a normal kobold. This both hurts and helps the player, hurts
286 * because in the old days a player could just avoid 300 pounds,
287 * and helps because now carrying 300 pounds is not very painful.
289 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
290 * damage, since that would affect non-combat things. These values
291 * are actually added in later, at the appropriate place.
293 * This function induces various "status" messages.
296 void calc_bonuses(player_type *creature_ptr)
298 int empty_hands_status = empty_hands(creature_ptr, TRUE);
301 /* Save the old vision stuff */
302 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
303 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
304 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
305 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
306 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
307 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
308 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
309 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
310 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
311 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
312 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
313 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
314 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
315 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
316 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
317 s16b old_speed = creature_ptr->pspeed;
319 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
320 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
322 creature_ptr->pass_wall = has_pass_wall(creature_ptr);
323 creature_ptr->kill_wall = has_kill_wall(creature_ptr);
324 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
325 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
326 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
327 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
328 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
329 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
330 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
331 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
332 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
333 creature_ptr->esp_human = has_esp_human(creature_ptr);
334 creature_ptr->esp_good = has_esp_good(creature_ptr);
335 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
336 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
337 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
338 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
339 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
340 creature_ptr->down_saving = has_down_saving(creature_ptr);
341 creature_ptr->yoiyami = has_no_ac(creature_ptr);
342 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
343 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
344 creature_ptr->reflect = has_reflect(creature_ptr);
345 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
346 creature_ptr->warning = has_warning(creature_ptr);
347 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
348 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
349 creature_ptr->sh_fire = has_sh_fire(creature_ptr);
350 creature_ptr->sh_elec = has_sh_elec(creature_ptr);
351 creature_ptr->sh_cold = has_sh_cold(creature_ptr);
352 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
353 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
354 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
355 creature_ptr->see_inv = has_see_inv(creature_ptr);
356 creature_ptr->free_act = has_free_act(creature_ptr);
357 creature_ptr->sustain_str = has_sustain_str(creature_ptr);
358 creature_ptr->sustain_int = has_sustain_int(creature_ptr);
359 creature_ptr->sustain_wis = has_sustain_wis(creature_ptr);
360 creature_ptr->sustain_dex = has_sustain_dex(creature_ptr);
361 creature_ptr->sustain_con = has_sustain_con(creature_ptr);
362 creature_ptr->sustain_chr = has_sustain_chr(creature_ptr);
363 creature_ptr->levitation = has_levitation(creature_ptr);
364 has_can_swim(creature_ptr);
365 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
366 creature_ptr->regenerate = has_regenerate(creature_ptr);
367 has_curses(creature_ptr);
368 creature_ptr->impact = has_impact(creature_ptr);
369 has_extra_blow(creature_ptr);
370 creature_ptr->resist_acid = has_resist_acid(creature_ptr);
371 creature_ptr->resist_elec = has_resist_elec(creature_ptr);
372 creature_ptr->resist_fire = has_resist_fire(creature_ptr);
373 creature_ptr->resist_cold = has_resist_cold(creature_ptr);
374 creature_ptr->resist_pois = has_resist_pois(creature_ptr);
375 creature_ptr->resist_conf = has_resist_conf(creature_ptr);
376 creature_ptr->resist_sound = has_resist_sound(creature_ptr);
377 creature_ptr->resist_lite = has_resist_lite(creature_ptr);
378 creature_ptr->resist_dark = has_resist_dark(creature_ptr);
379 creature_ptr->resist_chaos = has_resist_chaos(creature_ptr);
380 creature_ptr->resist_disen = has_resist_disen(creature_ptr);
381 creature_ptr->resist_shard = has_resist_shard(creature_ptr);
382 creature_ptr->resist_nexus = has_resist_nexus(creature_ptr);
383 creature_ptr->resist_blind = has_resist_blind(creature_ptr);
384 creature_ptr->resist_neth = has_resist_neth(creature_ptr);
385 creature_ptr->resist_time = has_resist_time(creature_ptr);
386 creature_ptr->resist_fear = has_resist_fear(creature_ptr);
387 creature_ptr->resist_time = has_resist_time(creature_ptr);
388 creature_ptr->resist_water = has_resist_water(creature_ptr);
390 creature_ptr->lite = has_lite(creature_ptr);
392 const player_race *tmp_rp_ptr;
393 if (creature_ptr->mimic_form)
394 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
396 tmp_rp_ptr = &race_info[creature_ptr->prace];
398 if (creature_ptr->special_defense & KAMAE_MASK) {
399 if (!(empty_hands_status & EMPTY_HAND_RARM)) {
400 set_action(creature_ptr, ACTION_NONE);
404 creature_ptr->stat_add[A_STR] = calc_strength_addition(creature_ptr);
405 creature_ptr->stat_add[A_INT] = calc_intelligence_addition(creature_ptr);
406 creature_ptr->stat_add[A_WIS] = calc_wisdom_addition(creature_ptr);
407 creature_ptr->stat_add[A_DEX] = calc_dexterity_addition(creature_ptr);
408 creature_ptr->stat_add[A_CON] = calc_constitution_addition(creature_ptr);
409 creature_ptr->stat_add[A_CHR] = calc_charisma_addition(creature_ptr);
410 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
411 creature_ptr->ac = calc_base_ac(creature_ptr);
412 creature_ptr->to_a = calc_to_ac(creature_ptr, TRUE);
413 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
414 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, FALSE);
416 for (int i = 0; i < A_MAX; i++) {
417 calc_top_status(creature_ptr, i);
418 calc_use_status(creature_ptr, i);
419 calc_ind_status(creature_ptr, i);
422 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
424 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
425 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
426 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
430 for (int i = 0; i < 2; i++) {
431 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
432 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
433 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
434 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_RARM + i);
435 creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_RARM + i);
438 creature_ptr->pspeed = calc_speed(creature_ptr);
439 creature_ptr->see_infra = calc_intra_vision(creature_ptr);
440 creature_ptr->skill_stl = calc_stealth(creature_ptr);
441 creature_ptr->skill_dis = calc_disarming(creature_ptr);
442 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
443 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
444 creature_ptr->skill_srh = calc_search(creature_ptr);
445 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
446 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
447 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
448 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
449 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, TRUE);
450 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, TRUE);
451 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, FALSE);
452 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, FALSE);
453 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_RARM, TRUE);
454 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_LARM, TRUE);
455 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_RARM, FALSE);
456 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_LARM, FALSE);
457 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, TRUE);
458 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, FALSE);
459 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
460 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
461 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
463 if (old_mighty_throw != creature_ptr->mighty_throw) {
464 creature_ptr->window |= PW_INVEN;
467 if (creature_ptr->telepathy != old_telepathy) {
468 creature_ptr->update |= (PU_MONSTERS);
471 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
472 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
473 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
474 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
475 creature_ptr->update |= (PU_MONSTERS);
478 if (creature_ptr->see_inv != old_see_inv) {
479 creature_ptr->update |= (PU_MONSTERS);
482 if (creature_ptr->pspeed != old_speed) {
483 creature_ptr->redraw |= (PR_SPEED);
486 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
487 creature_ptr->redraw |= (PR_ARMOR);
488 creature_ptr->window |= (PW_PLAYER);
491 if (current_world_ptr->character_xtra)
494 put_equipment_warning(creature_ptr);
497 static void calc_alignment(player_type *creature_ptr)
499 creature_ptr->align = 0;
500 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
501 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
504 m_ptr = &floor_ptr->m_list[m_idx];
505 if (!monster_is_valid(m_ptr))
507 r_ptr = &r_info[m_ptr->r_idx];
512 if (r_ptr->flags3 & RF3_GOOD)
513 creature_ptr->align += r_ptr->level;
514 if (r_ptr->flags3 & RF3_EVIL)
515 creature_ptr->align -= r_ptr->level;
518 if (creature_ptr->mimic_form) {
519 switch (creature_ptr->mimic_form) {
521 creature_ptr->align -= 200;
523 case MIMIC_DEMON_LORD:
524 creature_ptr->align -= 200;
528 switch (creature_ptr->prace) {
530 creature_ptr->align += 200;
533 creature_ptr->align -= 200;
538 for (int i = 0; i < 2; i++) {
539 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i))
541 if (creature_ptr->inventory_list[INVEN_RARM + i].name1 != ART_IRON_BALL)
543 creature_ptr->align -= 1000;
548 for (int i = 0; i < 8; i++) {
549 switch (creature_ptr->vir_types[i]) {
551 creature_ptr->align += creature_ptr->virtues[i] * 2;
560 creature_ptr->align -= creature_ptr->virtues[i];
563 creature_ptr->align += creature_ptr->virtues[i];
568 for (int i = 0; i < j; i++) {
569 if (creature_ptr->align > 0) {
570 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
571 if (creature_ptr->align < 0)
572 creature_ptr->align = 0;
573 } else if (creature_ptr->align < 0) {
574 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
575 if (creature_ptr->align > 0)
576 creature_ptr->align = 0;
582 * @brief プレイヤーの最大HPを計算する /
583 * Calculate the players (maximal) hit points
584 * Adjust current hitpoints if necessary
588 static void calc_hitpoints(player_type *creature_ptr)
590 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
591 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
594 if (creature_ptr->mimic_form) {
595 if (creature_ptr->pclass == CLASS_SORCERER)
596 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
598 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
599 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
602 if (creature_ptr->pclass == CLASS_SORCERER) {
603 if (creature_ptr->lev < 30)
604 mhp = (mhp * (45 + creature_ptr->lev) / 100);
606 mhp = (mhp * 75 / 100);
607 bonus = (bonus * 65 / 100);
612 if (creature_ptr->pclass == CLASS_BERSERKER) {
613 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
616 if (mhp < creature_ptr->lev + 1)
617 mhp = creature_ptr->lev + 1;
618 if (is_hero(creature_ptr))
620 if (is_shero(creature_ptr))
622 if (creature_ptr->tsuyoshi)
624 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
626 if (hex_spelling(creature_ptr, HEX_BUILDING))
628 if (creature_ptr->mhp == mhp)
631 if (creature_ptr->chp >= mhp) {
632 creature_ptr->chp = mhp;
633 creature_ptr->chp_frac = 0;
637 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
638 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
641 creature_ptr->mhp = mhp;
643 creature_ptr->redraw |= PR_HP;
644 creature_ptr->window |= PW_PLAYER;
648 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
649 * Calculate number of spells player should have, and forget,
650 * or remember, spells until that number is properly reflected.
653 * Note that this function induces various "status" messages,
654 * which must be bypasses until the character is created.
656 static void calc_spells(player_type *creature_ptr)
658 if (!mp_ptr->spell_book)
660 if (!current_world_ptr->character_generated)
662 if (current_world_ptr->character_xtra)
664 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
665 creature_ptr->new_spells = 0;
669 concptr p = spell_category_name(mp_ptr->spell_book);
670 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
674 int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
676 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
680 if (creature_ptr->pclass == CLASS_SAMURAI) {
682 } else if (creature_ptr->realm2 == REALM_NONE) {
683 num_allowed = (num_allowed + 1) / 2;
684 if (num_allowed > (32 + bonus))
685 num_allowed = 32 + bonus;
686 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
687 if (num_allowed > (96 + bonus))
688 num_allowed = 96 + bonus;
690 if (num_allowed > (80 + bonus))
691 num_allowed = 80 + bonus;
694 int num_boukyaku = 0;
695 for (int j = 0; j < 64; j++) {
696 if ((j < 32) ? (creature_ptr->spell_forgotten1 & (1L << j)) : (creature_ptr->spell_forgotten2 & (1L << (j - 32)))) {
701 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
702 for (int i = 63; i >= 0; i--) {
703 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
706 int j = creature_ptr->spell_order[i];
710 const magic_type *s_ptr;
711 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
713 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
715 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
717 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
719 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
721 if (s_ptr->slevel <= creature_ptr->lev)
724 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_learned1 & (1L << j)) : (creature_ptr->spell_learned2 & (1L << (j - 32)));
725 if (!is_spell_learned)
730 creature_ptr->spell_forgotten1 |= (1L << j);
731 which = creature_ptr->realm1;
733 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
734 which = creature_ptr->realm2;
738 creature_ptr->spell_learned1 &= ~(1L << j);
739 which = creature_ptr->realm1;
741 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
742 which = creature_ptr->realm2;
746 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
748 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
750 creature_ptr->new_spells++;
753 /* Forget spells if we know too many spells */
754 for (int i = 63; i >= 0; i--) {
755 if (creature_ptr->new_spells >= 0)
757 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
760 int j = creature_ptr->spell_order[i];
764 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_learned1 & (1L << j)) : (creature_ptr->spell_learned2 & (1L << (j - 32)));
765 if (!is_spell_learned)
770 creature_ptr->spell_forgotten1 |= (1L << j);
771 which = creature_ptr->realm1;
773 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
774 which = creature_ptr->realm2;
778 creature_ptr->spell_learned1 &= ~(1L << j);
779 which = creature_ptr->realm1;
781 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
782 which = creature_ptr->realm2;
786 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
788 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
790 creature_ptr->new_spells++;
793 /* Check for spells to remember */
794 for (int i = 0; i < 64; i++) {
795 if (creature_ptr->new_spells <= 0)
797 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
799 int j = creature_ptr->spell_order[i];
803 const magic_type *s_ptr;
804 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
806 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
808 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
810 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
812 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
814 if (s_ptr->slevel > creature_ptr->lev)
817 bool is_spell_learned = (j < 32) ? (creature_ptr->spell_forgotten1 & (1L << j)) : (creature_ptr->spell_forgotten2 & (1L << (j - 32)));
818 if (!is_spell_learned)
823 creature_ptr->spell_forgotten1 &= ~(1L << j);
824 which = creature_ptr->realm1;
826 creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
827 which = creature_ptr->realm2;
831 creature_ptr->spell_learned1 |= (1L << j);
832 which = creature_ptr->realm1;
834 creature_ptr->spell_learned2 |= (1L << (j - 32));
835 which = creature_ptr->realm2;
839 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
841 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
843 creature_ptr->new_spells--;
846 if (creature_ptr->realm2 == REALM_NONE) {
848 for (int j = 0; j < 32; j++) {
849 const magic_type *s_ptr;
850 if (!is_magic(creature_ptr->realm1))
851 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
853 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
855 if (s_ptr->slevel > creature_ptr->lev)
858 if (creature_ptr->spell_learned1 & (1L << j)) {
867 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
868 creature_ptr->new_spells = (s16b)k;
872 if (creature_ptr->new_spells < 0)
873 creature_ptr->new_spells = 0;
875 if (creature_ptr->old_spells == creature_ptr->new_spells)
878 if (creature_ptr->new_spells) {
880 if (creature_ptr->new_spells < 10) {
881 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
883 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
886 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
890 creature_ptr->old_spells = creature_ptr->new_spells;
891 creature_ptr->redraw |= PR_STUDY;
892 creature_ptr->window |= PW_OBJECT;
896 * @brief プレイヤーの最大MPを計算する /
897 * Calculate maximum mana. You do not need to know any spells.
898 * Note that mana is lowered by heavy (or inappropriate) armor.
901 * This function induces status messages.
903 static void calc_mana(player_type *creature_ptr)
905 if (!mp_ptr->spell_book)
909 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)) {
910 levels = creature_ptr->lev;
912 if (mp_ptr->spell_first > creature_ptr->lev) {
913 creature_ptr->msp = 0;
914 creature_ptr->redraw |= (PR_MANA);
918 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
922 if (creature_ptr->pclass == CLASS_SAMURAI) {
923 msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
925 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
927 msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
931 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
932 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
934 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
936 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
937 msp += msp * (25 + creature_ptr->lev) / 100;
940 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA) {
941 BIT_FLAGS flgs[TR_FLAG_SIZE];
942 creature_ptr->cumber_glove = FALSE;
944 o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
945 object_flags(creature_ptr, o_ptr, flgs);
946 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
947 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
948 creature_ptr->cumber_glove = TRUE;
953 creature_ptr->cumber_armor = FALSE;
956 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD)
957 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
958 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD)
959 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
960 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
961 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
962 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
963 cur_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
964 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
966 switch (creature_ptr->pclass) {
968 case CLASS_HIGH_MAGE:
969 case CLASS_BLUE_MAGE:
971 case CLASS_FORCETRAINER:
972 case CLASS_SORCERER: {
973 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
974 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
975 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
976 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
981 case CLASS_TOURIST: {
982 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
983 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight * 2 / 3;
984 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
985 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
988 case CLASS_MINDCRAFTER:
989 case CLASS_BEASTMASTER:
990 case CLASS_MIRROR_MASTER: {
991 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
992 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 2;
993 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
994 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 2;
1000 case CLASS_WARRIOR_MAGE: {
1001 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
1002 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 3;
1003 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
1004 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 3;
1008 case CLASS_CHAOS_WARRIOR: {
1009 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD)
1010 cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 5;
1011 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD)
1012 cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 5;
1020 int max_wgt = mp_ptr->spell_weight;
1021 if ((cur_wgt - max_wgt) > 0) {
1022 creature_ptr->cumber_armor = TRUE;
1023 switch (creature_ptr->pclass) {
1025 case CLASS_HIGH_MAGE:
1026 case CLASS_BLUE_MAGE: {
1027 msp -= msp * (cur_wgt - max_wgt) / 600;
1031 case CLASS_MINDCRAFTER:
1032 case CLASS_BEASTMASTER:
1034 case CLASS_FORCETRAINER:
1036 case CLASS_MIRROR_MASTER: {
1037 msp -= msp * (cur_wgt - max_wgt) / 800;
1040 case CLASS_SORCERER: {
1041 msp -= msp * (cur_wgt - max_wgt) / 900;
1047 case CLASS_RED_MAGE: {
1048 msp -= msp * (cur_wgt - max_wgt) / 1000;
1052 case CLASS_CHAOS_WARRIOR:
1053 case CLASS_WARRIOR_MAGE: {
1054 msp -= msp * (cur_wgt - max_wgt) / 1200;
1057 case CLASS_SAMURAI: {
1058 creature_ptr->cumber_armor = FALSE;
1062 msp -= msp * (cur_wgt - max_wgt) / 800;
1071 if (creature_ptr->msp != msp) {
1072 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
1073 creature_ptr->csp = msp;
1074 creature_ptr->csp_frac = 0;
1078 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
1079 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
1082 creature_ptr->msp = msp;
1083 creature_ptr->redraw |= (PR_MANA);
1084 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
1087 if (current_world_ptr->character_xtra)
1090 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
1091 if (creature_ptr->cumber_glove)
1092 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
1094 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
1096 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
1099 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
1102 if (creature_ptr->cumber_armor)
1103 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
1105 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
1107 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
1111 * @brief 装備中の射撃武器の威力倍率を返す /
1112 * calcurate the fire rate of target object
1113 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
1114 * @return 射撃倍率の値(100で1.00倍)
1116 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
1118 int extra_shots = 0;
1119 BIT_FLAGS flgs[TR_FLAG_SIZE];
1120 creature_ptr->num_fire = 100;
1121 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1123 q_ptr = &creature_ptr->inventory_list[i];
1130 object_flags(creature_ptr, q_ptr, flgs);
1131 if (has_flag(flgs, TR_XTRA_SHOTS))
1135 object_flags(creature_ptr, o_ptr, flgs);
1136 if (has_flag(flgs, TR_XTRA_SHOTS))
1140 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1144 num += (extra_shots * 100);
1146 tval_type tval_ammo = bow_tval_ammo(o_ptr);
1147 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1148 num += (creature_ptr->lev * 4);
1151 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1152 num += (creature_ptr->lev * 3);
1155 if (creature_ptr->pclass == CLASS_ARCHER) {
1156 if (tval_ammo == TV_ARROW)
1157 num += ((creature_ptr->lev * 5) + 50);
1158 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1159 num += (creature_ptr->lev * 4);
1162 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1163 num += (creature_ptr->lev * 2);
1166 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1167 num += (creature_ptr->lev * 4);
1175 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1179 * * 変異MUT3_INFRAVISによる加算(+3)
1180 * * 魔法効果tim_infraによる加算(+3)
1181 * * 装備がTR_INFRAフラグ持ちなら加算(+pval*1)
1183 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr)
1185 ACTION_SKILL_POWER pow;
1186 const player_race *tmp_rp_ptr;
1188 if (creature_ptr->mimic_form)
1189 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1191 tmp_rp_ptr = &race_info[creature_ptr->prace];
1193 pow = tmp_rp_ptr->infra;
1195 if (creature_ptr->muta3 & MUT3_INFRAVIS) {
1199 if (creature_ptr->tim_infra) {
1203 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1205 BIT_FLAGS flgs[TR_FLAG_SIZE];
1206 o_ptr = &creature_ptr->inventory_list[i];
1209 object_flags(creature_ptr, o_ptr, flgs);
1210 if (has_flag(flgs, TR_INFRA))
1219 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1225 * * 装備による修正(TR_STEALTHがあれば+pval*1)
1226 * * 変異MUT3_XTRA_NOISで減算(-3)
1227 * * 変異MUT3_MOTIONで加算(+1)
1228 * * 呪術を唱えていると減算(-(詠唱数+1))
1229 * * セクシーギャルでない影フェアリーがTRC_AGGRAVATE持ちの時、別処理でTRC_AGGRAVATEを無効にする代わりに減算(-3か3未満なら(現在値+2)/2)
1231 * * 忍者がheavy_armorならば減算(-レベル/10)
1232 * * 忍者がheavy_armorでなく適正な武器を持っていれば加算(+レベル/10)
1236 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr)
1238 ACTION_SKILL_POWER pow;
1239 const player_race *tmp_rp_ptr;
1241 if (creature_ptr->mimic_form)
1242 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1244 tmp_rp_ptr = &race_info[creature_ptr->prace];
1245 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1246 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1248 pow = 1 + tmp_rp_ptr->r_stl + c_ptr->c_stl + a_ptr->a_stl;
1249 pow += (c_ptr->x_stl * creature_ptr->lev / 10);
1251 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1253 BIT_FLAGS flgs[TR_FLAG_SIZE];
1254 o_ptr = &creature_ptr->inventory_list[i];
1257 object_flags(creature_ptr, o_ptr, flgs);
1258 if (has_flag(flgs, TR_STEALTH))
1262 if (creature_ptr->muta3 & MUT3_XTRA_NOIS) {
1265 if (creature_ptr->muta3 & MUT3_MOTION) {
1268 if (creature_ptr->realm1 == REALM_HEX) {
1269 if (hex_spelling_any(creature_ptr))
1270 pow -= (1 + casting_hex_num(creature_ptr));
1272 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
1273 pow = MIN(pow - 3, (pow + 2) / 2);
1276 if (is_shero(creature_ptr)) {
1280 if (creature_ptr->pclass == CLASS_NINJA && heavy_armor(creature_ptr)) {
1281 pow -= (creature_ptr->lev) / 10;
1282 } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
1283 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
1284 pow += (creature_ptr->lev) / 10;
1287 if (is_time_limit_stealth(creature_ptr))
1300 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1304 * * 職業と性格とレベルによる追加加算
1305 * * 器用さに応じたadj_dex_disテーブルによる加算
1306 * * 知力に応じたadj_int_disテーブルによる加算
1308 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1310 ACTION_SKILL_POWER pow;
1311 const player_race *tmp_rp_ptr;
1313 if (creature_ptr->mimic_form)
1314 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1316 tmp_rp_ptr = &race_info[creature_ptr->prace];
1317 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1318 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1320 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1321 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1322 pow += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
1323 pow += adj_int_dis[creature_ptr->stat_ind[A_INT]];
1329 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1333 * * 職業と性格とレベルによる追加加算
1334 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1335 * * 知力に応じたadj_int_devテーブルによる加算
1338 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1340 ACTION_SKILL_POWER pow;
1341 const player_race *tmp_rp_ptr;
1343 if (creature_ptr->mimic_form)
1344 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1346 tmp_rp_ptr = &race_info[creature_ptr->prace];
1347 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1348 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1350 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1351 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1353 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1355 BIT_FLAGS flgs[TR_FLAG_SIZE];
1356 o_ptr = &creature_ptr->inventory_list[i];
1359 object_flags(creature_ptr, o_ptr, flgs);
1360 if (has_flag(flgs, TR_MAGIC_MASTERY))
1361 pow += 8 * o_ptr->pval;
1364 pow += adj_int_dev[creature_ptr->stat_ind[A_INT]];
1366 if (is_shero(creature_ptr)) {
1374 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1378 * * 職業と性格とレベルによる追加加算
1379 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1380 * * 賢さによるadj_wis_savテーブル加算
1382 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1383 * * クターのつぶれ状態なら(10に上書き)
1384 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1385 * * 呪いのdown_savingがかかっているなら半減
1387 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1389 ACTION_SKILL_POWER pow;
1390 const player_race *tmp_rp_ptr;
1392 if (creature_ptr->mimic_form)
1393 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1395 tmp_rp_ptr = &race_info[creature_ptr->prace];
1396 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1397 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1399 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1400 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1402 if (creature_ptr->muta3 & MUT3_MAGIC_RES)
1403 pow += (15 + (creature_ptr->lev / 5));
1405 pow += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
1407 if (is_shero(creature_ptr))
1410 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1411 pow = 90 + creature_ptr->lev;
1413 if (creature_ptr->tsubureru)
1416 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1417 pow = 95 + creature_ptr->lev;
1419 if (creature_ptr->down_saving)
1427 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1432 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1434 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1436 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1438 ACTION_SKILL_POWER pow;
1439 const player_race *tmp_rp_ptr;
1441 if (creature_ptr->mimic_form)
1442 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1444 tmp_rp_ptr = &race_info[creature_ptr->prace];
1445 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1446 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1448 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1449 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1451 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1453 BIT_FLAGS flgs[TR_FLAG_SIZE];
1454 o_ptr = &creature_ptr->inventory_list[i];
1457 object_flags(creature_ptr, o_ptr, flgs);
1458 if (has_flag(flgs, TR_SEARCH))
1459 pow += (o_ptr->pval * 5);
1462 if (creature_ptr->muta3 & MUT3_XTRA_EYES) {
1466 if (is_shero(creature_ptr)) {
1475 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1480 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1482 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1484 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1486 ACTION_SKILL_POWER pow;
1487 const player_race *tmp_rp_ptr;
1489 if (creature_ptr->mimic_form)
1490 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1492 tmp_rp_ptr = &race_info[creature_ptr->prace];
1493 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1494 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1496 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1497 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1499 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1501 BIT_FLAGS flgs[TR_FLAG_SIZE];
1502 o_ptr = &creature_ptr->inventory_list[i];
1505 object_flags(creature_ptr, o_ptr, flgs);
1506 if (has_flag(flgs, TR_SEARCH))
1507 pow += (o_ptr->pval * 5);
1510 if (is_shero(creature_ptr)) {
1514 if (creature_ptr->muta3 & MUT3_XTRA_EYES) {
1523 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1526 * * 種族/職業/性格による加算とレベルによる追加加算
1528 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1530 ACTION_SKILL_POWER pow;
1531 const player_race *tmp_rp_ptr;
1532 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1533 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1535 if (creature_ptr->mimic_form)
1536 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1538 tmp_rp_ptr = &race_info[creature_ptr->prace];
1540 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1541 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1547 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1550 * * 種族/職業/性格による加算とレベルによる追加加算
1552 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1554 ACTION_SKILL_POWER pow;
1555 const player_race *tmp_rp_ptr;
1556 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1557 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1559 if (creature_ptr->mimic_form)
1560 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1562 tmp_rp_ptr = &race_info[creature_ptr->prace];
1564 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1565 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1571 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1574 * * 種族/職業/性格による加算とレベルによる追加加算
1577 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1579 ACTION_SKILL_POWER pow;
1580 const player_race *tmp_rp_ptr;
1581 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1582 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1584 if (creature_ptr->mimic_form)
1585 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1587 tmp_rp_ptr = &race_info[creature_ptr->prace];
1589 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1590 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1592 if (is_shero(creature_ptr)) {
1601 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1612 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1615 BIT_FLAGS flgs[TR_FLAG_SIZE];
1617 ACTION_SKILL_POWER pow;
1621 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_RARM].k_idx) {
1622 pow += creature_ptr->lev * 10;
1625 if (is_shero(creature_ptr))
1628 pow += adj_str_dig[creature_ptr->stat_ind[A_STR]];
1630 if (creature_ptr->pclass == CLASS_BERSERKER)
1631 pow += (100 + creature_ptr->lev * 8);
1633 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1634 o_ptr = &creature_ptr->inventory_list[i];
1637 object_flags(creature_ptr, o_ptr, flgs);
1638 if (has_flag(flgs, TR_TUNNEL))
1639 pow += (o_ptr->pval * 20);
1642 for (int i = 0; i < 2; i++) {
1643 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1644 if (has_melee_weapon(creature_ptr, INVEN_RARM + i) && !creature_ptr->heavy_wield[i]) {
1645 pow += (o_ptr->weight / 10);
1649 if (is_shero(creature_ptr)) {
1659 static bool is_martial_arts_mode(player_type *creature_ptr)
1661 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1662 && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM) && !has_left_hand_weapon(creature_ptr);
1665 static s16b calc_num_blow(player_type *creature_ptr, int i)
1668 BIT_FLAGS flgs[TR_FLAG_SIZE];
1671 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1672 object_flags(creature_ptr, o_ptr, flgs);
1673 creature_ptr->heavy_wield[i] = FALSE;
1674 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1677 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
1678 creature_ptr->heavy_wield[i] = TRUE;
1681 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1682 int str_index, dex_index;
1683 int num = 0, wgt = 0, mul = 0, div = 0;
1685 num = class_info[creature_ptr->pclass].num;
1686 wgt = class_info[creature_ptr->pclass].wgt;
1687 mul = class_info[creature_ptr->pclass].mul;
1689 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1695 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1701 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1702 str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
1704 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1706 if (creature_ptr->pclass == CLASS_NINJA)
1707 str_index = MAX(0, str_index - 1);
1711 dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
1715 num_blow = blows_table[str_index][dex_index];
1717 num_blow = (s16b)num;
1719 num_blow += (s16b)creature_ptr->extra_blows[i];
1720 if (creature_ptr->pclass == CLASS_WARRIOR)
1721 num_blow += (creature_ptr->lev / 40);
1722 else if (creature_ptr->pclass == CLASS_BERSERKER)
1723 num_blow += (creature_ptr->lev / 23);
1724 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
1727 if (creature_ptr->special_defense & KATA_FUUJIN)
1730 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1740 /* Different calculation for monks with empty hands */
1741 if (is_martial_arts_mode(creature_ptr)) {
1742 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
1745 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1755 MAGIC_NUM1 current_ki = get_current_ki(creature_ptr);
1756 if (current_ki != i) {
1757 creature_ptr->to_d[i] += current_ki / 5;
1758 creature_ptr->dis_to_d[i] += current_ki / 5;
1777 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1780 if (creature_ptr->special_defense & KAMAE_GENBU) {
1781 creature_ptr->to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
1782 creature_ptr->dis_to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
1784 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1788 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1789 creature_ptr->to_h[i] -= (creature_ptr->lev / 3);
1790 creature_ptr->to_d[i] -= (creature_ptr->lev / 6);
1792 creature_ptr->dis_to_h[i] -= (creature_ptr->lev / 3);
1793 creature_ptr->dis_to_d[i] -= (creature_ptr->lev / 6);
1797 num_blow += 1 + creature_ptr->extra_blows[0];
1800 if (has_not_ninja_weapon(creature_ptr, i)) {
1811 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1815 * * エントは別途レベル26,41,46到達ごとに加算(+1)
1816 * * 装備がTR_STRフラグを持っていれば加算(+pval*1)
1822 * * 変異MUT3_HYPER_STRで加算(+4)
1823 * * 変異MUT3_PUNYで減算(-4)
1824 * * ネオ・つよしスペシャル中で加算(+4)
1826 static s16b calc_strength_addition(player_type *creature_ptr)
1829 const player_race *tmp_rp_ptr;
1830 if (creature_ptr->mimic_form)
1831 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1833 tmp_rp_ptr = &race_info[creature_ptr->prace];
1834 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1835 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1836 pow = tmp_rp_ptr->r_adj[A_STR] + c_ptr->c_adj[A_STR] + a_ptr->a_adj[A_STR];
1838 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
1839 if (creature_ptr->lev > 25)
1841 if (creature_ptr->lev > 40)
1843 if (creature_ptr->lev > 45)
1847 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1849 BIT_FLAGS flgs[TR_FLAG_SIZE];
1850 o_ptr = &creature_ptr->inventory_list[i];
1853 object_flags(creature_ptr, o_ptr, flgs);
1854 if (has_flag(flgs, TR_STR)) {
1859 if (creature_ptr->realm1 == REALM_HEX) {
1860 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) {
1863 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
1868 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1872 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
1874 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1878 if (creature_ptr->muta3) {
1880 if (creature_ptr->muta3 & MUT3_HYPER_STR) {
1884 if (creature_ptr->muta3 & MUT3_PUNY) {
1889 if (creature_ptr->tsuyoshi) {
1897 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1901 * * 装備がTR_INTフラグを持っていれば加算(+pval*1)
1907 * * 変異MUT3_HYPER_INTで加算(+4)
1908 * * 変異MUT3_MORONICで減算(-4)
1910 s16b calc_intelligence_addition(player_type *creature_ptr)
1913 const player_race *tmp_rp_ptr;
1914 if (creature_ptr->mimic_form)
1915 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1917 tmp_rp_ptr = &race_info[creature_ptr->prace];
1918 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1919 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1920 pow = tmp_rp_ptr->r_adj[A_INT] + c_ptr->c_adj[A_INT] + a_ptr->a_adj[A_INT];
1922 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1924 BIT_FLAGS flgs[TR_FLAG_SIZE];
1925 o_ptr = &creature_ptr->inventory_list[i];
1928 object_flags(creature_ptr, o_ptr, flgs);
1929 if (has_flag(flgs, TR_INT)) {
1934 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1938 if (creature_ptr->special_defense & KAMAE_GENBU) {
1940 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
1944 if (creature_ptr->muta3) {
1945 if (creature_ptr->muta3 & MUT3_HYPER_INT) {
1949 if (creature_ptr->muta3 & MUT3_MORONIC) {
1959 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1963 * * 装備がTR_WISフラグを持っていれば加算(+pval*1)
1969 * * 変異MUT3_HYPER_INTで加算(+4)
1970 * * 変異MUT3_MORONICで減算(-4)
1972 static s16b calc_wisdom_addition(player_type *creature_ptr)
1975 const player_race *tmp_rp_ptr;
1976 if (creature_ptr->mimic_form)
1977 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1979 tmp_rp_ptr = &race_info[creature_ptr->prace];
1980 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1981 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1982 pow = tmp_rp_ptr->r_adj[A_WIS] + c_ptr->c_adj[A_WIS] + a_ptr->a_adj[A_WIS];
1984 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1986 BIT_FLAGS flgs[TR_FLAG_SIZE];
1987 o_ptr = &creature_ptr->inventory_list[i];
1990 object_flags(creature_ptr, o_ptr, flgs);
1991 if (has_flag(flgs, TR_WIS)) {
1996 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2000 if (creature_ptr->special_defense & KAMAE_GENBU) {
2002 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2006 if (creature_ptr->muta3) {
2008 if (creature_ptr->muta3 & MUT3_HYPER_INT) {
2012 if (creature_ptr->muta3 & MUT3_MORONIC) {
2022 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2026 * * エントは別途レベル26,41,46到達ごとに減算(-1)
2027 * * 装備がTR_DEXフラグを持っていれば加算(+pval*1)
2033 * * 変異MUT3_IRON_SKINで減算(-1)
2034 * * 変異MUT3_LIMBERで加算(+3)
2035 * * 変異MUT3_ARTHRITISで減算(-3)
2037 static s16b calc_dexterity_addition(player_type *creature_ptr)
2040 const player_race *tmp_rp_ptr;
2041 if (creature_ptr->mimic_form)
2042 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2044 tmp_rp_ptr = &race_info[creature_ptr->prace];
2045 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2046 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2047 pow = tmp_rp_ptr->r_adj[A_DEX] + c_ptr->c_adj[A_DEX] + a_ptr->a_adj[A_DEX];
2049 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2050 if (creature_ptr->lev > 25)
2052 if (creature_ptr->lev > 40)
2054 if (creature_ptr->lev > 45)
2058 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2060 BIT_FLAGS flgs[TR_FLAG_SIZE];
2061 o_ptr = &creature_ptr->inventory_list[i];
2064 object_flags(creature_ptr, o_ptr, flgs);
2065 if (has_flag(flgs, TR_DEX)) {
2070 if (creature_ptr->realm1 == REALM_HEX) {
2071 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2076 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2080 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2082 } else if (creature_ptr->special_defense & KAMAE_GENBU) {
2084 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2088 if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
2092 if (creature_ptr->muta3 & MUT3_LIMBER) {
2096 if (creature_ptr->muta3 & MUT3_ARTHRITIS) {
2105 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2109 * * エントは別途レベル26,41,46到達ごとに加算(+1)
2110 * * 装備がTR_CONフラグを持っていれば加算(+pval*1)
2116 * * 変異MUT3_RESILIENTで加算(+4)
2117 * * 変異MUT3_ALBINOで減算(-4)
2118 * * 変異MUT3_XTRA_FATで加算(+2)
2119 * * 変異MUT3_FLESH_ROTで減算(-2)
2120 * * ネオ・つよしスペシャル中で加算(+4)
2122 static s16b calc_constitution_addition(player_type *creature_ptr)
2125 const player_race *tmp_rp_ptr;
2126 if (creature_ptr->mimic_form)
2127 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2129 tmp_rp_ptr = &race_info[creature_ptr->prace];
2130 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2131 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2132 pow = tmp_rp_ptr->r_adj[A_CON] + c_ptr->c_adj[A_CON] + a_ptr->a_adj[A_CON];
2134 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2135 if (creature_ptr->lev > 25)
2137 if (creature_ptr->lev > 40)
2139 if (creature_ptr->lev > 45)
2143 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2145 BIT_FLAGS flgs[TR_FLAG_SIZE];
2146 o_ptr = &creature_ptr->inventory_list[i];
2149 object_flags(creature_ptr, o_ptr, flgs);
2150 if (has_flag(flgs, TR_CON))
2154 if (creature_ptr->realm1 == REALM_HEX) {
2155 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2160 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2164 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2166 } else if (creature_ptr->special_defense & KAMAE_GENBU) {
2168 } else if (creature_ptr->special_defense & KAMAE_SUZAKU) {
2172 if (creature_ptr->muta3) {
2173 if (creature_ptr->muta3 & MUT3_RESILIENT) {
2177 if (creature_ptr->muta3 & MUT3_ALBINO) {
2181 if (creature_ptr->muta3 & MUT3_XTRA_FAT) {
2185 if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
2190 if (creature_ptr->tsuyoshi) {
2199 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2203 * * 装備がTR_CHRフラグを持っていれば加算(+pval*1)
2206 * * 変異MUT3_FLESH_ROTで減算(-1)
2207 * * 変異MUT3_SILLY_VOIで減算(-4)
2208 * * 変異MUT3_BLANK_FACで減算(-1)
2209 * * 変異MUT3_WART_SKINで減算(-2)
2210 * * 変異MUT3_SCALESで減算(-1)
2211 * * 変異MUT3_ILL_NORMで0固定(後で個体値のみ上書きを行う)
2213 static s16b calc_charisma_addition(player_type *creature_ptr)
2216 const player_race *tmp_rp_ptr;
2217 if (creature_ptr->mimic_form)
2218 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2220 tmp_rp_ptr = &race_info[creature_ptr->prace];
2221 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2222 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2223 pow = tmp_rp_ptr->r_adj[A_CHR] + c_ptr->c_adj[A_CHR] + a_ptr->a_adj[A_CHR];
2225 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2227 BIT_FLAGS flgs[TR_FLAG_SIZE];
2228 o_ptr = &creature_ptr->inventory_list[i];
2231 object_flags(creature_ptr, o_ptr, flgs);
2232 if (has_flag(flgs, TR_CHR))
2236 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2240 if (creature_ptr->muta3) {
2241 if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
2244 if (creature_ptr->muta3 & MUT3_SILLY_VOI) {
2247 if (creature_ptr->muta3 & MUT3_BLANK_FAC) {
2250 if (creature_ptr->muta3 & MUT3_WART_SKIN) {
2253 if (creature_ptr->muta3 & MUT3_SCALES) {
2256 if (creature_ptr->muta3 & MUT3_ILL_NORM) {
2266 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2269 * * 性格なまけものなら加算(+10)
2271 * * 性格ちからじまんとがまんづよいなら加算(+1)
2272 * * 性格チャージマンなら加算(+5)
2273 * * 装備品にTRC_LOW_MAGICがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
2275 static s16b calc_to_magic_chance(player_type *creature_ptr)
2279 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
2281 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
2283 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
2285 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
2288 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2290 BIT_FLAGS flgs[TR_FLAG_SIZE];
2291 o_ptr = &creature_ptr->inventory_list[i];
2294 object_flags(creature_ptr, o_ptr, flgs);
2295 if (o_ptr->curse_flags & TRC_LOW_MAGIC) {
2296 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
2306 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
2308 ARMOUR_CLASS ac = 0;
2309 if (creature_ptr->yoiyami)
2312 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2314 o_ptr = &creature_ptr->inventory_list[i];
2320 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_RARM])
2321 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_LARM])) {
2322 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2328 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_true_value)
2330 ARMOUR_CLASS ac = 0;
2331 if (creature_ptr->yoiyami)
2334 ac += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2336 if (creature_ptr->mimic_form) {
2337 switch (creature_ptr->mimic_form) {
2341 case MIMIC_DEMON_LORD:
2349 if (creature_ptr->pclass == CLASS_BERSERKER) {
2350 ac += 10 + creature_ptr->lev / 2;
2352 if (creature_ptr->pclass == CLASS_SORCERER) {
2356 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2358 o_ptr = &creature_ptr->inventory_list[i];
2361 if (is_true_value || object_is_known(o_ptr))
2364 if (o_ptr->curse_flags & TRC_LOW_AC) {
2365 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
2366 if (is_true_value || object_is_fully_known(o_ptr))
2369 if (is_true_value || object_is_fully_known(o_ptr))
2374 if ((i == INVEN_LARM) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI))) {
2379 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
2380 ac += 10 + (creature_ptr->lev * 2 / 5);
2383 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2387 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI)) {
2391 if (creature_ptr->muta3 & MUT3_WART_SKIN) {
2395 if (creature_ptr->muta3 & MUT3_SCALES) {
2399 if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
2403 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
2404 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
2405 ac += (creature_ptr->lev * 3) / 2;
2407 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
2408 ac += ((creature_ptr->lev - 13) / 3);
2410 if (!(creature_ptr->inventory_list[INVEN_LARM].k_idx) && (creature_ptr->lev > 10)) {
2411 ac += ((creature_ptr->lev - 8) / 3);
2413 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
2414 ac += (creature_ptr->lev - 2) / 3;
2416 if (!(creature_ptr->inventory_list[INVEN_HANDS].k_idx)) {
2417 ac += (creature_ptr->lev / 2);
2419 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
2420 ac += (creature_ptr->lev / 3);
2424 if (creature_ptr->realm1 == REALM_HEX) {
2425 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
2429 for (inventory_slot_type i = INVEN_RARM; i <= INVEN_FEET; i++) {
2430 object_type *o_ptr = &creature_ptr->inventory_list[i];
2433 if (!object_is_armour(creature_ptr, o_ptr))
2435 if (!object_is_cursed(o_ptr))
2437 if (o_ptr->curse_flags & TRC_CURSED)
2439 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2441 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2446 if (creature_ptr->special_defense & KAMAE_BYAKKO) {
2448 } else if (creature_ptr->special_defense & KAMAE_SEIRYU) {
2450 } else if (creature_ptr->special_defense & KATA_KOUKIJIN) {
2454 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
2456 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
2460 if (is_blessed(creature_ptr)) {
2464 if (is_shero(creature_ptr)) {
2468 if (creature_ptr->pclass == CLASS_NINJA) {
2469 if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
2470 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
2471 ac += creature_ptr->lev / 2 + 5;
2480 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2485 * ** クラッコンと妖精に加算(+レベル/10)
2486 * ** 悪魔変化/吸血鬼変化で加算(+3)
2488 * ** 装備品にTR_SPEEDがあれば加算(+pval+1
2489 * ** 忍者の装備が重ければ減算(-レベル/10)
2490 * ** 忍者の装備が適正ならば加算(+3)さらにクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2491 * ** 錬気術師で装備が重くなくクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2492 * ** 狂戦士なら加算(+3),レベル20/30/40/50ごとに+1
2493 * ** いかさまでクラッコン/妖精以外なら加算(+5+レベル/10)
2496 * ** 呪術「衝撃のクローク」で加算(+3)
2499 * ** 変異MUT3_XTRA_FATなら減算(-2)
2500 * ** 変異MUT3_XTRA_LEGなら加算(+3)
2501 * ** 変異MUT3_SHORT_LEGなら減算(-3)
2502 * ** マーフォークがFF_WATER地形にいれば加算(+2+レベル/10)
2503 * ** そうでなく浮遊を持っていないなら減算(-2)
2504 * ** 棘セット装備中ならば加算(+7)
2505 * * 騎乗中ならばモンスターの加速に準拠、ただし騎乗技能値とモンスターレベルによるキャップ処理あり
2507 * * 光速移動中かこの時点で+99を超えていたら+99にキャップ
2510 static s16b calc_speed(player_type *creature_ptr)
2512 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2513 feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
2517 int j = creature_ptr->total_weight;
2520 if (!creature_ptr->riding) {
2521 count = (int)weight_limit(creature_ptr);
2523 const player_race *tmp_rp_ptr;
2524 if (creature_ptr->mimic_form)
2525 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2527 tmp_rp_ptr = &race_info[creature_ptr->prace];
2529 if (is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE))
2530 pow += (creature_ptr->lev) / 10;
2532 if (creature_ptr->mimic_form) {
2533 switch (creature_ptr->mimic_form) {
2537 case MIMIC_DEMON_LORD:
2546 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2547 object_type *o_ptr = &creature_ptr->inventory_list[i];
2548 BIT_FLAGS flgs[TR_FLAG_SIZE];
2549 object_flags(creature_ptr, o_ptr, flgs);
2553 if (has_flag(flgs, TR_SPEED))
2557 if (creature_ptr->pclass == CLASS_NINJA) {
2558 if (heavy_armor(creature_ptr)) {
2559 pow -= (creature_ptr->lev) / 10;
2560 } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
2561 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(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;
2569 if (creature_ptr->pclass == CLASS_FORCETRAINER && !(heavy_armor(creature_ptr))) {
2570 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2571 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2572 pow += (creature_ptr->lev) / 10;
2575 if (creature_ptr->pclass == CLASS_BERSERKER) {
2577 if (creature_ptr->lev > 29)
2579 if (creature_ptr->lev > 39)
2581 if (creature_ptr->lev > 44)
2583 if (creature_ptr->lev > 49)
2587 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN && creature_ptr->prace != RACE_KLACKON && creature_ptr->prace != RACE_SPRITE) {
2588 pow += (creature_ptr->lev) / 10 + 5;
2591 if (is_fast(creature_ptr)) {
2595 if (creature_ptr->slow) {
2599 if (creature_ptr->realm1 == REALM_HEX) {
2600 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) {
2605 if (creature_ptr->food >= PY_FOOD_MAX)
2608 if (creature_ptr->special_defense & KAMAE_SUZAKU)
2611 if (creature_ptr->muta3) {
2613 if (creature_ptr->muta3 & MUT3_XTRA_FAT) {
2617 if (creature_ptr->muta3 & MUT3_XTRA_LEGS) {
2621 if (creature_ptr->muta3 & MUT3_SHORT_LEG) {
2626 if (creature_ptr->prace == RACE_MERFOLK) {
2627 if (has_flag(f_ptr->flags, FF_WATER)) {
2628 pow += (2 + creature_ptr->lev / 10);
2629 } else if (!creature_ptr->levitation) {
2634 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
2635 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2641 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
2642 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2643 SPEED speed = riding_m_ptr->mspeed;
2645 if (riding_m_ptr->mspeed > 110) {
2646 pow = 110 + (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2653 pow += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2655 if (monster_fast_remaining(riding_m_ptr))
2657 if (monster_slow_remaining(riding_m_ptr))
2660 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED)
2661 j += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2663 count = 1500 + riding_r_ptr->level * 25;
2665 pow -= ((j - count) / (count / 5));
2668 if (creature_ptr->action == ACTION_SEARCH)
2671 /* Maximum speed is (+99). (internally it's 110 + 99) */
2672 /* Temporary lightspeed forces to be maximum speed */
2673 if ((creature_ptr->lightspeed && !creature_ptr->riding) || (pow > 209)) {
2677 /* Minimum speed is (-99). (internally it's 110 - 99) */
2685 * @brief 二刀流ペナルティ量計算
2686 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2687 * @param slot ペナルティ量を計算する武器スロット
2693 * * マンゴーシュ/脇差を左に装備した場合の軽減
2697 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
2700 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
2701 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
2702 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN)) {
2703 penalty = penalty / 2 - 5;
2705 if (creature_ptr->easy_2weapon) {
2708 } else if ((creature_ptr->inventory_list[INVEN_LARM].tval == TV_SWORD)
2709 && ((creature_ptr->inventory_list[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (creature_ptr->inventory_list[INVEN_LARM].sval == SV_WAKIZASHI))) {
2710 penalty = MAX(0, penalty - 10);
2712 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI)) {
2713 penalty = MIN(0, penalty);
2715 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty > 0))
2717 if ((creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty > 0))
2721 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
2724 return (s16b)penalty;
2727 static void calc_ind_status(player_type *creature_ptr, int status)
2730 if (creature_ptr->stat_use[status] <= 18)
2731 ind = (creature_ptr->stat_use[status] - 3);
2732 else if (creature_ptr->stat_use[status] <= 18 + 219)
2733 ind = (15 + (creature_ptr->stat_use[status] - 18) / 10);
2737 if (creature_ptr->stat_ind[status] == ind)
2740 creature_ptr->stat_ind[status] = (s16b)ind;
2741 if (status == A_CON) {
2742 creature_ptr->update |= (PU_HP);
2743 } else if (status == A_INT) {
2744 if (mp_ptr->spell_stat == A_INT) {
2745 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2747 } else if (status == A_WIS) {
2748 if (mp_ptr->spell_stat == A_WIS) {
2749 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2751 } else if (status == A_CHR) {
2752 if (mp_ptr->spell_stat == A_CHR) {
2753 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2757 creature_ptr->window |= (PW_PLAYER);
2760 static void calc_use_status(player_type *creature_ptr, int status)
2762 int use = modify_stat_value(creature_ptr->stat_cur[status], creature_ptr->stat_add[status]);
2764 if ((status == A_CHR) && (creature_ptr->muta3 & MUT3_ILL_NORM)) {
2765 /* 10 to 18/90 charisma, guaranteed, based on level */
2766 if (use < 8 + 2 * creature_ptr->lev) {
2767 use = 8 + 2 * creature_ptr->lev;
2771 if (creature_ptr->stat_use[status] != use) {
2772 creature_ptr->stat_use[status] = (s16b)use;
2773 creature_ptr->redraw |= (PR_STATS);
2774 creature_ptr->window |= (PW_PLAYER);
2778 static void calc_top_status(player_type *creature_ptr, int status)
2780 int top = modify_stat_value(creature_ptr->stat_max[status], creature_ptr->stat_add[status]);
2782 if (creature_ptr->stat_top[status] != top) {
2783 creature_ptr->stat_top[status] = (s16b)top;
2784 creature_ptr->redraw |= (PR_STATS);
2785 creature_ptr->window |= (PW_PLAYER);
2789 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
2791 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2792 if (!creature_ptr->riding)
2797 creature_ptr->riding_ryoute = FALSE;
2799 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
2800 creature_ptr->riding_ryoute = TRUE;
2801 else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) {
2802 switch (creature_ptr->pclass) {
2804 case CLASS_FORCETRAINER:
2805 case CLASS_BERSERKER:
2806 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM)
2807 && !has_melee_weapon(creature_ptr, INVEN_LARM))
2808 creature_ptr->riding_ryoute = TRUE;
2813 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2814 if (creature_ptr->tval_ammo != TV_ARROW)
2817 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2823 if (creature_ptr->tval_ammo == TV_BOLT)
2829 void put_equipment_warning(player_type *creature_ptr)
2831 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
2832 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
2834 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2835 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
2836 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2838 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2840 creature_ptr->old_heavy_shoot = heavy_shoot;
2843 for (int i = 0; i < 2; i++) {
2844 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
2845 if (creature_ptr->heavy_wield[i]) {
2846 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2847 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2848 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2849 } else if (creature_ptr->heavy_wield[1 - i]) {
2850 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
2852 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2855 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
2858 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
2859 if (creature_ptr->riding_wield[i]) {
2860 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2861 } else if (!creature_ptr->riding) {
2862 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
2863 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2864 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2867 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
2870 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
2873 if (creature_ptr->icky_wield[i]) {
2874 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2875 if (current_world_ptr->is_loading_now) {
2876 chg_virtue(creature_ptr, V_FAITH, -1);
2878 } else if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
2879 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2881 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2884 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
2887 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
2888 if (creature_ptr->riding_ryoute) {
2890 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2892 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
2896 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2898 msg_print("You began to control the pet you're riding with one hand.");
2902 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
2905 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
2906 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
2907 if (heavy_armor(creature_ptr)) {
2908 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2909 if (current_world_ptr->is_loading_now) {
2910 chg_virtue(creature_ptr, V_HARMONY, -1);
2913 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2916 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
2920 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value)
2922 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2923 int id = slot - INVEN_RARM;
2924 BIT_FLAGS flgs[TR_FLAG_SIZE];
2925 object_flags(creature_ptr, o_ptr, flgs);
2928 damage += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2930 if (is_shero(creature_ptr)) {
2931 damage += 3 + (creature_ptr->lev / 5);
2934 if (creature_ptr->stun > 50) {
2936 } else if (creature_ptr->stun) {
2940 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2942 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2943 damage += creature_ptr->lev / 6;
2944 if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2945 damage += creature_ptr->lev / 6;
2947 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2948 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2955 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2956 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2957 if (o_ptr->curse_flags & (TRC_CURSED)) {
2960 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) {
2963 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) {
2969 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
2971 o_ptr = &creature_ptr->inventory_list[i];
2972 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
2973 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2976 if (!object_is_known(o_ptr) && !is_true_value)
2978 bonus_to_d = o_ptr->to_d;
2980 if (creature_ptr->pclass == CLASS_NINJA) {
2981 if (o_ptr->to_d > 0)
2982 bonus_to_d = (o_ptr->to_d + 1) / 2;
2985 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
2986 damage += (s16b)bonus_to_d;
2987 } else if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) {
2989 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2991 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2992 } else if (id == get_default_hand(creature_ptr)) {
2993 damage += (s16b)bonus_to_d;
2997 if (get_default_hand(creature_ptr) == id) {
2998 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
2999 || !has_disable_two_handed_bonus(creature_ptr, 0)) {
3001 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
3002 damage += MAX(bonus_to_d, 1);
3006 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3007 damage += (creature_ptr->lev / 6);
3013 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value)
3015 int id = slot - INVEN_RARM;
3016 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3017 BIT_FLAGS flgs[TR_FLAG_SIZE];
3018 object_flags(creature_ptr, o_ptr, flgs);
3019 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + id].tval - TV_WEAPON_BEGIN;
3020 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + id].sval;
3024 hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3025 hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3027 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
3029 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
3030 hit += creature_ptr->lev / 5;
3031 if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
3032 hit += creature_ptr->lev / 5;
3034 } else if (creature_ptr->pclass == CLASS_SORCERER) {
3035 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
3042 if ((object_is_fully_known(o_ptr) || is_true_value) && o_ptr->curse_flags & TRC_LOW_MELEE) {
3043 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
3050 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
3051 if (o_ptr->curse_flags & (TRC_CURSED)) {
3054 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) {
3057 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) {
3060 if (o_ptr->curse_flags & (TRC_TY_CURSE)) {
3065 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
3066 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3069 if (is_blessed(creature_ptr)) {
3073 if (is_hero(creature_ptr)) {
3077 if (is_shero(creature_ptr)) {
3081 if (creature_ptr->stun > 50) {
3083 } else if (creature_ptr->stun) {
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 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3110 if (has_not_ninja_weapon(creature_ptr, id) || has_not_monk_weapon(creature_ptr, id)) {
3114 if (get_default_hand(creature_ptr) == id) {
3115 if ((has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))
3116 || (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_LARM))) {
3117 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
3120 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
3121 || !has_disable_two_handed_bonus(creature_ptr, 0)) {
3123 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);
3124 hit += MAX(bonus_to_h, 1);
3128 int default_hand = get_default_hand(creature_ptr);
3129 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3131 o_ptr = &creature_ptr->inventory_list[i];
3132 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
3133 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3136 if (is_true_value || !object_is_known(o_ptr))
3138 bonus_to_h = o_ptr->to_h;
3140 if (creature_ptr->pclass == CLASS_NINJA) {
3141 if (o_ptr->to_h > 0)
3142 bonus_to_h = (o_ptr->to_h + 1) / 2;
3145 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
3146 hit += (s16b)bonus_to_h;
3150 if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) {
3151 if (default_hand == 0)
3152 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
3153 if (default_hand == 1)
3154 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
3158 if (default_hand == id)
3159 hit += (s16b)bonus_to_h;
3161 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3162 hit += (creature_ptr->lev / 3);
3165 hit -= calc_double_weapon_penalty(creature_ptr, slot);
3170 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_true_value)
3174 pow += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3175 pow += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3179 BIT_FLAGS flgs[TR_FLAG_SIZE];
3180 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3182 object_flags(creature_ptr, o_ptr, flgs);
3184 if (o_ptr->curse_flags & TRC_LOW_MELEE) {
3185 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
3194 if (creature_ptr->stun > 50) {
3196 } else if (creature_ptr->stun) {
3200 if (is_blessed(creature_ptr)) {
3204 if (is_hero(creature_ptr)) {
3208 if (is_shero(creature_ptr)) {
3212 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3214 if (is_heavy_shoot(creature_ptr, o_ptr)) {
3215 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3219 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
3220 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
3221 pow += (10 + (creature_ptr->lev / 5));
3227 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3229 o_ptr = &creature_ptr->inventory_list[i];
3230 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
3231 || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3234 bonus_to_h = o_ptr->to_h;
3236 if (creature_ptr->pclass == CLASS_NINJA) {
3237 if (o_ptr->to_h > 0)
3238 bonus_to_h = (o_ptr->to_h + 1) / 2;
3241 if (is_true_value || object_is_known(o_ptr))
3242 pow += (s16b)bonus_to_h;
3245 pow -= calc_riding_bow_penalty(creature_ptr);
3250 static s16b calc_to_damage_misc(player_type *creature_ptr)
3253 BIT_FLAGS flgs[TR_FLAG_SIZE];
3257 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3258 o_ptr = &creature_ptr->inventory_list[i];
3262 object_flags(creature_ptr, o_ptr, flgs);
3264 int bonus_to_d = o_ptr->to_d;
3265 if (creature_ptr->pclass == CLASS_NINJA) {
3266 if (o_ptr->to_d > 0)
3267 bonus_to_d = (o_ptr->to_d + 1) / 2;
3269 to_dam += (s16b)bonus_to_d;
3272 if (is_shero(creature_ptr)) {
3273 to_dam += 3 + (creature_ptr->lev / 5);
3276 if (creature_ptr->stun > 50) {
3278 } else if (creature_ptr->stun) {
3282 to_dam += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
3286 static s16b calc_to_hit_misc(player_type *creature_ptr)
3289 BIT_FLAGS flgs[TR_FLAG_SIZE];
3293 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
3294 o_ptr = &creature_ptr->inventory_list[i];
3298 object_flags(creature_ptr, o_ptr, flgs);
3300 int bonus_to_h = o_ptr->to_h;
3301 if (creature_ptr->pclass == CLASS_NINJA) {
3302 if (o_ptr->to_h > 0)
3303 bonus_to_h = (o_ptr->to_h + 1) / 2;
3305 to_hit += (s16b)o_ptr->to_h;
3308 if (is_blessed(creature_ptr)) {
3312 if (is_hero(creature_ptr)) {
3316 if (is_shero(creature_ptr)) {
3320 if (creature_ptr->stun > 50) {
3322 } else if (creature_ptr->stun) {
3326 to_hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3327 to_hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3332 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
3334 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3337 if (creature_ptr->riding) {
3339 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3347 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
3349 (creature_ptr); // unused
3355 * @brief プレイヤーの所持重量制限を計算する /
3356 * Computes current weight limit.
3359 WEIGHT weight_limit(player_type *creature_ptr)
3361 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
3362 if (creature_ptr->pclass == CLASS_BERSERKER)
3368 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3369 * @param i 判定する手のID(右手:0 左手:1)
3370 * @return 持っているならばTRUE
3372 bool has_melee_weapon(player_type *creature_ptr, int i)
3374 return ((creature_ptr->inventory_list[i].k_idx && object_is_melee_weapon(&creature_ptr->inventory_list[i])) ? TRUE : FALSE);
3378 * @brief プレイヤーの現在開いている手の状態を返す
3379 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3380 * @return 開いている手のビットフラグ
3382 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
3384 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3385 if (!creature_ptr->inventory_list[INVEN_RARM].k_idx)
3386 status |= EMPTY_HAND_RARM;
3387 if (!creature_ptr->inventory_list[INVEN_LARM].k_idx)
3388 status |= EMPTY_HAND_LARM;
3390 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS)) {
3391 if (status & EMPTY_HAND_LARM)
3392 status &= ~(EMPTY_HAND_LARM);
3393 else if (status & EMPTY_HAND_RARM)
3394 status &= ~(EMPTY_HAND_RARM);
3401 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3402 * @return ペナルティが適用されるならばTRUE。
3404 bool heavy_armor(player_type *creature_ptr)
3406 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
3409 WEIGHT monk_arm_wgt = 0;
3410 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD)
3411 monk_arm_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
3412 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD)
3413 monk_arm_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
3414 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
3415 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
3416 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
3417 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
3418 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
3420 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
3424 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
3426 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3428 void update_creature(player_type *creature_ptr)
3430 if (!creature_ptr->update)
3433 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3434 if (creature_ptr->update & (PU_AUTODESTROY)) {
3435 creature_ptr->update &= ~(PU_AUTODESTROY);
3436 autopick_delayed_alter(creature_ptr);
3439 if (creature_ptr->update & (PU_COMBINE)) {
3440 creature_ptr->update &= ~(PU_COMBINE);
3441 combine_pack(creature_ptr);
3444 if (creature_ptr->update & (PU_REORDER)) {
3445 creature_ptr->update &= ~(PU_REORDER);
3446 reorder_pack(creature_ptr);
3449 if (creature_ptr->update & (PU_BONUS)) {
3450 creature_ptr->update &= ~(PU_BONUS);
3451 calc_alignment(creature_ptr);
3452 calc_bonuses(creature_ptr);
3455 if (creature_ptr->update & (PU_TORCH)) {
3456 creature_ptr->update &= ~(PU_TORCH);
3457 calc_lite_radius(creature_ptr);
3460 if (creature_ptr->update & (PU_HP)) {
3461 creature_ptr->update &= ~(PU_HP);
3462 calc_hitpoints(creature_ptr);
3465 if (creature_ptr->update & (PU_MANA)) {
3466 creature_ptr->update &= ~(PU_MANA);
3467 calc_mana(creature_ptr);
3470 if (creature_ptr->update & (PU_SPELLS)) {
3471 creature_ptr->update &= ~(PU_SPELLS);
3472 calc_spells(creature_ptr);
3475 if (!current_world_ptr->character_generated)
3477 if (current_world_ptr->character_icky)
3479 if (creature_ptr->update & (PU_UN_LITE)) {
3480 creature_ptr->update &= ~(PU_UN_LITE);
3481 forget_lite(floor_ptr);
3484 if (creature_ptr->update & (PU_UN_VIEW)) {
3485 creature_ptr->update &= ~(PU_UN_VIEW);
3486 forget_view(floor_ptr);
3489 if (creature_ptr->update & (PU_VIEW)) {
3490 creature_ptr->update &= ~(PU_VIEW);
3491 update_view(creature_ptr);
3494 if (creature_ptr->update & (PU_LITE)) {
3495 creature_ptr->update &= ~(PU_LITE);
3496 update_lite(creature_ptr);
3499 if (creature_ptr->update & (PU_FLOW)) {
3500 creature_ptr->update &= ~(PU_FLOW);
3501 update_flow(creature_ptr);
3504 if (creature_ptr->update & (PU_DISTANCE)) {
3505 creature_ptr->update &= ~(PU_DISTANCE);
3507 update_monsters(creature_ptr, TRUE);
3510 if (creature_ptr->update & (PU_MON_LITE)) {
3511 creature_ptr->update &= ~(PU_MON_LITE);
3512 update_mon_lite(creature_ptr);
3515 if (creature_ptr->update & (PU_DELAY_VIS)) {
3516 creature_ptr->update &= ~(PU_DELAY_VIS);
3517 delayed_visual_update(creature_ptr);
3520 if (creature_ptr->update & (PU_MONSTERS)) {
3521 creature_ptr->update &= ~(PU_MONSTERS);
3522 update_monsters(creature_ptr, FALSE);
3527 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
3528 * @return 魔道書を一冊も持っていないならTRUEを返す
3530 bool player_has_no_spellbooks(player_type *creature_ptr)
3533 for (int i = 0; i < INVEN_PACK; i++) {
3534 o_ptr = &creature_ptr->inventory_list[i];
3535 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3539 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3540 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
3541 o_ptr = &floor_ptr->o_list[i];
3542 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3549 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost) { creature_ptr->energy_use = (ENERGY)need_cost; }
3551 void free_turn(player_type *creature_ptr) { creature_ptr->energy_use = 0; }
3554 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
3557 * @return 配置に成功したらTRUE
3559 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
3561 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
3564 /* Save player location */
3565 creature_ptr->y = y;
3566 creature_ptr->x = x;
3571 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
3574 void wreck_the_pattern(player_type *creature_ptr)
3576 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3577 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
3578 if (pattern_type == PATTERN_TILE_WRECKED)
3581 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
3582 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
3584 if (!is_invuln(creature_ptr))
3585 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
3587 int to_ruin = randint1(45) + 35;
3590 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
3592 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
3593 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
3597 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
3601 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
3602 * Advance experience levels and print experience
3605 void check_experience(player_type *creature_ptr)
3607 if (creature_ptr->exp < 0)
3608 creature_ptr->exp = 0;
3609 if (creature_ptr->max_exp < 0)
3610 creature_ptr->max_exp = 0;
3611 if (creature_ptr->max_max_exp < 0)
3612 creature_ptr->max_max_exp = 0;
3614 if (creature_ptr->exp > PY_MAX_EXP)
3615 creature_ptr->exp = PY_MAX_EXP;
3616 if (creature_ptr->max_exp > PY_MAX_EXP)
3617 creature_ptr->max_exp = PY_MAX_EXP;
3618 if (creature_ptr->max_max_exp > PY_MAX_EXP)
3619 creature_ptr->max_max_exp = PY_MAX_EXP;
3621 if (creature_ptr->exp > creature_ptr->max_exp)
3622 creature_ptr->max_exp = creature_ptr->exp;
3623 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
3624 creature_ptr->max_max_exp = creature_ptr->max_exp;
3626 creature_ptr->redraw |= (PR_EXP);
3627 handle_stuff(creature_ptr);
3629 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
3630 PLAYER_LEVEL old_lev = creature_ptr->lev;
3631 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
3632 creature_ptr->lev--;
3633 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3634 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
3635 creature_ptr->window |= (PW_PLAYER);
3636 handle_stuff(creature_ptr);
3639 bool level_reward = FALSE;
3640 bool level_mutation = FALSE;
3641 bool level_inc_stat = FALSE;
3642 while ((creature_ptr->lev < PY_MAX_LEVEL)
3643 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
3644 creature_ptr->lev++;
3645 if (creature_ptr->lev > creature_ptr->max_plv) {
3646 creature_ptr->max_plv = creature_ptr->lev;
3648 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || (creature_ptr->muta2 & MUT2_CHAOS_GIFT)) {
3649 level_reward = TRUE;
3651 if (creature_ptr->prace == RACE_BEASTMAN) {
3653 level_mutation = TRUE;
3655 level_inc_stat = TRUE;
3657 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
3661 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
3662 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3663 creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
3664 creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
3665 creature_ptr->level_up_message = TRUE;
3666 handle_stuff(creature_ptr);
3668 creature_ptr->level_up_message = FALSE;
3669 if (level_inc_stat) {
3670 if (!(creature_ptr->max_plv % 10)) {
3677 cnv_stat(creature_ptr->stat_max[0], tmp);
3678 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
3679 cnv_stat(creature_ptr->stat_max[1], tmp);
3680 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
3681 cnv_stat(creature_ptr->stat_max[2], tmp);
3682 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
3683 cnv_stat(creature_ptr->stat_max[3], tmp);
3684 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
3685 cnv_stat(creature_ptr->stat_max[4], tmp);
3686 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
3687 cnv_stat(creature_ptr->stat_max[5], tmp);
3688 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
3691 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
3695 if ((choice >= 'a') && (choice <= 'f'))
3698 for (n = 0; n < A_MAX; n++)
3699 if (n != choice - 'a')
3701 if (get_check(_("よろしいですか?", "Are you sure? ")))
3704 do_inc_stat(creature_ptr, choice - 'a');
3706 } else if (!(creature_ptr->max_plv % 2))
3707 do_inc_stat(creature_ptr, randint0(6));
3710 if (level_mutation) {
3711 msg_print(_("あなたは変わった気がする...", "You feel different..."));
3712 (void)gain_mutation(creature_ptr, 0);
3713 level_mutation = FALSE;
3717 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
3721 gain_level_reward(creature_ptr, 0);
3722 level_reward = FALSE;
3725 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3726 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
3727 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
3728 handle_stuff(creature_ptr);
3731 if (old_lev != creature_ptr->lev)
3732 autopick_load_pref(creature_ptr, FALSE);
3736 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
3738 * @param out_val 出力先文字列ポインタ
3741 void cnv_stat(int val, char *out_val)
3744 sprintf(out_val, " %2d", val);
3748 int bonus = (val - 18);
3750 sprintf(out_val, "18/%3s", "***");
3751 } else if (bonus >= 100) {
3752 sprintf(out_val, "18/%03d", bonus);
3754 sprintf(out_val, " 18/%02d", bonus);
3759 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
3760 * Modify a stat value by a "modifier", return new value
3762 * @param amount 加減算値
3766 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
3767 * Or even: 18/13, 18/23, 18/33, ..., 18/220
3768 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
3769 * Or even: 18/13, 18/03, 18, 17, ..., 3
3772 s16b modify_stat_value(int value, int amount)
3775 for (int i = 0; i < amount; i++) {
3781 } else if (amount < 0) {
3782 for (int i = 0; i < (0 - amount); i++) {
3783 if (value >= 18 + 10)
3785 else if (value > 18)
3797 * Hack -- Calculates the total number of points earned -JWT-
3801 long calc_score(player_type *creature_ptr)
3803 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
3816 if (ironman_small_levels)
3818 if (ironman_empty_levels)
3824 if (ironman_nightmare)
3831 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
3832 if (max_dlv[i] > max_dl)
3833 max_dl = max_dlv[i];
3835 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
3836 u32b point_h = point_l / 0x10000L;
3837 point_l = point_l % 0x10000L;
3840 point_h += point_l / 0x10000L;
3841 point_l %= 0x10000L;
3843 point_l += ((point_h % 100) << 16);
3847 u32b point = (point_h << 16) + (point_l);
3848 if (creature_ptr->arena_number >= 0)
3849 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
3851 if (ironman_downward)
3853 if (creature_ptr->pclass == CLASS_BERSERKER) {
3854 if (creature_ptr->prace == RACE_SPECTRE)
3858 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
3860 if (current_world_ptr->total_winner)
3865 point = (0 - point);
3871 * @param creature_ptr プレーヤーへの参照ポインタ
3872 * @return 祝福状態ならばTRUE
3874 bool is_blessed(player_type *creature_ptr)
3876 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
3879 bool is_tim_esp(player_type *creature_ptr)
3881 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3884 bool is_tim_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
3886 bool is_time_limit_esp(player_type *creature_ptr)
3888 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3891 bool is_time_limit_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
3893 bool can_two_hands_wielding(player_type *creature_ptr) { return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS); }
3896 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
3899 void stop_singing(player_type *creature_ptr)
3901 if (creature_ptr->pclass != CLASS_BARD)
3904 /* Are there interupted song? */
3905 if (INTERUPTING_SONG_EFFECT(creature_ptr)) {
3906 /* Forget interupted song */
3907 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3911 /* The player is singing? */
3912 if (!SINGING_SONG_EFFECT(creature_ptr))
3915 /* Hack -- if called from set_action(), avoid recursive loop */
3916 if (creature_ptr->action == ACTION_SING)
3917 set_action(creature_ptr, ACTION_NONE);
3919 /* Message text of each song or etc. */
3920 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
3922 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3923 SINGING_SONG_ID(creature_ptr) = 0;
3924 creature_ptr->update |= (PU_BONUS);
3925 creature_ptr->redraw |= (PR_STATUS);
3929 * @brief 口を使う継続的な処理を中断する
3930 * @param caster_ptr プレーヤーへの参照ポインタ
3933 void stop_mouth(player_type *caster_ptr)
3935 if (music_singing_any(caster_ptr))
3936 stop_singing(caster_ptr);
3937 if (hex_spelling_any(caster_ptr))
3938 stop_hex_spell_all(caster_ptr);
3942 * @brief ペットの維持コスト計算
3945 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
3948 bool has_a_unique = FALSE;
3949 DEPTH total_friend_levels = 0;
3953 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
3954 monster_type *m_ptr;
3955 monster_race *r_ptr;
3957 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
3958 if (!monster_is_valid(m_ptr))
3960 r_ptr = &r_info[m_ptr->r_idx];
3962 if (is_pet(m_ptr)) {
3964 if (r_ptr->flags1 & RF1_UNIQUE) {
3965 if (creature_ptr->pclass == CLASS_CAVALRY) {
3966 if (creature_ptr->riding == m_idx)
3967 total_friend_levels += (r_ptr->level + 5) * 2;
3968 else if (!has_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
3969 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
3971 total_friend_levels += (r_ptr->level + 5) * 10;
3972 has_a_unique = TRUE;
3974 total_friend_levels += (r_ptr->level + 5) * 10;
3976 total_friend_levels += r_ptr->level;
3980 if (total_friends) {
3982 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
3983 if (upkeep_factor < 0)
3985 if (upkeep_factor > 1000)
3986 upkeep_factor = 1000;
3987 return upkeep_factor;
3992 bool music_singing(player_type *caster_ptr, int music_songs) { return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs); }
3994 bool is_fast(player_type *creature_ptr) { return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO); }
3996 bool is_invuln(player_type *creature_ptr) { return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN); }
3998 bool is_hero(player_type *creature_ptr) { return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO); }
4000 bool is_shero(player_type *creature_ptr) { return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER; }
4002 bool is_echizen(player_type *creature_ptr)
4004 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
4007 int calc_weapon_weight_limit(player_type *creature_ptr)
4009 int weight = adj_str_hold[creature_ptr->stat_ind[A_STR]];
4011 if (has_two_handed_weapons(creature_ptr))
4017 static int get_default_hand(player_type *creature_ptr)
4019 int default_hand = 0;
4021 if (has_melee_weapon(creature_ptr, INVEN_LARM)) {
4022 if (!has_right_hand_weapon(creature_ptr))
4026 if (can_two_hands_wielding(creature_ptr)) {
4027 if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
4028 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
4029 } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
4030 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
4036 return default_hand;