1 #include "player/player-status-flags.h"
2 #include "artifact/fixed-art-types.h"
3 #include "inventory/inventory-slot-types.h"
4 #include "mind/mind-elementalist.h"
5 #include "monster-race/monster-race.h"
6 #include "monster-race/race-flags2.h"
7 #include "monster-race/race-flags7.h"
8 #include "mutation/mutation-flag-types.h"
9 #include "object-enchant/object-ego.h"
10 #include "object-enchant/tr-types.h"
11 #include "object-enchant/trc-types.h"
12 #include "object-hook/hook-weapon.h"
13 #include "object/object-flags.h"
14 #include "player-base/player-class.h"
15 #include "player-base/player-race.h"
16 #include "player-info/class-info.h"
17 #include "player-info/equipment-info.h"
18 #include "player-info/mimic-info-table.h"
19 #include "player-status/player-basic-statistics.h"
20 #include "player-status/player-hand-types.h"
21 #include "player-status/player-infravision.h"
22 #include "player-status/player-speed.h"
23 #include "player-status/player-stealth.h"
24 #include "player/attack-defense-types.h"
25 #include "player/digestion-processor.h"
26 #include "player/player-skill.h"
27 #include "player/player-status.h"
28 #include "player/race-info-table.h"
29 #include "player/special-defense-types.h"
30 #include "realm/realm-hex-numbers.h"
31 #include "realm/realm-song-numbers.h"
32 #include "realm/realm-types.h"
33 #include "spell-realm/spells-hex.h"
34 #include "spell-realm/spells-song.h"
35 #include "sv-definition/sv-weapon-types.h"
36 #include "system/floor-type-definition.h"
37 #include "system/grid-type-definition.h"
38 #include "system/monster-race-definition.h"
39 #include "system/monster-type-definition.h"
40 #include "system/object-type-definition.h"
41 #include "system/player-type-definition.h"
42 #include "util/bit-flags-calculator.h"
43 #include "util/quarks.h"
44 #include "util/string-processor.h"
49 * @brief 指定した特性フラグが得られている要因となる flag_cause 型のうち以下の基本的な物のフラグ集合を取得する
50 * 装備品のアイテムスロット / 種族上の体得 / 職業上の体得
51 * @param tr_flag 特性フラグ
52 * @return tr_flag が得られる要因となるフラグの集合
54 BIT_FLAGS common_cause_flags(PlayerType *player_ptr, tr_type tr_flag)
56 BIT_FLAGS result = check_equipment_flags(player_ptr, tr_flag);
58 if (PlayerRace(player_ptr).tr_flags().has(tr_flag)) {
59 set_bits(result, FLAG_CAUSE_RACE);
62 if (PlayerClass(player_ptr).tr_flags().has(tr_flag)) {
63 set_bits(result, FLAG_CAUSE_CLASS);
66 if (PlayerClass(player_ptr).stance_tr_flags().has(tr_flag)) {
67 set_bits(result, FLAG_CAUSE_STANCE);
78 BIT_FLAGS convert_inventory_slot_type_to_flag_cause(inventory_slot_type inventory_slot)
80 switch (inventory_slot) {
82 return FLAG_CAUSE_INVEN_MAIN_HAND;
84 return FLAG_CAUSE_INVEN_SUB_HAND;
86 return FLAG_CAUSE_INVEN_BOW;
88 return FLAG_CAUSE_INVEN_MAIN_RING;
90 return FLAG_CAUSE_INVEN_SUB_RING;
92 return FLAG_CAUSE_INVEN_NECK;
94 return FLAG_CAUSE_INVEN_LITE;
96 return FLAG_CAUSE_INVEN_BODY;
98 return FLAG_CAUSE_INVEN_OUTER;
100 return FLAG_CAUSE_INVEN_HEAD;
102 return FLAG_CAUSE_INVEN_ARMS;
104 return FLAG_CAUSE_INVEN_FEET;
112 * @brief 装備による所定の特性フラグを得ているかを一括して取得する関数。
114 BIT_FLAGS check_equipment_flags(PlayerType *player_ptr, tr_type tr_flag)
117 BIT_FLAGS result = 0L;
118 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
119 o_ptr = &player_ptr->inventory_list[i];
123 auto flgs = object_flags(o_ptr);
125 if (flgs.has(tr_flag))
126 set_bits(result, convert_inventory_slot_type_to_flag_cause(i2enum<inventory_slot_type>(i)));
131 BIT_FLAGS player_flags_brand_pois(PlayerType *player_ptr)
133 BIT_FLAGS result = common_cause_flags(player_ptr, TR_BRAND_POIS);
135 if (player_ptr->special_attack & ATTACK_POIS)
136 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
141 BIT_FLAGS player_flags_brand_acid(PlayerType *player_ptr)
143 BIT_FLAGS result = common_cause_flags(player_ptr, TR_BRAND_ACID);
145 if (player_ptr->special_attack & ATTACK_ACID)
146 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
151 BIT_FLAGS player_flags_brand_elec(PlayerType *player_ptr)
153 BIT_FLAGS result = common_cause_flags(player_ptr, TR_BRAND_ELEC);
155 if (player_ptr->special_attack & ATTACK_ELEC)
156 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
161 BIT_FLAGS player_flags_brand_fire(PlayerType *player_ptr)
163 BIT_FLAGS result = common_cause_flags(player_ptr, TR_BRAND_FIRE);
165 if (player_ptr->special_attack & ATTACK_FIRE)
166 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
171 BIT_FLAGS player_flags_brand_cold(PlayerType *player_ptr)
173 BIT_FLAGS result = common_cause_flags(player_ptr, TR_BRAND_COLD);
175 if (player_ptr->special_attack & ATTACK_COLD)
176 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
182 * @brief プレイヤーの所持するフラグのうち、tr_flagに対応するものを返す
183 * @param player_ptr プレイヤーへの参照ポインタ
184 * @param tr_flag 要求する装備フラグ
186 BIT_FLAGS get_player_flags(PlayerType *player_ptr, tr_type tr_flag)
190 return PlayerStrength(player_ptr).get_all_flags();
192 return PlayerIntelligence(player_ptr).get_all_flags();
194 return PlayerWisdom(player_ptr).get_all_flags();
196 return PlayerDexterity(player_ptr).get_all_flags();
198 return PlayerConstitution(player_ptr).get_all_flags();
200 return PlayerCharisma(player_ptr).get_all_flags();
201 case TR_MAGIC_MASTERY:
202 return has_magic_mastery(player_ptr);
203 case TR_FORCE_WEAPON:
204 return check_equipment_flags(player_ptr, tr_flag);
206 return PlayerStealth(player_ptr).get_all_flags();
210 return PlayerInfravision(player_ptr).get_all_flags();
214 return PlayerSpeed(player_ptr).get_all_flags();
229 return check_equipment_flags(player_ptr, tr_flag);
231 return has_earthquake(player_ptr);
233 return player_flags_brand_pois(player_ptr);
235 return player_flags_brand_acid(player_ptr);
237 return player_flags_brand_elec(player_ptr);
239 return player_flags_brand_fire(player_ptr);
241 return player_flags_brand_cold(player_ptr);
244 return has_sustain_str(player_ptr);
246 return has_sustain_int(player_ptr);
248 return has_sustain_wis(player_ptr);
250 return has_sustain_dex(player_ptr);
252 return has_sustain_con(player_ptr);
254 return has_sustain_chr(player_ptr);
256 return check_equipment_flags(player_ptr, tr_flag);
258 return has_easy_spell(player_ptr);
260 return has_immune_acid(player_ptr);
262 return has_immune_elec(player_ptr);
264 return has_immune_fire(player_ptr);
266 return has_immune_cold(player_ptr);
268 return check_equipment_flags(player_ptr, tr_flag);
270 return has_reflect(player_ptr);
272 return has_free_act(player_ptr);
274 return has_hold_exp(player_ptr);
276 return has_resist_acid(player_ptr);
278 return has_resist_elec(player_ptr);
280 return has_resist_fire(player_ptr);
282 return has_resist_cold(player_ptr);
284 return has_resist_pois(player_ptr);
286 return has_resist_fear(player_ptr);
288 return has_resist_lite(player_ptr);
290 return has_resist_dark(player_ptr);
292 return has_resist_blind(player_ptr);
294 return has_resist_conf(player_ptr);
296 return has_resist_sound(player_ptr);
298 return has_resist_shard(player_ptr);
300 return has_resist_neth(player_ptr);
302 return has_resist_nexus(player_ptr);
304 return has_resist_chaos(player_ptr);
306 return has_resist_disen(player_ptr);
308 return has_resist_time(player_ptr);
310 return has_resist_water(player_ptr);
312 return has_resist_curse(player_ptr);
315 return has_sh_fire(player_ptr);
317 return has_sh_elec(player_ptr);
319 return check_equipment_flags(player_ptr, tr_flag);
321 return has_sh_cold(player_ptr);
323 return has_anti_tele(player_ptr);
325 return has_anti_magic(player_ptr);
327 return has_dec_mana(player_ptr);
329 return check_equipment_flags(player_ptr, tr_flag);
331 return has_warning(player_ptr);
335 return check_equipment_flags(player_ptr, tr_flag);
337 return has_levitation(player_ptr);
339 return has_lite(player_ptr);
341 return has_see_inv(player_ptr);
343 return has_esp_telepathy(player_ptr);
345 return has_slow_digest(player_ptr);
347 return has_regenerate(player_ptr);
349 return has_xtra_might(player_ptr);
358 return check_equipment_flags(player_ptr, tr_flag);
362 return has_bless_blade(player_ptr);
374 return check_equipment_flags(player_ptr, tr_flag);
376 return has_esp_animal(player_ptr);
378 return has_esp_undead(player_ptr);
380 return has_esp_demon(player_ptr);
382 return has_esp_orc(player_ptr);
384 return has_esp_troll(player_ptr);
386 return has_esp_giant(player_ptr);
388 return has_esp_dragon(player_ptr);
390 return has_esp_human(player_ptr);
392 return has_esp_evil(player_ptr);
394 return has_esp_good(player_ptr);
395 case TR_ESP_NONLIVING:
396 return has_esp_nonliving(player_ptr);
398 return has_esp_unique(player_ptr);
400 case TR_FIXED_FLAVOR:
421 return check_equipment_flags(player_ptr, tr_flag);
422 case TR_MIGHTY_THROW:
423 return has_mighty_throw(player_ptr);
424 case TR_EASY2_WEAPON:
425 return has_easy2_weapon(player_ptr);
427 return has_down_saving(player_ptr);
429 return has_no_ac(player_ptr);
431 return has_heavy_spell(player_ptr);
432 case TR_INVULN_ARROW:
433 return has_invuln_arrow(player_ptr);
438 return check_equipment_flags(player_ptr, tr_flag);
440 return has_impact(player_ptr);
442 return has_vuln_acid(player_ptr);
444 return has_vuln_cold(player_ptr);
446 return has_vuln_elec(player_ptr);
448 return has_vuln_fire(player_ptr);
450 return has_vuln_lite(player_ptr);
452 return has_immune_dark(player_ptr);
456 return check_equipment_flags(player_ptr, tr_flag);
465 * @brief プレイヤーが壁破壊進行を持っているかを返す。
467 bool has_kill_wall(PlayerType *player_ptr)
469 if (player_ptr->mimic_form == MIMIC_DEMON_LORD || music_singing(player_ptr, MUSIC_WALL)) {
473 if (player_ptr->riding) {
474 monster_type *riding_m_ptr = &player_ptr->current_floor_ptr->m_list[player_ptr->riding];
475 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
476 if (riding_r_ptr->flags2 & RF2_KILL_WALL)
484 * @brief プレイヤーが壁通過を持っているかを返す。
485 * @param player_ptr プレイヤーへの参照ポインタ
488 * * 時限で幽体化、壁抜けをもつか種族幽霊ならばひとまずTRUE。
489 * * 但し騎乗中は乗騎が壁抜けを持っていなければ不能になる。
491 bool has_pass_wall(PlayerType *player_ptr)
495 if (player_ptr->wraith_form || player_ptr->tim_pass_wall || (!player_ptr->mimic_form && player_ptr->prace == PlayerRaceType::SPECTRE)) {
499 if (player_ptr->riding) {
500 monster_type *riding_m_ptr = &player_ptr->current_floor_ptr->m_list[player_ptr->riding];
501 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
502 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL))
510 * @brief プレイヤーが強力射を持っているかを返す。
511 * @param player_ptr プレイヤーへの参照ポインタ
512 * @return 持っていたら所持前提ビットフラグを返す。
514 BIT_FLAGS has_xtra_might(PlayerType *player_ptr)
516 return common_cause_flags(player_ptr, TR_XTRA_MIGHT);
520 * @brief プレイヤーが邪悪感知を持っているかを返す。
521 * @param player_ptr プレイヤーへの参照ポインタ
522 * @return 持っていたら所持前提ビットフラグを返す。
524 BIT_FLAGS has_esp_evil(PlayerType *player_ptr)
526 BIT_FLAGS result = common_cause_flags(player_ptr, TR_ESP_EVIL);
527 if (player_ptr->realm1 == REALM_HEX) {
528 if (SpellHex(player_ptr).is_spelling_specific(HEX_DETECT_EVIL))
529 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
535 * @brief プレイヤーが自然界の動物感知を持っているかを返す。
536 * @param player_ptr プレイヤーへの参照ポインタ
537 * @return 持っていたら所持前提ビットフラグを返す。
539 BIT_FLAGS has_esp_animal(PlayerType *player_ptr)
541 return common_cause_flags(player_ptr, TR_ESP_ANIMAL);
545 * @brief プレイヤーがアンデッド感知を持っているかを返す。
546 * @param player_ptr プレイヤーへの参照ポインタ
547 * @return 持っていたら所持前提ビットフラグを返す。
549 BIT_FLAGS has_esp_undead(PlayerType *player_ptr)
551 return common_cause_flags(player_ptr, TR_ESP_UNDEAD);
555 * @brief プレイヤーが悪魔感知を持っているかを返す。
556 * @param player_ptr プレイヤーへの参照ポインタ
557 * @return 持っていたら所持前提ビットフラグを返す。
559 BIT_FLAGS has_esp_demon(PlayerType *player_ptr)
561 return common_cause_flags(player_ptr, TR_ESP_DEMON);
565 * @brief プレイヤーがオーク感知を持っているかを返す。
566 * @param player_ptr プレイヤーへの参照ポインタ
567 * @return 持っていたら所持前提ビットフラグを返す。
569 BIT_FLAGS has_esp_orc(PlayerType *player_ptr)
571 return common_cause_flags(player_ptr, TR_ESP_ORC);
575 * @brief プレイヤーがトロル感知を持っているかを返す。
576 * @param player_ptr プレイヤーへの参照ポインタ
577 * @return 持っていたら所持前提ビットフラグを返す。
579 BIT_FLAGS has_esp_troll(PlayerType *player_ptr)
581 return common_cause_flags(player_ptr, TR_ESP_TROLL);
585 * @brief プレイヤーが巨人感知を持っているかを返す。
586 * @param player_ptr プレイヤーへの参照ポインタ
587 * @return 持っていたら所持前提ビットフラグを返す。
589 BIT_FLAGS has_esp_giant(PlayerType *player_ptr)
591 return common_cause_flags(player_ptr, TR_ESP_GIANT);
595 * @brief プレイヤーがドラゴン感知を持っているかを返す。
596 * @param player_ptr プレイヤーへの参照ポインタ
597 * @return 持っていたら所持前提ビットフラグを返す。
599 BIT_FLAGS has_esp_dragon(PlayerType *player_ptr)
601 return common_cause_flags(player_ptr, TR_ESP_DRAGON);
605 * @brief プレイヤーが人間感知を持っているかを返す。
606 * @param player_ptr プレイヤーへの参照ポインタ
607 * @return 持っていたら所持前提ビットフラグを返す。
609 BIT_FLAGS has_esp_human(PlayerType *player_ptr)
611 return common_cause_flags(player_ptr, TR_ESP_HUMAN);
615 * @brief プレイヤーが善良感知を持っているかを返す。
616 * @param player_ptr プレイヤーへの参照ポインタ
617 * @return 持っていたら所持前提ビットフラグを返す。
619 BIT_FLAGS has_esp_good(PlayerType *player_ptr)
621 return common_cause_flags(player_ptr, TR_ESP_GOOD);
625 * @brief プレイヤーが無生物感知を持っているかを返す。
626 * @param player_ptr プレイヤーへの参照ポインタ
627 * @return 持っていたら所持前提ビットフラグを返す。
629 BIT_FLAGS has_esp_nonliving(PlayerType *player_ptr)
631 return common_cause_flags(player_ptr, TR_ESP_NONLIVING);
635 * @brief プレイヤーがユニーク感知を持っているかを返す。
636 * @param player_ptr プレイヤーへの参照ポインタ
637 * @return 持っていたら所持前提ビットフラグを返す。
639 BIT_FLAGS has_esp_unique(PlayerType *player_ptr)
641 return common_cause_flags(player_ptr, TR_ESP_UNIQUE);
645 * @brief プレイヤーがテレパシーを持っているかを返す。
646 * @param player_ptr プレイヤーへの参照ポインタ
647 * @return 持っていたら所持前提ビットフラグを返す。
649 BIT_FLAGS has_esp_telepathy(PlayerType *player_ptr)
651 BIT_FLAGS result = common_cause_flags(player_ptr, TR_TELEPATHY);
653 if (is_time_limit_esp(player_ptr) || player_ptr->ult_res) {
654 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
657 if (player_ptr->muta.has(PlayerMutationType::ESP)) {
658 result |= FLAG_CAUSE_MUTATION;
664 BIT_FLAGS has_bless_blade(PlayerType *player_ptr)
666 return common_cause_flags(player_ptr, TR_BLESSED);
669 BIT_FLAGS has_easy2_weapon(PlayerType *player_ptr)
671 return common_cause_flags(player_ptr, TR_EASY2_WEAPON);
674 BIT_FLAGS has_down_saving(PlayerType *player_ptr)
676 return common_cause_flags(player_ptr, TR_DOWN_SAVING);
679 BIT_FLAGS has_no_ac(PlayerType *player_ptr)
681 return common_cause_flags(player_ptr, TR_NO_AC);
684 BIT_FLAGS has_invuln_arrow(PlayerType *player_ptr)
686 if (player_ptr->blind)
689 return common_cause_flags(player_ptr, TR_INVULN_ARROW);
692 void check_no_flowed(PlayerType *player_ptr)
695 bool has_sw = false, has_kabe = false;
697 player_ptr->no_flowed = false;
699 if (has_pass_wall(player_ptr) && !has_kill_wall(player_ptr)) {
700 player_ptr->no_flowed = true;
704 if (!player_ptr->realm1) {
705 player_ptr->no_flowed = false;
709 for (int i = 0; i < INVEN_PACK; i++) {
710 if ((player_ptr->inventory_list[i].tval == ItemKindType::NATURE_BOOK) && (player_ptr->inventory_list[i].sval == 2))
712 if ((player_ptr->inventory_list[i].tval == ItemKindType::CRAFT_BOOK) && (player_ptr->inventory_list[i].sval == 2))
716 for (const auto this_o_idx : player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].o_idx_list) {
717 o_ptr = &player_ptr->current_floor_ptr->o_list[this_o_idx];
719 if ((o_ptr->tval == ItemKindType::NATURE_BOOK) && (o_ptr->sval == 2))
721 if ((o_ptr->tval == ItemKindType::CRAFT_BOOK) && (o_ptr->sval == 2))
725 if (has_sw && ((player_ptr->realm1 == REALM_NATURE) || (player_ptr->realm2 == REALM_NATURE) || (player_ptr->pclass == PlayerClassType::SORCERER))) {
726 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
727 if (player_ptr->lev >= s_ptr->slevel)
728 player_ptr->no_flowed = true;
731 if (has_kabe && ((player_ptr->realm1 == REALM_CRAFT) || (player_ptr->realm2 == REALM_CRAFT) || (player_ptr->pclass == PlayerClassType::SORCERER))) {
732 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_WALL];
733 if (player_ptr->lev >= s_ptr->slevel)
734 player_ptr->no_flowed = true;
738 BIT_FLAGS has_mighty_throw(PlayerType *player_ptr)
740 return common_cause_flags(player_ptr, TR_MIGHTY_THROW);
743 BIT_FLAGS has_dec_mana(PlayerType *player_ptr)
745 return common_cause_flags(player_ptr, TR_DEC_MANA);
748 BIT_FLAGS has_reflect(PlayerType *player_ptr)
750 BIT_FLAGS result = common_cause_flags(player_ptr, TR_REFLECT);
752 if (player_ptr->ult_res || player_ptr->wraith_form || player_ptr->magicdef || player_ptr->tim_reflect) {
753 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
759 BIT_FLAGS has_see_nocto(PlayerType *player_ptr)
761 return (player_ptr->pclass == PlayerClassType::NINJA) ? FLAG_CAUSE_CLASS : FLAG_CAUSE_NONE;
764 BIT_FLAGS has_warning(PlayerType *player_ptr)
766 BIT_FLAGS result = 0L;
769 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
770 o_ptr = &player_ptr->inventory_list[i];
774 auto flgs = object_flags(o_ptr);
776 if (flgs.has(TR_WARNING)) {
777 if (!o_ptr->inscription || !(angband_strchr(quark_str(o_ptr->inscription), '$')))
778 set_bits(result, convert_inventory_slot_type_to_flag_cause(i2enum<inventory_slot_type>(i)));
784 BIT_FLAGS has_anti_magic(PlayerType *player_ptr)
786 return common_cause_flags(player_ptr, TR_NO_MAGIC);
789 BIT_FLAGS has_anti_tele(PlayerType *player_ptr)
791 return common_cause_flags(player_ptr, TR_NO_TELE);
794 BIT_FLAGS has_sh_fire(PlayerType *player_ptr)
796 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SH_FIRE);
798 if (player_ptr->muta.has(PlayerMutationType::FIRE_BODY)) {
799 result |= FLAG_CAUSE_MUTATION;
802 if (SpellHex(player_ptr).is_spelling_specific(HEX_DEMON_AURA) || player_ptr->ult_res || player_ptr->tim_sh_fire) {
803 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
809 BIT_FLAGS has_sh_elec(PlayerType *player_ptr)
811 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SH_ELEC);
813 if (player_ptr->muta.has(PlayerMutationType::ELEC_TOUC))
814 result |= FLAG_CAUSE_MUTATION;
816 if (SpellHex(player_ptr).is_spelling_specific(HEX_SHOCK_CLOAK) || player_ptr->ult_res) {
817 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
823 BIT_FLAGS has_sh_cold(PlayerType *player_ptr)
825 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SH_COLD);
827 if (player_ptr->ult_res || SpellHex(player_ptr).is_spelling_specific(HEX_ICE_ARMOR)) {
828 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
834 BIT_FLAGS has_easy_spell(PlayerType *player_ptr)
836 return common_cause_flags(player_ptr, TR_EASY_SPELL);
839 BIT_FLAGS has_heavy_spell(PlayerType *player_ptr)
841 return common_cause_flags(player_ptr, TR_HEAVY_SPELL);
844 BIT_FLAGS has_hold_exp(PlayerType *player_ptr)
846 BIT_FLAGS result = common_cause_flags(player_ptr, TR_HOLD_EXP);
848 if (player_ptr->ppersonality == PERSONALITY_MUNCHKIN) {
849 result |= FLAG_CAUSE_PERSONALITY;
852 if (player_ptr->ult_res) {
853 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
859 BIT_FLAGS has_see_inv(PlayerType *player_ptr)
861 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SEE_INVIS);
863 if (player_ptr->ult_res || player_ptr->tim_invis) {
864 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
870 BIT_FLAGS has_magic_mastery(PlayerType *player_ptr)
872 return common_cause_flags(player_ptr, TR_MAGIC_MASTERY);
875 BIT_FLAGS has_free_act(PlayerType *player_ptr)
877 BIT_FLAGS result = common_cause_flags(player_ptr, TR_FREE_ACT);
879 if (player_ptr->muta.has(PlayerMutationType::MOTION))
880 result |= FLAG_CAUSE_MUTATION;
882 if (player_ptr->ult_res || player_ptr->magicdef) {
883 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
889 BIT_FLAGS has_sustain_str(PlayerType *player_ptr)
891 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SUST_STR);
893 if (player_ptr->ult_res) {
894 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
900 BIT_FLAGS has_sustain_int(PlayerType *player_ptr)
902 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SUST_INT);
904 if (player_ptr->ult_res) {
905 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
911 BIT_FLAGS has_sustain_wis(PlayerType *player_ptr)
913 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SUST_WIS);
915 if (player_ptr->ult_res) {
916 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
922 BIT_FLAGS has_sustain_dex(PlayerType *player_ptr)
924 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SUST_DEX);
926 if (player_ptr->ult_res) {
927 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
933 BIT_FLAGS has_sustain_con(PlayerType *player_ptr)
935 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SUST_CON);
937 if (player_ptr->ult_res) {
938 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
944 BIT_FLAGS has_sustain_chr(PlayerType *player_ptr)
946 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SUST_CHR);
948 if (player_ptr->ult_res) {
949 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
955 BIT_FLAGS has_levitation(PlayerType *player_ptr)
957 BIT_FLAGS result = common_cause_flags(player_ptr, TR_LEVITATION);
959 if (player_ptr->muta.has(PlayerMutationType::WINGS)) {
960 result |= FLAG_CAUSE_MUTATION;
963 if (player_ptr->ult_res || player_ptr->magicdef) {
964 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
967 if (player_ptr->tim_levitation) {
968 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
971 // 乗馬中は実際に浮遊するかどうかは乗馬中のモンスターに依存する
972 if (player_ptr->riding) {
973 monster_type *riding_m_ptr = &player_ptr->current_floor_ptr->m_list[player_ptr->riding];
974 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
975 result = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? FLAG_CAUSE_RIDING : FLAG_CAUSE_NONE;
981 bool has_can_swim(PlayerType *player_ptr)
983 bool can_swim = false;
984 if (player_ptr->riding) {
985 monster_type *riding_m_ptr = &player_ptr->current_floor_ptr->m_list[player_ptr->riding];
986 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
987 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
994 BIT_FLAGS has_slow_digest(PlayerType *player_ptr)
996 BIT_FLAGS result = common_cause_flags(player_ptr, TR_SLOW_DIGEST);
998 if (player_ptr->ult_res) {
999 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1005 BIT_FLAGS has_regenerate(PlayerType *player_ptr)
1007 BIT_FLAGS result = common_cause_flags(player_ptr, TR_REGEN);
1009 if (player_ptr->muta.has(PlayerMutationType::REGEN))
1010 result |= FLAG_CAUSE_MUTATION;
1012 if (SpellHex(player_ptr).is_spelling_specific(HEX_DEMON_AURA) || player_ptr->ult_res || player_ptr->tim_regen) {
1013 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1016 if (player_ptr->muta.has(PlayerMutationType::FLESH_ROT))
1022 void update_curses(PlayerType *player_ptr)
1025 player_ptr->cursed.clear();
1026 player_ptr->cursed_special.clear();
1028 if (player_ptr->ppersonality == PERSONALITY_SEXY)
1029 player_ptr->cursed.set(CurseTraitType::AGGRAVATE);
1031 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1032 o_ptr = &player_ptr->inventory_list[i];
1035 auto flgs = object_flags(o_ptr);
1036 if (flgs.has(TR_AGGRAVATE))
1037 player_ptr->cursed.set(CurseTraitType::AGGRAVATE);
1038 if (flgs.has(TR_DRAIN_EXP))
1039 player_ptr->cursed.set(CurseTraitType::DRAIN_EXP);
1040 if (flgs.has(TR_TY_CURSE))
1041 player_ptr->cursed.set(CurseTraitType::TY_CURSE);
1042 if (flgs.has(TR_ADD_L_CURSE))
1043 player_ptr->cursed.set(CurseTraitType::ADD_L_CURSE);
1044 if (flgs.has(TR_ADD_H_CURSE))
1045 player_ptr->cursed.set(CurseTraitType::ADD_H_CURSE);
1046 if (flgs.has(TR_DRAIN_HP))
1047 player_ptr->cursed.set(CurseTraitType::DRAIN_HP);
1048 if (flgs.has(TR_DRAIN_MANA))
1049 player_ptr->cursed.set(CurseTraitType::DRAIN_MANA);
1050 if (flgs.has(TR_CALL_ANIMAL))
1051 player_ptr->cursed.set(CurseTraitType::CALL_ANIMAL);
1052 if (flgs.has(TR_CALL_DEMON))
1053 player_ptr->cursed.set(CurseTraitType::CALL_DEMON);
1054 if (flgs.has(TR_CALL_DRAGON))
1055 player_ptr->cursed.set(CurseTraitType::CALL_DRAGON);
1056 if (flgs.has(TR_CALL_UNDEAD))
1057 player_ptr->cursed.set(CurseTraitType::CALL_UNDEAD);
1058 if (flgs.has(TR_COWARDICE))
1059 player_ptr->cursed.set(CurseTraitType::COWARDICE);
1060 if (flgs.has(TR_LOW_MELEE))
1061 player_ptr->cursed.set(CurseTraitType::LOW_MELEE);
1062 if (flgs.has(TR_LOW_AC))
1063 player_ptr->cursed.set(CurseTraitType::LOW_AC);
1064 if (flgs.has(TR_HARD_SPELL))
1065 player_ptr->cursed.set(CurseTraitType::HARD_SPELL);
1066 if (flgs.has(TR_FAST_DIGEST))
1067 player_ptr->cursed.set(CurseTraitType::FAST_DIGEST);
1068 if (flgs.has(TR_SLOW_REGEN))
1069 player_ptr->cursed.set(CurseTraitType::SLOW_REGEN);
1070 if (flgs.has(TR_BERS_RAGE))
1071 player_ptr->cursed.set(CurseTraitType::BERS_RAGE);
1073 auto obj_curse_flags = o_ptr->curse_flags;
1074 obj_curse_flags.reset({ CurseTraitType::CURSED, CurseTraitType::HEAVY_CURSE, CurseTraitType::PERMA_CURSE });
1075 player_ptr->cursed.set(obj_curse_flags);
1076 if (o_ptr->name1 == ART_CHAINSWORD)
1077 player_ptr->cursed_special.set(CurseSpecialTraitType::CHAINSWORD);
1079 if (flgs.has(TR_TELEPORT)) {
1080 if (o_ptr->is_cursed())
1081 player_ptr->cursed.set(CurseTraitType::TELEPORT);
1083 concptr insc = quark_str(o_ptr->inscription);
1085 /* {.} will stop random teleportation. */
1086 if (o_ptr->inscription && angband_strchr(insc, '.')) {
1088 player_ptr->cursed_special.set(CurseSpecialTraitType::TELEPORT_SELF);
1094 if (player_ptr->cursed.has(CurseTraitType::TELEPORT))
1095 player_ptr->cursed_special.reset(CurseSpecialTraitType::TELEPORT_SELF);
1098 BIT_FLAGS has_impact(PlayerType *player_ptr)
1100 return common_cause_flags(player_ptr, TR_IMPACT);
1103 BIT_FLAGS has_earthquake(PlayerType *player_ptr)
1105 return common_cause_flags(player_ptr, TR_EARTHQUAKE);
1108 void update_extra_blows(PlayerType *player_ptr)
1111 player_ptr->extra_blows[0] = player_ptr->extra_blows[1] = 0;
1113 const melee_type melee_type = player_melee_type(player_ptr);
1114 const bool two_handed = (melee_type == MELEE_TYPE_WEAPON_TWOHAND || melee_type == MELEE_TYPE_BAREHAND_TWO);
1116 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1117 o_ptr = &player_ptr->inventory_list[i];
1121 auto flgs = object_flags(o_ptr);
1122 if (flgs.has(TR_BLOWS)) {
1123 if ((i == INVEN_MAIN_HAND || i == INVEN_MAIN_RING) && !two_handed)
1124 player_ptr->extra_blows[0] += o_ptr->pval;
1125 else if ((i == INVEN_SUB_HAND || i == INVEN_SUB_RING) && !two_handed)
1126 player_ptr->extra_blows[1] += o_ptr->pval;
1128 player_ptr->extra_blows[0] += o_ptr->pval;
1129 player_ptr->extra_blows[1] += o_ptr->pval;
1135 BIT_FLAGS has_resist_acid(PlayerType *player_ptr)
1137 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_ACID);
1139 if (player_ptr->ult_res) {
1140 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1143 result |= has_immune_acid(player_ptr);
1148 BIT_FLAGS has_vuln_acid(PlayerType *player_ptr)
1150 BIT_FLAGS result = common_cause_flags(player_ptr, TR_VUL_ACID);
1152 if (player_ptr->muta.has(PlayerMutationType::VULN_ELEM)) {
1153 result |= FLAG_CAUSE_MUTATION;
1159 BIT_FLAGS has_resist_elec(PlayerType *player_ptr)
1161 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_ELEC);
1163 if (player_ptr->ult_res) {
1164 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1167 result |= has_immune_elec(player_ptr);
1172 BIT_FLAGS has_vuln_elec(PlayerType *player_ptr)
1174 BIT_FLAGS result = common_cause_flags(player_ptr, TR_VUL_ELEC);
1176 if (player_ptr->muta.has(PlayerMutationType::VULN_ELEM)) {
1177 result |= FLAG_CAUSE_MUTATION;
1183 BIT_FLAGS has_resist_fire(PlayerType *player_ptr)
1185 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_FIRE);
1187 if (player_ptr->ult_res) {
1188 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1191 result |= has_immune_fire(player_ptr);
1196 BIT_FLAGS has_vuln_fire(PlayerType *player_ptr)
1198 BIT_FLAGS result = common_cause_flags(player_ptr, TR_VUL_FIRE);
1200 if (player_ptr->muta.has(PlayerMutationType::VULN_ELEM)) {
1201 result |= FLAG_CAUSE_MUTATION;
1207 BIT_FLAGS has_resist_cold(PlayerType *player_ptr)
1209 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_COLD);
1211 if (player_ptr->ult_res) {
1212 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1215 result |= has_immune_cold(player_ptr);
1220 BIT_FLAGS has_vuln_cold(PlayerType *player_ptr)
1222 BIT_FLAGS result = common_cause_flags(player_ptr, TR_VUL_COLD);
1224 if (player_ptr->muta.has(PlayerMutationType::VULN_ELEM)) {
1225 result |= FLAG_CAUSE_MUTATION;
1231 BIT_FLAGS has_resist_pois(PlayerType *player_ptr)
1233 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_POIS);
1235 if (player_ptr->ult_res) {
1236 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1242 BIT_FLAGS has_resist_conf(PlayerType *player_ptr)
1244 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_CONF);
1246 if (player_ptr->ppersonality == PERSONALITY_CHARGEMAN || player_ptr->ppersonality == PERSONALITY_MUNCHKIN) {
1247 result |= FLAG_CAUSE_PERSONALITY;
1250 if (player_ptr->ult_res || player_ptr->magicdef) {
1251 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1257 BIT_FLAGS has_resist_sound(PlayerType *player_ptr)
1259 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_SOUND);
1261 if (player_ptr->ult_res) {
1262 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1268 BIT_FLAGS has_resist_lite(PlayerType *player_ptr)
1270 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_LITE);
1272 if (player_ptr->ult_res) {
1273 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1279 BIT_FLAGS has_vuln_lite(PlayerType *player_ptr)
1281 BIT_FLAGS result = common_cause_flags(player_ptr, TR_VUL_LITE);
1283 if (player_ptr->wraith_form) {
1284 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1290 BIT_FLAGS has_resist_dark(PlayerType *player_ptr)
1292 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_DARK);
1294 if (player_ptr->ult_res) {
1295 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1301 BIT_FLAGS has_resist_chaos(PlayerType *player_ptr)
1303 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_CHAOS);
1305 if (player_ptr->ult_res) {
1306 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1312 BIT_FLAGS has_resist_disen(PlayerType *player_ptr)
1314 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_DISEN);
1316 if (player_ptr->ult_res) {
1317 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1323 BIT_FLAGS has_resist_shard(PlayerType *player_ptr)
1325 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_SHARDS);
1327 if (player_ptr->ult_res) {
1328 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1334 BIT_FLAGS has_resist_nexus(PlayerType *player_ptr)
1336 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_NEXUS);
1338 if (player_ptr->ult_res) {
1339 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1345 BIT_FLAGS has_resist_blind(PlayerType *player_ptr)
1347 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_BLIND);
1349 if (player_ptr->ppersonality == PERSONALITY_MUNCHKIN) {
1350 result |= FLAG_CAUSE_PERSONALITY;
1353 if (player_ptr->ult_res || player_ptr->magicdef) {
1354 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1360 BIT_FLAGS has_resist_neth(PlayerType *player_ptr)
1362 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_NETHER);
1364 if (player_ptr->ult_res || player_ptr->tim_res_nether) {
1365 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1371 BIT_FLAGS has_resist_time(PlayerType *player_ptr)
1373 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_TIME);
1375 if (player_ptr->ult_res || player_ptr->tim_res_time) {
1376 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1382 BIT_FLAGS has_resist_water(PlayerType *player_ptr)
1384 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_WATER);
1386 if (player_ptr->ult_res) {
1387 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1395 * @brief 呪力耐性を所持しているかどうか
1396 * @param プレイヤー情報への参照ポインタ
1397 * @return 呪力耐性を所持していればTRUE、なければFALSE
1399 BIT_FLAGS has_resist_curse(PlayerType *player_ptr)
1401 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_CURSE);
1403 if (player_ptr->ult_res) {
1404 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1410 BIT_FLAGS has_resist_fear(PlayerType *player_ptr)
1412 BIT_FLAGS result = common_cause_flags(player_ptr, TR_RES_FEAR);
1414 if (player_ptr->muta.has(PlayerMutationType::FEARLESS))
1415 result |= FLAG_CAUSE_MUTATION;
1417 if (is_hero(player_ptr) || is_shero(player_ptr) || player_ptr->ult_res) {
1418 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1424 BIT_FLAGS has_immune_acid(PlayerType *player_ptr)
1426 BIT_FLAGS result = common_cause_flags(player_ptr, TR_IM_ACID);
1428 if (player_ptr->ele_immune) {
1429 if (player_ptr->special_defense & DEFENSE_ACID)
1430 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1436 BIT_FLAGS has_immune_elec(PlayerType *player_ptr)
1438 BIT_FLAGS result = common_cause_flags(player_ptr, TR_IM_ELEC);
1440 if (player_ptr->ele_immune) {
1441 if (player_ptr->special_defense & DEFENSE_ELEC)
1442 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1448 BIT_FLAGS has_immune_fire(PlayerType *player_ptr)
1450 BIT_FLAGS result = common_cause_flags(player_ptr, TR_IM_FIRE);
1452 if (player_ptr->ele_immune) {
1453 if (player_ptr->special_defense & DEFENSE_FIRE)
1454 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1460 BIT_FLAGS has_immune_cold(PlayerType *player_ptr)
1462 BIT_FLAGS result = common_cause_flags(player_ptr, TR_IM_COLD);
1464 if (player_ptr->ele_immune) {
1465 if (player_ptr->special_defense & DEFENSE_COLD)
1466 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1472 BIT_FLAGS has_immune_dark(PlayerType *player_ptr)
1474 BIT_FLAGS result = common_cause_flags(player_ptr, TR_IM_DARK);
1476 if (player_ptr->wraith_form) {
1477 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1483 melee_type player_melee_type(PlayerType *player_ptr)
1485 if (has_two_handed_weapons(player_ptr))
1486 return MELEE_TYPE_WEAPON_TWOHAND;
1488 if (has_melee_weapon(player_ptr, INVEN_MAIN_HAND)) {
1489 if (has_melee_weapon(player_ptr, INVEN_SUB_HAND)) {
1490 return MELEE_TYPE_WEAPON_DOUBLE;
1492 return MELEE_TYPE_WEAPON_MAIN;
1495 if (has_melee_weapon(player_ptr, INVEN_SUB_HAND))
1496 return MELEE_TYPE_WEAPON_SUB;
1498 if (empty_hands(player_ptr, false) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
1499 return MELEE_TYPE_BAREHAND_TWO;
1501 if (empty_hands(player_ptr, false) == EMPTY_HAND_MAIN)
1502 return MELEE_TYPE_BAREHAND_MAIN;
1504 if (empty_hands(player_ptr, false) == EMPTY_HAND_SUB)
1505 return MELEE_TYPE_BAREHAND_SUB;
1507 return MELEE_TYPE_SHIELD_DOUBLE;
1511 * @brief 利き手で攻撃可能かどうかを判定する
1512 * 利き手で攻撃可能とは、利き手に武器を持っているか、
1513 * 利き手が素手かつ左手も素手もしくは盾を装備している事を意味する。
1514 * @details Includes martial arts and hand combats as weapons.
1516 bool can_attack_with_main_hand(PlayerType *player_ptr)
1518 if (has_melee_weapon(player_ptr, INVEN_MAIN_HAND))
1521 if ((empty_hands(player_ptr, true) & EMPTY_HAND_MAIN) && !can_attack_with_sub_hand(player_ptr))
1528 * @brief 非利き手で攻撃可能かどうかを判定する
1529 * 非利き手で攻撃可能とは、非利き手に武器を持っている事に等しい
1530 * @details Exclude martial arts and hand combats from weapons.
1532 bool can_attack_with_sub_hand(PlayerType *player_ptr)
1534 return has_melee_weapon(player_ptr, INVEN_SUB_HAND);
1538 * @brief 両手持ち状態かどうかを判定する
1540 bool has_two_handed_weapons(PlayerType *player_ptr)
1542 if (can_two_hands_wielding(player_ptr)) {
1543 if (can_attack_with_main_hand(player_ptr) && (empty_hands(player_ptr, false) == EMPTY_HAND_SUB)
1544 && player_ptr->inventory_list[INVEN_MAIN_HAND].allow_two_hands_wielding()) {
1546 } else if (can_attack_with_sub_hand(player_ptr) && (empty_hands(player_ptr, false) == EMPTY_HAND_MAIN)
1547 && player_ptr->inventory_list[INVEN_SUB_HAND].allow_two_hands_wielding()) {
1554 BIT_FLAGS has_lite(PlayerType *player_ptr)
1556 BIT_FLAGS result = 0L;
1557 if (player_ptr->pclass == PlayerClassType::NINJA)
1560 if (player_ptr->ppersonality == PERSONALITY_MUNCHKIN) {
1561 result |= FLAG_CAUSE_PERSONALITY;
1564 if (PlayerRace(player_ptr).tr_flags().has(TR_LITE_1))
1565 result |= FLAG_CAUSE_RACE;
1567 if (player_ptr->ult_res) {
1568 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1571 result |= has_sh_fire(player_ptr);
1577 * @brief 両手持ちボーナスがもらえないかどうかを判定する。 / Does *not * get two hand wielding bonus.
1579 * Only can get hit bonuses when wieids an enough light weapon which is lighter than 5 times of weight limit.
1580 * If its weight is 10 times heavier or more than weight limit, gets hit penalty in calc_to_hit().
1582 bool has_disable_two_handed_bonus(PlayerType *player_ptr, int i)
1584 if (has_melee_weapon(player_ptr, INVEN_MAIN_HAND + i) && has_two_handed_weapons(player_ptr)) {
1585 object_type *o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + i];
1586 int limit = calc_weapon_weight_limit(player_ptr);
1588 /* Enable when two hand wields an enough light weapon */
1589 if (limit >= o_ptr->weight / 5)
1593 /* Disable when empty hands, one hand wieldings and heavy weapons */
1598 * @brief ふさわしくない武器を持っているかどうかを返す。
1599 * @todo 相応しい時にFALSEで相応しくない時にTRUEという負論理は良くない、後で修正する
1601 bool is_wielding_icky_weapon(PlayerType *player_ptr, int i)
1603 auto *o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + i];
1604 auto flgs = object_flags(o_ptr);
1606 auto has_no_weapon = (o_ptr->tval == ItemKindType::NONE) || (o_ptr->tval == ItemKindType::SHIELD);
1607 if (player_ptr->pclass == PlayerClassType::PRIEST) {
1608 auto is_suitable_weapon = flgs.has(TR_BLESSED);
1609 is_suitable_weapon |= (o_ptr->tval != ItemKindType::SWORD) && (o_ptr->tval != ItemKindType::POLEARM);
1610 return !has_no_weapon && !is_suitable_weapon;
1613 if (player_ptr->pclass == PlayerClassType::SORCERER) {
1614 auto is_suitable_weapon = o_ptr->tval == ItemKindType::HAFTED;
1615 is_suitable_weapon &= (o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER);
1616 return !has_no_weapon && !is_suitable_weapon;
1619 return has_not_monk_weapon(player_ptr, i) || has_not_ninja_weapon(player_ptr, i);
1623 * @brief 乗馬にふさわしくない武器を持って乗馬しているかどうかを返す.
1624 * @param player_ptr プレイヤーへの参照ポインタ
1625 * @param i 武器を持っている手。0ならば利き手、1ならば反対の手
1627 bool is_wielding_icky_riding_weapon(PlayerType *player_ptr, int i)
1629 auto *o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + i];
1630 auto flgs = object_flags(o_ptr);
1631 auto has_no_weapon = (o_ptr->tval == ItemKindType::NONE) || (o_ptr->tval == ItemKindType::SHIELD);
1632 auto is_suitable = o_ptr->is_lance() || flgs.has(TR_RIDING);
1633 return (player_ptr->riding > 0) && !has_no_weapon && !is_suitable;
1636 bool has_not_ninja_weapon(PlayerType *player_ptr, int i)
1638 if (!has_melee_weapon(player_ptr, INVEN_MAIN_HAND + i)) {
1642 auto tval = player_ptr->inventory_list[INVEN_MAIN_HAND + i].tval;
1643 auto sval = player_ptr->inventory_list[INVEN_MAIN_HAND + i].sval;
1644 return player_ptr->pclass == PlayerClassType::NINJA &&
1645 !((s_info[enum2i(PlayerClassType::NINJA)].w_max[tval][sval] > PlayerSkill::weapon_exp_at(PlayerSkillRank::BEGINNER)) &&
1646 (player_ptr->inventory_list[INVEN_SUB_HAND - i].tval != ItemKindType::SHIELD));
1649 bool has_not_monk_weapon(PlayerType *player_ptr, int i)
1651 if (!has_melee_weapon(player_ptr, INVEN_MAIN_HAND + i)) {
1655 auto tval = player_ptr->inventory_list[INVEN_MAIN_HAND + i].tval;
1656 auto sval = player_ptr->inventory_list[INVEN_MAIN_HAND + i].sval;
1657 return ((player_ptr->pclass == PlayerClassType::MONK) || (player_ptr->pclass == PlayerClassType::FORCETRAINER)) && !(s_info[enum2i(player_ptr->pclass)].w_max[tval][sval]);
1660 bool has_good_luck(PlayerType *player_ptr)
1662 return (player_ptr->ppersonality == PERSONALITY_LUCKY) || (player_ptr->muta.has(PlayerMutationType::GOOD_LUCK));
1665 BIT_FLAGS player_aggravate_state(PlayerType *player_ptr)
1667 if (player_ptr->cursed.has(CurseTraitType::AGGRAVATE)) {
1668 if ((PlayerRace(player_ptr).equals(PlayerRaceType::S_FAIRY)) && (player_ptr->ppersonality != PERSONALITY_SEXY)) {
1669 return AGGRAVATE_S_FAIRY;
1671 return AGGRAVATE_NORMAL;
1674 return AGGRAVATE_NONE;
1677 bool has_aggravate(PlayerType *player_ptr)
1679 return player_aggravate_state(player_ptr) == AGGRAVATE_NORMAL;