summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabrahamwl <abrahamwl@gmail.com>2009-10-31 08:39:53 -0700
committerRobert Vollmert <rvollmert@gmx.net>2009-10-31 17:31:05 +0100
commit09687dbfa8bc4df93dd243e4c291a1fad58f7470 (patch)
treece71ea575914510913a171a68b295197d7b7376f
parentc1d8dc0f1c7cfa48c46d7fe34c558a1d8f0ff586 (diff)
downloadcrawl-ref-09687dbfa8bc4df93dd243e4c291a1fad58f7470.tar.gz
crawl-ref-09687dbfa8bc4df93dd243e4c291a1fad58f7470.zip
Combine mons_res_foo(monsters *m) into monsters::res_foo()
...and replace all references to mons_res_foo() with res_foo(). Where "foo" is one of the many different things monsters can resist that happened to have a function of that format. TGfR! (Thank God for Regex!) Signed-off-by: Robert Vollmert <rvollmert@gmx.net>
-rw-r--r--crawl-ref/source/beam.cc44
-rw-r--r--crawl-ref/source/debug.cc16
-rw-r--r--crawl-ref/source/effects.cc2
-rw-r--r--crawl-ref/source/mon-util.cc453
-rw-r--r--crawl-ref/source/mon-util.h14
-rw-r--r--crawl-ref/source/monster.h1
-rw-r--r--crawl-ref/source/monstuff.cc32
-rw-r--r--crawl-ref/source/religion.cc2
-rw-r--r--crawl-ref/source/spells2.cc6
-rw-r--r--crawl-ref/source/spells4.cc6
10 files changed, 260 insertions, 316 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index c129785ddc..12510875e4 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2266,7 +2266,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted,
case BEAM_ACID:
hurted = resist_adjust_damage(monster, pbolt.flavour,
- mons_res_acid(monster),
+ monster->res_acid(),
hurted, true);
if (!hurted)
{
@@ -2281,7 +2281,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted,
case BEAM_POISON:
{
- int res = mons_res_poison(monster);
+ int res = monster->res_poison();
hurted = resist_adjust_damage(monster, pbolt.flavour, res,
hurted, true);
if (!hurted && res > 0)
@@ -2301,7 +2301,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted,
case BEAM_POISON_ARROW:
hurted = resist_adjust_damage(monster, pbolt.flavour,
- mons_res_poison(monster),
+ monster->res_poison(),
hurted);
if (hurted < original)
{
@@ -2321,7 +2321,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted,
break;
case BEAM_NEG:
- if (mons_res_negative_energy(monster) == 3)
+ if (monster->res_negative_energy() == 3)
{
if (doFlavouredEffects)
simple_monster_message(monster, " completely resists.");
@@ -2345,7 +2345,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted,
break;
case BEAM_MIASMA:
- if (mons_res_rotting(monster))
+ if (monster->res_rotting())
{
if (doFlavouredEffects)
simple_monster_message(monster, " completely resists.");
@@ -2425,7 +2425,7 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted,
break;
case BEAM_HELLFIRE:
- resist = mons_res_fire(monster);
+ resist = monster->res_fire();
if (resist > 2)
{
if (doFlavouredEffects)
@@ -2641,12 +2641,12 @@ bool curare_hits_monster(actor *agent, monsters *monster, kill_category who,
int hurted = 0;
- if (!mons_res_asphyx(monster))
+ if (!monster->res_asphyx())
{
hurted = roll_dice(2, 6);
// Note that the hurtage is halved by poison resistance.
- if (mons_res_poison(monster) > 0)
+ if (monster->res_poison() > 0)
hurted /= 2;
if (hurted)
@@ -2673,7 +2673,7 @@ bool poison_monster(monsters *monster, kill_category who, int levels,
if (!monster->alive())
return (false);
- if ((!force && mons_res_poison(monster) > 0) || levels <= 0)
+ if ((!force && monster->res_poison() > 0) || levels <= 0)
return (false);
const mon_enchant old_pois = monster->get_ench(ENCH_POISON);
@@ -2706,7 +2706,7 @@ bool miasma_monster(monsters *monster, kill_category who)
if (!monster->alive())
return (false);
- if (mons_res_rotting(monster))
+ if (monster->res_rotting())
return (false);
bool success = poison_monster(monster, who);
@@ -2737,7 +2737,7 @@ bool napalm_monster(monsters *monster, kill_category who, int levels,
if (!monster->alive())
return (false);
- if (mons_res_sticky_flame(monster) || levels <= 0)
+ if (monster->res_sticky_flame() || levels <= 0)
return (false);
const mon_enchant old_flame = monster->get_ench(ENCH_STICKY_FLAME);
@@ -3351,28 +3351,28 @@ bool bolt::is_harmless(const monsters *mon) const
return (mon->res_holy_energy(agent()) > 0);
case BEAM_STEAM:
- return (mons_res_steam(mon) >= 3);
+ return (mon->res_steam() >= 3);
case BEAM_FIRE:
- return (mons_res_fire(mon) >= 3);
+ return (mon->res_fire() >= 3);
case BEAM_COLD:
- return (mons_res_cold(mon) >= 3);
+ return (mon->res_cold() >= 3);
case BEAM_MIASMA:
- return (mons_res_rotting(mon));
+ return (mon->res_rotting());
case BEAM_NEG:
- return (mons_res_negative_energy(mon) == 3);
+ return (mon->res_negative_energy() == 3);
case BEAM_ELECTRICITY:
- return (mons_res_elec(mon) >= 3);
+ return (mon->res_elec() >= 3);
case BEAM_POISON:
- return (mons_res_poison(mon) >= 3);
+ return (mon->res_poison() >= 3);
case BEAM_ACID:
- return (mons_res_acid(mon) >= 3);
+ return (mon->res_acid() >= 3);
default:
return (false);
@@ -4858,13 +4858,13 @@ bool _ench_flavour_affects_monster(beam_type flavour, const monsters* mon)
break;
case BEAM_PAIN:
- rc = !mons_res_negative_energy(mon);
+ rc = !mon->res_negative_energy();
break;
case BEAM_SLEEP:
rc = !mon->has_ench(ENCH_SLEEP_WARY) // slept recently
&& mons_holiness(mon) == MH_NATURAL // no unnatural
- && mons_res_cold(mon) <= 0; // can't be hibernated
+ && mon->res_cold() <= 0; // can't be hibernated
break;
case BEAM_PORKALATOR:
@@ -5723,7 +5723,7 @@ bool bolt::nasty_to(const monsters *mon) const
// pain / agony
if (flavour == BEAM_PAIN)
- return (!mons_res_negative_energy(mon));
+ return (!mon->res_negative_energy());
// control demon
if (flavour == BEAM_ENSLAVE_DEMON)
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index de076ea193..b597b65367 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -2663,14 +2663,14 @@ void debug_stethoscope(int mon)
// Print resistances.
mprf(MSGCH_DIAGNOSTICS, "resist: fire=%d cold=%d elec=%d pois=%d neg=%d "
"acid=%d sticky=%s rot=%s",
- mons_res_fire( &mons ),
- mons_res_cold( &mons ),
- mons_res_elec( &mons ),
- mons_res_poison( &mons ),
- mons_res_negative_energy( &mons ),
- mons_res_acid( &mons ),
- mons_res_sticky_flame( &mons ) ? "yes" : "no",
- mons_res_rotting( &mons ) ? "yes" : "no");
+ mons.res_fire(),
+ mons.res_cold(),
+ mons.res_elec(),
+ mons.res_poison(),
+ mons.res_negative_energy(),
+ mons.res_acid(),
+ mons.res_sticky_flame() ? "yes" : "no",
+ mons.res_rotting() ? "yes" : "no");
mprf(MSGCH_DIAGNOSTICS, "ench: %s",
mons.describe_enchantments().c_str());
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 6f64234350..ffca8c92c9 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -296,7 +296,7 @@ int torment_monsters(coord_def where, int pow, int caster, actor *attacker)
if (monster == NULL)
return (retval);
- if (!monster->alive() || mons_res_negative_energy(monster) == 3)
+ if (!monster->alive() || monster->res_negative_energy() == 3)
return (retval);
int hploss = std::max(0, monster->hit_points / 2 - 1);
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 2741b34707..ce918eee26 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1247,243 +1247,6 @@ bool check_mons_resist_magic( const monsters *monster, int pow )
return (mrch2 < mrchance);
}
-int mons_res_elec(const monsters *mon)
-{
- // This is a variable, not a player_xx() function, so can be above 1.
- int u = 0;
-
- u += get_mons_resists(mon).elec;
-
- // Don't bother checking equipment if the monster can't use it.
- if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
- {
- u += _scan_mon_inv_randarts(mon, ARTP_ELECTRICITY);
-
- // No ego armour, but storm dragon.
- const int armour = mon->inv[MSLOT_ARMOUR];
- if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR
- && mitm[armour].sub_type == ARM_STORM_DRAGON_ARMOUR)
- {
- u += 1;
- }
- }
-
- // Monsters can legitimately get multiple levels of electricity resistance.
-
- return (u);
-}
-
-int mons_res_acid(const monsters *mon)
-{
- return (get_mons_resists(mon).acid);
-}
-
-int mons_res_poison(const monsters *mon)
-{
- int u = get_mons_resists(mon).poison;
-
- if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
- {
- u += _scan_mon_inv_randarts( mon, ARTP_POISON );
-
- const int armour = mon->inv[MSLOT_ARMOUR];
- const int shield = mon->inv[MSLOT_SHIELD];
-
- if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
- {
- // intrinsic armour abilities
- switch (mitm[armour].sub_type)
- {
- case ARM_SWAMP_DRAGON_ARMOUR: u += 1; break;
- case ARM_GOLD_DRAGON_ARMOUR: u += 1; break;
- default: break;
- }
-
- // ego armour resistance
- if (get_armour_ego_type(mitm[armour]) == SPARM_POISON_RESISTANCE)
- u += 1;
- }
-
- if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
- {
- // ego armour resistance
- if (get_armour_ego_type(mitm[shield]) == SPARM_POISON_RESISTANCE)
- u += 1;
- }
- }
-
- // Monsters can legitimately get multiple levels of poison resistance.
-
- return (u);
-}
-
-int mons_res_asphyx(const monsters *mon)
-{
- int res = get_mons_resists(mon).asphyx;
- const mon_holy_type holiness = mons_holiness(mon);
- if (mons_is_unholy(mon)
- || holiness == MH_NONLIVING
- || holiness == MH_PLANT)
- {
- res += 1;
- }
- return (res);
-}
-
-int mons_res_sticky_flame(const monsters *mon)
-{
- int res = get_mons_resists(mon).sticky_flame;
- if (mon->has_equipped(EQ_BODY_ARMOUR, ARM_MOTTLED_DRAGON_ARMOUR))
- res += 1;
- return (res);
-}
-
-int mons_res_rotting(const monsters *mon)
-{
- int res = get_mons_resists(mon).rotting;
- if (mons_holiness(mon) != MH_NATURAL)
- res += 1;
- return (res);
-}
-
-int mons_res_steam(const monsters *mon)
-{
- int res = get_mons_resists(mon).steam;
- if (mon->has_equipped(EQ_BODY_ARMOUR, ARM_STEAM_DRAGON_ARMOUR))
- res += 3;
- return (res + mons_res_fire(mon) / 2);
-}
-
-int mons_res_fire(const monsters *mon)
-{
- const mon_resist_def res = get_mons_resists(mon);
-
- int u = std::min(res.fire + res.hellfire * 3, 3);
-
- if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
- {
- u += _scan_mon_inv_randarts(mon, ARTP_FIRE);
-
- const int armour = mon->inv[MSLOT_ARMOUR];
- const int shield = mon->inv[MSLOT_SHIELD];
-
- if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
- {
- // intrinsic armour abilities
- switch (mitm[armour].sub_type)
- {
- case ARM_DRAGON_ARMOUR: u += 2; break;
- case ARM_GOLD_DRAGON_ARMOUR: u += 1; break;
- case ARM_ICE_DRAGON_ARMOUR: u -= 1; break;
- default: break;
- }
-
- // check ego resistance
- const int ego = get_armour_ego_type(mitm[armour]);
- if (ego == SPARM_FIRE_RESISTANCE || ego == SPARM_RESISTANCE)
- u += 1;
- }
-
- if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
- {
- // check ego resistance
- const int ego = get_armour_ego_type(mitm[shield]);
- if (ego == SPARM_FIRE_RESISTANCE || ego == SPARM_RESISTANCE)
- u += 1;
- }
- }
-
- if (u < -3)
- u = -3;
- else if (u > 3)
- u = 3;
-
- return (u);
-}
-
-int mons_res_cold(const monsters *mon)
-{
- int u = get_mons_resists(mon).cold;
-
- if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
- {
- u += _scan_mon_inv_randarts(mon, ARTP_COLD);
-
- const int armour = mon->inv[MSLOT_ARMOUR];
- const int shield = mon->inv[MSLOT_SHIELD];
-
- if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
- {
- // intrinsic armour abilities
- switch (mitm[armour].sub_type)
- {
- case ARM_ICE_DRAGON_ARMOUR: u += 2; break;
- case ARM_GOLD_DRAGON_ARMOUR: u += 1; break;
- case ARM_DRAGON_ARMOUR: u -= 1; break;
- default: break;
- }
-
- // check ego resistance
- const int ego = get_armour_ego_type(mitm[armour]);
- if (ego == SPARM_COLD_RESISTANCE || ego == SPARM_RESISTANCE)
- u += 1;
- }
-
- if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
- {
- // check ego resistance
- const int ego = get_armour_ego_type(mitm[shield]);
- if (ego == SPARM_COLD_RESISTANCE || ego == SPARM_RESISTANCE)
- u += 1;
- }
- }
-
- if (u < -3)
- u = -3;
- else if (u > 3)
- u = 3;
-
- return (u);
-}
-
-int mons_res_negative_energy(const monsters *mon)
-{
- if (mons_holiness(mon) != MH_NATURAL
- || mon->type == MONS_SHADOW_DRAGON)
- {
- return (3);
- }
-
- int u = 0;
-
- if (mons_itemuse(mon) >= MONUSE_STARTING_EQUIPMENT)
- {
- u += _scan_mon_inv_randarts(mon, ARTP_NEGATIVE_ENERGY);
-
- const int armour = mon->inv[MSLOT_ARMOUR];
- const int shield = mon->inv[MSLOT_SHIELD];
-
- if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
- {
- // check for ego resistance
- if (get_armour_ego_type(mitm[armour]) == SPARM_POSITIVE_ENERGY)
- u += 1;
- }
-
- if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
- {
- // check for ego resistance
- if (get_armour_ego_type(mitm[shield]) == SPARM_POSITIVE_ENERGY)
- u += 1;
- }
- }
-
- if (u > 3)
- u = 3;
-
- return (u);
-}
-
bool mons_is_holy(const monsters *mon)
{
return (mons_holiness(mon) == MH_HOLY);
@@ -3812,7 +3575,7 @@ bool monsters::can_drown() const
// Mummies can fall apart in water or be incinerated in lava.
// Ghouls, vampires, and demons can drown in water or lava. Others
// just "sink like a rock", to never be seen again.
- return (!mons_res_asphyx(this)
+ return (!res_asphyx()
|| mons_genus(type) == MONS_MUMMY
|| mons_genus(type) == MONS_GHOUL
|| mons_genus(type) == MONS_VAMPIRE
@@ -6078,42 +5841,196 @@ mon_holy_type monsters::holiness() const
int monsters::res_fire() const
{
- return (mons_res_fire(this));
+ const mon_resist_def res = get_mons_resists(this);
+
+ int u = std::min(res.fire + res.hellfire * 3, 3);
+
+ if (mons_itemuse(this) >= MONUSE_STARTING_EQUIPMENT)
+ {
+ u += _scan_mon_inv_randarts(this, ARTP_FIRE);
+
+ const int armour = inv[MSLOT_ARMOUR];
+ const int shield = inv[MSLOT_SHIELD];
+
+ if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
+ {
+ // intrinsic armour abilities
+ switch (mitm[armour].sub_type)
+ {
+ case ARM_DRAGON_ARMOUR: u += 2; break;
+ case ARM_GOLD_DRAGON_ARMOUR: u += 1; break;
+ case ARM_ICE_DRAGON_ARMOUR: u -= 1; break;
+ default: break;
+ }
+
+ // check ego resistance
+ const int ego = get_armour_ego_type(mitm[armour]);
+ if (ego == SPARM_FIRE_RESISTANCE || ego == SPARM_RESISTANCE)
+ u += 1;
+ }
+
+ if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
+ {
+ // check ego resistance
+ const int ego = get_armour_ego_type(mitm[shield]);
+ if (ego == SPARM_FIRE_RESISTANCE || ego == SPARM_RESISTANCE)
+ u += 1;
+ }
+ }
+
+ if (u < -3)
+ u = -3;
+ else if (u > 3)
+ u = 3;
+
+ return (u);
}
int monsters::res_steam() const
{
- return (mons_res_steam(this));
+ int res = get_mons_resists(this).steam;
+ if (has_equipped(EQ_BODY_ARMOUR, ARM_STEAM_DRAGON_ARMOUR))
+ res += 3;
+ return (res + res_fire() / 2);
}
int monsters::res_cold() const
{
- return (mons_res_cold(this));
+ int u = get_mons_resists(this).cold;
+
+ if (mons_itemuse(this) >= MONUSE_STARTING_EQUIPMENT)
+ {
+ u += _scan_mon_inv_randarts(this, ARTP_COLD);
+
+ const int armour = inv[MSLOT_ARMOUR];
+ const int shield = inv[MSLOT_SHIELD];
+
+ if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
+ {
+ // intrinsic armour abilities
+ switch (mitm[armour].sub_type)
+ {
+ case ARM_ICE_DRAGON_ARMOUR: u += 2; break;
+ case ARM_GOLD_DRAGON_ARMOUR: u += 1; break;
+ case ARM_DRAGON_ARMOUR: u -= 1; break;
+ default: break;
+ }
+
+ // check ego resistance
+ const int ego = get_armour_ego_type(mitm[armour]);
+ if (ego == SPARM_COLD_RESISTANCE || ego == SPARM_RESISTANCE)
+ u += 1;
+ }
+
+ if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
+ {
+ // check ego resistance
+ const int ego = get_armour_ego_type(mitm[shield]);
+ if (ego == SPARM_COLD_RESISTANCE || ego == SPARM_RESISTANCE)
+ u += 1;
+ }
+ }
+
+ if (u < -3)
+ u = -3;
+ else if (u > 3)
+ u = 3;
+
+ return (u);
}
int monsters::res_elec() const
{
- return (mons_res_elec(this));
+ // This is a variable, not a player_xx() function, so can be above 1.
+ int u = 0;
+
+ u += get_mons_resists(this).elec;
+
+ // Don't bother checking equipment if the monster can't use it.
+ if (mons_itemuse(this) >= MONUSE_STARTING_EQUIPMENT)
+ {
+ u += _scan_mon_inv_randarts(this, ARTP_ELECTRICITY);
+
+ // No ego armour, but storm dragon.
+ const int armour = inv[MSLOT_ARMOUR];
+ if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR
+ && mitm[armour].sub_type == ARM_STORM_DRAGON_ARMOUR)
+ {
+ u += 1;
+ }
+ }
+
+ // Monsters can legitimately get multiple levels of electricity resistance.
+
+ return (u);
}
int monsters::res_asphyx() const
{
- return (mons_res_asphyx(this));
+ int res = get_mons_resists(this).asphyx;
+ const mon_holy_type holiness = mons_holiness(this);
+ if (mons_is_unholy(this)
+ || holiness == MH_NONLIVING
+ || holiness == MH_PLANT)
+ {
+ res += 1;
+ }
+ return (res);
}
int monsters::res_poison() const
{
- return (mons_res_poison(this));
+ int u = get_mons_resists(this).poison;
+
+ if (mons_itemuse(this) >= MONUSE_STARTING_EQUIPMENT)
+ {
+ u += _scan_mon_inv_randarts( this, ARTP_POISON );
+
+ const int armour = mon->inv[MSLOT_ARMOUR];
+ const int shield = mon->inv[MSLOT_SHIELD];
+
+ if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
+ {
+ // intrinsic armour abilities
+ switch (mitm[armour].sub_type)
+ {
+ case ARM_SWAMP_DRAGON_ARMOUR: u += 1; break;
+ case ARM_GOLD_DRAGON_ARMOUR: u += 1; break;
+ default: break;
+ }
+
+ // ego armour resistance
+ if (get_armour_ego_type(mitm[armour]) == SPARM_POISON_RESISTANCE)
+ u += 1;
+ }
+
+ if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
+ {
+ // ego armour resistance
+ if (get_armour_ego_type(mitm[shield]) == SPARM_POISON_RESISTANCE)
+ u += 1;
+ }
+ }
+
+ // Monsters can legitimately get multiple levels of poison resistance.
+
+ return (u);
}
int monsters::res_sticky_flame() const
{
- return (mons_res_sticky_flame(this));
+ int res = get_mons_resists(this).sticky_flame;
+ if (has_equipped(EQ_BODY_ARMOUR, ARM_MOTTLED_DRAGON_ARMOUR))
+ res += 1;
+ return (res);
}
int monsters::res_rotting() const
{
- return (mons_res_rotting(this));
+ int res = get_mons_resists(this).rotting;
+ if (mons_holiness(this) != MH_NATURAL)
+ res += 1;
+ return (res);
}
int monsters::res_holy_energy(const actor *attacker) const
@@ -6138,7 +6055,40 @@ int monsters::res_holy_energy(const actor *attacker) const
int monsters::res_negative_energy() const
{
- return (mons_res_negative_energy(this));
+ if (mons_holiness(this) != MH_NATURAL
+ || type == MONS_SHADOW_DRAGON)
+ {
+ return (3);
+ }
+
+ int u = 0;
+
+ if (mons_itemuse(this) >= MONUSE_STARTING_EQUIPMENT)
+ {
+ u += _scan_mon_inv_randarts(this, ARTP_NEGATIVE_ENERGY);
+
+ const int armour = mon->inv[MSLOT_ARMOUR];
+ const int shield = mon->inv[MSLOT_SHIELD];
+
+ if (armour != NON_ITEM && mitm[armour].base_type == OBJ_ARMOUR)
+ {
+ // check for ego resistance
+ if (get_armour_ego_type(mitm[armour]) == SPARM_POSITIVE_ENERGY)
+ u += 1;
+ }
+
+ if (shield != NON_ITEM && mitm[shield].base_type == OBJ_ARMOUR)
+ {
+ // check for ego resistance
+ if (get_armour_ego_type(mitm[shield]) == SPARM_POSITIVE_ENERGY)
+ u += 1;
+ }
+ }
+
+ if (u > 3)
+ u = 3;
+
+ return (u);
}
int monsters::res_torment() const
@@ -6154,6 +6104,11 @@ int monsters::res_torment() const
return (0);
}
+int monsters::res_acid() const
+{
+ return (get_mons_resists(this).acid);
+}
+
flight_type monsters::flight_mode() const
{
return (mons_flies(this));
@@ -7609,7 +7564,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
if (coinflip())
dam += roll_dice(1, poisonval + 1);
- if (mons_res_poison(this) < 0)
+ if (res_poison() < 0)
dam += roll_dice(2, poisonval) - 1;
if (dam > 0)
@@ -7649,7 +7604,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
break;
}
- // Assumption: mons_res_fire has already been checked.
+ // Assumption: monsters::res_fire has already been checked.
case ENCH_STICKY_FLAME:
{
if (feat_is_watery(grd(pos())))
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index b06517207c..e5bfa0f84d 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -219,7 +219,7 @@ enum mon_resist_flags
// resistances
// Notes:
- // - negative energy is mostly handled via mons_res_negative_energy()
+ // - negative energy is mostly handled via monsters::res_negative_energy()
MR_RES_ELEC = (1<< 0),
MR_RES_POISON = (1<< 1),
MR_RES_FIRE = (1<< 2),
@@ -611,18 +611,6 @@ habitat_type mons_secondary_habitat(const monsters *mon);
bool intelligent_ally(const monsters *mon);
-int mons_res_cold(const monsters *mon);
-int mons_res_elec(const monsters *mon);
-int mons_res_fire(const monsters *mon);
-int mons_res_steam(const monsters *mon);
-int mons_res_poison(const monsters *mon);
-int mons_res_asphyx(const monsters *mon);
-int mons_res_sticky_flame(const monsters *mon);
-int mons_res_rotting(const monsters *mon);
-int mons_res_acid(const monsters *mon);
-int mons_res_negative_energy(const monsters *mon);
-
-
// last updated 12may2000 {dlb}
/* ***********************************************************************
* called from: dungeon - items - spells2 - spells4
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index 27ac976b07..30fac86595 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -293,6 +293,7 @@ public:
int res_holy_energy(const actor *) const;
int res_negative_energy() const;
int res_torment() const;
+ int res_acid() const;
flight_type flight_mode() const;
bool is_levitating() const;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 77bdebd4e3..176338c4ad 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -5488,17 +5488,17 @@ bool mons_avoids_cloud(const monsters *monster, cloud_struct cloud,
{
case CLOUD_MIASMA:
// Even the dumbest monsters will avoid miasma if they can.
- return (!mons_res_rotting(monster));
+ return (!monster->res_rotting());
case CLOUD_FIRE:
case CLOUD_FOREST_FIRE:
- if (mons_res_fire(monster) > 1)
+ if (monster->res_fire() > 1)
return (false);
if (extra_careful)
return (true);
- if (mons_intel(monster) >= I_ANIMAL && mons_res_fire(monster) < 0)
+ if (mons_intel(monster) >= I_ANIMAL && monster->res_fire() < 0)
return (true);
if (monster->hit_points >= 15 + random2avg(46, 5))
@@ -5506,13 +5506,13 @@ bool mons_avoids_cloud(const monsters *monster, cloud_struct cloud,
break;
case CLOUD_STINK:
- if (mons_res_poison(monster) > 0)
+ if (monster->res_poison() > 0)
return (false);
if (extra_careful)
return (true);
- if (mons_intel(monster) >= I_ANIMAL && mons_res_poison(monster) < 0)
+ if (mons_intel(monster) >= I_ANIMAL && monster->res_poison() < 0)
return (true);
if (x_chance_in_y(monster->hit_dice - 1, 5))
@@ -5523,13 +5523,13 @@ bool mons_avoids_cloud(const monsters *monster, cloud_struct cloud,
break;
case CLOUD_COLD:
- if (mons_res_cold(monster) > 1)
+ if (monster->res_cold() > 1)
return (false);
if (extra_careful)
return (true);
- if (mons_intel(monster) >= I_ANIMAL && mons_res_cold(monster) < 0)
+ if (mons_intel(monster) >= I_ANIMAL && monster->res_cold() < 0)
return (true);
if (monster->hit_points >= 15 + random2avg(46, 5))
@@ -5537,13 +5537,13 @@ bool mons_avoids_cloud(const monsters *monster, cloud_struct cloud,
break;
case CLOUD_POISON:
- if (mons_res_poison(monster) > 0)
+ if (monster->res_poison() > 0)
return (false);
if (extra_careful)
return (true);
- if (mons_intel(monster) >= I_ANIMAL && mons_res_poison(monster) < 0)
+ if (mons_intel(monster) >= I_ANIMAL && monster->res_poison() < 0)
return (true);
if (monster->hit_points >= random2avg(37, 4))
@@ -5558,7 +5558,7 @@ bool mons_avoids_cloud(const monsters *monster, cloud_struct cloud,
if (mons_intel(monster) > I_ANIMAL || coinflip())
return (false);
- if (mons_res_fire(monster) > 0)
+ if (monster->res_fire() > 0)
return (false);
if (monster->hit_points >= random2avg(19, 2))
@@ -8579,7 +8579,7 @@ void mons_check_pool(monsters *monster, const coord_def &oldpos,
grid == DNGN_LAVA ? "lava" : "water");
}
- if (grid == DNGN_LAVA && mons_res_fire(monster) >= 2)
+ if (grid == DNGN_LAVA && monster->res_fire() >= 2)
grid = DNGN_DEEP_WATER;
// Even fire resistant monsters perish in lava, but inanimate
@@ -9428,7 +9428,7 @@ static void _mons_in_cloud(monsters *monster)
case CLOUD_STINK:
simple_monster_message(monster, " is engulfed in noxious gasses!");
- if (mons_res_poison(monster) > 0)
+ if (monster->res_poison() > 0)
return;
beam.flavour = BEAM_CONFUSION;
@@ -9461,7 +9461,7 @@ static void _mons_in_cloud(monsters *monster)
case CLOUD_POISON:
simple_monster_message(monster, " is engulfed in a cloud of poison!");
- if (mons_res_poison(monster) > 0)
+ if (monster->res_poison() > 0)
return;
poison_monster(monster, cloud.whose);
@@ -9470,7 +9470,7 @@ static void _mons_in_cloud(monsters *monster)
hurted += (random2(8) * 10) / speed;
- if (mons_res_poison(monster) < 0)
+ if (monster->res_poison() < 0)
hurted += (random2(4) * 10) / speed;
break;
@@ -9495,7 +9495,7 @@ static void _mons_in_cloud(monsters *monster)
case CLOUD_MIASMA:
simple_monster_message(monster, " is engulfed in a dark miasma!");
- if (mons_res_rotting(monster))
+ if (monster->res_rotting())
return;
miasma_monster(monster, cloud.whose);
@@ -9523,7 +9523,7 @@ static void _mons_in_cloud(monsters *monster)
// mutate, aren't res asphyx, and pass the same check as meph cloud.
if (monster->can_mutate() && !mons_immune_magic(monster)
&& 1 + random2(27) >= monster->hit_dice
- && !mons_res_asphyx(monster))
+ && !monster->res_asphyx())
{
if (monster->mutate())
wake = true;
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 64d2f9190c..1620868e1c 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -1646,7 +1646,7 @@ static bool _tso_blessing_holy_wpn(monsters* mon)
static bool _tso_blessing_holy_arm(monsters* mon)
{
// If a monster has full negative energy resistance, get out.
- if (mons_res_negative_energy(mon) == 3)
+ if (mon->res_negative_energy() == 3)
return (false);
// Pick either a monster's armour or its shield.
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index ea96dd9595..a1ea78180f 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -681,7 +681,7 @@ void drain_life(int pow)
if (!monster->alive()
|| mons_holiness(monster) != MH_NATURAL
- || mons_res_negative_energy(monster))
+ || monster->res_negative_energy())
{
continue;
}
@@ -754,7 +754,7 @@ bool vampiric_drain(int pow, const dist &vmove)
}
if (mons_holiness(monster) != MH_NATURAL
- || mons_res_negative_energy(monster))
+ || monster->res_negative_energy())
{
canned_msg(MSG_NOTHING_HAPPENS);
return (false);
@@ -842,7 +842,7 @@ bool burn_freeze(int pow, beam_type flavour, monsters *monster)
if (flavour == BEAM_COLD)
{
- const int cold_res = mons_res_cold( monster );
+ const int cold_res = monster->res_cold();
if (cold_res <= 0)
{
const int stun = (1 - cold_res) * random2(2 + pow/5);
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index c6fb109290..3d281652b2 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -401,7 +401,7 @@ static int _sleep_monsters(coord_def where, int pow, int, actor *)
// Works on friendlies too, so no check for that.
//jmf: Now that sleep == hibernation:
- const int res = mons_res_cold(monster);
+ const int res = monster->res_cold();
if (res > 0 && one_chance_in(std::max(4 - res, 1)))
return (0);
if (monster->has_ench(ENCH_SLEEP_WARY) && !one_chance_in(3))
@@ -791,7 +791,7 @@ static int _discharge_monsters(coord_def where, int pow, int, actor *)
}
else if (monster == NULL)
return (0);
- else if (mons_res_elec(monster) > 0 || mons_flies(monster))
+ else if (monster->res_elec() > 0 || mons_flies(monster))
return (0);
else
{
@@ -1003,7 +1003,7 @@ static int _intoxicate_monsters(coord_def where, int pow, int, actor *)
if (monster == NULL
|| mons_intel(monster) < I_NORMAL
|| mons_holiness(monster) != MH_NATURAL
- || mons_res_poison(monster) > 0)
+ || monster->res_poison() > 0)
{
return 0;
}