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 void has_hold_exp(player_type *creature_ptr)
429 BIT_FLAGS flgs[TR_FLAG_SIZE];
431 creature_ptr->hold_exp = FALSE;
433 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
434 creature_ptr->hold_exp = TRUE;
437 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
438 creature_ptr->hold_exp = TRUE;
441 if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON)
442 || is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
443 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG)
444 || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
445 creature_ptr->hold_exp = TRUE;
448 if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
449 if (creature_ptr->lev > 34)
450 creature_ptr->hold_exp = TRUE;
453 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
454 creature_ptr->hold_exp = TRUE;
457 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
458 o_ptr = &creature_ptr->inventory_list[i];
462 object_flags(creature_ptr, o_ptr, flgs);
463 if (has_flag(flgs, TR_HOLD_EXP))
464 creature_ptr->hold_exp = TRUE;
468 void has_see_inv(player_type *creature_ptr)
471 BIT_FLAGS flgs[TR_FLAG_SIZE];
472 creature_ptr->see_inv = FALSE;
474 if (creature_ptr->pclass == CLASS_NINJA || creature_ptr->lev > 29)
475 creature_ptr->see_inv = TRUE;
477 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
478 creature_ptr->see_inv = TRUE;
481 if (!creature_ptr->mimic_form
482 && (creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
483 || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ARCHON)) {
484 creature_ptr->see_inv = TRUE;
487 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DARK_ELF) {
488 if (creature_ptr->lev > 19)
489 creature_ptr->see_inv = TRUE;
492 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MIND_FLAYER) {
493 if (creature_ptr->lev > 14)
494 creature_ptr->see_inv = TRUE;
497 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
498 if (creature_ptr->lev > 9)
499 creature_ptr->see_inv = TRUE;
502 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
503 creature_ptr->see_inv = TRUE;
506 if (creature_ptr->tim_invis) {
507 creature_ptr->see_inv = TRUE;
510 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
511 o_ptr = &creature_ptr->inventory_list[i];
515 object_flags(creature_ptr, o_ptr, flgs);
516 if (has_flag(flgs, TR_SEE_INVIS))
517 creature_ptr->see_inv = TRUE;
521 BIT_FLAGS has_free_act(player_type *creature_ptr)
523 BIT_FLAGS result = 0L;
525 if (creature_ptr->muta3 & MUT3_MOTION)
526 result |= FLAG_CAUSE_MUTATION;
528 if (is_specific_player_race(creature_ptr, RACE_GNOME) || is_specific_player_race(creature_ptr, RACE_GOLEM)
529 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
530 result |= FLAG_CAUSE_RACE;
533 if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
534 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
535 if (creature_ptr->lev > 24)
536 result |= FLAG_CAUSE_CLASS;
539 if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) {
540 if (!(heavy_armor(creature_ptr))) {
541 if (creature_ptr->lev > 24)
542 result |= FLAG_CAUSE_CLASS;
546 if (creature_ptr->pclass == CLASS_BERSERKER) {
547 result |= FLAG_CAUSE_CLASS;
550 if (creature_ptr->ult_res || creature_ptr->magicdef) {
551 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
554 if (creature_ptr->special_defense & KATA_MUSOU) {
555 result |= FLAG_CAUSE_BATTLE_FORM;
558 result |= check_equipment_flags(creature_ptr, TR_FREE_ACT);
562 BIT_FLAGS has_sustain_str(player_type *creature_ptr)
564 BIT_FLAGS result = 0L;
566 if (creature_ptr->pclass == CLASS_BERSERKER) {
567 result |= FLAG_CAUSE_CLASS;
569 if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) || is_specific_player_race(creature_ptr, RACE_HALF_OGRE)
570 || is_specific_player_race(creature_ptr, RACE_HALF_GIANT)) {
571 result |= FLAG_CAUSE_RACE;
574 if (creature_ptr->ult_res) {
575 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
578 if (creature_ptr->special_defense & KATA_MUSOU) {
579 result |= FLAG_CAUSE_BATTLE_FORM;
582 result |= check_equipment_flags(creature_ptr, TR_SUST_STR);
586 BIT_FLAGS has_sustain_int(player_type *creature_ptr)
588 BIT_FLAGS result = 0L;
590 if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER)) {
591 result |= FLAG_CAUSE_RACE;
594 if (creature_ptr->ult_res) {
595 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
598 if (creature_ptr->special_defense & KATA_MUSOU) {
599 result |= FLAG_CAUSE_BATTLE_FORM;
602 result |= check_equipment_flags(creature_ptr, TR_SUST_INT);
606 BIT_FLAGS has_sustain_wis(player_type *creature_ptr)
608 BIT_FLAGS result = 0L;
611 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
612 result |= FLAG_CAUSE_CLASS;
614 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
615 result |= FLAG_CAUSE_RACE;
618 if (creature_ptr->ult_res) {
619 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
622 if (creature_ptr->special_defense & KATA_MUSOU) {
623 result |= FLAG_CAUSE_BATTLE_FORM;
626 result |= check_equipment_flags(creature_ptr, TR_SUST_WIS);
630 BIT_FLAGS has_sustain_dex(player_type *creature_ptr)
632 BIT_FLAGS result = 0L;
633 if (creature_ptr->pclass == CLASS_BERSERKER) {
634 result |= FLAG_CAUSE_CLASS;
637 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 24)
638 result |= FLAG_CAUSE_CLASS;
640 if (creature_ptr->ult_res) {
641 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
644 if (creature_ptr->special_defense & KATA_MUSOU) {
645 result |= FLAG_CAUSE_BATTLE_FORM;
648 result |= check_equipment_flags(creature_ptr, TR_SUST_DEX);
652 BIT_FLAGS has_sustain_con(player_type *creature_ptr)
654 BIT_FLAGS result = 0L;
655 if (creature_ptr->pclass == CLASS_BERSERKER) {
656 result |= FLAG_CAUSE_CLASS;
659 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
660 result |= FLAG_CAUSE_RACE;
663 if (creature_ptr->ult_res) {
664 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
667 if (creature_ptr->special_defense & KATA_MUSOU) {
668 result |= FLAG_CAUSE_BATTLE_FORM;
671 result |= check_equipment_flags(creature_ptr, TR_SUST_CON);
675 BIT_FLAGS has_sustain_chr(player_type *creature_ptr)
677 BIT_FLAGS result = 0L;
679 if (creature_ptr->ult_res) {
680 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
683 if (creature_ptr->special_defense & KATA_MUSOU) {
684 result |= FLAG_CAUSE_BATTLE_FORM;
687 result |= check_equipment_flags(creature_ptr, TR_SUST_CHR);
691 BIT_FLAGS has_levitation(player_type *creature_ptr)
693 BIT_FLAGS result = 0L;
695 if (creature_ptr->muta3 & MUT3_WINGS)
696 result = FLAG_CAUSE_MUTATION;
698 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
699 result = FLAG_CAUSE_RACE;
702 if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) || is_specific_player_race(creature_ptr, RACE_SPECTRE)
703 || is_specific_player_race(creature_ptr, RACE_SPRITE) || is_specific_player_race(creature_ptr, RACE_ARCHON)
704 || is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
705 result = FLAG_CAUSE_RACE;
708 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU || (creature_ptr->special_defense & KATA_MUSOU)) {
709 result = FLAG_CAUSE_BATTLE_FORM;
712 if (creature_ptr->ult_res) {
713 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
716 if (creature_ptr->riding) {
717 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
718 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
719 result = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? result : 0;
722 if (creature_ptr->tim_levitation) {
723 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
726 result |= check_equipment_flags(creature_ptr, TR_LEVITATION);
730 void has_can_swim(player_type *creature_ptr)
732 creature_ptr->can_swim = FALSE;
733 if (creature_ptr->riding) {
734 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
735 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
736 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
737 creature_ptr->can_swim = TRUE;
741 void has_slow_digest(player_type *creature_ptr)
744 BIT_FLAGS flgs[TR_FLAG_SIZE];
745 creature_ptr->slow_digest = FALSE;
747 if (creature_ptr->pclass == CLASS_NINJA) {
748 creature_ptr->slow_digest = TRUE;
751 if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
752 if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
753 creature_ptr->slow_digest = TRUE;
754 /* Let's not make Regeneration
755 * a disadvantage for the poor warriors who can
756 * never learn a spell that satisfies hunger (actually
757 * neither can rogues, but half-trolls are not
758 * supposed to play rogues) */
762 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
763 creature_ptr->slow_digest = TRUE;
766 if (!creature_ptr->mimic_form
767 && (creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE
768 || creature_ptr->prace == RACE_ANDROID)) {
769 creature_ptr->slow_digest = TRUE;
772 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
773 o_ptr = &creature_ptr->inventory_list[i];
776 object_flags(creature_ptr, o_ptr, flgs);
777 if (has_flag(flgs, TR_SLOW_DIGEST))
778 creature_ptr->slow_digest = TRUE;
782 BIT_FLAGS has_regenerate(player_type *creature_ptr)
784 BIT_FLAGS result = 0L;
786 if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) && creature_ptr->lev > 14) {
787 result |= FLAG_CAUSE_RACE;
790 if (is_specific_player_race(creature_ptr, RACE_AMBERITE)) {
791 result |= FLAG_CAUSE_RACE;
794 if (creature_ptr->pclass == CLASS_WARRIOR && creature_ptr->lev > 44) {
795 result |= FLAG_CAUSE_RACE;
798 if (creature_ptr->pclass == CLASS_BERSERKER) {
799 result |= FLAG_CAUSE_RACE;
802 if (creature_ptr->muta3 & MUT3_REGEN)
803 result |= FLAG_CAUSE_MUTATION;
805 if (creature_ptr->special_defense & KATA_MUSOU) {
806 result |= FLAG_CAUSE_MUTATION;
809 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_regen) {
810 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
813 result |= check_equipment_flags(creature_ptr, TR_REGEN);
815 if (creature_ptr->muta3 & MUT3_FLESH_ROT)
821 void has_curses(player_type *creature_ptr)
824 BIT_FLAGS flgs[TR_FLAG_SIZE];
825 creature_ptr->cursed = 0L;
827 if (creature_ptr->pseikaku == PERSONALITY_SEXY)
828 creature_ptr->cursed |= (TRC_AGGRAVATE);
830 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
831 o_ptr = &creature_ptr->inventory_list[i];
834 object_flags(creature_ptr, o_ptr, flgs);
835 if (has_flag(flgs, TR_AGGRAVATE))
836 creature_ptr->cursed |= TRC_AGGRAVATE;
837 if (has_flag(flgs, TR_DRAIN_EXP))
838 creature_ptr->cursed |= TRC_DRAIN_EXP;
839 if (has_flag(flgs, TR_TY_CURSE))
840 creature_ptr->cursed |= TRC_TY_CURSE;
841 if (has_flag(flgs, TR_ADD_L_CURSE))
842 creature_ptr->cursed |= TRC_ADD_L_CURSE;
843 if (has_flag(flgs, TR_ADD_H_CURSE))
844 creature_ptr->cursed |= TRC_ADD_H_CURSE;
845 if (has_flag(flgs, TR_DRAIN_HP))
846 creature_ptr->cursed |= TRC_DRAIN_HP;
847 if (has_flag(flgs, TR_DRAIN_MANA))
848 creature_ptr->cursed |= TRC_DRAIN_MANA;
849 if (has_flag(flgs, TR_CALL_ANIMAL))
850 creature_ptr->cursed |= TRC_CALL_ANIMAL;
851 if (has_flag(flgs, TR_CALL_DEMON))
852 creature_ptr->cursed |= TRC_CALL_DEMON;
853 if (has_flag(flgs, TR_CALL_DRAGON))
854 creature_ptr->cursed |= TRC_CALL_DRAGON;
855 if (has_flag(flgs, TR_CALL_UNDEAD))
856 creature_ptr->cursed |= TRC_CALL_UNDEAD;
857 if (has_flag(flgs, TR_COWARDICE))
858 creature_ptr->cursed |= TRC_COWARDICE;
859 if (has_flag(flgs, TR_LOW_MELEE))
860 creature_ptr->cursed |= TRC_LOW_MELEE;
861 if (has_flag(flgs, TR_LOW_AC))
862 creature_ptr->cursed |= TRC_LOW_AC;
863 if (has_flag(flgs, TR_LOW_MAGIC))
864 creature_ptr->cursed |= TRC_LOW_MAGIC;
865 if (has_flag(flgs, TR_FAST_DIGEST))
866 creature_ptr->cursed |= TRC_FAST_DIGEST;
867 if (has_flag(flgs, TR_SLOW_REGEN))
868 creature_ptr->cursed |= TRC_SLOW_REGEN;
870 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
871 if (o_ptr->name1 == ART_CHAINSWORD)
872 creature_ptr->cursed |= TRC_CHAINSWORD;
874 if (has_flag(flgs, TR_TELEPORT)) {
875 if (object_is_cursed(o_ptr))
876 creature_ptr->cursed |= TRC_TELEPORT;
878 concptr insc = quark_str(o_ptr->inscription);
880 /* {.} will stop random teleportation. */
881 if (o_ptr->inscription && angband_strchr(insc, '.')) {
883 creature_ptr->cursed |= TRC_TELEPORT_SELF;
889 if (creature_ptr->cursed & TRC_TELEPORT)
890 creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
892 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
893 creature_ptr->cursed &= ~(TRC_AGGRAVATE);
897 BIT_FLAGS has_impact(player_type *creature_ptr)
899 BIT_FLAGS result = 0L;
900 result |= check_equipment_flags(creature_ptr, TR_IMPACT);
904 void has_extra_blow(player_type *creature_ptr)
907 BIT_FLAGS flgs[TR_FLAG_SIZE];
908 creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
910 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
911 o_ptr = &creature_ptr->inventory_list[i];
915 object_flags(creature_ptr, o_ptr, flgs);
917 if (has_flag(flgs, TR_INFRA))
918 creature_ptr->see_infra += o_ptr->pval;
919 if (has_flag(flgs, TR_BLOWS)) {
920 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr))
921 creature_ptr->extra_blows[0] += o_ptr->pval;
922 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !has_two_handed_weapons(creature_ptr))
923 creature_ptr->extra_blows[1] += o_ptr->pval;
925 creature_ptr->extra_blows[0] += o_ptr->pval;
926 creature_ptr->extra_blows[1] += o_ptr->pval;
932 void has_resist_acid(player_type *creature_ptr)
935 BIT_FLAGS flgs[TR_FLAG_SIZE];
936 creature_ptr->resist_acid = FALSE;
938 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
939 creature_ptr->resist_acid = TRUE;
942 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_YEEK || creature_ptr->prace == RACE_KLACKON)) {
943 creature_ptr->resist_acid = TRUE;
946 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
947 creature_ptr->resist_acid = TRUE;
950 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
951 creature_ptr->resist_acid = TRUE;
954 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
955 creature_ptr->resist_acid = TRUE;
958 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
959 o_ptr = &creature_ptr->inventory_list[i];
963 object_flags(creature_ptr, o_ptr, flgs);
964 if (has_flag(flgs, TR_RES_ACID))
965 creature_ptr->resist_acid = TRUE;
968 if (creature_ptr->immune_acid)
969 creature_ptr->resist_acid = TRUE;
972 void has_resist_elec(player_type *creature_ptr)
975 BIT_FLAGS flgs[TR_FLAG_SIZE];
976 creature_ptr->resist_elec = FALSE;
978 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
979 creature_ptr->resist_elec = TRUE;
982 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 19) {
983 creature_ptr->resist_elec = TRUE;
986 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
987 creature_ptr->resist_elec = TRUE;
990 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
991 creature_ptr->resist_elec = TRUE;
994 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
995 o_ptr = &creature_ptr->inventory_list[i];
999 object_flags(creature_ptr, o_ptr, flgs);
1000 if (has_flag(flgs, TR_RES_ELEC))
1001 creature_ptr->resist_elec = TRUE;
1004 if (creature_ptr->immune_elec)
1005 creature_ptr->resist_elec = TRUE;
1008 void has_resist_fire(player_type *creature_ptr)
1011 BIT_FLAGS flgs[TR_FLAG_SIZE];
1012 creature_ptr->resist_fire = FALSE;
1014 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1015 creature_ptr->resist_fire = TRUE;
1018 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 4) {
1019 creature_ptr->resist_fire = TRUE;
1022 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
1023 creature_ptr->resist_fire = TRUE;
1026 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1027 creature_ptr->resist_fire = TRUE;
1030 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1031 creature_ptr->resist_fire = TRUE;
1034 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1035 o_ptr = &creature_ptr->inventory_list[i];
1039 object_flags(creature_ptr, o_ptr, flgs);
1041 if (has_flag(flgs, TR_RES_FIRE))
1042 creature_ptr->resist_fire = TRUE;
1045 if (creature_ptr->immune_fire)
1046 creature_ptr->resist_fire = TRUE;
1049 void has_resist_cold(player_type *creature_ptr)
1052 BIT_FLAGS flgs[TR_FLAG_SIZE];
1053 creature_ptr->resist_cold = FALSE;
1055 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1056 creature_ptr->resist_cold = TRUE;
1059 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ZOMBIE) && creature_ptr->lev > 4) {
1060 creature_ptr->resist_cold = TRUE;
1063 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON) && creature_ptr->lev > 9) {
1064 creature_ptr->resist_cold = TRUE;
1067 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
1068 creature_ptr->resist_fire = TRUE;
1071 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1072 creature_ptr->resist_cold = TRUE;
1075 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1076 creature_ptr->resist_cold = TRUE;
1079 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1080 o_ptr = &creature_ptr->inventory_list[i];
1084 object_flags(creature_ptr, o_ptr, flgs);
1086 if (has_flag(flgs, TR_RES_COLD))
1087 creature_ptr->resist_cold = TRUE;
1090 if (creature_ptr->immune_cold)
1091 creature_ptr->resist_cold = TRUE;
1094 void has_resist_pois(player_type *creature_ptr)
1097 BIT_FLAGS flgs[TR_FLAG_SIZE];
1098 creature_ptr->resist_pois = FALSE;
1100 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
1101 creature_ptr->resist_pois = TRUE;
1103 if (creature_ptr->mimic_form == MIMIC_VAMPIRE || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1104 creature_ptr->resist_pois = TRUE;
1107 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 34) {
1108 creature_ptr->resist_pois = TRUE;
1111 if (!creature_ptr->mimic_form
1112 && (creature_ptr->prace == RACE_KOBOLD || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
1113 || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ANDROID)) {
1114 creature_ptr->resist_pois = TRUE;
1117 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1118 creature_ptr->resist_pois = TRUE;
1121 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1122 creature_ptr->resist_pois = TRUE;
1125 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1126 o_ptr = &creature_ptr->inventory_list[i];
1130 object_flags(creature_ptr, o_ptr, flgs);
1132 if (has_flag(flgs, TR_RES_POIS))
1133 creature_ptr->resist_pois = TRUE;
1137 void has_resist_conf(player_type *creature_ptr)
1140 BIT_FLAGS flgs[TR_FLAG_SIZE];
1141 creature_ptr->resist_conf = FALSE;
1143 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
1144 creature_ptr->resist_conf = TRUE;
1146 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1147 creature_ptr->resist_conf = TRUE;
1150 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_KLACKON || creature_ptr->prace == RACE_BEASTMAN || creature_ptr->prace == RACE_KUTAR)) {
1151 creature_ptr->resist_conf = TRUE;
1154 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1155 creature_ptr->resist_conf = TRUE;
1158 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1159 creature_ptr->resist_conf = TRUE;
1162 if (creature_ptr->magicdef) {
1163 creature_ptr->resist_conf = TRUE;
1166 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1167 o_ptr = &creature_ptr->inventory_list[i];
1171 object_flags(creature_ptr, o_ptr, flgs);
1173 if (has_flag(flgs, TR_RES_CONF))
1174 creature_ptr->resist_conf = TRUE;
1178 void has_resist_sound(player_type *creature_ptr)
1181 BIT_FLAGS flgs[TR_FLAG_SIZE];
1182 creature_ptr->resist_sound = FALSE;
1184 if (creature_ptr->pclass == CLASS_BARD) {
1185 creature_ptr->resist_sound = TRUE;
1188 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_CYCLOPS || creature_ptr->prace == RACE_BEASTMAN)) {
1189 creature_ptr->resist_sound = TRUE;
1192 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1193 creature_ptr->resist_sound = TRUE;
1196 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1197 o_ptr = &creature_ptr->inventory_list[i];
1201 object_flags(creature_ptr, o_ptr, flgs);
1203 if (has_flag(flgs, TR_RES_SOUND))
1204 creature_ptr->resist_sound = TRUE;
1208 void has_resist_lite(player_type *creature_ptr)
1211 BIT_FLAGS flgs[TR_FLAG_SIZE];
1212 creature_ptr->resist_lite = FALSE;
1214 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ELF || creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_SPRITE)) {
1215 creature_ptr->resist_lite = TRUE;
1218 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1219 creature_ptr->resist_lite = TRUE;
1222 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1223 o_ptr = &creature_ptr->inventory_list[i];
1227 object_flags(creature_ptr, o_ptr, flgs);
1229 if (has_flag(flgs, TR_RES_LITE))
1230 creature_ptr->resist_lite = TRUE;
1234 void has_resist_dark(player_type *creature_ptr)
1237 BIT_FLAGS flgs[TR_FLAG_SIZE];
1238 creature_ptr->resist_dark = FALSE;
1240 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1241 creature_ptr->resist_dark = TRUE;
1244 if (!creature_ptr->mimic_form
1245 && (creature_ptr->prace == RACE_HALF_ORC || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_NIBELUNG
1246 || creature_ptr->prace == RACE_DARK_ELF || creature_ptr->prace == RACE_VAMPIRE)) {
1247 creature_ptr->resist_lite = TRUE;
1250 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1251 creature_ptr->resist_dark = TRUE;
1254 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1255 o_ptr = &creature_ptr->inventory_list[i];
1259 object_flags(creature_ptr, o_ptr, flgs);
1261 if (has_flag(flgs, TR_RES_DARK))
1262 creature_ptr->resist_dark = TRUE;
1266 void has_resist_chaos(player_type *creature_ptr)
1269 BIT_FLAGS flgs[TR_FLAG_SIZE];
1270 creature_ptr->resist_chaos = FALSE;
1272 if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
1273 creature_ptr->resist_chaos = TRUE;
1275 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1276 creature_ptr->resist_chaos = TRUE;
1279 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
1280 creature_ptr->resist_chaos = TRUE;
1282 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1283 creature_ptr->resist_chaos = TRUE;
1286 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1287 o_ptr = &creature_ptr->inventory_list[i];
1291 object_flags(creature_ptr, o_ptr, flgs);
1293 if (has_flag(flgs, TR_RES_CHAOS))
1294 creature_ptr->resist_chaos = TRUE;
1298 void has_resist_disen(player_type *creature_ptr)
1301 BIT_FLAGS flgs[TR_FLAG_SIZE];
1302 creature_ptr->resist_disen = FALSE;
1304 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1305 creature_ptr->resist_disen = TRUE;
1308 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_NIBELUNG)
1309 creature_ptr->resist_disen = TRUE;
1311 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1312 creature_ptr->resist_disen = TRUE;
1315 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1316 o_ptr = &creature_ptr->inventory_list[i];
1320 object_flags(creature_ptr, o_ptr, flgs);
1322 if (has_flag(flgs, TR_RES_DISEN))
1323 creature_ptr->resist_disen = TRUE;
1327 void has_resist_shard(player_type *creature_ptr)
1330 BIT_FLAGS flgs[TR_FLAG_SIZE];
1331 creature_ptr->resist_shard = FALSE;
1333 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_HALF_TITAN || creature_ptr->prace == RACE_SKELETON))
1334 creature_ptr->resist_shard = TRUE;
1336 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1337 creature_ptr->resist_shard = TRUE;
1340 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1341 o_ptr = &creature_ptr->inventory_list[i];
1345 object_flags(creature_ptr, o_ptr, flgs);
1347 if (has_flag(flgs, TR_RES_DISEN))
1348 creature_ptr->resist_shard = TRUE;
1352 void has_resist_nexus(player_type *creature_ptr)
1355 BIT_FLAGS flgs[TR_FLAG_SIZE];
1356 creature_ptr->resist_nexus = FALSE;
1358 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1359 creature_ptr->resist_nexus = TRUE;
1362 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1363 creature_ptr->resist_nexus = TRUE;
1366 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1367 o_ptr = &creature_ptr->inventory_list[i];
1371 object_flags(creature_ptr, o_ptr, flgs);
1373 if (has_flag(flgs, TR_RES_NEXUS))
1374 creature_ptr->resist_nexus = TRUE;
1378 void has_resist_blind(player_type *creature_ptr)
1381 BIT_FLAGS flgs[TR_FLAG_SIZE];
1382 creature_ptr->resist_blind = FALSE;
1384 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1385 creature_ptr->resist_blind = TRUE;
1388 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DWARF)
1389 creature_ptr->resist_blind = TRUE;
1391 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1392 creature_ptr->resist_blind = TRUE;
1395 if (creature_ptr->magicdef) {
1396 creature_ptr->resist_blind = TRUE;
1399 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1400 o_ptr = &creature_ptr->inventory_list[i];
1404 object_flags(creature_ptr, o_ptr, flgs);
1406 if (has_flag(flgs, TR_RES_BLIND))
1407 creature_ptr->resist_blind = TRUE;
1411 void has_resist_neth(player_type *creature_ptr)
1414 BIT_FLAGS flgs[TR_FLAG_SIZE];
1416 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1417 creature_ptr->resist_neth = TRUE;
1420 if (!creature_ptr->mimic_form
1421 && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE
1422 || creature_ptr->prace == RACE_BALROG))
1423 creature_ptr->resist_neth = TRUE;
1425 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1426 creature_ptr->resist_neth = TRUE;
1429 if (creature_ptr->tim_res_nether) {
1430 creature_ptr->resist_neth = TRUE;
1433 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1434 o_ptr = &creature_ptr->inventory_list[i];
1438 object_flags(creature_ptr, o_ptr, flgs);
1440 if (has_flag(flgs, TR_RES_NETHER))
1441 creature_ptr->resist_neth = TRUE;
1445 void has_resist_time(player_type *creature_ptr)
1448 BIT_FLAGS flgs[TR_FLAG_SIZE];
1449 creature_ptr->resist_time = FALSE;
1451 if (creature_ptr->tim_res_time) {
1452 creature_ptr->resist_time = TRUE;
1455 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1456 o_ptr = &creature_ptr->inventory_list[i];
1460 object_flags(creature_ptr, o_ptr, flgs);
1461 if (o_ptr->name2 == EGO_RING_RES_TIME)
1462 creature_ptr->resist_time = TRUE;
1466 void has_resist_water(player_type *creature_ptr)
1468 creature_ptr->resist_water = FALSE;
1470 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
1471 creature_ptr->resist_water = TRUE;
1474 void has_resist_fear(player_type *creature_ptr)
1477 BIT_FLAGS flgs[TR_FLAG_SIZE];
1478 creature_ptr->resist_fear = FALSE;
1480 if (creature_ptr->muta3 & MUT3_FEARLESS)
1481 creature_ptr->resist_fear = TRUE;
1483 switch (creature_ptr->pclass) {
1485 if (creature_ptr->lev > 29)
1486 creature_ptr->resist_fear = TRUE;
1489 if (creature_ptr->lev > 39)
1490 creature_ptr->resist_fear = TRUE;
1492 case CLASS_CHAOS_WARRIOR:
1493 if (creature_ptr->lev > 39)
1494 creature_ptr->resist_fear = TRUE;
1496 case CLASS_MINDCRAFTER:
1497 if (creature_ptr->lev > 9)
1498 creature_ptr->resist_fear = TRUE;
1501 if (creature_ptr->lev > 29)
1502 creature_ptr->resist_fear = TRUE;
1505 creature_ptr->resist_fear = TRUE;
1509 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1510 creature_ptr->resist_fear = TRUE;
1513 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
1514 creature_ptr->resist_fear = TRUE;
1516 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1517 creature_ptr->resist_fear = TRUE;
1520 if (is_hero(creature_ptr) || creature_ptr->shero) {
1521 creature_ptr->resist_fear = TRUE;
1524 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1525 o_ptr = &creature_ptr->inventory_list[i];
1529 object_flags(creature_ptr, o_ptr, flgs);
1530 if (has_flag(flgs, TR_RES_FEAR))
1531 creature_ptr->resist_fear = TRUE;
1535 void has_immune_acid(player_type *creature_ptr)
1538 BIT_FLAGS flgs[TR_FLAG_SIZE];
1539 creature_ptr->immune_acid = FALSE;
1541 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_YEEK && creature_ptr->lev > 19)
1542 creature_ptr->immune_acid = TRUE;
1544 if (creature_ptr->ele_immune) {
1545 if (creature_ptr->special_defense & DEFENSE_ACID)
1546 creature_ptr->immune_acid = TRUE;
1549 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1550 o_ptr = &creature_ptr->inventory_list[i];
1554 object_flags(creature_ptr, o_ptr, flgs);
1555 if (has_flag(flgs, TR_IM_ACID))
1556 creature_ptr->immune_acid = TRUE;
1560 void has_immune_elec(player_type *creature_ptr)
1563 BIT_FLAGS flgs[TR_FLAG_SIZE];
1564 creature_ptr->immune_elec = FALSE;
1565 if (creature_ptr->ele_immune) {
1566 if (creature_ptr->special_defense & DEFENSE_ELEC)
1567 creature_ptr->immune_elec = TRUE;
1570 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1571 o_ptr = &creature_ptr->inventory_list[i];
1575 object_flags(creature_ptr, o_ptr, flgs);
1576 if (has_flag(flgs, TR_IM_ELEC))
1577 creature_ptr->immune_elec = TRUE;
1581 void has_immune_fire(player_type *creature_ptr)
1584 BIT_FLAGS flgs[TR_FLAG_SIZE];
1585 creature_ptr->immune_fire = FALSE;
1586 if (creature_ptr->ele_immune) {
1587 if (creature_ptr->special_defense & DEFENSE_FIRE)
1588 creature_ptr->immune_fire = TRUE;
1591 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1592 o_ptr = &creature_ptr->inventory_list[i];
1596 object_flags(creature_ptr, o_ptr, flgs);
1597 if (has_flag(flgs, TR_IM_FIRE))
1598 creature_ptr->immune_fire = TRUE;
1602 void has_immune_cold(player_type *creature_ptr)
1605 BIT_FLAGS flgs[TR_FLAG_SIZE];
1606 creature_ptr->immune_cold = FALSE;
1607 if (creature_ptr->ele_immune) {
1608 if (creature_ptr->special_defense & DEFENSE_COLD)
1609 creature_ptr->immune_cold = TRUE;
1612 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1613 o_ptr = &creature_ptr->inventory_list[i];
1617 object_flags(creature_ptr, o_ptr, flgs);
1618 if (has_flag(flgs, TR_IM_COLD))
1619 creature_ptr->immune_cold = TRUE;
1623 bool has_right_hand_weapon(player_type *creature_ptr)
1625 if (has_melee_weapon(creature_ptr, INVEN_RARM))
1628 if (can_two_hands_wielding(creature_ptr)) {
1629 switch (creature_ptr->pclass) {
1631 case CLASS_FORCETRAINER:
1632 case CLASS_BERSERKER:
1633 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
1643 bool has_left_hand_weapon(player_type *creature_ptr) { return has_melee_weapon(creature_ptr, INVEN_LARM); }
1645 bool has_two_handed_weapons(player_type *creature_ptr)
1647 if (can_two_hands_wielding(creature_ptr)) {
1648 if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
1649 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
1651 } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
1652 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
1659 void has_lite(player_type *creature_ptr)
1661 creature_ptr->lite = FALSE;
1662 if (creature_ptr->pclass == CLASS_NINJA)
1665 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1666 creature_ptr->lite = TRUE;
1669 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1670 creature_ptr->lite = TRUE;
1673 if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
1674 creature_ptr->lite = TRUE;
1677 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
1678 creature_ptr->lite = TRUE;
1680 if (creature_ptr->sh_fire)
1681 creature_ptr->lite = TRUE;
1683 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1684 creature_ptr->lite = TRUE;
1688 bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
1691 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1692 if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1693 if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && has_two_handed_weapons(creature_ptr)
1694 && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
1700 bool is_icky_wield_weapon(player_type *creature_ptr, int i)
1703 BIT_FLAGS flgs[TR_FLAG_SIZE];
1704 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1705 object_flags(creature_ptr, o_ptr, flgs);
1707 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1709 } else if (creature_ptr->pclass == CLASS_SORCERER) {
1710 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
1714 if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
1720 bool is_riding_wield_weapon(player_type *creature_ptr, int i)
1723 BIT_FLAGS flgs[TR_FLAG_SIZE];
1724 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1725 object_flags(creature_ptr, o_ptr, flgs);
1726 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
1727 && !has_flag(flgs, TR_RIDING)) {
1733 bool is_not_ninja_weapon(player_type *creature_ptr, int i)
1735 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1736 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1737 return creature_ptr->pclass == CLASS_NINJA
1738 && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
1741 bool is_not_monk_weapon(player_type *creature_ptr, int i)
1743 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1744 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1745 return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
1748 bool has_good_luck(player_type *creature_ptr) { return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta3 |= MUT3_GOOD_LUCK); };