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 is_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 is_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 is_xtra_might(player_type *creature_ptr)
89 BIT_FLAGS result = 0L;
90 result |= check_equipment_flags(creature_ptr, TR_XTRA_MIGHT);
94 BIT_FLAGS is_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 is_esp_animal(player_type *creature_ptr)
107 BIT_FLAGS result = 0L;
108 result |= check_equipment_flags(creature_ptr, TR_ESP_ANIMAL);
112 BIT_FLAGS is_esp_undead(player_type *creature_ptr)
114 BIT_FLAGS result = 0L;
115 result |= check_equipment_flags(creature_ptr, TR_ESP_UNDEAD);
119 BIT_FLAGS is_esp_demon(player_type *creature_ptr)
121 BIT_FLAGS result = 0L;
122 result |= check_equipment_flags(creature_ptr, TR_ESP_DEMON);
126 BIT_FLAGS is_esp_orc(player_type *creature_ptr)
128 BIT_FLAGS result = 0L;
129 result |= check_equipment_flags(creature_ptr, TR_ESP_ORC);
133 BIT_FLAGS is_esp_troll(player_type *creature_ptr)
135 BIT_FLAGS result = 0L;
136 result |= check_equipment_flags(creature_ptr, TR_ESP_TROLL);
140 BIT_FLAGS is_esp_giant(player_type *creature_ptr)
142 BIT_FLAGS result = 0L;
143 result |= check_equipment_flags(creature_ptr, TR_ESP_GIANT);
147 BIT_FLAGS is_esp_dragon(player_type *creature_ptr)
149 BIT_FLAGS result = 0L;
150 result |= check_equipment_flags(creature_ptr, TR_ESP_DRAGON);
154 BIT_FLAGS is_esp_human(player_type *creature_ptr)
156 BIT_FLAGS result = 0L;
157 result |= check_equipment_flags(creature_ptr, TR_ESP_HUMAN);
161 BIT_FLAGS is_esp_good(player_type *creature_ptr)
163 BIT_FLAGS result = 0L;
164 result |= check_equipment_flags(creature_ptr, TR_ESP_GOOD);
168 BIT_FLAGS is_esp_nonliving(player_type *creature_ptr)
170 BIT_FLAGS result = 0L;
171 result |= check_equipment_flags(creature_ptr, TR_ESP_GOOD);
175 BIT_FLAGS is_esp_unique(player_type *creature_ptr)
177 BIT_FLAGS result = 0L;
178 result |= check_equipment_flags(creature_ptr, TR_ESP_UNIQUE);
182 BIT_FLAGS is_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 |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
190 if (creature_ptr->muta3 & MUT3_ESP) {
191 result |= 0x01 << FLAG_CAUSE_MUTATION;
194 if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER) && creature_ptr->lev > 29)
195 result |= 0x01 << FLAG_CAUSE_RACE;
197 if (is_specific_player_race(creature_ptr, RACE_SPECTRE) && creature_ptr->lev > 34)
198 result |= 0x01 << FLAG_CAUSE_RACE;
200 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 39)
201 result |= 0x01 << FLAG_CAUSE_CLASS;
203 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
204 result |= 0x01 << 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 BIT_FLAGS has_invuln_arrow(player_type *creature_ptr)
241 BIT_FLAGS result = 0L;
242 if (creature_ptr->blind)
244 result |= check_equipment_flags(creature_ptr, TR_INVULN_ARROW);
248 void has_no_flowed(player_type *creature_ptr)
251 bool has_sw = FALSE, has_kabe = FALSE;
252 OBJECT_IDX this_o_idx, next_o_idx = 0;
254 creature_ptr->no_flowed = FALSE;
256 if (creature_ptr->pass_wall && !creature_ptr->kill_wall)
257 creature_ptr->no_flowed = TRUE;
259 for (int i = 0; i < INVEN_PACK; i++) {
260 if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
262 if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
266 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) {
267 o_ptr = &creature_ptr->current_floor_ptr->o_list[this_o_idx];
268 next_o_idx = o_ptr->next_o_idx;
270 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2))
272 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2))
276 if (has_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER))) {
277 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
278 if (creature_ptr->lev >= s_ptr->slevel)
279 creature_ptr->no_flowed = TRUE;
282 if (has_kabe && ((creature_ptr->realm1 == REALM_CRAFT) || (creature_ptr->realm2 == REALM_CRAFT) || (creature_ptr->pclass == CLASS_SORCERER))) {
283 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_WALL];
284 if (creature_ptr->lev >= s_ptr->slevel)
285 creature_ptr->no_flowed = TRUE;
289 BIT_FLAGS has_mighty_throw(player_type *creature_ptr)
291 BIT_FLAGS result = 0L;
292 result |= check_equipment_flags(creature_ptr, TR_MIGHTY_THROW);
296 BIT_FLAGS has_dec_mana(player_type *creature_ptr)
298 BIT_FLAGS result = 0L;
299 result |= check_equipment_flags(creature_ptr, TR_DEC_MANA);
303 BIT_FLAGS has_reflect(player_type *creature_ptr)
305 BIT_FLAGS result = 0L;
307 if (creature_ptr->pclass == CLASS_BERSERKER && creature_ptr->lev > 39)
308 result |= 0x01 << FLAG_CAUSE_CLASS;
310 if (creature_ptr->pclass == CLASS_MIRROR_MASTER && creature_ptr->lev > 39)
311 result |= 0x01 << FLAG_CAUSE_CLASS;
313 if (creature_ptr->special_defense & KAMAE_GENBU || creature_ptr->special_defense & KATA_MUSOU) {
314 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
317 if (creature_ptr->ult_res || creature_ptr->wraith_form || creature_ptr->magicdef || creature_ptr->tim_reflect) {
318 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
321 result |= check_equipment_flags(creature_ptr, TR_REFLECT);
325 BIT_FLAGS has_see_nocto(player_type *creature_ptr) { return creature_ptr->pclass == CLASS_NINJA ? FLAG_CAUSE_CLASS : 0L; }
327 BIT_FLAGS has_warning(player_type *creature_ptr)
329 BIT_FLAGS result = 0L;
331 BIT_FLAGS flgs[TR_FLAG_SIZE];
333 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
334 o_ptr = &creature_ptr->inventory_list[i];
338 object_flags(creature_ptr, o_ptr, flgs);
340 if (has_flag(flgs, TR_WARNING)) {
341 if (!o_ptr->inscription || !(angband_strchr(quark_str(o_ptr->inscription), '$')))
342 result |= 0x01 << (i - INVEN_RARM);
348 BIT_FLAGS has_anti_magic(player_type *creature_ptr)
350 BIT_FLAGS result = 0L;
351 result |= check_equipment_flags(creature_ptr, TR_NO_MAGIC);
355 BIT_FLAGS has_anti_tele(player_type *creature_ptr)
357 BIT_FLAGS result = 0L;
358 result |= check_equipment_flags(creature_ptr, TR_NO_TELE);
362 BIT_FLAGS has_sh_fire(player_type *creature_ptr)
364 BIT_FLAGS result = 0L;
366 if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
367 result |= 0x01 << FLAG_CAUSE_MUTATION;
370 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
371 result |= 0x01 << FLAG_CAUSE_RACE;
374 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
375 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
378 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_sh_fire) {
379 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
382 result |= check_equipment_flags(creature_ptr, TR_SH_FIRE);
386 BIT_FLAGS has_sh_elec(player_type *creature_ptr)
388 BIT_FLAGS result = 0L;
390 if (creature_ptr->muta3 & MUT3_ELEC_TOUC)
391 result |= 0x01 << FLAG_CAUSE_MUTATION;
393 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK) || creature_ptr->ult_res) {
394 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
397 if (creature_ptr->special_defense & KAMAE_SEIRYU || (creature_ptr->special_defense & KATA_MUSOU)) {
398 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
401 result |= check_equipment_flags(creature_ptr, TR_SH_ELEC);
405 BIT_FLAGS has_sh_cold(player_type *creature_ptr)
407 BIT_FLAGS result = 0L;
409 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
410 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
413 if (creature_ptr->ult_res || hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
414 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
417 result |= check_equipment_flags(creature_ptr, TR_SH_COLD);
421 BIT_FLAGS has_easy_spell(player_type *creature_ptr)
423 BIT_FLAGS result = 0L;
424 result |= check_equipment_flags(creature_ptr, TR_EASY_SPELL);
428 BIT_FLAGS has_heavy_spell(player_type *creature_ptr)
430 BIT_FLAGS result = 0L;
431 result |= check_equipment_flags(creature_ptr, TR_HEAVY_SPELL);
435 BIT_FLAGS has_hold_exp(player_type *creature_ptr)
437 BIT_FLAGS result = 0L;
439 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
440 result |= 0x01 << FLAG_CAUSE_PERSONALITY;
443 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
444 result |= 0x01 << FLAG_CAUSE_RACE;
447 if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON)
448 || is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
449 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG)
450 || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
451 result |= 0x01 << FLAG_CAUSE_RACE;
454 if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
455 if (creature_ptr->lev > 34)
456 result |= 0x01 << FLAG_CAUSE_RACE;
459 if (creature_ptr->special_defense & KATA_MUSOU) {
460 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
463 if (creature_ptr->ult_res) {
464 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
467 result |= check_equipment_flags(creature_ptr, TR_HOLD_EXP);
471 BIT_FLAGS has_see_inv(player_type *creature_ptr)
473 BIT_FLAGS result = 0L;
475 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 29)
476 result |= 0x01 << FLAG_CAUSE_CLASS;
478 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
479 result |= 0x01 << FLAG_CAUSE_RACE;
480 } else if (is_specific_player_race(creature_ptr, RACE_HIGH_ELF) || is_specific_player_race(creature_ptr, RACE_GOLEM)
481 || is_specific_player_race(creature_ptr, RACE_SKELETON) || is_specific_player_race(creature_ptr, RACE_ZOMBIE)
482 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_ARCHON)) {
483 result |= 0x01 << FLAG_CAUSE_RACE;
484 } else if (is_specific_player_race(creature_ptr, RACE_DARK_ELF) && creature_ptr->lev > 19) {
485 result |= 0x01 << FLAG_CAUSE_RACE;
486 } else if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER) && creature_ptr->lev > 14) {
487 result |= 0x01 << FLAG_CAUSE_RACE;
488 } else if ((is_specific_player_race(creature_ptr, RACE_IMP) || is_specific_player_race(creature_ptr, RACE_BALROG)) && creature_ptr->lev > 9) {
489 result |= 0x01 << FLAG_CAUSE_RACE;
492 if (creature_ptr->special_defense & KATA_MUSOU) {
493 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
496 if (creature_ptr->ult_res || creature_ptr->tim_invis) {
497 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
500 result |= check_equipment_flags(creature_ptr, TR_SEE_INVIS);
504 BIT_FLAGS has_magic_mastery(player_type *creature_ptr)
506 BIT_FLAGS result = 0L;
508 result |= check_equipment_flags(creature_ptr, TR_MAGIC_MASTERY);
512 BIT_FLAGS has_free_act(player_type *creature_ptr)
514 BIT_FLAGS result = 0L;
516 if (creature_ptr->muta3 & MUT3_MOTION)
517 result |= 0x01 << FLAG_CAUSE_MUTATION;
519 if (is_specific_player_race(creature_ptr, RACE_GNOME) || is_specific_player_race(creature_ptr, RACE_GOLEM)
520 || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
521 result |= 0x01 << FLAG_CAUSE_RACE;
524 if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
525 && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
526 if (creature_ptr->lev > 24)
527 result |= 0x01 << FLAG_CAUSE_CLASS;
530 if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) {
531 if (!(heavy_armor(creature_ptr))) {
532 if (creature_ptr->lev > 24)
533 result |= 0x01 << FLAG_CAUSE_CLASS;
537 if (creature_ptr->pclass == CLASS_BERSERKER) {
538 result |= 0x01 << FLAG_CAUSE_CLASS;
541 if (creature_ptr->ult_res || creature_ptr->magicdef) {
542 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
545 if (creature_ptr->special_defense & KATA_MUSOU) {
546 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
549 result |= check_equipment_flags(creature_ptr, TR_FREE_ACT);
553 BIT_FLAGS is_sustain_str(player_type *creature_ptr)
555 BIT_FLAGS result = 0L;
557 if (creature_ptr->pclass == CLASS_BERSERKER) {
558 result |= 0x01 << FLAG_CAUSE_CLASS;
560 if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) || is_specific_player_race(creature_ptr, RACE_HALF_OGRE)
561 || is_specific_player_race(creature_ptr, RACE_HALF_GIANT)) {
562 result |= 0x01 << FLAG_CAUSE_RACE;
565 if (creature_ptr->ult_res) {
566 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
569 if (creature_ptr->special_defense & KATA_MUSOU) {
570 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
573 result |= check_equipment_flags(creature_ptr, TR_SUST_STR);
577 BIT_FLAGS is_sustain_int(player_type *creature_ptr)
579 BIT_FLAGS result = 0L;
581 if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER)) {
582 result |= 0x01 << FLAG_CAUSE_RACE;
585 if (creature_ptr->ult_res) {
586 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
589 if (creature_ptr->special_defense & KATA_MUSOU) {
590 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
593 result |= check_equipment_flags(creature_ptr, TR_SUST_INT);
597 BIT_FLAGS is_sustain_wis(player_type *creature_ptr)
599 BIT_FLAGS result = 0L;
602 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
603 result |= 0x01 << FLAG_CAUSE_CLASS;
605 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
606 result |= 0x01 << FLAG_CAUSE_RACE;
609 if (creature_ptr->ult_res) {
610 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
613 if (creature_ptr->special_defense & KATA_MUSOU) {
614 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
617 result |= check_equipment_flags(creature_ptr, TR_SUST_WIS);
621 BIT_FLAGS is_sustain_dex(player_type *creature_ptr)
623 BIT_FLAGS result = 0L;
624 if (creature_ptr->pclass == CLASS_BERSERKER) {
625 result |= 0x01 << FLAG_CAUSE_CLASS;
628 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 24)
629 result |= 0x01 << FLAG_CAUSE_CLASS;
631 if (creature_ptr->ult_res) {
632 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
635 if (creature_ptr->special_defense & KATA_MUSOU) {
636 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
639 result |= check_equipment_flags(creature_ptr, TR_SUST_DEX);
643 BIT_FLAGS is_sustain_con(player_type *creature_ptr)
645 BIT_FLAGS result = 0L;
646 if (creature_ptr->pclass == CLASS_BERSERKER) {
647 result |= 0x01 << FLAG_CAUSE_CLASS;
650 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
651 result |= 0x01 << FLAG_CAUSE_RACE;
654 if (creature_ptr->ult_res) {
655 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
658 if (creature_ptr->special_defense & KATA_MUSOU) {
659 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
662 result |= check_equipment_flags(creature_ptr, TR_SUST_CON);
666 BIT_FLAGS is_sustain_chr(player_type *creature_ptr)
668 BIT_FLAGS result = 0L;
670 if (creature_ptr->ult_res) {
671 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
674 if (creature_ptr->special_defense & KATA_MUSOU) {
675 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
678 result |= check_equipment_flags(creature_ptr, TR_SUST_CHR);
682 BIT_FLAGS has_levitation(player_type *creature_ptr)
684 BIT_FLAGS result = 0L;
686 if (creature_ptr->muta3 & MUT3_WINGS)
687 result = FLAG_CAUSE_MUTATION;
689 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
690 result = FLAG_CAUSE_RACE;
693 if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) || is_specific_player_race(creature_ptr, RACE_SPECTRE)
694 || is_specific_player_race(creature_ptr, RACE_SPRITE) || is_specific_player_race(creature_ptr, RACE_ARCHON)
695 || is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
696 result = FLAG_CAUSE_RACE;
699 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU || (creature_ptr->special_defense & KATA_MUSOU)) {
700 result = FLAG_CAUSE_BATTLE_FORM;
703 if (creature_ptr->ult_res) {
704 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
707 if (creature_ptr->riding) {
708 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
709 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
710 result = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? result : 0;
713 if (creature_ptr->tim_levitation) {
714 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
717 result |= check_equipment_flags(creature_ptr, TR_LEVITATION);
721 void has_can_swim(player_type *creature_ptr)
723 creature_ptr->can_swim = FALSE;
724 if (creature_ptr->riding) {
725 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
726 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
727 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
728 creature_ptr->can_swim = TRUE;
732 BIT_FLAGS has_slow_digest(player_type *creature_ptr)
734 BIT_FLAGS result = 0L;
736 if (creature_ptr->pclass == CLASS_NINJA) {
737 result = FLAG_CAUSE_CLASS;
740 if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
741 if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
742 result = FLAG_CAUSE_CLASS;
743 /* Let's not make Regeneration
744 * a disadvantage for the poor warriors who can
745 * never learn a spell that satisfies hunger (actually
746 * neither can rogues, but half-trolls are not
747 * supposed to play rogues) */
751 if (creature_ptr->special_defense & KATA_MUSOU) {
752 result = FLAG_CAUSE_BATTLE_FORM;
755 if (creature_ptr->ult_res) {
756 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
759 if (!creature_ptr->mimic_form
760 && (creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE
761 || creature_ptr->prace == RACE_ANDROID)) {
762 result = FLAG_CAUSE_RACE;
765 result |= check_equipment_flags(creature_ptr, TR_SLOW_DIGEST);
769 BIT_FLAGS has_regenerate(player_type *creature_ptr)
771 BIT_FLAGS result = 0L;
773 if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) && creature_ptr->lev > 14) {
774 result |= 0x01 << FLAG_CAUSE_RACE;
777 if (is_specific_player_race(creature_ptr, RACE_AMBERITE)) {
778 result |= 0x01 << FLAG_CAUSE_RACE;
781 if (creature_ptr->pclass == CLASS_WARRIOR && creature_ptr->lev > 44) {
782 result |= 0x01 << FLAG_CAUSE_RACE;
785 if (creature_ptr->pclass == CLASS_BERSERKER) {
786 result |= 0x01 << FLAG_CAUSE_RACE;
789 if (creature_ptr->muta3 & MUT3_REGEN)
790 result |= 0x01 << FLAG_CAUSE_MUTATION;
792 if (creature_ptr->special_defense & KATA_MUSOU) {
793 result |= 0x01 << FLAG_CAUSE_MUTATION;
796 if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_regen) {
797 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
800 result |= check_equipment_flags(creature_ptr, TR_REGEN);
802 if (creature_ptr->muta3 & MUT3_FLESH_ROT)
808 void has_curses(player_type *creature_ptr)
811 BIT_FLAGS flgs[TR_FLAG_SIZE];
812 creature_ptr->cursed = 0L;
814 if (creature_ptr->pseikaku == PERSONALITY_SEXY)
815 creature_ptr->cursed |= (TRC_AGGRAVATE);
817 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
818 o_ptr = &creature_ptr->inventory_list[i];
821 object_flags(creature_ptr, o_ptr, flgs);
822 if (has_flag(flgs, TR_AGGRAVATE))
823 creature_ptr->cursed |= TRC_AGGRAVATE;
824 if (has_flag(flgs, TR_DRAIN_EXP))
825 creature_ptr->cursed |= TRC_DRAIN_EXP;
826 if (has_flag(flgs, TR_TY_CURSE))
827 creature_ptr->cursed |= TRC_TY_CURSE;
828 if (has_flag(flgs, TR_ADD_L_CURSE))
829 creature_ptr->cursed |= TRC_ADD_L_CURSE;
830 if (has_flag(flgs, TR_ADD_H_CURSE))
831 creature_ptr->cursed |= TRC_ADD_H_CURSE;
832 if (has_flag(flgs, TR_DRAIN_HP))
833 creature_ptr->cursed |= TRC_DRAIN_HP;
834 if (has_flag(flgs, TR_DRAIN_MANA))
835 creature_ptr->cursed |= TRC_DRAIN_MANA;
836 if (has_flag(flgs, TR_CALL_ANIMAL))
837 creature_ptr->cursed |= TRC_CALL_ANIMAL;
838 if (has_flag(flgs, TR_CALL_DEMON))
839 creature_ptr->cursed |= TRC_CALL_DEMON;
840 if (has_flag(flgs, TR_CALL_DRAGON))
841 creature_ptr->cursed |= TRC_CALL_DRAGON;
842 if (has_flag(flgs, TR_CALL_UNDEAD))
843 creature_ptr->cursed |= TRC_CALL_UNDEAD;
844 if (has_flag(flgs, TR_COWARDICE))
845 creature_ptr->cursed |= TRC_COWARDICE;
846 if (has_flag(flgs, TR_LOW_MELEE))
847 creature_ptr->cursed |= TRC_LOW_MELEE;
848 if (has_flag(flgs, TR_LOW_AC))
849 creature_ptr->cursed |= TRC_LOW_AC;
850 if (has_flag(flgs, TR_LOW_MAGIC))
851 creature_ptr->cursed |= TRC_LOW_MAGIC;
852 if (has_flag(flgs, TR_FAST_DIGEST))
853 creature_ptr->cursed |= TRC_FAST_DIGEST;
854 if (has_flag(flgs, TR_SLOW_REGEN))
855 creature_ptr->cursed |= TRC_SLOW_REGEN;
857 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
858 if (o_ptr->name1 == ART_CHAINSWORD)
859 creature_ptr->cursed |= TRC_CHAINSWORD;
861 if (has_flag(flgs, TR_TELEPORT)) {
862 if (object_is_cursed(o_ptr))
863 creature_ptr->cursed |= TRC_TELEPORT;
865 concptr insc = quark_str(o_ptr->inscription);
867 /* {.} will stop random teleportation. */
868 if (o_ptr->inscription && angband_strchr(insc, '.')) {
870 creature_ptr->cursed |= TRC_TELEPORT_SELF;
876 if (creature_ptr->cursed & TRC_TELEPORT)
877 creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
879 if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
880 creature_ptr->cursed &= ~(TRC_AGGRAVATE);
884 BIT_FLAGS has_impact(player_type *creature_ptr)
886 BIT_FLAGS result = 0L;
887 result |= check_equipment_flags(creature_ptr, TR_IMPACT);
891 void has_extra_blow(player_type *creature_ptr)
894 BIT_FLAGS flgs[TR_FLAG_SIZE];
895 creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
897 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
898 o_ptr = &creature_ptr->inventory_list[i];
902 object_flags(creature_ptr, o_ptr, flgs);
903 if (has_flag(flgs, TR_BLOWS)) {
904 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr))
905 creature_ptr->extra_blows[0] += o_ptr->pval;
906 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !has_two_handed_weapons(creature_ptr))
907 creature_ptr->extra_blows[1] += o_ptr->pval;
909 creature_ptr->extra_blows[0] += o_ptr->pval;
910 creature_ptr->extra_blows[1] += o_ptr->pval;
916 BIT_FLAGS is_resist_acid(player_type *creature_ptr)
918 BIT_FLAGS result = 0L;
920 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
921 result |= 0x01 << FLAG_CAUSE_RACE;
922 } else if (is_specific_player_race(creature_ptr, RACE_YEEK) || is_specific_player_race(creature_ptr, RACE_KLACKON)) {
923 result |= 0x01 << FLAG_CAUSE_RACE;
924 } else if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) && creature_ptr->lev > 14) {
925 result |= 0x01 << FLAG_CAUSE_RACE;
928 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
929 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
932 if (creature_ptr->ult_res) {
933 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
936 result |= is_immune_acid(creature_ptr);
938 result |= check_equipment_flags(creature_ptr, TR_RES_ACID);
942 BIT_FLAGS is_vuln_acid(player_type *creature_ptr)
944 BIT_FLAGS result = 0L;
945 if (creature_ptr->muta3 & MUT3_VULN_ELEM) {
946 result |= 0x01 << FLAG_CAUSE_MUTATION;
949 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
950 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
955 BIT_FLAGS is_resist_elec(player_type *creature_ptr)
957 BIT_FLAGS result = 0L;
959 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
960 result |= 0x01 << FLAG_CAUSE_RACE;
961 } else if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) && creature_ptr->lev > 19) {
962 result |= 0x01 << FLAG_CAUSE_RACE;
965 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
966 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
969 if (creature_ptr->ult_res) {
970 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
973 result |= check_equipment_flags(creature_ptr, TR_RES_ELEC);
974 result |= is_immune_elec(creature_ptr);
978 BIT_FLAGS is_vuln_elec(player_type *creature_ptr)
980 BIT_FLAGS result = 0L;
981 if (creature_ptr->muta3 & MUT3_VULN_ELEM) {
982 result |= 0x01 << FLAG_CAUSE_MUTATION;
985 if (is_specific_player_race(creature_ptr, RACE_ANDROID)) {
986 result |= 0x01 << FLAG_CAUSE_RACE;
989 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
990 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
995 BIT_FLAGS is_resist_fire(player_type *creature_ptr)
997 BIT_FLAGS result = 0L;
999 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1000 result |= 0x01 << FLAG_CAUSE_RACE;
1003 if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) && creature_ptr->lev > 4) {
1004 result |= 0x01 << FLAG_CAUSE_RACE;
1007 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
1008 result |= 0x01 << FLAG_CAUSE_RACE;
1011 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1012 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1015 if (creature_ptr->ult_res) {
1016 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1019 result |= check_equipment_flags(creature_ptr, TR_RES_FIRE);
1020 result |= is_immune_fire(creature_ptr);
1024 BIT_FLAGS is_vuln_fire(player_type *creature_ptr)
1026 BIT_FLAGS result = 0L;
1027 if (creature_ptr->muta3 & MUT3_VULN_ELEM) {
1028 result |= 0x01 << FLAG_CAUSE_MUTATION;
1031 if (is_specific_player_race(creature_ptr, RACE_ENT)) {
1032 result |= 0x01 << FLAG_CAUSE_RACE;
1035 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1036 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1041 BIT_FLAGS is_resist_cold(player_type *creature_ptr)
1043 BIT_FLAGS result = 0L;
1045 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1046 result |= 0x01 << FLAG_CAUSE_RACE;
1049 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ZOMBIE) && creature_ptr->lev > 4) {
1050 result |= 0x01 << FLAG_CAUSE_RACE;
1053 if ((is_specific_player_race(creature_ptr, RACE_DRACONIAN) || is_specific_player_race(creature_ptr, RACE_SKELETON)) && creature_ptr->lev > 9) {
1054 result |= 0x01 << FLAG_CAUSE_RACE;
1057 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
1058 result |= 0x01 << FLAG_CAUSE_RACE;
1061 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1062 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1065 if (creature_ptr->ult_res) {
1066 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1069 result |= check_equipment_flags(creature_ptr, TR_RES_COLD);
1070 result |= is_immune_cold(creature_ptr);
1074 BIT_FLAGS is_vuln_cold(player_type *creature_ptr)
1076 BIT_FLAGS result = 0L;
1077 if (creature_ptr->muta3 & MUT3_VULN_ELEM) {
1078 result |= 0x01 << FLAG_CAUSE_MUTATION;
1081 if (creature_ptr->special_defense & KATA_KOUKIJIN) {
1082 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1087 BIT_FLAGS is_resist_pois(player_type *creature_ptr)
1089 BIT_FLAGS result = 0L;
1091 if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
1092 result |= 0x01 << FLAG_CAUSE_CLASS;
1094 if (creature_ptr->mimic_form == MIMIC_VAMPIRE || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1095 result |= 0x01 << FLAG_CAUSE_RACE;
1098 if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) && creature_ptr->lev > 34) {
1099 result |= 0x01 << FLAG_CAUSE_RACE;
1102 if (!creature_ptr->mimic_form
1103 && (creature_ptr->prace == RACE_KOBOLD || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
1104 || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ANDROID)) {
1105 result |= 0x01 << FLAG_CAUSE_RACE;
1108 if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
1109 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1112 if (creature_ptr->ult_res) {
1113 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1116 result |= check_equipment_flags(creature_ptr, TR_RES_POIS);
1120 BIT_FLAGS is_resist_conf(player_type *creature_ptr)
1122 BIT_FLAGS result = 0L;
1124 if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
1125 result |= 0x01 << FLAG_CAUSE_CLASS;
1127 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1128 result |= 0x01 << FLAG_CAUSE_PERSONALITY;
1131 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_KLACKON || creature_ptr->prace == RACE_BEASTMAN || creature_ptr->prace == RACE_KUTAR)) {
1132 result |= 0x01 << FLAG_CAUSE_RACE;
1135 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1136 result |= 0x01 << FLAG_CAUSE_RACE;
1139 if (creature_ptr->ult_res || creature_ptr->magicdef) {
1140 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1143 if (creature_ptr->special_defense & KATA_MUSOU) {
1144 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1147 result |= check_equipment_flags(creature_ptr, TR_RES_CONF);
1151 BIT_FLAGS is_resist_sound(player_type *creature_ptr)
1153 BIT_FLAGS result = 0L;
1155 if (creature_ptr->pclass == CLASS_BARD) {
1156 result |= 0x01 << FLAG_CAUSE_CLASS;
1159 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_CYCLOPS || creature_ptr->prace == RACE_BEASTMAN)) {
1160 result |= 0x01 << FLAG_CAUSE_RACE;
1163 if (creature_ptr->special_defense & KATA_MUSOU) {
1164 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1167 if (creature_ptr->ult_res) {
1168 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1171 result |= check_equipment_flags(creature_ptr, TR_RES_SOUND);
1175 BIT_FLAGS is_resist_lite(player_type *creature_ptr)
1177 BIT_FLAGS result = 0L;
1179 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ELF || creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_SPRITE)) {
1180 result |= 0x01 << FLAG_CAUSE_RACE;
1183 if (creature_ptr->special_defense & KATA_MUSOU) {
1184 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1187 if (creature_ptr->ult_res) {
1188 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1191 result |= check_equipment_flags(creature_ptr, TR_RES_LITE);
1195 BIT_FLAGS is_vuln_lite(player_type *creature_ptr)
1197 BIT_FLAGS result = 0L;
1198 if (is_specific_player_race(creature_ptr, RACE_S_FAIRY) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
1199 || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
1200 result |= 0x01 << FLAG_CAUSE_RACE;
1203 if (creature_ptr->wraith_form) {
1204 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1210 BIT_FLAGS is_resist_dark(player_type *creature_ptr)
1212 BIT_FLAGS result = 0L;
1214 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1215 result |= 0x01 << FLAG_CAUSE_RACE;
1218 if (!creature_ptr->mimic_form
1219 && (creature_ptr->prace == RACE_HALF_ORC || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_NIBELUNG
1220 || creature_ptr->prace == RACE_DARK_ELF || creature_ptr->prace == RACE_VAMPIRE)) {
1221 result |= 0x01 << FLAG_CAUSE_RACE;
1224 if (creature_ptr->special_defense & KATA_MUSOU) {
1225 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1228 if (creature_ptr->ult_res) {
1229 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1232 result |= check_equipment_flags(creature_ptr, TR_RES_DARK);
1236 BIT_FLAGS is_resist_chaos(player_type *creature_ptr)
1238 BIT_FLAGS result = 0L;
1240 if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
1241 result |= 0x01 << FLAG_CAUSE_CLASS;
1243 if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1244 result |= 0x01 << FLAG_CAUSE_RACE;
1247 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
1248 result |= 0x01 << FLAG_CAUSE_RACE;
1250 if (creature_ptr->special_defense & KATA_MUSOU) {
1251 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1254 if (creature_ptr->ult_res) {
1255 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1258 result |= check_equipment_flags(creature_ptr, TR_RES_CHAOS);
1262 BIT_FLAGS is_resist_disen(player_type *creature_ptr)
1264 BIT_FLAGS result = 0L;
1266 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1267 result |= 0x01 << FLAG_CAUSE_RACE;
1270 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_NIBELUNG)
1271 result |= 0x01 << FLAG_CAUSE_RACE;
1273 if (creature_ptr->special_defense & KATA_MUSOU) {
1274 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1277 if (creature_ptr->ult_res) {
1278 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1281 result |= check_equipment_flags(creature_ptr, TR_RES_DISEN);
1285 BIT_FLAGS is_resist_shard(player_type *creature_ptr)
1287 BIT_FLAGS result = 0L;
1289 if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_HALF_TITAN || creature_ptr->prace == RACE_SKELETON))
1290 result |= 0x01 << FLAG_CAUSE_RACE;
1292 if (creature_ptr->special_defense & KATA_MUSOU) {
1293 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1296 if (creature_ptr->ult_res) {
1297 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1300 result |= check_equipment_flags(creature_ptr, TR_RES_SHARDS);
1304 BIT_FLAGS is_resist_nexus(player_type *creature_ptr)
1306 BIT_FLAGS result = 0L;
1308 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1309 result |= 0x01 << FLAG_CAUSE_RACE;
1312 if (creature_ptr->special_defense & KATA_MUSOU) {
1313 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1316 if (creature_ptr->ult_res) {
1317 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1320 result |= check_equipment_flags(creature_ptr, TR_RES_NEXUS);
1324 BIT_FLAGS is_resist_blind(player_type *creature_ptr)
1326 BIT_FLAGS result = 0L;
1328 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1329 result |= 0x01 << FLAG_CAUSE_PERSONALITY;
1332 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DWARF)
1333 result |= 0x01 << FLAG_CAUSE_RACE;
1335 if (creature_ptr->special_defense & KATA_MUSOU) {
1336 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1339 if (creature_ptr->ult_res || creature_ptr->magicdef) {
1340 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1343 result |= check_equipment_flags(creature_ptr, TR_RES_BLIND);
1347 BIT_FLAGS is_resist_neth(player_type *creature_ptr)
1349 BIT_FLAGS result = 0L;
1351 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1352 result |= 0x01 << FLAG_CAUSE_RACE;
1355 if (!creature_ptr->mimic_form
1356 && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE
1357 || creature_ptr->prace == RACE_BALROG))
1358 result |= 0x01 << FLAG_CAUSE_RACE;
1360 if (creature_ptr->special_defense & KATA_MUSOU) {
1361 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1364 if (creature_ptr->ult_res || creature_ptr->tim_res_nether) {
1365 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1368 result |= check_equipment_flags(creature_ptr, TR_RES_NETHER);
1372 BIT_FLAGS is_resist_time(player_type *creature_ptr)
1374 BIT_FLAGS result = 0L;
1376 if (creature_ptr->tim_res_time) {
1377 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1380 result |= check_equipment_flags(creature_ptr, TR_RES_TIME);
1384 BIT_FLAGS is_resist_water(player_type *creature_ptr)
1386 BIT_FLAGS result = 0L;
1388 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
1389 result |= 0x01 << FLAG_CAUSE_RACE;
1391 result |= check_equipment_flags(creature_ptr, TR_RES_WATER);
1395 BIT_FLAGS is_resist_fear(player_type *creature_ptr)
1397 BIT_FLAGS result = 0L;
1399 if (creature_ptr->muta3 & MUT3_FEARLESS)
1400 result |= 0x01 << FLAG_CAUSE_MUTATION;
1402 switch (creature_ptr->pclass) {
1405 if (creature_ptr->lev > 29)
1406 result |= 0x01 << FLAG_CAUSE_CLASS;
1409 case CLASS_CHAOS_WARRIOR:
1410 if (creature_ptr->lev > 39)
1411 result |= 0x01 << FLAG_CAUSE_CLASS;
1413 case CLASS_MINDCRAFTER:
1414 if (creature_ptr->lev > 9)
1415 result |= 0x01 << FLAG_CAUSE_CLASS;
1418 result |= 0x01 << FLAG_CAUSE_CLASS;
1422 if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1423 result |= 0x01 << FLAG_CAUSE_RACE;
1426 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
1427 result |= 0x01 << FLAG_CAUSE_RACE;
1429 if ((creature_ptr->special_defense & KATA_MUSOU)) {
1430 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1433 if (is_hero(creature_ptr) || is_shero(creature_ptr) || creature_ptr->ult_res) {
1434 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1437 result |= check_equipment_flags(creature_ptr, TR_RES_FEAR);
1441 BIT_FLAGS is_immune_acid(player_type *creature_ptr)
1443 BIT_FLAGS result = 0L;
1444 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_YEEK && creature_ptr->lev > 19)
1445 result |= 0x01 << FLAG_CAUSE_RACE;
1447 if (creature_ptr->ele_immune) {
1448 if (creature_ptr->special_defense & DEFENSE_ACID)
1449 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1452 result |= check_equipment_flags(creature_ptr, TR_IM_ACID);
1456 BIT_FLAGS is_immune_elec(player_type *creature_ptr)
1458 BIT_FLAGS result = 0L;
1460 if (creature_ptr->ele_immune) {
1461 if (creature_ptr->special_defense & DEFENSE_ELEC)
1462 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1465 result |= check_equipment_flags(creature_ptr, TR_IM_ELEC);
1469 BIT_FLAGS is_immune_fire(player_type *creature_ptr)
1471 BIT_FLAGS result = 0L;
1473 if (creature_ptr->ele_immune) {
1474 if (creature_ptr->special_defense & DEFENSE_FIRE)
1475 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1478 result |= check_equipment_flags(creature_ptr, TR_IM_FIRE);
1482 BIT_FLAGS is_immune_cold(player_type *creature_ptr)
1484 BIT_FLAGS result = 0L;
1486 if (creature_ptr->ele_immune) {
1487 if (creature_ptr->special_defense & DEFENSE_COLD)
1488 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1491 result |= check_equipment_flags(creature_ptr, TR_IM_COLD);
1495 BIT_FLAGS is_immune_dark(player_type *creature_ptr)
1497 BIT_FLAGS result = 0L;
1499 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
1500 result |= 0x01 << FLAG_CAUSE_RACE;
1503 if (creature_ptr->wraith_form) {
1504 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1510 bool has_right_hand_weapon(player_type *creature_ptr)
1512 if (has_melee_weapon(creature_ptr, INVEN_RARM))
1515 if (can_two_hands_wielding(creature_ptr)) {
1516 switch (creature_ptr->pclass) {
1518 case CLASS_FORCETRAINER:
1519 case CLASS_BERSERKER:
1520 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
1530 bool has_left_hand_weapon(player_type *creature_ptr) { return has_melee_weapon(creature_ptr, INVEN_LARM); }
1532 bool has_two_handed_weapons(player_type *creature_ptr)
1534 if (can_two_hands_wielding(creature_ptr)) {
1535 if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
1536 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
1538 } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
1539 && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
1546 BIT_FLAGS has_lite(player_type *creature_ptr)
1548 BIT_FLAGS result = 0L;
1549 if (creature_ptr->pclass == CLASS_NINJA)
1552 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1553 result |= 0x01 << FLAG_CAUSE_PERSONALITY;
1556 if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1557 result |= 0x01 << FLAG_CAUSE_RACE;
1560 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
1561 result |= 0x01 << FLAG_CAUSE_RACE;
1563 if (creature_ptr->ult_res) {
1564 result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
1567 if (creature_ptr->special_defense & KATA_MUSOU) {
1568 result |= 0x01 << FLAG_CAUSE_BATTLE_FORM;
1571 result |= has_sh_fire(creature_ptr);
1576 bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
1579 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1580 if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1581 if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && has_two_handed_weapons(creature_ptr)
1582 && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
1588 bool is_icky_wield_weapon(player_type *creature_ptr, int i)
1591 BIT_FLAGS flgs[TR_FLAG_SIZE];
1592 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1593 object_flags(creature_ptr, o_ptr, flgs);
1595 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1597 } else if (creature_ptr->pclass == CLASS_SORCERER) {
1598 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
1602 if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
1608 bool is_riding_wield_weapon(player_type *creature_ptr, int i)
1611 BIT_FLAGS flgs[TR_FLAG_SIZE];
1612 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1613 object_flags(creature_ptr, o_ptr, flgs);
1614 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
1615 && !has_flag(flgs, TR_RIDING)) {
1621 bool is_not_ninja_weapon(player_type *creature_ptr, int i)
1623 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1624 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1625 return creature_ptr->pclass == CLASS_NINJA
1626 && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
1629 bool is_not_monk_weapon(player_type *creature_ptr, int i)
1631 tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1632 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1633 return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
1636 bool has_good_luck(player_type *creature_ptr) { return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta3 & MUT3_GOOD_LUCK); }