diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-13 12:38:31 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-13 12:38:31 +0000 |
commit | d436eeaf8f01d5e9b0476254171b6a0bcc2c403d (patch) | |
tree | 6aaf27955df1ada2cd90d4159c98afa1c9b48354 | |
parent | a09546a8bd90676ada9dbf82788321a709e6a6b0 (diff) | |
download | crawl-ref-d436eeaf8f01d5e9b0476254171b6a0bcc2c403d.tar.gz crawl-ref-d436eeaf8f01d5e9b0476254171b6a0bcc2c403d.zip |
is_orckind() and is_dragonkind() no longer duplicate their arguments.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8443 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/fight.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/misc.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/mstuff2.cc | 2 |
5 files changed, 17 insertions, 13 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 43fe5e3307..66e13428d9 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2814,7 +2814,7 @@ bool melee_attack::apply_damage_brand() break; case SPWPN_ORC_SLAYING: - if (is_orckind(defender, def)) + if (is_orckind(defender)) { special_damage = 1 + random2(3*damage_done/2); if (defender_visible) @@ -2830,7 +2830,7 @@ bool melee_attack::apply_damage_brand() break; case SPWPN_DRAGON_SLAYING: - if (is_dragonkind(defender, def)) + if (is_dragonkind(defender)) { special_damage = 1 + random2(3*damage_done/2); if (defender_visible) diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index dd5765ecf3..65ad96c77b 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -3154,22 +3154,25 @@ bool stop_attack_prompt(const monsters *mon, bool beam_attack, return (retval); } -bool is_orckind(const actor *act, const monsters *mon) +bool is_orckind(const actor *act) { if (mons_genus(act->mons_species()) == MONS_ORC) return (true); - if (act->atype() == ACT_MONSTER - && mons_is_zombified(mon) - && mons_genus(mon->base_monster) == MONS_ORC) + if (act->atype() == ACT_MONSTER) { - return (true); + const monsters* mon = dynamic_cast<const monsters*>(act); + if (mons_is_zombified(mon) + && mons_genus(mon->base_monster) == MONS_ORC) + { + return (true); + } } return (false); } -bool is_dragonkind(const actor *act, const monsters *mon) +bool is_dragonkind(const actor *act) { if (mons_genus(act->mons_species()) == MONS_DRAGON || mons_genus(act->mons_species()) == MONS_DRACONIAN) @@ -3183,6 +3186,7 @@ bool is_dragonkind(const actor *act, const monsters *mon) || you.attribute[ATTR_TRANSFORMATION] == TRAN_SERPENT_OF_HELL); } // else the actor is a monster + const monsters* mon = dynamic_cast<const monsters*>(act); if (mon->type == MONS_SERPENT_OF_HELL) return (true); diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 9eb46eaf11..10ac17ed89 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -116,8 +116,8 @@ std::string your_hand(bool plural); bool stop_attack_prompt(const monsters *mon, bool beam_attack, bool beam_target); -bool is_orckind(const actor *act, const monsters *mon); +bool is_orckind(const actor *act); -bool is_dragonkind(const actor *act, const monsters *mon); +bool is_dragonkind(const actor *act); #endif diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index b508a3a54b..b22ebf5ccd 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3905,11 +3905,11 @@ bool monsters::could_wield(const item_def &item, bool ignore_brand, const int brand = get_weapon_brand(item); // Draconians won't use dragon slaying weapons. - if (brand == SPWPN_DRAGON_SLAYING && is_dragonkind(this, this)) + if (brand == SPWPN_DRAGON_SLAYING && is_dragonkind(this)) return (false); // Orcs won't use orc slaying weapons. - if (brand == SPWPN_ORC_SLAYING && is_orckind(this, this)) + if (brand == SPWPN_ORC_SLAYING && is_orckind(this)) return (false); // Demonic/undead monsters won't use holy weapons. diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index af671e5f06..28bb03ab6b 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -2201,7 +2201,7 @@ bolt mons_spells( monsters *mons, spell_type spell_cast, int power ) // FIXME: This effect is not yet implemented for player draconians // or characters in dragon form breathing at monsters wielding a // weapon with this brand. - if (is_dragonkind(mons, mons)) + if (is_dragonkind(mons)) { if (actor *foe = mons->get_foe()) { |