1 #include "player/player-status-flags.h"
2 #include "artifact/fixed-art-types.h"
4 #include "inventory/inventory-slot-types.h"
5 #include "mind/mind-elementalist.h"
6 #include "monster-race/monster-race.h"
7 #include "monster-race/race-flags2.h"
8 #include "monster-race/race-flags7.h"
9 #include "mutation/mutation-flag-types.h"
10 #include "object-enchant/object-ego.h"
11 #include "object-enchant/tr-types.h"
12 #include "object-enchant/trc-types.h"
13 #include "object-hook/hook-checker.h"
14 #include "object-hook/hook-weapon.h"
15 #include "object/object-flags.h"
16 #include "player-info/equipment-info.h"
17 #include "player-status/player-basic-statistics.h"
18 #include "player-status/player-hand-types.h"
19 #include "player-status/player-infravision.h"
20 #include "player-status/player-speed.h"
21 #include "player-status/player-stealth.h"
22 #include "player/attack-defense-types.h"
23 #include "player/digestion-processor.h"
24 #include "player/mimic-info-table.h"
25 #include "player/player-class.h"
26 #include "player/player-race-types.h"
27 #include "player/player-race.h"
28 #include "player/player-skill.h"
29 #include "player/player-status.h"
30 #include "player/race-info-table.h"
31 #include "player/special-defense-types.h"
32 #include "realm/realm-hex-numbers.h"
33 #include "realm/realm-song-numbers.h"
34 #include "realm/realm-types.h"
35 #include "spell-realm/spells-hex.h"
36 #include "spell-realm/spells-song.h"
37 #include "sv-definition/sv-weapon-types.h"
38 #include "system/floor-type-definition.h"
39 #include "system/monster-race-definition.h"
40 #include "system/monster-type-definition.h"
41 #include "system/object-type-definition.h"
42 #include "system/player-type-definition.h"
43 #include "util/bit-flags-calculator.h"
44 #include "util/quarks.h"
45 #include "util/string-processor.h"
50 BIT_FLAGS convert_inventory_slot_type_to_flag_cause(inventory_slot_type inventory_slot)
52 switch (inventory_slot) {
54 return FLAG_CAUSE_INVEN_MAIN_HAND;
56 return FLAG_CAUSE_INVEN_SUB_HAND;
58 return FLAG_CAUSE_INVEN_BOW;
60 return FLAG_CAUSE_INVEN_MAIN_RING;
62 return FLAG_CAUSE_INVEN_SUB_RING;
64 return FLAG_CAUSE_INVEN_NECK;
66 return FLAG_CAUSE_INVEN_LITE;
68 return FLAG_CAUSE_INVEN_BODY;
70 return FLAG_CAUSE_INVEN_OUTER;
72 return FLAG_CAUSE_INVEN_HEAD;
74 return FLAG_CAUSE_INVEN_ARMS;
76 return FLAG_CAUSE_INVEN_FEET;
84 * @brief 装備による所定の特性フラグを得ているかを一括して取得する関数。
86 BIT_FLAGS check_equipment_flags(player_type *creature_ptr, tr_type tr_flag)
89 BIT_FLAGS flgs[TR_FLAG_SIZE];
90 BIT_FLAGS result = 0L;
91 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
92 o_ptr = &creature_ptr->inventory_list[i];
96 object_flags(creature_ptr, o_ptr, flgs);
98 if (has_flag(flgs, tr_flag))
99 set_bits(result, convert_inventory_slot_type_to_flag_cause(static_cast<inventory_slot_type>(i)));
104 BIT_FLAGS player_flags_brand_pois(player_type *creature_ptr)
106 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_BRAND_POIS);
108 if (creature_ptr->special_attack & ATTACK_POIS)
109 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
114 BIT_FLAGS player_flags_brand_acid(player_type *creature_ptr)
116 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_BRAND_ACID);
118 if (creature_ptr->special_attack & ATTACK_ACID)
119 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
124 BIT_FLAGS player_flags_brand_elec(player_type *creature_ptr)
126 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_BRAND_ELEC);
128 if (creature_ptr->special_attack & ATTACK_ELEC)
129 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
134 BIT_FLAGS player_flags_brand_fire(player_type *creature_ptr)
136 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_BRAND_FIRE);
138 if (creature_ptr->special_attack & ATTACK_FIRE)
139 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
144 BIT_FLAGS player_flags_brand_cold(player_type *creature_ptr)
146 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_BRAND_COLD);
148 if (creature_ptr->special_attack & ATTACK_COLD)
149 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
155 * @brief プレイヤーの所持するフラグのうち、tr_flagに対応するものを返す
156 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
157 * @param tr_flag 要求する装備フラグ
159 BIT_FLAGS get_player_flags(player_type *creature_ptr, tr_type tr_flag)
163 return PlayerStrength(creature_ptr).get_all_flags();
165 return PlayerIntelligence(creature_ptr).get_all_flags();
167 return PlayerWisdom(creature_ptr).get_all_flags();
169 return PlayerDexterity(creature_ptr).get_all_flags();
171 return PlayerConstitution(creature_ptr).get_all_flags();
173 return PlayerCharisma(creature_ptr).get_all_flags();
174 case TR_MAGIC_MASTERY:
175 return has_magic_mastery(creature_ptr);
176 case TR_FORCE_WEAPON:
177 return check_equipment_flags(creature_ptr, tr_flag);
179 return PlayerStealth(creature_ptr).get_all_flags();
183 return PlayerInfravision(creature_ptr).get_all_flags();
187 return PlayerSpeed(creature_ptr).get_all_flags();
202 return check_equipment_flags(creature_ptr, tr_flag);
204 return has_earthquake(creature_ptr);
206 return player_flags_brand_pois(creature_ptr);
208 return player_flags_brand_acid(creature_ptr);
210 return player_flags_brand_elec(creature_ptr);
212 return player_flags_brand_fire(creature_ptr);
214 return player_flags_brand_cold(creature_ptr);
217 return has_sustain_str(creature_ptr);
219 return has_sustain_int(creature_ptr);
221 return has_sustain_wis(creature_ptr);
223 return has_sustain_dex(creature_ptr);
225 return has_sustain_con(creature_ptr);
227 return has_sustain_chr(creature_ptr);
229 return check_equipment_flags(creature_ptr, tr_flag);
231 return has_easy_spell(creature_ptr);
233 return has_immune_acid(creature_ptr);
235 return has_immune_elec(creature_ptr);
237 return has_immune_fire(creature_ptr);
239 return has_immune_cold(creature_ptr);
241 return check_equipment_flags(creature_ptr, tr_flag);
243 return has_reflect(creature_ptr);
245 return has_free_act(creature_ptr);
247 return has_hold_exp(creature_ptr);
249 return has_resist_acid(creature_ptr);
251 return has_resist_elec(creature_ptr);
253 return has_resist_fire(creature_ptr);
255 return has_resist_cold(creature_ptr);
257 return has_resist_pois(creature_ptr);
259 return has_resist_fear(creature_ptr);
261 return has_resist_lite(creature_ptr);
263 return has_resist_dark(creature_ptr);
265 return has_resist_blind(creature_ptr);
267 return has_resist_conf(creature_ptr);
269 return has_resist_sound(creature_ptr);
271 return has_resist_shard(creature_ptr);
273 return has_resist_neth(creature_ptr);
275 return has_resist_nexus(creature_ptr);
277 return has_resist_chaos(creature_ptr);
279 return has_resist_disen(creature_ptr);
281 return has_resist_time(creature_ptr);
283 return has_resist_water(creature_ptr);
285 return has_resist_curse(creature_ptr);
288 return has_sh_fire(creature_ptr);
290 return has_sh_elec(creature_ptr);
292 return check_equipment_flags(creature_ptr, tr_flag);
294 return has_sh_cold(creature_ptr);
296 return has_anti_tele(creature_ptr);
298 return has_anti_magic(creature_ptr);
300 return has_dec_mana(creature_ptr);
302 return check_equipment_flags(creature_ptr, tr_flag);
304 return has_warning(creature_ptr);
308 return check_equipment_flags(creature_ptr, tr_flag);
310 return has_levitation(creature_ptr);
312 return has_lite(creature_ptr);
314 return has_see_inv(creature_ptr);
316 return has_esp_telepathy(creature_ptr);
318 return has_slow_digest(creature_ptr);
320 return has_regenerate(creature_ptr);
322 return has_xtra_might(creature_ptr);
331 return check_equipment_flags(creature_ptr, tr_flag);
335 return has_bless_blade(creature_ptr);
347 return check_equipment_flags(creature_ptr, tr_flag);
349 return has_esp_animal(creature_ptr);
351 return has_esp_undead(creature_ptr);
353 return has_esp_demon(creature_ptr);
355 return has_esp_orc(creature_ptr);
357 return has_esp_troll(creature_ptr);
359 return has_esp_giant(creature_ptr);
361 return has_esp_dragon(creature_ptr);
363 return has_esp_human(creature_ptr);
365 return has_esp_evil(creature_ptr);
367 return has_esp_good(creature_ptr);
368 case TR_ESP_NONLIVING:
369 return has_esp_nonliving(creature_ptr);
371 return has_esp_unique(creature_ptr);
373 case TR_FIXED_FLAVOR:
394 return check_equipment_flags(creature_ptr, tr_flag);
395 case TR_MIGHTY_THROW:
396 return has_mighty_throw(creature_ptr);
397 case TR_EASY2_WEAPON:
398 return has_easy2_weapon(creature_ptr);
400 return has_down_saving(creature_ptr);
402 return has_no_ac(creature_ptr);
404 return has_heavy_spell(creature_ptr);
405 case TR_INVULN_ARROW:
406 return has_invuln_arrow(creature_ptr);
411 return check_equipment_flags(creature_ptr, tr_flag);
413 return has_impact(creature_ptr);
415 return has_vuln_acid(creature_ptr);
417 return has_vuln_cold(creature_ptr);
419 return has_vuln_elec(creature_ptr);
421 return has_vuln_fire(creature_ptr);
423 return has_vuln_lite(creature_ptr);
425 return has_immune_dark(creature_ptr);
434 * @brief クリーチャーが壁破壊進行を持っているかを返す。
436 bool has_kill_wall(player_type *creature_ptr)
438 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || music_singing(creature_ptr, MUSIC_WALL)) {
442 if (creature_ptr->riding) {
443 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
444 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
445 if (riding_r_ptr->flags2 & RF2_KILL_WALL)
453 * @brief クリーチャーが壁通過を持っているかを返す。
454 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
457 * * 時限で幽体化、壁抜けをもつか種族幽霊ならばひとまずTRUE。
458 * * 但し騎乗中は乗騎が壁抜けを持っていなければ不能になる。
460 bool has_pass_wall(player_type *creature_ptr)
464 if (creature_ptr->wraith_form || creature_ptr->tim_pass_wall || (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE)) {
468 if (creature_ptr->riding) {
469 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
470 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
471 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL))
479 * @brief クリーチャーが強力射を持っているかを返す。
480 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
481 * @return 持っていたら所持前提ビットフラグを返す。
483 BIT_FLAGS has_xtra_might(player_type *creature_ptr)
485 BIT_FLAGS result = 0L;
486 result |= check_equipment_flags(creature_ptr, TR_XTRA_MIGHT);
491 * @brief クリーチャーが邪悪感知を持っているかを返す。
492 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
493 * @return 持っていたら所持前提ビットフラグを返す。
495 BIT_FLAGS has_esp_evil(player_type *creature_ptr)
497 BIT_FLAGS result = 0L;
498 if (creature_ptr->realm1 == REALM_HEX) {
499 if (hex_spelling(creature_ptr, HEX_DETECT_EVIL))
500 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
502 result |= check_equipment_flags(creature_ptr, TR_ESP_EVIL);
507 * @brief クリーチャーが自然界の動物感知を持っているかを返す。
508 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
509 * @return 持っていたら所持前提ビットフラグを返す。
511 BIT_FLAGS has_esp_animal(player_type *creature_ptr)
513 return check_equipment_flags(creature_ptr, TR_ESP_ANIMAL);
517 * @brief クリーチャーがアンデッド感知を持っているかを返す。
518 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
519 * @return 持っていたら所持前提ビットフラグを返す。
521 BIT_FLAGS has_esp_undead(player_type *creature_ptr)
523 return check_equipment_flags(creature_ptr, TR_ESP_UNDEAD);
527 * @brief クリーチャーが悪魔感知を持っているかを返す。
528 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
529 * @return 持っていたら所持前提ビットフラグを返す。
531 BIT_FLAGS has_esp_demon(player_type *creature_ptr)
533 return check_equipment_flags(creature_ptr, TR_ESP_DEMON);
537 * @brief クリーチャーがオーク感知を持っているかを返す。
538 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
539 * @return 持っていたら所持前提ビットフラグを返す。
541 BIT_FLAGS has_esp_orc(player_type *creature_ptr)
543 return check_equipment_flags(creature_ptr, TR_ESP_ORC);
547 * @brief クリーチャーがトロル感知を持っているかを返す。
548 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
549 * @return 持っていたら所持前提ビットフラグを返す。
551 BIT_FLAGS has_esp_troll(player_type *creature_ptr)
553 return check_equipment_flags(creature_ptr, TR_ESP_TROLL);
557 * @brief クリーチャーが巨人感知を持っているかを返す。
558 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
559 * @return 持っていたら所持前提ビットフラグを返す。
561 BIT_FLAGS has_esp_giant(player_type *creature_ptr)
563 return check_equipment_flags(creature_ptr, TR_ESP_GIANT);
567 * @brief クリーチャーがドラゴン感知を持っているかを返す。
568 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
569 * @return 持っていたら所持前提ビットフラグを返す。
571 BIT_FLAGS has_esp_dragon(player_type *creature_ptr)
573 return check_equipment_flags(creature_ptr, TR_ESP_DRAGON);
577 * @brief クリーチャーが人間感知を持っているかを返す。
578 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
579 * @return 持っていたら所持前提ビットフラグを返す。
581 BIT_FLAGS has_esp_human(player_type *creature_ptr)
583 return check_equipment_flags(creature_ptr, TR_ESP_HUMAN);
587 * @brief クリーチャーが善良感知を持っているかを返す。
588 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
589 * @return 持っていたら所持前提ビットフラグを返す。
591 BIT_FLAGS has_esp_good(player_type *creature_ptr)
593 return check_equipment_flags(creature_ptr, TR_ESP_GOOD);
597 * @brief クリーチャーが無生物感知を持っているかを返す。
598 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
599 * @return 持っていたら所持前提ビットフラグを返す。
601 BIT_FLAGS has_esp_nonliving(player_type *creature_ptr)
603 return check_equipment_flags(creature_ptr, TR_ESP_NONLIVING);
607 * @brief クリーチャーがユニーク感知を持っているかを返す。
608 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
609 * @return 持っていたら所持前提ビットフラグを返す。
611 BIT_FLAGS has_esp_unique(player_type *creature_ptr)
613 return check_equipment_flags(creature_ptr, TR_ESP_UNIQUE);
617 * @brief クリーチャーがテレパシーを持っているかを返す。
618 * @param creature_ptr 判定対象のクリーチャー参照ポインタ
619 * @return 持っていたら所持前提ビットフラグを返す。
621 BIT_FLAGS has_esp_telepathy(player_type *creature_ptr)
623 BIT_FLAGS result = 0L;
625 if (is_time_limit_esp(creature_ptr) || creature_ptr->ult_res) {
626 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
628 if (creature_ptr->special_defense & KATA_MUSOU) {
629 result |= FLAG_CAUSE_BATTLE_FORM;
632 if (creature_ptr->muta.has(MUTA::ESP)) {
633 result |= FLAG_CAUSE_MUTATION;
636 if (player_race_has_flag(creature_ptr, TR_TELEPATHY))
637 result |= FLAG_CAUSE_RACE;
639 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 39)
640 result |= FLAG_CAUSE_CLASS;
642 result |= check_equipment_flags(creature_ptr, TR_TELEPATHY);
646 BIT_FLAGS has_bless_blade(player_type *creature_ptr)
648 return check_equipment_flags(creature_ptr, TR_BLESSED);
651 BIT_FLAGS has_easy2_weapon(player_type *creature_ptr)
653 return check_equipment_flags(creature_ptr, TR_EASY2_WEAPON);
656 BIT_FLAGS has_down_saving(player_type *creature_ptr)
658 return check_equipment_flags(creature_ptr, TR_DOWN_SAVING);
661 BIT_FLAGS has_no_ac(player_type *creature_ptr)
663 return check_equipment_flags(creature_ptr, TR_NO_AC);
666 BIT_FLAGS has_invuln_arrow(player_type *creature_ptr)
668 BIT_FLAGS result = 0L;
669 if (creature_ptr->blind)
671 result |= check_equipment_flags(creature_ptr, TR_INVULN_ARROW);
675 void check_no_flowed(player_type *creature_ptr)
678 bool has_sw = FALSE, has_kabe = FALSE;
680 creature_ptr->no_flowed = FALSE;
682 if (has_pass_wall(creature_ptr) && !has_kill_wall(creature_ptr)) {
683 creature_ptr->no_flowed = TRUE;
687 if (!creature_ptr->realm1) {
688 creature_ptr->no_flowed = FALSE;
692 for (int i = 0; i < INVEN_PACK; i++) {
693 if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
695 if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
699 for (const auto this_o_idx : creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx_list) {
700 o_ptr = &creature_ptr->current_floor_ptr->o_list[this_o_idx];
702 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2))
704 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2))
708 if (has_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER))) {
709 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
710 if (creature_ptr->lev >= s_ptr->slevel)
711 creature_ptr->no_flowed = TRUE;
714 if (has_kabe && ((creature_ptr->realm1 == REALM_CRAFT) || (creature_ptr->realm2 == REALM_CRAFT) || (creature_ptr->pclass == CLASS_SORCERER))) {
715 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_WALL];
716 if (creature_ptr->lev >= s_ptr->slevel)
717 creature_ptr->no_flowed = TRUE;
721 BIT_FLAGS has_mighty_throw(player_type *creature_ptr)
723 return check_equipment_flags(creature_ptr, TR_MIGHTY_THROW);
726 BIT_FLAGS has_dec_mana(player_type *creature_ptr)
728 return check_equipment_flags(creature_ptr, TR_DEC_MANA);
731 BIT_FLAGS has_reflect(player_type *creature_ptr)
733 BIT_FLAGS result = 0L;
735 if (creature_ptr->pclass == CLASS_BERSERKER && creature_ptr->lev > 39)
736 result |= FLAG_CAUSE_CLASS;
738 if (creature_ptr->pclass == CLASS_MIRROR_MASTER && creature_ptr->lev > 39)
739 result |= FLAG_CAUSE_CLASS;
741 if (creature_ptr->special_defense & KAMAE_GENBU || creature_ptr->special_defense & KATA_MUSOU) {
742 result |= FLAG_CAUSE_BATTLE_FORM;
745 if (creature_ptr->ult_res || creature_ptr->wraith_form || creature_ptr->magicdef || creature_ptr->tim_reflect) {
746 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
749 if (has_element_resist(creature_ptr, ElementRealm::EARTH, 30))
750 result |= FLAG_CAUSE_CLASS;
752 result |= check_equipment_flags(creature_ptr, TR_REFLECT);
756 BIT_FLAGS has_see_nocto(player_type *creature_ptr)
758 return (creature_ptr->pclass == CLASS_NINJA) ? FLAG_CAUSE_CLASS : FLAG_CAUSE_NONE;
761 BIT_FLAGS has_warning(player_type *creature_ptr)
763 BIT_FLAGS result = 0L;
765 BIT_FLAGS flgs[TR_FLAG_SIZE];
767 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
768 o_ptr = &creature_ptr->inventory_list[i];
772 object_flags(creature_ptr, o_ptr, flgs);
774 if (has_flag(flgs, TR_WARNING)) {
775 if (!o_ptr->inscription || !(angband_strchr(quark_str(o_ptr->inscription), '$')))
776 set_bits(result, convert_inventory_slot_type_to_flag_cause(static_cast<inventory_slot_type>(i)));
782 BIT_FLAGS has_anti_magic(player_type *creature_ptr)
784 return check_equipment_flags(creature_ptr, TR_NO_MAGIC);
787 BIT_FLAGS has_anti_tele(player_type *creature_ptr)
789 return check_equipment_flags(creature_ptr, TR_NO_TELE);
792 BIT_FLAGS has_sh_fire(player_type *creature_ptr)
794 BIT_FLAGS result = 0L;
796 if (creature_ptr->muta.has(MUTA::FIRE_BODY)) {
797 result |= FLAG_CAUSE_MUTATION;
800 if (player_race_has_flag(creature_ptr, TR_SH_FIRE))
801 result |= FLAG_CAUSE_RACE;
803 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
804 result |= FLAG_CAUSE_BATTLE_FORM;
807 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_sh_fire) {
808 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
811 result |= check_equipment_flags(creature_ptr, TR_SH_FIRE);
815 BIT_FLAGS has_sh_elec(player_type *creature_ptr)
817 BIT_FLAGS result = 0L;
819 if (player_race_has_flag(creature_ptr, TR_SH_ELEC))
820 result |= FLAG_CAUSE_RACE;
822 if (creature_ptr->muta.has(MUTA::ELEC_TOUC))
823 result |= FLAG_CAUSE_MUTATION;
825 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK) || creature_ptr->ult_res) {
826 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
829 if (creature_ptr->special_defense & KAMAE_SEIRYU || (creature_ptr->special_defense & KATA_MUSOU)) {
830 result |= FLAG_CAUSE_BATTLE_FORM;
833 result |= check_equipment_flags(creature_ptr, TR_SH_ELEC);
837 BIT_FLAGS has_sh_cold(player_type *creature_ptr)
839 BIT_FLAGS result = 0L;
841 if (player_race_has_flag(creature_ptr, TR_SH_COLD))
842 result |= FLAG_CAUSE_RACE;
844 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
845 result |= FLAG_CAUSE_BATTLE_FORM;
848 if (creature_ptr->ult_res || hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
849 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
852 result |= check_equipment_flags(creature_ptr, TR_SH_COLD);
856 BIT_FLAGS has_easy_spell(player_type *creature_ptr)
858 return check_equipment_flags(creature_ptr, TR_EASY_SPELL);
861 BIT_FLAGS has_heavy_spell(player_type *creature_ptr)
863 return check_equipment_flags(creature_ptr, TR_HEAVY_SPELL);
866 BIT_FLAGS has_hold_exp(player_type *creature_ptr)
868 BIT_FLAGS result = 0L;
870 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
871 result |= FLAG_CAUSE_PERSONALITY;
874 if (player_race_has_flag(creature_ptr, TR_HOLD_EXP))
875 result |= FLAG_CAUSE_RACE;
877 if (creature_ptr->special_defense & KATA_MUSOU) {
878 result |= FLAG_CAUSE_BATTLE_FORM;
881 if (creature_ptr->ult_res) {
882 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
885 result |= check_equipment_flags(creature_ptr, TR_HOLD_EXP);
889 BIT_FLAGS has_see_inv(player_type *creature_ptr)
891 BIT_FLAGS result = 0L;
893 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 29)
894 result |= FLAG_CAUSE_CLASS;
896 if (player_race_has_flag(creature_ptr, TR_SEE_INVIS))
897 result |= FLAG_CAUSE_RACE;
899 if (creature_ptr->special_defense & KATA_MUSOU) {
900 result |= FLAG_CAUSE_BATTLE_FORM;
903 if (creature_ptr->ult_res || creature_ptr->tim_invis) {
904 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
907 result |= check_equipment_flags(creature_ptr, TR_SEE_INVIS);
911 BIT_FLAGS has_magic_mastery(player_type *creature_ptr)
913 return check_equipment_flags(creature_ptr, TR_MAGIC_MASTERY);
916 BIT_FLAGS has_free_act(player_type *creature_ptr)
918 BIT_FLAGS result = 0L;
920 if (creature_ptr->muta.has(MUTA::MOTION))
921 result |= FLAG_CAUSE_MUTATION;
923 if (player_race_has_flag(creature_ptr, TR_FREE_ACT))
924 result |= FLAG_CAUSE_RACE;
926 if (creature_ptr->pclass == CLASS_NINJA && !heavy_armor(creature_ptr)
927 && (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
928 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
929 if (creature_ptr->lev > 24)
930 result |= FLAG_CAUSE_CLASS;
933 if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) {
934 if (!(heavy_armor(creature_ptr))) {
935 if (creature_ptr->lev > 24)
936 result |= FLAG_CAUSE_CLASS;
940 if (creature_ptr->pclass == CLASS_BERSERKER) {
941 result |= FLAG_CAUSE_CLASS;
944 if (creature_ptr->ult_res || creature_ptr->magicdef) {
945 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
948 if (creature_ptr->special_defense & KATA_MUSOU) {
949 result |= FLAG_CAUSE_BATTLE_FORM;
952 result |= check_equipment_flags(creature_ptr, TR_FREE_ACT);
956 BIT_FLAGS has_sustain_str(player_type *creature_ptr)
958 BIT_FLAGS result = 0L;
960 if (creature_ptr->pclass == CLASS_BERSERKER) {
961 result |= FLAG_CAUSE_CLASS;
964 if (player_race_has_flag(creature_ptr, TR_SUST_STR))
965 result |= FLAG_CAUSE_RACE;
967 if (creature_ptr->ult_res) {
968 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
971 if (creature_ptr->special_defense & KATA_MUSOU) {
972 result |= FLAG_CAUSE_BATTLE_FORM;
975 result |= check_equipment_flags(creature_ptr, TR_SUST_STR);
979 BIT_FLAGS has_sustain_int(player_type *creature_ptr)
981 BIT_FLAGS result = 0L;
983 if (player_race_has_flag(creature_ptr, TR_SUST_INT))
984 result |= FLAG_CAUSE_RACE;
986 if (creature_ptr->ult_res) {
987 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
990 if (creature_ptr->special_defense & KATA_MUSOU) {
991 result |= FLAG_CAUSE_BATTLE_FORM;
994 result |= check_equipment_flags(creature_ptr, TR_SUST_INT);
998 BIT_FLAGS has_sustain_wis(player_type *creature_ptr)
1000 BIT_FLAGS result = 0L;
1002 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
1003 result |= FLAG_CAUSE_CLASS;
1005 if (player_race_has_flag(creature_ptr, TR_SUST_WIS))
1006 result |= FLAG_CAUSE_RACE;
1008 if (creature_ptr->ult_res) {
1009 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1012 if (creature_ptr->special_defense & KATA_MUSOU) {
1013 result |= FLAG_CAUSE_BATTLE_FORM;
1016 result |= check_equipment_flags(creature_ptr, TR_SUST_WIS);
1020 BIT_FLAGS has_sustain_dex(player_type *creature_ptr)
1022 BIT_FLAGS result = 0L;
1023 if (creature_ptr->pclass == CLASS_BERSERKER) {
1024 result |= FLAG_CAUSE_CLASS;
1027 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 24)
1028 result |= FLAG_CAUSE_CLASS;
1030 if (player_race_has_flag(creature_ptr, TR_SUST_DEX))
1031 result |= FLAG_CAUSE_RACE;
1033 if (creature_ptr->ult_res) {
1034 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1037 if (creature_ptr->special_defense & KATA_MUSOU) {
1038 result |= FLAG_CAUSE_BATTLE_FORM;
1041 result |= check_equipment_flags(creature_ptr, TR_SUST_DEX);
1045 BIT_FLAGS has_sustain_con(player_type *creature_ptr)
1047 BIT_FLAGS result = 0L;
1048 if (creature_ptr->pclass == CLASS_BERSERKER) {
1049 result |= FLAG_CAUSE_CLASS;
1052 if (player_race_has_flag(creature_ptr, TR_SUST_CON))
1053 result |= FLAG_CAUSE_RACE;
1055 if (creature_ptr->ult_res) {
1056 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1059 if (creature_ptr->special_defense & KATA_MUSOU) {
1060 result |= FLAG_CAUSE_BATTLE_FORM;
1063 result |= check_equipment_flags(creature_ptr, TR_SUST_CON);
1067 BIT_FLAGS has_sustain_chr(player_type *creature_ptr)
1069 BIT_FLAGS result = 0L;
1071 if (player_race_has_flag(creature_ptr, TR_SUST_CHR))
1072 result |= FLAG_CAUSE_RACE;
1074 if (creature_ptr->ult_res) {
1075 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1078 if (creature_ptr->special_defense & KATA_MUSOU) {
1079 result |= FLAG_CAUSE_BATTLE_FORM;
1082 result |= check_equipment_flags(creature_ptr, TR_SUST_CHR);
1086 BIT_FLAGS has_levitation(player_type *creature_ptr)
1088 BIT_FLAGS result = 0L;
1090 if (creature_ptr->muta.has(MUTA::WINGS)) {
1091 result |= FLAG_CAUSE_MUTATION;
1094 if (player_race_has_flag(creature_ptr, TR_LEVITATION))
1095 result |= FLAG_CAUSE_RACE;
1097 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU || (creature_ptr->special_defense & KATA_MUSOU)) {
1098 result |= FLAG_CAUSE_BATTLE_FORM;
1101 if (creature_ptr->ult_res || creature_ptr->magicdef) {
1102 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1105 if (creature_ptr->tim_levitation) {
1106 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1109 result |= check_equipment_flags(creature_ptr, TR_LEVITATION);
1111 if (creature_ptr->riding) {
1112 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1113 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
1114 result = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? FLAG_CAUSE_RIDING : FLAG_CAUSE_NONE;
1119 bool has_can_swim(player_type *creature_ptr)
1121 bool can_swim = FALSE;
1122 if (creature_ptr->riding) {
1123 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1124 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
1125 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
1132 BIT_FLAGS has_slow_digest(player_type *creature_ptr)
1134 BIT_FLAGS result = 0L;
1136 if (creature_ptr->pclass == CLASS_NINJA) {
1137 result |= FLAG_CAUSE_CLASS;
1140 if (player_race_has_flag(creature_ptr, TR_SLOW_DIGEST))
1141 result |= FLAG_CAUSE_RACE;
1143 if (creature_ptr->special_defense & KATA_MUSOU) {
1144 result |= FLAG_CAUSE_BATTLE_FORM;
1147 if (creature_ptr->ult_res) {
1148 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1151 result |= check_equipment_flags(creature_ptr, TR_SLOW_DIGEST);
1155 BIT_FLAGS has_regenerate(player_type *creature_ptr)
1157 BIT_FLAGS result = 0L;
1159 if (creature_ptr->pclass == CLASS_WARRIOR && creature_ptr->lev > 44) {
1160 result |= FLAG_CAUSE_CLASS;
1163 if (creature_ptr->muta.has(MUTA::REGEN))
1164 result |= FLAG_CAUSE_MUTATION;
1166 if (player_race_has_flag(creature_ptr, TR_REGEN))
1167 result |= FLAG_CAUSE_RACE;
1169 if (creature_ptr->special_defense & KATA_MUSOU) {
1170 result |= FLAG_CAUSE_BATTLE_FORM;
1173 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_regen) {
1174 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1177 result |= check_equipment_flags(creature_ptr, TR_REGEN);
1179 if (creature_ptr->muta.has(MUTA::FLESH_ROT))
1185 void update_curses(player_type *creature_ptr)
1188 BIT_FLAGS flgs[TR_FLAG_SIZE];
1189 creature_ptr->cursed = 0L;
1191 if (creature_ptr->pseikaku == PERSONALITY_SEXY)
1192 creature_ptr->cursed |= (TRC_AGGRAVATE);
1194 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1195 o_ptr = &creature_ptr->inventory_list[i];
1198 object_flags(creature_ptr, o_ptr, flgs);
1199 if (has_flag(flgs, TR_AGGRAVATE))
1200 creature_ptr->cursed |= TRC_AGGRAVATE;
1201 if (has_flag(flgs, TR_DRAIN_EXP))
1202 creature_ptr->cursed |= TRC_DRAIN_EXP;
1203 if (has_flag(flgs, TR_TY_CURSE))
1204 creature_ptr->cursed |= TRC_TY_CURSE;
1205 if (has_flag(flgs, TR_ADD_L_CURSE))
1206 creature_ptr->cursed |= TRC_ADD_L_CURSE;
1207 if (has_flag(flgs, TR_ADD_H_CURSE))
1208 creature_ptr->cursed |= TRC_ADD_H_CURSE;
1209 if (has_flag(flgs, TR_DRAIN_HP))
1210 creature_ptr->cursed |= TRC_DRAIN_HP;
1211 if (has_flag(flgs, TR_DRAIN_MANA))
1212 creature_ptr->cursed |= TRC_DRAIN_MANA;
1213 if (has_flag(flgs, TR_CALL_ANIMAL))
1214 creature_ptr->cursed |= TRC_CALL_ANIMAL;
1215 if (has_flag(flgs, TR_CALL_DEMON))
1216 creature_ptr->cursed |= TRC_CALL_DEMON;
1217 if (has_flag(flgs, TR_CALL_DRAGON))
1218 creature_ptr->cursed |= TRC_CALL_DRAGON;
1219 if (has_flag(flgs, TR_CALL_UNDEAD))
1220 creature_ptr->cursed |= TRC_CALL_UNDEAD;
1221 if (has_flag(flgs, TR_COWARDICE))
1222 creature_ptr->cursed |= TRC_COWARDICE;
1223 if (has_flag(flgs, TR_LOW_MELEE))
1224 creature_ptr->cursed |= TRC_LOW_MELEE;
1225 if (has_flag(flgs, TR_LOW_AC))
1226 creature_ptr->cursed |= TRC_LOW_AC;
1227 if (has_flag(flgs, TR_HARD_SPELL))
1228 creature_ptr->cursed |= TRC_HARD_SPELL;
1229 if (has_flag(flgs, TR_FAST_DIGEST))
1230 creature_ptr->cursed |= TRC_FAST_DIGEST;
1231 if (has_flag(flgs, TR_SLOW_REGEN))
1232 creature_ptr->cursed |= TRC_SLOW_REGEN;
1233 if (has_flag(flgs, TR_BERS_RAGE))
1234 creature_ptr->cursed |= TRC_BERS_RAGE;
1236 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
1237 if (o_ptr->name1 == ART_CHAINSWORD)
1238 creature_ptr->cursed |= TRC_CHAINSWORD;
1240 if (has_flag(flgs, TR_TELEPORT)) {
1241 if (object_is_cursed(o_ptr))
1242 creature_ptr->cursed |= TRC_TELEPORT;
1244 concptr insc = quark_str(o_ptr->inscription);
1246 /* {.} will stop random teleportation. */
1247 if (o_ptr->inscription && angband_strchr(insc, '.')) {
1249 creature_ptr->cursed |= TRC_TELEPORT_SELF;
1255 if (creature_ptr->cursed & TRC_TELEPORT)
1256 creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
1259 BIT_FLAGS has_impact(player_type *creature_ptr)
1261 return check_equipment_flags(creature_ptr, TR_IMPACT);
1264 BIT_FLAGS has_earthquake(player_type *creature_ptr)
1266 return check_equipment_flags(creature_ptr, TR_EARTHQUAKE);
1269 void update_extra_blows(player_type *creature_ptr)
1272 BIT_FLAGS flgs[TR_FLAG_SIZE];
1273 creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
1275 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1276 o_ptr = &creature_ptr->inventory_list[i];
1280 object_flags(creature_ptr, o_ptr, flgs);
1281 if (has_flag(flgs, TR_BLOWS)) {
1282 if ((i == INVEN_MAIN_HAND || i == INVEN_MAIN_RING) && !has_two_handed_weapons(creature_ptr))
1283 creature_ptr->extra_blows[0] += o_ptr->pval;
1284 else if ((i == INVEN_SUB_HAND || i == INVEN_SUB_RING) && !has_two_handed_weapons(creature_ptr))
1285 creature_ptr->extra_blows[1] += o_ptr->pval;
1287 creature_ptr->extra_blows[0] += o_ptr->pval;
1288 creature_ptr->extra_blows[1] += o_ptr->pval;
1294 BIT_FLAGS has_resist_acid(player_type *creature_ptr)
1296 BIT_FLAGS result = 0L;
1298 if (player_race_has_flag(creature_ptr, TR_RES_ACID))
1299 result |= FLAG_CAUSE_RACE;
1301 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1302 result |= FLAG_CAUSE_BATTLE_FORM;
1305 if (creature_ptr->ult_res) {
1306 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1309 if (has_element_resist(creature_ptr, ElementRealm::SEA, 1))
1310 result |= FLAG_CAUSE_CLASS;
1312 result |= has_immune_acid(creature_ptr);
1314 result |= check_equipment_flags(creature_ptr, TR_RES_ACID);
1318 BIT_FLAGS has_vuln_acid(player_type *creature_ptr)
1320 BIT_FLAGS result = 0L;
1322 if (creature_ptr->muta.has(MUTA::VULN_ELEM)) {
1323 result |= FLAG_CAUSE_MUTATION;
1326 if (player_race_has_flag(creature_ptr, TR_VUL_ACID))
1327 result |= FLAG_CAUSE_RACE;
1329 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1330 result |= FLAG_CAUSE_BATTLE_FORM;
1333 result |= check_equipment_flags(creature_ptr, TR_VUL_ACID);
1337 BIT_FLAGS has_resist_elec(player_type *creature_ptr)
1339 BIT_FLAGS result = 0L;
1341 if (player_race_has_flag(creature_ptr, TR_RES_ELEC))
1342 result |= FLAG_CAUSE_RACE;
1344 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1345 result |= FLAG_CAUSE_BATTLE_FORM;
1348 if (creature_ptr->ult_res) {
1349 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1352 if (has_element_resist(creature_ptr, ElementRealm::SKY, 1))
1353 result |= FLAG_CAUSE_CLASS;
1355 result |= check_equipment_flags(creature_ptr, TR_RES_ELEC);
1356 result |= has_immune_elec(creature_ptr);
1360 BIT_FLAGS has_vuln_elec(player_type *creature_ptr)
1362 BIT_FLAGS result = 0L;
1363 if (creature_ptr->muta.has(MUTA::VULN_ELEM)) {
1364 result |= FLAG_CAUSE_MUTATION;
1367 if (player_race_has_flag(creature_ptr, TR_VUL_ELEC))
1368 result |= FLAG_CAUSE_RACE;
1370 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1371 result |= FLAG_CAUSE_BATTLE_FORM;
1374 result |= check_equipment_flags(creature_ptr, TR_VUL_ELEC);
1378 BIT_FLAGS has_resist_fire(player_type *creature_ptr)
1380 BIT_FLAGS result = 0L;
1382 if (player_race_has_flag(creature_ptr, TR_RES_FIRE))
1383 result |= FLAG_CAUSE_RACE;
1385 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1386 result |= FLAG_CAUSE_BATTLE_FORM;
1389 if (creature_ptr->ult_res) {
1390 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1393 if (has_element_resist(creature_ptr, ElementRealm::FIRE, 1))
1394 result |= FLAG_CAUSE_CLASS;
1396 result |= check_equipment_flags(creature_ptr, TR_RES_FIRE);
1397 result |= has_immune_fire(creature_ptr);
1401 BIT_FLAGS has_vuln_fire(player_type *creature_ptr)
1403 BIT_FLAGS result = 0L;
1405 if (creature_ptr->muta.has(MUTA::VULN_ELEM)) {
1406 result |= FLAG_CAUSE_MUTATION;
1409 if (player_race_has_flag(creature_ptr, TR_VUL_FIRE))
1410 result |= FLAG_CAUSE_RACE;
1412 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1413 result |= FLAG_CAUSE_BATTLE_FORM;
1416 result |= check_equipment_flags(creature_ptr, TR_VUL_FIRE);
1420 BIT_FLAGS has_resist_cold(player_type *creature_ptr)
1422 BIT_FLAGS result = 0L;
1424 if (player_race_has_flag(creature_ptr, TR_RES_COLD))
1425 result |= FLAG_CAUSE_RACE;
1427 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1428 result |= FLAG_CAUSE_BATTLE_FORM;
1431 if (creature_ptr->ult_res) {
1432 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1435 if (has_element_resist(creature_ptr, ElementRealm::ICE, 1))
1436 result |= FLAG_CAUSE_CLASS;
1438 result |= check_equipment_flags(creature_ptr, TR_RES_COLD);
1439 result |= has_immune_cold(creature_ptr);
1443 BIT_FLAGS has_vuln_cold(player_type *creature_ptr)
1445 BIT_FLAGS result = 0L;
1447 if (creature_ptr->muta.has(MUTA::VULN_ELEM)) {
1448 result |= FLAG_CAUSE_MUTATION;
1451 if (player_race_has_flag(creature_ptr, TR_VUL_COLD))
1452 result |= FLAG_CAUSE_RACE;
1454 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1455 result |= FLAG_CAUSE_BATTLE_FORM;
1458 result |= check_equipment_flags(creature_ptr, TR_VUL_COLD);
1462 BIT_FLAGS has_resist_pois(player_type *creature_ptr)
1464 BIT_FLAGS result = 0L;
1466 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
1467 result |= FLAG_CAUSE_CLASS;
1469 if (player_race_has_flag(creature_ptr, TR_RES_POIS))
1470 result |= FLAG_CAUSE_RACE;
1472 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1473 result |= FLAG_CAUSE_BATTLE_FORM;
1476 if (creature_ptr->ult_res) {
1477 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1480 if (has_element_resist(creature_ptr, ElementRealm::DEATH, 1))
1481 result |= FLAG_CAUSE_CLASS;
1483 result |= check_equipment_flags(creature_ptr, TR_RES_POIS);
1487 BIT_FLAGS has_resist_conf(player_type *creature_ptr)
1489 BIT_FLAGS result = 0L;
1491 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
1492 result |= FLAG_CAUSE_CLASS;
1494 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1495 result |= FLAG_CAUSE_PERSONALITY;
1498 if (player_race_has_flag(creature_ptr, TR_RES_CONF))
1499 result |= FLAG_CAUSE_RACE;
1501 if (creature_ptr->ult_res || creature_ptr->magicdef) {
1502 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1505 if (creature_ptr->special_defense & KATA_MUSOU) {
1506 result |= FLAG_CAUSE_BATTLE_FORM;
1509 if (has_element_resist(creature_ptr, ElementRealm::CHAOS, 1))
1510 result |= FLAG_CAUSE_CLASS;
1512 result |= check_equipment_flags(creature_ptr, TR_RES_CONF);
1516 BIT_FLAGS has_resist_sound(player_type *creature_ptr)
1518 BIT_FLAGS result = 0L;
1520 if (creature_ptr->pclass == CLASS_BARD) {
1521 result |= FLAG_CAUSE_CLASS;
1523 if (player_race_has_flag(creature_ptr, TR_RES_SOUND))
1524 result |= FLAG_CAUSE_RACE;
1526 if (creature_ptr->special_defense & KATA_MUSOU) {
1527 result |= FLAG_CAUSE_BATTLE_FORM;
1530 if (creature_ptr->ult_res) {
1531 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1534 result |= check_equipment_flags(creature_ptr, TR_RES_SOUND);
1538 BIT_FLAGS has_resist_lite(player_type *creature_ptr)
1540 BIT_FLAGS result = 0L;
1542 if (player_race_has_flag(creature_ptr, TR_RES_LITE))
1543 result |= FLAG_CAUSE_RACE;
1545 if (creature_ptr->special_defense & KATA_MUSOU) {
1546 result |= FLAG_CAUSE_BATTLE_FORM;
1549 if (creature_ptr->ult_res) {
1550 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1553 result |= check_equipment_flags(creature_ptr, TR_RES_LITE);
1557 BIT_FLAGS has_vuln_lite(player_type *creature_ptr)
1559 BIT_FLAGS result = 0L;
1561 if (player_race_has_flag(creature_ptr, TR_VUL_LITE))
1562 result |= FLAG_CAUSE_RACE;
1564 if (creature_ptr->wraith_form) {
1565 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1568 result |= check_equipment_flags(creature_ptr, TR_VUL_LITE);
1572 BIT_FLAGS has_resist_dark(player_type *creature_ptr)
1574 BIT_FLAGS result = 0L;
1576 if (player_race_has_flag(creature_ptr, TR_RES_DARK))
1577 result |= FLAG_CAUSE_RACE;
1579 if (creature_ptr->special_defense & KATA_MUSOU) {
1580 result |= FLAG_CAUSE_BATTLE_FORM;
1583 if (creature_ptr->ult_res) {
1584 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1587 if (has_element_resist(creature_ptr, ElementRealm::DARKNESS, 1))
1588 result |= FLAG_CAUSE_CLASS;
1590 result |= check_equipment_flags(creature_ptr, TR_RES_DARK);
1594 BIT_FLAGS has_resist_chaos(player_type *creature_ptr)
1596 BIT_FLAGS result = 0L;
1598 if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
1599 result |= FLAG_CAUSE_CLASS;
1601 if (player_race_has_flag(creature_ptr, TR_RES_CHAOS))
1602 result |= FLAG_CAUSE_RACE;
1604 if (creature_ptr->special_defense & KATA_MUSOU) {
1605 result |= FLAG_CAUSE_BATTLE_FORM;
1608 if (creature_ptr->ult_res) {
1609 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1612 if (has_element_resist(creature_ptr, ElementRealm::CHAOS, 30))
1613 result |= FLAG_CAUSE_CLASS;
1615 result |= check_equipment_flags(creature_ptr, TR_RES_CHAOS);
1619 BIT_FLAGS has_resist_disen(player_type *creature_ptr)
1621 BIT_FLAGS result = 0L;
1623 if (player_race_has_flag(creature_ptr, TR_RES_DISEN))
1624 result |= FLAG_CAUSE_RACE;
1626 if (creature_ptr->special_defense & KATA_MUSOU) {
1627 result |= FLAG_CAUSE_BATTLE_FORM;
1630 if (creature_ptr->ult_res) {
1631 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1634 if (has_element_resist(creature_ptr, ElementRealm::DEATH, 30))
1635 result |= FLAG_CAUSE_CLASS;
1637 result |= check_equipment_flags(creature_ptr, TR_RES_DISEN);
1641 BIT_FLAGS has_resist_shard(player_type *creature_ptr)
1643 BIT_FLAGS result = 0L;
1645 if (player_race_has_flag(creature_ptr, TR_RES_SHARDS))
1646 result |= FLAG_CAUSE_RACE;
1648 if (creature_ptr->special_defense & KATA_MUSOU) {
1649 result |= FLAG_CAUSE_BATTLE_FORM;
1652 if (creature_ptr->ult_res) {
1653 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1656 if (has_element_resist(creature_ptr, ElementRealm::EARTH, 1))
1657 result |= FLAG_CAUSE_CLASS;
1659 result |= check_equipment_flags(creature_ptr, TR_RES_SHARDS);
1663 BIT_FLAGS has_resist_nexus(player_type *creature_ptr)
1665 BIT_FLAGS result = 0L;
1667 if (player_race_has_flag(creature_ptr, TR_RES_NEXUS))
1668 result |= FLAG_CAUSE_RACE;
1670 if (creature_ptr->special_defense & KATA_MUSOU) {
1671 result |= FLAG_CAUSE_BATTLE_FORM;
1674 if (creature_ptr->ult_res) {
1675 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1678 result |= check_equipment_flags(creature_ptr, TR_RES_NEXUS);
1682 BIT_FLAGS has_resist_blind(player_type *creature_ptr)
1684 BIT_FLAGS result = 0L;
1686 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1687 result |= FLAG_CAUSE_PERSONALITY;
1690 if (player_race_has_flag(creature_ptr, TR_RES_BLIND))
1691 result |= FLAG_CAUSE_RACE;
1693 if (creature_ptr->special_defense & KATA_MUSOU) {
1694 result |= FLAG_CAUSE_BATTLE_FORM;
1697 if (creature_ptr->ult_res || creature_ptr->magicdef) {
1698 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1701 result |= check_equipment_flags(creature_ptr, TR_RES_BLIND);
1705 BIT_FLAGS has_resist_neth(player_type *creature_ptr)
1707 BIT_FLAGS result = 0L;
1709 if (player_race_has_flag(creature_ptr, TR_RES_NETHER))
1710 result |= FLAG_CAUSE_RACE;
1712 if (creature_ptr->special_defense & KATA_MUSOU) {
1713 result |= FLAG_CAUSE_BATTLE_FORM;
1716 if (creature_ptr->ult_res || creature_ptr->tim_res_nether) {
1717 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1720 if (has_element_resist(creature_ptr, ElementRealm::DARKNESS, 30))
1721 result |= FLAG_CAUSE_CLASS;
1723 result |= check_equipment_flags(creature_ptr, TR_RES_NETHER);
1727 BIT_FLAGS has_resist_time(player_type *creature_ptr)
1729 BIT_FLAGS result = 0L;
1731 if (player_race_has_flag(creature_ptr, TR_RES_TIME))
1732 result |= FLAG_CAUSE_RACE;
1734 if (creature_ptr->tim_res_time) {
1735 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1738 result |= check_equipment_flags(creature_ptr, TR_RES_TIME);
1742 BIT_FLAGS has_resist_water(player_type *creature_ptr)
1744 BIT_FLAGS result = 0L;
1746 if (player_race_has_flag(creature_ptr, TR_RES_WATER))
1747 result |= FLAG_CAUSE_RACE;
1749 result |= check_equipment_flags(creature_ptr, TR_RES_WATER);
1754 * @brief 呪力耐性を所持しているかどうか
1755 * @param プレイヤー情報への参照ポインタ
1756 * @return 呪力耐性を所持していればTRUE、なければFALSE
1758 BIT_FLAGS has_resist_curse(player_type *creature_ptr)
1760 BIT_FLAGS result = 0L;
1762 if (player_race_has_flag(creature_ptr, TR_RES_CURSE))
1763 result |= FLAG_CAUSE_RACE;
1765 result |= check_equipment_flags(creature_ptr, TR_RES_CURSE);
1769 BIT_FLAGS has_resist_fear(player_type *creature_ptr)
1771 BIT_FLAGS result = 0L;
1773 if (creature_ptr->muta.has(MUTA::FEARLESS))
1774 result |= FLAG_CAUSE_MUTATION;
1776 switch (creature_ptr->pclass) {
1779 if (creature_ptr->lev > 29)
1780 result |= FLAG_CAUSE_CLASS;
1783 case CLASS_CHAOS_WARRIOR:
1784 if (creature_ptr->lev > 39)
1785 result |= FLAG_CAUSE_CLASS;
1787 case CLASS_MINDCRAFTER:
1788 if (creature_ptr->lev > 9)
1789 result |= FLAG_CAUSE_CLASS;
1792 result |= FLAG_CAUSE_CLASS;
1799 if (player_race_has_flag(creature_ptr, TR_RES_FEAR))
1800 result |= FLAG_CAUSE_RACE;
1802 if ((creature_ptr->special_defense & KATA_MUSOU)) {
1803 result |= FLAG_CAUSE_BATTLE_FORM;
1806 if (is_hero(creature_ptr) || is_shero(creature_ptr) || creature_ptr->ult_res) {
1807 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1810 result |= check_equipment_flags(creature_ptr, TR_RES_FEAR);
1814 BIT_FLAGS has_immune_acid(player_type *creature_ptr)
1816 BIT_FLAGS result = 0L;
1818 if (player_race_has_flag(creature_ptr, TR_IM_ACID))
1819 result |= FLAG_CAUSE_RACE;
1821 if (creature_ptr->ele_immune) {
1822 if (creature_ptr->special_defense & DEFENSE_ACID)
1823 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1826 if (has_element_resist(creature_ptr, ElementRealm::SEA, 30))
1827 result |= FLAG_CAUSE_CLASS;
1829 result |= check_equipment_flags(creature_ptr, TR_IM_ACID);
1833 BIT_FLAGS has_immune_elec(player_type *creature_ptr)
1835 BIT_FLAGS result = 0L;
1837 if (player_race_has_flag(creature_ptr, TR_IM_ELEC))
1838 result |= FLAG_CAUSE_RACE;
1840 if (creature_ptr->ele_immune) {
1841 if (creature_ptr->special_defense & DEFENSE_ELEC)
1842 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1845 if (has_element_resist(creature_ptr, ElementRealm::SKY, 30))
1846 result |= FLAG_CAUSE_CLASS;
1848 result |= check_equipment_flags(creature_ptr, TR_IM_ELEC);
1852 BIT_FLAGS has_immune_fire(player_type *creature_ptr)
1854 BIT_FLAGS result = 0L;
1856 if (player_race_has_flag(creature_ptr, TR_IM_FIRE))
1857 result |= FLAG_CAUSE_RACE;
1859 if (creature_ptr->ele_immune) {
1860 if (creature_ptr->special_defense & DEFENSE_FIRE)
1861 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1864 if (has_element_resist(creature_ptr, ElementRealm::FIRE, 30))
1865 result |= FLAG_CAUSE_CLASS;
1867 result |= check_equipment_flags(creature_ptr, TR_IM_FIRE);
1871 BIT_FLAGS has_immune_cold(player_type *creature_ptr)
1873 BIT_FLAGS result = 0L;
1875 if (player_race_has_flag(creature_ptr, TR_IM_COLD))
1876 result |= FLAG_CAUSE_RACE;
1878 if (creature_ptr->ele_immune) {
1879 if (creature_ptr->special_defense & DEFENSE_COLD)
1880 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1883 if (has_element_resist(creature_ptr, ElementRealm::ICE, 30))
1884 result |= FLAG_CAUSE_CLASS;
1886 result |= check_equipment_flags(creature_ptr, TR_IM_COLD);
1890 BIT_FLAGS has_immune_dark(player_type *creature_ptr)
1892 BIT_FLAGS result = 0L;
1894 if (player_race_has_flag(creature_ptr, TR_IM_DARK))
1895 result |= FLAG_CAUSE_RACE;
1897 if (creature_ptr->wraith_form) {
1898 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1901 result |= check_equipment_flags(creature_ptr, TR_IM_DARK);
1905 melee_type player_melee_type(player_type *creature_ptr)
1907 if (has_two_handed_weapons(creature_ptr))
1908 return MELEE_TYPE_WEAPON_TWOHAND;
1910 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)) {
1911 if (has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
1912 return MELEE_TYPE_WEAPON_DOUBLE;
1914 return MELEE_TYPE_WEAPON_MAIN;
1917 if (has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
1918 return MELEE_TYPE_WEAPON_SUB;
1920 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
1921 return MELEE_TYPE_BAREHAND_TWO;
1923 if (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_MAIN)
1924 return MELEE_TYPE_BAREHAND_MAIN;
1926 if (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_SUB)
1927 return MELEE_TYPE_BAREHAND_SUB;
1929 return MELEE_TYPE_SHIELD_DOUBLE;
1933 * @brief 利き手で攻撃可能かどうかを判定する
1934 * 利き手で攻撃可能とは、利き手に武器を持っているか、
1935 * 利き手が素手かつ左手も素手もしくは盾を装備している事を意味する。
1936 * @details Includes martial arts and hand combats as weapons.
1938 bool can_attack_with_main_hand(player_type *creature_ptr)
1940 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND))
1943 if ((empty_hands(creature_ptr, TRUE) & EMPTY_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr))
1950 * @brief 非利き手で攻撃可能かどうかを判定する
1951 * 非利き手で攻撃可能とは、非利き手に武器を持っている事に等しい
1952 * @details Exclude martial arts and hand combats from weapons.
1954 bool can_attack_with_sub_hand(player_type *creature_ptr)
1956 return has_melee_weapon(creature_ptr, INVEN_SUB_HAND);
1960 * @brief 両手持ち状態かどうかを判定する
1962 bool has_two_handed_weapons(player_type *creature_ptr)
1964 if (can_two_hands_wielding(creature_ptr)) {
1965 if (can_attack_with_main_hand(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_SUB)
1966 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_MAIN_HAND])) {
1968 } else if (can_attack_with_sub_hand(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_MAIN)
1969 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_SUB_HAND])) {
1976 BIT_FLAGS has_lite(player_type *creature_ptr)
1978 BIT_FLAGS result = 0L;
1979 if (creature_ptr->pclass == CLASS_NINJA)
1982 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1983 result |= FLAG_CAUSE_PERSONALITY;
1986 if (player_race_has_flag(creature_ptr, TR_LITE_1))
1987 result |= FLAG_CAUSE_RACE;
1989 if (creature_ptr->ult_res) {
1990 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1993 if (creature_ptr->special_defense & KATA_MUSOU) {
1994 result |= FLAG_CAUSE_BATTLE_FORM;
1997 result |= has_sh_fire(creature_ptr);
2003 * @brief 両手持ちボーナスがもらえないかどうかを判定する。 / Does *not * get two hand wielding bonus.
2005 * Only can get hit bonuses when wieids an enough light weapon which is lighter than 5 times of weight limit.
2006 * If its weight is 10 times heavier or more than weight limit, gets hit penalty in calc_to_hit().
2008 bool has_disable_two_handed_bonus(player_type *creature_ptr, int i)
2010 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && has_two_handed_weapons(creature_ptr)) {
2011 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
2012 int limit = calc_weapon_weight_limit(creature_ptr) * 2;
2014 /* Enable when two hand wields an enough light weapon */
2015 if (limit >= o_ptr->weight / 5)
2019 /* Disable when empty hands, one hand wieldings and heavy weapons */
2024 * @brief ふさわしくない武器を持っているかどうかを返す。
2025 * @todo 相応しい時にFALSEで相応しくない時にTRUEという負論理は良くない、後で修正する
2027 bool has_icky_wield_weapon(player_type *creature_ptr, int i)
2029 BIT_FLAGS flgs[TR_FLAG_SIZE];
2030 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
2031 object_flags(creature_ptr, o_ptr, flgs);
2033 bool has_no_weapon = (o_ptr->tval == TV_NONE) || (o_ptr->tval == TV_SHIELD);
2034 if (creature_ptr->pclass == CLASS_PRIEST) {
2035 bool is_suitable_weapon = has_flag(flgs, TR_BLESSED);
2036 is_suitable_weapon |= (o_ptr->tval != TV_SWORD) && (o_ptr->tval != TV_POLEARM);
2037 return !has_no_weapon && !is_suitable_weapon;
2040 if (creature_ptr->pclass == CLASS_SORCERER) {
2041 bool is_suitable_weapon = o_ptr->tval == TV_HAFTED;
2042 is_suitable_weapon &= (o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER);
2043 return !has_no_weapon && !is_suitable_weapon;
2046 if (has_not_monk_weapon(creature_ptr, i) || has_not_ninja_weapon(creature_ptr, i))
2052 bool has_riding_wield_weapon(player_type *creature_ptr, int i)
2055 BIT_FLAGS flgs[TR_FLAG_SIZE];
2056 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
2057 object_flags(creature_ptr, o_ptr, flgs);
2058 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
2059 && !has_flag(flgs, TR_RIDING)) {
2065 bool has_not_ninja_weapon(player_type *creature_ptr, int i)
2067 if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2070 int tval = creature_ptr->inventory_list[INVEN_MAIN_HAND + i].tval - TV_WEAPON_BEGIN;
2071 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_MAIN_HAND + i].sval;
2072 return creature_ptr->pclass == CLASS_NINJA
2073 && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_SUB_HAND - i].tval != TV_SHIELD));
2076 bool has_not_monk_weapon(player_type *creature_ptr, int i)
2078 if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2081 int tval = creature_ptr->inventory_list[INVEN_MAIN_HAND + i].tval - TV_WEAPON_BEGIN;
2082 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_MAIN_HAND + i].sval;
2083 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !(s_info[creature_ptr->pclass].w_max[tval][sval]);
2086 bool has_good_luck(player_type *creature_ptr)
2088 return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta.has(MUTA::GOOD_LUCK));
2091 BIT_FLAGS player_aggravate_state(player_type *creature_ptr)
2093 if (creature_ptr->cursed & TRC_AGGRAVATE) {
2094 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY)) {
2095 return AGGRAVATE_S_FAIRY;
2097 return AGGRAVATE_NORMAL;
2100 return AGGRAVATE_NONE;
2103 bool has_aggravate(player_type *creature_ptr)
2105 return player_aggravate_state(creature_ptr) == AGGRAVATE_NORMAL;