OSDN Git Service

[Refactor] 特殊な種族の能力/耐性の定義をplayer_raceに移動
authoriks <iks3@users.noreply.github.com>
Sat, 17 Apr 2021 17:02:53 +0000 (02:02 +0900)
committeriks <iks3@users.noreply.github.com>
Mon, 19 Apr 2021 13:39:23 +0000 (22:39 +0900)
アイテム能力フラグにTR_VUL_ACID~TR_VUL_LITEとTR_IM_DARK追加。
幽霊の地獄吸収ついては未対応。
種族の食事については未対応。
種族か切り傷を負うかどうかについては未対応。

18 files changed:
src/birth/game-play-initializer.cpp
src/cmd-building/cmd-inn.cpp
src/cmd-item/cmd-eat.cpp
src/core/hp-mp-processor.cpp
src/effect/effect-player-resist-hurt.cpp
src/mspell/high-resistance-checker.cpp
src/object-enchant/tr-types.h
src/object/warning.cpp
src/player-info/resistance-info.cpp
src/player/eldritch-horror.cpp
src/player/mimic-info-table.cpp
src/player/player-race.cpp
src/player/player-race.h
src/player/player-status-flags.cpp
src/player/player-status-resist.cpp
src/player/race-info-table.cpp
src/player/race-resistances.cpp
src/realm/realm-nature.cpp

index d919352..e7b47bf 100644 (file)
@@ -14,6 +14,7 @@
 #include "object/object-kind.h"
 #include "pet/pet-util.h"
 #include "player/player-race-types.h"
+#include "player/player-race.h"
 #include "system/artifact-type-definition.h"
 #include "system/floor-type-definition.h"
 #include "system/system-variables.h"
@@ -223,7 +224,7 @@ void init_dungeon_quests(player_type *creature_ptr)
  */
 void init_turn(player_type *creature_ptr)
 {
-    if ((creature_ptr->prace == RACE_VAMPIRE) || (creature_ptr->prace == RACE_SKELETON) || (creature_ptr->prace == RACE_ZOMBIE) || (creature_ptr->prace == RACE_SPECTRE)) {
+    if (player_race_life(creature_ptr) == PlayerRaceLife::UNDEAD) {
         current_world_ptr->game_turn = (TURNS_PER_TICK * 3 * TOWN_DAWN) / 4 + 1;
         current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
     } else {
index 8340742..8e4f5f5 100644 (file)
@@ -52,11 +52,7 @@ static bool is_healthy_stay(player_type *customer_ptr)
 #ifdef JP
 static bool is_player_undead(player_type *customer_ptr)
 {
-       bool is_player_undead = is_specific_player_race(customer_ptr, RACE_SKELETON) ||
-               is_specific_player_race(customer_ptr, RACE_ZOMBIE) ||
-               is_specific_player_race(customer_ptr, RACE_VAMPIRE) ||
-               is_specific_player_race(customer_ptr, RACE_SPECTRE);
-       return is_player_undead;
+       return player_race_life(customer_ptr, true) == PlayerRaceLife::UNDEAD;
 }
 #endif
 
index 5ec60d5..7da3c6e 100644 (file)
@@ -339,9 +339,7 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
 
         if (creature_ptr->food < PY_FOOD_ALERT) /* Hungry */
             msg_print(_("あなたの飢えは新鮮な血によってのみ満たされる!", "Your hunger can only be satisfied with fresh blood!"));
-    } else if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ZOMBIE)
-        || is_specific_player_race(creature_ptr, RACE_ENT) || is_specific_player_race(creature_ptr, RACE_BALROG)
-        || is_specific_player_race(creature_ptr, RACE_ANDROID) || is_specific_player_race(creature_ptr, RACE_SPECTRE)
+    } else if (player_race_life(creature_ptr) != PlayerRaceLife::LIVING
         || (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)) {
         msg_print(_("生者の食物はあなたにとってほとんど栄養にならない。", "The food of mortals is poor sustenance for you."));
         set_food(creature_ptr, creature_ptr->food + ((o_ptr->pval) / 20));
index d1909be..4742e66 100644 (file)
@@ -122,7 +122,7 @@ void process_player_hp_mp(player_type *creature_ptr)
         take_hit(creature_ptr, DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"));
     }
 
-    if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
+    if (player_race_life(creature_ptr) == PlayerRaceLife::UNDEAD && player_race_has_flag(creature_ptr, TR_VUL_LITE)) {
         if (!is_in_dungeon(creature_ptr) && !has_resist_lite(creature_ptr) && !is_invuln(creature_ptr) && is_daytime()) {
             if ((creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) {
                 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
@@ -192,7 +192,7 @@ void process_player_hp_mp(player_type *creature_ptr)
         HIT_POINT damage;
         if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !has_immune_fire(creature_ptr)) {
             damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
-            if (is_specific_player_race(creature_ptr, RACE_ENT))
+            if (player_race_has_flag(creature_ptr, TR_VUL_FIRE))
                 damage += damage / 3;
             if (has_resist_fire(creature_ptr))
                 damage = damage / 3;
@@ -203,7 +203,7 @@ void process_player_hp_mp(player_type *creature_ptr)
         }
         if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !has_immune_elec(creature_ptr)) {
             damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
-            if (is_specific_player_race(creature_ptr, RACE_ANDROID))
+            if (player_race_has_flag(creature_ptr, TR_VUL_ELEC))
                 damage += damage / 3;
             if (has_resist_elec(creature_ptr))
                 damage = damage / 3;
@@ -214,6 +214,8 @@ void process_player_hp_mp(player_type *creature_ptr)
         }
         if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !has_immune_cold(creature_ptr)) {
             damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
+            if (player_race_has_flag(creature_ptr, TR_VUL_COLD))
+                damage += damage / 3;
             if (has_resist_cold(creature_ptr))
                 damage = damage / 3;
             if (is_oppose_cold(creature_ptr))
index 649b307..a9dc89f 100644 (file)
@@ -376,7 +376,7 @@ void effect_player_lite(player_type *target_ptr, effect_player_type *ep_ptr)
 
     ep_ptr->dam = ep_ptr->dam * calc_lite_damage_rate(target_ptr, CALC_RAND) / 100;
 
-    if (is_specific_player_race(target_ptr, RACE_VAMPIRE) || (target_ptr->mimic_form == MIMIC_VAMPIRE)) {
+    if (player_race_life(target_ptr) == PlayerRaceLife::UNDEAD && player_race_has_flag(target_ptr, TR_VUL_LITE)) {
         if (!check_multishadow(target_ptr))
             msg_print(_("光で肉体が焦がされた!", "The light scorches your flesh!"));
     }
index 7ebad85..733b707 100644 (file)
@@ -89,7 +89,7 @@ static void check_dark_resistance(player_type *target_ptr, msr_type *msr_ptr)
     if (msr_ptr->smart.has_not(SM::RES_DARK))
         return;
 
-    if (is_specific_player_race(target_ptr, RACE_VAMPIRE)) {
+    if (player_race_has_flag(target_ptr, TR_IM_DARK)) {
         msr_ptr->ability_flags.reset(RF_ABILITY::BR_DARK);
         msr_ptr->ability_flags.reset(RF_ABILITY::BA_DARK);
         return;
index 93b654f..5a0ffcd 100644 (file)
@@ -160,6 +160,12 @@ enum tr_type {
     TR_BERS_RAGE = 149, //!< 狂戦士化の発作
     TR_BRAND_MAGIC = 150, //!< 魔術属性
     TR_IMPACT = 151, //!< クリティカル率アップ / Increase critical hit ratio
+    TR_VUL_ACID = 152, //!< 酸弱点
+    TR_VUL_COLD = 153, //!< 冷気弱点
+    TR_VUL_ELEC = 154, //!< 電撃弱点
+    TR_VUL_FIRE = 155, //!< 火炎弱点
+    TR_VUL_LITE = 156, //!< 閃光弱点
+    TR_IM_DARK = 157, //!< 暗黒免疫
 
-    TR_FLAG_MAX = 152,
+    TR_FLAG_MAX = 158,
 };
index 08d00a0..6a60b39 100644 (file)
@@ -134,7 +134,7 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
 
     case GF_DARK:
         dam = dam * calc_dark_damage_rate(target_ptr, CALC_MAX) / 100;
-        if (is_specific_player_race(target_ptr, RACE_VAMPIRE) || (target_ptr->mimic_form == MIMIC_VAMPIRE) || target_ptr->wraith_form)
+        if (has_immune_dark(target_ptr) || target_ptr->wraith_form)
             ignore_wraith_form = TRUE;
         break;
 
index 1b5bf6a..415a88c 100644 (file)
@@ -6,50 +6,50 @@
 
 void set_element_resistance_info(player_type* creature_ptr, self_info_type* self_ptr)
 {
-    if (has_immune_acid(creature_ptr)) {
+    if (has_immune_acid(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは酸に対する完全なる免疫を持っている。", "You are completely immune to acid.");
-    } else if (has_resist_acid(creature_ptr) && is_oppose_acid(creature_ptr)) {
+    else if (has_resist_acid(creature_ptr) && is_oppose_acid(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは酸への強力な耐性を持っている。", "You resist acid exceptionally well.");
-    } else if (has_resist_acid(creature_ptr) || is_oppose_acid(creature_ptr)) {
+    else if (has_resist_acid(creature_ptr) || is_oppose_acid(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは酸への耐性を持っている。", "You are resistant to acid.");
-    }
 
-    if (has_immune_elec(creature_ptr)) {
+    if (player_race_has_flag(creature_ptr, TR_VUL_ACID) && !has_immune_acid(creature_ptr))
+        self_ptr->info[self_ptr->line++] = _("あなたは酸に弱い。", "You are susceptible to damage from acid.");
+
+    if (has_immune_elec(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは電撃に対する完全なる免疫を持っている。", "You are completely immune to lightning.");
-    } else if (has_resist_elec(creature_ptr) && is_oppose_elec(creature_ptr)) {
+    else if (has_resist_elec(creature_ptr) && is_oppose_elec(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは電撃への強力な耐性を持っている。", "You resist lightning exceptionally well.");
-    } else if (has_resist_elec(creature_ptr) || is_oppose_elec(creature_ptr)) {
+    else if (has_resist_elec(creature_ptr) || is_oppose_elec(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは電撃への耐性を持っている。", "You are resistant to lightning.");
-    }
-    if (is_specific_player_race(creature_ptr, RACE_ANDROID) && !has_immune_elec(creature_ptr)) {
+
+    if (player_race_has_flag(creature_ptr, TR_VUL_ELEC) && !has_immune_elec(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは電撃に弱い。", "You are susceptible to damage from lightning.");
-    }
 
-    if (has_immune_fire(creature_ptr)) {
+    if (has_immune_fire(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは火に対する完全なる免疫を持っている。", "You are completely immune to fire.");
-    } else if (has_resist_fire(creature_ptr) &&is_oppose_fire(creature_ptr)) {
+    else if (has_resist_fire(creature_ptr) && is_oppose_fire(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは火への強力な耐性を持っている。", "You resist fire exceptionally well.");
-    } else if (has_resist_fire(creature_ptr) || is_oppose_fire(creature_ptr)) {
+    else if (has_resist_fire(creature_ptr) || is_oppose_fire(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは火への耐性を持っている。", "You are resistant to fire.");
-    }
 
-    if (is_specific_player_race(creature_ptr, RACE_ENT) && !has_immune_fire(creature_ptr)) {
+    if (player_race_has_flag(creature_ptr, TR_VUL_FIRE) && !has_immune_fire(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは火に弱い。", "You are susceptible to damage from fire.");
-    }
 
-    if (has_immune_cold(creature_ptr)) {
+    if (has_immune_cold(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは冷気に対する完全なる免疫を持っている。", "You are completely immune to cold.");
-    } else if (has_resist_cold(creature_ptr) && is_oppose_cold(creature_ptr)) {
+    else if (has_resist_cold(creature_ptr) && is_oppose_cold(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは冷気への強力な耐性を持っている。", "You resist cold exceptionally well.");
-    } else if (has_resist_cold(creature_ptr) || is_oppose_cold(creature_ptr)) {
+    else if (has_resist_cold(creature_ptr) || is_oppose_cold(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは冷気への耐性を持っている。", "You are resistant to cold.");
-    }
 
-    if (has_resist_pois(creature_ptr) && is_oppose_pois(creature_ptr)) {
+    if (player_race_has_flag(creature_ptr, TR_VUL_COLD) && !has_immune_cold(creature_ptr))
+        self_ptr->info[self_ptr->line++] = _("あなたは冷気に弱い。", "You are susceptible to damage from cold.");
+
+    if (has_resist_pois(creature_ptr) && is_oppose_pois(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは毒への強力な耐性を持っている。", "You resist poison exceptionally well.");
-    } else if (has_resist_pois(creature_ptr) || is_oppose_pois(creature_ptr)) {
+    else if (has_resist_pois(creature_ptr) || is_oppose_pois(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは毒への耐性を持っている。", "You are resistant to poison.");
-    }
 }
 
 void set_high_resistance_info(player_type *creature_ptr, self_info_type *self_ptr)
@@ -57,11 +57,10 @@ void set_high_resistance_info(player_type *creature_ptr, self_info_type *self_pt
     if (has_resist_lite(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは閃光への耐性を持っている。", "You are resistant to bright light.");
 
-    if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || is_specific_player_race(creature_ptr, RACE_S_FAIRY)
-        || (creature_ptr->mimic_form == MIMIC_VAMPIRE))
+    if (has_vuln_lite(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは閃光に弱い。", "You are susceptible to damage from bright light.");
 
-    if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE) || creature_ptr->wraith_form)
+    if (has_immune_dark(creature_ptr) || creature_ptr->wraith_form)
         self_ptr->info[self_ptr->line++] = _("あなたは暗黒に対する完全なる免疫を持っている。", "You are completely immune to darkness.");
     else if (has_resist_dark(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたは暗黒への耐性を持っている。", "You are resistant to darkness.");
index 180c696..ebdbf4c 100644 (file)
@@ -131,15 +131,15 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
         }
 
         see_eldritch_horror(m_name, r_ptr);
-        if (is_specific_player_race(creature_ptr, RACE_IMP) || is_specific_player_race(creature_ptr, RACE_BALROG)
-            || (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON) || current_world_ptr->wizard)
+        switch (player_race_life(creature_ptr)) {
+        case PlayerRaceLife::DEMON:
             return;
-
-        if (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)
-            || (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)) {
+        case PlayerRaceLife::UNDEAD:
             if (saving_throw(25 + creature_ptr->lev))
                 return;
+            break;
+        default:
+            break;
         }
     } else if (!necro) {
         monster_race *r_ptr;
@@ -182,32 +182,17 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
         }
 
         feel_eldritch_horror(desc, r_ptr);
-        if (!creature_ptr->mimic_form) {
-            switch (creature_ptr->prace) {
-            case RACE_IMP:
-            case RACE_BALROG:
-                if (saving_throw(20 + creature_ptr->lev))
-                    return;
-                break;
-            case RACE_SKELETON:
-            case RACE_ZOMBIE:
-            case RACE_SPECTRE:
-            case RACE_VAMPIRE:
-                if (saving_throw(10 + creature_ptr->lev))
-                    return;
-                break;
-
-            default:
-                break;
-            }
-        } else {
-            if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON) {
-                if (saving_throw(20 + creature_ptr->lev))
-                    return;
-            } else if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD) {
-                if (saving_throw(10 + creature_ptr->lev))
-                    return;
-            }
+        switch (player_race_life(creature_ptr)) {
+        case PlayerRaceLife::DEMON:
+            if (saving_throw(20 + creature_ptr->lev))
+                return;
+            break;
+        case PlayerRaceLife::UNDEAD:
+            if (saving_throw(10 + creature_ptr->lev))
+                return;
+            break;
+        default:
+            break;
         }
     } else {
         msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
index 6b461e8..1b54b99 100644 (file)
@@ -22,6 +22,7 @@ const player_race mimic_info[MAX_MIMIC_FORMS] =
                0,  0, 0, 0,
                0,
                0x000000,
+               PlayerRaceLife::LIVING,
                { },
        },
        {
@@ -34,6 +35,7 @@ const player_race mimic_info[MAX_MIMIC_FORMS] =
                0,  0, 0, 0,
                5,
                0x000003,
+               PlayerRaceLife::DEMON,
                {
                        { TR_RES_FIRE },
                        { TR_RES_NETHER },
@@ -53,6 +55,7 @@ const player_race mimic_info[MAX_MIMIC_FORMS] =
                0,  0, 0, 0,
                20,
                0x000003,
+               PlayerRaceLife::DEMON,
                {
                        { TR_IM_FIRE },
                        { TR_RES_COLD },
@@ -83,10 +86,12 @@ const player_race mimic_info[MAX_MIMIC_FORMS] =
                0,  0, 0, 0,
                5,
                0x000005,
+               PlayerRaceLife::UNDEAD,
                {
                        { TR_RES_COLD },
                        { TR_RES_POIS },
-                       { TR_RES_DARK },
+                       { TR_VUL_LITE },
+                       { TR_IM_DARK },
                        { TR_RES_NETHER },
                        { TR_SEE_INVIS },
                        { TR_HOLD_EXP },
index 0b81d8a..521bb04 100644 (file)
@@ -101,3 +101,14 @@ void add_player_race_flags(player_type *creature_ptr, BIT_FLAGS *flags, bool bas
         add_flag(flags, cond.type);
     }
 }
+
+/*!
+ * @brief 種族の生命形態を返す
+ * @param creature_ptr プレイヤー情報への参照ポインタ
+ * @return 生命形態
+ */
+PlayerRaceLife player_race_life(player_type *creature_ptr, bool base_race)
+{
+    auto race_ptr = get_player_race_info(creature_ptr, base_race);
+    return race_ptr->life;
+}
index 6d7cad4..7e7b733 100644 (file)
 #define MIMIC_IS_DEMON 0x00000002
 #define MIMIC_IS_UNDEAD 0x00000004
 
+/*!
+ * プレイヤー種族の生命形態
+ */
+enum class PlayerRaceLife {
+    LIVING = 0, //生きている
+    UNDEAD = 1, //不死
+    DEMON = 2, //悪魔
+    NONLIVING = 3, //生きてない
+    MAX
+};
+
 struct player_race_condition {
     tr_type type{};
     PLAYER_LEVEL level{};
@@ -67,6 +78,7 @@ struct player_race {
     byte infra{}; //!< 赤外線視力 / Infra-vision range
 
     u32b choice{}; //!< 似つかわしい職業(ミミック時はミミック種族属性) / Legal class choices
+    PlayerRaceLife life{}; //!< 生命の形態
 
     std::vector<player_race_condition> extra_flags;
 };
@@ -78,3 +90,4 @@ SYMBOL_CODE get_summon_symbol_from_player(player_type *creature_ptr);
 bool is_specific_player_race(player_type *creature_ptr, player_race_type prace);
 bool player_race_has_flag(player_type *creature_ptr, tr_type flag, bool base_race = false);
 void add_player_race_flags(player_type *creature_ptr, BIT_FLAGS *flags, bool base_race = false);
+PlayerRaceLife player_race_life(player_type *creature_ptr, bool base_race = false);
index 3f9162b..88eec98 100644 (file)
@@ -401,6 +401,18 @@ BIT_FLAGS get_player_flags(player_type *creature_ptr, tr_type tr_flag)
         return check_equipment_flags(creature_ptr, tr_flag);
     case TR_IMPACT:
         return has_impact(creature_ptr);
+    case TR_VUL_ACID:
+        return has_vuln_acid(creature_ptr);
+    case TR_VUL_COLD:
+        return has_vuln_cold(creature_ptr);
+    case TR_VUL_ELEC:
+        return has_vuln_elec(creature_ptr);
+    case TR_VUL_FIRE:
+        return has_vuln_fire(creature_ptr);
+    case TR_VUL_LITE:
+        return has_vuln_lite(creature_ptr);
+    case TR_IM_DARK:
+        return has_immune_dark(creature_ptr);
 
     case TR_FLAG_MAX:
         break;
@@ -1327,10 +1339,14 @@ BIT_FLAGS has_resist_acid(player_type *creature_ptr)
 BIT_FLAGS has_vuln_acid(player_type *creature_ptr)
 {
     BIT_FLAGS result = 0L;
+
     if (creature_ptr->muta.has(MUTA::VULN_ELEM)) {
         result |= FLAG_CAUSE_MUTATION;
     }
 
+    if (player_race_has_flag(creature_ptr, TR_VUL_ACID))
+        result |= FLAG_CAUSE_RACE;
+
     if (creature_ptr->special_defense & KATA_KOUKIJIN) {
         result |= FLAG_CAUSE_BATTLE_FORM;
     }
@@ -1367,9 +1383,8 @@ BIT_FLAGS has_vuln_elec(player_type *creature_ptr)
         result |= FLAG_CAUSE_MUTATION;
     }
 
-    if (is_specific_player_race(creature_ptr, RACE_ANDROID)) {
+    if (player_race_has_flag(creature_ptr, TR_VUL_ELEC))
         result |= FLAG_CAUSE_RACE;
-    }
 
     if (creature_ptr->special_defense & KATA_KOUKIJIN) {
         result |= FLAG_CAUSE_BATTLE_FORM;
@@ -1403,13 +1418,13 @@ BIT_FLAGS has_resist_fire(player_type *creature_ptr)
 BIT_FLAGS has_vuln_fire(player_type *creature_ptr)
 {
     BIT_FLAGS result = 0L;
+
     if (creature_ptr->muta.has(MUTA::VULN_ELEM)) {
         result |= FLAG_CAUSE_MUTATION;
     }
 
-    if (is_specific_player_race(creature_ptr, RACE_ENT)) {
+    if (player_race_has_flag(creature_ptr, TR_VUL_FIRE))
         result |= FLAG_CAUSE_RACE;
-    }
 
     if (creature_ptr->special_defense & KATA_KOUKIJIN) {
         result |= FLAG_CAUSE_BATTLE_FORM;
@@ -1443,10 +1458,14 @@ BIT_FLAGS has_resist_cold(player_type *creature_ptr)
 BIT_FLAGS has_vuln_cold(player_type *creature_ptr)
 {
     BIT_FLAGS result = 0L;
+
     if (creature_ptr->muta.has(MUTA::VULN_ELEM)) {
         result |= FLAG_CAUSE_MUTATION;
     }
 
+    if (player_race_has_flag(creature_ptr, TR_VUL_COLD))
+        result |= FLAG_CAUSE_RACE;
+
     if (creature_ptr->special_defense & KATA_KOUKIJIN) {
         result |= FLAG_CAUSE_BATTLE_FORM;
     }
@@ -1551,10 +1570,9 @@ BIT_FLAGS has_resist_lite(player_type *creature_ptr)
 BIT_FLAGS has_vuln_lite(player_type *creature_ptr)
 {
     BIT_FLAGS result = 0L;
-    if (is_specific_player_race(creature_ptr, RACE_S_FAIRY) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
-        || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
+
+    if (player_race_has_flag(creature_ptr, TR_VUL_LITE))
         result |= FLAG_CAUSE_RACE;
-    }
 
     if (creature_ptr->wraith_form) {
         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
@@ -1885,9 +1903,8 @@ BIT_FLAGS has_immune_dark(player_type *creature_ptr)
 {
     BIT_FLAGS result = 0L;
 
-    if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
+    if (player_race_has_flag(creature_ptr, TR_IM_DARK))
         result |= FLAG_CAUSE_RACE;
-    }
 
     if (creature_ptr->wraith_form) {
         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
@@ -1977,11 +1994,7 @@ BIT_FLAGS has_lite(player_type *creature_ptr)
         result |= FLAG_CAUSE_PERSONALITY;
     }
 
-    if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
-        result |= FLAG_CAUSE_RACE;
-    }
-
-    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
+    if (player_race_has_flag(creature_ptr, TR_LITE_1))
         result |= FLAG_CAUSE_RACE;
 
     if (creature_ptr->ult_res) {
index 4c2f4ce..569012d 100644 (file)
@@ -233,10 +233,16 @@ PERCENTAGE calc_deathray_damage_rate(player_type *creature_ptr, rate_calc_type_m
 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
-    if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
-        per *= 2;
-    } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
-        per = per * 4 / 3;
+
+    if (player_race_has_flag(creature_ptr, TR_VUL_LITE)) {
+        switch (player_race_life(creature_ptr)) {
+        case PlayerRaceLife::UNDEAD:
+            per *= 2;
+            break;
+        default:
+            per = per * 4 / 3;
+            break;
+        }
     }
 
     if (has_resist_lite(creature_ptr)) {
@@ -257,9 +263,8 @@ PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode
 {
     PERCENTAGE per = 100;
 
-    if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE) || creature_ptr->wraith_form) {
+    if (has_immune_dark(creature_ptr))
         return 0;
-    }
 
     if (has_resist_dark(creature_ptr)) {
         per *= 400;
index 2806980..01fab47 100644 (file)
@@ -34,6 +34,7 @@ const player_race race_info[MAX_RACES] =
                66,  4, 150, 20,
                0,
                0x1FFFFFFF,
+               PlayerRaceLife::LIVING,
                {},
        },
        {
@@ -46,6 +47,7 @@ const player_race race_info[MAX_RACES] =
                62,  6, 100, 10,
                2,
                0x1E77E7FF,
+               PlayerRaceLife::LIVING,
         {},
     },
        {
@@ -58,6 +60,7 @@ const player_race race_info[MAX_RACES] =
                54,  4, 80,  6,
                3,
                0x1E77E75B,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_LITE },
                },
@@ -72,6 +75,7 @@ const player_race race_info[MAX_RACES] =
                33,  3, 50,  3,
                4,
                0x1F6FFC0B,
+               PlayerRaceLife::LIVING,
         {
                        { TR_HOLD_EXP },
                },
@@ -86,6 +90,7 @@ const player_race race_info[MAX_RACES] =
                39,  3, 75,  3,
                4,
                0x1F67D60F,
+               PlayerRaceLife::LIVING,
         {
                        { TR_FREE_ACT },
                },
@@ -100,6 +105,7 @@ const player_race race_info[MAX_RACES] =
                46,  3, 120, 10,
                5,
                0x11890005,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_BLIND },
                },
@@ -114,6 +120,7 @@ const player_race race_info[MAX_RACES] =
                62,  1, 120,  5,
                3,
                0x1DD8818D,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_DARK },
                },
@@ -128,6 +135,7 @@ const player_race race_info[MAX_RACES] =
                84,  8, 225, 40,
                3,
                0x00880005,
+               PlayerRaceLife::LIVING,
         {
                        { TR_SUST_STR },
                        { TR_REGEN, 15 },
@@ -146,6 +154,7 @@ const player_race race_info[MAX_RACES] =
                78,  6, 180, 15,
                0,
                0x1FFFF7FF,
+               PlayerRaceLife::LIVING,
         {
                        { TR_SUST_CON },
                        { TR_REGEN },
@@ -161,6 +170,7 @@ const player_race race_info[MAX_RACES] =
                82, 10, 180, 15,
                4,
                0x1F77E75B,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_LITE },
                        { TR_SEE_INVIS },
@@ -176,6 +186,7 @@ const player_race race_info[MAX_RACES] =
                78,  6, 190, 15,
                0,
                0x05C0A09D,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_FEAR },
                },
@@ -190,6 +201,7 @@ const player_race race_info[MAX_RACES] =
                80,  8, 235, 60,
                3,
                0x10A80407,
+               PlayerRaceLife::LIVING,
         {
                        { TR_SUST_STR },
                        { TR_RES_DARK },
@@ -205,6 +217,7 @@ const player_race race_info[MAX_RACES] =
                80, 10, 240, 64,
                3,
                0x08880011,
+               PlayerRaceLife::LIVING,
         {
                        { TR_SUST_STR },
                        { TR_RES_SHARDS },
@@ -220,6 +233,7 @@ const player_race race_info[MAX_RACES] =
                99, 11, 250, 86,
                0,
                0x123D4727,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_CHAOS },
                },
@@ -234,6 +248,7 @@ const player_race race_info[MAX_RACES] =
                80,  8, 235, 60,
                1,
                0x00888005,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_SOUND },
                },
@@ -248,6 +263,7 @@ const player_race race_info[MAX_RACES] =
                50,  3, 75,  3,
                2,
                0x1667360F,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_ACID },
                        { TR_IM_ACID, 20 },
@@ -263,6 +279,7 @@ const player_race race_info[MAX_RACES] =
                54,  3, 70,  4,
                2,
                0x004D8011,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_ACID },
                        { TR_RES_CONF },
@@ -279,6 +296,7 @@ const player_race race_info[MAX_RACES] =
                55,  1, 100,  5,
                3,
                0x1444A009,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_POIS },
                },
@@ -293,6 +311,7 @@ const player_race race_info[MAX_RACES] =
                40,  3, 78,  3,
                5,
                0x1569040F,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_DARK },
                        { TR_RES_DISEN },
@@ -308,6 +327,7 @@ const player_race race_info[MAX_RACES] =
                54,  4, 80,  6,
                5,
                0x1E77C7DF,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_DARK },
                        { TR_SEE_INVIS, 20 },
@@ -323,6 +343,7 @@ const player_race race_info[MAX_RACES] =
                72,  1, 130,  5,
                2,
                0x07FFE757,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_FIRE, 5 },
                        { TR_RES_COLD, 10 },
@@ -342,6 +363,7 @@ const player_race race_info[MAX_RACES] =
                63,  6, 112, 10,
                4,
                0x12334746,
+               PlayerRaceLife::LIVING,
         {
                        { TR_SUST_INT },
                        { TR_SUST_WIS },
@@ -359,6 +381,7 @@ const player_race race_info[MAX_RACES] =
                64,  1, 120,  5,
                3,
                0x1DB537CB,
+               PlayerRaceLife::DEMON,
         {
                        { TR_RES_FIRE },
                        { TR_SEE_INVIS, 10 },
@@ -374,6 +397,7 @@ const player_race race_info[MAX_RACES] =
                62,  1, 180,  6,
                4,
                0x00800001,
+               PlayerRaceLife::NONLIVING,
         {
                        { TR_RES_POIS },
                        { TR_SEE_INVIS },
@@ -392,6 +416,7 @@ const player_race race_info[MAX_RACES] =
                66,  4, 50, 5,
                2,
                0x0234070F,
+               PlayerRaceLife::UNDEAD,
                {
                        { TR_RES_COLD, 10 },
                        { TR_RES_POIS },
@@ -410,6 +435,7 @@ const player_race race_info[MAX_RACES] =
                66, 4, 100, 20,
                2,
                0x00800001,
+               PlayerRaceLife::UNDEAD,
                {
                        { TR_RES_COLD, 5 },
                        { TR_RES_POIS },
@@ -429,12 +455,12 @@ const player_race race_info[MAX_RACES] =
                66,  4, 150, 20,
                5,
                0x067DC7FF,
+               PlayerRaceLife::UNDEAD,
                {
-                       // { TR_VUL_LITE }, (予定)
-                       // { TR_IM_DARK }, (予定)
                        { TR_RES_COLD },
                        { TR_RES_POIS },
-                       { TR_RES_DARK },
+                       { TR_VUL_LITE },
+                       { TR_IM_DARK },
                        { TR_RES_NETHER },
                        { TR_HOLD_EXP },
                        { TR_LITE_1, 1, CLASS_NINJA, true },
@@ -450,6 +476,7 @@ const player_race race_info[MAX_RACES] =
                66, 4, 100, 20,
                5,
                0x0631474A,
+               PlayerRaceLife::UNDEAD,
                {
                        { TR_RES_COLD },
                        { TR_RES_POIS },
@@ -472,6 +499,7 @@ const player_race race_info[MAX_RACES] =
                29,  2, 65,  2,
                4,
                0x1623F65E,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_LITE },
                        { TR_LEVITATION },
@@ -488,6 +516,7 @@ const player_race race_info[MAX_RACES] =
                61,  6, 120, 15,
                0,
                0x057887CF,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_CONF },
                        { TR_RES_SOUND },
@@ -503,8 +532,9 @@ const player_race race_info[MAX_RACES] =
                99, 11, 250, 45,
                  0,
                0x10010005,
+               PlayerRaceLife::LIVING,
         {
-                       // { TR_VUL_FIRE } (予定)
+                       { TR_VUL_FIRE }
                },
     },
        {
@@ -517,6 +547,7 @@ const player_race race_info[MAX_RACES] =
                78,  6, 180, 15,
                3,
                0x1779F777,
+               PlayerRaceLife::LIVING,
         {
                        { TR_SEE_INVIS },
                        { TR_LEVITATION },
@@ -532,6 +563,7 @@ const player_race race_info[MAX_RACES] =
                80, 10, 240, 64,
                5,
                0x07EDC4DB,
+               PlayerRaceLife::DEMON,
         {
                        { TR_RES_FIRE },
                        { TR_RES_NETHER },
@@ -549,6 +581,7 @@ const player_race race_info[MAX_RACES] =
                78,  6, 180, 15,
                0,
                0x1FFFF7FF,
+               PlayerRaceLife::LIVING,
         {
                        { TR_SUST_CON },
                },
@@ -563,8 +596,9 @@ const player_race race_info[MAX_RACES] =
                 73,  8, 80, 15,
                  4,
                0x1E33C7DF,
+               PlayerRaceLife::LIVING,
         {
-                       // { TR_VUL_LITE }, (予定)
+                       { TR_VUL_LITE },
                        { TR_LEVITATION },
                },
     },
@@ -578,6 +612,7 @@ const player_race race_info[MAX_RACES] =
                44,  4, 130, 20,
                0,
                0x0C18B7AD,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_CONF },
                },
@@ -592,8 +627,9 @@ const player_race race_info[MAX_RACES] =
                66, 12, 220, 64,
                0,
                0x00800001,
+               PlayerRaceLife::NONLIVING,
         {
-                       // { TR_VUL_ELEC }, (予定)
+                       { TR_VUL_ELEC },
                        { TR_RES_POIS },
                        { TR_FREE_ACT },
                        { TR_HOLD_EXP },
@@ -610,6 +646,7 @@ const player_race race_info[MAX_RACES] =
                62,  6, 100, 10,
                2,
                0x1E77E7FF,
+               PlayerRaceLife::LIVING,
         {
                        { TR_RES_WATER },
                },
index 6750443..964f772 100644 (file)
@@ -34,7 +34,7 @@ void player_immunity(player_type *creature_ptr, BIT_FLAGS *flags)
 
     if (is_specific_player_race(creature_ptr, RACE_SPECTRE))
         add_flag(flags, TR_RES_NETHER);
-    if (creature_ptr->mimic_form == MIMIC_VAMPIRE || is_specific_player_race(creature_ptr, RACE_VAMPIRE))
+    if (player_race_has_flag(creature_ptr, TR_IM_DARK))
         add_flag(flags, TR_RES_DARK);
 
     if (creature_ptr->pclass == CLASS_ELEMENTALIST) {
@@ -126,11 +126,14 @@ void player_vulnerability_flags(player_type *creature_ptr, BIT_FLAGS *flags)
                add_flag(flags, TR_RES_COLD);
        }
 
-       if (is_specific_player_race(creature_ptr, RACE_ANDROID))
-               add_flag(flags, TR_RES_ELEC);
-       if (is_specific_player_race(creature_ptr, RACE_ENT))
-               add_flag(flags, TR_RES_FIRE);
-       if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || is_specific_player_race(creature_ptr, RACE_S_FAIRY) ||
-               (creature_ptr->mimic_form == MIMIC_VAMPIRE))
-               add_flag(flags, TR_RES_LITE);
+       if (player_race_has_flag(creature_ptr, TR_VUL_ACID))
+            add_flag(flags, TR_RES_ACID);
+    if (player_race_has_flag(creature_ptr, TR_VUL_COLD))
+        add_flag(flags, TR_RES_COLD);
+    if (player_race_has_flag(creature_ptr, TR_VUL_ELEC))
+        add_flag(flags, TR_RES_ELEC);
+    if (player_race_has_flag(creature_ptr, TR_VUL_FIRE))
+        add_flag(flags, TR_RES_FIRE);
+    if (player_race_has_flag(creature_ptr, TR_VUL_LITE))
+        add_flag(flags, TR_RES_LITE);
 }
index 3147601..b4fa4e0 100644 (file)
@@ -158,7 +158,7 @@ concptr do_nature_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mod
             if (cast) {
                 lite_area(caster_ptr, damroll(dice, sides), rad);
 
-                if ((is_specific_player_race(caster_ptr, RACE_VAMPIRE) || (caster_ptr->mimic_form == MIMIC_VAMPIRE)) && !has_resist_lite(caster_ptr)) {
+                if (player_race_life(caster_ptr) == PlayerRaceLife::UNDEAD && player_race_has_flag(caster_ptr, TR_VUL_LITE) && !has_resist_lite(caster_ptr)) {
                     msg_print(_("日の光があなたの肉体を焦がした!", "The daylight scorches your flesh!"));
                     take_hit(caster_ptr, DAMAGE_NOESCAPE, damroll(2, 2), _("日の光", "daylight"));
                 }
@@ -623,7 +623,7 @@ concptr do_nature_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mod
                 chg_virtue(caster_ptr, V_ENLIGHTEN, 1);
                 wiz_lite(caster_ptr, FALSE);
 
-                if ((is_specific_player_race(caster_ptr, RACE_VAMPIRE) || (caster_ptr->mimic_form == MIMIC_VAMPIRE)) && !has_resist_lite(caster_ptr)) {
+                if (player_race_life(caster_ptr) == PlayerRaceLife::UNDEAD && player_race_has_flag(caster_ptr, TR_VUL_LITE) && !has_resist_lite(caster_ptr)) {
                     msg_print(_("日光があなたの肉体を焦がした!", "The sunlight scorches your flesh!"));
                     take_hit(caster_ptr, DAMAGE_NOESCAPE, 50, _("日光", "sunlight"));
                 }