OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband
[hengband/hengband.git] / src / player / player-status-flags.c
index 5606d55..646a478 100644 (file)
@@ -1,79 +1,76 @@
-#include "art-definition/art-sword-types.h"
+#include "player/player-status-flags.h"
+#include "art-definition/art-sword-types.h"
 #include "grid/grid.h"
 #include "inventory/inventory-slot-types.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags2.h"
+#include "monster-race/race-flags7.h"
 #include "mutation/mutation-flag-types.h"
-#include "object/object-flags.h"
 #include "object-enchant/object-ego.h"
 #include "object-enchant/tr-types.h"
 #include "object-enchant/trc-types.h"
 #include "object-hook/hook-checker.h"
+#include "object-hook/hook-weapon.h"
+#include "object/object-flags.h"
 #include "player/player-class.h"
 #include "player/player-race-types.h"
 #include "player/player-race.h"
+#include "player/player-skill.h"
 #include "player/player-status.h"
 #include "player/special-defense-types.h"
 #include "realm/realm-hex-numbers.h"
 #include "realm/realm-song-numbers.h"
 #include "realm/realm-types.h"
 #include "spell-realm/spells-hex.h"
+#include "sv-definition/sv-weapon-types.h"
 #include "system/floor-type-definition.h"
 #include "system/monster-type-definition.h"
 #include "system/object-type-definition.h"
 #include "util/bit-flags-calculator.h"
 #include "util/quarks.h"
 #include "util/string-processor.h"
-#include "monster-race/race-flags7.h"
 
-void have_kill_wall(player_type *creature_ptr)
+bool have_kill_wall(player_type *creature_ptr)
 {
-    creature_ptr->kill_wall = FALSE;
-
-    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
-        creature_ptr->kill_wall = TRUE;
-    }
-
-    if (music_singing(creature_ptr, MUSIC_WALL)) {
-        creature_ptr->kill_wall = TRUE;
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || music_singing(creature_ptr, MUSIC_WALL)) {
+        return TRUE;
     }
 
     if (creature_ptr->riding) {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
         if (riding_r_ptr->flags2 & RF2_KILL_WALL)
-            creature_ptr->kill_wall = TRUE;
+            return TRUE;
     }
+
+       return FALSE;
 }
 
-void have_pass_wall(player_type *creature_ptr)
+bool have_pass_wall(player_type *creature_ptr)
 {
-    creature_ptr->pass_wall = FALSE;
+    bool pow = FALSE;
 
-    if (creature_ptr->wraith_form) {
-        creature_ptr->pass_wall = TRUE;
-    }
-
-    if (creature_ptr->tim_pass_wall) {
-        creature_ptr->pass_wall = TRUE;
+    if (creature_ptr->wraith_form || creature_ptr->tim_pass_wall || (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE)) {
+        pow = TRUE;
     }
 
     if (creature_ptr->riding) {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
         if (!(riding_r_ptr->flags2 & RF2_PASS_WALL))
-            creature_ptr->pass_wall = FALSE;
+            pow = FALSE;
     }
+
+       return pow;
 }
 
-void have_xtra_might(player_type *creature_ptr)
+BIT_FLAGS have_xtra_might(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->xtra_might = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -81,23 +78,24 @@ void have_xtra_might(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_XTRA_MIGHT))
-            creature_ptr->xtra_might = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_evil(player_type *creature_ptr)
+BIT_FLAGS have_esp_evil(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-    creature_ptr->esp_evil = FALSE;
+    BIT_FLAGS result = 0L;
 
     if (creature_ptr->realm1 == REALM_HEX) {
         if (hex_spelling(creature_ptr, HEX_DETECT_EVIL))
-            creature_ptr->esp_evil = TRUE;
+            result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -105,18 +103,19 @@ void have_esp_evil(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_EVIL))
-            creature_ptr->esp_evil = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_animal(player_type *creature_ptr)
+BIT_FLAGS have_esp_animal(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_animal = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -124,18 +123,19 @@ void have_esp_animal(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_ANIMAL))
-            creature_ptr->esp_animal = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_undead(player_type *creature_ptr)
+BIT_FLAGS have_esp_undead(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_undead = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -143,18 +143,19 @@ void have_esp_undead(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_UNDEAD))
-            creature_ptr->esp_undead = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_demon(player_type *creature_ptr)
+BIT_FLAGS have_esp_demon(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_demon = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -162,18 +163,19 @@ void have_esp_demon(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_DEMON))
-            creature_ptr->esp_demon = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_orc(player_type *creature_ptr)
+BIT_FLAGS have_esp_orc(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_orc = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -181,18 +183,19 @@ void have_esp_orc(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_ORC))
-            creature_ptr->esp_orc = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_troll(player_type *creature_ptr)
+BIT_FLAGS have_esp_troll(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_troll = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -200,18 +203,19 @@ void have_esp_troll(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_TROLL))
-            creature_ptr->esp_troll = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_giant(player_type *creature_ptr)
+BIT_FLAGS have_esp_giant(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_giant = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -219,18 +223,19 @@ void have_esp_giant(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_GIANT))
-            creature_ptr->esp_giant = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_dragon(player_type *creature_ptr)
+BIT_FLAGS have_esp_dragon(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_dragon = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -238,8 +243,10 @@ void have_esp_dragon(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_DRAGON))
-            creature_ptr->esp_dragon = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
 void have_esp_human(player_type *creature_ptr)
@@ -249,7 +256,7 @@ void have_esp_human(player_type *creature_ptr)
 
     creature_ptr->esp_human = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -268,7 +275,7 @@ void have_esp_good(player_type *creature_ptr)
 
     creature_ptr->esp_good = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -287,7 +294,7 @@ void have_esp_nonliving(player_type *creature_ptr)
 
     creature_ptr->esp_nonliving = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -306,7 +313,7 @@ void have_esp_unique(player_type *creature_ptr)
 
     creature_ptr->esp_unique = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -350,7 +357,7 @@ void have_esp_telepathy(player_type *creature_ptr)
         creature_ptr->telepathy = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -369,7 +376,7 @@ void have_bless_blade(player_type *creature_ptr)
 
     creature_ptr->bless_blade = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -388,7 +395,7 @@ void have_easy2_weapon(player_type *creature_ptr)
 
     creature_ptr->easy_2weapon = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -407,7 +414,7 @@ void have_down_saving(player_type *creature_ptr)
 
     creature_ptr->down_saving = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -426,7 +433,7 @@ void have_no_ac(player_type *creature_ptr)
 
     creature_ptr->yoiyami = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -485,7 +492,7 @@ void have_mighty_throw(player_type *creature_ptr)
 
     creature_ptr->mighty_throw = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -502,7 +509,7 @@ void have_dec_mana(player_type *creature_ptr)
 
     creature_ptr->xtra_might = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -547,7 +554,7 @@ void have_reflect(player_type *creature_ptr)
         creature_ptr->reflect = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -574,7 +581,7 @@ void have_warning(player_type *creature_ptr)
 
     creature_ptr->warning = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -595,7 +602,7 @@ void have_anti_magic(player_type *creature_ptr)
 
     creature_ptr->anti_magic = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -614,7 +621,7 @@ void have_anti_tele(player_type *creature_ptr)
 
     creature_ptr->anti_tele = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -658,7 +665,7 @@ void have_sh_fire(player_type *creature_ptr)
         creature_ptr->sh_fire = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -692,7 +699,7 @@ void have_sh_elec(player_type *creature_ptr)
         creature_ptr->sh_elec = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -723,7 +730,7 @@ void have_sh_cold(player_type *creature_ptr)
         creature_ptr->sh_cold = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -739,7 +746,7 @@ void have_easy_spell(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->easy_spell = FALSE;
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -755,7 +762,7 @@ void have_heavy_spell(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->heavy_spell = FALSE;
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -781,26 +788,23 @@ void have_hold_exp(player_type *creature_ptr)
         creature_ptr->hold_exp = TRUE;
     }
 
-    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HOBBIT) {
+    if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON) ||
+        is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE) ||
+               is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG) ||
+        is_specific_player_race(creature_ptr, RACE_ANDROID)) {
         creature_ptr->hold_exp = TRUE;
     }
 
-    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GOLEM) {
+    if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
         if (creature_ptr->lev > 34)
             creature_ptr->hold_exp = TRUE;
     }
 
-    if (!creature_ptr->mimic_form
-        && (creature_ptr->prace == RACE_SKELETON || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE
-            || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_BALROG || creature_ptr->prace == RACE_ANDROID)) {
-        creature_ptr->hold_exp = TRUE;    
-       }
-
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->hold_exp = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -849,11 +853,11 @@ void have_see_inv(player_type *creature_ptr)
         creature_ptr->see_inv = TRUE;
     }
 
-       if (creature_ptr->tim_invis) {
+    if (creature_ptr->tim_invis) {
         creature_ptr->see_inv = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -869,12 +873,12 @@ void have_free_act(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->free_act = FALSE;
-       
-       if (creature_ptr->muta3 & MUT3_MOTION)
+
+    if (creature_ptr->muta3 & MUT3_MOTION)
         creature_ptr->free_act = TRUE;
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GNOME) {
-               creature_ptr->free_act = TRUE;
+        creature_ptr->free_act = TRUE;
     }
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GOLEM) {
@@ -889,8 +893,8 @@ void have_free_act(player_type *creature_ptr)
         creature_ptr->free_act = TRUE;
     }
 
-    if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->right_hand_weapon)
-        && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->left_hand_weapon)) {
+    if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || have_right_hand_weapon(creature_ptr))
+        && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || have_left_hand_weapon(creature_ptr))) {
         if (creature_ptr->lev > 24)
             creature_ptr->free_act = TRUE;
     }
@@ -914,7 +918,7 @@ void have_free_act(player_type *creature_ptr)
         creature_ptr->free_act = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -932,7 +936,7 @@ void have_sustain_str(player_type *creature_ptr)
     creature_ptr->sustain_str = FALSE;
     if (creature_ptr->pclass == CLASS_BERSERKER) {
         creature_ptr->sustain_str = TRUE;
-       }
+    }
     if (!creature_ptr->mimic_form
         && (creature_ptr->prace == RACE_HALF_TROLL || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_HALF_GIANT)) {
         creature_ptr->sustain_str = TRUE;
@@ -941,7 +945,7 @@ void have_sustain_str(player_type *creature_ptr)
         creature_ptr->sustain_str = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -957,8 +961,7 @@ void have_sustain_int(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->sustain_int = FALSE;
-    if (!creature_ptr->mimic_form
-        && (creature_ptr->prace == RACE_MIND_FLAYER)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
         creature_ptr->sustain_int = TRUE;
     }
 
@@ -966,7 +969,7 @@ void have_sustain_int(player_type *creature_ptr)
         creature_ptr->sustain_int = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -984,8 +987,8 @@ void have_sustain_wis(player_type *creature_ptr)
     creature_ptr->sustain_wis = FALSE;
     if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
         creature_ptr->sustain_wis = TRUE;
-       
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
+
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
         creature_ptr->sustain_wis = TRUE;
     }
 
@@ -993,7 +996,7 @@ void have_sustain_wis(player_type *creature_ptr)
         creature_ptr->sustain_wis = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1020,7 +1023,7 @@ void have_sustain_dex(player_type *creature_ptr)
         creature_ptr->sustain_dex = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1040,7 +1043,7 @@ void have_sustain_con(player_type *creature_ptr)
         creature_ptr->sustain_con = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
         creature_ptr->sustain_con = TRUE;
     }
 
@@ -1048,7 +1051,7 @@ void have_sustain_con(player_type *creature_ptr)
         creature_ptr->sustain_con = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1069,7 +1072,7 @@ void have_sustain_chr(player_type *creature_ptr)
         creature_ptr->sustain_chr = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1090,6 +1093,9 @@ void have_levitation(player_type *creature_ptr)
         creature_ptr->levitation = TRUE;
     }
 
+    if (creature_ptr->muta3 & MUT3_WINGS)
+        creature_ptr->levitation = TRUE;
+
     if (!creature_ptr->mimic_form
         && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_SPRITE
             || creature_ptr->prace == RACE_ARCHON || creature_ptr->prace == RACE_S_FAIRY)) {
@@ -1102,7 +1108,7 @@ void have_levitation(player_type *creature_ptr)
 
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->levitation = TRUE;
-       }
+    }
 
     if (creature_ptr->magicdef) {
     }
@@ -1117,7 +1123,7 @@ void have_levitation(player_type *creature_ptr)
         creature_ptr->levitation = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1129,7 +1135,7 @@ void have_levitation(player_type *creature_ptr)
 
 void have_can_swim(player_type *creature_ptr)
 {
-       creature_ptr->can_swim = FALSE;
+    creature_ptr->can_swim = FALSE;
     if (creature_ptr->riding) {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
@@ -1148,7 +1154,7 @@ void have_slow_digest(player_type *creature_ptr)
         creature_ptr->slow_digest = TRUE;
     }
 
-       if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
+    if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
         if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
             creature_ptr->slow_digest = TRUE;
             /* Let's not make Regeneration
@@ -1169,7 +1175,7 @@ void have_slow_digest(player_type *creature_ptr)
         creature_ptr->slow_digest = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1224,11 +1230,11 @@ void have_regenerate(player_type *creature_ptr)
         }
     }
 
-       if (creature_ptr->tim_regen) {
+    if (creature_ptr->tim_regen) {
         creature_ptr->regenerate = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1247,7 +1253,7 @@ void have_curses(player_type *creature_ptr)
     if (creature_ptr->pseikaku == PERSONALITY_SEXY)
         creature_ptr->cursed |= (TRC_AGGRAVATE);
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1321,7 +1327,7 @@ void have_impact(player_type *creature_ptr)
     creature_ptr->impact[0] = FALSE;
     creature_ptr->impact[1] = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1329,7 +1335,6 @@ void have_impact(player_type *creature_ptr)
         if (have_flag(flgs, TR_IMPACT))
             creature_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
     }
-
 }
 
 void have_extra_blow(player_type *creature_ptr)
@@ -1338,7 +1343,7 @@ void have_extra_blow(player_type *creature_ptr)
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1348,9 +1353,9 @@ void have_extra_blow(player_type *creature_ptr)
         if (have_flag(flgs, TR_INFRA))
             creature_ptr->see_infra += o_ptr->pval;
         if (have_flag(flgs, TR_BLOWS)) {
-            if ((i == INVEN_RARM || i == INVEN_RIGHT) && !creature_ptr->two_handed_weapon)
+            if ((i == INVEN_RARM || i == INVEN_RIGHT) && !have_two_handed_weapons(creature_ptr))
                 creature_ptr->extra_blows[0] += o_ptr->pval;
-            else if ((i == INVEN_LARM || i == INVEN_LEFT) && !creature_ptr->two_handed_weapon)
+            else if ((i == INVEN_LARM || i == INVEN_LEFT) && !have_two_handed_weapons(creature_ptr))
                 creature_ptr->extra_blows[1] += o_ptr->pval;
             else {
                 creature_ptr->extra_blows[0] += o_ptr->pval;
@@ -1374,19 +1379,19 @@ void have_resist_acid(player_type *creature_ptr)
         creature_ptr->resist_acid = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
         creature_ptr->resist_acid = TRUE;
-       }
+    }
 
-       if (creature_ptr->special_defense & KAMAE_SEIRYU) {
+    if (creature_ptr->special_defense & KAMAE_SEIRYU) {
         creature_ptr->resist_acid = TRUE;
-       }
+    }
 
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->resist_acid = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1396,7 +1401,7 @@ void have_resist_acid(player_type *creature_ptr)
             creature_ptr->resist_acid = TRUE;
     }
 
-       if (creature_ptr->immune_acid)
+    if (creature_ptr->immune_acid)
         creature_ptr->resist_acid = TRUE;
 }
 
@@ -1422,7 +1427,7 @@ void have_resist_elec(player_type *creature_ptr)
         creature_ptr->resist_elec = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1450,7 +1455,7 @@ void have_resist_fire(player_type *creature_ptr)
         creature_ptr->resist_fire = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
         creature_ptr->resist_fire = TRUE;
     }
 
@@ -1462,7 +1467,7 @@ void have_resist_fire(player_type *creature_ptr)
         creature_ptr->resist_fire = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1483,7 +1488,6 @@ void have_resist_cold(player_type *creature_ptr)
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->resist_cold = FALSE;
 
-
     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
         creature_ptr->resist_cold = TRUE;
     }
@@ -1492,38 +1496,691 @@ void have_resist_cold(player_type *creature_ptr)
         creature_ptr->resist_cold = TRUE;
     }
 
-    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON)
-                        && creature_ptr->lev > 9) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON) && creature_ptr->lev > 9) {
         creature_ptr->resist_cold = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
         creature_ptr->resist_fire = TRUE;
     }
 
-       if (creature_ptr->special_defense & KAMAE_SEIRYU) {
+    if (creature_ptr->special_defense & KAMAE_SEIRYU) {
         creature_ptr->resist_cold = TRUE;
     }
 
-       if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->resist_cold = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-           if (have_flag(flgs, TR_RES_COLD))
+        if (have_flag(flgs, TR_RES_COLD))
             creature_ptr->resist_cold = TRUE;
     }
 
-
     if (creature_ptr->immune_cold)
         creature_ptr->resist_cold = TRUE;
+}
+
+void have_resist_pois(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_pois = FALSE;
+
+    if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
+        creature_ptr->resist_pois = TRUE;
+
+    if (creature_ptr->mimic_form == MIMIC_VAMPIRE || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->resist_pois = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 34) {
+        creature_ptr->resist_pois = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form
+        && (creature_ptr->prace == RACE_KOBOLD || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
+            || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ANDROID)) {
+        creature_ptr->resist_pois = TRUE;
+    }
+
+    if (creature_ptr->special_defense & KAMAE_SEIRYU) {
+        creature_ptr->resist_pois = TRUE;
+    }
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_pois = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_POIS))
+            creature_ptr->resist_pois = TRUE;
+    }
+}
+
+void have_resist_conf(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_conf = FALSE;
+
+    if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
+        creature_ptr->resist_conf = TRUE;
+
+    if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
+        creature_ptr->resist_conf = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_KLACKON || creature_ptr->prace == RACE_BEASTMAN || creature_ptr->prace == RACE_KUTAR)) {
+        creature_ptr->resist_conf = TRUE;
+    }
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->resist_conf = TRUE;
+    }
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_conf = TRUE;
+    }
+
+    if (creature_ptr->magicdef) {
+        creature_ptr->resist_conf = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_CONF))
+            creature_ptr->resist_conf = TRUE;
+    }
+}
+
+void have_resist_sound(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_sound = FALSE;
+
+    if (creature_ptr->pclass == CLASS_BARD) {
+        creature_ptr->resist_sound = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_CYCLOPS || creature_ptr->prace == RACE_BEASTMAN)) {
+        creature_ptr->resist_sound = TRUE;
+    }
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_sound = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_SOUND))
+            creature_ptr->resist_sound = TRUE;
+    }
+}
+
+void have_resist_lite(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_lite = FALSE;
+
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ELF || creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_SPRITE)) {
+        creature_ptr->resist_lite = TRUE;
+    }
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_lite = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_LITE))
+            creature_ptr->resist_lite = TRUE;
+    }
+}
+
+void have_resist_dark(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_dark = FALSE;
+
+    if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
+        creature_ptr->resist_dark = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form
+        && (creature_ptr->prace == RACE_HALF_ORC || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_NIBELUNG
+            || creature_ptr->prace == RACE_DARK_ELF || creature_ptr->prace == RACE_VAMPIRE)) {
+        creature_ptr->resist_lite = TRUE;
+    }
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_dark = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_DARK))
+            creature_ptr->resist_dark = TRUE;
+    }
+}
+
+void have_resist_chaos(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_chaos = FALSE;
+
+    if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
+        creature_ptr->resist_chaos = TRUE;
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->resist_chaos = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
+        creature_ptr->resist_chaos = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_chaos = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_CHAOS))
+            creature_ptr->resist_chaos = TRUE;
+    }
+}
+
+void have_resist_disen(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_disen = FALSE;
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->resist_disen = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_NIBELUNG)
+        creature_ptr->resist_disen = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_disen = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_DISEN))
+            creature_ptr->resist_disen = TRUE;
+    }
+}
+
+void have_resist_shard(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_shard = FALSE;
+
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_HALF_TITAN || creature_ptr->prace == RACE_SKELETON))
+        creature_ptr->resist_shard = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_shard = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_DISEN))
+            creature_ptr->resist_shard = TRUE;
+    }
+}
 
+void have_resist_nexus(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_nexus = FALSE;
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->resist_nexus = TRUE;
+    }
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_nexus = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_NEXUS))
+            creature_ptr->resist_nexus = TRUE;
+    }
+}
+
+void have_resist_blind(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_blind = FALSE;
+
+    if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
+        creature_ptr->resist_blind = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DWARF)
+        creature_ptr->resist_blind = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_blind = TRUE;
+    }
+
+    if (creature_ptr->magicdef) {
+        creature_ptr->resist_blind = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_BLIND))
+            creature_ptr->resist_blind = TRUE;
+    }
+}
+
+void have_resist_neth(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
+        creature_ptr->resist_neth = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form
+        && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE
+            || creature_ptr->prace == RACE_BALROG))
+        creature_ptr->resist_neth = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_neth = TRUE;
+    }
+
+    if (creature_ptr->tim_res_nether) {
+        creature_ptr->resist_neth = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+
+        if (have_flag(flgs, TR_RES_NETHER))
+            creature_ptr->resist_neth = TRUE;
+    }
+}
+
+void have_resist_time(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_time = FALSE;
+
+    if (creature_ptr->tim_res_time) {
+        creature_ptr->resist_time = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+        if (o_ptr->name2 == EGO_RING_RES_TIME)
+            creature_ptr->resist_time = TRUE;
+    }
+}
+
+void have_resist_water(player_type *creature_ptr)
+{
+    creature_ptr->resist_water = FALSE;
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
+        creature_ptr->resist_water = TRUE;
+}
+
+void have_resist_fear(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_fear = FALSE;
+
+    if (creature_ptr->muta3 & MUT3_FEARLESS)
+        creature_ptr->resist_fear = TRUE;
+
+    switch (creature_ptr->pclass) {
+    case CLASS_WARRIOR:
+        if (creature_ptr->lev > 29)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_PALADIN:
+        if (creature_ptr->lev > 39)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_CHAOS_WARRIOR:
+        if (creature_ptr->lev > 39)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_MINDCRAFTER:
+        if (creature_ptr->lev > 9)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_SAMURAI:
+        if (creature_ptr->lev > 29)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_NINJA:
+        creature_ptr->resist_fear = TRUE;
+        break;
+    }
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->resist_fear = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
+        creature_ptr->resist_fear = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_fear = TRUE;
+    }
+
+    if (is_hero(creature_ptr) || creature_ptr->shero) {
+        creature_ptr->resist_fear = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+        if (have_flag(flgs, TR_RES_FEAR))
+            creature_ptr->resist_fear = TRUE;
+    }
+}
+
+void have_immune_acid(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->immune_acid = FALSE;
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_YEEK && creature_ptr->lev > 19)
+        creature_ptr->immune_acid = TRUE;
+
+    if (creature_ptr->ele_immune) {
+        if (creature_ptr->special_defense & DEFENSE_ACID)
+            creature_ptr->immune_acid = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+        if (have_flag(flgs, TR_IM_ACID))
+            creature_ptr->immune_acid = TRUE;
+    }
+}
+
+void have_immune_elec(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->immune_elec = FALSE;
+    if (creature_ptr->ele_immune) {
+        if (creature_ptr->special_defense & DEFENSE_ELEC)
+            creature_ptr->immune_elec = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+        if (have_flag(flgs, TR_IM_ELEC))
+            creature_ptr->immune_elec = TRUE;
+    }
+}
+
+void have_immune_fire(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->immune_fire = FALSE;
+    if (creature_ptr->ele_immune) {
+        if (creature_ptr->special_defense & DEFENSE_FIRE)
+            creature_ptr->immune_fire = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+        if (have_flag(flgs, TR_IM_FIRE))
+            creature_ptr->immune_fire = TRUE;
+    }
+}
+
+void have_immune_cold(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->immune_cold = FALSE;
+    if (creature_ptr->ele_immune) {
+        if (creature_ptr->special_defense & DEFENSE_COLD)
+            creature_ptr->immune_cold = TRUE;
+    }
+
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+        if (have_flag(flgs, TR_IM_COLD))
+            creature_ptr->immune_cold = TRUE;
+    }
+}
 
+bool have_right_hand_weapon(player_type *creature_ptr)
+{
+    if (has_melee_weapon(creature_ptr, INVEN_RARM))
+        return TRUE;
+
+    if (can_two_hands_wielding(creature_ptr)) {
+        switch (creature_ptr->pclass) {
+        case CLASS_MONK:
+        case CLASS_FORCETRAINER:
+        case CLASS_BERSERKER:
+            if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
+                return TRUE;
+            }
+            break;
+        }
+    }
+
+       return FALSE;
+}
+
+bool have_left_hand_weapon(player_type *creature_ptr)
+{
+    return has_melee_weapon(creature_ptr, INVEN_LARM);
+}
+
+bool have_two_handed_weapons(player_type *creature_ptr)
+{
+    if (can_two_hands_wielding(creature_ptr)) {
+        if (have_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
+            && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
+            return TRUE;
+        } else if (have_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
+            && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
+void have_lite(player_type *creature_ptr)
+{
+    creature_ptr->lite = FALSE;
+    if (creature_ptr->pclass == CLASS_NINJA)
+        return;
+
+    if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
+        creature_ptr->lite = TRUE;
+    }
+
+    if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
+        creature_ptr->lite = TRUE;
+    }
+
+    if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
+        creature_ptr->lite = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
+        creature_ptr->lite = TRUE;
+
+    if (creature_ptr->sh_fire)
+        creature_ptr->lite = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->lite = TRUE;
+    }
+}
+
+bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
+{
+    object_type *o_ptr;
+    o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
+    if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
+        if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && have_two_handed_weapons(creature_ptr) && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
+            return TRUE;
+    }
+    return FALSE;
+}
+
+bool is_icky_wield_weapon(player_type *creature_ptr, int i)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
+    object_flags(creature_ptr, o_ptr, flgs);
+
+    if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
+        return TRUE;
+    } else if (creature_ptr->pclass == CLASS_SORCERER) {
+        if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
+            return TRUE;
+        }
+    }
+    if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+bool is_riding_wield_weapon(player_type *creature_ptr, int i)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
+    object_flags(creature_ptr, o_ptr, flgs);
+    if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
+        && !have_flag(flgs, TR_RIDING)) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+bool is_not_ninja_weapon(player_type *creature_ptr, int i)
+{
+    tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
+    OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
+    return creature_ptr->pclass == CLASS_NINJA
+        && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
+}
+
+bool is_not_monk_weapon(player_type *creature_ptr, int i)
+{
+    tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
+    OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
+    return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
 }
 
+bool have_good_luck(player_type *creature_ptr) { return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta3 |= MUT3_GOOD_LUCK); };