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)
317 { return creature_ptr->pclass == CLASS_NINJA ? FLAG_CAUSE_CLASS : 0L; }
319 void has_warning(player_type *creature_ptr)
322 BIT_FLAGS flgs[TR_FLAG_SIZE];
324 creature_ptr->warning = FALSE;
326 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
327 o_ptr = &creature_ptr->inventory_list[i];
331 object_flags(creature_ptr, o_ptr, flgs);
333 if (has_flag(flgs, TR_WARNING)) {
334 if (!o_ptr->inscription || !(angband_strchr(quark_str(o_ptr->inscription), '$')))
335 creature_ptr->warning = TRUE;
340 BIT_FLAGS has_anti_magic(player_type *creature_ptr)
342 BIT_FLAGS result = 0L;
343 result |= check_equipment_flags(creature_ptr, TR_NO_MAGIC);
347 BIT_FLAGS has_anti_tele(player_type *creature_ptr)
349 BIT_FLAGS result = 0L;
350 result |= check_equipment_flags(creature_ptr, TR_NO_TELE);
354 BIT_FLAGS has_sh_fire(player_type *creature_ptr)
356 BIT_FLAGS result = 0L;
358 if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
359 result |= FLAG_CAUSE_MUTATION;
362 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
363 result |= FLAG_CAUSE_RACE;
366 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
367 result |= FLAG_CAUSE_BATTLE_FORM;
370 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_sh_fire) {
371 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
374 result |= check_equipment_flags(creature_ptr, TR_SH_FIRE);
378 BIT_FLAGS has_sh_elec(player_type *creature_ptr)
380 BIT_FLAGS result = 0L;
382 if (creature_ptr->muta3 & MUT3_ELEC_TOUC)
383 result |= FLAG_CAUSE_MUTATION;
385 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK) || creature_ptr->ult_res) {
386 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
389 if (creature_ptr->special_defense & KAMAE_SEIRYU || (creature_ptr->special_defense & KATA_MUSOU)) {
390 result |= FLAG_CAUSE_BATTLE_FORM;
393 result |= check_equipment_flags(creature_ptr, TR_SH_ELEC);
397 BIT_FLAGS has_sh_cold(player_type *creature_ptr)
399 BIT_FLAGS result = 0L;
401 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
402 result |= FLAG_CAUSE_BATTLE_FORM;
405 if (creature_ptr->ult_res || hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
406 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
409 result |= check_equipment_flags(creature_ptr, TR_SH_COLD);
413 BIT_FLAGS has_easy_spell(player_type *creature_ptr)
415 BIT_FLAGS result = 0L;
416 result |= check_equipment_flags(creature_ptr, TR_EASY_SPELL);
420 BIT_FLAGS has_heavy_spell(player_type *creature_ptr)
422 BIT_FLAGS result = 0L;
423 result |= check_equipment_flags(creature_ptr, TR_HEAVY_SPELL);
427 void has_hold_exp(player_type *creature_ptr)
430 BIT_FLAGS flgs[TR_FLAG_SIZE];
432 creature_ptr->hold_exp = FALSE;
434 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
435 creature_ptr->hold_exp = TRUE;
438 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
439 creature_ptr->hold_exp = TRUE;
442 if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON)
443 || is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
444 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG)
445 || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
446 creature_ptr->hold_exp = TRUE;
449 if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
450 if (creature_ptr->lev > 34)
451 creature_ptr->hold_exp = TRUE;
454 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
455 creature_ptr->hold_exp = TRUE;
458 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
459 o_ptr = &creature_ptr->inventory_list[i];
463 object_flags(creature_ptr, o_ptr, flgs);
464 if (has_flag(flgs, TR_HOLD_EXP))
465 creature_ptr->hold_exp = TRUE;
469 void has_see_inv(player_type *creature_ptr)
472 BIT_FLAGS flgs[TR_FLAG_SIZE];
473 creature_ptr->see_inv = FALSE;
475 if (creature_ptr->pclass == CLASS_NINJA || creature_ptr->lev > 29)
476 creature_ptr->see_inv = TRUE;
478 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
479 creature_ptr->see_inv = TRUE;
482 if (!creature_ptr->mimic_form
483 && (creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
484 || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ARCHON)) {
485 creature_ptr->see_inv = TRUE;
488 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DARK_ELF) {
489 if (creature_ptr->lev > 19)
490 creature_ptr->see_inv = TRUE;
493 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MIND_FLAYER) {
494 if (creature_ptr->lev > 14)
495 creature_ptr->see_inv = TRUE;
498 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
499 if (creature_ptr->lev > 9)
500 creature_ptr->see_inv = TRUE;
503 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
504 creature_ptr->see_inv = TRUE;
507 if (creature_ptr->tim_invis) {
508 creature_ptr->see_inv = TRUE;
511 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
512 o_ptr = &creature_ptr->inventory_list[i];
516 object_flags(creature_ptr, o_ptr, flgs);
517 if (has_flag(flgs, TR_SEE_INVIS))
518 creature_ptr->see_inv = TRUE;
522 BIT_FLAGS has_free_act(player_type *creature_ptr)
524 BIT_FLAGS result = 0L;
526 if (creature_ptr->muta3 & MUT3_MOTION)
527 result |= FLAG_CAUSE_MUTATION;
529 if (is_specific_player_race(creature_ptr, RACE_GNOME) || is_specific_player_race(creature_ptr, RACE_GOLEM)
530 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
531 result |= FLAG_CAUSE_RACE;
534 if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
535 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
536 if (creature_ptr->lev > 24)
537 result |= FLAG_CAUSE_CLASS;
540 if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) {
541 if (!(heavy_armor(creature_ptr))) {
542 if (creature_ptr->lev > 24)
543 result |= FLAG_CAUSE_CLASS;
547 if (creature_ptr->pclass == CLASS_BERSERKER) {
548 result |= FLAG_CAUSE_CLASS;
551 if (creature_ptr->ult_res || creature_ptr->magicdef) {
552 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
555 if (creature_ptr->special_defense & KATA_MUSOU) {
556 result |= FLAG_CAUSE_BATTLE_FORM;
559 result |= check_equipment_flags(creature_ptr, TR_FREE_ACT);
563 BIT_FLAGS has_sustain_str(player_type *creature_ptr)
565 BIT_FLAGS result = 0L;
567 if (creature_ptr->pclass == CLASS_BERSERKER) {
568 result |= FLAG_CAUSE_CLASS;
570 if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) || is_specific_player_race(creature_ptr, RACE_HALF_OGRE)
571 || is_specific_player_race(creature_ptr, RACE_HALF_GIANT)) {
572 result |= FLAG_CAUSE_RACE;
575 if (creature_ptr->ult_res) {
576 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
579 if (creature_ptr->special_defense & KATA_MUSOU) {
580 result |= FLAG_CAUSE_BATTLE_FORM;
583 result |= check_equipment_flags(creature_ptr, TR_SUST_STR);
587 BIT_FLAGS has_sustain_int(player_type *creature_ptr)
589 BIT_FLAGS result = 0L;
591 if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER)) {
592 result |= FLAG_CAUSE_RACE;
595 if (creature_ptr->ult_res) {
596 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
599 if (creature_ptr->special_defense & KATA_MUSOU) {
600 result |= FLAG_CAUSE_BATTLE_FORM;
603 result |= check_equipment_flags(creature_ptr, TR_SUST_INT);
607 BIT_FLAGS has_sustain_wis(player_type *creature_ptr)
609 BIT_FLAGS result = 0L;
612 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
613 result |= FLAG_CAUSE_CLASS;
615 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
616 result |= FLAG_CAUSE_RACE;
619 if (creature_ptr->ult_res) {
620 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
623 if (creature_ptr->special_defense & KATA_MUSOU) {
624 result |= FLAG_CAUSE_BATTLE_FORM;
627 result |= check_equipment_flags(creature_ptr, TR_SUST_WIS);
631 BIT_FLAGS has_sustain_dex(player_type *creature_ptr)
633 BIT_FLAGS result = 0L;
634 if (creature_ptr->pclass == CLASS_BERSERKER) {
635 result |= FLAG_CAUSE_CLASS;
638 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 24)
639 result |= FLAG_CAUSE_CLASS;
641 if (creature_ptr->ult_res) {
642 result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
645 if (creature_ptr->special_defense & KATA_MUSOU) {
646 result |= FLAG_CAUSE_BATTLE_FORM;
649 result |= check_equipment_flags(creature_ptr, TR_SUST_DEX);
653 void has_sustain_con(player_type *creature_ptr)
656 BIT_FLAGS flgs[TR_FLAG_SIZE];
657 creature_ptr->sustain_con = FALSE;
658 if (creature_ptr->pclass == CLASS_BERSERKER) {
659 creature_ptr->sustain_con = TRUE;
662 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
663 creature_ptr->sustain_con = TRUE;
666 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
667 creature_ptr->sustain_con = TRUE;
670 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
671 o_ptr = &creature_ptr->inventory_list[i];
675 object_flags(creature_ptr, o_ptr, flgs);
676 if (has_flag(flgs, TR_SUST_CON))
677 creature_ptr->sustain_con = TRUE;
681 void has_sustain_chr(player_type *creature_ptr)
684 BIT_FLAGS flgs[TR_FLAG_SIZE];
685 creature_ptr->sustain_chr = FALSE;
687 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
688 creature_ptr->sustain_chr = TRUE;
691 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
692 o_ptr = &creature_ptr->inventory_list[i];
696 object_flags(creature_ptr, o_ptr, flgs);
697 if (has_flag(flgs, TR_SUST_CHR))
698 creature_ptr->sustain_chr = TRUE;
702 void has_levitation(player_type *creature_ptr)
705 BIT_FLAGS flgs[TR_FLAG_SIZE];
706 creature_ptr->levitation = FALSE;
708 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
709 creature_ptr->levitation = TRUE;
712 if (creature_ptr->muta3 & MUT3_WINGS)
713 creature_ptr->levitation = TRUE;
715 if (!creature_ptr->mimic_form
716 && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_SPRITE
717 || creature_ptr->prace == RACE_ARCHON || creature_ptr->prace == RACE_S_FAIRY)) {
718 creature_ptr->levitation = TRUE;
721 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU) {
722 creature_ptr->levitation = TRUE;
725 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
726 creature_ptr->levitation = TRUE;
729 if (creature_ptr->magicdef) {
732 if (creature_ptr->riding) {
733 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
734 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
735 creature_ptr->levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
738 if (creature_ptr->tim_levitation) {
739 creature_ptr->levitation = TRUE;
742 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
743 o_ptr = &creature_ptr->inventory_list[i];
746 object_flags(creature_ptr, o_ptr, flgs);
747 if (has_flag(flgs, TR_LEVITATION))
748 creature_ptr->levitation = TRUE;
752 void has_can_swim(player_type *creature_ptr)
754 creature_ptr->can_swim = FALSE;
755 if (creature_ptr->riding) {
756 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
757 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
758 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
759 creature_ptr->can_swim = TRUE;
763 void has_slow_digest(player_type *creature_ptr)
766 BIT_FLAGS flgs[TR_FLAG_SIZE];
767 creature_ptr->slow_digest = FALSE;
769 if (creature_ptr->pclass == CLASS_NINJA) {
770 creature_ptr->slow_digest = TRUE;
773 if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
774 if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
775 creature_ptr->slow_digest = TRUE;
776 /* Let's not make Regeneration
777 * a disadvantage for the poor warriors who can
778 * never learn a spell that satisfies hunger (actually
779 * neither can rogues, but half-trolls are not
780 * supposed to play rogues) */
784 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
785 creature_ptr->slow_digest = TRUE;
788 if (!creature_ptr->mimic_form
789 && (creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE
790 || creature_ptr->prace == RACE_ANDROID)) {
791 creature_ptr->slow_digest = TRUE;
794 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
795 o_ptr = &creature_ptr->inventory_list[i];
798 object_flags(creature_ptr, o_ptr, flgs);
799 if (has_flag(flgs, TR_SLOW_DIGEST))
800 creature_ptr->slow_digest = TRUE;
804 void has_regenerate(player_type *creature_ptr)
807 BIT_FLAGS flgs[TR_FLAG_SIZE];
808 creature_ptr->regenerate = FALSE;
810 if (!creature_ptr->mimic_form) {
811 switch (creature_ptr->prace) {
812 case RACE_HALF_TROLL:
813 if (creature_ptr->lev > 14) {
814 creature_ptr->regenerate = TRUE;
818 creature_ptr->regenerate = TRUE;
823 switch (creature_ptr->pclass) {
825 if (creature_ptr->lev > 44)
826 creature_ptr->regenerate = TRUE;
828 case CLASS_BERSERKER:
829 creature_ptr->regenerate = TRUE;
833 if (creature_ptr->muta3 & MUT3_FLESH_ROT)
834 creature_ptr->regenerate = FALSE;
836 if (creature_ptr->muta3 & MUT3_REGEN)
837 creature_ptr->regenerate = TRUE;
839 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
840 creature_ptr->regenerate = TRUE;
843 if (creature_ptr->realm1 == REALM_HEX) {
844 if (hex_spelling(creature_ptr, HEX_DEMON_AURA)) {
845 creature_ptr->regenerate = TRUE;
849 if (creature_ptr->tim_regen) {
850 creature_ptr->regenerate = TRUE;
853 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
854 o_ptr = &creature_ptr->inventory_list[i];
857 object_flags(creature_ptr, o_ptr, flgs);
858 if (has_flag(flgs, TR_REGEN))
859 creature_ptr->regenerate = TRUE;
863 void has_curses(player_type *creature_ptr)
866 BIT_FLAGS flgs[TR_FLAG_SIZE];
867 creature_ptr->cursed = 0L;
869 if (creature_ptr->pseikaku == PERSONALITY_SEXY)
870 creature_ptr->cursed |= (TRC_AGGRAVATE);
872 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
873 o_ptr = &creature_ptr->inventory_list[i];
876 object_flags(creature_ptr, o_ptr, flgs);
877 if (has_flag(flgs, TR_AGGRAVATE))
878 creature_ptr->cursed |= TRC_AGGRAVATE;
879 if (has_flag(flgs, TR_DRAIN_EXP))
880 creature_ptr->cursed |= TRC_DRAIN_EXP;
881 if (has_flag(flgs, TR_TY_CURSE))
882 creature_ptr->cursed |= TRC_TY_CURSE;
883 if (has_flag(flgs, TR_ADD_L_CURSE))
884 creature_ptr->cursed |= TRC_ADD_L_CURSE;
885 if (has_flag(flgs, TR_ADD_H_CURSE))
886 creature_ptr->cursed |= TRC_ADD_H_CURSE;
887 if (has_flag(flgs, TR_DRAIN_HP))
888 creature_ptr->cursed |= TRC_DRAIN_HP;
889 if (has_flag(flgs, TR_DRAIN_MANA))
890 creature_ptr->cursed |= TRC_DRAIN_MANA;
891 if (has_flag(flgs, TR_CALL_ANIMAL))
892 creature_ptr->cursed |= TRC_CALL_ANIMAL;
893 if (has_flag(flgs, TR_CALL_DEMON))
894 creature_ptr->cursed |= TRC_CALL_DEMON;
895 if (has_flag(flgs, TR_CALL_DRAGON))
896 creature_ptr->cursed |= TRC_CALL_DRAGON;
897 if (has_flag(flgs, TR_CALL_UNDEAD))
898 creature_ptr->cursed |= TRC_CALL_UNDEAD;
899 if (has_flag(flgs, TR_COWARDICE))
900 creature_ptr->cursed |= TRC_COWARDICE;
901 if (has_flag(flgs, TR_LOW_MELEE))
902 creature_ptr->cursed |= TRC_LOW_MELEE;
903 if (has_flag(flgs, TR_LOW_AC))
904 creature_ptr->cursed |= TRC_LOW_AC;
905 if (has_flag(flgs, TR_LOW_MAGIC))
906 creature_ptr->cursed |= TRC_LOW_MAGIC;
907 if (has_flag(flgs, TR_FAST_DIGEST))
908 creature_ptr->cursed |= TRC_FAST_DIGEST;
909 if (has_flag(flgs, TR_SLOW_REGEN))
910 creature_ptr->cursed |= TRC_SLOW_REGEN;
912 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
913 if (o_ptr->name1 == ART_CHAINSWORD)
914 creature_ptr->cursed |= TRC_CHAINSWORD;
916 if (has_flag(flgs, TR_TELEPORT)) {
917 if (object_is_cursed(o_ptr))
918 creature_ptr->cursed |= TRC_TELEPORT;
920 concptr insc = quark_str(o_ptr->inscription);
922 /* {.} will stop random teleportation. */
923 if (o_ptr->inscription && angband_strchr(insc, '.')) {
925 creature_ptr->cursed |= TRC_TELEPORT_SELF;
931 if (creature_ptr->cursed & TRC_TELEPORT)
932 creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
934 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
935 creature_ptr->cursed &= ~(TRC_AGGRAVATE);
939 BIT_FLAGS has_impact(player_type *creature_ptr)
941 BIT_FLAGS result = 0L;
942 result |= check_equipment_flags(creature_ptr, TR_IMPACT);
946 void has_extra_blow(player_type *creature_ptr)
949 BIT_FLAGS flgs[TR_FLAG_SIZE];
950 creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
952 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
953 o_ptr = &creature_ptr->inventory_list[i];
957 object_flags(creature_ptr, o_ptr, flgs);
959 if (has_flag(flgs, TR_INFRA))
960 creature_ptr->see_infra += o_ptr->pval;
961 if (has_flag(flgs, TR_BLOWS)) {
962 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr))
963 creature_ptr->extra_blows[0] += o_ptr->pval;
964 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !has_two_handed_weapons(creature_ptr))
965 creature_ptr->extra_blows[1] += o_ptr->pval;
967 creature_ptr->extra_blows[0] += o_ptr->pval;
968 creature_ptr->extra_blows[1] += o_ptr->pval;
974 void has_resist_acid(player_type *creature_ptr)
977 BIT_FLAGS flgs[TR_FLAG_SIZE];
978 creature_ptr->resist_acid = FALSE;
980 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
981 creature_ptr->resist_acid = TRUE;
984 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_YEEK || creature_ptr->prace == RACE_KLACKON)) {
985 creature_ptr->resist_acid = TRUE;
988 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
989 creature_ptr->resist_acid = TRUE;
992 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
993 creature_ptr->resist_acid = TRUE;
996 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
997 creature_ptr->resist_acid = TRUE;
1000 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1001 o_ptr = &creature_ptr->inventory_list[i];
1005 object_flags(creature_ptr, o_ptr, flgs);
1006 if (has_flag(flgs, TR_RES_ACID))
1007 creature_ptr->resist_acid = TRUE;
1010 if (creature_ptr->immune_acid)
1011 creature_ptr->resist_acid = TRUE;
1014 void has_resist_elec(player_type *creature_ptr)
1017 BIT_FLAGS flgs[TR_FLAG_SIZE];
1018 creature_ptr->resist_elec = FALSE;
1020 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1021 creature_ptr->resist_elec = TRUE;
1024 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 19) {
1025 creature_ptr->resist_elec = TRUE;
1028 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1029 creature_ptr->resist_elec = TRUE;
1032 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1033 creature_ptr->resist_elec = TRUE;
1036 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1037 o_ptr = &creature_ptr->inventory_list[i];
1041 object_flags(creature_ptr, o_ptr, flgs);
1042 if (has_flag(flgs, TR_RES_ELEC))
1043 creature_ptr->resist_elec = TRUE;
1046 if (creature_ptr->immune_elec)
1047 creature_ptr->resist_elec = TRUE;
1050 void has_resist_fire(player_type *creature_ptr)
1053 BIT_FLAGS flgs[TR_FLAG_SIZE];
1054 creature_ptr->resist_fire = FALSE;
1056 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1057 creature_ptr->resist_fire = TRUE;
1060 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 4) {
1061 creature_ptr->resist_fire = TRUE;
1064 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
1065 creature_ptr->resist_fire = TRUE;
1068 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1069 creature_ptr->resist_fire = TRUE;
1072 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1073 creature_ptr->resist_fire = TRUE;
1076 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1077 o_ptr = &creature_ptr->inventory_list[i];
1081 object_flags(creature_ptr, o_ptr, flgs);
1083 if (has_flag(flgs, TR_RES_FIRE))
1084 creature_ptr->resist_fire = TRUE;
1087 if (creature_ptr->immune_fire)
1088 creature_ptr->resist_fire = TRUE;
1091 void has_resist_cold(player_type *creature_ptr)
1094 BIT_FLAGS flgs[TR_FLAG_SIZE];
1095 creature_ptr->resist_cold = FALSE;
1097 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1098 creature_ptr->resist_cold = TRUE;
1101 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ZOMBIE) && creature_ptr->lev > 4) {
1102 creature_ptr->resist_cold = TRUE;
1105 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON) && creature_ptr->lev > 9) {
1106 creature_ptr->resist_cold = TRUE;
1109 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
1110 creature_ptr->resist_fire = TRUE;
1113 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1114 creature_ptr->resist_cold = TRUE;
1117 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1118 creature_ptr->resist_cold = TRUE;
1121 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1122 o_ptr = &creature_ptr->inventory_list[i];
1126 object_flags(creature_ptr, o_ptr, flgs);
1128 if (has_flag(flgs, TR_RES_COLD))
1129 creature_ptr->resist_cold = TRUE;
1132 if (creature_ptr->immune_cold)
1133 creature_ptr->resist_cold = TRUE;
1136 void has_resist_pois(player_type *creature_ptr)
1139 BIT_FLAGS flgs[TR_FLAG_SIZE];
1140 creature_ptr->resist_pois = FALSE;
1142 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
1143 creature_ptr->resist_pois = TRUE;
1145 if (creature_ptr->mimic_form == MIMIC_VAMPIRE || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1146 creature_ptr->resist_pois = TRUE;
1149 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 34) {
1150 creature_ptr->resist_pois = TRUE;
1153 if (!creature_ptr->mimic_form
1154 && (creature_ptr->prace == RACE_KOBOLD || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
1155 || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ANDROID)) {
1156 creature_ptr->resist_pois = TRUE;
1159 if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1160 creature_ptr->resist_pois = TRUE;
1163 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1164 creature_ptr->resist_pois = TRUE;
1167 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1168 o_ptr = &creature_ptr->inventory_list[i];
1172 object_flags(creature_ptr, o_ptr, flgs);
1174 if (has_flag(flgs, TR_RES_POIS))
1175 creature_ptr->resist_pois = TRUE;
1179 void has_resist_conf(player_type *creature_ptr)
1182 BIT_FLAGS flgs[TR_FLAG_SIZE];
1183 creature_ptr->resist_conf = FALSE;
1185 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
1186 creature_ptr->resist_conf = TRUE;
1188 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1189 creature_ptr->resist_conf = TRUE;
1192 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_KLACKON || creature_ptr->prace == RACE_BEASTMAN || creature_ptr->prace == RACE_KUTAR)) {
1193 creature_ptr->resist_conf = TRUE;
1196 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1197 creature_ptr->resist_conf = TRUE;
1200 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1201 creature_ptr->resist_conf = TRUE;
1204 if (creature_ptr->magicdef) {
1205 creature_ptr->resist_conf = TRUE;
1208 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1209 o_ptr = &creature_ptr->inventory_list[i];
1213 object_flags(creature_ptr, o_ptr, flgs);
1215 if (has_flag(flgs, TR_RES_CONF))
1216 creature_ptr->resist_conf = TRUE;
1220 void has_resist_sound(player_type *creature_ptr)
1223 BIT_FLAGS flgs[TR_FLAG_SIZE];
1224 creature_ptr->resist_sound = FALSE;
1226 if (creature_ptr->pclass == CLASS_BARD) {
1227 creature_ptr->resist_sound = TRUE;
1230 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_CYCLOPS || creature_ptr->prace == RACE_BEASTMAN)) {
1231 creature_ptr->resist_sound = TRUE;
1234 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1235 creature_ptr->resist_sound = TRUE;
1238 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1239 o_ptr = &creature_ptr->inventory_list[i];
1243 object_flags(creature_ptr, o_ptr, flgs);
1245 if (has_flag(flgs, TR_RES_SOUND))
1246 creature_ptr->resist_sound = TRUE;
1250 void has_resist_lite(player_type *creature_ptr)
1253 BIT_FLAGS flgs[TR_FLAG_SIZE];
1254 creature_ptr->resist_lite = FALSE;
1256 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ELF || creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_SPRITE)) {
1257 creature_ptr->resist_lite = TRUE;
1260 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1261 creature_ptr->resist_lite = TRUE;
1264 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1265 o_ptr = &creature_ptr->inventory_list[i];
1269 object_flags(creature_ptr, o_ptr, flgs);
1271 if (has_flag(flgs, TR_RES_LITE))
1272 creature_ptr->resist_lite = TRUE;
1276 void has_resist_dark(player_type *creature_ptr)
1279 BIT_FLAGS flgs[TR_FLAG_SIZE];
1280 creature_ptr->resist_dark = FALSE;
1282 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1283 creature_ptr->resist_dark = TRUE;
1286 if (!creature_ptr->mimic_form
1287 && (creature_ptr->prace == RACE_HALF_ORC || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_NIBELUNG
1288 || creature_ptr->prace == RACE_DARK_ELF || creature_ptr->prace == RACE_VAMPIRE)) {
1289 creature_ptr->resist_lite = TRUE;
1292 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1293 creature_ptr->resist_dark = TRUE;
1296 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1297 o_ptr = &creature_ptr->inventory_list[i];
1301 object_flags(creature_ptr, o_ptr, flgs);
1303 if (has_flag(flgs, TR_RES_DARK))
1304 creature_ptr->resist_dark = TRUE;
1308 void has_resist_chaos(player_type *creature_ptr)
1311 BIT_FLAGS flgs[TR_FLAG_SIZE];
1312 creature_ptr->resist_chaos = FALSE;
1314 if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
1315 creature_ptr->resist_chaos = TRUE;
1317 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1318 creature_ptr->resist_chaos = TRUE;
1321 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
1322 creature_ptr->resist_chaos = TRUE;
1324 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1325 creature_ptr->resist_chaos = TRUE;
1328 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1329 o_ptr = &creature_ptr->inventory_list[i];
1333 object_flags(creature_ptr, o_ptr, flgs);
1335 if (has_flag(flgs, TR_RES_CHAOS))
1336 creature_ptr->resist_chaos = TRUE;
1340 void has_resist_disen(player_type *creature_ptr)
1343 BIT_FLAGS flgs[TR_FLAG_SIZE];
1344 creature_ptr->resist_disen = FALSE;
1346 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1347 creature_ptr->resist_disen = TRUE;
1350 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_NIBELUNG)
1351 creature_ptr->resist_disen = TRUE;
1353 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1354 creature_ptr->resist_disen = TRUE;
1357 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1358 o_ptr = &creature_ptr->inventory_list[i];
1362 object_flags(creature_ptr, o_ptr, flgs);
1364 if (has_flag(flgs, TR_RES_DISEN))
1365 creature_ptr->resist_disen = TRUE;
1369 void has_resist_shard(player_type *creature_ptr)
1372 BIT_FLAGS flgs[TR_FLAG_SIZE];
1373 creature_ptr->resist_shard = FALSE;
1375 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_HALF_TITAN || creature_ptr->prace == RACE_SKELETON))
1376 creature_ptr->resist_shard = TRUE;
1378 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1379 creature_ptr->resist_shard = TRUE;
1382 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1383 o_ptr = &creature_ptr->inventory_list[i];
1387 object_flags(creature_ptr, o_ptr, flgs);
1389 if (has_flag(flgs, TR_RES_DISEN))
1390 creature_ptr->resist_shard = TRUE;
1394 void has_resist_nexus(player_type *creature_ptr)
1397 BIT_FLAGS flgs[TR_FLAG_SIZE];
1398 creature_ptr->resist_nexus = FALSE;
1400 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1401 creature_ptr->resist_nexus = TRUE;
1404 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1405 creature_ptr->resist_nexus = TRUE;
1408 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1409 o_ptr = &creature_ptr->inventory_list[i];
1413 object_flags(creature_ptr, o_ptr, flgs);
1415 if (has_flag(flgs, TR_RES_NEXUS))
1416 creature_ptr->resist_nexus = TRUE;
1420 void has_resist_blind(player_type *creature_ptr)
1423 BIT_FLAGS flgs[TR_FLAG_SIZE];
1424 creature_ptr->resist_blind = FALSE;
1426 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1427 creature_ptr->resist_blind = TRUE;
1430 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DWARF)
1431 creature_ptr->resist_blind = TRUE;
1433 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1434 creature_ptr->resist_blind = TRUE;
1437 if (creature_ptr->magicdef) {
1438 creature_ptr->resist_blind = TRUE;
1441 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1442 o_ptr = &creature_ptr->inventory_list[i];
1446 object_flags(creature_ptr, o_ptr, flgs);
1448 if (has_flag(flgs, TR_RES_BLIND))
1449 creature_ptr->resist_blind = TRUE;
1453 void has_resist_neth(player_type *creature_ptr)
1456 BIT_FLAGS flgs[TR_FLAG_SIZE];
1458 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1459 creature_ptr->resist_neth = TRUE;
1462 if (!creature_ptr->mimic_form
1463 && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE
1464 || creature_ptr->prace == RACE_BALROG))
1465 creature_ptr->resist_neth = TRUE;
1467 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1468 creature_ptr->resist_neth = TRUE;
1471 if (creature_ptr->tim_res_nether) {
1472 creature_ptr->resist_neth = TRUE;
1475 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1476 o_ptr = &creature_ptr->inventory_list[i];
1480 object_flags(creature_ptr, o_ptr, flgs);
1482 if (has_flag(flgs, TR_RES_NETHER))
1483 creature_ptr->resist_neth = TRUE;
1487 void has_resist_time(player_type *creature_ptr)
1490 BIT_FLAGS flgs[TR_FLAG_SIZE];
1491 creature_ptr->resist_time = FALSE;
1493 if (creature_ptr->tim_res_time) {
1494 creature_ptr->resist_time = TRUE;
1497 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1498 o_ptr = &creature_ptr->inventory_list[i];
1502 object_flags(creature_ptr, o_ptr, flgs);
1503 if (o_ptr->name2 == EGO_RING_RES_TIME)
1504 creature_ptr->resist_time = TRUE;
1508 void has_resist_water(player_type *creature_ptr)
1510 creature_ptr->resist_water = FALSE;
1512 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
1513 creature_ptr->resist_water = TRUE;
1516 void has_resist_fear(player_type *creature_ptr)
1519 BIT_FLAGS flgs[TR_FLAG_SIZE];
1520 creature_ptr->resist_fear = FALSE;
1522 if (creature_ptr->muta3 & MUT3_FEARLESS)
1523 creature_ptr->resist_fear = TRUE;
1525 switch (creature_ptr->pclass) {
1527 if (creature_ptr->lev > 29)
1528 creature_ptr->resist_fear = TRUE;
1531 if (creature_ptr->lev > 39)
1532 creature_ptr->resist_fear = TRUE;
1534 case CLASS_CHAOS_WARRIOR:
1535 if (creature_ptr->lev > 39)
1536 creature_ptr->resist_fear = TRUE;
1538 case CLASS_MINDCRAFTER:
1539 if (creature_ptr->lev > 9)
1540 creature_ptr->resist_fear = TRUE;
1543 if (creature_ptr->lev > 29)
1544 creature_ptr->resist_fear = TRUE;
1547 creature_ptr->resist_fear = TRUE;
1551 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1552 creature_ptr->resist_fear = TRUE;
1555 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
1556 creature_ptr->resist_fear = TRUE;
1558 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1559 creature_ptr->resist_fear = TRUE;
1562 if (is_hero(creature_ptr) || creature_ptr->shero) {
1563 creature_ptr->resist_fear = TRUE;
1566 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1567 o_ptr = &creature_ptr->inventory_list[i];
1571 object_flags(creature_ptr, o_ptr, flgs);
1572 if (has_flag(flgs, TR_RES_FEAR))
1573 creature_ptr->resist_fear = TRUE;
1577 void has_immune_acid(player_type *creature_ptr)
1580 BIT_FLAGS flgs[TR_FLAG_SIZE];
1581 creature_ptr->immune_acid = FALSE;
1583 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_YEEK && creature_ptr->lev > 19)
1584 creature_ptr->immune_acid = TRUE;
1586 if (creature_ptr->ele_immune) {
1587 if (creature_ptr->special_defense & DEFENSE_ACID)
1588 creature_ptr->immune_acid = 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_ACID))
1598 creature_ptr->immune_acid = TRUE;
1602 void has_immune_elec(player_type *creature_ptr)
1605 BIT_FLAGS flgs[TR_FLAG_SIZE];
1606 creature_ptr->immune_elec = FALSE;
1607 if (creature_ptr->ele_immune) {
1608 if (creature_ptr->special_defense & DEFENSE_ELEC)
1609 creature_ptr->immune_elec = 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_ELEC))
1619 creature_ptr->immune_elec = TRUE;
1623 void has_immune_fire(player_type *creature_ptr)
1626 BIT_FLAGS flgs[TR_FLAG_SIZE];
1627 creature_ptr->immune_fire = FALSE;
1628 if (creature_ptr->ele_immune) {
1629 if (creature_ptr->special_defense & DEFENSE_FIRE)
1630 creature_ptr->immune_fire = TRUE;
1633 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1634 o_ptr = &creature_ptr->inventory_list[i];
1638 object_flags(creature_ptr, o_ptr, flgs);
1639 if (has_flag(flgs, TR_IM_FIRE))
1640 creature_ptr->immune_fire = TRUE;
1644 void has_immune_cold(player_type *creature_ptr)
1647 BIT_FLAGS flgs[TR_FLAG_SIZE];
1648 creature_ptr->immune_cold = FALSE;
1649 if (creature_ptr->ele_immune) {
1650 if (creature_ptr->special_defense & DEFENSE_COLD)
1651 creature_ptr->immune_cold = TRUE;
1654 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1655 o_ptr = &creature_ptr->inventory_list[i];
1659 object_flags(creature_ptr, o_ptr, flgs);
1660 if (has_flag(flgs, TR_IM_COLD))
1661 creature_ptr->immune_cold = TRUE;
1665 bool has_right_hand_weapon(player_type *creature_ptr)
1667 if (has_melee_weapon(creature_ptr, INVEN_RARM))
1670 if (can_two_hands_wielding(creature_ptr)) {
1671 switch (creature_ptr->pclass) {
1673 case CLASS_FORCETRAINER:
1674 case CLASS_BERSERKER:
1675 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
1685 bool has_left_hand_weapon(player_type *creature_ptr) { return has_melee_weapon(creature_ptr, INVEN_LARM); }
1687 bool has_two_handed_weapons(player_type *creature_ptr)
1689 if (can_two_hands_wielding(creature_ptr)) {
1690 if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
1691 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
1693 } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
1694 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
1701 void has_lite(player_type *creature_ptr)
1703 creature_ptr->lite = FALSE;
1704 if (creature_ptr->pclass == CLASS_NINJA)
1707 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1708 creature_ptr->lite = TRUE;
1711 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1712 creature_ptr->lite = TRUE;
1715 if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
1716 creature_ptr->lite = TRUE;
1719 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
1720 creature_ptr->lite = TRUE;
1722 if (creature_ptr->sh_fire)
1723 creature_ptr->lite = TRUE;
1725 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1726 creature_ptr->lite = TRUE;
1730 bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
1733 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1734 if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1735 if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && has_two_handed_weapons(creature_ptr)
1736 && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
1742 bool is_icky_wield_weapon(player_type *creature_ptr, int i)
1745 BIT_FLAGS flgs[TR_FLAG_SIZE];
1746 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1747 object_flags(creature_ptr, o_ptr, flgs);
1749 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1751 } else if (creature_ptr->pclass == CLASS_SORCERER) {
1752 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
1756 if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
1762 bool is_riding_wield_weapon(player_type *creature_ptr, int i)
1765 BIT_FLAGS flgs[TR_FLAG_SIZE];
1766 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1767 object_flags(creature_ptr, o_ptr, flgs);
1768 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
1769 && !has_flag(flgs, TR_RIDING)) {
1775 bool is_not_ninja_weapon(player_type *creature_ptr, int i)
1777 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1778 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1779 return creature_ptr->pclass == CLASS_NINJA
1780 && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
1783 bool is_not_monk_weapon(player_type *creature_ptr, int i)
1785 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1786 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1787 return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
1790 bool has_good_luck(player_type *creature_ptr) { return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta3 |= MUT3_GOOD_LUCK); };