OSDN Git Service

[feature] ソースファイルをC++に対応
[hengbandforosx/hengbandosx.git] / src / object / warning.c
index 30a1200..2771ee7 100644 (file)
@@ -1,5 +1,5 @@
 #include "object/warning.h"
-#include "art-definition/art-sword-types.h"
+#include "artifact/fixed-art-types.h"
 #include "core/asking-player.h"
 #include "core/disturbance.h"
 #include "dungeon/dungeon-flag-types.h"
@@ -29,9 +29,9 @@
 #include "player/mimic-info-table.h"
 #include "player/player-class.h"
 #include "player/player-race-types.h"
-#include "player/special-defense-types.h"
 #include "player/player-status-flags.h"
 #include "player/player-status-resist.h"
+#include "player/special-defense-types.h"
 #include "spell/spell-types.h"
 #include "status/element-resistance.h"
 #include "system/floor-type-definition.h"
@@ -47,7 +47,7 @@
  */
 object_type *choose_warning_item(player_type *creature_ptr)
 {
-    int choices[INVEN_TOTAL - INVEN_RARM];
+    int choices[INVEN_TOTAL - INVEN_MAIN_HAND];
 
     /* Paranoia -- Player has no warning ability */
     if (!creature_ptr->warning)
@@ -55,7 +55,7 @@ object_type *choose_warning_item(player_type *creature_ptr)
 
     /* Search Inventory */
     int number = 0;
-    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
         BIT_FLAGS flgs[TR_FLAG_SIZE];
         object_type *o_ptr = &creature_ptr->inventory_list[i];
 
@@ -88,7 +88,7 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
     /* Vulnerability, resistance and immunity */
     switch (typ) {
     case GF_ELEC:
-        if (is_immune_elec(target_ptr)) {
+        if (has_immune_elec(target_ptr)) {
             ignore_wraith_form = TRUE;
         }
         dam = dam * calc_elec_damage_rate(target_ptr) / 100;
@@ -99,7 +99,7 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
         break;
 
     case GF_ACID:
-        if (is_immune_acid(target_ptr)) {
+        if (has_immune_acid(target_ptr)) {
             ignore_wraith_form = TRUE;
         }
         dam = dam * calc_acid_damage_rate(target_ptr) / 100;
@@ -107,27 +107,25 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
 
     case GF_COLD:
     case GF_ICE:
-        if (is_immune_cold(target_ptr)) {
+        if (has_immune_cold(target_ptr)) {
             ignore_wraith_form = TRUE;
         }
         dam = dam * calc_cold_damage_rate(target_ptr) / 100;
         break;
 
     case GF_FIRE:
-        if (is_immune_fire(target_ptr)) {
-            dam = 0;
+        if (has_immune_fire(target_ptr)) {
             ignore_wraith_form = TRUE;
-            break;
         }
         dam = dam * calc_fire_damage_rate(target_ptr) / 100;
+        break;
 
     case GF_PSY_SPEAR:
         ignore_wraith_form = TRUE;
         break;
 
     case GF_ARROW:
-        if (!target_ptr->blind
-            && (has_invuln_arrow(target_ptr))) {
+        if (!target_ptr->blind && (has_invuln_arrow(target_ptr))) {
             dam = 0;
             ignore_wraith_form = TRUE;
         }
@@ -172,23 +170,19 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
         break;
 
     case GF_NEXUS:
-        if (target_ptr->resist_nexus)
-            dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
+        dam = dam * calc_nexus_damage_rate(target_ptr, CALC_MAX) / 100;
         break;
 
     case GF_TIME:
-        if (target_ptr->resist_time)
-            dam /= 2; /* Worst case of 4 / (d4 + 7) */
+        dam = dam * calc_time_damage_rate(target_ptr, CALC_MAX) / 100;
         break;
 
     case GF_GRAVITY:
-        if (target_ptr->levitation)
-            dam = (dam * 2) / 3;
+        dam = dam * calc_gravity_damage_rate(target_ptr, CALC_MAX) / 100;
         break;
 
     case GF_ROCKET:
-        if (target_ptr->resist_shard)
-            dam /= 2;
+        dam = dam * calc_rocket_damage_rate(target_ptr, CALC_MAX) / 100;
         break;
 
     case GF_NUKE:
@@ -196,27 +190,9 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
         break;
 
     case GF_DEATH_RAY:
-        if (target_ptr->mimic_form) {
-            if (mimic_info[target_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) {
-                dam = 0;
-                ignore_wraith_form = TRUE;
-            }
-
-            break;
-        }
-
-        switch (target_ptr->prace) {
-        case RACE_GOLEM:
-        case RACE_SKELETON:
-        case RACE_ZOMBIE:
-        case RACE_VAMPIRE:
-        case RACE_BALROG:
-        case RACE_SPECTRE:
-            dam = 0;
+        dam = dam * calc_deathray_damage_rate(target_ptr, CALC_MAX) / 100;
+        if (dam == 0)
             ignore_wraith_form = TRUE;
-            break;
-        }
-
         break;
 
     case GF_HOLY_FIRE: