1 #include "player/player-status-flags.h"
2 #include "art-definition/art-sword-types.h"
4 #include "inventory/inventory-slot-types.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-checker.h"
13 #include "object-hook/hook-weapon.h"
14 #include "object/object-flags.h"
15 #include "player/player-class.h"
16 #include "player/player-race-types.h"
17 #include "player/player-race.h"
18 #include "player/player-skill.h"
19 #include "player/player-status.h"
20 #include "player/special-defense-types.h"
21 #include "realm/realm-hex-numbers.h"
22 #include "realm/realm-song-numbers.h"
23 #include "realm/realm-types.h"
24 #include "spell-realm/spells-hex.h"
25 #include "sv-definition/sv-weapon-types.h"
26 #include "system/floor-type-definition.h"
27 #include "system/monster-type-definition.h"
28 #include "system/object-type-definition.h"
29 #include "util/bit-flags-calculator.h"
30 #include "util/quarks.h"
31 #include "util/string-processor.h"
33 static BIT_FLAGS check_equipment_flags(player_type *creature_ptr, tr_type tr_flag);
35 static BIT_FLAGS check_equipment_flags(player_type *creature_ptr, tr_type tr_flag)
38 BIT_FLAGS flgs[TR_FLAG_SIZE];
39 BIT_FLAGS result = 0L;
40 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
41 o_ptr = &creature_ptr->inventory_list[i];
45 object_flags(creature_ptr, o_ptr, flgs);
47 if (has_flag(flgs, tr_flag))
48 result |= 0x01 << (i - INVEN_RARM);
53 bool has_kill_wall(player_type *creature_ptr)
55 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || music_singing(creature_ptr, MUSIC_WALL)) {
59 if (creature_ptr->riding) {
60 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
61 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
62 if (riding_r_ptr->flags2 & RF2_KILL_WALL)
69 bool has_pass_wall(player_type *creature_ptr)
73 if (creature_ptr->wraith_form || creature_ptr->tim_pass_wall || (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE)) {
77 if (creature_ptr->riding) {
78 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
79 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
80 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL))
87 BIT_FLAGS has_xtra_might(player_type *creature_ptr)
89 BIT_FLAGS result = 0L;
90 result |= check_equipment_flags(creature_ptr, TR_XTRA_MIGHT);
94 BIT_FLAGS has_esp_evil(player_type *creature_ptr)
96 BIT_FLAGS result = 0L;
97 if (creature_ptr->realm1 == REALM_HEX) {
98 if (hex_spelling(creature_ptr, HEX_DETECT_EVIL))
99 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
101 result |= check_equipment_flags(creature_ptr, TR_ESP_EVIL);
105 BIT_FLAGS has_esp_animal(player_type *creature_ptr)
107 BIT_FLAGS result = 0L;
108 result |= check_equipment_flags(creature_ptr, TR_ESP_ANIMAL);
112 BIT_FLAGS has_esp_undead(player_type *creature_ptr)
114 BIT_FLAGS result = 0L;
115 result |= check_equipment_flags(creature_ptr, TR_ESP_UNDEAD);
119 BIT_FLAGS has_esp_demon(player_type *creature_ptr)
121 BIT_FLAGS result = 0L;
122 result |= check_equipment_flags(creature_ptr, TR_ESP_DEMON);
126 BIT_FLAGS has_esp_orc(player_type *creature_ptr)
128 BIT_FLAGS result = 0L;
129 result |= check_equipment_flags(creature_ptr, TR_ESP_ORC);
133 BIT_FLAGS has_esp_troll(player_type *creature_ptr)
135 BIT_FLAGS result = 0L;
136 result |= check_equipment_flags(creature_ptr, TR_ESP_TROLL);
140 BIT_FLAGS has_esp_giant(player_type *creature_ptr)
142 BIT_FLAGS result = 0L;
143 result |= check_equipment_flags(creature_ptr, TR_ESP_GIANT);
147 BIT_FLAGS has_esp_dragon(player_type *creature_ptr)
149 BIT_FLAGS result = 0L;
150 result |= check_equipment_flags(creature_ptr, TR_ESP_DRAGON);
154 BIT_FLAGS has_esp_human(player_type *creature_ptr)
156 BIT_FLAGS result = 0L;
157 result |= check_equipment_flags(creature_ptr, TR_ESP_HUMAN);
161 BIT_FLAGS has_esp_good(player_type *creature_ptr)
163 BIT_FLAGS result = 0L;
164 result |= check_equipment_flags(creature_ptr, TR_ESP_GOOD);
168 BIT_FLAGS has_esp_nonliving(player_type *creature_ptr)
170 BIT_FLAGS result = 0L;
171 result |= check_equipment_flags(creature_ptr, TR_ESP_GOOD);
175 BIT_FLAGS has_esp_unique(player_type *creature_ptr)
177 BIT_FLAGS result = 0L;
178 result |= check_equipment_flags(creature_ptr, TR_ESP_UNIQUE);
182 BIT_FLAGS has_esp_telepathy(player_type *creature_ptr)
184 BIT_FLAGS result = 0L;
186 if (is_time_limit_esp(creature_ptr) || creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
187 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
190 if (creature_ptr->muta3 & MUT3_ESP) {
191 result |= FLAG_CAUSE_MUTATION;
194 if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER) && creature_ptr->lev > 29)
195 result |= FLAG_CAUSE_RACE;
197 if (is_specific_player_race(creature_ptr, RACE_SPECTRE) && creature_ptr->lev > 34)
198 result |= FLAG_CAUSE_RACE;
200 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 39)
201 result |= FLAG_CAUSE_CLASS;
203 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
204 result |= FLAG_CAUSE_RACE;
207 result |= check_equipment_flags(creature_ptr, TR_TELEPATHY);
211 BIT_FLAGS has_bless_blade(player_type *creature_ptr)
213 BIT_FLAGS result = 0L;
214 result |= check_equipment_flags(creature_ptr, TR_BLESSED);
218 BIT_FLAGS has_easy2_weapon(player_type *creature_ptr)
220 BIT_FLAGS result = 0L;
221 result |= check_equipment_flags(creature_ptr, TR_EASY2_WEAPON);
225 BIT_FLAGS has_down_saving(player_type *creature_ptr)
227 BIT_FLAGS result = 0L;
228 result |= check_equipment_flags(creature_ptr, TR_DOWN_SAVING);
232 BIT_FLAGS has_no_ac(player_type *creature_ptr)
234 BIT_FLAGS result = 0L;
235 result |= check_equipment_flags(creature_ptr, TR_NO_AC);
239 void has_no_flowed(player_type *creature_ptr)
242 bool has_sw = FALSE, has_kabe = FALSE;
243 OBJECT_IDX this_o_idx, next_o_idx = 0;
245 creature_ptr->no_flowed = FALSE;
247 if (creature_ptr->pass_wall && !creature_ptr->kill_wall)
248 creature_ptr->no_flowed = TRUE;
250 for (int i = 0; i < INVEN_PACK; i++) {
251 if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
253 if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
257 for (this_o_idx = creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx) {
258 o_ptr = &creature_ptr->current_floor_ptr->o_list[this_o_idx];
259 next_o_idx = o_ptr->next_o_idx;
261 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2))
263 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2))
267 if (has_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER))) {
268 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
269 if (creature_ptr->lev >= s_ptr->slevel)
270 creature_ptr->no_flowed = TRUE;
273 if (has_kabe && ((creature_ptr->realm1 == REALM_CRAFT) || (creature_ptr->realm2 == REALM_CRAFT) || (creature_ptr->pclass == CLASS_SORCERER))) {
274 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_WALL];
275 if (creature_ptr->lev >= s_ptr->slevel)
276 creature_ptr->no_flowed = TRUE;
280 BIT_FLAGS has_mighty_throw(player_type *creature_ptr)
282 BIT_FLAGS result = 0L;
283 result |= check_equipment_flags(creature_ptr, TR_MIGHTY_THROW);
287 BIT_FLAGS has_dec_mana(player_type *creature_ptr)
289 BIT_FLAGS result = 0L;
290 result |= check_equipment_flags(creature_ptr, TR_DEC_MANA);
294 BIT_FLAGS has_reflect(player_type *creature_ptr)
296 BIT_FLAGS result = 0L;
298 if (creature_ptr->pclass == CLASS_BERSERKER && creature_ptr->lev > 39)
299 result |= FLAG_CAUSE_CLASS;
301 if (creature_ptr->pclass == CLASS_MIRROR_MASTER && creature_ptr->lev > 39)
302 result |= FLAG_CAUSE_CLASS;
304 if (creature_ptr->special_defense & KAMAE_GENBU || creature_ptr->special_defense & KATA_MUSOU) {
305 result |= FLAG_CAUSE_BATTLE_FORM;
308 if (creature_ptr->ult_res || creature_ptr->wraith_form || creature_ptr->magicdef || creature_ptr->tim_reflect) {
309 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
312 result |= check_equipment_flags(creature_ptr, TR_REFLECT);
316 BIT_FLAGS has_see_nocto(player_type *creature_ptr) { return creature_ptr->pclass == CLASS_NINJA ? FLAG_CAUSE_CLASS : 0L; }
318 void has_warning(player_type *creature_ptr)
321 BIT_FLAGS flgs[TR_FLAG_SIZE];
323 creature_ptr->warning = FALSE;
325 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
326 o_ptr = &creature_ptr->inventory_list[i];
330 object_flags(creature_ptr, o_ptr, flgs);
332 if (has_flag(flgs, TR_WARNING)) {
333 if (!o_ptr->inscription || !(angband_strchr(quark_str(o_ptr->inscription), '$')))
334 creature_ptr->warning = TRUE;
339 BIT_FLAGS has_anti_magic(player_type *creature_ptr)
341 BIT_FLAGS result = 0L;
342 result |= check_equipment_flags(creature_ptr, TR_NO_MAGIC);
346 BIT_FLAGS has_anti_tele(player_type *creature_ptr)
348 BIT_FLAGS result = 0L;
349 result |= check_equipment_flags(creature_ptr, TR_NO_TELE);
353 BIT_FLAGS has_sh_fire(player_type *creature_ptr)
355 BIT_FLAGS result = 0L;
357 if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
358 result |= FLAG_CAUSE_MUTATION;
361 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
362 result |= FLAG_CAUSE_RACE;
365 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
366 result |= FLAG_CAUSE_BATTLE_FORM;
369 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_sh_fire) {
370 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
373 result |= check_equipment_flags(creature_ptr, TR_SH_FIRE);
377 BIT_FLAGS has_sh_elec(player_type *creature_ptr)
379 BIT_FLAGS result = 0L;
381 if (creature_ptr->muta3 & MUT3_ELEC_TOUC)
382 result |= FLAG_CAUSE_MUTATION;
384 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK) || creature_ptr->ult_res) {
385 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
388 if (creature_ptr->special_defense & KAMAE_SEIRYU || (creature_ptr->special_defense & KATA_MUSOU)) {
389 result |= FLAG_CAUSE_BATTLE_FORM;
392 result |= check_equipment_flags(creature_ptr, TR_SH_ELEC);
396 BIT_FLAGS has_sh_cold(player_type *creature_ptr)
398 BIT_FLAGS result = 0L;
400 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
401 result |= FLAG_CAUSE_BATTLE_FORM;
404 if (creature_ptr->ult_res || hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
405 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
408 result |= check_equipment_flags(creature_ptr, TR_SH_COLD);
412 BIT_FLAGS has_easy_spell(player_type *creature_ptr)
414 BIT_FLAGS result = 0L;
415 result |= check_equipment_flags(creature_ptr, TR_EASY_SPELL);
419 BIT_FLAGS has_heavy_spell(player_type *creature_ptr)
421 BIT_FLAGS result = 0L;
422 result |= check_equipment_flags(creature_ptr, TR_HEAVY_SPELL);
426 BIT_FLAGS has_hold_exp(player_type *creature_ptr)
428 BIT_FLAGS result = 0L;
430 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
431 result |= FLAG_CAUSE_PERSONALITY;
434 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
435 result |= FLAG_CAUSE_RACE;
438 if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON)
439 || is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
440 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG)
441 || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
442 result |= FLAG_CAUSE_RACE;
445 if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
446 if (creature_ptr->lev > 34)
447 result |= FLAG_CAUSE_RACE;
450 if (creature_ptr->special_defense & KATA_MUSOU) {
451 result |= FLAG_CAUSE_BATTLE_FORM;
454 if (creature_ptr->ult_res) {
455 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
458 result |= check_equipment_flags(creature_ptr, TR_HOLD_EXP);
462 BIT_FLAGS has_see_inv(player_type *creature_ptr)
464 BIT_FLAGS result = 0L;
466 if (creature_ptr->pclass == CLASS_NINJA || creature_ptr->lev > 29)
467 result |= FLAG_CAUSE_CLASS;
469 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
470 result |= FLAG_CAUSE_RACE;
473 if (!creature_ptr->mimic_form
474 && (creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
475 || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ARCHON)) {
476 result |= FLAG_CAUSE_RACE;
479 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DARK_ELF) {
480 if (creature_ptr->lev > 19)
481 result |= FLAG_CAUSE_RACE;
484 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MIND_FLAYER) {
485 if (creature_ptr->lev > 14)
486 result |= FLAG_CAUSE_RACE;
489 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
490 if (creature_ptr->lev > 9)
491 result |= FLAG_CAUSE_RACE;
494 if (creature_ptr->special_defense & KATA_MUSOU) {
495 result |= FLAG_CAUSE_BATTLE_FORM;
498 if (creature_ptr->ult_res || creature_ptr->tim_invis) {
499 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
502 result |= check_equipment_flags(creature_ptr, TR_SEE_INVIS);
507 BIT_FLAGS has_free_act(player_type *creature_ptr)
509 BIT_FLAGS result = 0L;
511 if (creature_ptr->muta3 & MUT3_MOTION)
512 result |= FLAG_CAUSE_MUTATION;
514 if (is_specific_player_race(creature_ptr, RACE_GNOME) || is_specific_player_race(creature_ptr, RACE_GOLEM)
515 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
516 result |= FLAG_CAUSE_RACE;
519 if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
520 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
521 if (creature_ptr->lev > 24)
522 result |= FLAG_CAUSE_CLASS;
525 if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) {
526 if (!(heavy_armor(creature_ptr))) {
527 if (creature_ptr->lev > 24)
528 result |= FLAG_CAUSE_CLASS;
532 if (creature_ptr->pclass == CLASS_BERSERKER) {
533 result |= FLAG_CAUSE_CLASS;
536 if (creature_ptr->ult_res || creature_ptr->magicdef) {
537 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
540 if (creature_ptr->special_defense & KATA_MUSOU) {
541 result |= FLAG_CAUSE_BATTLE_FORM;
544 result |= check_equipment_flags(creature_ptr, TR_FREE_ACT);
548 BIT_FLAGS has_sustain_str(player_type *creature_ptr)
550 BIT_FLAGS result = 0L;
552 if (creature_ptr->pclass == CLASS_BERSERKER) {
553 result |= FLAG_CAUSE_CLASS;
555 if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) || is_specific_player_race(creature_ptr, RACE_HALF_OGRE)
556 || is_specific_player_race(creature_ptr, RACE_HALF_GIANT)) {
557 result |= FLAG_CAUSE_RACE;
560 if (creature_ptr->ult_res) {
561 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
564 if (creature_ptr->special_defense & KATA_MUSOU) {
565 result |= FLAG_CAUSE_BATTLE_FORM;
568 result |= check_equipment_flags(creature_ptr, TR_SUST_STR);
572 BIT_FLAGS has_sustain_int(player_type *creature_ptr)
574 BIT_FLAGS result = 0L;
576 if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER)) {
577 result |= FLAG_CAUSE_RACE;
580 if (creature_ptr->ult_res) {
581 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
584 if (creature_ptr->special_defense & KATA_MUSOU) {
585 result |= FLAG_CAUSE_BATTLE_FORM;
588 result |= check_equipment_flags(creature_ptr, TR_SUST_INT);
592 BIT_FLAGS has_sustain_wis(player_type *creature_ptr)
594 BIT_FLAGS result = 0L;
597 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
598 result |= FLAG_CAUSE_CLASS;
600 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
601 result |= FLAG_CAUSE_RACE;
604 if (creature_ptr->ult_res) {
605 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
608 if (creature_ptr->special_defense & KATA_MUSOU) {
609 result |= FLAG_CAUSE_BATTLE_FORM;
612 result |= check_equipment_flags(creature_ptr, TR_SUST_WIS);
616 BIT_FLAGS has_sustain_dex(player_type *creature_ptr)
618 BIT_FLAGS result = 0L;
619 if (creature_ptr->pclass == CLASS_BERSERKER) {
620 result |= FLAG_CAUSE_CLASS;
623 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 24)
624 result |= FLAG_CAUSE_CLASS;
626 if (creature_ptr->ult_res) {
627 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
630 if (creature_ptr->special_defense & KATA_MUSOU) {
631 result |= FLAG_CAUSE_BATTLE_FORM;
634 result |= check_equipment_flags(creature_ptr, TR_SUST_DEX);
638 BIT_FLAGS has_sustain_con(player_type *creature_ptr)
640 BIT_FLAGS result = 0L;
641 if (creature_ptr->pclass == CLASS_BERSERKER) {
642 result |= FLAG_CAUSE_CLASS;
645 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
646 result |= FLAG_CAUSE_RACE;
649 if (creature_ptr->ult_res) {
650 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
653 if (creature_ptr->special_defense & KATA_MUSOU) {
654 result |= FLAG_CAUSE_BATTLE_FORM;
657 result |= check_equipment_flags(creature_ptr, TR_SUST_CON);
661 BIT_FLAGS has_sustain_chr(player_type *creature_ptr)
663 BIT_FLAGS result = 0L;
665 if (creature_ptr->ult_res) {
666 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
669 if (creature_ptr->special_defense & KATA_MUSOU) {
670 result |= FLAG_CAUSE_BATTLE_FORM;
673 result |= check_equipment_flags(creature_ptr, TR_SUST_CHR);
677 BIT_FLAGS has_levitation(player_type *creature_ptr)
679 BIT_FLAGS result = 0L;
681 if (creature_ptr->muta3 & MUT3_WINGS)
682 result = FLAG_CAUSE_MUTATION;
684 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
685 result = FLAG_CAUSE_RACE;
688 if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) || is_specific_player_race(creature_ptr, RACE_SPECTRE)
689 || is_specific_player_race(creature_ptr, RACE_SPRITE) || is_specific_player_race(creature_ptr, RACE_ARCHON)
690 || is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
691 result = FLAG_CAUSE_RACE;
694 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU || (creature_ptr->special_defense & KATA_MUSOU)) {
695 result = FLAG_CAUSE_BATTLE_FORM;
698 if (creature_ptr->ult_res) {
699 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
702 if (creature_ptr->riding) {
703 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
704 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
705 result = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? result : 0;
708 if (creature_ptr->tim_levitation) {
709 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
712 result |= check_equipment_flags(creature_ptr, TR_LEVITATION);
716 void has_can_swim(player_type *creature_ptr)
718 creature_ptr->can_swim = FALSE;
719 if (creature_ptr->riding) {
720 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
721 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
722 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
723 creature_ptr->can_swim = TRUE;
727 void has_slow_digest(player_type *creature_ptr)
730 BIT_FLAGS flgs[TR_FLAG_SIZE];
731 creature_ptr->slow_digest = FALSE;
733 if (creature_ptr->pclass == CLASS_NINJA) {
734 creature_ptr->slow_digest = TRUE;
737 if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
738 if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
739 creature_ptr->slow_digest = TRUE;
740 /* Let's not make Regeneration
741 * a disadvantage for the poor warriors who can
742 * never learn a spell that satisfies hunger (actually
743 * neither can rogues, but half-trolls are not
744 * supposed to play rogues) */
748 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
749 creature_ptr->slow_digest = TRUE;
752 if (!creature_ptr->mimic_form
753 && (creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE
754 || creature_ptr->prace == RACE_ANDROID)) {
755 creature_ptr->slow_digest = TRUE;
758 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
759 o_ptr = &creature_ptr->inventory_list[i];
762 object_flags(creature_ptr, o_ptr, flgs);
763 if (has_flag(flgs, TR_SLOW_DIGEST))
764 creature_ptr->slow_digest = TRUE;
768 BIT_FLAGS has_regenerate(player_type *creature_ptr)
770 BIT_FLAGS result = 0L;
772 if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) && creature_ptr->lev > 14) {
773 result |= FLAG_CAUSE_RACE;
776 if (is_specific_player_race(creature_ptr, RACE_AMBERITE)) {
777 result |= FLAG_CAUSE_RACE;
780 if (creature_ptr->pclass == CLASS_WARRIOR && creature_ptr->lev > 44) {
781 result |= FLAG_CAUSE_RACE;
784 if (creature_ptr->pclass == CLASS_BERSERKER) {
785 result |= FLAG_CAUSE_RACE;
788 if (creature_ptr->muta3 & MUT3_REGEN)
789 result |= FLAG_CAUSE_MUTATION;
791 if (creature_ptr->special_defense & KATA_MUSOU) {
792 result |= FLAG_CAUSE_MUTATION;
795 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_regen) {
796 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
799 result |= check_equipment_flags(creature_ptr, TR_REGEN);
801 if (creature_ptr->muta3 & MUT3_FLESH_ROT)
807 void has_curses(player_type *creature_ptr)
810 BIT_FLAGS flgs[TR_FLAG_SIZE];
811 creature_ptr->cursed = 0L;
813 if (creature_ptr->pseikaku == PERSONALITY_SEXY)
814 creature_ptr->cursed |= (TRC_AGGRAVATE);
816 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
817 o_ptr = &creature_ptr->inventory_list[i];
820 object_flags(creature_ptr, o_ptr, flgs);
821 if (has_flag(flgs, TR_AGGRAVATE))
822 creature_ptr->cursed |= TRC_AGGRAVATE;
823 if (has_flag(flgs, TR_DRAIN_EXP))
824 creature_ptr->cursed |= TRC_DRAIN_EXP;
825 if (has_flag(flgs, TR_TY_CURSE))
826 creature_ptr->cursed |= TRC_TY_CURSE;
827 if (has_flag(flgs, TR_ADD_L_CURSE))
828 creature_ptr->cursed |= TRC_ADD_L_CURSE;
829 if (has_flag(flgs, TR_ADD_H_CURSE))
830 creature_ptr->cursed |= TRC_ADD_H_CURSE;
831 if (has_flag(flgs, TR_DRAIN_HP))
832 creature_ptr->cursed |= TRC_DRAIN_HP;
833 if (has_flag(flgs, TR_DRAIN_MANA))
834 creature_ptr->cursed |= TRC_DRAIN_MANA;
835 if (has_flag(flgs, TR_CALL_ANIMAL))
836 creature_ptr->cursed |= TRC_CALL_ANIMAL;
837 if (has_flag(flgs, TR_CALL_DEMON))
838 creature_ptr->cursed |= TRC_CALL_DEMON;
839 if (has_flag(flgs, TR_CALL_DRAGON))
840 creature_ptr->cursed |= TRC_CALL_DRAGON;
841 if (has_flag(flgs, TR_CALL_UNDEAD))
842 creature_ptr->cursed |= TRC_CALL_UNDEAD;
843 if (has_flag(flgs, TR_COWARDICE))
844 creature_ptr->cursed |= TRC_COWARDICE;
845 if (has_flag(flgs, TR_LOW_MELEE))
846 creature_ptr->cursed |= TRC_LOW_MELEE;
847 if (has_flag(flgs, TR_LOW_AC))
848 creature_ptr->cursed |= TRC_LOW_AC;
849 if (has_flag(flgs, TR_LOW_MAGIC))
850 creature_ptr->cursed |= TRC_LOW_MAGIC;
851 if (has_flag(flgs, TR_FAST_DIGEST))
852 creature_ptr->cursed |= TRC_FAST_DIGEST;
853 if (has_flag(flgs, TR_SLOW_REGEN))
854 creature_ptr->cursed |= TRC_SLOW_REGEN;
856 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
857 if (o_ptr->name1 == ART_CHAINSWORD)
858 creature_ptr->cursed |= TRC_CHAINSWORD;
860 if (has_flag(flgs, TR_TELEPORT)) {
861 if (object_is_cursed(o_ptr))
862 creature_ptr->cursed |= TRC_TELEPORT;
864 concptr insc = quark_str(o_ptr->inscription);
866 /* {.} will stop random teleportation. */
867 if (o_ptr->inscription && angband_strchr(insc, '.')) {
869 creature_ptr->cursed |= TRC_TELEPORT_SELF;
875 if (creature_ptr->cursed & TRC_TELEPORT)
876 creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
878 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
879 creature_ptr->cursed &= ~(TRC_AGGRAVATE);
883 BIT_FLAGS has_impact(player_type *creature_ptr)
885 BIT_FLAGS result = 0L;
886 result |= check_equipment_flags(creature_ptr, TR_IMPACT);
890 void has_extra_blow(player_type *creature_ptr)
893 BIT_FLAGS flgs[TR_FLAG_SIZE];
894 creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
896 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
897 o_ptr = &creature_ptr->inventory_list[i];
901 object_flags(creature_ptr, o_ptr, flgs);
903 if (has_flag(flgs, TR_INFRA))
904 creature_ptr->see_infra += o_ptr->pval;
905 if (has_flag(flgs, TR_BLOWS)) {
906 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr))
907 creature_ptr->extra_blows[0] += o_ptr->pval;
908 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !has_two_handed_weapons(creature_ptr))
909 creature_ptr->extra_blows[1] += o_ptr->pval;
911 creature_ptr->extra_blows[0] += o_ptr->pval;
912 creature_ptr->extra_blows[1] += o_ptr->pval;
918 BIT_FLAGS has_resist_acid(player_type *creature_ptr)
920 BIT_FLAGS result = 0L;
922 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
923 result |= FLAG_CAUSE_RACE;
926 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_YEEK || creature_ptr->prace == RACE_KLACKON)) {
927 result |= FLAG_CAUSE_RACE;
930 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
931 result |= FLAG_CAUSE_RACE;
934 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
935 result |= FLAG_CAUSE_BATTLE_FORM;
938 if (creature_ptr->ult_res) {
939 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
942 result |= has_immune_acid(creature_ptr);
944 result |= check_equipment_flags(creature_ptr, TR_RES_ACID);
949 BIT_FLAGS has_resist_elec(player_type *creature_ptr)
951 BIT_FLAGS result = 0L;
953 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
954 result |= FLAG_CAUSE_RACE;
957 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 19) {
958 result |= FLAG_CAUSE_RACE;
961 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
962 result |= FLAG_CAUSE_BATTLE_FORM;
965 if (creature_ptr->ult_res) {
966 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
969 result |= check_equipment_flags(creature_ptr, TR_RES_ELEC);
970 result |= has_immune_elec(creature_ptr);
974 BIT_FLAGS has_resist_fire(player_type *creature_ptr)
976 BIT_FLAGS result = 0L;
978 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
979 result |= FLAG_CAUSE_RACE;
982 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 4) {
983 result |= FLAG_CAUSE_RACE;
986 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
987 result |= FLAG_CAUSE_RACE;
990 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
991 result |= FLAG_CAUSE_BATTLE_FORM;
994 if (creature_ptr->ult_res) {
995 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
998 result |= check_equipment_flags(creature_ptr, TR_RES_FIRE);
999 result |= has_immune_fire(creature_ptr);
1003 BIT_FLAGS has_resist_cold(player_type *creature_ptr)
1005 BIT_FLAGS result = 0L;
1007 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1008 result |= FLAG_CAUSE_RACE;
1011 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ZOMBIE) && creature_ptr->lev > 4) {
1012 result |= FLAG_CAUSE_RACE;
1015 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON) && creature_ptr->lev > 9) {
1016 result |= FLAG_CAUSE_RACE;
1019 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
1020 result |= FLAG_CAUSE_RACE;
1023 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1024 result |= FLAG_CAUSE_BATTLE_FORM;
1027 if (creature_ptr->ult_res) {
1028 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1031 result |= check_equipment_flags(creature_ptr, TR_RES_COLD);
1032 result |= has_immune_cold(creature_ptr);
1036 BIT_FLAGS has_resist_pois(player_type *creature_ptr)
1038 BIT_FLAGS result = 0L;
1040 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
1041 result |= FLAG_CAUSE_CLASS;
1043 if (creature_ptr->mimic_form == MIMIC_VAMPIRE || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1044 result |= FLAG_CAUSE_RACE;
1047 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 34) {
1048 result |= FLAG_CAUSE_RACE;
1051 if (!creature_ptr->mimic_form
1052 && (creature_ptr->prace == RACE_KOBOLD || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
1053 || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ANDROID)) {
1054 result |= FLAG_CAUSE_RACE;
1057 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1058 result |= FLAG_CAUSE_BATTLE_FORM;
1061 if (creature_ptr->ult_res) {
1062 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1065 result |= check_equipment_flags(creature_ptr, TR_RES_POIS);
1069 BIT_FLAGS has_resist_conf(player_type *creature_ptr)
1071 BIT_FLAGS result = 0L;
1073 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
1074 result |= FLAG_CAUSE_CLASS;
1076 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1077 result |= FLAG_CAUSE_PERSONALITY;
1080 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_KLACKON || creature_ptr->prace == RACE_BEASTMAN || creature_ptr->prace == RACE_KUTAR)) {
1081 result |= FLAG_CAUSE_RACE;
1084 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1085 result |= FLAG_CAUSE_RACE;
1088 if (creature_ptr->ult_res || creature_ptr->magicdef) {
1089 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1092 if (creature_ptr->special_defense & KATA_MUSOU) {
1093 result |= FLAG_CAUSE_BATTLE_FORM;
1096 result |= check_equipment_flags(creature_ptr, TR_RES_CONF);
1100 BIT_FLAGS has_resist_sound(player_type *creature_ptr)
1102 BIT_FLAGS result = 0L;
1104 if (creature_ptr->pclass == CLASS_BARD) {
1105 result |= FLAG_CAUSE_CLASS;
1108 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_CYCLOPS || creature_ptr->prace == RACE_BEASTMAN)) {
1109 result |= FLAG_CAUSE_RACE;
1112 if (creature_ptr->special_defense & KATA_MUSOU) {
1113 result |= FLAG_CAUSE_BATTLE_FORM;
1116 if (creature_ptr->ult_res) {
1117 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1120 result |= check_equipment_flags(creature_ptr, TR_RES_SOUND);
1124 BIT_FLAGS has_resist_lite(player_type *creature_ptr)
1126 BIT_FLAGS result = 0L;
1128 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ELF || creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_SPRITE)) {
1129 result |= FLAG_CAUSE_RACE;
1132 if (creature_ptr->special_defense & KATA_MUSOU) {
1133 result |= FLAG_CAUSE_BATTLE_FORM;
1136 if (creature_ptr->ult_res) {
1137 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1140 result |= check_equipment_flags(creature_ptr, TR_RES_LITE);
1144 BIT_FLAGS has_resist_dark(player_type *creature_ptr)
1146 BIT_FLAGS result = 0L;
1148 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1149 result |= FLAG_CAUSE_RACE;
1152 if (!creature_ptr->mimic_form
1153 && (creature_ptr->prace == RACE_HALF_ORC || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_NIBELUNG
1154 || creature_ptr->prace == RACE_DARK_ELF || creature_ptr->prace == RACE_VAMPIRE)) {
1155 result |= FLAG_CAUSE_RACE;
1158 if (creature_ptr->special_defense & KATA_MUSOU) {
1159 result |= FLAG_CAUSE_BATTLE_FORM;
1162 if (creature_ptr->ult_res) {
1163 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1166 result |= check_equipment_flags(creature_ptr, TR_RES_DARK);
1170 BIT_FLAGS has_resist_chaos(player_type *creature_ptr)
1172 BIT_FLAGS result = 0L;
1174 if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
1175 result |= FLAG_CAUSE_CLASS;
1177 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1178 result |= FLAG_CAUSE_RACE;
1181 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
1182 result |= FLAG_CAUSE_RACE;
1184 if (creature_ptr->special_defense & KATA_MUSOU) {
1185 result |= FLAG_CAUSE_BATTLE_FORM;
1188 if (creature_ptr->ult_res) {
1189 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1192 result |= check_equipment_flags(creature_ptr, TR_RES_CHAOS);
1196 BIT_FLAGS has_resist_disen(player_type *creature_ptr)
1198 BIT_FLAGS result = 0L;
1200 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1201 result |= FLAG_CAUSE_RACE;
1204 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_NIBELUNG)
1205 result |= FLAG_CAUSE_RACE;
1207 if (creature_ptr->special_defense & KATA_MUSOU) {
1208 result |= FLAG_CAUSE_BATTLE_FORM;
1211 if (creature_ptr->ult_res) {
1212 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1215 result |= check_equipment_flags(creature_ptr, TR_RES_DISEN);
1219 BIT_FLAGS has_resist_shard(player_type *creature_ptr)
1221 BIT_FLAGS result = 0L;
1223 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_HALF_TITAN || creature_ptr->prace == RACE_SKELETON))
1224 result |= FLAG_CAUSE_RACE;
1226 if (creature_ptr->special_defense & KATA_MUSOU) {
1227 result |= FLAG_CAUSE_BATTLE_FORM;
1230 if (creature_ptr->ult_res) {
1231 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1234 result |= check_equipment_flags(creature_ptr, TR_RES_SHARDS);
1238 BIT_FLAGS has_resist_nexus(player_type *creature_ptr)
1240 BIT_FLAGS result = 0L;
1242 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1243 result |= FLAG_CAUSE_RACE;
1246 if (creature_ptr->special_defense & KATA_MUSOU) {
1247 result |= FLAG_CAUSE_BATTLE_FORM;
1250 if (creature_ptr->ult_res) {
1251 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1254 result |= check_equipment_flags(creature_ptr, TR_RES_NEXUS);
1258 void has_resist_blind(player_type *creature_ptr)
1261 BIT_FLAGS flgs[TR_FLAG_SIZE];
1262 creature_ptr->resist_blind = FALSE;
1264 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1265 creature_ptr->resist_blind = TRUE;
1268 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DWARF)
1269 creature_ptr->resist_blind = TRUE;
1271 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1272 creature_ptr->resist_blind = TRUE;
1275 if (creature_ptr->magicdef) {
1276 creature_ptr->resist_blind = TRUE;
1279 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1280 o_ptr = &creature_ptr->inventory_list[i];
1284 object_flags(creature_ptr, o_ptr, flgs);
1286 if (has_flag(flgs, TR_RES_BLIND))
1287 creature_ptr->resist_blind = TRUE;
1291 void has_resist_neth(player_type *creature_ptr)
1294 BIT_FLAGS flgs[TR_FLAG_SIZE];
1296 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1297 creature_ptr->resist_neth = TRUE;
1300 if (!creature_ptr->mimic_form
1301 && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE
1302 || creature_ptr->prace == RACE_BALROG))
1303 creature_ptr->resist_neth = TRUE;
1305 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1306 creature_ptr->resist_neth = TRUE;
1309 if (creature_ptr->tim_res_nether) {
1310 creature_ptr->resist_neth = TRUE;
1313 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1314 o_ptr = &creature_ptr->inventory_list[i];
1318 object_flags(creature_ptr, o_ptr, flgs);
1320 if (has_flag(flgs, TR_RES_NETHER))
1321 creature_ptr->resist_neth = TRUE;
1325 void has_resist_time(player_type *creature_ptr)
1328 BIT_FLAGS flgs[TR_FLAG_SIZE];
1329 creature_ptr->resist_time = FALSE;
1331 if (creature_ptr->tim_res_time) {
1332 creature_ptr->resist_time = TRUE;
1335 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1336 o_ptr = &creature_ptr->inventory_list[i];
1340 object_flags(creature_ptr, o_ptr, flgs);
1341 if (o_ptr->name2 == EGO_RING_RES_TIME)
1342 creature_ptr->resist_time = TRUE;
1346 void has_resist_water(player_type *creature_ptr)
1348 creature_ptr->resist_water = FALSE;
1350 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
1351 creature_ptr->resist_water = TRUE;
1354 void has_resist_fear(player_type *creature_ptr)
1357 BIT_FLAGS flgs[TR_FLAG_SIZE];
1358 creature_ptr->resist_fear = FALSE;
1360 if (creature_ptr->muta3 & MUT3_FEARLESS)
1361 creature_ptr->resist_fear = TRUE;
1363 switch (creature_ptr->pclass) {
1365 if (creature_ptr->lev > 29)
1366 creature_ptr->resist_fear = TRUE;
1369 if (creature_ptr->lev > 39)
1370 creature_ptr->resist_fear = TRUE;
1372 case CLASS_CHAOS_WARRIOR:
1373 if (creature_ptr->lev > 39)
1374 creature_ptr->resist_fear = TRUE;
1376 case CLASS_MINDCRAFTER:
1377 if (creature_ptr->lev > 9)
1378 creature_ptr->resist_fear = TRUE;
1381 if (creature_ptr->lev > 29)
1382 creature_ptr->resist_fear = TRUE;
1385 creature_ptr->resist_fear = TRUE;
1389 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1390 creature_ptr->resist_fear = TRUE;
1393 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
1394 creature_ptr->resist_fear = TRUE;
1396 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1397 creature_ptr->resist_fear = TRUE;
1400 if (is_hero(creature_ptr) || creature_ptr->shero) {
1401 creature_ptr->resist_fear = TRUE;
1404 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1405 o_ptr = &creature_ptr->inventory_list[i];
1409 object_flags(creature_ptr, o_ptr, flgs);
1410 if (has_flag(flgs, TR_RES_FEAR))
1411 creature_ptr->resist_fear = TRUE;
1415 BIT_FLAGS has_immune_acid(player_type *creature_ptr)
1417 BIT_FLAGS result = 0L;
1418 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_YEEK && creature_ptr->lev > 19)
1419 result |= FLAG_CAUSE_RACE;
1421 if (creature_ptr->ele_immune) {
1422 if (creature_ptr->special_defense & DEFENSE_ACID)
1423 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1426 result |= check_equipment_flags(creature_ptr, TR_IM_ACID);
1430 BIT_FLAGS has_immune_elec(player_type *creature_ptr)
1432 BIT_FLAGS result = 0L;
1434 if (creature_ptr->ele_immune) {
1435 if (creature_ptr->special_defense & DEFENSE_ELEC)
1436 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1439 result |= check_equipment_flags(creature_ptr, TR_IM_ELEC);
1443 BIT_FLAGS has_immune_fire(player_type *creature_ptr)
1445 BIT_FLAGS result = 0L;
1447 if (creature_ptr->ele_immune) {
1448 if (creature_ptr->special_defense & DEFENSE_FIRE)
1449 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1452 result |= check_equipment_flags(creature_ptr, TR_IM_FIRE);
1456 BIT_FLAGS has_immune_cold(player_type *creature_ptr)
1458 BIT_FLAGS result = 0L;
1460 if (creature_ptr->ele_immune) {
1461 if (creature_ptr->special_defense & DEFENSE_COLD)
1462 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
1465 result |= check_equipment_flags(creature_ptr, TR_IM_COLD);
1469 bool has_right_hand_weapon(player_type *creature_ptr)
1471 if (has_melee_weapon(creature_ptr, INVEN_RARM))
1474 if (can_two_hands_wielding(creature_ptr)) {
1475 switch (creature_ptr->pclass) {
1477 case CLASS_FORCETRAINER:
1478 case CLASS_BERSERKER:
1479 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
1489 bool has_left_hand_weapon(player_type *creature_ptr) { return has_melee_weapon(creature_ptr, INVEN_LARM); }
1491 bool has_two_handed_weapons(player_type *creature_ptr)
1493 if (can_two_hands_wielding(creature_ptr)) {
1494 if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
1495 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
1497 } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
1498 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
1505 void has_lite(player_type *creature_ptr)
1507 creature_ptr->lite = FALSE;
1508 if (creature_ptr->pclass == CLASS_NINJA)
1511 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1512 creature_ptr->lite = TRUE;
1515 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1516 creature_ptr->lite = TRUE;
1519 if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
1520 creature_ptr->lite = TRUE;
1523 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
1524 creature_ptr->lite = TRUE;
1526 if (creature_ptr->sh_fire)
1527 creature_ptr->lite = TRUE;
1529 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1530 creature_ptr->lite = TRUE;
1534 bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
1537 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1538 if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1539 if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && has_two_handed_weapons(creature_ptr)
1540 && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
1546 bool is_icky_wield_weapon(player_type *creature_ptr, int i)
1549 BIT_FLAGS flgs[TR_FLAG_SIZE];
1550 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1551 object_flags(creature_ptr, o_ptr, flgs);
1553 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1555 } else if (creature_ptr->pclass == CLASS_SORCERER) {
1556 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
1560 if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
1566 bool is_riding_wield_weapon(player_type *creature_ptr, int i)
1569 BIT_FLAGS flgs[TR_FLAG_SIZE];
1570 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1571 object_flags(creature_ptr, o_ptr, flgs);
1572 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
1573 && !has_flag(flgs, TR_RIDING)) {
1579 bool is_not_ninja_weapon(player_type *creature_ptr, int i)
1581 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1582 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1583 return creature_ptr->pclass == CLASS_NINJA
1584 && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
1587 bool is_not_monk_weapon(player_type *creature_ptr, int i)
1589 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1590 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1591 return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
1594 bool has_good_luck(player_type *creature_ptr) { return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta3 |= MUT3_GOOD_LUCK); };