diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-09-20 14:46:47 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-09-20 14:46:47 +0000 |
commit | d9d67a71bcda20fd3c629ba2475396a91afe0d16 (patch) | |
tree | 95b838c4c273ca823cf669c4a14df51f3bc8f09d /crawl-ref/source | |
parent | 7f87a01c11f21ffa4dbb9660268eaa88494237ae (diff) | |
download | crawl-ref-d9d67a71bcda20fd3c629ba2475396a91afe0d16.tar.gz crawl-ref-d9d67a71bcda20fd3c629ba2475396a91afe0d16.zip |
Convert asphyxiation resistance to a boolean, since you can either be
asphyxiated or not.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10742 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/externs.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 74 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 41 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 2 |
5 files changed, 68 insertions, 59 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 069d5d81b8..f6104eaa72 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -385,8 +385,8 @@ public: virtual int res_steam() const = 0; virtual int res_cold() const = 0; virtual int res_elec() const = 0; - virtual int res_asphyx() const = 0; virtual int res_poison() const = 0; + virtual int res_asphyx() const = 0; virtual int res_sticky_flame() const = 0; virtual int res_rotting() const = 0; virtual int res_holy_energy(const actor *attacker) const = 0; @@ -1112,8 +1112,8 @@ public: int res_steam() const; int res_cold() const; int res_elec() const; - int res_asphyx() const; int res_poison() const; + int res_asphyx() const; int res_sticky_flame() const; int res_rotting() const; int res_holy_energy(const actor *) const; @@ -1473,8 +1473,8 @@ public: int res_steam() const; int res_cold() const; int res_elec() const; - int res_asphyx() const; int res_poison() const; + int res_asphyx() const; int res_sticky_flame() const; int res_rotting() const; int res_holy_energy(const actor *) const; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 8bc73d39f9..a4376baa45 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1307,15 +1307,6 @@ int mons_res_elec(const monsters *mon) return (u); } -bool mons_res_asphyx(const monsters *mon) -{ - const mon_holy_type holiness = mons_holiness(mon); - return (mons_is_unholy(mon) - || holiness == MH_NONLIVING - || holiness == MH_PLANT - || get_mons_resists(mon).asphyx > 0); -} - int mons_res_acid(const monsters *mon) { return (get_mons_resists(mon).acid); @@ -1360,6 +1351,19 @@ int mons_res_poison(const monsters *mon) 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; @@ -3773,7 +3777,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 (mons_res_asphyx(this) > 0 || mons_genus(type) == MONS_MUMMY || mons_genus(type) == MONS_GHOUL || mons_genus(type) == MONS_VAMPIRE @@ -9272,9 +9276,9 @@ std::string get_mon_shape_str(const mon_body_shape shape) // mon_resist_def mon_resist_def::mon_resist_def() - : elec(0), poison(0), fire(0), steam(0), cold(0), hellfire(0), - asphyx(0), acid(0), sticky_flame(false), rotting(false), pierce(0), - slice(0), bludgeon(0) + : elec(0), poison(0), fire(0), steam(0), cold(0), hellfire(0), acid(0), + asphyx(false), sticky_flame(false), rotting(false), pierce(0), slice(0), + bludgeon(0) { } @@ -9295,9 +9299,9 @@ short mon_resist_def::get_default_res_level(int resist, short level) const } mon_resist_def::mon_resist_def(int flags, short level) - : elec(0), poison(0), fire(0), steam(0), cold(0), hellfire(0), - asphyx(0), acid(0), sticky_flame(false), rotting(false), pierce(0), - slice(0), bludgeon(0) + : elec(0), poison(0), fire(0), steam(0), cold(0), hellfire(0), acid(0), + asphyx(false), sticky_flame(false), rotting(false), pierce(0), slice(0), + bludgeon(0) { for (int i = 0; i < 32; ++i) { @@ -9305,30 +9309,30 @@ mon_resist_def::mon_resist_def(int flags, short level) switch (flags & (1 << i)) { // resistances - case MR_RES_STEAM: steam = 3; break; - case MR_RES_ELEC: elec = nl; break; - case MR_RES_POISON: poison = nl; break; - case MR_RES_FIRE: fire = nl; break; - case MR_RES_HELLFIRE: hellfire = nl; break; - case MR_RES_COLD: cold = nl; break; - case MR_RES_ASPHYX: asphyx = nl; break; - case MR_RES_ACID: acid = nl; break; + case MR_RES_STEAM: steam = 3; break; + case MR_RES_ELEC: elec = nl; break; + case MR_RES_POISON: poison = nl; break; + case MR_RES_FIRE: fire = nl; break; + case MR_RES_HELLFIRE: hellfire = nl; break; + case MR_RES_COLD: cold = nl; break; + case MR_RES_ASPHYX: asphyx = true; break; + case MR_RES_ACID: acid = nl; break; // vulnerabilities - case MR_VUL_ELEC: elec = -nl; break; - case MR_VUL_POISON: poison = -nl; break; - case MR_VUL_FIRE: fire = -nl; break; - case MR_VUL_COLD: cold = -nl; break; + case MR_VUL_ELEC: elec = -nl; break; + case MR_VUL_POISON: poison = -nl; break; + case MR_VUL_FIRE: fire = -nl; break; + case MR_VUL_COLD: cold = -nl; break; // resistance to certain damage types - case MR_RES_PIERCE: pierce = nl; break; - case MR_RES_SLICE: slice = nl; break; - case MR_RES_BLUDGEON: bludgeon = nl; break; + case MR_RES_PIERCE: pierce = nl; break; + case MR_RES_SLICE: slice = nl; break; + case MR_RES_BLUDGEON: bludgeon = nl; break; // vulnerability to certain damage types - case MR_VUL_PIERCE: pierce = -nl; break; - case MR_VUL_SLICE: slice = -nl; break; - case MR_VUL_BLUDGEON: bludgeon = -nl; break; + case MR_VUL_PIERCE: pierce = -nl; break; + case MR_VUL_SLICE: slice = -nl; break; + case MR_VUL_BLUDGEON: bludgeon = -nl; break; case MR_RES_STICKY_FLAME: sticky_flame = true; break; case MR_RES_ROTTING: rotting = true; break; @@ -9345,7 +9349,7 @@ const mon_resist_def &mon_resist_def::operator |= (const mon_resist_def &o) fire += o.fire; cold += o.cold; hellfire += o.hellfire; - asphyx += o.asphyx; + asphyx = asphyx || o.asphyx; acid += o.acid; pierce += o.pierce; slice += o.slice; diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index f871a05e5b..1754e1bd67 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -383,9 +383,9 @@ struct mon_resist_def short steam; short cold; short hellfire; - short asphyx; short acid; + bool asphyx; bool sticky_flame; bool rotting; @@ -618,12 +618,12 @@ 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); int mons_res_miasma(const monsters *mon); -bool mons_res_asphyx(const monsters *mon); // last updated 12may2000 {dlb} diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 898dfd705c..b89848114c 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1643,23 +1643,6 @@ int player_res_electricity(bool calc_unid, bool temp, bool items) return (re); } -// Does the player resist asphyxiation? -bool player_res_asphyx() -{ - // The undead are immune to asphyxiation, or so we'll assume. - if (you.is_undead) - return (true); - - switch (you.attribute[ATTR_TRANSFORMATION]) - { - case TRAN_LICH: - case TRAN_STATUE: - return (true); - } - - return (false); -} - bool player_control_teleport(bool calc_unid, bool temp, bool items) { return ((temp && you.duration[DUR_CONTROL_TELEPORT]) @@ -1731,6 +1714,28 @@ int player_res_poison(bool calc_unid, bool temp, bool items) return (rp); } +int player_res_asphyx() +{ + int ra = 0; + + // The undead are immune to asphyxiation, or so we'll assume. + if (you.is_undead) + ra++; + + switch (you.attribute[ATTR_TRANSFORMATION]) + { + case TRAN_LICH: + case TRAN_STATUE: + ra++; + break; + } + + if (ra > 1) + ra = 1; + + return (ra); +} + int player_res_sticky_flame(bool calc_unid, bool temp, bool items) { int rsf = 0; @@ -5401,7 +5406,7 @@ bool curare_hits_player(int death_source, int amount) int hurted = 0; - if (!player_res_asphyx()) + if (player_res_asphyx() > 0) { hurted = roll_dice(2, 6); diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index d88baf8747..322d962ee0 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -245,7 +245,7 @@ bool player_control_teleport(bool calc_unid = true, bool temp = true, int player_res_magic(void); -bool player_res_asphyx(); +int player_res_asphyx(); /* *********************************************************************** * called from: beam - chardump - fight - misc - output |